netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: Ben Hutchings <bhutchings@solarflare.com>,
	Kay Sievers <kay.sievers@vrfy.org>,
	David Miller <davem@davemloft.net>,
	linux-hotplug@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] netdev: generate kobject uevent on network state transitions
Date: Mon, 24 Nov 2008 20:14:40 -0800	[thread overview]
Message-ID: <20081124201440.0e4d61cc@extreme> (raw)
In-Reply-To: <AAE2573A-3C23-4C61-89E1-3A6F31D7B23E@holtmann.org>

On Tue, 25 Nov 2008 04:51:53 +0100
Marcel Holtmann <marcel@holtmann.org> wrote:

> Hi Stephen,
> 
> > It is easier for some applications to deal with text based interfaces
> > like uevent, rather than using netlink to listen for events.
> >
> > Note, this does not deal with network namespaces but that is a generic
> > problem that already exists with kobjects (see rename events).
> >
> > Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> >
> > ---
> > net/core/Makefile |    1
> > net/core/uevent.c |   61 ++++++++++++++++++++++++++++++++++++++++++++ 
> > ++++++++++
> > 2 files changed, 62 insertions(+)
> >
> > --- a/net/core/Makefile	2008-11-24 12:07:18.000000000 -0800
> > +++ b/net/core/Makefile	2008-11-24 12:07:22.000000000 -0800
> > @@ -17,3 +17,4 @@ obj-$(CONFIG_NET_PKTGEN) += pktgen.o
> > obj-$(CONFIG_NETPOLL) += netpoll.o
> > obj-$(CONFIG_NET_DMA) += user_dma.o
> > obj-$(CONFIG_FIB_RULES) += fib_rules.o
> > +obj-$(CONFIG_HOTPLUG) += uevent.o
> > --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> > +++ b/net/core/uevent.c	2008-11-24 12:11:46.000000000 -0800
> > @@ -0,0 +1,55 @@
> > +/*
> > + * Linux network device event notification
> > + *
> > + * Author:
> > + *	Stephen Hemminger <shemminger@vyatta.com>
> > + */
> > +
> > +#include <linux/kernel.h>
> > +#include <linux/netdevice.h>
> > +#include <linux/kobject.h>
> > +#include <linux/notifier.h>
> > +
> > +/*
> > + * Generate uevent in response to network device state changes.
> > + * Other events are already handled by device subsystem.
> > + */
> > +static int netdev_event(struct notifier_block *this, unsigned long  
> > event, void *ptr)
> > +{
> > +	struct net_device *netdev = ptr;
> > +
> > +	switch (event) {
> > +	case NETDEV_UP:
> > +		kobject_uevent(&netdev->dev.kobj, KOBJ_ONLINE);
> > +		break;
> > +
> > +	case NETDEV_DOWN:
> > +		kobject_uevent(&netdev->dev.kobj, KOBJ_OFFLINE);
> > +		break;
> > +
> > +	case NETDEV_CHANGE: {
> > +		char str[64] = "DEVSTATE=UP";
> > +		char *envp[2] = { str, NULL };
> > +
> > +		if (netif_oper_up(netdev))
> > +			strcat(str, ",RUNNING");
> > +		if (netif_carrier_ok(netdev))
> > +			strcat(str, ",LOWER_UP");
> > +		if (netif_dormant(netdev))
> > +			strcat(str, ",DORMANT");
> > +		kobject_uevent_env(&netdev->dev.kobj, KOBJ_CHANGE, envp);
> > +		break;
> 
> do we wanna copy just what ifconfig shows or do we might be a more  
> intelligent and have separate variables like RUNNING=1 etc.?
> 
> Regards
> 
> Marcel

Was arbitrary choice to just use same flags as existing ifconfig.
What ever feels best I guess...


  reply	other threads:[~2008-11-25  4:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20081121234110.22b47154@extreme>
     [not found] ` <ac3eb2510811220608y33662b0bkb66026c2a21b061e@mail.gmail.com>
     [not found]   ` <F6B63A37-A69F-4197-B7E5-C9FD9BFA76F6@holtmann.org>
     [not found]     ` <20081122223249.4be03e4e@extreme>
     [not found]       ` <ac3eb2510811230813s3cb5c248k1e15d9ece581c8ad@mail.gmail.com>
2008-11-24 19:45         ` [PATCH] netdev: generate kobject uevent on network events Stephen Hemminger
2008-11-24 19:55           ` Kay Sievers
2008-11-24 20:06             ` Stephen Hemminger
2008-11-25  8:39               ` David Miller
2008-11-24 20:06           ` Ben Hutchings
2008-11-24 23:03             ` [PATCH] netdev: generate kobject uevent on network state transitions Stephen Hemminger
2008-11-25  3:08               ` Kay Sievers
2008-11-25  3:51               ` Marcel Holtmann
2008-11-25  4:14                 ` Stephen Hemminger [this message]
2008-11-25  9:09                   ` David Miller
2008-11-26  5:24                     ` Marcel Holtmann
2008-11-26 12:09                       ` Kay Sievers

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=20081124201440.0e4d61cc@extreme \
    --to=shemminger@vyatta.com \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-hotplug@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=netdev@vger.kernel.org \
    /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).