diff options
author | Vadim Fedorenko <vfedorenko@novek.ru> | 2021-09-10 01:04:09 +0300 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2021-09-10 23:20:13 +0200 |
commit | 3384c7c7641b44987e35eadbc9df6c16a0520159 (patch) | |
tree | c9f94e549e26966186c4e3a6672ce42b6a470b83 /net/bpf | |
parent | f64c4acea51fbe2c08c0b0f48b7f5d1657d7a5e4 (diff) |
selftests/bpf: Test new __sk_buff field hwtstamp
Analogous to the gso_segs selftests introduced in commit d9ff286a0f59
("bpf: allow BPF programs access skb_shared_info->gso_segs field").
Signed-off-by: Vadim Fedorenko <vfedorenko@novek.ru>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20210909220409.8804-3-vfedorenko@novek.ru
Diffstat (limited to 'net/bpf')
-rw-r--r-- | net/bpf/test_run.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index 1153b89c9d93..fcb2f493f710 100644 --- a/net/bpf/test_run.c +++ b/net/bpf/test_run.c @@ -507,6 +507,12 @@ static int convert___skb_to_skb(struct sk_buff *skb, struct __sk_buff *__skb) /* gso_size is allowed */ if (!range_is_zero(__skb, offsetofend(struct __sk_buff, gso_size), + offsetof(struct __sk_buff, hwtstamp))) + return -EINVAL; + + /* hwtstamp is allowed */ + + if (!range_is_zero(__skb, offsetofend(struct __sk_buff, hwtstamp), sizeof(struct __sk_buff))) return -EINVAL; @@ -529,6 +535,7 @@ static int convert___skb_to_skb(struct sk_buff *skb, struct __sk_buff *__skb) return -EINVAL; skb_shinfo(skb)->gso_segs = __skb->gso_segs; skb_shinfo(skb)->gso_size = __skb->gso_size; + skb_shinfo(skb)->hwtstamps.hwtstamp = __skb->hwtstamp; return 0; } @@ -548,6 +555,7 @@ static void convert_skb_to___skb(struct sk_buff *skb, struct __sk_buff *__skb) memcpy(__skb->cb, &cb->data, QDISC_CB_PRIV_LEN); __skb->wire_len = cb->pkt_len; __skb->gso_segs = skb_shinfo(skb)->gso_segs; + __skb->hwtstamp = skb_shinfo(skb)->hwtstamps.hwtstamp; } int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr, |