Commit b41848b6 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller

netpoll setup error handling

The beast was not always healthy. When it was sick,
it tended to be laconic and not tell anyone the real problem.
A few small changes had it telling the world about its
problems, if they really wanted to hear.
Signed-off-by: default avatarStephen Hemminger <shemminger@osdl.org>
parent b6cd27ed
...@@ -102,6 +102,8 @@ __setup("netconsole=", option_setup); ...@@ -102,6 +102,8 @@ __setup("netconsole=", option_setup);
static int init_netconsole(void) static int init_netconsole(void)
{ {
int err;
if(strlen(config)) if(strlen(config))
option_setup(config); option_setup(config);
...@@ -110,8 +112,9 @@ static int init_netconsole(void) ...@@ -110,8 +112,9 @@ static int init_netconsole(void)
return 0; return 0;
} }
if(netpoll_setup(&np)) err = netpoll_setup(&np);
return -EINVAL; if (err)
return err;
register_console(&netconsole); register_console(&netconsole);
printk(KERN_INFO "netconsole: network logging started\n"); printk(KERN_INFO "netconsole: network logging started\n");
......
...@@ -611,20 +611,23 @@ int netpoll_setup(struct netpoll *np) ...@@ -611,20 +611,23 @@ int netpoll_setup(struct netpoll *np)
struct in_device *in_dev; struct in_device *in_dev;
struct netpoll_info *npinfo; struct netpoll_info *npinfo;
unsigned long flags; unsigned long flags;
int err;
if (np->dev_name) if (np->dev_name)
ndev = dev_get_by_name(np->dev_name); ndev = dev_get_by_name(np->dev_name);
if (!ndev) { if (!ndev) {
printk(KERN_ERR "%s: %s doesn't exist, aborting.\n", printk(KERN_ERR "%s: %s doesn't exist, aborting.\n",
np->name, np->dev_name); np->name, np->dev_name);
return -1; return -ENODEV;
} }
np->dev = ndev; np->dev = ndev;
if (!ndev->npinfo) { if (!ndev->npinfo) {
npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL); npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL);
if (!npinfo) if (!npinfo) {
err = -ENOMEM;
goto release; goto release;
}
npinfo->rx_flags = 0; npinfo->rx_flags = 0;
npinfo->rx_np = NULL; npinfo->rx_np = NULL;
...@@ -645,6 +648,7 @@ int netpoll_setup(struct netpoll *np) ...@@ -645,6 +648,7 @@ int netpoll_setup(struct netpoll *np)
if (!ndev->poll_controller) { if (!ndev->poll_controller) {
printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n", printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n",
np->name, np->dev_name); np->name, np->dev_name);
err = -ENOTSUPP;
goto release; goto release;
} }
...@@ -655,13 +659,14 @@ int netpoll_setup(struct netpoll *np) ...@@ -655,13 +659,14 @@ int netpoll_setup(struct netpoll *np)
np->name, np->dev_name); np->name, np->dev_name);
rtnl_lock(); rtnl_lock();
if (dev_change_flags(ndev, ndev->flags | IFF_UP) < 0) { err = dev_open(ndev);
printk(KERN_ERR "%s: failed to open %s\n",
np->name, np->dev_name);
rtnl_unlock(); rtnl_unlock();
if (err) {
printk(KERN_ERR "%s: failed to open %s\n",
np->name, ndev->name);
goto release; goto release;
} }
rtnl_unlock();
atleast = jiffies + HZ/10; atleast = jiffies + HZ/10;
atmost = jiffies + 4*HZ; atmost = jiffies + 4*HZ;
...@@ -699,6 +704,7 @@ int netpoll_setup(struct netpoll *np) ...@@ -699,6 +704,7 @@ int netpoll_setup(struct netpoll *np)
rcu_read_unlock(); rcu_read_unlock();
printk(KERN_ERR "%s: no IP address for %s, aborting\n", printk(KERN_ERR "%s: no IP address for %s, aborting\n",
np->name, np->dev_name); np->name, np->dev_name);
err = -EDESTADDRREQ;
goto release; goto release;
} }
...@@ -731,7 +737,7 @@ int netpoll_setup(struct netpoll *np) ...@@ -731,7 +737,7 @@ int netpoll_setup(struct netpoll *np)
kfree(npinfo); kfree(npinfo);
np->dev = NULL; np->dev = NULL;
dev_put(ndev); dev_put(ndev);
return -1; return err;
} }
static int __init netpoll_init(void) { static int __init netpoll_init(void) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment