From 340c7bb2b9565b07de7c105d7fae298be908d138 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 28 Jun 2013 10:06:58 -0700 Subject: ofp-util: OpenFlow 1.0 can match IPv6 Ethertype even though not L3 or L4. OpenFlow 1.0 can match on flows that have the IPv6 Ethertype, but ofputil_usable_protocols() incorrectly reported that such a match required NXM or OXM. This commit fixes the problem. Also, add some related tests. Reported-by: Nagi Reddy Jonnala Signed-off-by: Ben Pfaff --- lib/ofp-util.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'lib/ofp-util.c') diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 028eaeba..48b89287 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -1086,8 +1086,19 @@ ofputil_usable_protocols(const struct match *match) | OFPUTIL_P_OF13_OXM; } - /* NXM and OXM support matching IPv6 traffic. */ - if (match->flow.dl_type == htons(ETH_TYPE_IPV6)) { + /* NXM and OXM support matching L3 and L4 fields within IPv6. + * + * (arp_sha, arp_tha, nw_frag, and nw_ttl are covered elsewhere so they + * don't need to be included in this test too.) */ + if (match->flow.dl_type == htons(ETH_TYPE_IPV6) + && (!ipv6_mask_is_any(&wc->masks.ipv6_src) + || !ipv6_mask_is_any(&wc->masks.ipv6_dst) + || !ipv6_mask_is_any(&wc->masks.nd_target) + || wc->masks.ipv6_label + || wc->masks.tp_src + || wc->masks.tp_dst + || wc->masks.nw_proto + || wc->masks.nw_tos)) { return OFPUTIL_P_OF10_NXM_ANY | OFPUTIL_P_OF12_OXM | OFPUTIL_P_OF13_OXM; } @@ -1112,12 +1123,6 @@ ofputil_usable_protocols(const struct match *match) | OFPUTIL_P_OF13_OXM; } - /* NXM and OXM support matching IPv6 flow label. */ - if (wc->masks.ipv6_label) { - return OFPUTIL_P_OF10_NXM_ANY | OFPUTIL_P_OF12_OXM - | OFPUTIL_P_OF13_OXM; - } - /* NXM and OXM support matching IP ECN bits. */ if (wc->masks.nw_tos & IP_ECN_MASK) { return OFPUTIL_P_OF10_NXM_ANY | OFPUTIL_P_OF12_OXM -- cgit v1.2.3