forked from luck/tmp_suning_uos_patched
bpf: only test gso type on gso packets
BPF can adjust gso only for tcp bytestreams. Fail on other gso types.
But only on gso packets. It does not touch this field if !gso_size.
Fixes: b90efd2258
("bpf: only adjust gso_size on bytestream protocols")
Signed-off-by: Willem de Bruijn <willemb@google.com>
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
parent
78c3aff834
commit
4c3024debf
|
@ -4232,10 +4232,10 @@ static inline bool skb_is_gso_sctp(const struct sk_buff *skb)
|
||||||
return skb_shinfo(skb)->gso_type & SKB_GSO_SCTP;
|
return skb_shinfo(skb)->gso_type & SKB_GSO_SCTP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Note: Should be called only if skb_is_gso(skb) is true */
|
||||||
static inline bool skb_is_gso_tcp(const struct sk_buff *skb)
|
static inline bool skb_is_gso_tcp(const struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
return skb_is_gso(skb) &&
|
return skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6);
|
||||||
skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void skb_gso_reset(struct sk_buff *skb)
|
static inline void skb_gso_reset(struct sk_buff *skb)
|
||||||
|
|
|
@ -2804,7 +2804,7 @@ static int bpf_skb_proto_4_to_6(struct sk_buff *skb)
|
||||||
u32 off = skb_mac_header_len(skb);
|
u32 off = skb_mac_header_len(skb);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!skb_is_gso_tcp(skb))
|
if (skb_is_gso(skb) && !skb_is_gso_tcp(skb))
|
||||||
return -ENOTSUPP;
|
return -ENOTSUPP;
|
||||||
|
|
||||||
ret = skb_cow(skb, len_diff);
|
ret = skb_cow(skb, len_diff);
|
||||||
|
@ -2845,7 +2845,7 @@ static int bpf_skb_proto_6_to_4(struct sk_buff *skb)
|
||||||
u32 off = skb_mac_header_len(skb);
|
u32 off = skb_mac_header_len(skb);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!skb_is_gso_tcp(skb))
|
if (skb_is_gso(skb) && !skb_is_gso_tcp(skb))
|
||||||
return -ENOTSUPP;
|
return -ENOTSUPP;
|
||||||
|
|
||||||
ret = skb_unclone(skb, GFP_ATOMIC);
|
ret = skb_unclone(skb, GFP_ATOMIC);
|
||||||
|
@ -2970,7 +2970,7 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 len_diff)
|
||||||
u32 off = skb_mac_header_len(skb) + bpf_skb_net_base_len(skb);
|
u32 off = skb_mac_header_len(skb) + bpf_skb_net_base_len(skb);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!skb_is_gso_tcp(skb))
|
if (skb_is_gso(skb) && !skb_is_gso_tcp(skb))
|
||||||
return -ENOTSUPP;
|
return -ENOTSUPP;
|
||||||
|
|
||||||
ret = skb_cow(skb, len_diff);
|
ret = skb_cow(skb, len_diff);
|
||||||
|
@ -2999,7 +2999,7 @@ static int bpf_skb_net_shrink(struct sk_buff *skb, u32 len_diff)
|
||||||
u32 off = skb_mac_header_len(skb) + bpf_skb_net_base_len(skb);
|
u32 off = skb_mac_header_len(skb) + bpf_skb_net_base_len(skb);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!skb_is_gso_tcp(skb))
|
if (skb_is_gso(skb) && !skb_is_gso_tcp(skb))
|
||||||
return -ENOTSUPP;
|
return -ENOTSUPP;
|
||||||
|
|
||||||
ret = skb_unclone(skb, GFP_ATOMIC);
|
ret = skb_unclone(skb, GFP_ATOMIC);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user