Commit 99f3a064 authored by Martin KaFai Lau's avatar Martin KaFai Lau Committed by Daniel Borkmann
Browse files

bpf: net: Add SO_DETACH_REUSEPORT_BPF



There is SO_ATTACH_REUSEPORT_[CE]BPF but there is no DETACH.
This patch adds SO_DETACH_REUSEPORT_BPF sockopt.  The same
sockopt can be used to undo both SO_ATTACH_REUSEPORT_[CE]BPF.

reseport_detach_prog() is added and it is mostly a mirror
of the existing reuseport_attach_prog().  The differences are,
it does not call reuseport_alloc() and returns -ENOENT when
there is no old prog.

Cc: Craig Gallek <kraig@google.com>
Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
Reviewed-by: default avatarStanislav Fomichev <sdf@google.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent e55d54f4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -122,6 +122,8 @@
#define SO_RCVTIMEO_NEW         66
#define SO_SNDTIMEO_NEW         67

#define SO_DETACH_REUSEPORT_BPF 68

#if !defined(__KERNEL__)

#if __BITS_PER_LONG == 64
+2 −0
Original line number Diff line number Diff line
@@ -133,6 +133,8 @@
#define SO_RCVTIMEO_NEW         66
#define SO_SNDTIMEO_NEW         67

#define SO_DETACH_REUSEPORT_BPF 68

#if !defined(__KERNEL__)

#if __BITS_PER_LONG == 64
+2 −0
Original line number Diff line number Diff line
@@ -114,6 +114,8 @@
#define SO_RCVTIMEO_NEW         0x4040
#define SO_SNDTIMEO_NEW         0x4041

#define SO_DETACH_REUSEPORT_BPF 0x4042

#if !defined(__KERNEL__)

#if __BITS_PER_LONG == 64
+2 −0
Original line number Diff line number Diff line
@@ -115,6 +115,8 @@
#define SO_RCVTIMEO_NEW          0x0044
#define SO_SNDTIMEO_NEW          0x0045

#define SO_DETACH_REUSEPORT_BPF  0x0047

#if !defined(__KERNEL__)


+2 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ extern struct sock *reuseport_select_sock(struct sock *sk,
					  struct sk_buff *skb,
					  int hdr_len);
extern int reuseport_attach_prog(struct sock *sk, struct bpf_prog *prog);
extern int reuseport_detach_prog(struct sock *sk);

int reuseport_get_id(struct sock_reuseport *reuse);

#endif  /* _SOCK_REUSEPORT_H */
Loading