Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux-kernel

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

like image 359
Varda Elentári Avatar asked Jun 11 '12 12:06

Varda Elentári


People also ask

How do you check interrupts in Linux?

With the CPU keyword, the number of each individual interrupt received per second by the CPU or CPUs is displayed. Interrupts are those listed in /proc/interrupts file.

How interrupts are handled in Linux?

An interrupt is simply a signal that the hardware can send when it wants the processor's attention. Linux handles interrupts in much the same way that it handles signals in user space. For the most part, a driver need only register a handler for its device's interrupts, and handle them properly when they arrive.

Can interrupt handler be interrupted?

However, such kernel control paths may be arbitrarily nested; an interrupt handler may be interrupted by another interrupt handler, thus giving raise to a nested execution of kernel threads.

What is IRQ in Linux?

An IRQ is an interrupt request from a device. Currently they can come in over a pin, or over a packet. Several devices may be connected to the same pin thus sharing an IRQ. An IRQ number is a kernel identifier used to talk about a hardware interrupt source.


1 Answers

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.

like image 173
Roland Avatar answered Oct 24 '22 11:10

Roland