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", 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.
CC: "David S. Miller" <davem@davemloft.net>
CC: Jason Baron <jbaron@akamai.com>
CC: Eric Dumazet <redacted>
CC: Vlad Yasevich <redacted>
CC: stephen hemminger <stephen@networkplumber.org>
CC: Jerry Chu <redacted>
CC: Ben Hutchings <redacted>
Signed-off-by: Veaceslav Falico <redacted>
---
include/linux/netdevice.h | 21 ++++++++++++++++++---
lib/dynamic_debug.c | 8 +++++---
net/core/dev.c | 8 +++++---
3 files changed, 28 insertions(+), 9 deletions(-)