Search code examples
cperlnetwork-programmingfreebsdethernet

FreeBSD Ethernet Manipulation


I need a method to perform the following task, suppose if I have a computer with k (k is large) number of Ethernet interfaces. I want to have a method to identify which identifier (em0) is assigned to which physical interface.

The only "easy" method that I came up is to blink the LED light on the physical interface.

For example

etherblink em0

Would flash the link or the activity LED on the physical Ethernet interface that is assigned to em0.

I know on linux there is the ethertool, but that doesn't work with FreeBSD. As well as there is the LED driver on FreeBSD, but that only support limited number of Ethernet modules.

Any ideas? I thought about binding a socket to the interface and write to the socket, but that didn't work.

C or Perl


Solution

  • Sadly I did not find a general solution to this problem, however, from my research (by reading the change log of FreeBSD 8.2, and from the forums) It seems that:

    "some cards blink the LEDs on access, so pings could make a repeated pattern. 
    The LEDs might even go off if the card is downed with ifconfig(8)." 
    

    Particularly em and igb interfaces, as stated by:

    "The em(4) and igb(4) drivers now support the led(4) interface via /dev/led/emN and 
    /dev/led/igbN for identification LED control. The following command line makes the 
    LED blink on em0:[r211241]" (FreeBSD 8.2 Release changelog)
    

    However I do not have the hardware to test this. What I did end up doing was rewritten the Ethernet driver for the interface that I am using to support the LED hardware feature.