datapath: Fix parsing invalid LLC/SNAP ethertypes
authorRich Lane <rlane@bigswitch.com>
Fri, 8 Feb 2013 23:29:57 +0000 (15:29 -0800)
committerJesse Gross <jesse@nicira.com>
Tue, 19 Feb 2013 19:07:03 +0000 (11:07 -0800)
Before this patch, if an LLC/SNAP packet with OUI 00:00:00 had an ethertype
less than 1536 the flow key given to userspace in the upcall would contain the
invalid ethertype (for example, 3). If userspace attempted to insert a kernel
flow for this key it would be rejected by ovs_flow_from_nlattrs.

This patch allows OVS to pass the OFTest pktact.DirectBadLlcPackets.

Signed-off-by: Rich Lane <rlane@bigswitch.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
datapath/flow.c
lib/flow.c

index fad9e19..b14229f 100644 (file)
@@ -500,7 +500,11 @@ static __be16 parse_ethertype(struct sk_buff *skb)
                return htons(ETH_P_802_2);
 
        __skb_pull(skb, sizeof(struct llc_snap_hdr));
-       return llc->ethertype;
+
+       if (ntohs(llc->ethertype) >= 1536)
+               return llc->ethertype;
+
+       return htons(ETH_P_802_2);
 }
 
 static int parse_icmpv6(struct sk_buff *skb, struct sw_flow_key *key,
index 5e7d1d4..397bda1 100644 (file)
@@ -147,7 +147,12 @@ parse_ethertype(struct ofpbuf *b)
     }
 
     ofpbuf_pull(b, sizeof *llc);
-    return llc->snap.snap_type;
+
+    if (ntohs(llc->snap.snap_type) >= ETH_TYPE_MIN) {
+        return llc->snap.snap_type;
+    }
+
+    return htons(FLOW_DL_TYPE_NONE);
 }
 
 static int