diff options
author | Willem de Bruijn <willemb@google.com> | 2020-03-03 15:05:01 -0500 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-03-03 16:23:59 -0800 |
commit | cf62089b0edd7e74a1f474844b4d9f7b5697fb5c (patch) | |
tree | 9daf8bfb7c74ff98ca4c507f8d5bf8184c4d7bec /net/bpf | |
parent | abbc61a5f26d52a5d3abbbe552b275360b2c6631 (diff) | |
download | linux-cf62089b0edd7e74a1f474844b4d9f7b5697fb5c.tar.gz linux-cf62089b0edd7e74a1f474844b4d9f7b5697fb5c.tar.bz2 linux-cf62089b0edd7e74a1f474844b4d9f7b5697fb5c.zip |
bpf: Add gso_size to __sk_buff
BPF programs may want to know whether an skb is gso. The canonical
answer is skb_is_gso(skb), which tests that gso_size != 0.
Expose this field in the same manner as gso_segs. That field itself
is not a sufficient signal, as the comment in skb_shared_info makes
clear: gso_segs may be zero, e.g., from dodgy sources.
Also prepare net/bpf/test_run for upcoming BPF_PROG_TEST_RUN tests
of the feature.
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200303200503.226217-2-willemdebruijn.kernel@gmail.com
Diffstat (limited to 'net/bpf')
-rw-r--r-- | net/bpf/test_run.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index 562443f94133..1cd7a1c2f8b2 100644 --- a/net/bpf/test_run.c +++ b/net/bpf/test_run.c @@ -277,6 +277,12 @@ static int convert___skb_to_skb(struct sk_buff *skb, struct __sk_buff *__skb) /* gso_segs is allowed */ if (!range_is_zero(__skb, offsetofend(struct __sk_buff, gso_segs), + offsetof(struct __sk_buff, gso_size))) + return -EINVAL; + + /* gso_size is allowed */ + + if (!range_is_zero(__skb, offsetofend(struct __sk_buff, gso_size), sizeof(struct __sk_buff))) return -EINVAL; @@ -297,6 +303,7 @@ static int convert___skb_to_skb(struct sk_buff *skb, struct __sk_buff *__skb) if (__skb->gso_segs > GSO_MAX_SEGS) return -EINVAL; skb_shinfo(skb)->gso_segs = __skb->gso_segs; + skb_shinfo(skb)->gso_size = __skb->gso_size; return 0; } |