* [PATCH v2 net-next 0/2] net: print net_device name/state more often
@ 2014-07-17 14:09 Veaceslav Falico
2014-07-17 14:09 ` [PATCH v2 net-next 1/2] net: use dev->name in netdev_pr* when it's available Veaceslav Falico
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Veaceslav Falico @ 2014-07-17 14:09 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Jason Baron, Eric Dumazet, Vlad Yasevich,
stephen hemminger, Jerry Chu, Ben Hutchings, Tom Gundersen,
Veaceslav Falico
Hi,
Currently we use net_device->name only if it's the NETREG_REGISTERED
reg_state, otherwise we return "(unregistered device)".
However, we always populate net_device->name on creation, so it's always
available to us for use. The only caveat is that we might have a name like
"eth%d", in which case we cannot use it as it might change in the future.
Also, the net_device might not be NETREG_UNREGISTERED when the function is
called (_UNINITIALIZED, _UNREGISTERING, _RELEASED, _DUMMY), so it's
misleading.
So, a better way would be to always return the dev->name in netdev_name(),
unless it's in the form of "eth%d" or it's empty, then return
"unnamed net_device". This way we'll always return the name in
NETREG_REGISTERED reg_state, and also return it in other states, when
possible.
Also, to be more verbose on non-NETREG_REGISTERED states, add a function
netdev_reg_state(), which returns a string describing the state, and use it
in netdev_printk()-related functions. If the dev is in NETREG_REGISTERED
state then a void string is regurned and, thus, nothing changes.
After these two patches we'll have the same behaviour in the usual cases,
and more verbose in non-standardad/buggy ones.
v1->v2:
As Tom Gundersen suggested, there might be a case when we have an empty
string as a name for a device, so account this also and return "unnamed
device" for that case too.
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: Tom Gundersen <teg@jklm.no>
Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
---
include/linux/netdevice.h | 21 ++++++++++++++++++---
lib/dynamic_debug.c | 8 +++++---
net/core/dev.c | 8 +++++---
3 files changed, 28 insertions(+), 9 deletions(-)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 net-next 1/2] net: use dev->name in netdev_pr* when it's available
2014-07-17 14:09 [PATCH v2 net-next 0/2] net: print net_device name/state more often Veaceslav Falico
@ 2014-07-17 14:09 ` Veaceslav Falico
2014-07-17 16:18 ` Joe Perches
2014-07-17 14:09 ` [PATCH v2 net-next 2/2] net: print net_device reg_state in netdev_* unless it's registered Veaceslav Falico
2014-07-17 14:48 ` [PATCH v2 net-next 0/2] net: print net_device name/state more often David Laight
2 siblings, 1 reply; 15+ messages in thread
From: Veaceslav Falico @ 2014-07-17 14:09 UTC (permalink / raw)
To: netdev; +Cc: Veaceslav Falico, David S. Miller, Tom Gundersen
netdev_name() returns dev->name only when the net_device is in
NETREG_REGISTERED state.
However, dev->name is always populated on creation, so we can easily use
it.
There are two cases when there's no real name - when it's an empty string
or when the name is in form of "eth%d", then netdev_name() returns "unnamed
net_device".
CC: "David S. Miller" <davem@davemloft.net>
CC: Tom Gundersen <teg@jklm.no>
Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
---
Notes:
v1->v2:
Also account for an empty string, as Tom Gundersen suggested.
include/linux/netdevice.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 15ed750..70256aa 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3383,8 +3383,8 @@ extern struct pernet_operations __net_initdata loopback_net_ops;
static inline const char *netdev_name(const struct net_device *dev)
{
- if (dev->reg_state != NETREG_REGISTERED)
- return "(unregistered net_device)";
+ if (!dev->name[0] || strchr(dev->name, '%'))
+ return "(unnamed net_device)";
return dev->name;
}
--
1.8.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 net-next 2/2] net: print net_device reg_state in netdev_* unless it's registered
2014-07-17 14:09 [PATCH v2 net-next 0/2] net: print net_device name/state more often Veaceslav Falico
2014-07-17 14:09 ` [PATCH v2 net-next 1/2] net: use dev->name in netdev_pr* when it's available Veaceslav Falico
@ 2014-07-17 14:09 ` Veaceslav Falico
2014-07-17 17:00 ` Joe Perches
2014-07-17 14:48 ` [PATCH v2 net-next 0/2] net: print net_device name/state more often David Laight
2 siblings, 1 reply; 15+ messages in thread
From: Veaceslav Falico @ 2014-07-17 14:09 UTC (permalink / raw)
To: netdev
Cc: Veaceslav Falico, David S. Miller, Jason Baron, Eric Dumazet,
Vlad Yasevich, stephen hemminger, Jerry Chu, Ben Hutchings
This way we'll always know in what status the device is, unless it's
running normally (i.e. NETDEV_REGISTERED).
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>
Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
---
include/linux/netdevice.h | 17 ++++++++++++++++-
lib/dynamic_debug.c | 8 +++++---
net/core/dev.c | 8 +++++---
3 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 70256aa..d868858 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3388,6 +3388,20 @@ static inline const char *netdev_name(const struct net_device *dev)
return dev->name;
}
+static inline const char *netdev_reg_state(const struct net_device *dev)
+{
+ switch (dev->reg_state) {
+ case NETREG_UNINITIALIZED: return " (unregistered)";
+ case NETREG_REGISTERED: return "";
+ case NETREG_UNREGISTERING: return " (unregistering)";
+ case NETREG_UNREGISTERED: return " (unregistered)";
+ case NETREG_RELEASED: return " (released)";
+ case NETREG_DUMMY: return " (dummy)";
+ }
+
+ return " (unknown)";
+}
+
__printf(3, 4)
int netdev_printk(const char *level, const struct net_device *dev,
const char *format, ...);
@@ -3444,7 +3458,8 @@ do { \
* file/line information and a backtrace.
*/
#define netdev_WARN(dev, format, args...) \
- WARN(1, "netdevice: %s\n" format, netdev_name(dev), ##args)
+ WARN(1, "netdevice: %s%s\n" format, netdev_name(dev), \
+ netdev_reg_state(dev), ##args)
/* netif printk helpers, similar to netdev_printk */
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 7288e38..c9afbe2 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -614,13 +614,15 @@ int __dynamic_netdev_dbg(struct _ddebug *descriptor,
char buf[PREFIX_SIZE];
res = dev_printk_emit(7, dev->dev.parent,
- "%s%s %s %s: %pV",
+ "%s%s %s %s%s: %pV",
dynamic_emit_prefix(descriptor, buf),
dev_driver_string(dev->dev.parent),
dev_name(dev->dev.parent),
- netdev_name(dev), &vaf);
+ netdev_name(dev), netdev_reg_state(dev),
+ &vaf);
} else if (dev) {
- res = printk(KERN_DEBUG "%s: %pV", netdev_name(dev), &vaf);
+ res = printk(KERN_DEBUG "%s%s: %pV", netdev_name(dev),
+ netdev_reg_state(dev), &vaf);
} else {
res = printk(KERN_DEBUG "(NULL net_device): %pV", &vaf);
}
diff --git a/net/core/dev.c b/net/core/dev.c
index 239722a..81d6101 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,
if (dev && dev->dev.parent) {
r = dev_printk_emit(level[1] - '0',
dev->dev.parent,
- "%s %s %s: %pV",
+ "%s %s %s%s: %pV",
dev_driver_string(dev->dev.parent),
dev_name(dev->dev.parent),
- netdev_name(dev), vaf);
+ netdev_name(dev), netdev_reg_state(dev),
+ vaf);
} else if (dev) {
- r = printk("%s%s: %pV", level, netdev_name(dev), vaf);
+ r = printk("%s%s%s: %pV", level, netdev_name(dev),
+ netdev_reg_state(dev), vaf);
} else {
r = printk("%s(NULL net_device): %pV", level, vaf);
}
--
1.8.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* RE: [PATCH v2 net-next 0/2] net: print net_device name/state more often
2014-07-17 14:09 [PATCH v2 net-next 0/2] net: print net_device name/state more often Veaceslav Falico
2014-07-17 14:09 ` [PATCH v2 net-next 1/2] net: use dev->name in netdev_pr* when it's available Veaceslav Falico
2014-07-17 14:09 ` [PATCH v2 net-next 2/2] net: print net_device reg_state in netdev_* unless it's registered Veaceslav Falico
@ 2014-07-17 14:48 ` David Laight
2014-07-17 15:24 ` Veaceslav Falico
2014-07-17 15:25 ` Tom Gundersen
2 siblings, 2 replies; 15+ messages in thread
From: David Laight @ 2014-07-17 14:48 UTC (permalink / raw)
To: 'Veaceslav Falico', netdev@vger.kernel.org
Cc: David S. Miller, Jason Baron, Eric Dumazet, Vlad Yasevich,
stephen hemminger, Jerry Chu, Ben Hutchings, Tom Gundersen
From: Veaceslav Falico
> Currently we use net_device->name only if it's the NETREG_REGISTERED
> reg_state, otherwise we return "(unregistered device)".
>
> However, we always populate net_device->name on creation, so it's always
> available to us for use. The only caveat is that we might have a name like
> "eth%d", in which case we cannot use it as it might change in the future.
While you've got this code out on the operating table what about:
1) Tracing the renames into the kernel message buffer.
2) Including the original name in some of the kernel traces.
I've been trying to diagnose some issues on a system that renames
its interfaces, and it can get tricky working out which interface
messages refer to.
David
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 net-next 0/2] net: print net_device name/state more often
2014-07-17 14:48 ` [PATCH v2 net-next 0/2] net: print net_device name/state more often David Laight
@ 2014-07-17 15:24 ` Veaceslav Falico
2014-07-17 15:25 ` Tom Gundersen
1 sibling, 0 replies; 15+ messages in thread
From: Veaceslav Falico @ 2014-07-17 15:24 UTC (permalink / raw)
To: David Laight
Cc: netdev@vger.kernel.org, David S. Miller, Jason Baron,
Eric Dumazet, Vlad Yasevich, stephen hemminger, Jerry Chu,
Ben Hutchings, Tom Gundersen
On Thu, Jul 17, 2014 at 02:48:17PM +0000, David Laight wrote:
>From: Veaceslav Falico
>> Currently we use net_device->name only if it's the NETREG_REGISTERED
>> reg_state, otherwise we return "(unregistered device)".
>>
>> However, we always populate net_device->name on creation, so it's always
>> available to us for use. The only caveat is that we might have a name like
>> "eth%d", in which case we cannot use it as it might change in the future.
>
>While you've got this code out on the operating table what about:
I don't think these ideas fit into the current patchset, as it's somehow
unrelated to the "lets give the real name/state when possible".
However, I like them, see below.
>1) Tracing the renames into the kernel message buffer.
I think you can enable it already. dev_change_name() (net's function to
change net_device name) calls device_rename(), which handles the device
renaming, and it has:
1805 dev_dbg(dev, "renaming to %s\n", new_name);
It can be easily enabled if you have dynamic debug compiled in.
However, indeed, it might be a good info to watch for, and a pretty simple
patch, which might be useful.
diff --git a/net/core/dev.c b/net/core/dev.c
index 239722a..d14ebf0 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1113,6 +1113,9 @@ int dev_change_name(struct net_device *dev, const char *newname)
return err;
}
+ if (oldname[0] && !strchr(oldname, '%'))
+ netdev_info(dev, "renamed from %s\n", oldname);
+
old_assign_type = dev->name_assign_type;
dev->name_assign_type = NET_NAME_RENAMED;
>2) Including the original name in some of the kernel traces.
The only possible use-case of that, from what I can see (with the patch
from 1) ) - is in the renaming functions themselves, which have already
quite a few output sources and, tbh, it's a really rare situation to
implenment tracking of renames in-kernel.
>
>I've been trying to diagnose some issues on a system that renames
>its interfaces, and it can get tricky working out which interface
>messages refer to.
>
> David
>
>
>
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v2 net-next 0/2] net: print net_device name/state more often
2014-07-17 14:48 ` [PATCH v2 net-next 0/2] net: print net_device name/state more often David Laight
2014-07-17 15:24 ` Veaceslav Falico
@ 2014-07-17 15:25 ` Tom Gundersen
2014-07-17 15:27 ` David Laight
1 sibling, 1 reply; 15+ messages in thread
From: Tom Gundersen @ 2014-07-17 15:25 UTC (permalink / raw)
To: David Laight
Cc: Veaceslav Falico, netdev@vger.kernel.org, David S. Miller,
Jason Baron, Eric Dumazet, Vlad Yasevich, stephen hemminger,
Jerry Chu, Ben Hutchings
On Thu, Jul 17, 2014 at 4:48 PM, David Laight <David.Laight@aculab.com> wrote:
> From: Veaceslav Falico
>> Currently we use net_device->name only if it's the NETREG_REGISTERED
>> reg_state, otherwise we return "(unregistered device)".
>>
>> However, we always populate net_device->name on creation, so it's always
>> available to us for use. The only caveat is that we might have a name like
>> "eth%d", in which case we cannot use it as it might change in the future.
>
> While you've got this code out on the operating table what about:
> 1) Tracing the renames into the kernel message buffer.
udev will log to dmesg what renames it does. I agree it would make
more sense to do this from the kernel though, as there are other ways
to rename interfaces than through udev.
Cheers,
Tom
> 2) Including the original name in some of the kernel traces.
>
> I've been trying to diagnose some issues on a system that renames
> its interfaces, and it can get tricky working out which interface
> messages refer to.
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [PATCH v2 net-next 0/2] net: print net_device name/state more often
2014-07-17 15:25 ` Tom Gundersen
@ 2014-07-17 15:27 ` David Laight
0 siblings, 0 replies; 15+ messages in thread
From: David Laight @ 2014-07-17 15:27 UTC (permalink / raw)
To: 'Tom Gundersen'
Cc: Veaceslav Falico, netdev@vger.kernel.org, David S. Miller,
Jason Baron, Eric Dumazet, Vlad Yasevich, stephen hemminger,
Jerry Chu, Ben Hutchings
From: Tom Gundersen
> On Thu, Jul 17, 2014 at 4:48 PM, David Laight <David.Laight@aculab.com> wrote:
...
> > While you've got this code out on the operating table what about:
> > 1) Tracing the renames into the kernel message buffer.
>
> udev will log to dmesg what renames it does.
Not on the systems I'm looking at (ubuntu 13.10 server).
Possibly the trace level is such that they get dropped.
David
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 net-next 1/2] net: use dev->name in netdev_pr* when it's available
2014-07-17 14:09 ` [PATCH v2 net-next 1/2] net: use dev->name in netdev_pr* when it's available Veaceslav Falico
@ 2014-07-17 16:18 ` Joe Perches
2014-07-17 16:25 ` Veaceslav Falico
0 siblings, 1 reply; 15+ messages in thread
From: Joe Perches @ 2014-07-17 16:18 UTC (permalink / raw)
To: Veaceslav Falico; +Cc: netdev, David S. Miller, Tom Gundersen
On Thu, 2014-07-17 at 16:09 +0200, Veaceslav Falico wrote:
> netdev_name() returns dev->name only when the net_device is in
> NETREG_REGISTERED state.
>
> However, dev->name is always populated on creation, so we can easily use
> it.
>
> There are two cases when there's no real name - when it's an empty string
> or when the name is in form of "eth%d", then netdev_name() returns "unnamed
> net_device".
>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Tom Gundersen <teg@jklm.no>
> Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
> ---
>
> Notes:
> v1->v2:
> Also account for an empty string, as Tom Gundersen suggested.
>
> include/linux/netdevice.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 15ed750..70256aa 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -3383,8 +3383,8 @@ extern struct pernet_operations __net_initdata loopback_net_ops;
>
> static inline const char *netdev_name(const struct net_device *dev)
> {
> - if (dev->reg_state != NETREG_REGISTERED)
> - return "(unregistered net_device)";
> + if (!dev->name[0] || strchr(dev->name, '%'))
> + return "(unnamed net_device)";
> return dev->name;
> }
>
Maybe this should not be inline and become something like:
const char *netdev_name(const struct net_device *dev)
{
if (dev->reg_state == NETREG_REGISTERED)
return dev->name;
if (!dev->name[0])
return "(unnamed net_device)";
if (!strchr(dev->name, '%'))
return "(unregistered net_device)";
return dev->name;
}
EXPORT_SYMBOL(netdev_name);
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 net-next 1/2] net: use dev->name in netdev_pr* when it's available
2014-07-17 16:18 ` Joe Perches
@ 2014-07-17 16:25 ` Veaceslav Falico
2014-07-17 16:36 ` Joe Perches
0 siblings, 1 reply; 15+ messages in thread
From: Veaceslav Falico @ 2014-07-17 16:25 UTC (permalink / raw)
To: Joe Perches; +Cc: netdev, David S. Miller, Tom Gundersen
On Thu, Jul 17, 2014 at 09:18:44AM -0700, Joe Perches wrote:
>On Thu, 2014-07-17 at 16:09 +0200, Veaceslav Falico wrote:
>> netdev_name() returns dev->name only when the net_device is in
>> NETREG_REGISTERED state.
>>
>> However, dev->name is always populated on creation, so we can easily use
>> it.
>>
>> There are two cases when there's no real name - when it's an empty string
>> or when the name is in form of "eth%d", then netdev_name() returns "unnamed
>> net_device".
>>
>> CC: "David S. Miller" <davem@davemloft.net>
>> CC: Tom Gundersen <teg@jklm.no>
>> Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
>> ---
>>
>> Notes:
>> v1->v2:
>> Also account for an empty string, as Tom Gundersen suggested.
>>
>> include/linux/netdevice.h | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
>> index 15ed750..70256aa 100644
>> --- a/include/linux/netdevice.h
>> +++ b/include/linux/netdevice.h
>> @@ -3383,8 +3383,8 @@ extern struct pernet_operations __net_initdata loopback_net_ops;
>>
>> static inline const char *netdev_name(const struct net_device *dev)
>> {
>> - if (dev->reg_state != NETREG_REGISTERED)
>> - return "(unregistered net_device)";
>> + if (!dev->name[0] || strchr(dev->name, '%'))
>> + return "(unnamed net_device)";
>> return dev->name;
>> }
>>
>
>Maybe this should not be inline and become something like:
It will miss the states then, when it's not NETREG_REGISTERED.
>
>const char *netdev_name(const struct net_device *dev)
>{
> if (dev->reg_state == NETREG_REGISTERED)
> return dev->name;
>
> if (!dev->name[0])
> return "(unnamed net_device)";
>
> if (!strchr(dev->name, '%'))
> return "(unregistered net_device)";
>
> return dev->name;
>}
>EXPORT_SYMBOL(netdev_name);
>
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 net-next 1/2] net: use dev->name in netdev_pr* when it's available
2014-07-17 16:25 ` Veaceslav Falico
@ 2014-07-17 16:36 ` Joe Perches
2014-07-17 16:38 ` Veaceslav Falico
0 siblings, 1 reply; 15+ messages in thread
From: Joe Perches @ 2014-07-17 16:36 UTC (permalink / raw)
To: Veaceslav Falico; +Cc: netdev, David S. Miller, Tom Gundersen
On Thu, 2014-07-17 at 18:25 +0200, Veaceslav Falico wrote:
> On Thu, Jul 17, 2014 at 09:18:44AM -0700, Joe Perches wrote:
> >On Thu, 2014-07-17 at 16:09 +0200, Veaceslav Falico wrote:
> >> netdev_name() returns dev->name only when the net_device is in
> >> NETREG_REGISTERED state.
[]
> >Maybe this should not be inline and become something like:
>
> It will miss the states then, when it's not NETREG_REGISTERED.
If it's registered, it has a valid name via
dev_get_valid_name() doesn't it?
> >const char *netdev_name(const struct net_device *dev)
> >{
> > if (dev->reg_state == NETREG_REGISTERED)
> > return dev->name;
> >
> > if (!dev->name[0])
> > return "(unnamed net_device)";
> >
> > if (!strchr(dev->name, '%'))
> > return "(unregistered net_device)";
> >
> > return dev->name;
> >}
> >EXPORT_SYMBOL(netdev_name);
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 net-next 1/2] net: use dev->name in netdev_pr* when it's available
2014-07-17 16:36 ` Joe Perches
@ 2014-07-17 16:38 ` Veaceslav Falico
2014-07-17 16:58 ` Joe Perches
0 siblings, 1 reply; 15+ messages in thread
From: Veaceslav Falico @ 2014-07-17 16:38 UTC (permalink / raw)
To: Joe Perches; +Cc: netdev, David S. Miller, Tom Gundersen
On Thu, Jul 17, 2014 at 09:36:08AM -0700, Joe Perches wrote:
>On Thu, 2014-07-17 at 18:25 +0200, Veaceslav Falico wrote:
>> On Thu, Jul 17, 2014 at 09:18:44AM -0700, Joe Perches wrote:
>> >On Thu, 2014-07-17 at 16:09 +0200, Veaceslav Falico wrote:
>> >> netdev_name() returns dev->name only when the net_device is in
>> >> NETREG_REGISTERED state.
>[]
>> >Maybe this should not be inline and become something like:
>>
>> It will miss the states then, when it's not NETREG_REGISTERED.
>
>If it's registered, it has a valid name via
>dev_get_valid_name() doesn't it?
Yes, I'm speaking about the NETREG_* states when it's not registered.
i.e.:
Jul 17 13:35:29 darkmag kernel: [ 602.686489] bond2 (unregistering): Released all slaves
that's with my patchset, when the bond device is unregistering
(NETREG_UNREGISTERING). With your patch it would be only "bond2: Released
all slaves".
As the most time the device is in the NETREG_REGISTERED state, there will
be no differencies in the output (with either my or your approach), however
in less-common states/codepaths it will also output its state, which might
be quite valuable when analyzing the logs.
>
>> >const char *netdev_name(const struct net_device *dev)
>> >{
>> > if (dev->reg_state == NETREG_REGISTERED)
>> > return dev->name;
>> >
>> > if (!dev->name[0])
>> > return "(unnamed net_device)";
>> >
>> > if (!strchr(dev->name, '%'))
>> > return "(unregistered net_device)";
>> >
>> > return dev->name;
>> >}
>> >EXPORT_SYMBOL(netdev_name);
>
>
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 net-next 1/2] net: use dev->name in netdev_pr* when it's available
2014-07-17 16:58 ` Joe Perches
@ 2014-07-17 16:58 ` Veaceslav Falico
0 siblings, 0 replies; 15+ messages in thread
From: Veaceslav Falico @ 2014-07-17 16:58 UTC (permalink / raw)
To: Joe Perches; +Cc: netdev, David S. Miller, Tom Gundersen
On Thu, Jul 17, 2014 at 09:58:16AM -0700, Joe Perches wrote:
>On Thu, 2014-07-17 at 18:38 +0200, Veaceslav Falico wrote:
>> On Thu, Jul 17, 2014 at 09:36:08AM -0700, Joe Perches wrote:
>> >On Thu, 2014-07-17 at 18:25 +0200, Veaceslav Falico wrote:
>> >> On Thu, Jul 17, 2014 at 09:18:44AM -0700, Joe Perches wrote:
>> >> >On Thu, 2014-07-17 at 16:09 +0200, Veaceslav Falico wrote:
>> >> >> netdev_name() returns dev->name only when the net_device is in
>> >> >> NETREG_REGISTERED state.
>> >[]
>> >> >Maybe this should not be inline and become something like:
>> >>
>> >> It will miss the states then, when it's not NETREG_REGISTERED.
>> >
>> >If it's registered, it has a valid name via
>> >dev_get_valid_name() doesn't it?
>>
>> Yes, I'm speaking about the NETREG_* states when it's not registered.
>>
>> i.e.:
>>
>> Jul 17 13:35:29 darkmag kernel: [ 602.686489] bond2 (unregistering): Released all slaves
>
>OK, I hadn't read the patch where netdev_reg_state was emitted.
>
>Still, it's probably smaller overall code to uninline it now.
I don't really care about that, and it's used only in several non-inlined
functions anyway, so the difference would be minimal, if any. I can easily
re-spin it unlined, however I don't really see a point in doing so :).
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 net-next 1/2] net: use dev->name in netdev_pr* when it's available
2014-07-17 16:38 ` Veaceslav Falico
@ 2014-07-17 16:58 ` Joe Perches
2014-07-17 16:58 ` Veaceslav Falico
0 siblings, 1 reply; 15+ messages in thread
From: Joe Perches @ 2014-07-17 16:58 UTC (permalink / raw)
To: Veaceslav Falico; +Cc: netdev, David S. Miller, Tom Gundersen
On Thu, 2014-07-17 at 18:38 +0200, Veaceslav Falico wrote:
> On Thu, Jul 17, 2014 at 09:36:08AM -0700, Joe Perches wrote:
> >On Thu, 2014-07-17 at 18:25 +0200, Veaceslav Falico wrote:
> >> On Thu, Jul 17, 2014 at 09:18:44AM -0700, Joe Perches wrote:
> >> >On Thu, 2014-07-17 at 16:09 +0200, Veaceslav Falico wrote:
> >> >> netdev_name() returns dev->name only when the net_device is in
> >> >> NETREG_REGISTERED state.
> >[]
> >> >Maybe this should not be inline and become something like:
> >>
> >> It will miss the states then, when it's not NETREG_REGISTERED.
> >
> >If it's registered, it has a valid name via
> >dev_get_valid_name() doesn't it?
>
> Yes, I'm speaking about the NETREG_* states when it's not registered.
>
> i.e.:
>
> Jul 17 13:35:29 darkmag kernel: [ 602.686489] bond2 (unregistering): Released all slaves
OK, I hadn't read the patch where netdev_reg_state was emitted.
Still, it's probably smaller overall code to uninline it now.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 net-next 2/2] net: print net_device reg_state in netdev_* unless it's registered
2014-07-17 14:09 ` [PATCH v2 net-next 2/2] net: print net_device reg_state in netdev_* unless it's registered Veaceslav Falico
@ 2014-07-17 17:00 ` Joe Perches
2014-07-17 17:27 ` Veaceslav Falico
0 siblings, 1 reply; 15+ messages in thread
From: Joe Perches @ 2014-07-17 17:00 UTC (permalink / raw)
To: Veaceslav Falico
Cc: netdev, David S. Miller, Jason Baron, Eric Dumazet, Vlad Yasevich,
stephen hemminger, Jerry Chu, Ben Hutchings
On Thu, 2014-07-17 at 16:09 +0200, Veaceslav Falico wrote:
> This way we'll always know in what status the device is, unless it's
> running normally (i.e. NETDEV_REGISTERED).
[]
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
[]
> @@ -3388,6 +3388,20 @@ static inline const char *netdev_name(const struct net_device *dev)
> return dev->name;
> }
>
> +static inline const char *netdev_reg_state(const struct net_device *dev)
> +{
> + switch (dev->reg_state) {
> + case NETREG_UNINITIALIZED: return " (unregistered)";
Why not " (uninitialized)"?
> + case NETREG_REGISTERED: return "";
> + case NETREG_UNREGISTERING: return " (unregistering)";
> + case NETREG_UNREGISTERED: return " (unregistered)";
> + case NETREG_RELEASED: return " (released)";
> + case NETREG_DUMMY: return " (dummy)";
> + }
> +
> + return " (unknown)";
Shouldn't this " (unknown)" have stronger text
and use a WARN_ON_ONCE?
I'd put this in net/core/dev.c and make it not be static inline.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 net-next 2/2] net: print net_device reg_state in netdev_* unless it's registered
2014-07-17 17:00 ` Joe Perches
@ 2014-07-17 17:27 ` Veaceslav Falico
0 siblings, 0 replies; 15+ messages in thread
From: Veaceslav Falico @ 2014-07-17 17:27 UTC (permalink / raw)
To: Joe Perches
Cc: netdev, David S. Miller, Jason Baron, Eric Dumazet, Vlad Yasevich,
stephen hemminger, Jerry Chu, Ben Hutchings
On Thu, Jul 17, 2014 at 10:00:24AM -0700, Joe Perches wrote:
>On Thu, 2014-07-17 at 16:09 +0200, Veaceslav Falico wrote:
>> This way we'll always know in what status the device is, unless it's
>> running normally (i.e. NETDEV_REGISTERED).
>[]
>> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
>[]
>> @@ -3388,6 +3388,20 @@ static inline const char *netdev_name(const struct net_device *dev)
>> return dev->name;
>> }
>>
>> +static inline const char *netdev_reg_state(const struct net_device *dev)
>> +{
>> + switch (dev->reg_state) {
>> + case NETREG_UNINITIALIZED: return " (unregistered)";
>
>Why not " (uninitialized)"?
Good one, thank you, missed it somehow. Will send v2.
>
>> + case NETREG_REGISTERED: return "";
>> + case NETREG_UNREGISTERING: return " (unregistering)";
>> + case NETREG_UNREGISTERED: return " (unregistered)";
>> + case NETREG_RELEASED: return " (released)";
>> + case NETREG_DUMMY: return " (dummy)";
>> + }
>> +
>> + return " (unknown)";
>
>Shouldn't this " (unknown)" have stronger text
>and use a WARN_ON_ONCE?
Hrm, I don't remember why, but I've specifically dropped the warning here.
Now it seems like a good idea, so I'll add it here.
>
>I'd put this in net/core/dev.c and make it not be static inline.
Again, I don't think it's really needed, as it's used in 4 functions (which
aren't inline), so the benefits are minimal, if any.
I'll rather keep them inline, I guess...
>
>
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2014-07-17 17:30 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-17 14:09 [PATCH v2 net-next 0/2] net: print net_device name/state more often Veaceslav Falico
2014-07-17 14:09 ` [PATCH v2 net-next 1/2] net: use dev->name in netdev_pr* when it's available Veaceslav Falico
2014-07-17 16:18 ` Joe Perches
2014-07-17 16:25 ` Veaceslav Falico
2014-07-17 16:36 ` Joe Perches
2014-07-17 16:38 ` Veaceslav Falico
2014-07-17 16:58 ` Joe Perches
2014-07-17 16:58 ` Veaceslav Falico
2014-07-17 14:09 ` [PATCH v2 net-next 2/2] net: print net_device reg_state in netdev_* unless it's registered Veaceslav Falico
2014-07-17 17:00 ` Joe Perches
2014-07-17 17:27 ` Veaceslav Falico
2014-07-17 14:48 ` [PATCH v2 net-next 0/2] net: print net_device name/state more often David Laight
2014-07-17 15:24 ` Veaceslav Falico
2014-07-17 15:25 ` Tom Gundersen
2014-07-17 15:27 ` David Laight
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).