diff mbox

[net-next] net: print a notification on device rename

Message ID 1405622012-5511-1-git-send-email-vfalico@gmail.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Veaceslav Falico July 17, 2014, 6:33 p.m. UTC
Currently it's done silently (from the kernel part), and thus it might be
hard to track the renames from logs.

Add a simple netdev_info() to notify the rename, but only in case the
previous name was valid.

CC: "David S. Miller" <davem@davemloft.net>
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: David Laight <David.Laight@ACULAB.COM>
Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
---
 net/core/dev.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Yuval Mintz July 20, 2014, 12:37 p.m. UTC | #1
> Currently it's done silently (from the kernel part), and thus it might be hard to
> track the renames from logs.
>
> Add a simple netdev_info() to notify the rename, but only in case the previous
> name was valid.

Hi,

Why you're at it, perhaps we could also consider adding an optional ndo callback
in the drivers to notify them of the device name change?
[e.g., multi-module dependencies where one would wish to inform the others
of the name change]

Cheers,
Yuval

>
> CC: "David S. Miller" <davem@davemloft.net>
> 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: David Laight <David.Laight@ACULAB.COM>
> Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
> ---
>  net/core/dev.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> 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;
>
Veaceslav Falico July 20, 2014, 9:17 p.m. UTC | #2
On Sun, Jul 20, 2014 at 12:37:52PM +0000, Yuval Mintz wrote:
>> Currently it's done silently (from the kernel part), and thus it might be hard to
>> track the renames from logs.
>>
>> Add a simple netdev_info() to notify the rename, but only in case the previous
>> name was valid.
>
>Hi,
>
>Why you're at it, perhaps we could also consider adding an optional ndo callback
>in the drivers to notify them of the device name change?
>[e.g., multi-module dependencies where one would wish to inform the others
>of the name change]

There's already one, I think:

1142         ret = call_netdevice_notifiers(NETDEV_CHANGENAME, dev);

It's also possible to block it. Or did you mean something else?

Thank you!

>
>Cheers,
>Yuval
>
>>
>> CC: "David S. Miller" <davem@davemloft.net>
>> 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: David Laight <David.Laight@ACULAB.COM>
>> Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
>> ---
>>  net/core/dev.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> 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;
>>
>
>________________________________
>
>This message and any attached documents contain information from QLogic Corporation or its wholly-owned subsidiaries that may be confidential. If you are not the intended recipient, you may not read, copy, distribute, or use this information. If you have received this transmission in error, please notify the sender immediately by reply e-mail and then delete this message.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller July 21, 2014, 3:44 a.m. UTC | #3
From: Veaceslav Falico <vfalico@gmail.com>
Date: Thu, 17 Jul 2014 20:33:32 +0200

> Currently it's done silently (from the kernel part), and thus it might be
> hard to track the renames from logs.
> 
> Add a simple netdev_info() to notify the rename, but only in case the
> previous name was valid.
> 
> CC: "David S. Miller" <davem@davemloft.net>
> 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: David Laight <David.Laight@ACULAB.COM>
> Signed-off-by: Veaceslav Falico <vfalico@gmail.com>

This is fine, applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yuval Mintz July 21, 2014, 5:50 a.m. UTC | #4
> Cc: netdev; David Miller; Eric Dumazet; Vlad Yasevich; stephen hemminger; Jerry
> Chu; Ben Hutchings; David Laight
> Subject: Re: [PATCH net-next] net: print a notification on device rename
>
> On Sun, Jul 20, 2014 at 12:37:52PM +0000, Yuval Mintz wrote:
> >> Currently it's done silently (from the kernel part), and thus it
> >> might be hard to track the renames from logs.
> >>
> >> Add a simple netdev_info() to notify the rename, but only in case the
> >> previous name was valid.
> >
> >Hi,
> >
> >Why you're at it, perhaps we could also consider adding an optional ndo
> >callback in the drivers to notify them of the device name change?
> >[e.g., multi-module dependencies where one would wish to inform the
> >others of the name change]
>
> There's already one, I think:
>
> 1142         ret = call_netdevice_notifiers(NETDEV_CHANGENAME, dev);
>
> It's also possible to block it. Or did you mean something else?
>

I wasn't aware of the notifier, but although usable I've meant an actual .ndo
to the device itself - under current implementation the device is oblivious to
changes to its own name, and it's only method of getting a notification is by
enlisting into the notifier chain and getting all sorts of notifications for all sort
of devices.

[You're right my example was probably covered by the current implementation]

Although it might be debatable whether the device should actually care about its
Name change.

> Thank you!
>
> >
> >Cheers,
> >Yuval
> >
> >>
> >> CC: "David S. Miller" <davem@davemloft.net>
> >> 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: David Laight <David.Laight@ACULAB.COM>
> >> Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
> >> ---
> >>  net/core/dev.c | 3 +++
> >>  1 file changed, 3 insertions(+)
> >>
> >> 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;
> >>
> >
> >________________________________
> >
> >This message and any attached documents contain information from QLogic
> Corporation or its wholly-owned subsidiaries that may be confidential. If you are
> not the intended recipient, you may not read, copy, distribute, or use this
> information. If you have received this transmission in error, please notify the
> sender immediately by reply e-mail and then delete this message.
diff mbox

Patch

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;