diff options
author | Alexei Starovoitov <ast@kernel.org> | 2020-06-01 14:57:15 -0700 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-06-01 15:00:20 -0700 |
commit | c48a24f00e7a8b90c817e3f7aa800a3150bb83d0 (patch) | |
tree | bba2031049e20cce4e5ff3d21f6749c6b9e625b5 /net/core/sock.c | |
parent | bb2359f4dbe98e8863b4e885fc09269ef4682ec3 (diff) | |
parent | 9c441fe4c06a553ad770b6f21616327a3badf793 (diff) |
Merge branch 'bpf_setsockopt-SO_BINDTODEVICE'
Ferenc Fejes says:
====================
This option makes it possible to programatically bind sockets
to netdevices. With the help of this option sockets
of VRF unaware applications could be distributed between
multiple VRFs with an eBPF program. This lets the applications
benefit from multiple possible routes.
v2:
- splitting up the patch to three parts
- lock_sk parameter for optional locking in sock_bindtoindex - Stanislav Fomichev
- testing the SO_BINDTODEVICE option - Andrii Nakryiko
====================
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'net/core/sock.c')
-rw-r--r-- | net/core/sock.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index 61ec573221a6..6c4acf1f0220 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -594,13 +594,15 @@ out: return ret; } -int sock_bindtoindex(struct sock *sk, int ifindex) +int sock_bindtoindex(struct sock *sk, int ifindex, bool lock_sk) { int ret; - lock_sock(sk); + if (lock_sk) + lock_sock(sk); ret = sock_bindtoindex_locked(sk, ifindex); - release_sock(sk); + if (lock_sk) + release_sock(sk); return ret; } @@ -646,7 +648,7 @@ static int sock_setbindtodevice(struct sock *sk, char __user *optval, goto out; } - return sock_bindtoindex(sk, index); + return sock_bindtoindex(sk, index, true); out: #endif |