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
42324232 return skb_shinfo(skb)->gso_type & SKB_GSO_SCTP;
42334233 }
42344234
4235+/* Note: Should be called only if skb_is_gso(skb) is true */
42354236 static inline bool skb_is_gso_tcp(const struct sk_buff *skb)
42364237 {
4237− return skb_is_gso(skb) &&
4238− skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6);
4238+ return skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6);
42394239 }
42404240
42414241 static 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
28042804 u32 off = skb_mac_header_len(skb);
28052805 int ret;
28062806
2807− if (!skb_is_gso_tcp(skb))
2807+ if (skb_is_gso(skb) && !skb_is_gso_tcp(skb))
28082808 return -ENOTSUPP;
28092809
28102810 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
28452845 u32 off = skb_mac_header_len(skb);
28462846 int ret;
28472847
2848− if (!skb_is_gso_tcp(skb))
2848+ if (skb_is_gso(skb) && !skb_is_gso_tcp(skb))
28492849 return -ENOTSUPP;
28502850
28512851 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
29702970 u32 off = skb_mac_header_len(skb) + bpf_skb_net_base_len(skb);
29712971 int ret;
29722972
2973− if (!skb_is_gso_tcp(skb))
2973+ if (skb_is_gso(skb) && !skb_is_gso_tcp(skb))
29742974 return -ENOTSUPP;
29752975
29762976 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
29992999 u32 off = skb_mac_header_len(skb) + bpf_skb_net_base_len(skb);
30003000 int ret;
30013001
3002− if (!skb_is_gso_tcp(skb))
3002+ if (skb_is_gso(skb) && !skb_is_gso_tcp(skb))
30033003 return -ENOTSUPP;
30043004
30053005 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