netpoll_setup questions
Hi, Matt,
The section of code in the body of this if statement:
if (!(ndev->flags & IFF_UP)) {is a bit broken. First, upon discussion with jgarzik, it seems we should not check for IFF_UP, but instead do netif_running. However, I'm wondering why we try to force the interface up in the first place? Just because we force it up doesn't mean that it will get an IP address. And, in the case where it doesn't, you will get an oops further on when dereferencing the ifa_list. So, why does this section of code exist at all? If it has a good purpose, can we replace it with a call to ndev->open?
Thanks!
Jeff
Quoted 8 lines · Jeff Moyer
Hi, Matt,
The section of code in the body of this if statement:
if (!(ndev->flags & IFF_UP)) {is a bit broken. First, upon discussion with jgarzik, it seems we should not check for
IFF_UP, but instead donetif_running.
Well I cribbed it from the nfsroot code, which is perhaps not up on fashion.
Quoted 2 lines
However, I'm wondering why we try to force the interface up in the first place?
Uh, so we can send packets before userspace has configured the network?
Quoted 2 lines
Just because we force it up doesn't mean that it will get an IP address.
I don't expect it does. Usually we have our own IP address from the command line, but if we don't, we will check if there's an in_dev connected to the device and if so, look up the device's IP. This is useful for the modular case where the network is up before we start and we have a handy default for local IP.
Quoted 2 lines
And, in the case where it doesn't, you will get an oops further on when dereferencing the
ifa_list.
Does this actually happen? I'm checking in_dev for null already, but perhaps I need to check ifa_list as well.
Quoted 2 lines
So, why does this section of code exist at all? If it has a good purpose, can we replace it with a call to
ndev->open?
Maybe. We should probably revisit the nfsroot code as well.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
==> Regarding Re: netpoll_setup questions; Matt Mackall <[email protected]> adds:
Quoted 8 lines · Jeff Moyer
Quoted 8 lines
Hi, Matt,
The section of code in the body of this if statement:
if (!(ndev->flags &
IFF_UP)) {is a bit broken. First, upon discussion with jgarzik, it seems we should not check for
IFF_UP, but instead donetif_running.
mpm> Well I cribbed it from the nfsroot code, which is perhaps not up on mpm> fashion.
Hmm, I can't seem to find the relevant code. Where is it?
Quoted 2 lines
Quoted 2 lines
However, I'm wondering why we try to force the interface up in the first place?
mpm> Uh, so we can send packets before userspace has configured the mpm> network?
Heh. right.
Quoted 1 line
Quoted 1 line
Just because we force it up doesn't mean that it will get an IP address.
mpm> I don't expect it does. Usually we have our own IP address from the mpm> command line, but if we don't, we will check if there's an in_dev mpm> connected to the device and if so, look up the device's IP. This is mpm> useful for the modular case where the network is up before we start mpm> and we have a handy default for local IP.
Right, but the case in question is the one where we don't have a local IP specified:
if (!np->local_ip) {
rcu_read_lock();
in_dev = __in_dev_get(ndev);
if (!in_dev) {
rcu_read_unlock();
printk(KERN_ERR "%s: no IP address for %s, aborting\n",
np->name, np->dev_name);
goto release;
}
np->local_ip = ntohl(in_dev->ifa_list->ifa_local);
rcu_read_unlock();
printk(KERN_INFO "%s: local IP %d.%d.%d.%d\n",
np->name, HIPQUAD(np->local_ip));
}Quoted 2 lines
Quoted 2 lines
And, in the case where it doesn't, you will get an oops further on when dereferencing the
ifa_list.
mpm> Does this actually happen? I'm checking in_dev for null already, but mpm> perhaps I need to check ifa_list as well.
Yes, that should do it.
Quoted 2 lines
Quoted 2 lines
So, why does this section of code exist at all? If it has a good purpose, can we replace it with a call to
ndev->open?
mpm> Maybe. We should probably revisit the nfsroot code as well.
Right, just point me at it.
Here is a patch which should work. I'll test today.
-Jeff
net/core/netpoll.c renamed from net/core/netpoll.c~ +2 -2
@@ -571,7 +571,7 @@ int netpoll_setup(struct netpoll *np) goto release; } -if (!(ndev->flags &IFF_UP )) { +if (!netif_running (ndev)) {unsigned short oflags;unsigned long atmost, atleast;
@@ -617,7 +617,7 @@ int netpoll_setup(struct netpoll *np)rcu_read_lock (); in_dev =__in_dev_get (ndev); -if (!in_dev) { +if (!in_dev || !in_dev->ifa_list) {rcu_read_unlock ();printk (KERN_ERR "%s: no IP address for %s, aborting\n" , np->name, np->dev_name);
Quoted 9 lines · Jeff Moyer
==> Regarding Re:
netpoll_setupquestions; Matt Mackall <[email protected]> adds:Quoted 6 lines · Jeff Moyer
Quoted 6 lines
Hi, Matt,
The section of code in the body of this if statement:
if (!(ndev->flags &
IFF_UP)) {
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
is a bit broken. First, upon discussion with jgarzik, it seems we should not check for
IFF_UP, but instead donetif_running.mpm> Well I cribbed it from the nfsroot code, which is perhaps not up on mpm> fashion.
Hmm, I can't seem to find the relevant code. Where is it?
net/ipv4/ipconfig.c, IIRC.
Quoted 8 lines
mpm> I don't expect it does. Usually we have our own IP address from the mpm> command line, but if we don't, we will check if there's an
in_devmpm> connected to the device and if so, look up the device's IP. This is mpm> useful for the modular case where the network is up before we start mpm> and we have a handy default for local IP.Right, but the case in question is the one where we don't have a local IP specified:
Yeah..
Quoted 1 line
if (!np->local_ip) {"but if we don't"
Quoted 4 lines
rcu_read_lock();
in_dev = __in_dev_get(ndev);
if (!in_dev) {"we will check if there's an in_dev"
Quoted 7 lines
rcu_read_unlock(); printk(KERN_ERR "%s: no IP address for %s, aborting\n", np->name, np->dev_name); goto release; } np->local_ip = ntohl(in_dev->ifa_list->ifa_local);
"if so, look up the device's IP"
Quoted 6 lines
rcu_read_unlock(); printk(KERN_INFO "%s: local IP %d.%d.%d.%d\n", np->name, HIPQUAD(np->local_ip)); }
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
And, in the case where it doesn't, you will get an oops further on when dereferencing the
ifa_list.mpm> Does this actually happen? I'm checking
in_devfor null already, but mpm> perhaps I need to checkifa_listas well.Yes, that should do it.
Again, does the oops actually happen? I'd expect I'd have seen it by now if this were really a problem, but I don't mind adding another check.
Quoted 16 lines
Here is a patch which should work. I'll test today.
(quoted diff) +0
-1-Jeffnet/core/netpoll.c renamed from net/core/netpoll.c~ +1
-1@@ -571,7 +571,7 @@ int netpoll_setup(struct netpoll *np) goto release; } -if (!(ndev->flags &IFF_UP )) { +if (!netif_running (ndev)) {unsigned short oflags;unsigned long atmost, atleast;
net/core/netpoll.c int netpoll_setup(struct netpoll *np) · line 623
Quoted 8 lines
net/core/netpoll.c renamed from net/core/netpoll.c~ +1
-1@@ -617,7 +617,7 @@ int netpoll_setup(struct netpoll *np)rcu_read_lock (); in_dev =__in_dev_get (ndev); -if (!in_dev) { +if (!in_dev || !in_dev->ifa_list) {rcu_read_unlock ();printk (KERN_ERR "%s: no IP address for %s, aborting\n" , np->name, np->dev_name);
Looks good to me.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
==> Regarding Re: netpoll_setup questions; Matt Mackall <[email protected]> adds:
Quoted 3 lines · Jeff Moyer
Quoted 3 lines
==> Regarding Re:
netpoll_setupquestions; Matt Mackall <[email protected]> adds:
Quoted 9 lines · Jeff Moyer
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Hi, Matt,
The section of code in the body of this if statement:
if (!(ndev->flags &
IFF_UP)) {is a bit broken. First, upon discussion with jgarzik, it seems we >>
should not check for
IFF_UP, but instead donetif_running.
mpm> Well I cribbed it from the nfsroot code, which is perhaps not up on mpm> fashion.
Quoted 1 line
Quoted 1 line
Hmm, I can't seem to find the relevant code. Where is it?
mpm> net/ipv4/ipconfig.c, IIRC.
mpm> I don't expect it does. Usually we have our own IP address from the mpm> command line, but if we don't, we will check if there's an in_dev mpm> connected to the device and if so, look up the device's IP. This is mpm> useful for the modular case where the network is up before we start mpm> and we have a handy default for local IP.
Quoted 2 lines
Quoted 2 lines
Right, but the case in question is the one where we don't have a local IP
specified>
mpm> Yeah..
Quoted 1 line
Quoted 1 line
if (!np->local_ip) {
mpm> "but if we don't"
Quoted 3 lines
Quoted 3 lines
rcu_read_lock();in_dev=__in_dev_get(ndev);if (!in_dev) {
mpm> "we will check if there's an in_dev"
Quoted 2 lines
Quoted 2 lines
rcu_read_unlock(); printk(KERN_ERR "%s: no IP address for %s, aborting\n",
np-> name, np->dev_name);
Quoted 2 lines
Quoted 2 lines
goto release; }
np-> local_ip = ntohl(in_dev->ifa_list->ifa_local);
mpm> "if so, look up the device's IP"
Quoted 1 line
Quoted 1 line
rcu_read_unlock(); printk(KERN_INFO "%s: local IP %d.%d.%d.%d\n",
np-> name, HIPQUAD(np->local_ip));
Quoted 6 lines
Quoted 6 lines
}
Quoted 1 line
Quoted 1 line
And, in the case where it doesn't, you will get an oops further on
when >> dereferencing the
ifa_list.
mpm> Does this actually happen? I'm checking in_dev for null already, but mpm> perhaps I need to check ifa_list as well.
Quoted 1 line
Quoted 1 line
Yes, that should do it.
mpm> Again, does the oops actually happen? I'd expect I'd have seen it by mpm> now if this were really a problem, but I don't mind adding another mpm> check.
I'm sorry, I should have said this before. Yes, it occurs. You simply need to have an interface in the down state, plugged into a network that will not auto-assign an address. Then, modprobe netconsole, and don't specify what the local IP address is. Believe it or not, I have a bug filed on this. ;)
-Jeff
Quoted 9 lines · Jeff Moyer
mpm> Again, does the oops actually happen? I'd expect I'd have seen it by mpm> now if this were really a problem, but I don't mind adding another mpm> check.
I'm sorry, I should have said this before. Yes, it occurs. You simply need to have an interface in the down state, plugged into a network that will not auto-assign an address. Then, modprobe netconsole, and don't specify what the local IP address is. Believe it or not, I have a bug filed on this. ;)
Ok, fair enough. Resend your patch when you've tested it and I'll forward it on to Andrew.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
==> Regarding Re: netpoll_setup questions; Matt Mackall <[email protected]> adds:
mpm> On Wed, Oct 27, 2004 at 03:44:33PM -0400, Jeff Moyer wrote: Again, mpm> does the oops actually happen? I'd expect I'd have seen it by now if mpm> this were really a problem, but I don't mind adding another check.
Quoted 5 lines
Quoted 5 lines
I'm sorry, I should have said this before. Yes, it occurs. You simply need to have an interface in the down state, plugged into a network that will not auto-assign an address. Then, modprobe netconsole, and don't specify what the local IP address is. Believe it or not, I have a bug filed on this. ;)
mpm> Ok, fair enough. Resend your patch when you've tested it and I'll mpm> forward it on to Andrew.
Patch attached, unchanged. This did indeed fix the problem.
-Jeff
Signed-off by: Jeff Moyer <[email protected]>
net/core/netpoll.c renamed from net/core/netpoll.c~ +2 -2
@@ -571,7 +571,7 @@ int netpoll_setup(struct netpoll *np) goto release; } -if (!(ndev->flags &IFF_UP )) { +if (!netif_running (ndev)) {unsigned short oflags;unsigned long atmost, atleast;
@@ -617,7 +617,7 @@ int netpoll_setup(struct netpoll *np)rcu_read_lock (); in_dev =__in_dev_get (ndev); -if (!in_dev) { +if (!in_dev || !in_dev->ifa_list) {rcu_read_unlock ();printk (KERN_ERR "%s: no IP address for %s, aborting\n" , np->name, np->dev_name);