linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: ignore sysctl_devconf_inherit_init_net without SYSCTL
@ 2019-03-04 20:38 Arnd Bergmann
  2019-03-04 21:00 ` Christian Brauner
  2019-03-04 21:14 ` David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2019-03-04 20:38 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI
  Cc: Zhu Yanjun, Tonghao Zhang, Nicolas Dichtel, Arnd Bergmann,
	David Ahern, Christian Brauner, Xin Long, Cong Wang, netdev,
	linux-kernel

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")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 net/ipv4/devinet.c  | 4 +++-
 net/ipv6/addrconf.c | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index cd9033245b98..eb514f312e6f 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -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));
 	}
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index da5a21050ba9..4ae17a966ae3 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -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));
 	}
-- 
2.20.0


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

* Re: [PATCH] net: ignore sysctl_devconf_inherit_init_net without SYSCTL
  2019-03-04 20:38 [PATCH] net: ignore sysctl_devconf_inherit_init_net without SYSCTL Arnd Bergmann
@ 2019-03-04 21:00 ` Christian Brauner
  2019-03-04 21:07   ` Arnd Bergmann
  2019-03-04 21:14 ` David Miller
  1 sibling, 1 reply; 5+ messages in thread
From: Christian Brauner @ 2019-03-04 21:00 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI, Zhu Yanjun,
	Tonghao Zhang, Nicolas Dichtel, David Ahern, Xin Long, Cong Wang,
	netdev, linux-kernel

On Mon, Mar 04, 2019 at 09:38:03PM +0100, Arnd Bergmann wrote:
> 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")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  net/ipv4/devinet.c  | 4 +++-
>  net/ipv6/addrconf.c | 3 ++-
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
> index cd9033245b98..eb514f312e6f 100644
> --- a/net/ipv4/devinet.c
> +++ b/net/ipv4/devinet.c
> @@ -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.

> +	    !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));
>  	}
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index da5a21050ba9..4ae17a966ae3 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -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));
>  	}
> -- 
> 2.20.0
> 

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

* Re: [PATCH] net: ignore sysctl_devconf_inherit_init_net without SYSCTL
  2019-03-04 21:00 ` Christian Brauner
@ 2019-03-04 21:07   ` Arnd Bergmann
  2019-03-04 21:08     ` Christian Brauner
  0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2019-03-04 21:07 UTC (permalink / raw)
  To: Christian Brauner
  Cc: David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI, Zhu Yanjun,
	Tonghao Zhang, Nicolas Dichtel, David Ahern, Xin Long, Cong Wang,
	Networking, Linux Kernel Mailing List

On Mon, Mar 4, 2019 at 10:00 PM Christian Brauner <christian@brauner.io> wrote:
>
> On Mon, Mar 04, 2019 at 09:38:03PM +0100, Arnd Bergmann wrote:
> > 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")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ---
> >  net/ipv4/devinet.c  | 4 +++-
> >  net/ipv6/addrconf.c | 3 ++-
> >  2 files changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
> > index cd9033245b98..eb514f312e6f 100644
> > --- a/net/ipv4/devinet.c
> > +++ b/net/ipv4/devinet.c
> > @@ -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.

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

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

* Re: [PATCH] net: ignore sysctl_devconf_inherit_init_net without SYSCTL
  2019-03-04 21:07   ` Arnd Bergmann
@ 2019-03-04 21:08     ` Christian Brauner
  0 siblings, 0 replies; 5+ messages in thread
From: Christian Brauner @ 2019-03-04 21:08 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI, Zhu Yanjun,
	Tonghao Zhang, Nicolas Dichtel, David Ahern, Xin Long, Cong Wang,
	Networking, Linux Kernel Mailing List

On Mon, Mar 04, 2019 at 10:07:17PM +0100, Arnd Bergmann wrote:
> On Mon, Mar 4, 2019 at 10:00 PM Christian Brauner <christian@brauner.io> wrote:
> >
> > On Mon, Mar 04, 2019 at 09:38:03PM +0100, Arnd Bergmann wrote:
> > > 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")
> > > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > > ---
> > >  net/ipv4/devinet.c  | 4 +++-
> > >  net/ipv6/addrconf.c | 3 ++-
> > >  2 files changed, 5 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
> > > index cd9033245b98..eb514f312e6f 100644
> > > --- a/net/ipv4/devinet.c
> > > +++ b/net/ipv4/devinet.c
> > > @@ -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.
> 
> 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!

Acked-by: Christian Brauner <christian@brauner.io>

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

* Re: [PATCH] net: ignore sysctl_devconf_inherit_init_net without SYSCTL
  2019-03-04 20:38 [PATCH] net: ignore sysctl_devconf_inherit_init_net without SYSCTL Arnd Bergmann
  2019-03-04 21:00 ` Christian Brauner
@ 2019-03-04 21:14 ` David Miller
  1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2019-03-04 21:14 UTC (permalink / raw)
  To: arnd
  Cc: kuznet, yoshfuji, Yanjun.Zhu, xiangxia.m.yue, nicolas.dichtel,
	dsahern, christian, lucien.xin, xiyou.wangcong, netdev,
	linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Mon,  4 Mar 2019 21:38:03 +0100

> 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")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied, thanks Arnd.

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

end of thread, other threads:[~2019-03-04 21:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-04 20:38 [PATCH] net: ignore sysctl_devconf_inherit_init_net without SYSCTL Arnd Bergmann
2019-03-04 21:00 ` Christian Brauner
2019-03-04 21:07   ` Arnd Bergmann
2019-03-04 21:08     ` Christian Brauner
2019-03-04 21:14 ` David Miller

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).