2 * Copyright (c) 2009, 2010 Nicira Networks.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "classifier.h"
21 #include <netinet/in.h>
22 #include "dynamic-string.h"
27 static struct cls_table *find_table(const struct classifier *,
28 const struct flow_wildcards *);
29 static struct cls_table *insert_table(struct classifier *,
30 const struct flow_wildcards *);
32 static struct cls_table *classifier_first_table(const struct classifier *);
33 static struct cls_table *classifier_next_table(const struct classifier *,
34 const struct cls_table *);
35 static void destroy_table(struct classifier *, struct cls_table *);
37 static struct cls_rule *find_match(const struct cls_table *,
39 static struct cls_rule *find_equal(struct cls_table *, const struct flow *,
41 static struct cls_rule *insert_rule(struct cls_table *, struct cls_rule *);
43 static bool flow_equal_except(const struct flow *, const struct flow *,
44 const struct flow_wildcards *);
45 static void zero_wildcards(struct flow *, const struct flow_wildcards *);
47 /* Iterates RULE over HEAD and all of the cls_rules on HEAD->list. */
48 #define FOR_EACH_RULE_IN_LIST(RULE, HEAD) \
49 for ((RULE) = (HEAD); (RULE) != NULL; (RULE) = next_rule_in_list(RULE))
50 #define FOR_EACH_RULE_IN_LIST_SAFE(RULE, NEXT, HEAD) \
51 for ((RULE) = (HEAD); \
52 (RULE) != NULL && ((NEXT) = next_rule_in_list(RULE), true); \
55 static struct cls_rule *next_rule_in_list(struct cls_rule *);
57 static struct cls_table *
58 cls_table_from_hmap_node(const struct hmap_node *node)
60 return node ? CONTAINER_OF(node, struct cls_table, hmap_node) : NULL;
63 /* Converts the flow in 'flow' into a cls_rule in 'rule', with the given
64 * 'wildcards' and 'priority'. */
66 cls_rule_init(const struct flow *flow, const struct flow_wildcards *wildcards,
67 unsigned int priority, struct cls_rule *rule)
70 rule->wc = *wildcards;
71 rule->priority = priority;
72 cls_rule_zero_wildcarded_fields(rule);
75 /* Converts the flow in 'flow' into an exact-match cls_rule in 'rule', with the
76 * given 'priority'. (For OpenFlow 1.0, exact-match rule are always highest
77 * priority, so 'priority' should be at least 65535.) */
79 cls_rule_init_exact(const struct flow *flow,
80 unsigned int priority, struct cls_rule *rule)
83 flow_wildcards_init_exact(&rule->wc);
84 rule->priority = priority;
87 /* Converts the ofp_match in 'match' (with format 'flow_format', one of NXFF_*)
88 * into a cls_rule in 'rule', with the given 'priority'. 'cookie' is used
89 * when 'flow_format' is NXFF_TUN_ID_FROM_COOKIE. */
91 cls_rule_from_match(const struct ofp_match *match, unsigned int priority,
92 int flow_format, uint64_t cookie,
93 struct cls_rule *rule)
95 flow_from_match(match, flow_format, cookie, &rule->flow, &rule->wc);
96 rule->priority = !rule->wc.wildcards ? UINT16_MAX : priority;
97 cls_rule_zero_wildcarded_fields(rule);
100 /* Initializes 'rule' as a "catch-all" rule that matches every packet, with
101 * priority 'priority'. */
103 cls_rule_init_catchall(struct cls_rule *rule, unsigned int priority)
105 memset(&rule->flow, 0, sizeof rule->flow);
106 flow_wildcards_init(&rule->wc, OVSFW_ALL | FWW_ALL);
107 rule->priority = priority;
110 /* For each bit or field wildcarded in 'rule', sets the corresponding bit or
111 * field in 'flow' to all-0-bits. It is important to maintain this invariant
112 * in a clr_rule that might be inserted into a classifier.
114 * It is never necessary to call this function directly for a cls_rule that is
115 * initialized or modified only by cls_rule_*() functions. It is useful to
116 * restore the invariant in a cls_rule whose 'wc' member is modified by hand.
119 cls_rule_zero_wildcarded_fields(struct cls_rule *rule)
121 zero_wildcards(&rule->flow, &rule->wc);
125 cls_rule_set_in_port(struct cls_rule *rule, uint16_t odp_port)
127 rule->wc.wildcards &= ~OFPFW_IN_PORT;
128 rule->flow.in_port = odp_port;
132 cls_rule_set_dl_type(struct cls_rule *rule, ovs_be16 dl_type)
134 rule->wc.wildcards &= ~OFPFW_DL_TYPE;
135 rule->flow.dl_type = dl_type;
139 cls_rule_set_dl_src(struct cls_rule *rule, const uint8_t dl_src[ETH_ADDR_LEN])
141 rule->wc.wildcards &= ~OFPFW_DL_SRC;
142 memcpy(rule->flow.dl_src, dl_src, ETH_ADDR_LEN);
146 cls_rule_set_dl_dst(struct cls_rule *rule, const uint8_t dl_dst[ETH_ADDR_LEN])
148 rule->wc.wildcards &= ~(OFPFW_DL_DST | FWW_ETH_MCAST);
149 memcpy(rule->flow.dl_dst, dl_dst, ETH_ADDR_LEN);
153 cls_rule_set_dl_tci(struct cls_rule *rule, ovs_be16 tci)
155 return cls_rule_set_dl_tci_masked(rule, tci, htons(0xffff));
159 cls_rule_set_dl_tci_masked(struct cls_rule *rule, ovs_be16 tci, ovs_be16 mask)
161 switch (ntohs(mask)) {
163 if (tci == htons(0)) {
164 /* Match only packets that have no 802.1Q header. */
165 rule->wc.wildcards &= ~(OFPFW_DL_VLAN | OFPFW_DL_VLAN_PCP);
166 rule->flow.dl_vlan = htons(OFP_VLAN_NONE);
167 rule->flow.dl_vlan_pcp = 0;
169 } else if (tci & htons(VLAN_CFI)) {
170 /* Match only packets that have a specific 802.1Q VID and PCP. */
171 rule->wc.wildcards &= ~(OFPFW_DL_VLAN | OFPFW_DL_VLAN_PCP);
172 rule->flow.dl_vlan = htons(vlan_tci_to_vid(tci));
173 rule->flow.dl_vlan_pcp = vlan_tci_to_pcp(tci);
181 if (!(tci & htons(VLAN_CFI))) {
184 /* Match only packets that have a specific 802.1Q VID. */
185 cls_rule_set_dl_vlan(rule, tci & htons(VLAN_VID_MASK));
186 rule->wc.wildcards |= OFPFW_DL_VLAN_PCP;
187 rule->flow.dl_vlan_pcp = 0;
192 if (!(tci & htons(VLAN_CFI))) {
195 /* Match only packets that have a specific 802.1Q PCP. */
196 cls_rule_set_dl_vlan_pcp(rule, vlan_tci_to_pcp(tci));
197 rule->wc.wildcards |= OFPFW_DL_VLAN;
198 rule->flow.dl_vlan = 0;
203 /* Match anything. */
204 rule->wc.wildcards |= OFPFW_DL_VLAN | OFPFW_DL_VLAN_PCP;
205 rule->flow.dl_vlan = htons(0);
206 rule->flow.dl_vlan_pcp = 0;
215 cls_rule_set_dl_vlan(struct cls_rule *rule, ovs_be16 dl_vlan)
217 if (dl_vlan != htons(OFP_VLAN_NONE)) {
218 dl_vlan &= htons(VLAN_VID_MASK);
221 rule->wc.wildcards &= ~OFPFW_DL_VLAN;
222 rule->flow.dl_vlan = dl_vlan;
226 cls_rule_set_dl_vlan_pcp(struct cls_rule *rule, uint8_t dl_vlan_pcp)
228 rule->wc.wildcards &= ~OFPFW_DL_VLAN_PCP;
229 rule->flow.dl_vlan_pcp = dl_vlan_pcp & 0x07;
233 cls_rule_set_tp_src(struct cls_rule *rule, ovs_be16 tp_src)
235 rule->wc.wildcards &= ~OFPFW_TP_SRC;
236 rule->flow.tp_src = tp_src;
240 cls_rule_set_tp_dst(struct cls_rule *rule, ovs_be16 tp_dst)
242 rule->wc.wildcards &= ~OFPFW_TP_DST;
243 rule->flow.tp_dst = tp_dst;
247 cls_rule_set_nw_proto(struct cls_rule *rule, uint8_t nw_proto)
249 rule->wc.wildcards &= ~OFPFW_NW_PROTO;
250 rule->flow.nw_proto = nw_proto;
254 cls_rule_set_nw_src(struct cls_rule *rule, ovs_be32 nw_src)
256 cls_rule_set_nw_src_masked(rule, nw_src, htonl(UINT32_MAX));
260 cls_rule_set_nw_src_masked(struct cls_rule *rule, ovs_be32 ip, ovs_be32 mask)
262 if (flow_wildcards_set_nw_src_mask(&rule->wc, mask)) {
263 rule->flow.nw_src = ip & mask;
271 cls_rule_set_nw_dst(struct cls_rule *rule, ovs_be32 nw_dst)
273 cls_rule_set_nw_dst_masked(rule, nw_dst, htonl(UINT32_MAX));
277 cls_rule_set_nw_dst_masked(struct cls_rule *rule, ovs_be32 ip, ovs_be32 mask)
279 if (flow_wildcards_set_nw_dst_mask(&rule->wc, mask)) {
280 rule->flow.nw_dst = ip & mask;
288 cls_rule_set_nw_tos(struct cls_rule *rule, uint8_t nw_tos)
290 rule->wc.wildcards &= ~OFPFW_NW_TOS;
291 rule->flow.nw_tos = nw_tos & IP_DSCP_MASK;
295 cls_rule_set_icmp_type(struct cls_rule *rule, uint8_t icmp_type)
297 rule->wc.wildcards &= ~OFPFW_ICMP_TYPE;
298 rule->flow.icmp_type = htons(icmp_type);
303 cls_rule_set_icmp_code(struct cls_rule *rule, uint8_t icmp_code)
305 rule->wc.wildcards &= ~OFPFW_ICMP_CODE;
306 rule->flow.icmp_code = htons(icmp_code);
309 /* Converts 'rule' to a string and returns the string. The caller must free
310 * the string (with free()). */
312 cls_rule_to_string(const struct cls_rule *rule)
314 struct ds s = DS_EMPTY_INITIALIZER;
315 ds_put_format(&s, "wildcards=%x priority=%u ",
316 rule->wc.wildcards, rule->priority);
317 flow_format(&s, &rule->flow);
321 /* Prints cls_rule 'rule', for debugging.
323 * (The output could be improved and expanded, but this was good enough to
324 * debug the classifier.) */
326 cls_rule_print(const struct cls_rule *rule)
328 printf("wildcards=%x priority=%u ", rule->wc.wildcards, rule->priority);
329 flow_print(stdout, &rule->flow);
333 /* Initializes 'cls' as a classifier that initially contains no classification
336 classifier_init(struct classifier *cls)
339 hmap_init(&cls->tables);
342 /* Destroys 'cls'. Rules within 'cls', if any, are not freed; this is the
343 * caller's responsibility. */
345 classifier_destroy(struct classifier *cls)
348 struct cls_table *table, *next_table;
350 HMAP_FOR_EACH_SAFE (table, next_table, hmap_node, &cls->tables) {
351 hmap_destroy(&table->rules);
352 hmap_remove(&cls->tables, &table->hmap_node);
355 hmap_destroy(&cls->tables);
359 /* Returns true if 'cls' contains no classification rules, false otherwise. */
361 classifier_is_empty(const struct classifier *cls)
363 return cls->n_rules == 0;
366 /* Returns the number of rules in 'classifier'. */
368 classifier_count(const struct classifier *cls)
373 /* Inserts 'rule' into 'cls'. Until 'rule' is removed from 'cls', the caller
374 * must not modify or free it.
376 * If 'cls' already contains an identical rule (including wildcards, values of
377 * fixed fields, and priority), replaces the old rule by 'rule' and returns the
378 * rule that was replaced. The caller takes ownership of the returned rule and
379 * is thus responsible for freeing it, etc., as necessary.
381 * Returns NULL if 'cls' does not contain a rule with an identical key, after
382 * inserting the new rule. In this case, no rules are displaced by the new
383 * rule, even rules that cannot have any effect because the new rule matches a
384 * superset of their flows and has higher priority. */
386 classifier_insert(struct classifier *cls, struct cls_rule *rule)
388 struct cls_rule *old_rule;
389 struct cls_table *table;
391 table = find_table(cls, &rule->wc);
393 table = insert_table(cls, &rule->wc);
396 old_rule = insert_rule(table, rule);
398 table->n_table_rules++;
404 /* Removes 'rule' from 'cls'. It is the caller's responsibility to free
405 * 'rule', if this is desirable. */
407 classifier_remove(struct classifier *cls, struct cls_rule *rule)
409 struct cls_rule *head;
410 struct cls_table *table;
412 table = find_table(cls, &rule->wc);
413 head = find_equal(table, &rule->flow, rule->hmap_node.hash);
415 list_remove(&rule->list);
416 } else if (list_is_empty(&rule->list)) {
417 hmap_remove(&table->rules, &rule->hmap_node);
419 struct cls_rule *next = CONTAINER_OF(rule->list.next,
420 struct cls_rule, list);
422 list_remove(&rule->list);
423 hmap_replace(&table->rules, &rule->hmap_node, &next->hmap_node);
426 if (--table->n_table_rules == 0 && !table->n_refs) {
427 destroy_table(cls, table);
433 /* Finds and returns the highest-priority rule in 'cls' that matches 'flow'.
434 * Returns a null pointer if no rules in 'cls' match 'flow'. If multiple rules
435 * of equal priority match 'flow', returns one arbitrarily. */
437 classifier_lookup(const struct classifier *cls, const struct flow *flow)
439 struct cls_table *table;
440 struct cls_rule *best;
443 HMAP_FOR_EACH (table, hmap_node, &cls->tables) {
444 struct cls_rule *rule = find_match(table, flow);
445 if (rule && (!best || rule->priority > best->priority)) {
452 /* Finds and returns a rule in 'cls' with exactly the same priority and
453 * matching criteria as 'target'. Returns a null pointer if 'cls' doesn't
454 * contain an exact match.
456 * Priority is ignored for exact-match rules (because OpenFlow 1.0 always
457 * treats exact-match rules as highest priority). */
459 classifier_find_rule_exactly(const struct classifier *cls,
460 const struct cls_rule *target)
462 struct cls_rule *head, *rule;
463 struct cls_table *table;
465 table = find_table(cls, &target->wc);
470 head = find_equal(table, &target->flow, flow_hash(&target->flow, 0));
471 if (!target->wc.wildcards) {
474 FOR_EACH_RULE_IN_LIST (rule, head) {
475 if (target->priority >= rule->priority) {
476 return target->priority == rule->priority ? rule : NULL;
482 /* Checks if 'target' would overlap any other rule in 'cls'. Two rules are
483 * considered to overlap if both rules have the same priority and a packet
484 * could match both. */
486 classifier_rule_overlaps(const struct classifier *cls,
487 const struct cls_rule *target)
489 struct cls_table *table;
491 HMAP_FOR_EACH (table, hmap_node, &cls->tables) {
492 struct flow_wildcards wc;
493 struct cls_rule *head;
495 flow_wildcards_combine(&wc, &target->wc, &table->wc);
496 HMAP_FOR_EACH (head, hmap_node, &table->rules) {
497 struct cls_rule *rule;
499 FOR_EACH_RULE_IN_LIST (rule, head) {
500 if (rule->priority == target->priority
501 && flow_equal_except(&target->flow, &rule->flow, &wc)) {
511 /* Searches 'cls' for rules that exactly match 'target' or are more specific
512 * than 'target'. That is, a given 'rule' matches 'target' if, for every
515 * - 'target' and 'rule' specify the same (non-wildcarded) value for the
518 * - 'target' wildcards the field,
522 * - 'target' and 'rule' specify different values for the field, or
524 * - 'target' specifies a value for the field but 'rule' wildcards it.
526 * Equivalently, the truth table for whether a field matches is:
531 * +---------+---------+
532 * t wild | yes | yes |
534 * r +---------+---------+
535 * g exact | no |if values|
537 * t +---------+---------+
539 * This is the matching rule used by OpenFlow 1.0 non-strict OFPT_FLOW_MOD
540 * commands and by OpenFlow 1.0 aggregate and flow stats.
542 * Ignores target->priority.
544 * 'callback' is allowed to delete the rule that is passed as its argument, but
545 * it must not delete (or move) any other rules in 'cls' that have the same
546 * wildcards as the argument rule. */
548 classifier_for_each_match(const struct classifier *cls_,
549 const struct cls_rule *target,
550 cls_cb_func *callback, void *aux)
552 struct classifier *cls = (struct classifier *) cls_;
553 struct cls_table *table, *next_table;
555 for (table = classifier_first_table(cls); table; table = next_table) {
556 if (!flow_wildcards_has_extra(&table->wc, &target->wc)) {
557 /* We have eliminated the "no" case in the truth table above. Two
558 * of the three remaining cases are trivial. We only need to check
559 * the fourth case, where both 'rule' and 'target' require an exact
561 struct cls_rule *head, *next_head;
564 HMAP_FOR_EACH_SAFE (head, next_head, hmap_node, &table->rules) {
565 if (flow_equal_except(&head->flow, &target->flow,
567 struct cls_rule *rule, *next_rule;
569 FOR_EACH_RULE_IN_LIST_SAFE (rule, next_rule, head) {
574 next_table = classifier_next_table(cls, table);
575 if (!--table->n_refs && !table->n_table_rules) {
576 destroy_table(cls, table);
579 next_table = classifier_next_table(cls, table);
584 /* 'callback' is allowed to delete the rule that is passed as its argument, but
585 * it must not delete (or move) any other rules in 'cls' that have the same
586 * wildcards as the argument rule. */
588 classifier_for_each(const struct classifier *cls_,
589 cls_cb_func *callback, void *aux)
591 struct classifier *cls = (struct classifier *) cls_;
592 struct cls_table *table, *next_table;
594 for (table = classifier_first_table(cls); table; table = next_table) {
595 struct cls_rule *head, *next_head;
598 HMAP_FOR_EACH_SAFE (head, next_head, hmap_node, &table->rules) {
599 struct cls_rule *rule, *next_rule;
601 FOR_EACH_RULE_IN_LIST_SAFE (rule, next_rule, head) {
605 next_table = classifier_next_table(cls, table);
606 if (!--table->n_refs && !table->n_table_rules) {
607 destroy_table(cls, table);
612 static struct cls_table *
613 find_table(const struct classifier *cls, const struct flow_wildcards *wc)
615 struct cls_table *table;
617 HMAP_FOR_EACH_IN_BUCKET (table, hmap_node, flow_wildcards_hash(wc),
619 if (flow_wildcards_equal(wc, &table->wc)) {
626 static struct cls_table *
627 insert_table(struct classifier *cls, const struct flow_wildcards *wc)
629 struct cls_table *table;
631 table = xzalloc(sizeof *table);
632 hmap_init(&table->rules);
634 hmap_insert(&cls->tables, &table->hmap_node, flow_wildcards_hash(wc));
639 static struct cls_table *
640 classifier_first_table(const struct classifier *cls)
642 return cls_table_from_hmap_node(hmap_first(&cls->tables));
645 static struct cls_table *
646 classifier_next_table(const struct classifier *cls,
647 const struct cls_table *table)
649 return cls_table_from_hmap_node(hmap_next(&cls->tables,
654 destroy_table(struct classifier *cls, struct cls_table *table)
656 hmap_remove(&cls->tables, &table->hmap_node);
657 hmap_destroy(&table->rules);
661 static struct cls_rule *
662 find_match(const struct cls_table *table, const struct flow *flow)
664 struct cls_rule *rule;
668 zero_wildcards(&f, &table->wc);
669 HMAP_FOR_EACH_WITH_HASH (rule, hmap_node, flow_hash(&f, 0),
671 if (flow_equal(&f, &rule->flow)) {
678 static struct cls_rule *
679 find_equal(struct cls_table *table, const struct flow *flow, uint32_t hash)
681 struct cls_rule *head;
683 HMAP_FOR_EACH_WITH_HASH (head, hmap_node, hash, &table->rules) {
684 if (flow_equal(&head->flow, flow)) {
691 static struct cls_rule *
692 insert_rule(struct cls_table *table, struct cls_rule *new)
694 struct cls_rule *head;
696 new->hmap_node.hash = flow_hash(&new->flow, 0);
698 head = find_equal(table, &new->flow, new->hmap_node.hash);
700 hmap_insert(&table->rules, &new->hmap_node, new->hmap_node.hash);
701 list_init(&new->list);
704 /* Scan the list for the insertion point that will keep the list in
705 * order of decreasing priority. */
706 struct cls_rule *rule;
707 FOR_EACH_RULE_IN_LIST (rule, head) {
708 if (new->priority >= rule->priority) {
710 /* 'new' is the new highest-priority flow in the list. */
711 hmap_replace(&table->rules,
712 &rule->hmap_node, &new->hmap_node);
715 if (new->priority == rule->priority) {
716 list_replace(&new->list, &rule->list);
719 list_insert(&rule->list, &new->list);
725 /* Insert 'new' at the end of the list. */
726 list_push_back(&head->list, &new->list);
731 static struct cls_rule *
732 next_rule_in_list(struct cls_rule *rule)
734 struct cls_rule *next = OBJECT_CONTAINING(rule->list.next, next, list);
735 return next->priority < rule->priority ? next : NULL;
739 flow_equal_except(const struct flow *a, const struct flow *b,
740 const struct flow_wildcards *wildcards)
742 const uint32_t wc = wildcards->wildcards;
745 BUILD_ASSERT_DECL(FLOW_SIG_SIZE == 37 + FLOW_N_REGS * 4);
747 for (i = 0; i < FLOW_N_REGS; i++) {
748 if ((a->regs[i] ^ b->regs[i]) & wildcards->reg_masks[i]) {
753 return ((wc & NXFW_TUN_ID || a->tun_id == b->tun_id)
754 && !((a->nw_src ^ b->nw_src) & wildcards->nw_src_mask)
755 && !((a->nw_dst ^ b->nw_dst) & wildcards->nw_dst_mask)
756 && (wc & OFPFW_IN_PORT || a->in_port == b->in_port)
757 && (wc & OFPFW_DL_VLAN || a->dl_vlan == b->dl_vlan)
758 && (wc & OFPFW_DL_TYPE || a->dl_type == b->dl_type)
759 && (wc & OFPFW_TP_SRC || a->tp_src == b->tp_src)
760 && (wc & OFPFW_TP_DST || a->tp_dst == b->tp_dst)
761 && (wc & OFPFW_DL_SRC || eth_addr_equals(a->dl_src, b->dl_src))
762 && (wc & OFPFW_DL_DST
763 || (!((a->dl_dst[0] ^ b->dl_dst[0]) & 0xfe)
764 && a->dl_dst[1] == b->dl_dst[1]
765 && a->dl_dst[2] == b->dl_dst[2]
766 && a->dl_dst[3] == b->dl_dst[3]
767 && a->dl_dst[4] == b->dl_dst[4]
768 && a->dl_dst[5] == b->dl_dst[5]))
769 && (wc & FWW_ETH_MCAST || !((a->dl_dst[0] ^ b->dl_dst[0]) & 0x01))
770 && (wc & OFPFW_NW_PROTO || a->nw_proto == b->nw_proto)
771 && (wc & OFPFW_DL_VLAN_PCP || a->dl_vlan_pcp == b->dl_vlan_pcp)
772 && (wc & OFPFW_NW_TOS || a->nw_tos == b->nw_tos));
776 zero_wildcards(struct flow *flow, const struct flow_wildcards *wildcards)
778 const uint32_t wc = wildcards->wildcards;
781 BUILD_ASSERT_DECL(FLOW_SIG_SIZE == 37 + 4 * FLOW_N_REGS);
783 for (i = 0; i < FLOW_N_REGS; i++) {
784 flow->regs[i] &= wildcards->reg_masks[i];
786 if (wc & NXFW_TUN_ID) {
789 flow->nw_src &= wildcards->nw_src_mask;
790 flow->nw_dst &= wildcards->nw_dst_mask;
791 if (wc & OFPFW_IN_PORT) {
794 if (wc & OFPFW_DL_VLAN) {
797 if (wc & OFPFW_DL_TYPE) {
800 if (wc & OFPFW_TP_SRC) {
803 if (wc & OFPFW_TP_DST) {
806 if (wc & OFPFW_DL_SRC) {
807 memset(flow->dl_src, 0, sizeof flow->dl_src);
809 if (wc & OFPFW_DL_DST) {
810 flow->dl_dst[0] &= 0x01;
811 memset(&flow->dl_dst[1], 0, 5);
813 if (wc & FWW_ETH_MCAST) {
814 flow->dl_dst[0] &= 0xfe;
816 if (wc & OFPFW_NW_PROTO) {
819 if (wc & OFPFW_DL_VLAN_PCP) {
820 flow->dl_vlan_pcp = 0;
822 if (wc & OFPFW_NW_TOS) {