diff options
| author | Jakub Kicinski <kuba@kernel.org> | 2025-02-20 13:17:21 -0800 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2025-02-20 13:17:21 -0800 |
| commit | 372ab5a5feebb791663c7398fdf1cc541e2059ff (patch) | |
| tree | 30cdabd37e083fa4cc0ec571e559b0c1a10081c4 /net/core | |
| parent | Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net (diff) | |
| parent | net: Add options as a flexible array to struct ip_tunnel_info (diff) | |
| download | linux-372ab5a5feebb791663c7398fdf1cc541e2059ff.tar.gz linux-372ab5a5feebb791663c7398fdf1cc541e2059ff.zip | |
Merge branch 'flexible-array-for-ip-tunnel-options'
Gal Pressman says:
====================
Flexible array for ip tunnel options
Remove the hidden assumption that options are allocated at the end of
the struct, and teach the compiler about them using a flexible array.
First patch is converting hard-coded 'info + 1' to use ip_tunnel_info()
helper.
Second patch adds the 'options' flexible array and changes the helper to
use it.
v4: https://lore.kernel.org/20250217202503.265318-1-gal@nvidia.com
v3: https://lore.kernel.org/20250212140953.107533-1-gal@nvidia.com
v2: https://lore.kernel.org/20250209101853.15828-1-gal@nvidia.com
====================
Link: https://patch.msgid.link/20250219143256.370277-1-gal@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/core')
| -rw-r--r-- | net/core/dst.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/net/core/dst.c b/net/core/dst.c index 9552a90d4772..c99b95cf9cbb 100644 --- a/net/core/dst.c +++ b/net/core/dst.c @@ -286,7 +286,8 @@ struct metadata_dst *metadata_dst_alloc(u8 optslen, enum metadata_type type, { struct metadata_dst *md_dst; - md_dst = kmalloc(sizeof(*md_dst) + optslen, flags); + md_dst = kmalloc(struct_size(md_dst, u.tun_info.options, optslen), + flags); if (!md_dst) return NULL; @@ -314,7 +315,8 @@ metadata_dst_alloc_percpu(u8 optslen, enum metadata_type type, gfp_t flags) int cpu; struct metadata_dst __percpu *md_dst; - md_dst = __alloc_percpu_gfp(sizeof(struct metadata_dst) + optslen, + md_dst = __alloc_percpu_gfp(struct_size(md_dst, u.tun_info.options, + optslen), __alignof__(struct metadata_dst), flags); if (!md_dst) return NULL; |
