android_kernel_motorola_sm6375/net
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Daniel Borkmann 770a93776c
UPSTREAM: bpf: Allow for map-in-map with dynamic inner array map entries
Recent work in f4d05259213f ("bpf: Add map_meta_equal map ops") and 134fede4eecf
("bpf: Relax max_entries check for most of the inner map types") added support
for dynamic inner max elements for most map-in-map types. Exceptions were maps
like array or prog array where the map_gen_lookup() callback uses the maps'
max_entries field as a constant when emitting instructions.

We recently implemented Maglev consistent hashing into Cilium's load balancer
which uses map-in-map with an outer map being hash and inner being array holding
the Maglev backend table for each service. This has been designed this way in
order to reduce overall memory consumption given the outer hash map allows to
avoid preallocating a large, flat memory area for all services. Also, the
number of service mappings is not always known a-priori.

The use case for dynamic inner array map entries is to further reduce memory
overhead, for example, some services might just have a small number of back
ends while others could have a large number. Right now the Maglev backend table
for small and large number of backends would need to have the same inner array
map entries which adds a lot of unneeded overhead.

Dynamic inner array map entries can be realized by avoiding the inlined code
generation for their lookup. The lookup will still be efficient since it will
be calling into array_map_lookup_elem() directly and thus avoiding retpoline.
The patch adds a BPF_F_INNER_MAP flag to map creation which therefore skips
inline code generation and relaxes array_map_meta_equal() check to ignore both
maps' max_entries. This also still allows to have faster lookups for map-in-map
when BPF_F_INNER_MAP is not specified and hence dynamic max_entries not needed.

Example code generation where inner map is dynamic sized array:

  # bpftool p d x i 125
  int handle__sys_enter(void * ctx):
  ; int handle__sys_enter(void *ctx)
     0: (b4) w1 = 0
  ; int key = 0;
     1: (63) *(u32 *)(r10 -4) = r1
     2: (bf) r2 = r10
  ;
     3: (07) r2 += -4
  ; inner_map = bpf_map_lookup_elem(&outer_arr_dyn, &key);
     4: (18) r1 = map[id:468]
     6: (07) r1 += 272
     7: (61) r0 = *(u32 *)(r2 +0)
     8: (35) if r0 >= 0x3 goto pc+5
     9: (67) r0 <<= 3
    10: (0f) r0 += r1
    11: (79) r0 = *(u64 *)(r0 +0)
    12: (15) if r0 == 0x0 goto pc+1
    13: (05) goto pc+1
    14: (b7) r0 = 0
    15: (b4) w6 = -1
  ; if (!inner_map)
    16: (15) if r0 == 0x0 goto pc+6
    17: (bf) r2 = r10
  ;
    18: (07) r2 += -4
  ; val = bpf_map_lookup_elem(inner_map, &key);
    19: (bf) r1 = r0                               | No inlining but instead
    20: (85) call array_map_lookup_elem#149280     | call to array_map_lookup_elem()
  ; return val ? *val : -1;                        | for inner array lookup.
    21: (15) if r0 == 0x0 goto pc+1
  ; return val ? *val : -1;
    22: (61) r6 = *(u32 *)(r0 +0)
  ; }
    23: (bc) w0 = w6
    24: (95) exit

Change-Id: I808f50ea72c452cee8fa74473101e2a900b9c836
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20201010234006.7075-4-daniel@iogearbox.net
2026-01-14 18:12:44 -08:00
..
6lowpan
9p net/9p: fix double req put in p9_fd_cancelled 2025-10-29 13:59:54 +01:00
802
8021q net: vlan: sync VLAN features with lower device 2025-12-03 12:45:15 +01:00
appletalk
atm
ax25 BACKPORT: net: Make sock protocol value checks more specific 2025-12-23 13:35:52 -08:00
batman-adv
bluetooth This is the 5.4.302 stable release 2025-12-03 14:36:44 +00:00
bpf UPSTREAM: bpf: fix raw_tp test run in preempt kernel 2026-01-14 18:12:38 -08:00
bpfilter UPSTREAM: bpf: Add kernel module with user mode driver that populates bpffs. 2026-01-14 18:12:16 -08:00
bridge BACKPORT: mm: remove the pgprot argument to __vmalloc 2026-01-14 17:48:09 -08:00
caif
can
ceph
core BACKPORT: bpf: Add redirect_peer helper 2026-01-14 18:12:44 -08:00
dcb
dccp
decnet
dns_resolver
dsa
embms_kernel
ethernet
hsr
ieee802154
ife
ipv4 BACKPORT: net: add a new ndo_tunnel_ioctl method 2026-01-14 18:12:44 -08:00
ipv6 BACKPORT: bpf: tcp: Add bpf_skops_hdr_opt_len() and bpf_skops_write_hdr_opt() 2026-01-14 18:12:18 -08:00
iucv
kcm
key
l2tp
l3mdev
lapb
llc
mac80211 Merge branch 'android11-5.4-lts' of https://android.googlesource.com/kernel/common into android13-5.4-lahaina 2025-12-11 01:41:51 -08:00
mac802154
mpls BACKPORT: sysctl: pass kernel pointers to ->proc_handler 2025-12-23 13:36:15 -08:00
ncsi
netfilter BACKPORT: sysctl: pass kernel pointers to ->proc_handler 2025-12-23 13:36:15 -08:00
netlabel
netlink UPSTREAM: bpf: Refactor bpf_iter_reg to have separate seq_info member 2026-01-14 18:12:07 -08:00
netrom
neuron
nfc
nsh
openvswitch net: openvswitch: remove never-working support for setting nsh fields 2025-12-03 12:45:20 +01:00
packet BACKPORT: net: switch copy_bpf_fprog_from_user to sockptr_t 2026-01-14 18:12:35 -08:00
phonet BACKPORT: sysctl: pass kernel pointers to ->proc_handler 2025-12-23 13:36:15 -08:00
psample
qrtr
rds BACKPORT: tcp: add tcp_sock_set_keepidle 2026-01-14 17:50:47 -08:00
rfkill
rose
rxrpc
sched BACKPORT: bpf: Add socket assign support 2025-12-23 13:36:11 -08:00
sctp BACKPORT: sysctl: pass kernel pointers to ->proc_handler 2025-12-23 13:36:15 -08:00
smc
strparser strparser: Fix signed/unsigned mismatch bug 2025-12-03 12:45:19 +01:00
sunrpc BACKPORT: tcp: add tcp_sock_set_keepidle 2026-01-14 17:50:47 -08:00
switchdev
tipc This is the 5.4.302 stable release 2025-12-03 14:36:44 +00:00
tls UPSTREAM: net, sk_msg: Annotate lockless access to sk_prot on clone 2025-12-23 13:36:03 -08:00
unix
vmw_vsock This is the 5.4.302 stable release 2025-12-03 14:36:44 +00:00
wimax
wireless
x25
xdp UPSTREAM: bpf: Allow for map-in-map with dynamic inner array map entries 2026-01-14 18:12:44 -08:00
xfrm
compat.c BACKPORT: net: simplify cBPF setsockopt compat handling 2026-01-14 18:12:33 -08:00
Kconfig
Makefile
OWNERS
socket.c
sysctl_net.c
TEST_MAPPING