History

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.

Willem de Bruijn committed 7 years ago

Commit 4c3024d1 parent 78c3aff2 files · +6 −6Browse files

Unified · Split

2 files
  1. include/linux/skbuff.h +2 −2
  2. net/core/filter.c +4 −4
include/linux/skbuff.h+2−2
@@ -4232,10 +4232,10 @@ static inline bool skb_is_gso_sctp(const struct sk_buff *skb) · 4231 unmodified lines
4232 return skb_shinfo(skb)->gso_type & SKB_GSO_SCTP;4232 return skb_shinfo(skb)->gso_type & SKB_GSO_SCTP;
4233}4233}
4234 4234
4235/* Note: Should be called only if skb_is_gso(skb) is true */
4235static inline bool skb_is_gso_tcp(const struct sk_buff *skb)4236static inline bool skb_is_gso_tcp(const struct sk_buff *skb)
4236{4237{
4237 return skb_is_gso(skb) &&4238 return skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6);
4238 skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6);
4239}4239}
4240 4240
4241static inline void skb_gso_reset(struct sk_buff *skb)4241static inline void skb_gso_reset(struct sk_buff *skb)
net/core/filter.c+4−4
@@ -2804,7 +2804,7 @@ static int bpf_skb_proto_4_to_6(struct sk_buff *skb) · 2803 unmodified lines
2804 u32 off = skb_mac_header_len(skb);2804 u32 off = skb_mac_header_len(skb);
2805 int ret;2805 int ret;
2806 2806
2807 if (!skb_is_gso_tcp(skb))2807 if (skb_is_gso(skb) && !skb_is_gso_tcp(skb))
2808 return -ENOTSUPP;2808 return -ENOTSUPP;
2809 2809
2810 ret = skb_cow(skb, len_diff);2810 ret = skb_cow(skb, len_diff);
@@ -2845,7 +2845,7 @@ static int bpf_skb_proto_6_to_4(struct sk_buff *skb) · 34 unmodified lines
2845 u32 off = skb_mac_header_len(skb);2845 u32 off = skb_mac_header_len(skb);
2846 int ret;2846 int ret;
2847 2847
2848 if (!skb_is_gso_tcp(skb))2848 if (skb_is_gso(skb) && !skb_is_gso_tcp(skb))
2849 return -ENOTSUPP;2849 return -ENOTSUPP;
2850 2850
2851 ret = skb_unclone(skb, GFP_ATOMIC);2851 ret = skb_unclone(skb, GFP_ATOMIC);
@@ -2970,7 +2970,7 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 len_diff) · 118 unmodified lines
2970 u32 off = skb_mac_header_len(skb) + bpf_skb_net_base_len(skb);2970 u32 off = skb_mac_header_len(skb) + bpf_skb_net_base_len(skb);
2971 int ret;2971 int ret;
2972 2972
2973 if (!skb_is_gso_tcp(skb))2973 if (skb_is_gso(skb) && !skb_is_gso_tcp(skb))
2974 return -ENOTSUPP;2974 return -ENOTSUPP;
2975 2975
2976 ret = skb_cow(skb, len_diff);2976 ret = skb_cow(skb, len_diff);
@@ -2999,7 +2999,7 @@ static int bpf_skb_net_shrink(struct sk_buff *skb, u32 len_diff) · 22 unmodified lines
2999 u32 off = skb_mac_header_len(skb) + bpf_skb_net_base_len(skb);2999 u32 off = skb_mac_header_len(skb) + bpf_skb_net_base_len(skb);
3000 int ret;3000 int ret;
3001 3001
3002 if (!skb_is_gso_tcp(skb))3002 if (skb_is_gso(skb) && !skb_is_gso_tcp(skb))
3003 return -ENOTSUPP;3003 return -ENOTSUPP;
3004 3004
3005 ret = skb_unclone(skb, GFP_ATOMIC);3005 ret = skb_unclone(skb, GFP_ATOMIC);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t