• Philippe Gerum's avatar
    net: create sysfs nodes for net devices · 20818d45
    Philippe Gerum authored
    Each rtnet device registered with the stack is represented by a node
    into /sys/devices/virtual/rtnet/.
    
    Setting the address of the real device probed by the kernel into the
    rtnet_device.sysbind field before calling rt_register_rtnetdev(),
    causes the "adapter" symlink to be installed in the newly created
    attribute directory, pointing at that device.
    
    e.g.
    
    static int probe_handler(struct pci_dev *pdev, const struct pci_device_id *ent)
    {
    	...
    	rtdev->sysbind = &pdev->dev;
    	...
    	ret = rt_register_rtnetdev(rtdev);
    	...
    }
    
    $ ls -l /sys/devices/virtual/rtnet/
    total 0
    drwxr-xr-x    2 root     root             0 Mar 30 12:50 enp1s0
    drwxr-xr-x    2 root     root             0 Mar 30 12:50 rtlo
    
    $ ls -l /sys/devices/virtual/rtnet/enp1s0/
    total 0
    lrwxrwxrwx    1 root     root             0 Mar 30 12:51 adapter -> ../../../pci0000:00/0000:00:13.0/0000:01:00.0
    lrwxrwxrwx    1 root     root             0 Mar 30 12:51 subsystem -> ../../../../class/rtnet
    -rw-r--r--    1 root     root          4096 Mar 30 12:50 uevent
    20818d45
rtdev.h 9.19 KB