X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fofp-util.c;h=3c004dcd175976d3d70b0f08fa18177302229cc9;hb=4895c7016139e2e59c17b1d9c39aa3eca90399da;hp=5ef4e80fc122e9bb0a82f63cc15bf992057742ef;hpb=9e44d715638af28689b15ef0c5be920e61c7997b;p=openvswitch diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 5ef4e80f..3c004dcd 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -101,18 +101,20 @@ static const flow_wildcards_t WC_INVARIANTS = 0 void ofputil_wildcard_from_openflow(uint32_t ofpfw, struct flow_wildcards *wc) { - BUILD_ASSERT_DECL(FLOW_WC_SEQ == 5); + BUILD_ASSERT_DECL(FLOW_WC_SEQ == 7); /* Initialize most of rule->wc. */ flow_wildcards_init_catchall(wc); wc->wildcards = (OVS_FORCE flow_wildcards_t) ofpfw & WC_INVARIANTS; /* Wildcard fields that aren't defined by ofp_match or tun_id. */ - wc->wildcards |= (FWW_ARP_SHA | FWW_ARP_THA | FWW_ND_TARGET - | FWW_IPV6_LABEL); + wc->wildcards |= (FWW_ARP_SHA | FWW_ARP_THA | FWW_NW_ECN | FWW_NW_TTL + | FWW_ND_TARGET | FWW_IPV6_LABEL); - if (!(ofpfw & OFPFW_NW_TOS)) { - wc->tos_mask |= IP_DSCP_MASK; + if (ofpfw & OFPFW_NW_TOS) { + /* OpenFlow 1.0 defines a TOS wildcard, but it's much later in + * the enum than we can use. */ + wc->wildcards |= FWW_NW_DSCP; } wc->nw_src_mask = ofputil_wcbits_to_netmask(ofpfw >> OFPFW_NW_SRC_SHIFT); @@ -155,7 +157,7 @@ ofputil_cls_rule_from_match(const struct ofp_match *match, rule->flow.tp_dst = match->tp_dst; memcpy(rule->flow.dl_src, match->dl_src, ETH_ADDR_LEN); memcpy(rule->flow.dl_dst, match->dl_dst, ETH_ADDR_LEN); - rule->flow.tos = match->nw_tos & IP_DSCP_MASK; + rule->flow.nw_tos = match->nw_tos & IP_DSCP_MASK; rule->flow.nw_proto = match->nw_proto; /* Translate VLANs. */ @@ -194,7 +196,7 @@ ofputil_cls_rule_to_match(const struct cls_rule *rule, struct ofp_match *match) ofpfw = (OVS_FORCE uint32_t) (wc->wildcards & WC_INVARIANTS); ofpfw |= ofputil_netmask_to_wcbits(wc->nw_src_mask) << OFPFW_NW_SRC_SHIFT; ofpfw |= ofputil_netmask_to_wcbits(wc->nw_dst_mask) << OFPFW_NW_DST_SHIFT; - if (!(wc->tos_mask & IP_DSCP_MASK)) { + if (wc->wildcards & FWW_NW_DSCP) { ofpfw |= OFPFW_NW_TOS; } @@ -228,7 +230,7 @@ ofputil_cls_rule_to_match(const struct cls_rule *rule, struct ofp_match *match) match->dl_type = ofputil_dl_type_to_openflow(rule->flow.dl_type); match->nw_src = rule->flow.nw_src; match->nw_dst = rule->flow.nw_dst; - match->nw_tos = rule->flow.tos & IP_DSCP_MASK; + match->nw_tos = rule->flow.nw_tos & IP_DSCP_MASK; match->nw_proto = rule->flow.nw_proto; match->tp_src = rule->flow.tp_src; match->tp_dst = rule->flow.tp_dst; @@ -859,7 +861,7 @@ ofputil_min_flow_format(const struct cls_rule *rule) { const struct flow_wildcards *wc = &rule->wc; - BUILD_ASSERT_DECL(FLOW_WC_SEQ == 5); + BUILD_ASSERT_DECL(FLOW_WC_SEQ == 7); /* Only NXM supports separately wildcards the Ethernet multicast bit. */ if (!(wc->wildcards & FWW_DL_DST) != !(wc->wildcards & FWW_ETH_MCAST)) { @@ -888,7 +890,7 @@ ofputil_min_flow_format(const struct cls_rule *rule) } /* Only NXM supports matching fragments. */ - if (wc->frag_mask) { + if (wc->nw_frag_mask) { return NXFF_NXM; } @@ -897,6 +899,16 @@ ofputil_min_flow_format(const struct cls_rule *rule) return NXFF_NXM; } + /* Only NXM supports matching IP ECN bits. */ + if (!(wc->wildcards & FWW_NW_ECN)) { + return NXFF_NXM; + } + + /* Only NXM supports matching IP TTL/hop limit. */ + if (!(wc->wildcards & FWW_NW_TTL)) { + return NXFF_NXM; + } + /* Other formats can express this rule. */ return NXFF_OPENFLOW10; } @@ -2511,10 +2523,10 @@ ofputil_normalize_rule(struct cls_rule *rule, enum nx_flow_format flow_format) MAY_NW_ADDR = 1 << 0, /* nw_src, nw_dst */ MAY_TP_ADDR = 1 << 1, /* tp_src, tp_dst */ MAY_NW_PROTO = 1 << 2, /* nw_proto */ - MAY_IPVx = 1 << 3, /* tos, frag */ + MAY_IPVx = 1 << 3, /* tos, frag, ttl */ MAY_ARP_SHA = 1 << 4, /* arp_sha */ MAY_ARP_THA = 1 << 5, /* arp_tha */ - MAY_IPV6_ADDR = 1 << 6, /* ipv6_src, ipv6_dst */ + MAY_IPV6 = 1 << 6, /* ipv6_src, ipv6_dst, ipv6_label */ MAY_ND_TARGET = 1 << 7 /* nd_target */ } may_match; @@ -2530,7 +2542,7 @@ ofputil_normalize_rule(struct cls_rule *rule, enum nx_flow_format flow_format) } } else if (rule->flow.dl_type == htons(ETH_TYPE_IPV6) && flow_format == NXFF_NXM) { - may_match = MAY_NW_PROTO | MAY_IPVx | MAY_IPV6_ADDR; + may_match = MAY_NW_PROTO | MAY_IPVx | MAY_IPV6; if (rule->flow.nw_proto == IPPROTO_TCP || rule->flow.nw_proto == IPPROTO_UDP) { may_match |= MAY_TP_ADDR; @@ -2563,8 +2575,9 @@ ofputil_normalize_rule(struct cls_rule *rule, enum nx_flow_format flow_format) wc.wildcards |= FWW_NW_PROTO; } if (!(may_match & MAY_IPVx)) { - wc.tos_mask = 0; - wc.frag_mask = 0; + wc.wildcards |= FWW_NW_DSCP; + wc.wildcards |= FWW_NW_ECN; + wc.wildcards |= FWW_NW_TTL; } if (!(may_match & MAY_ARP_SHA)) { wc.wildcards |= FWW_ARP_SHA; @@ -2572,7 +2585,7 @@ ofputil_normalize_rule(struct cls_rule *rule, enum nx_flow_format flow_format) if (!(may_match & MAY_ARP_THA)) { wc.wildcards |= FWW_ARP_THA; } - if (!(may_match & MAY_IPV6_ADDR)) { + if (!(may_match & MAY_IPV6)) { wc.ipv6_src_mask = wc.ipv6_dst_mask = in6addr_any; wc.wildcards |= FWW_IPV6_LABEL; }