blob: 0054b3a9b9239eb47e14ce09460dc0814b5a1ebe [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Craig Gallekef456142016-01-04 17:41:45 -05002#ifndef _SOCK_REUSEPORT_H
3#define _SOCK_REUSEPORT_H
4
Craig Gallek538950a2016-01-04 17:41:47 -05005#include <linux/filter.h>
6#include <linux/skbuff.h>
Craig Gallekef456142016-01-04 17:41:45 -05007#include <linux/types.h>
8#include <net/sock.h>
9
10struct sock_reuseport {
11 struct rcu_head rcu;
12
13 u16 max_socks; /* length of socks */
14 u16 num_socks; /* elements in socks */
Craig Gallek538950a2016-01-04 17:41:47 -050015 struct bpf_prog __rcu *prog; /* optional BPF sock selector */
Craig Gallekef456142016-01-04 17:41:45 -050016 struct sock *socks[0]; /* array of sock pointers */
17};
18
19extern int reuseport_alloc(struct sock *sk);
Craig Gallekb4ace4f2016-01-19 14:27:08 -050020extern int reuseport_add_sock(struct sock *sk, struct sock *sk2);
Craig Gallekef456142016-01-04 17:41:45 -050021extern void reuseport_detach_sock(struct sock *sk);
Craig Gallek538950a2016-01-04 17:41:47 -050022extern struct sock *reuseport_select_sock(struct sock *sk,
23 u32 hash,
24 struct sk_buff *skb,
25 int hdr_len);
26extern struct bpf_prog *reuseport_attach_prog(struct sock *sk,
27 struct bpf_prog *prog);
Craig Gallekef456142016-01-04 17:41:45 -050028
29#endif /* _SOCK_REUSEPORT_H */