X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=lib%2Fclassifier.c;h=b05b491e89adb043b9876ff3b35df2f3b348b6b9;hb=b46ccdf582946f30d80735345c533c23a7f035c0;hp=236b1204217b6b34f659f81754daff58faac994c;hpb=8fe2b9682c74b4735a5a7503568a586e3353ca85;p=openvswitch diff --git a/lib/classifier.c b/lib/classifier.c index 236b1204..b05b491e 100644 --- a/lib/classifier.c +++ b/lib/classifier.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010 Nicira Networks. + * Copyright (c) 2009, 2010, 2011 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -130,8 +130,15 @@ cls_rule_set_reg_masked(struct cls_rule *rule, unsigned int reg_idx, void cls_rule_set_tun_id(struct cls_rule *rule, ovs_be64 tun_id) { - rule->wc.wildcards &= ~FWW_TUN_ID; - rule->flow.tun_id = tun_id; + cls_rule_set_tun_id_masked(rule, tun_id, htonll(UINT64_MAX)); +} + +void +cls_rule_set_tun_id_masked(struct cls_rule *rule, + ovs_be64 tun_id, ovs_be64 mask) +{ + rule->wc.tun_id_mask = mask; + rule->flow.tun_id = tun_id & mask; } void @@ -393,8 +400,16 @@ cls_rule_format(const struct cls_rule *rule, struct ds *s) break; } } - if (!(w & FWW_TUN_ID)) { - ds_put_format(s, "tun_id=0x%"PRIx64",", ntohll(f->tun_id)); + switch (wc->tun_id_mask) { + case 0: + break; + case CONSTANT_HTONLL(UINT64_MAX): + ds_put_format(s, "tun_id=%#"PRIx64",", ntohll(f->tun_id)); + break; + default: + ds_put_format(s, "tun_id=%#"PRIx64"/%#"PRIx64",", + ntohll(f->tun_id), ntohll(wc->tun_id_mask)); + break; } if (!(w & FWW_IN_PORT)) { ds_put_format(s, "in_port=%"PRIu16",", @@ -447,9 +462,9 @@ cls_rule_format(const struct cls_rule *rule, struct ds *s) format_ip_netmask(s, "nw_dst", f->nw_dst, wc->nw_dst_mask); if (!skip_proto && !(w & FWW_NW_PROTO)) { if (f->dl_type == htons(ETH_TYPE_ARP)) { - ds_put_format(s, "arp_op=%"PRIu8, f->nw_proto); + ds_put_format(s, "opcode=%"PRIu8",", f->nw_proto); } else { - ds_put_format(s, "nw_proto=%"PRIu8, f->nw_proto); + ds_put_format(s, "nw_proto=%"PRIu8",", f->nw_proto); } } if (!(w & FWW_NW_TOS)) { @@ -457,17 +472,17 @@ cls_rule_format(const struct cls_rule *rule, struct ds *s) } if (f->nw_proto == IP_TYPE_ICMP) { if (!(w & FWW_TP_SRC)) { - ds_put_format(s, "icmp_type=%"PRIu16, ntohs(f->tp_src)); + ds_put_format(s, "icmp_type=%"PRIu16",", ntohs(f->tp_src)); } if (!(w & FWW_TP_DST)) { - ds_put_format(s, "icmp_code=%"PRIu16, ntohs(f->tp_dst)); + ds_put_format(s, "icmp_code=%"PRIu16",", ntohs(f->tp_dst)); } } else { if (!(w & FWW_TP_SRC)) { - ds_put_format(s, "tp_src=%"PRIu16, ntohs(f->tp_src)); + ds_put_format(s, "tp_src=%"PRIu16",", ntohs(f->tp_src)); } if (!(w & FWW_TP_DST)) { - ds_put_format(s, "tp_dst=%"PRIu16, ntohs(f->tp_dst)); + ds_put_format(s, "tp_dst=%"PRIu16",", ntohs(f->tp_dst)); } } @@ -940,7 +955,7 @@ flow_equal_except(const struct flow *a, const struct flow *b, } } - return ((wc & FWW_TUN_ID || a->tun_id == b->tun_id) + return (!((a->tun_id ^ b->tun_id) & wildcards->tun_id_mask) && !((a->nw_src ^ b->nw_src) & wildcards->nw_src_mask) && !((a->nw_dst ^ b->nw_dst) & wildcards->nw_dst_mask) && (wc & FWW_IN_PORT || a->in_port == b->in_port) @@ -973,9 +988,7 @@ zero_wildcards(struct flow *flow, const struct flow_wildcards *wildcards) for (i = 0; i < FLOW_N_REGS; i++) { flow->regs[i] &= wildcards->reg_masks[i]; } - if (wc & FWW_TUN_ID) { - flow->tun_id = 0; - } + flow->tun_id &= wildcards->tun_id_mask; flow->nw_src &= wildcards->nw_src_mask; flow->nw_dst &= wildcards->nw_dst_mask; if (wc & FWW_IN_PORT) {