How to catch a NIC interrupt (up / down)?

I am writing a Linux kernel module that should be notified when a link goes up / down, now I have read that I can open netlink socketand listen to RTMGRP_LINK(create / delete / up / down network interface) multicast groups, but this is used from user space .. Does anyone know how to catch this interrupt from kernel space? I am using kernel 2.6.35

+5
source share
1 answer

See <linux/netdevice.h>, in particular, the netdev notification chain information. You can call register_netdevice_notifier()to register a callback that (among many other types of events) will receive events NETDEV_UPand NETDEV_DOWN.

+3
source

All Articles