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) {
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)) {
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);
609 HMAP_FOR_EACH_CONTINUE (rule, hmap_node, &cursor->table->rules) {
610 if (rule_matches(rule, cursor->target)) {
615 for (table = classifier_next_table(cursor->cls, cursor->table); table;
616 table = classifier_next_table(cursor->cls, table)) {
617 rule = search_table(table, cursor->target);
619 cursor->table = table;
627 static struct cls_table *
628 find_table(const struct classifier *cls, const struct flow_wildcards *wc)
630 struct cls_table *table;
632 HMAP_FOR_EACH_IN_BUCKET (table, hmap_node, flow_wildcards_hash(wc),
634 if (flow_wildcards_equal(wc, &table->wc)) {
641 static struct cls_table *
642 insert_table(struct classifier *cls, const struct flow_wildcards *wc)
644 struct cls_table *table;
646 table = xzalloc(sizeof *table);
647 hmap_init(&table->rules);
649 hmap_insert(&cls->tables, &table->hmap_node, flow_wildcards_hash(wc));
654 static struct cls_table *
655 classifier_first_table(const struct classifier *cls)
657 return cls_table_from_hmap_node(hmap_first(&cls->tables));
660 static struct cls_table *
661 classifier_next_table(const struct classifier *cls,
662 const struct cls_table *table)
664 return cls_table_from_hmap_node(hmap_next(&cls->tables,
669 destroy_table(struct classifier *cls, struct cls_table *table)
671 hmap_remove(&cls->tables, &table->hmap_node);
672 hmap_destroy(&table->rules);
676 static struct cls_rule *
677 find_match(const struct cls_table *table, const struct flow *flow)
679 struct cls_rule *rule;
683 zero_wildcards(&f, &table->wc);
684 HMAP_FOR_EACH_WITH_HASH (rule, hmap_node, flow_hash(&f, 0),
686 if (flow_equal(&f, &rule->flow)) {
693 static struct cls_rule *
694 find_equal(struct cls_table *table, const struct flow *flow, uint32_t hash)
696 struct cls_rule *head;
698 HMAP_FOR_EACH_WITH_HASH (head, hmap_node, hash, &table->rules) {
699 if (flow_equal(&head->flow, flow)) {
706 static struct cls_rule *
707 insert_rule(struct cls_table *table, struct cls_rule *new)
709 struct cls_rule *head;
711 new->hmap_node.hash = flow_hash(&new->flow, 0);
713 head = find_equal(table, &new->flow, new->hmap_node.hash);
715 hmap_insert(&table->rules, &new->hmap_node, new->hmap_node.hash);
716 list_init(&new->list);
719 /* Scan the list for the insertion point that will keep the list in
720 * order of decreasing priority. */
721 struct cls_rule *rule;
722 FOR_EACH_RULE_IN_LIST (rule, head) {
723 if (new->priority >= rule->priority) {
725 /* 'new' is the new highest-priority flow in the list. */
726 hmap_replace(&table->rules,
727 &rule->hmap_node, &new->hmap_node);
730 if (new->priority == rule->priority) {
731 list_replace(&new->list, &rule->list);
734 list_insert(&rule->list, &new->list);
740 /* Insert 'new' at the end of the list. */
741 list_push_back(&head->list, &new->list);
746 static struct cls_rule *
747 next_rule_in_list(struct cls_rule *rule)
749 struct cls_rule *next = OBJECT_CONTAINING(rule->list.next, next, list);
750 return next->priority < rule->priority ? next : NULL;
754 flow_equal_except(const struct flow *a, const struct flow *b,
755 const struct flow_wildcards *wildcards)
757 const uint32_t wc = wildcards->wildcards;
760 BUILD_ASSERT_DECL(FLOW_SIG_SIZE == 37 + FLOW_N_REGS * 4);
762 for (i = 0; i < FLOW_N_REGS; i++) {
763 if ((a->regs[i] ^ b->regs[i]) & wildcards->reg_masks[i]) {
768 return ((wc & NXFW_TUN_ID || a->tun_id == b->tun_id)
769 && !((a->nw_src ^ b->nw_src) & wildcards->nw_src_mask)
770 && !((a->nw_dst ^ b->nw_dst) & wildcards->nw_dst_mask)
771 && (wc & OFPFW_IN_PORT || a->in_port == b->in_port)
772 && (wc & OFPFW_DL_VLAN || a->dl_vlan == b->dl_vlan)
773 && (wc & OFPFW_DL_TYPE || a->dl_type == b->dl_type)
774 && (wc & OFPFW_TP_SRC || a->tp_src == b->tp_src)
775 && (wc & OFPFW_TP_DST || a->tp_dst == b->tp_dst)
776 && (wc & OFPFW_DL_SRC || eth_addr_equals(a->dl_src, b->dl_src))
777 && (wc & OFPFW_DL_DST
778 || (!((a->dl_dst[0] ^ b->dl_dst[0]) & 0xfe)
779 && a->dl_dst[1] == b->dl_dst[1]
780 && a->dl_dst[2] == b->dl_dst[2]
781 && a->dl_dst[3] == b->dl_dst[3]
782 && a->dl_dst[4] == b->dl_dst[4]
783 && a->dl_dst[5] == b->dl_dst[5]))
784 && (wc & FWW_ETH_MCAST || !((a->dl_dst[0] ^ b->dl_dst[0]) & 0x01))
785 && (wc & OFPFW_NW_PROTO || a->nw_proto == b->nw_proto)
786 && (wc & OFPFW_DL_VLAN_PCP || a->dl_vlan_pcp == b->dl_vlan_pcp)
787 && (wc & OFPFW_NW_TOS || a->nw_tos == b->nw_tos));
791 zero_wildcards(struct flow *flow, const struct flow_wildcards *wildcards)
793 const uint32_t wc = wildcards->wildcards;
796 BUILD_ASSERT_DECL(FLOW_SIG_SIZE == 37 + 4 * FLOW_N_REGS);
798 for (i = 0; i < FLOW_N_REGS; i++) {
799 flow->regs[i] &= wildcards->reg_masks[i];
801 if (wc & NXFW_TUN_ID) {
804 flow->nw_src &= wildcards->nw_src_mask;
805 flow->nw_dst &= wildcards->nw_dst_mask;
806 if (wc & OFPFW_IN_PORT) {
809 if (wc & OFPFW_DL_VLAN) {
812 if (wc & OFPFW_DL_TYPE) {
815 if (wc & OFPFW_TP_SRC) {
818 if (wc & OFPFW_TP_DST) {
821 if (wc & OFPFW_DL_SRC) {
822 memset(flow->dl_src, 0, sizeof flow->dl_src);
824 if (wc & OFPFW_DL_DST) {
825 flow->dl_dst[0] &= 0x01;
826 memset(&flow->dl_dst[1], 0, 5);
828 if (wc & FWW_ETH_MCAST) {
829 flow->dl_dst[0] &= 0xfe;
831 if (wc & OFPFW_NW_PROTO) {
834 if (wc & OFPFW_DL_VLAN_PCP) {
835 flow->dl_vlan_pcp = 0;
837 if (wc & OFPFW_NW_TOS) {