X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fofp-util.c;h=f017fc9f42baf577005dcbeffa5930f66f12270f;hb=85dcedffa5de44699ff4885a344c70d97aaead32;hp=925f45fdf388776dd4a6bb2fdd384ab6961c4090;hpb=36956a7d33c9ee204fcb184484a5aaacbd9ecef8;p=openvswitch diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 925f45fd..f017fc9f 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -124,6 +124,10 @@ ofputil_cls_rule_from_match(const struct ofp_match *match, /* Initialize most of rule->wc. */ flow_wildcards_init_catchall(wc); wc->wildcards = 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); + if (ofpfw & OFPFW_NW_TOS) { wc->wildcards |= FWW_NW_TOS; } @@ -852,13 +856,25 @@ is_nxm_required(const struct cls_rule *rule, bool cookie_support, ovs_be64 cookie) { const struct flow_wildcards *wc = &rule->wc; - ovs_be32 cookie_hi; + uint32_t cookie_hi; + uint64_t tun_id; /* Only NXM supports separately wildcards the Ethernet multicast bit. */ if (!(wc->wildcards & FWW_DL_DST) != !(wc->wildcards & FWW_ETH_MCAST)) { return true; } + /* Only NXM supports matching ARP hardware addresses. */ + if (!(wc->wildcards & FWW_ARP_SHA) || !(wc->wildcards & FWW_ARP_THA)) { + return true; + } + + /* Only NXM supports matching IPv6 traffic. */ + if (!(wc->wildcards & FWW_DL_TYPE) + && (rule->flow.dl_type == htons(ETH_TYPE_IPV6))) { + return true; + } + /* Only NXM supports matching registers. */ if (!regs_fully_wildcarded(wc)) { return true; @@ -870,11 +886,21 @@ is_nxm_required(const struct cls_rule *rule, bool cookie_support, break; case CONSTANT_HTONLL(UINT64_MAX): - /* Only NXM supports matching tunnel ID, unless there is a cookie and - * the top 32 bits of the cookie are the desired tunnel ID value. */ - cookie_hi = htonl(ntohll(cookie) >> 32); - if (!cookie_support - || (cookie_hi && cookie_hi != ntohll(rule->flow.tun_id))) { + /* Only NXM supports tunnel ID matching without a cookie. */ + if (!cookie_support) { + return true; + } + + /* Only NXM supports 64-bit tunnel IDs. */ + tun_id = ntohll(rule->flow.tun_id); + if (tun_id > UINT32_MAX) { + return true; + } + + /* Only NXM supports a cookie whose top 32 bits conflict with the + * tunnel ID. */ + cookie_hi = ntohll(cookie) >> 32; + if (cookie_hi && cookie_hi != tun_id) { return true; } break; @@ -2032,6 +2058,9 @@ normalize_match(struct ofp_match *m) m->nw_dst &= ofputil_wcbits_to_netmask(wc >> OFPFW_NW_DST_SHIFT); } m->tp_src = m->tp_dst = m->nw_tos = 0; + } else if (m->dl_type == htons(ETH_TYPE_IPV6)) { + /* Don't normalize IPv6 traffic, since OpenFlow doesn't have a + * way to express it. */ } else { /* Network and transport layer fields will always be extracted as * zeros, so we can do an exact-match on those values. */