sock_reuseport.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _SOCK_REUSEPORT_H
  3. #define _SOCK_REUSEPORT_H
  4. #include <linux/filter.h>
  5. #include <linux/skbuff.h>
  6. #include <linux/types.h>
  7. #include <linux/spinlock.h>
  8. #include <net/sock.h>
  9. extern spinlock_t reuseport_lock;
  10. struct sock_reuseport {
  11. struct rcu_head rcu;
  12. u16 max_socks; /* length of socks */
  13. u16 num_socks; /* elements in socks */
  14. /* The last synq overflow event timestamp of this
  15. * reuse->socks[] group.
  16. */
  17. unsigned int synq_overflow_ts;
  18. /* ID stays the same even after the size of socks[] grows. */
  19. unsigned int reuseport_id;
  20. bool bind_inany;
  21. struct bpf_prog __rcu *prog; /* optional BPF sock selector */
  22. struct sock *socks[0]; /* array of sock pointers */
  23. };
  24. extern int reuseport_alloc(struct sock *sk, bool bind_inany);
  25. extern int reuseport_add_sock(struct sock *sk, struct sock *sk2,
  26. bool bind_inany);
  27. extern void reuseport_detach_sock(struct sock *sk);
  28. extern struct sock *reuseport_select_sock(struct sock *sk,
  29. u32 hash,
  30. struct sk_buff *skb,
  31. int hdr_len);
  32. extern int reuseport_attach_prog(struct sock *sk, struct bpf_prog *prog);
  33. int reuseport_get_id(struct sock_reuseport *reuse);
  34. #endif /* _SOCK_REUSEPORT_H */