netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: [PATCH 4/8] netpoll setup error handling
Date: Thu, 26 Oct 2006 15:46:52 -0700	[thread overview]
Message-ID: <20061026225646.011206921@osdl.org> (raw)
In-Reply-To: 20061026225535.443288276@osdl.org

[-- Attachment #1: netpoll-setup-errors.patch --]
[-- Type: text/plain, Size: 2733 bytes --]

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: Stephen Hemminger <shemminger@osdl.org>
---
 drivers/net/netconsole.c |    7 +++++--
 net/core/netpoll.c       |   20 +++++++++++++-------
 2 files changed, 18 insertions(+), 9 deletions(-)

--- linux-2.6.orig/drivers/net/netconsole.c
+++ linux-2.6/drivers/net/netconsole.c
@@ -102,6 +102,8 @@ __setup("netconsole=", option_setup);
 
 static int init_netconsole(void)
 {
+	int err;
+
 	if(strlen(config))
 		option_setup(config);
 
@@ -110,8 +112,9 @@ static int init_netconsole(void)
 		return 0;
 	}
 
-	if(netpoll_setup(&np))
-		return -EINVAL;
+	err = netpoll_setup(&np);
+	if (err)
+		return err;
 
 	register_console(&netconsole);
 	printk(KERN_INFO "netconsole: network logging started\n");
--- linux-2.6.orig/net/core/netpoll.c
+++ linux-2.6/net/core/netpoll.c
@@ -602,20 +602,23 @@ int netpoll_setup(struct netpoll *np)
 	struct in_device *in_dev;
 	struct netpoll_info *npinfo;
 	unsigned long flags;
+	int err;
 
 	if (np->dev_name)
 		ndev = dev_get_by_name(np->dev_name);
 	if (!ndev) {
 		printk(KERN_ERR "%s: %s doesn't exist, aborting.\n",
 		       np->name, np->dev_name);
-		return -1;
+		return -ENODEV;
 	}
 
 	np->dev = ndev;
 	if (!ndev->npinfo) {
 		npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL);
-		if (!npinfo)
+		if (!npinfo) {
+			err = -ENOMEM;
 			goto release;
+		}
 
 		npinfo->rx_flags = 0;
 		npinfo->rx_np = NULL;
@@ -636,6 +639,7 @@ int netpoll_setup(struct netpoll *np)
 	if (!ndev->poll_controller) {
 		printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n",
 		       np->name, np->dev_name);
+		err = -ENOTSUPP;
 		goto release;
 	}
 
@@ -646,13 +650,14 @@ int netpoll_setup(struct netpoll *np)
 		       np->name, np->dev_name);
 
 		rtnl_lock();
-		if (dev_change_flags(ndev, ndev->flags | IFF_UP) < 0) {
+		err = dev_open(ndev);
+		rtnl_unlock();
+
+		if (err) {
 			printk(KERN_ERR "%s: failed to open %s\n",
-			       np->name, np->dev_name);
-			rtnl_unlock();
+			       np->name, ndev->name);
 			goto release;
 		}
-		rtnl_unlock();
 
 		atleast = jiffies + HZ/10;
  		atmost = jiffies + 4*HZ;
@@ -690,6 +695,7 @@ int netpoll_setup(struct netpoll *np)
 			rcu_read_unlock();
 			printk(KERN_ERR "%s: no IP address for %s, aborting\n",
 			       np->name, np->dev_name);
+			err = -EDESTADDRREQ;
 			goto release;
 		}
 
@@ -722,7 +728,7 @@ int netpoll_setup(struct netpoll *np)
 		kfree(npinfo);
 	np->dev = NULL;
 	dev_put(ndev);
-	return -1;
+	return err;
 }
 
 static int __init netpoll_init(void) {

--
Stephen Hemminger <shemminger@osdl.org>


  parent reply	other threads:[~2006-10-26 23:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-26 22:46 [PATCH 0/8] netpoll: A Halloween horror mystery Stephen Hemminger
2006-10-26 22:46 ` [PATCH 1/8] netpoll: skb private pool management Stephen Hemminger
2006-10-27  0:12   ` David Miller
2006-10-27  1:04     ` Stephen Hemminger
2006-10-27  1:08       ` David Miller
2006-10-27  2:29         ` Stephen Hemminger
2006-11-14  1:00           ` David Miller
2006-11-14 21:55             ` netpoll patches Stephen Hemminger
2006-11-15  4:43               ` David Miller
2006-10-26 22:46 ` [PATCH 2/8] netpoll info leak Stephen Hemminger
2006-10-26 22:46 ` [PATCH 3/8] netpoll per device txq Stephen Hemminger
2006-10-26 22:46 ` Stephen Hemminger [this message]
2006-10-26 22:46 ` [PATCH 5/8] netpoll deferred transmit path Stephen Hemminger
2006-10-26 22:46 ` [PATCH 6/8] netpoll retry cleanup Stephen Hemminger
2006-10-26 22:46 ` [PATCH 7/8] netpoll queue cleanup Stephen Hemminger
2006-10-26 22:46 ` [PATCH 8/8] netpoll header cleanup Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061026225646.011206921@osdl.org \
    --to=shemminger@osdl.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).