how to catch the NIC interrupt(up/down)?

linux-kernel

Solution

Look in `<linux/netdevice.h>`, specifically the stuff about the netdev notifier chain. You can call `register_netdevice_notifier()` to register a callback that (among many other event types) will receive `NETDEV_UP` and `NETDEV_DOWN` events.

Problem

I'm writing a linux kernel module that needs to be notified when a link goes up/down, now I've read that I can open a `netlink socket` and listen to the `RTMGRP_LINK` (network interface create/delete/up/down events) multicast groups, but this is used from user space... any one knows how to catch this interrupt from kernel space? I'm using kernel 2.6.35

Original source