Return no protocols if mask is supplied for unmaskable match
authorSimon Horman <horms@verge.net.au>
Thu, 31 Oct 2013 04:00:02 +0000 (13:00 +0900)
committerBen Pfaff <blp@nicira.com>
Thu, 31 Oct 2013 23:43:59 +0000 (16:43 -0700)
Currently if a mask is supplied for an unmaskable match then NOT_REACHED()
is called. The effect of this for a user calling ovs-vsctl with a match
that includes a mask which is not permitted is to politely inform them of
the error of their ways by calling abort and segfaulting.

This patch takes an alternate approach to return no protocols which has the
has the effect when that ovs-vsctl is called with a match that includes a
mask which is not permitted an error message of the following form is
displayed.

ovs-ofctl: none of the usable flow formats (none) is among the allowed flow formats (OpenFlow10,NXM)

This patch also updates the ovs-ofctl test to test matches with masks
where possible.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/meta-flow.c
tests/ovs-ofctl.at

index b9553af..494277f 100644 (file)
@@ -2030,7 +2030,7 @@ mf_set(const struct mf_field *mf,
     case MFF_ICMPV4_CODE:
     case MFF_ICMPV6_TYPE:
     case MFF_ICMPV6_CODE:
-        NOT_REACHED();
+        return OFPUTIL_P_NONE;
 
     case MFF_TUN_ID:
         match_set_tun_id_masked(match, value->be64, mask->be64);
index e399479..7097009 100644 (file)
@@ -4,40 +4,66 @@ AT_SETUP([ovs-ofctl parse-flows choice of protocol])
 # This doesn't cover some potential vlan_tci test cases.
 for test_case in \
     'tun_id=0                                    NXM,OXM' \
+    'tun_id=0/0x1                                NXM,OXM' \
     'tun_src=1.2.3.4                             NXM,OXM' \
+    'tun_src=1.2.3.4/0.0.0.1                     NXM,OXM' \
     'tun_dst=1.2.3.4                             NXM,OXM' \
+    'tun_dst=1.2.3.4/0.0.0.1                     NXM,OXM' \
     'tun_flags=0                                 none' \
+    'tun_flags=1/1                               none' \
     'tun_tos=0                                   none' \
+    'tun_tos=1/1                                 none' \
     'tun_ttl=0                                   none' \
+    'tun_ttl=1/1                                 none' \
     'metadata=0                                  NXM,OXM,OpenFlow11' \
+    'metadata=1/1                                NXM,OXM,OpenFlow11' \
     'in_port=1                                   any' \
     'skb_priority=0                              none' \
+    'skb_priority=1/1                            none' \
     'pkt_mark=1                                  NXM,OXM' \
+    'pkt_mark=1/1                                NXM,OXM' \
     'reg0=0                                      NXM,OXM' \
+    'reg0=0/1                                    NXM,OXM' \
     'reg1=1                                      NXM,OXM' \
+    'reg1=1/1                                    NXM,OXM' \
     'reg2=2                                      NXM,OXM' \
+    'reg2=2/1                                    NXM,OXM' \
     'reg3=3                                      NXM,OXM' \
+    'reg3=3/1                                    NXM,OXM' \
     'reg4=4                                      NXM,OXM' \
+    'reg4=4/1                                    NXM,OXM' \
     'reg5=5                                      NXM,OXM' \
+    'reg5=5/1                                    NXM,OXM' \
     'reg6=6                                      NXM,OXM' \
+    'reg6=6/1                                    NXM,OXM' \
     'reg7=7                                      NXM,OXM' \
+    'reg7=7/1                                    NXM,OXM' \
     'dl_src=00:11:22:33:44:55                    any' \
     'dl_src=00:11:22:33:44:55/00:ff:ff:ff:ff:ff  NXM,OXM,OpenFlow11' \
     'dl_dst=00:11:22:33:44:55                    any' \
     'dl_dst=00:11:22:33:44:55/00:ff:ff:ff:ff:ff  NXM,OXM,OpenFlow11' \
     'dl_type=0x1234                              any' \
+    'dl_type=0x1234/0x1                          none' \
     'dl_type=0x0800                              any' \
     'dl_type=0x0806                              any' \
     'dl_type=0x86dd                              any' \
     'vlan_tci=0                                  any' \
     'vlan_tci=0x1009                             any' \
+    'vlan_tci=0x1009/0x1                         NXM,OXM' \
     'dl_vlan=9                                   any' \
+    'dl_vlan=9/0x1                               none' \
     'vlan_vid=11                                 any' \
+    'vlan_vid=11/0x1                             NXM,OXM' \
     'dl_vlan_pcp=6                               any' \
+    'dl_vlan_pcp=6/0x1                           none' \
     'vlan_pcp=5                                  any' \
+    'vlan_pcp=5/0x1                              none' \
     'mpls,mpls_label=5                           NXM,OXM,OpenFlow11' \
+    'mpls,mpls_label=5/0x1                       none' \
     'mpls,mpls_tc=1                              NXM,OXM,OpenFlow11' \
+    'mpls,mpls_tc=1/0x1                          none' \
     'mpls,mpls_bos=0                             NXM,OXM' \
+    'mpls,mpls_bos=1/0x1                         none' \
     'ip,ip_src=1.2.3.4                           any' \
     'ip,ip_src=192.168.0.0/24                    any' \
     'ip,ip_src=192.0.168.0/255.0.255.0           NXM,OXM,OpenFlow11' \
@@ -45,25 +71,43 @@ for test_case in \
     'ip,ip_dst=192.168.0.0/24                    any' \
     'ip,ip_dst=192.0.168.0/255.0.255.0           NXM,OXM,OpenFlow11' \
     'ipv6,ipv6_src=::1                           NXM,OXM' \
+    'ipv6,ipv6_src=::1/::1                       NXM,OXM' \
     'ipv6,ipv6_dst=::1                           NXM,OXM' \
+    'ipv6,ipv6_dst=::1/::1                       NXM,OXM' \
     'ipv6,ipv6_label=5                           NXM,OXM' \
+    'ipv6,ipv6_label=5/1                         NXM,OXM' \
     'ip,nw_proto=1                               any' \
+    'ip,nw_proto=1/1                             none' \
     'ipv6,nw_proto=1                             NXM,OXM' \
+    'ipv6,nw_proto=1/1                           none' \
     'ip,nw_tos=0xf0                              any' \
+    'ip,nw_tos=0xf0/0xf0                         none' \
     'ipv6,nw_tos=0xf0                            NXM,OXM' \
+    'ipv6,nw_tos=0xf0/0xf0                       none' \
     'ip,nw_tos_shifted=0x3c                      any' \
+    'ip,nw_tos_shifted=0x3c/0xf0                 none' \
     'ipv6,nw_tos_shifted=0x3c                    NXM,OXM' \
+    'ipv6,nw_tos_shifted=0x3c/0xf0               none' \
     'ip,nw_ecn=1                                 NXM,OXM' \
+    'ip,nw_ecn=1/1                               none' \
     'ipv6,nw_ecn=1                               NXM,OXM' \
+    'ipv6,nw_ecn=1/1                             none' \
     'ip,nw_ttl=5                                 NXM,OXM' \
+    'ip,nw_ttl=5/1                               none' \
     'ipv6,nw_ttl=5                               NXM,OXM' \
+    'ipv6,nw_ttl=5/1                             none' \
     'ip,ip_frag=no                               NXM,OXM' \
     'ipv6,ip_frag=no                             NXM,OXM' \
     'arp,arp_op=0                                any' \
+    'arp,arp_op=0/1                              none' \
     'arp,arp_spa=1.2.3.4                         any' \
+    'arp,arp_spa=1.2.3.4/0.0.0.1                 NXM,OXM,OpenFlow11' \
     'arp,arp_tpa=1.2.3.4                         any' \
+    'arp,arp_tpa=1.2.3.4/0.0.0.1                 NXM,OXM,OpenFlow11' \
     'arp,arp_sha=00:11:22:33:44:55               NXM,OXM' \
+    'arp,arp_sha=00:11:22:33:44:55/00:ff:ff:ff:ff:ff NXM,OXM' \
     'arp,arp_tha=00:11:22:33:44:55               NXM,OXM' \
+    'arp,arp_tha=00:11:22:33:44:55/00:ff:ff:ff:ff:ff NXM,OXM' \
     'tcp,tcp_src=80                              any' \
     'tcp,tcp_src=0x1000/0x1000                   NXM,OXM' \
     'tcp6,tcp_src=80                             NXM,OXM' \
@@ -81,9 +125,12 @@ for test_case in \
     'udp6,udp_dst=80                             NXM,OXM' \
     'udp6,udp_dst=0x1000/0x1000                  NXM,OXM' \
     'icmp,icmp_type=1                            any' \
+    'icmp,icmp_type=1/1                          none' \
     'icmp,icmp_code=2                            any' \
+    'icmp,icmp_code=2/1                          none' \
     'icmp6,icmpv6_type=1                         NXM,OXM' \
-    'icmp6,icmpv6_code=2                         NXM,OXM'
+    'icmp6,icmpv6_code=2                         NXM,OXM' \
+    'icmp6,icmpv6_code=2/1                       none'
 do
     set $test_case
     echo