summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMatthieu Baerts <matthieu.baerts@tessares.net>2020-06-03 21:03:47 +0200
committerDaniel Borkmann <daniel@iogearbox.net>2020-06-04 22:52:10 +0200
commit49b23575943c04b6711107cfd08ad2b3ae4e81f5 (patch)
treee768761ed5727d7b628cab70fde6c22aba249328 /net
parentMerge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next (diff)
downloadlinux-49b23575943c04b6711107cfd08ad2b3ae4e81f5.tar.xz
linux-49b23575943c04b6711107cfd08ad2b3ae4e81f5.zip
bpf: Fix unused-var without NETDEVICES
A recent commit added new variables only used if CONFIG_NETDEVICES is set. A simple fix would be to only declare these variables if the same condition is valid but Alexei suggested an even simpler solution: since CONFIG_NETDEVICES doesn't change anything in .h I think the best is to remove #ifdef CONFIG_NETDEVICES from net/core/filter.c and rely on sock_bindtoindex() returning ENOPROTOOPT in the extreme case of oddly configured kernels. Fixes: 70c58997c1e8 ("bpf: Allow SO_BINDTODEVICE opt in bpf_setsockopt") Suggested-by: Alexei Starovoitov <alexei.starovoitov@gmail.com> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Song Liu <songliubraving@fb.com> Link: https://lore.kernel.org/bpf/20200603190347.2310320-1-matthieu.baerts@tessares.net
Diffstat (limited to 'net')
-rw-r--r--net/core/filter.c3
1 files changed, 0 insertions, 3 deletions
diff --git a/net/core/filter.c b/net/core/filter.c
index d01a244b5087..90d2eb77002f 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4340,8 +4340,6 @@ static int _bpf_setsockopt(struct sock *sk, int level, int optname,
}
break;
case SO_BINDTODEVICE:
- ret = -ENOPROTOOPT;
-#ifdef CONFIG_NETDEVICES
optlen = min_t(long, optlen, IFNAMSIZ - 1);
strncpy(devname, optval, optlen);
devname[optlen] = 0;
@@ -4360,7 +4358,6 @@ static int _bpf_setsockopt(struct sock *sk, int level, int optname,
dev_put(dev);
}
ret = sock_bindtoindex(sk, ifindex, false);
-#endif
break;
default:
ret = -EINVAL;