1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2ef456144SCraig Gallek #ifndef _SOCK_REUSEPORT_H 3ef456144SCraig Gallek #define _SOCK_REUSEPORT_H 4ef456144SCraig Gallek 5538950a1SCraig Gallek #include <linux/filter.h> 6538950a1SCraig Gallek #include <linux/skbuff.h> 7ef456144SCraig Gallek #include <linux/types.h> 8*736b4602SMartin KaFai Lau #include <linux/spinlock.h> 9ef456144SCraig Gallek #include <net/sock.h> 10ef456144SCraig Gallek 11*736b4602SMartin KaFai Lau extern spinlock_t reuseport_lock; 12*736b4602SMartin KaFai Lau 13ef456144SCraig Gallek struct sock_reuseport { 14ef456144SCraig Gallek struct rcu_head rcu; 15ef456144SCraig Gallek 16ef456144SCraig Gallek u16 max_socks; /* length of socks */ 17ef456144SCraig Gallek u16 num_socks; /* elements in socks */ 1840a1227eSMartin KaFai Lau /* The last synq overflow event timestamp of this 1940a1227eSMartin KaFai Lau * reuse->socks[] group. 2040a1227eSMartin KaFai Lau */ 2140a1227eSMartin KaFai Lau unsigned int synq_overflow_ts; 22*736b4602SMartin KaFai Lau /* ID stays the same even after the size of socks[] grows. */ 23*736b4602SMartin KaFai Lau unsigned int reuseport_id; 24538950a1SCraig Gallek struct bpf_prog __rcu *prog; /* optional BPF sock selector */ 25ef456144SCraig Gallek struct sock *socks[0]; /* array of sock pointers */ 26ef456144SCraig Gallek }; 27ef456144SCraig Gallek 28ef456144SCraig Gallek extern int reuseport_alloc(struct sock *sk); 29b4ace4f1SCraig Gallek extern int reuseport_add_sock(struct sock *sk, struct sock *sk2); 30ef456144SCraig Gallek extern void reuseport_detach_sock(struct sock *sk); 31538950a1SCraig Gallek extern struct sock *reuseport_select_sock(struct sock *sk, 32538950a1SCraig Gallek u32 hash, 33538950a1SCraig Gallek struct sk_buff *skb, 34538950a1SCraig Gallek int hdr_len); 35538950a1SCraig Gallek extern struct bpf_prog *reuseport_attach_prog(struct sock *sk, 36538950a1SCraig Gallek struct bpf_prog *prog); 37*736b4602SMartin KaFai Lau int reuseport_get_id(struct sock_reuseport *reuse); 38ef456144SCraig Gallek 39ef456144SCraig Gallek #endif /* _SOCK_REUSEPORT_H */ 40