Skip to content

Commit 49b2357

Browse files
matttbeborkmann
authored andcommitted
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: 70c5899 ("bpf: Allow SO_BINDTODEVICE opt in bpf_setsockopt") Suggested-by: Alexei Starovoitov <[email protected]> Signed-off-by: Matthieu Baerts <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Song Liu <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent cb8e59c commit 49b2357

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

net/core/filter.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4340,8 +4340,6 @@ static int _bpf_setsockopt(struct sock *sk, int level, int optname,
43404340
}
43414341
break;
43424342
case SO_BINDTODEVICE:
4343-
ret = -ENOPROTOOPT;
4344-
#ifdef CONFIG_NETDEVICES
43454343
optlen = min_t(long, optlen, IFNAMSIZ - 1);
43464344
strncpy(devname, optval, optlen);
43474345
devname[optlen] = 0;
@@ -4360,7 +4358,6 @@ static int _bpf_setsockopt(struct sock *sk, int level, int optname,
43604358
dev_put(dev);
43614359
}
43624360
ret = sock_bindtoindex(sk, ifindex, false);
4363-
#endif
43644361
break;
43654362
default:
43664363
ret = -EINVAL;

0 commit comments

Comments
 (0)