diff options
-rw-r--r-- | include/linux/netdevice.h | 3 | ||||
-rw-r--r-- | lib/dynamic_debug.c | 26 | ||||
-rw-r--r-- | net/core/dev.c | 24 |
3 files changed, 40 insertions, 13 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 59dc05f38247..5f49cc0a107e 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -2720,9 +2720,6 @@ static inline const char *netdev_name(const struct net_device *dev) | |||
2720 | return dev->name; | 2720 | return dev->name; |
2721 | } | 2721 | } |
2722 | 2722 | ||
2723 | extern int __netdev_printk(const char *level, const struct net_device *dev, | ||
2724 | struct va_format *vaf); | ||
2725 | |||
2726 | extern __printf(3, 4) | 2723 | extern __printf(3, 4) |
2727 | int netdev_printk(const char *level, const struct net_device *dev, | 2724 | int netdev_printk(const char *level, const struct net_device *dev, |
2728 | const char *format, ...); | 2725 | const char *format, ...); |
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 29ff2e4cfb75..2a29f4e04bdf 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c | |||
@@ -611,20 +611,40 @@ EXPORT_SYMBOL(__dynamic_dev_dbg); | |||
611 | #ifdef CONFIG_NET | 611 | #ifdef CONFIG_NET |
612 | 612 | ||
613 | int __dynamic_netdev_dbg(struct _ddebug *descriptor, | 613 | int __dynamic_netdev_dbg(struct _ddebug *descriptor, |
614 | const struct net_device *dev, const char *fmt, ...) | 614 | const struct net_device *dev, const char *fmt, ...) |
615 | { | 615 | { |
616 | struct va_format vaf; | 616 | struct va_format vaf; |
617 | va_list args; | 617 | va_list args; |
618 | int res; | 618 | int res; |
619 | char buf[PREFIX_SIZE]; | ||
620 | 619 | ||
621 | BUG_ON(!descriptor); | 620 | BUG_ON(!descriptor); |
622 | BUG_ON(!fmt); | 621 | BUG_ON(!fmt); |
623 | 622 | ||
624 | va_start(args, fmt); | 623 | va_start(args, fmt); |
624 | |||
625 | vaf.fmt = fmt; | 625 | vaf.fmt = fmt; |
626 | vaf.va = &args; | 626 | vaf.va = &args; |
627 | res = __netdev_printk(dynamic_emit_prefix(descriptor, buf), dev, &vaf); | 627 | |
628 | if (dev && dev->dev.parent) { | ||
629 | char buf[PREFIX_SIZE]; | ||
630 | char dict[128]; | ||
631 | size_t dictlen; | ||
632 | |||
633 | dictlen = create_syslog_header(dev->dev.parent, | ||
634 | dict, sizeof(dict)); | ||
635 | |||
636 | res = printk_emit(0, 7, dictlen ? dict : NULL, dictlen, | ||
637 | "%s%s %s: %s: %pV", | ||
638 | dynamic_emit_prefix(descriptor, buf), | ||
639 | dev_driver_string(dev->dev.parent), | ||
640 | dev_name(dev->dev.parent), | ||
641 | netdev_name(dev), &vaf); | ||
642 | } else if (dev) { | ||
643 | res = printk(KERN_DEBUG "%s: %pV", netdev_name(dev), &vaf); | ||
644 | } else { | ||
645 | res = printk(KERN_DEBUG "(NULL net_device): %pV", &vaf); | ||
646 | } | ||
647 | |||
628 | va_end(args); | 648 | va_end(args); |
629 | 649 | ||
630 | return res; | 650 | return res; |
diff --git a/net/core/dev.c b/net/core/dev.c index d7fe32c946c1..ac890f14613a 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -6423,22 +6423,30 @@ const char *netdev_drivername(const struct net_device *dev) | |||
6423 | return empty; | 6423 | return empty; |
6424 | } | 6424 | } |
6425 | 6425 | ||
6426 | int __netdev_printk(const char *level, const struct net_device *dev, | 6426 | static int __netdev_printk(const char *level, const struct net_device *dev, |
6427 | struct va_format *vaf) | 6427 | struct va_format *vaf) |
6428 | { | 6428 | { |
6429 | int r; | 6429 | int r; |
6430 | 6430 | ||
6431 | if (dev && dev->dev.parent) | 6431 | if (dev && dev->dev.parent) { |
6432 | r = dev_printk(level, dev->dev.parent, "%s: %pV", | 6432 | char dict[128]; |
6433 | netdev_name(dev), vaf); | 6433 | size_t dictlen = create_syslog_header(dev->dev.parent, |
6434 | else if (dev) | 6434 | dict, sizeof(dict)); |
6435 | |||
6436 | r = printk_emit(0, level[1] - '0', | ||
6437 | dictlen ? dict : NULL, dictlen, | ||
6438 | "%s %s: %s: %pV", | ||
6439 | dev_driver_string(dev->dev.parent), | ||
6440 | dev_name(dev->dev.parent), | ||
6441 | netdev_name(dev), vaf); | ||
6442 | } else if (dev) { | ||
6435 | r = printk("%s%s: %pV", level, netdev_name(dev), vaf); | 6443 | r = printk("%s%s: %pV", level, netdev_name(dev), vaf); |
6436 | else | 6444 | } else { |
6437 | r = printk("%s(NULL net_device): %pV", level, vaf); | 6445 | r = printk("%s(NULL net_device): %pV", level, vaf); |
6446 | } | ||
6438 | 6447 | ||
6439 | return r; | 6448 | return r; |
6440 | } | 6449 | } |
6441 | EXPORT_SYMBOL(__netdev_printk); | ||
6442 | 6450 | ||
6443 | int netdev_printk(const char *level, const struct net_device *dev, | 6451 | int netdev_printk(const char *level, const struct net_device *dev, |
6444 | const char *format, ...) | 6452 | const char *format, ...) |
@@ -6453,6 +6461,7 @@ int netdev_printk(const char *level, const struct net_device *dev, | |||
6453 | vaf.va = &args; | 6461 | vaf.va = &args; |
6454 | 6462 | ||
6455 | r = __netdev_printk(level, dev, &vaf); | 6463 | r = __netdev_printk(level, dev, &vaf); |
6464 | |||
6456 | va_end(args); | 6465 | va_end(args); |
6457 | 6466 | ||
6458 | return r; | 6467 | return r; |
@@ -6472,6 +6481,7 @@ int func(const struct net_device *dev, const char *fmt, ...) \ | |||
6472 | vaf.va = &args; \ | 6481 | vaf.va = &args; \ |
6473 | \ | 6482 | \ |
6474 | r = __netdev_printk(level, dev, &vaf); \ | 6483 | r = __netdev_printk(level, dev, &vaf); \ |
6484 | \ | ||
6475 | va_end(args); \ | 6485 | va_end(args); \ |
6476 | \ | 6486 | \ |
6477 | return r; \ | 6487 | return r; \ |