History

bpf: Support BPF_FUNC_get_socket_cookie() for BPF_PROG_TYPE_SK_REUSEPORT.

We will call sock_reuseport.prog for socket migration in the next commit, so the eBPF program has to know which listener is closing to select a new listener. We can currently get a unique ID of each listener in the userspace by calling bpf_map_lookup_elem() for BPF_MAP_TYPE_REUSEPORT_SOCKARRAY map. This patch makes the pointer of sk available in sk_reuseport_md so that we can get the ID by BPF_FUNC_get_socket_cookie() in the eBPF program.

Kuniyuki Iwashima committed 5 years ago

Commit e0610471 parent d4f2c863 files · +12 −0Browse files

Showing the changes to include/uapi (1 of 3 files). Show all

Unified · Split

include/uapi/linux/bpf.h+1−0
@@ -5416,6 +5416,7 @@ struct sk_reuseport_md { · 5415 unmodified lines
5416 __u32 ip_protocol; /* IP protocol. e.g. IPPROTO_TCP, IPPROTO_UDP */5416 __u32 ip_protocol; /* IP protocol. e.g. IPPROTO_TCP, IPPROTO_UDP */
5417 __u32 bind_inany; /* Is sock bound to an INANY address? */5417 __u32 bind_inany; /* Is sock bound to an INANY address? */
5418 __u32 hash; /* A hash of the packet 4 tuples */5418 __u32 hash; /* A hash of the packet 4 tuples */
5419 __bpf_md_ptr(struct bpf_sock *, sk);
5419};5420};
5420 5421
5421#define BPF_TAG_SIZE 85422#define BPF_TAG_SIZE 8