public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Notifier chains bug ?
@ 2010-03-02  0:08 Oleg Kutkov
  2010-03-02  3:24 ` Américo Wang
  0 siblings, 1 reply; 5+ messages in thread
From: Oleg Kutkov @ 2010-03-02  0:08 UTC (permalink / raw)
  To: linux-kernel

Hello.
I try to used notifier chains for monitoring network devices events.
All works perfectly when just i'm connecting/disconnecting network cable 
or up/down interface via ifconfig.
But when i try to change interface address - nothing happens. Notifier 
is don't send any events :(
There is many events in notifier.h:

#define NETDEV_UP                                        0x0001   
#define NETDEV_DOWN                                 0x0002
#define NETDEV_REBOOT                              0x0003   
#define NETDEV_CHANGE                             0x0004 
#define NETDEV_REGISTER                          0x0005
#define NETDEV_UNREGISTER                    0x0006
#define NETDEV_CHANGEMTU                    0x0007
#define NETDEV_CHANGEADDR                  0x0008
#define NETDEV_GOING_DOWN                  0x0009
#define NETDEV_CHANGENAME                 0x000A
#define NETDEV_FEAT_CHANGE                 0x000B
#define NETDEV_BONDING_FAILOVER      0x000C
#define NETDEV_PRE_UP                               0x000D
#define NETDEV_BONDING_OLDTYPE        0x000E
#define NETDEV_BONDING_NEWTYPE       0x000F

So i receive only NETDEV_UP  and NETDEV_DOWN events.

Part of my code:

//event handler
static int ifEventListener(struct notifier_block *nb, unsigned long 
event, void *ptr);

//set handler
struct notifier_block nbListener =
{
    .notifier_call = ifEventListener
};

//event handler
static int ifEventListener(struct notifier_block *this, unsigned long 
event, void *ptr)
{
    struct net_device *dev = (struct net_device *) ptr;

    printk(KERN_INFO "eventListener() -- %d event from net_device '%s' 
(0x%08X)\n", event, dev->name, (unsigned) dev);
 
    return 0;
}

//register handler
register_netdevice_notifier(&nbListener);



So, this is a bug in notifier or something wrong with my code ?
Thank for any help

-- 
Best regards, 
Oleg


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Notifier chains bug ?
  2010-03-02  0:08 Notifier chains bug ? Oleg Kutkov
@ 2010-03-02  3:24 ` Américo Wang
  2010-03-02  5:50   ` Oleg Kutkov
  0 siblings, 1 reply; 5+ messages in thread
From: Américo Wang @ 2010-03-02  3:24 UTC (permalink / raw)
  To: Oleg Kutkov; +Cc: linux-kernel

On Tue, Mar 2, 2010 at 8:08 AM, Oleg Kutkov <elenbert@gmail.com> wrote:
> Hello.
> I try to used notifier chains for monitoring network devices events.
> All works perfectly when just i'm connecting/disconnecting network cable or
> up/down interface via ifconfig.
> But when i try to change interface address - nothing happens. Notifier is
> don't send any events :(

I think you mean IP address? No, NETDEV_CHANGEADDR is for hardware
address, not for IP address.

If you were changing mac address, you will receive NETDEV_CHANGEADDR.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Notifier chains bug ?
  2010-03-02  3:24 ` Américo Wang
@ 2010-03-02  5:50   ` Oleg Kutkov
  2010-03-02 15:42     ` Américo Wang
  0 siblings, 1 reply; 5+ messages in thread
From: Oleg Kutkov @ 2010-03-02  5:50 UTC (permalink / raw)
  To: Américo Wang, linux-kernel

2010/3/2 Américo Wang <xiyou.wangcong@gmail.com>:
> On Tue, Mar 2, 2010 at 8:08 AM, Oleg Kutkov <elenbert@gmail.com> wrote:
>> Hello.
>> I try to used notifier chains for monitoring network devices events.
>> All works perfectly when just i'm connecting/disconnecting network cable or
>> up/down interface via ifconfig.
>> But when i try to change interface address - nothing happens. Notifier is
>> don't send any events :(
>
> I think you mean IP address? No, NETDEV_CHANGEADDR is for hardware
> address, not for IP address.
>
> If you were changing mac address, you will receive NETDEV_CHANGEADDR.
>

Thank for quick answer.
Yes, i mean IP address. And what about NETDEV_CHANGE ?
Is there possible for monitoring IP address/netmask changing ?

Thank.

-- 
Best regards,
Oleg

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Notifier chains bug ?
  2010-03-02  5:50   ` Oleg Kutkov
@ 2010-03-02 15:42     ` Américo Wang
       [not found]       ` <7f9bf5711003020755p653a0b8cq707e9b1e12b44c98@mail.gmail.com>
  0 siblings, 1 reply; 5+ messages in thread
From: Américo Wang @ 2010-03-02 15:42 UTC (permalink / raw)
  To: Oleg Kutkov; +Cc: Américo Wang, linux-kernel, netdev

On Tue, Mar 02, 2010 at 07:50:01AM +0200, Oleg Kutkov wrote:
>2010/3/2 Américo Wang <xiyou.wangcong@gmail.com>:
>> On Tue, Mar 2, 2010 at 8:08 AM, Oleg Kutkov <elenbert@gmail.com> wrote:
>>> Hello.
>>> I try to used notifier chains for monitoring network devices events.
>>> All works perfectly when just i'm connecting/disconnecting network cable or
>>> up/down interface via ifconfig.
>>> But when i try to change interface address - nothing happens. Notifier is
>>> don't send any events :(
>>
>> I think you mean IP address? No, NETDEV_CHANGEADDR is for hardware
>> address, not for IP address.
>>
>> If you were changing mac address, you will receive NETDEV_CHANGEADDR.
>>
>
>Thank for quick answer.
>Yes, i mean IP address. And what about NETDEV_CHANGE ?

It is for rtnetlink state transition.

>Is there possible for monitoring IP address/netmask changing ?
>

AFAIK, no.

Cc'ing netdev experts...

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Notifier chains bug ?
       [not found]       ` <7f9bf5711003020755p653a0b8cq707e9b1e12b44c98@mail.gmail.com>
@ 2010-03-04 10:08         ` Américo Wang
  0 siblings, 0 replies; 5+ messages in thread
From: Américo Wang @ 2010-03-04 10:08 UTC (permalink / raw)
  To: Atis Elsts; +Cc: Oleg Kutkov, LKML, Linux Kernel Network Developers

On Tue, Mar 2, 2010 at 11:55 PM, Atis Elsts <atis.elsts@gmail.com> wrote:
> I'm no expert, but IMHO for handling IP address changes you should use
> function register_inetaddr_notifier() to register you callback and
> then wait for  NETDEV_UP and NETDEV_DOWN events.
>

Oh, I think you are right.

Btw, please don't drop Cc's.

Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-03-04 10:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-02  0:08 Notifier chains bug ? Oleg Kutkov
2010-03-02  3:24 ` Américo Wang
2010-03-02  5:50   ` Oleg Kutkov
2010-03-02 15:42     ` Américo Wang
     [not found]       ` <7f9bf5711003020755p653a0b8cq707e9b1e12b44c98@mail.gmail.com>
2010-03-04 10:08         ` Américo Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox