Skip to contentSkip to conversation

net: ignore sysctl_devconf_inherit_init_net without SYSCTL

PATCH Applied Arnd Bergmann 3 participants 5 messages Mar 4, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: ignore sysctl_devconf_inherit_init_net without SYSCTL

When CONFIG_SYSCTL is turned off, we get a link failure for the newly introduced tuning knob.

net/ipv6/addrconf.o: In function `addrconf_init_net':
addrconf.c:(.text+0x31dc): undefined reference to `sysctl_devconf_inherit_init_net'

Add an IS_ENABLED() check to fall back to the default behavior (sysctl_devconf_inherit_init_net=0) here.

Fixes 856c395cfa63 ("net: introduce a knob to control whether to inherit devconf config")
---
 net/ipv4/devinet.c  | 4 +++-
 net/ipv6/addrconf.c | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)
net/ipv4/devinet.c +3 -1
index cd9033245b98..eb514f312e6f 100644
@@ -2614,7 +2614,9 @@ static __net_init int devinet_init_net(struct net *net)
 	tbl[0].extra2 = net;
 #endif
 
-	if (sysctl_devconf_inherit_init_net != 2 && !net_eq(net, &init_net)) {
+	if ((!IS_ENABLED(CONFIG_SYSCTL) ||
+	     sysctl_devconf_inherit_init_net != 2) &&
+	    !net_eq(net, &init_net)) {
 		memcpy(all, init_net.ipv4.devconf_all, sizeof(ipv4_devconf));
 		memcpy(dflt, init_net.ipv4.devconf_dflt, sizeof(ipv4_devconf_dflt));
 	}
net/ipv6/addrconf.c +2 -1
index da5a21050ba9..4ae17a966ae3 100644
@@ -6905,7 +6905,8 @@ static int __net_init addrconf_init_net(struct net *net)
 	if (!dflt)
 		goto err_alloc_dflt;
 
-	if (sysctl_devconf_inherit_init_net == 1 && !net_eq(net, &init_net)) {
+	if (IS_ENABLED(CONFIG_SYSCTL) &&
+	    sysctl_devconf_inherit_init_net == 1 && !net_eq(net, &init_net)) {
 		memcpy(all, init_net.ipv6.devconf_all, sizeof(ipv6_devconf));
 		memcpy(dflt, init_net.ipv6.devconf_dflt, sizeof(ipv6_devconf_dflt));
 	}
Signature · 1 line
2.20.0
#1 lore raw
Quoted 21 lines · Arnd Bergmann

When CONFIG_SYSCTL is turned off, we get a link failure for the newly introduced tuning knob.

net/ipv6/addrconf.o: In function `addrconf_init_net':
addrconf.c:(.text+0x31dc): undefined reference to `sysctl_devconf_inherit_init_net'

Add an IS_ENABLED() check to fall back to the default behavior (sysctl_devconf_inherit_init_net=0) here.

Fixes 856c395cfa63 ("net: introduce a knob to control whether to inherit devconf config")
---
 net/ipv4/devinet.c  | 4 +++-
 net/ipv6/addrconf.c | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)
net/ipv4/devinet.c +0 -0
index cd9033245b98..eb514f312e6f 100644

net/ipv4/devinet.c static __net_init int devinet_init_net(struct net *net) · line 2618

Quoted 6 lines
net/ipv4/devinet.c +2 -1
@@ -2614,7 +2614,9 @@ static __net_init int devinet_init_net(struct net *net)
 	tbl[0].extra2 = net;
 #endif
 
-	if (sysctl_devconf_inherit_init_net != 2 && !net_eq(net, &init_net)) {
+	if ((!IS_ENABLED(CONFIG_SYSCTL) ||
+	     sysctl_devconf_inherit_init_net != 2) &&

I'm sure I'm just being stupid here but wouldn't this still trigger the warning or is sysctl_devconf_inherit_init_net unconditionally defined? The error you're reporting makes it look like it isn't.

Quoted 21 lines
net/ipv4/devinet.c +1 -0
+	    !net_eq(net, &init_net)) {
 		memcpy(all, init_net.ipv4.devconf_all, sizeof(ipv4_devconf));
 		memcpy(dflt, init_net.ipv4.devconf_dflt, sizeof(ipv4_devconf_dflt));
 	}
net/ipv6/addrconf.c +2 -1
index da5a21050ba9..4ae17a966ae3 100644
@@ -6905,7 +6905,8 @@ static int __net_init addrconf_init_net(struct net *net)
 	if (!dflt)
 		goto err_alloc_dflt;
 
-	if (sysctl_devconf_inherit_init_net == 1 && !net_eq(net, &init_net)) {
+	if (IS_ENABLED(CONFIG_SYSCTL) &&
+	    sysctl_devconf_inherit_init_net == 1 && !net_eq(net, &init_net)) {
 		memcpy(all, init_net.ipv6.devconf_all, sizeof(ipv6_devconf));
 		memcpy(dflt, init_net.ipv6.devconf_dflt, sizeof(ipv6_devconf_dflt));
 	}
Signature · 1 line
2.20.0
#2 lore raw
Quoted 26 lines · Christian Brauner
Quoted 24 lines · Arnd Bergmann

When CONFIG_SYSCTL is turned off, we get a link failure for the newly introduced tuning knob.

net/ipv6/addrconf.o: In function `addrconf_init_net':
addrconf.c:(.text+0x31dc): undefined reference to `sysctl_devconf_inherit_init_net'

Add an IS_ENABLED() check to fall back to the default behavior (sysctl_devconf_inherit_init_net=0) here.

Fixes 856c395cfa63 ("net: introduce a knob to control whether to inherit devconf config")
---
 net/ipv4/devinet.c  | 4 +++-
 net/ipv6/addrconf.c | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)
net/ipv4/devinet.c +0 -0
index cd9033245b98..eb514f312e6f 100644
@@ -2614,7 +2614,9 @@ static __net_init int devinet_init_net(struct net *net)
      tbl[0].extra2 = net;
 #endif
 
Quoted 7 lines

net/ipv4/devinet.c static __net_init int devinet_init_net(struct net *net) · line 2618

Quoted 3 lines
net/ipv4/devinet.c +2 -1
-     if (sysctl_devconf_inherit_init_net != 2 && !net_eq(net, &init_net)) {
+     if ((!IS_ENABLED(CONFIG_SYSCTL) ||
+          sysctl_devconf_inherit_init_net != 2) &&

I'm sure I'm just being stupid here but wouldn't this still trigger the warning or is sysctl_devconf_inherit_init_net unconditionally defined? The error you're reporting makes it look like it isn't.

The declaration is unconditional in include/linux/netdevice.h, so the compiler does not see a problem, it simply doesn't create a reference when it sees that the code path is dead.

The error message I quoted is from the linker, so this is in turn not a problem after there is no reference to the variable.

Arnd

#3 lore raw
Quoted 35 lines · Arnd Bergmann
Quoted 26 lines · Christian Brauner
Quoted 24 lines · Arnd Bergmann

When CONFIG_SYSCTL is turned off, we get a link failure for the newly introduced tuning knob.

net/ipv6/addrconf.o: In function `addrconf_init_net':
addrconf.c:(.text+0x31dc): undefined reference to `sysctl_devconf_inherit_init_net'

Add an IS_ENABLED() check to fall back to the default behavior (sysctl_devconf_inherit_init_net=0) here.

Fixes 856c395cfa63 ("net: introduce a knob to control whether to inherit devconf config")
---
 net/ipv4/devinet.c  | 4 +++-
 net/ipv6/addrconf.c | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)
net/ipv4/devinet.c +0 -0
index cd9033245b98..eb514f312e6f 100644
@@ -2614,7 +2614,9 @@ static __net_init int devinet_init_net(struct net *net)
      tbl[0].extra2 = net;
 #endif
 
Quoted 7 lines

net/ipv4/devinet.c static __net_init int devinet_init_net(struct net *net) · line 2618

Quoted 3 lines
net/ipv4/devinet.c +2 -1
-     if (sysctl_devconf_inherit_init_net != 2 && !net_eq(net, &init_net)) {
+     if ((!IS_ENABLED(CONFIG_SYSCTL) ||
+          sysctl_devconf_inherit_init_net != 2) &&

I'm sure I'm just being stupid here but wouldn't this still trigger the warning or is sysctl_devconf_inherit_init_net unconditionally defined? The error you're reporting makes it look like it isn't.

Quoted 6 lines

The declaration is unconditional in include/linux/netdevice.h, so the compiler does not see a problem, it simply doesn't create a reference when it sees that the code path is dead.

The error message I quoted is from the linker, so this is in turn not a problem after there is no reference to the variable.

Perfect!

maintainer Applied
#4 lore raw
In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>
Date: Mon, 4 Mar 2019 21:38:03 +0100

Quoted 11 lines

When CONFIG_SYSCTL is turned off, we get a link failure for the newly introduced tuning knob.

net/ipv6/addrconf.o: In function `addrconf_init_net':
addrconf.c:(.text+0x31dc): undefined reference to `sysctl_devconf_inherit_init_net'

Add an IS_ENABLED() check to fall back to the default behavior (sysctl_devconf_inherit_init_net=0) here.

Fixes 856c395cfa63 ("net: introduce a knob to control whether to inherit devconf config")

Applied, thanks Arnd.