diff options
author | Lorenzo Bianconi <lorenzo@kernel.org> | 2022-01-21 11:09:54 +0100 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2022-01-21 23:14:02 +0100 |
commit | 0165cc817075cf701e4289838f1d925ff1911b3e (patch) | |
tree | 4044357f657e7f6d79002a841e1a733384df07af /include/net/xdp.h | |
parent | net: mvneta: enable jumbo frames if the loaded XDP program support frags (diff) | |
download | linux-0165cc817075cf701e4289838f1d925ff1911b3e.tar.xz linux-0165cc817075cf701e4289838f1d925ff1911b3e.zip |
bpf: introduce bpf_xdp_get_buff_len helper
Introduce bpf_xdp_get_buff_len helper in order to return the xdp buffer
total size (linear and paged area)
Acked-by: Toke Hoiland-Jorgensen <toke@redhat.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/aac9ac3504c84026cf66a3c71b7c5ae89bc991be.1642758637.git.lorenzo@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include/net/xdp.h')
-rw-r--r-- | include/net/xdp.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/net/xdp.h b/include/net/xdp.h index 8463dea8b4db..52b593321956 100644 --- a/include/net/xdp.h +++ b/include/net/xdp.h @@ -145,6 +145,20 @@ xdp_get_shared_info_from_buff(struct xdp_buff *xdp) return (struct skb_shared_info *)xdp_data_hard_end(xdp); } +static __always_inline unsigned int xdp_get_buff_len(struct xdp_buff *xdp) +{ + unsigned int len = xdp->data_end - xdp->data; + struct skb_shared_info *sinfo; + + if (likely(!xdp_buff_has_frags(xdp))) + goto out; + + sinfo = xdp_get_shared_info_from_buff(xdp); + len += sinfo->xdp_frags_size; +out: + return len; +} + struct xdp_frame { void *data; u16 len; |