From: Rich Lane Date: Fri, 8 Feb 2013 23:29:57 +0000 (-0800) Subject: datapath: Fix parsing invalid LLC/SNAP ethertypes X-Git-Tag: sliver-openvswitch-1.10.90-1~11^2~19 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=9e69bc5f6ba7dac11b9e0a12925f8d318379991c;p=sliver-openvswitch.git datapath: Fix parsing invalid LLC/SNAP ethertypes 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 Signed-off-by: Jesse Gross --- diff --git a/datapath/flow.c b/datapath/flow.c index fad9e1977..b14229f8e 100644 --- a/datapath/flow.c +++ b/datapath/flow.c @@ -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, diff --git a/lib/flow.c b/lib/flow.c index 5e7d1d47d..397bda161 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -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