openvswitch: Fix IPv6 later frags parsing
authorYi-Hung Wei <[email protected]>
Thu, 3 Jan 2019 17:51:57 +0000 (09:51 -0800)
committerDavid S. Miller <[email protected]>
Fri, 4 Jan 2019 21:00:02 +0000 (13:00 -0800)
The previous commit fa642f08839b
("openvswitch: Derive IP protocol number for IPv6 later frags")
introduces IP protocol number parsing for IPv6 later frags that can mess
up the network header length calculation logic, i.e. nh_len < 0.
However, the network header length calculation is mainly for deriving
the transport layer header in the key extraction process which the later
fragment does not apply.

Therefore, this commit skips the network header length calculation to
fix the issue.

Reported-by: Chris Mi <[email protected]>
Reported-by: Greg Rose <[email protected]>
Fixes: fa642f08839b ("openvswitch: Derive IP protocol number for IPv6 later frags")
Signed-off-by: Yi-Hung Wei <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
net/openvswitch/flow.c

index 57e07768c9d12b65e9f1dc8d7271040e25cfd82f..f54cf17ef7a8bc3fa1449644fff07dd1cba523d2 100644 (file)
@@ -276,10 +276,12 @@ static int parse_ipv6hdr(struct sk_buff *skb, struct sw_flow_key *key)
 
        nexthdr = ipv6_find_hdr(skb, &payload_ofs, -1, &frag_off, &flags);
        if (flags & IP6_FH_F_FRAG) {
-               if (frag_off)
+               if (frag_off) {
                        key->ip.frag = OVS_FRAG_TYPE_LATER;
-               else
-                       key->ip.frag = OVS_FRAG_TYPE_FIRST;
+                       key->ip.proto = nexthdr;
+                       return 0;
+               }
+               key->ip.frag = OVS_FRAG_TYPE_FIRST;
        } else {
                key->ip.frag = OVS_FRAG_TYPE_NONE;
        }