On 08/08/2018 09:59 AM, Martin KaFai Lau wrote: > This series introduces a new map type "BPF_MAP_TYPE_REUSEPORT_SOCKARRAY" > and a new prog type BPF_PROG_TYPE_SK_REUSEPORT. > > Here is a snippet from a commit message: > > "To unleash the full potential of a bpf prog, it is essential for the > userspace to be capable of directly setting up a bpf map which can then > be consumed by the bpf prog to make decision. In this case, decide which > SO_REUSEPORT sk to serve the incoming request. > > By adding BPF_MAP_TYPE_REUSEPORT_SOCKARRAY, the userspace has total control > and visibility on where a SO_REUSEPORT sk should be located in a bpf map. > The later patch will introduce BPF_PROG_TYPE_SK_REUSEPORT such that > the bpf prog can directly select a sk from the bpf map. That will > raise the programmability of the bpf prog attached to a reuseport > group (a group of sk serving the same IP:PORT). > > For example, in UDP, the bpf prog can peek into the payload (e.g. > through the "data" pointer introduced in the later patch) to learn > the application level's connection information and then decide which sk > to pick from a bpf map. The userspace can tightly couple the sk's location > in a bpf map with the application logic in generating the UDP payload's > connection information. This connection info contact/API stays within the > userspace. > > Also, when used with map-in-map, the userspace can switch the > old-server-process's inner map to a new-server-process's inner map > in one call "bpf_map_update_elem(outer_map, &index, &new_reuseport_array)". > The bpf prog will then direct incoming requests to the new process instead > of the old process. The old process can finish draining the pending > requests (e.g. by "accept()") before closing the old-fds. [Note that > deleting a fd from a bpf map does not necessary mean the fd is closed]" > > Please see individual patch for details > > Martin KaFai Lau (9): > tcp: Avoid TCP syncookie rejected by SO_REUSEPORT socket > net: Add ID (if needed) to sock_reuseport and expose reuseport_lock > bpf: Introduce BPF_MAP_TYPE_REUSEPORT_SOCKARRAY > bpf: Introduce BPF_PROG_TYPE_SK_REUSEPORT > bpf: Enable BPF_PROG_TYPE_SK_REUSEPORT bpf prog in reuseport selection > bpf: Refactor ARRAY_SIZE macro to bpf_util.h > bpf: Sync bpf.h uapi to tools/ > bpf: test BPF_MAP_TYPE_REUSEPORT_SOCKARRAY > bpf: Test BPF_PROG_TYPE_SK_REUSEPORT
Applied to bpf-next, thanks Martin!