summaryrefslogtreecommitdiff
path: root/include/net/xdp.h
diff options
context:
space:
mode:
authorZvi Effron <zeffron@riotgames.com>2021-07-08 01:16:54 +0300
committerAlexei Starovoitov <ast@kernel.org>2021-07-08 05:51:12 +0300
commit7445cf31d2e25e3f8ad7b1c5342e624c09ab23a2 (patch)
treea7babfa3dec035e81533d4e66266bfc75f3013ea /include/net/xdp.h
parent5e437416ff66981d8154687cfdf7de50b1d82bfc (diff)
downloadlinux-7445cf31d2e25e3f8ad7b1c5342e624c09ab23a2.tar.xz
bpf: Add function for XDP meta data length check
This commit prepares to use the XDP meta data length check in multiple places by making it into a static inline function instead of a literal. Co-developed-by: Cody Haas <chaas@riotgames.com> Co-developed-by: Lisa Watanabe <lwatanabe@riotgames.com> Signed-off-by: Cody Haas <chaas@riotgames.com> Signed-off-by: Lisa Watanabe <lwatanabe@riotgames.com> Signed-off-by: Zvi Effron <zeffron@riotgames.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Yonghong Song <yhs@fb.com> Link: https://lore.kernel.org/bpf/20210707221657.3985075-2-zeffron@riotgames.com
Diffstat (limited to 'include/net/xdp.h')
-rw-r--r--include/net/xdp.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/net/xdp.h b/include/net/xdp.h
index 5533f0ab2afc..ad5b02dcb6f4 100644
--- a/include/net/xdp.h
+++ b/include/net/xdp.h
@@ -276,6 +276,11 @@ xdp_data_meta_unsupported(const struct xdp_buff *xdp)
return unlikely(xdp->data_meta > xdp->data);
}
+static inline bool xdp_metalen_invalid(unsigned long metalen)
+{
+ return (metalen & (sizeof(__u32) - 1)) || (metalen > 32);
+}
+
struct xdp_attachment_info {
struct bpf_prog *prog;
u32 flags;