Skip to content

net: print net_device name/state more often

Veaceslav Falico netdev 3 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 4 repliesIn review
  2. v22 patches 12 repliesSuperseded
  3. v12 patches 4 repliesSuperseded

Changes in v3 from the cover letter

Correct the string for _UNINITIALIZED and warn on a bad reg_state, per Joe Perches's comments.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2net: use dev->name in netdev_pr* when it's availableinclude/linux/netdevice.h+2 -21 reply
2/2net: print net_device reg_state in netdev_* unless it's registeredinclude/linux/netdevice.h lib/dynamic_debug.c net/core/dev.c+27 -72 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchTom Gundersen
1/2A-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 net-next 0/2] net: print net_device name/state more often

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.

v2->v3:
Correct the string for _UNINITIALIZED and warn on a bad reg_state, per Joe Perches's comments.

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" <[email protected]>
CC Jason Baron <[email protected]>
CC Eric Dumazet <[email protected]>
CC Vlad Yasevich <[email protected]>
CC stephen hemminger <[email protected]>
CC Jerry Chu <[email protected]>
CC Ben Hutchings <[email protected]>
CC Joe Perches <[email protected]>
---
 include/linux/netdevice.h | 22 +++++++++++++++++++---
 lib/dynamic_debug.c       |  8 +++++---
 net/core/dev.c            |  8 +++++---
 3 files changed, 29 insertions(+), 9 deletions(-)