2006-02-21 23:48:12

by Thomas Ogrisegg

[permalink] [raw]
Subject: [PATCH] netdev/uevent

This patch adds userspace notification for register/unregister and
plug/unplug events for netdevices. It calls kobject_uevent to let
userspace applications (via netlink-interface) know that e.g. the
ethernet-cable was plugged in (or plugged out) and thus the ethernet
device may have to be reconfigured.

Common scenario:
A userspace application is notified that the ethernet cable was plugged
out and later plugged in. It now checks whether the ethernet card is now
connected to an other network and reassigns it's IP-Address via DHCP.

BTW: Of course I know that the constant KOBJ_ONLINE actually has an other
meaning than what I used it for. I just didn't want to introduce a new
constant and it just seems perfect for my purpose.

Signed-off-by: Thomas Ogrisegg <[email protected]>


Attachments:
(No filename) (791.00 B)
netdev_uevent.diff (1.80 kB)
Download all attachments

2006-02-22 00:17:05

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] netdev/uevent

On Wed, Feb 22, 2006 at 12:48:07AM +0100, Thomas Ogrisegg wrote:
> This patch adds userspace notification for register/unregister and
> plug/unplug events for netdevices. It calls kobject_uevent to let
> userspace applications (via netlink-interface) know that e.g. the
> ethernet-cable was plugged in (or plugged out) and thus the ethernet
> device may have to be reconfigured.
>
> Common scenario:
> A userspace application is notified that the ethernet cable was plugged
> out and later plugged in. It now checks whether the ethernet card is now
> connected to an other network and reassigns it's IP-Address via DHCP.
>
> BTW: Of course I know that the constant KOBJ_ONLINE actually has an other
> meaning than what I used it for. I just didn't want to introduce a new
> constant and it just seems perfect for my purpose.
>
> Signed-off-by: Thomas Ogrisegg <[email protected]>

Hm, I thought ethtool and netlink already handled this kind of event
just fine. Why would you add a uevent too?

thanks,

greg k-h

2006-02-22 08:37:54

by Thomas Ogrisegg

[permalink] [raw]
Subject: Re: [PATCH] netdev/uevent

On Tue, Feb 21, 2006 at 04:17:07PM -0800, Greg KH wrote:
> On Wed, Feb 22, 2006 at 12:48:07AM +0100, Thomas Ogrisegg wrote:
> > This patch adds userspace notification for register/unregister and
> > plug/unplug events for netdevices. It calls kobject_uevent to let
> > userspace applications (via netlink-interface) know that e.g. the
> > ethernet-cable was plugged in (or plugged out) and thus the ethernet
> > device may have to be reconfigured.
[...]
> > Signed-off-by: Thomas Ogrisegg <[email protected]>
> Hm, I thought ethtool and netlink already handled this kind of event
> just fine. Why would you add a uevent too?

What do you mean with "ethtool and netlink"? At least the current
release of ethtool does not seem to have any netlink support.

Is there currently any possibility for a program to get notified when
a netdevice link becomes ready (or the opposite)? I don't see any interface
(besides polling /sys).

2006-02-22 17:53:15

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] netdev/uevent

On Wed, Feb 22, 2006 at 09:37:51AM +0100, Thomas Ogrisegg wrote:
> On Tue, Feb 21, 2006 at 04:17:07PM -0800, Greg KH wrote:
> > On Wed, Feb 22, 2006 at 12:48:07AM +0100, Thomas Ogrisegg wrote:
> > > This patch adds userspace notification for register/unregister and
> > > plug/unplug events for netdevices. It calls kobject_uevent to let
> > > userspace applications (via netlink-interface) know that e.g. the
> > > ethernet-cable was plugged in (or plugged out) and thus the ethernet
> > > device may have to be reconfigured.
> [...]
> > > Signed-off-by: Thomas Ogrisegg <[email protected]>
> > Hm, I thought ethtool and netlink already handled this kind of event
> > just fine. Why would you add a uevent too?
>
> What do you mean with "ethtool and netlink"? At least the current
> release of ethtool does not seem to have any netlink support.

That should have been "or", sorry.

> Is there currently any possibility for a program to get notified when
> a netdevice link becomes ready (or the opposite)? I don't see any interface
> (besides polling /sys).

Try asking on the netdev mailing list, I'm sure it must come up there a
lot.

thanks,

greg k-h

2006-02-22 17:53:34

by Chris Wright

[permalink] [raw]
Subject: Re: [PATCH] netdev/uevent

* Thomas Ogrisegg ([email protected]) wrote:
> Is there currently any possibility for a program to get notified when
> a netdevice link becomes ready (or the opposite)? I don't see any interface
> (besides polling /sys).

Yes, there's a netlink socket that already communicates these changes.
Routing daemons typically consume this information. The netdev notifier
chain should end up generating these events via rtmsg_ifinfo.

thanks,
-chris

2006-02-22 22:42:54

by Stefan Rompf

[permalink] [raw]
Subject: Re: [PATCH] netdev/uevent

Thomas Ogrisegg wrote:

> What do you mean with "ethtool and netlink"? At least the current
> release of ethtool does not seem to have any netlink support.

You can listen to RTMGRP_LINK on NETLINK_ROUTE. IFF_RUNNING will give you the
link state information you're looking for.

For you application scenario: I'm working on a DHCP client that uses this
netlink information, so don't invent the wheel twice ;-)

Stefan