linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf] bpf: fix unused-var without NETDEVICES
@ 2020-06-03  8:11 Matthieu Baerts
  2020-06-03  8:56 ` Ferenc Fejes
  0 siblings, 1 reply; 10+ messages in thread
From: Matthieu Baerts @ 2020-06-03  8:11 UTC (permalink / raw)
  To: netdev
  Cc: Matthieu Baerts, Alexei Starovoitov, Daniel Borkmann,
	Martin KaFai Lau, Song Liu, Yonghong Song, Andrii Nakryiko,
	John Fastabend, KP Singh, David S. Miller, Jakub Kicinski,
	Ferenc Fejes, bpf, linux-kernel

A recent commit added new variables only used if CONFIG_NETDEVICES is
set. A simple fix is to only declare these variables if the same
condition is valid.

Other solutions could be to move the code related to SO_BINDTODEVICE
option from _bpf_setsockopt() function to a dedicated one or only
declare these variables in the related "case" section.

Fixes: 70c58997c1e8 ("bpf: Allow SO_BINDTODEVICE opt in bpf_setsockopt")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---

Notes:
    This fix currently applies on net-next and bpf-next only. Except that
    net-next is now closed and -net will get commits from net-next after
    Linus' pull.
    
    I hope it is fine to have picked [PATCH bpf] and not bpf-next (or net).

 net/core/filter.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/core/filter.c b/net/core/filter.c
index d01a244b5087..ee08c6fcee1a 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4286,9 +4286,11 @@ static const struct bpf_func_proto bpf_get_socket_uid_proto = {
 static int _bpf_setsockopt(struct sock *sk, int level, int optname,
 			   char *optval, int optlen, u32 flags)
 {
+#ifdef CONFIG_NETDEVICES
 	char devname[IFNAMSIZ];
 	struct net *net;
 	int ifindex;
+#endif
 	int ret = 0;
 	int val;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-06-04 20:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03  8:11 [PATCH bpf] bpf: fix unused-var without NETDEVICES Matthieu Baerts
2020-06-03  8:56 ` Ferenc Fejes
2020-06-03  9:12   ` Matthieu Baerts
2020-06-03 18:14     ` Alexei Starovoitov
2020-06-03 18:41       ` Matthieu Baerts
2020-06-03 18:43         ` Alexei Starovoitov
2020-06-03 19:03           ` [PATCH bpf v2] " Matthieu Baerts
2020-06-03 20:45             ` Song Liu
2020-06-04 20:53               ` Daniel Borkmann
2020-06-03 18:59         ` [PATCH bpf] " Ferenc Fejes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).