From: Veaceslav Falico <vfalico@gmail.com>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Jason Baron <jbaron@akamai.com>,
Eric Dumazet <edumazet@google.com>,
Vlad Yasevich <vyasevic@redhat.com>,
stephen hemminger <stephen@networkplumber.org>,
Jerry Chu <hkchu@google.com>,
Ben Hutchings <bhutchings@solarflare.com>,
Joe Perches <joe@perches.com>,
Veaceslav Falico <vfalico@gmail.com>
Subject: [PATCH v3 net-next 0/2] net: print net_device name/state more often
Date: Thu, 17 Jul 2014 19:46:08 +0200 [thread overview]
Message-ID: <1405619171-18172-1-git-send-email-vfalico@gmail.com> (raw)
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" <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>
---
include/linux/netdevice.h | 22 +++++++++++++++++++---
lib/dynamic_debug.c | 8 +++++---
net/core/dev.c | 8 +++++---
3 files changed, 29 insertions(+), 9 deletions(-)
next reply other threads:[~2014-07-17 17:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-17 17:46 Veaceslav Falico [this message]
2014-07-17 17:46 ` [PATCH v3 net-next 1/2] net: use dev->name in netdev_pr* when it's available Veaceslav Falico
2014-07-18 9:01 ` Tom Gundersen
2014-07-17 17:46 ` [PATCH v3 net-next 2/2] net: print net_device reg_state in netdev_* unless it's registered Veaceslav Falico
2014-07-17 19:21 ` Joe Perches
2014-07-17 19:39 ` Veaceslav Falico
2014-07-21 3:39 ` [PATCH v3 net-next 0/2] net: print net_device name/state more often David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1405619171-18172-1-git-send-email-vfalico@gmail.com \
--to=vfalico@gmail.com \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkchu@google.com \
--cc=jbaron@akamai.com \
--cc=joe@perches.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
--cc=vyasevic@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).