aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeaceslav Falico <vfalico@gmail.com>2014-07-17 13:46:10 -0400
committerDavid S. Miller <davem@davemloft.net>2014-07-20 23:38:43 -0400
commitccc7f4968a18b980994e622006b84e0195754390 (patch)
tree92c83d2cbb4ff1a24b21295853f3c5008d1d0158
parentc6f854d57d704a97adbf952ef0948acc68f3312c (diff)
net: print net_device reg_state in netdev_* unless it's registered
This way we'll always know in what status the device is, unless it's running normally (i.e. NETDEV_REGISTERED). Also, emit a warning once in case of a bad reg_state. CC: "David S. Miller" <davem@davemloft.net> CC: Jason Baron <jbaron@akamai.com> CC: Eric Dumazet <edumazet@google.com> CC: Vlad Yasevich <vyasevic@redhat.com> CC: stephen hemminger <stephen@networkplumber.org> CC: Jerry Chu <hkchu@google.com> CC: Ben Hutchings <bhutchings@solarflare.com> CC: Joe Perches <joe@perches.com> Signed-off-by: Veaceslav Falico <vfalico@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/netdevice.h18
-rw-r--r--lib/dynamic_debug.c8
-rw-r--r--net/core/dev.c8
3 files changed, 27 insertions, 7 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 70256aa2ae81..8e8fb3ed574b 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3388,6 +3388,21 @@ static inline const char *netdev_name(const struct net_device *dev)
3388 return dev->name; 3388 return dev->name;
3389} 3389}
3390 3390
3391static inline const char *netdev_reg_state(const struct net_device *dev)
3392{
3393 switch (dev->reg_state) {
3394 case NETREG_UNINITIALIZED: return " (uninitialized)";
3395 case NETREG_REGISTERED: return "";
3396 case NETREG_UNREGISTERING: return " (unregistering)";
3397 case NETREG_UNREGISTERED: return " (unregistered)";
3398 case NETREG_RELEASED: return " (released)";
3399 case NETREG_DUMMY: return " (dummy)";
3400 }
3401
3402 WARN_ONCE(1, "%s: unknown reg_state %d\n", dev->name, dev->reg_state);
3403 return " (unknown)";
3404}
3405
3391__printf(3, 4) 3406__printf(3, 4)
3392int netdev_printk(const char *level, const struct net_device *dev, 3407int netdev_printk(const char *level, const struct net_device *dev,
3393 const char *format, ...); 3408 const char *format, ...);
@@ -3444,7 +3459,8 @@ do { \
3444 * file/line information and a backtrace. 3459 * file/line information and a backtrace.
3445 */ 3460 */
3446#define netdev_WARN(dev, format, args...) \ 3461#define netdev_WARN(dev, format, args...) \
3447 WARN(1, "netdevice: %s\n" format, netdev_name(dev), ##args) 3462 WARN(1, "netdevice: %s%s\n" format, netdev_name(dev), \
3463 netdev_reg_state(dev), ##args)
3448 3464
3449/* netif printk helpers, similar to netdev_printk */ 3465/* netif printk helpers, similar to netdev_printk */
3450 3466
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 7288e38e1757..c9afbe2c445a 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -614,13 +614,15 @@ int __dynamic_netdev_dbg(struct _ddebug *descriptor,
614 char buf[PREFIX_SIZE]; 614 char buf[PREFIX_SIZE];
615 615
616 res = dev_printk_emit(7, dev->dev.parent, 616 res = dev_printk_emit(7, dev->dev.parent,
617 "%s%s %s %s: %pV", 617 "%s%s %s %s%s: %pV",
618 dynamic_emit_prefix(descriptor, buf), 618 dynamic_emit_prefix(descriptor, buf),
619 dev_driver_string(dev->dev.parent), 619 dev_driver_string(dev->dev.parent),
620 dev_name(dev->dev.parent), 620 dev_name(dev->dev.parent),
621 netdev_name(dev), &vaf); 621 netdev_name(dev), netdev_reg_state(dev),
622 &vaf);
622 } else if (dev) { 623 } else if (dev) {
623 res = printk(KERN_DEBUG "%s: %pV", netdev_name(dev), &vaf); 624 res = printk(KERN_DEBUG "%s%s: %pV", netdev_name(dev),
625 netdev_reg_state(dev), &vaf);
624 } else { 626 } else {
625 res = printk(KERN_DEBUG "(NULL net_device): %pV", &vaf); 627 res = printk(KERN_DEBUG "(NULL net_device): %pV", &vaf);
626 } 628 }
diff --git a/net/core/dev.c b/net/core/dev.c
index 239722af098d..81d61014fd9b 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6950,12 +6950,14 @@ static int __netdev_printk(const char *level, const struct net_device *dev,
6950 if (dev && dev->dev.parent) { 6950 if (dev && dev->dev.parent) {
6951 r = dev_printk_emit(level[1] - '0', 6951 r = dev_printk_emit(level[1] - '0',
6952 dev->dev.parent, 6952 dev->dev.parent,
6953 "%s %s %s: %pV", 6953 "%s %s %s%s: %pV",
6954 dev_driver_string(dev->dev.parent), 6954 dev_driver_string(dev->dev.parent),
6955 dev_name(dev->dev.parent), 6955 dev_name(dev->dev.parent),
6956 netdev_name(dev), vaf); 6956 netdev_name(dev), netdev_reg_state(dev),
6957 vaf);
6957 } else if (dev) { 6958 } else if (dev) {
6958 r = printk("%s%s: %pV", level, netdev_name(dev), vaf); 6959 r = printk("%s%s%s: %pV", level, netdev_name(dev),
6960 netdev_reg_state(dev), vaf);
6959 } else { 6961 } else {
6960 r = printk("%s(NULL net_device): %pV", level, vaf); 6962 r = printk("%s(NULL net_device): %pV", level, vaf);
6961 } 6963 }