1
0
Fork 0
alistair23-linux/include
Martin KaFai Lau 736b46027e net: Add ID (if needed) to sock_reuseport and expose reuseport_lock
A later patch will introduce a BPF_MAP_TYPE_REUSEPORT_ARRAY which
allows a SO_REUSEPORT sk to be added to a bpf map.  When a sk
is removed from reuse->socks[], it also needs to be removed from
the bpf map.  Also, when adding a sk to a bpf map, the bpf
map needs to ensure it is indeed in a reuse->socks[].
Hence, reuseport_lock is needed by the bpf map to ensure its
map_update_elem() and map_delete_elem() operations are in-sync with
the reuse->socks[].  The BPF_MAP_TYPE_REUSEPORT_ARRAY map will only
acquire the reuseport_lock after ensuring the adding sk is already
in a reuseport group (i.e. reuse->socks[]).  The map_lookup_elem()
will be lockless.

This patch also adds an ID to sock_reuseport.  A later patch
will introduce BPF_PROG_TYPE_SK_REUSEPORT which allows
a bpf prog to select a sk from a bpf map.  It is inflexible to
statically enforce a bpf map can only contain the sk belonging to
a particular reuse->socks[] (i.e. same IP:PORT) during the bpf
verification time. For example, think about the the map-in-map situation
where the inner map can be dynamically changed in runtime and the outer
map may have inner maps belonging to different reuseport groups.
Hence, when the bpf prog (in the new BPF_PROG_TYPE_SK_REUSEPORT
type) selects a sk,  this selected sk has to be checked to ensure it
belongs to the requesting reuseport group (i.e. the group serving
that IP:PORT).

The "sk->sk_reuseport_cb" pointer cannot be used for this checking
purpose because the pointer value will change after reuseport_grow().
Instead of saving all checking conditions like the ones
preced calling "reuseport_add_sock()" and compare them everytime a
bpf_prog is run, a 32bits ID is introduced to survive the
reuseport_grow().  The ID is only acquired if any of the
reuse->socks[] is added to the newly introduced
"BPF_MAP_TYPE_REUSEPORT_ARRAY" map.

If "BPF_MAP_TYPE_REUSEPORT_ARRAY" is not used,  the changes in this
patch is a no-op.

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2018-08-11 01:58:45 +02:00
..
acpi ACPI / processor: Finish making acpi_processor_ppc_has_changed() void 2018-06-20 10:50:40 +02:00
asm-generic mm: allow arch to supply p??_free_tlb functions 2018-07-14 11:11:09 -07:00
clocksource
crypto Revert changes to convert to ->poll_mask() and aio IOCB_CMD_POLL 2018-06-28 10:40:47 -07:00
drm drm for v4.18-rc1 2018-06-06 08:16:33 -07:00
dt-bindings dt-bindings: clock: imx6ul: Do not change the clock definition order 2018-06-29 11:40:20 -07:00
keys docs: Fix some broken references 2018-06-15 18:10:01 -03:00
kvm KVM: arm/arm64: Bump VGIC_V3_MAX_CPUS to 512 2018-05-25 12:29:27 +01:00
linux xdp: Helpers for disabling napi_direct of xdp_return_frame 2018-08-10 16:12:21 +02:00
math-emu
media media: v4l2-core: push taking ioctl mutex down to ioctl handler 2018-05-28 16:31:44 -04:00
memory
misc ocxl: Expose the thread_id needed for wait on POWER9 2018-06-03 20:40:32 +10:00
net net: Add ID (if needed) to sock_reuseport and expose reuseport_lock 2018-08-11 01:58:45 +02:00
pcmcia
ras
rdma 4.18-rc 2018-06-21 07:22:30 +09:00
scsi SCSI misc on 20180610 2018-06-10 13:01:12 -07:00
soc ARM: SoC: late updates 2018-06-11 18:19:45 -07:00
sound sound updates for 4.18 2018-06-06 09:08:38 -07:00
target scsi: target: transport should handle st FM/EOM/ILI reads 2018-05-18 12:22:48 -04:00
trace rxrpc: Trace socket notification 2018-08-01 13:28:23 +01:00
uapi net/sched: allow flower to match tunnel options 2018-08-07 12:22:15 -07:00
video fbdev changes for v4.18: 2018-06-17 05:00:24 +09:00
xen xen: fixes for 4.18-rc2 2018-06-23 20:44:11 +08:00