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 "byte-order.h"
23 #include "dynamic-string.h"
29 static struct cls_table *find_table(const struct classifier *,
30 const struct flow_wildcards *);
31 static struct cls_table *insert_table(struct classifier *,
32 const struct flow_wildcards *);
34 static struct cls_table *classifier_first_table(const struct classifier *);
35 static struct cls_table *classifier_next_table(const struct classifier *,
36 const struct cls_table *);
37 static void destroy_table(struct classifier *, struct cls_table *);
39 static struct cls_rule *find_match(const struct cls_table *,
41 static struct cls_rule *find_equal(struct cls_table *, const struct flow *,
43 static struct cls_rule *insert_rule(struct cls_table *, struct cls_rule *);
45 static bool flow_equal_except(const struct flow *, const struct flow *,
46 const struct flow_wildcards *);
47 static void zero_wildcards(struct flow *, const struct flow_wildcards *);
49 /* Iterates RULE over HEAD and all of the cls_rules on HEAD->list. */
50 #define FOR_EACH_RULE_IN_LIST(RULE, HEAD) \
51 for ((RULE) = (HEAD); (RULE) != NULL; (RULE) = next_rule_in_list(RULE))
52 #define FOR_EACH_RULE_IN_LIST_SAFE(RULE, NEXT, HEAD) \
53 for ((RULE) = (HEAD); \
54 (RULE) != NULL && ((NEXT) = next_rule_in_list(RULE), true); \
57 static struct cls_rule *next_rule_in_list__(struct cls_rule *);
58 static struct cls_rule *next_rule_in_list(struct cls_rule *);
60 static struct cls_table *
61 cls_table_from_hmap_node(const struct hmap_node *node)
63 return node ? CONTAINER_OF(node, struct cls_table, hmap_node) : NULL;
66 /* Converts the flow in 'flow' into a cls_rule in 'rule', with the given
67 * 'wildcards' and 'priority'. */
69 cls_rule_init(const struct flow *flow, const struct flow_wildcards *wildcards,
70 unsigned int priority, struct cls_rule *rule)
73 rule->wc = *wildcards;
74 rule->priority = priority;
75 cls_rule_zero_wildcarded_fields(rule);
78 /* Converts the flow in 'flow' into an exact-match cls_rule in 'rule', with the
79 * given 'priority'. (For OpenFlow 1.0, exact-match rule are always highest
80 * priority, so 'priority' should be at least 65535.) */
82 cls_rule_init_exact(const struct flow *flow,
83 unsigned int priority, struct cls_rule *rule)
86 flow_wildcards_init_exact(&rule->wc);
87 rule->priority = priority;
90 /* Initializes 'rule' as a "catch-all" rule that matches every packet, with
91 * priority 'priority'. */
93 cls_rule_init_catchall(struct cls_rule *rule, unsigned int priority)
95 memset(&rule->flow, 0, sizeof rule->flow);
96 flow_wildcards_init_catchall(&rule->wc);
97 rule->priority = priority;
100 /* For each bit or field wildcarded in 'rule', sets the corresponding bit or
101 * field in 'flow' to all-0-bits. It is important to maintain this invariant
102 * in a clr_rule that might be inserted into a classifier.
104 * It is never necessary to call this function directly for a cls_rule that is
105 * initialized or modified only by cls_rule_*() functions. It is useful to
106 * restore the invariant in a cls_rule whose 'wc' member is modified by hand.
109 cls_rule_zero_wildcarded_fields(struct cls_rule *rule)
111 zero_wildcards(&rule->flow, &rule->wc);
115 cls_rule_set_in_port(struct cls_rule *rule, uint16_t odp_port)
117 rule->wc.wildcards &= ~FWW_IN_PORT;
118 rule->flow.in_port = odp_port;
122 cls_rule_set_dl_type(struct cls_rule *rule, ovs_be16 dl_type)
124 rule->wc.wildcards &= ~FWW_DL_TYPE;
125 rule->flow.dl_type = dl_type;
129 cls_rule_set_dl_src(struct cls_rule *rule, const uint8_t dl_src[ETH_ADDR_LEN])
131 rule->wc.wildcards &= ~FWW_DL_SRC;
132 memcpy(rule->flow.dl_src, dl_src, ETH_ADDR_LEN);
136 cls_rule_set_dl_dst(struct cls_rule *rule, const uint8_t dl_dst[ETH_ADDR_LEN])
138 rule->wc.wildcards &= ~(FWW_DL_DST | FWW_ETH_MCAST);
139 memcpy(rule->flow.dl_dst, dl_dst, ETH_ADDR_LEN);
143 cls_rule_set_dl_tci(struct cls_rule *rule, ovs_be16 tci)
145 return cls_rule_set_dl_tci_masked(rule, tci, htons(0xffff));
149 cls_rule_set_dl_tci_masked(struct cls_rule *rule, ovs_be16 tci, ovs_be16 mask)
151 switch (ntohs(mask)) {
153 if (tci == htons(0)) {
154 /* Match only packets that have no 802.1Q header. */
155 rule->wc.wildcards &= ~(FWW_DL_VLAN | FWW_DL_VLAN_PCP);
156 rule->flow.dl_vlan = htons(OFP_VLAN_NONE);
157 rule->flow.dl_vlan_pcp = 0;
159 } else if (tci & htons(VLAN_CFI)) {
160 /* Match only packets that have a specific 802.1Q VID and PCP. */
161 rule->wc.wildcards &= ~(FWW_DL_VLAN | FWW_DL_VLAN_PCP);
162 rule->flow.dl_vlan = htons(vlan_tci_to_vid(tci));
163 rule->flow.dl_vlan_pcp = vlan_tci_to_pcp(tci);
171 if (!(tci & htons(VLAN_CFI))) {
174 /* Match only packets that have a specific 802.1Q VID. */
175 cls_rule_set_dl_vlan(rule, tci & htons(VLAN_VID_MASK));
176 rule->wc.wildcards |= FWW_DL_VLAN_PCP;
177 rule->flow.dl_vlan_pcp = 0;
182 if (!(tci & htons(VLAN_CFI))) {
185 /* Match only packets that have a specific 802.1Q PCP. */
186 cls_rule_set_dl_vlan_pcp(rule, vlan_tci_to_pcp(tci));
187 rule->wc.wildcards |= FWW_DL_VLAN;
188 rule->flow.dl_vlan = 0;
193 /* Match anything. */
194 rule->wc.wildcards |= FWW_DL_VLAN | FWW_DL_VLAN_PCP;
195 rule->flow.dl_vlan = htons(0);
196 rule->flow.dl_vlan_pcp = 0;
205 cls_rule_set_dl_vlan(struct cls_rule *rule, ovs_be16 dl_vlan)
207 if (dl_vlan != htons(OFP_VLAN_NONE)) {
208 dl_vlan &= htons(VLAN_VID_MASK);
211 rule->wc.wildcards &= ~FWW_DL_VLAN;
212 rule->flow.dl_vlan = dl_vlan;
216 cls_rule_set_dl_vlan_pcp(struct cls_rule *rule, uint8_t dl_vlan_pcp)
218 rule->wc.wildcards &= ~FWW_DL_VLAN_PCP;
219 rule->flow.dl_vlan_pcp = dl_vlan_pcp & 0x07;
223 cls_rule_set_tp_src(struct cls_rule *rule, ovs_be16 tp_src)
225 rule->wc.wildcards &= ~FWW_TP_SRC;
226 rule->flow.tp_src = tp_src;
230 cls_rule_set_tp_dst(struct cls_rule *rule, ovs_be16 tp_dst)
232 rule->wc.wildcards &= ~FWW_TP_DST;
233 rule->flow.tp_dst = tp_dst;
237 cls_rule_set_nw_proto(struct cls_rule *rule, uint8_t nw_proto)
239 rule->wc.wildcards &= ~FWW_NW_PROTO;
240 rule->flow.nw_proto = nw_proto;
244 cls_rule_set_nw_src(struct cls_rule *rule, ovs_be32 nw_src)
246 cls_rule_set_nw_src_masked(rule, nw_src, htonl(UINT32_MAX));
250 cls_rule_set_nw_src_masked(struct cls_rule *rule, ovs_be32 ip, ovs_be32 mask)
252 if (flow_wildcards_set_nw_src_mask(&rule->wc, mask)) {
253 rule->flow.nw_src = ip & mask;
261 cls_rule_set_nw_dst(struct cls_rule *rule, ovs_be32 nw_dst)
263 cls_rule_set_nw_dst_masked(rule, nw_dst, htonl(UINT32_MAX));
267 cls_rule_set_nw_dst_masked(struct cls_rule *rule, ovs_be32 ip, ovs_be32 mask)
269 if (flow_wildcards_set_nw_dst_mask(&rule->wc, mask)) {
270 rule->flow.nw_dst = ip & mask;
278 cls_rule_set_nw_tos(struct cls_rule *rule, uint8_t nw_tos)
280 rule->wc.wildcards &= ~FWW_NW_TOS;
281 rule->flow.nw_tos = nw_tos & IP_DSCP_MASK;
285 cls_rule_set_icmp_type(struct cls_rule *rule, uint8_t icmp_type)
287 rule->wc.wildcards &= ~FWW_TP_SRC;
288 rule->flow.icmp_type = htons(icmp_type);
293 cls_rule_set_icmp_code(struct cls_rule *rule, uint8_t icmp_code)
295 rule->wc.wildcards &= ~FWW_TP_DST;
296 rule->flow.icmp_code = htons(icmp_code);
299 /* Returns true if 'a' and 'b' have the same priority, wildcard the same
300 * fields, and have the same values for fixed fields, otherwise false. */
302 cls_rule_equal(const struct cls_rule *a, const struct cls_rule *b)
304 return (a->priority == b->priority
305 && flow_wildcards_equal(&a->wc, &b->wc)
306 && flow_equal(&a->flow, &b->flow));
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) {
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 (flow_wildcards_is_exact(&target->wc)) {
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)) {
514 rule_matches(const struct cls_rule *rule, const struct cls_rule *target)
517 || flow_equal_except(&rule->flow, &target->flow, &target->wc));
520 static struct cls_rule *
521 search_table(const struct cls_table *table, const struct cls_rule *target)
523 if (!target || !flow_wildcards_has_extra(&table->wc, &target->wc)) {
524 struct cls_rule *rule;
526 HMAP_FOR_EACH (rule, hmap_node, &table->rules) {
527 if (rule_matches(rule, target)) {
535 /* Initializes 'cursor' for iterating through 'cls' rules that exactly match
536 * 'target' or are more specific than 'target'. That is, a given 'rule'
537 * matches 'target' if, for every field:
539 * - 'target' and 'rule' specify the same (non-wildcarded) value for the
542 * - 'target' wildcards the field,
546 * - 'target' and 'rule' specify different values for the field, or
548 * - 'target' specifies a value for the field but 'rule' wildcards it.
550 * Equivalently, the truth table for whether a field matches is:
555 * +---------+---------+
556 * t wild | yes | yes |
558 * r +---------+---------+
559 * g exact | no |if values|
561 * t +---------+---------+
563 * This is the matching rule used by OpenFlow 1.0 non-strict OFPT_FLOW_MOD
564 * commands and by OpenFlow 1.0 aggregate and flow stats.
566 * Ignores target->priority.
568 * 'target' may be NULL to iterate over every rule in 'cls'. */
570 cls_cursor_init(struct cls_cursor *cursor, const struct classifier *cls,
571 const struct cls_rule *target)
574 cursor->target = target;
577 /* Returns the first matching cls_rule in 'cursor''s iteration, or a null
578 * pointer if there are no matches. */
580 cls_cursor_first(struct cls_cursor *cursor)
582 struct cls_table *table;
584 for (table = classifier_first_table(cursor->cls); table;
585 table = classifier_next_table(cursor->cls, table)) {
586 struct cls_rule *rule = search_table(table, cursor->target);
588 cursor->table = table;
596 /* Returns the next matching cls_rule in 'cursor''s iteration, or a null
597 * pointer if there are no more matches. */
599 cls_cursor_next(struct cls_cursor *cursor, struct cls_rule *rule)
601 const struct cls_table *table;
602 struct cls_rule *next;
604 next = next_rule_in_list__(rule);
605 if (next->priority < rule->priority) {
609 /* 'next' is the head of the list, that is, the rule that is included in
610 * the table's hmap. (This is important when the classifier contains rules
611 * that differ only in priority.) */
613 HMAP_FOR_EACH_CONTINUE (rule, hmap_node, &cursor->table->rules) {
614 if (rule_matches(rule, cursor->target)) {
619 for (table = classifier_next_table(cursor->cls, cursor->table); table;
620 table = classifier_next_table(cursor->cls, table)) {
621 rule = search_table(table, cursor->target);
623 cursor->table = table;
631 static struct cls_table *
632 find_table(const struct classifier *cls, const struct flow_wildcards *wc)
634 struct cls_table *table;
636 HMAP_FOR_EACH_IN_BUCKET (table, hmap_node, flow_wildcards_hash(wc),
638 if (flow_wildcards_equal(wc, &table->wc)) {
645 static struct cls_table *
646 insert_table(struct classifier *cls, const struct flow_wildcards *wc)
648 struct cls_table *table;
650 table = xzalloc(sizeof *table);
651 hmap_init(&table->rules);
653 hmap_insert(&cls->tables, &table->hmap_node, flow_wildcards_hash(wc));
658 static struct cls_table *
659 classifier_first_table(const struct classifier *cls)
661 return cls_table_from_hmap_node(hmap_first(&cls->tables));
664 static struct cls_table *
665 classifier_next_table(const struct classifier *cls,
666 const struct cls_table *table)
668 return cls_table_from_hmap_node(hmap_next(&cls->tables,
673 destroy_table(struct classifier *cls, struct cls_table *table)
675 hmap_remove(&cls->tables, &table->hmap_node);
676 hmap_destroy(&table->rules);
680 static struct cls_rule *
681 find_match(const struct cls_table *table, const struct flow *flow)
683 struct cls_rule *rule;
687 zero_wildcards(&f, &table->wc);
688 HMAP_FOR_EACH_WITH_HASH (rule, hmap_node, flow_hash(&f, 0),
690 if (flow_equal(&f, &rule->flow)) {
697 static struct cls_rule *
698 find_equal(struct cls_table *table, const struct flow *flow, uint32_t hash)
700 struct cls_rule *head;
702 HMAP_FOR_EACH_WITH_HASH (head, hmap_node, hash, &table->rules) {
703 if (flow_equal(&head->flow, flow)) {
710 static struct cls_rule *
711 insert_rule(struct cls_table *table, struct cls_rule *new)
713 struct cls_rule *head;
715 new->hmap_node.hash = flow_hash(&new->flow, 0);
717 head = find_equal(table, &new->flow, new->hmap_node.hash);
719 hmap_insert(&table->rules, &new->hmap_node, new->hmap_node.hash);
720 list_init(&new->list);
723 /* Scan the list for the insertion point that will keep the list in
724 * order of decreasing priority. */
725 struct cls_rule *rule;
726 FOR_EACH_RULE_IN_LIST (rule, head) {
727 if (new->priority >= rule->priority) {
729 /* 'new' is the new highest-priority flow in the list. */
730 hmap_replace(&table->rules,
731 &rule->hmap_node, &new->hmap_node);
734 if (new->priority == rule->priority) {
735 list_replace(&new->list, &rule->list);
738 list_insert(&rule->list, &new->list);
744 /* Insert 'new' at the end of the list. */
745 list_push_back(&head->list, &new->list);
750 static struct cls_rule *
751 next_rule_in_list__(struct cls_rule *rule)
753 struct cls_rule *next = OBJECT_CONTAINING(rule->list.next, next, list);
757 static struct cls_rule *
758 next_rule_in_list(struct cls_rule *rule)
760 struct cls_rule *next = next_rule_in_list__(rule);
761 return next->priority < rule->priority ? next : NULL;
765 flow_equal_except(const struct flow *a, const struct flow *b,
766 const struct flow_wildcards *wildcards)
768 const flow_wildcards_t wc = wildcards->wildcards;
771 BUILD_ASSERT_DECL(FLOW_SIG_SIZE == 37 + FLOW_N_REGS * 4);
773 for (i = 0; i < FLOW_N_REGS; i++) {
774 if ((a->regs[i] ^ b->regs[i]) & wildcards->reg_masks[i]) {
779 return ((wc & FWW_TUN_ID || a->tun_id == b->tun_id)
780 && !((a->nw_src ^ b->nw_src) & wildcards->nw_src_mask)
781 && !((a->nw_dst ^ b->nw_dst) & wildcards->nw_dst_mask)
782 && (wc & FWW_IN_PORT || a->in_port == b->in_port)
783 && (wc & FWW_DL_VLAN || a->dl_vlan == b->dl_vlan)
784 && (wc & FWW_DL_TYPE || a->dl_type == b->dl_type)
785 && (wc & FWW_TP_SRC || a->tp_src == b->tp_src)
786 && (wc & FWW_TP_DST || a->tp_dst == b->tp_dst)
787 && (wc & FWW_DL_SRC || eth_addr_equals(a->dl_src, b->dl_src))
789 || (!((a->dl_dst[0] ^ b->dl_dst[0]) & 0xfe)
790 && a->dl_dst[1] == b->dl_dst[1]
791 && a->dl_dst[2] == b->dl_dst[2]
792 && a->dl_dst[3] == b->dl_dst[3]
793 && a->dl_dst[4] == b->dl_dst[4]
794 && a->dl_dst[5] == b->dl_dst[5]))
795 && (wc & FWW_ETH_MCAST
796 || !((a->dl_dst[0] ^ b->dl_dst[0]) & 0x01))
797 && (wc & FWW_NW_PROTO || a->nw_proto == b->nw_proto)
798 && (wc & FWW_DL_VLAN_PCP || a->dl_vlan_pcp == b->dl_vlan_pcp)
799 && (wc & FWW_NW_TOS || a->nw_tos == b->nw_tos));
803 zero_wildcards(struct flow *flow, const struct flow_wildcards *wildcards)
805 const flow_wildcards_t wc = wildcards->wildcards;
808 BUILD_ASSERT_DECL(FLOW_SIG_SIZE == 37 + 4 * FLOW_N_REGS);
810 for (i = 0; i < FLOW_N_REGS; i++) {
811 flow->regs[i] &= wildcards->reg_masks[i];
813 if (wc & FWW_TUN_ID) {
816 flow->nw_src &= wildcards->nw_src_mask;
817 flow->nw_dst &= wildcards->nw_dst_mask;
818 if (wc & FWW_IN_PORT) {
821 if (wc & FWW_DL_VLAN) {
824 if (wc & FWW_DL_TYPE) {
827 if (wc & FWW_TP_SRC) {
830 if (wc & FWW_TP_DST) {
833 if (wc & FWW_DL_SRC) {
834 memset(flow->dl_src, 0, sizeof flow->dl_src);
836 if (wc & FWW_DL_DST) {
837 flow->dl_dst[0] &= 0x01;
838 memset(&flow->dl_dst[1], 0, 5);
840 if (wc & FWW_ETH_MCAST) {
841 flow->dl_dst[0] &= 0xfe;
843 if (wc & FWW_NW_PROTO) {
846 if (wc & FWW_DL_VLAN_PCP) {
847 flow->dl_vlan_pcp = 0;
849 if (wc & FWW_NW_TOS) {