summaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorAleksander Lobakin <aleksander.lobakin@intel.com>2023-12-06 21:59:19 +0100
committerDaniel Borkmann <daniel@iogearbox.net>2023-12-11 16:09:36 +0100
commit2ebe81c814355d000fe49d9c4213983844dcb32b (patch)
tree695a116c8cea02abc891dd2e3181e11adc48ba57 /include/net
parent15c79c6507c0eab5ec0d4cd402ac52d42735a43e (diff)
downloadlinux-stable-2ebe81c814355d000fe49d9c4213983844dcb32b.tar.gz
linux-stable-2ebe81c814355d000fe49d9c4213983844dcb32b.tar.bz2
linux-stable-2ebe81c814355d000fe49d9c4213983844dcb32b.zip
net, xdp: Allow metadata > 32
32 bytes may be not enough for some custom metadata. Relax the restriction, allow metadata larger than 32 bytes and make __skb_metadata_differs() work with bigger lengths. Now size of metadata is only limited by the fact it is stored as u8 in skb_shared_info, so maximum possible value is 255. Size still has to be aligned to 4, so the actual upper limit becomes 252. Most driver implementations will offer less, none can offer more. Other important conditions, such as having enough space for xdp_frame building, are already checked in bpf_xdp_adjust_meta(). Signed-off-by: Aleksander Lobakin <aleksander.lobakin@intel.com> Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/eb87653c-8ff8-447d-a7a1-25961f60518a@kernel.org Link: https://lore.kernel.org/bpf/20231206205919.404415-3-larysa.zaremba@intel.com
Diffstat (limited to 'include/net')
-rw-r--r--include/net/xdp.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/include/net/xdp.h b/include/net/xdp.h
index 349c36fb5fd8..5d3673afc037 100644
--- a/include/net/xdp.h
+++ b/include/net/xdp.h
@@ -369,7 +369,12 @@ xdp_data_meta_unsupported(const struct xdp_buff *xdp)
static inline bool xdp_metalen_invalid(unsigned long metalen)
{
- return (metalen & (sizeof(__u32) - 1)) || (metalen > 32);
+ unsigned long meta_max;
+
+ meta_max = type_max(typeof_member(struct skb_shared_info, meta_len));
+ BUILD_BUG_ON(!__builtin_constant_p(meta_max));
+
+ return !IS_ALIGNED(metalen, sizeof(u32)) || metalen > meta_max;
}
struct xdp_attachment_info {