net: fix GSO in bpf_lwt_push_ip_encap
authorPeter Oskolkov <[email protected]>
Tue, 5 Mar 2019 00:27:08 +0000 (16:27 -0800)
committerDaniel Borkmann <[email protected]>
Thu, 7 Mar 2019 09:41:29 +0000 (10:41 +0100)
GSO needs inner headers and inner protocol set properly to work.

skb->inner_mac_header: skb_reset_inner_headers() assigns the current
mac header value to inner_mac_header; but it is not set at the point,
so we need to call skb_reset_inner_mac_header, otherwise gre_gso_segment
fails: it does

    int tnl_hlen = skb_inner_mac_header(skb) - skb_transport_header(skb);
    ...
    if (unlikely(!pskb_may_pull(skb, tnl_hlen)))
    ...

skb->inner_protocol should also be correctly set.

Fixes: ca78801a81e0 ("bpf: handle GSO in bpf_lwt_push_encap")
Signed-off-by: Peter Oskolkov <[email protected]>
Reviewed-by: David Ahern <[email protected]>
Acked-by: Song Liu <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
net/core/lwt_bpf.c

index cf2f8897ca1945ad162f4c783e74c2698c5b8cc3..126d31ff5ee343e3248e1bdc9ba238f46a2a69c4 100644 (file)
@@ -625,6 +625,8 @@ int bpf_lwt_push_ip_encap(struct sk_buff *skb, void *hdr, u32 len, bool ingress)
 
        /* push the encap headers and fix pointers */
        skb_reset_inner_headers(skb);
+       skb_reset_inner_mac_header(skb);  /* mac header is not yet set */
+       skb_set_inner_protocol(skb, skb->protocol);
        skb->encapsulation = 1;
        skb_push(skb, len);
        if (ingress)