Hotplug.d script is not called after eth0 unplug

Hi,

I placed a script in both /etc/hotplug.d/iface and /etc/hotplug.d/net dirs.
Neither script is being called when I unplug and re-plug my ethernet cable into eth0

But I do see kernel and netifd messages for when eth0 is being unplugged and plugged in the log

Tue Oct 17 12:11:22 2017 kern.info kernel: [  156.304917] eth0: link up (1000Mbps/Full duplex)
Tue Oct 17 12:11:22 2017 daemon.notice netifd: Network device 'eth0' link is up
Tue Oct 17 12:11:24 2017 kern.info kernel: [  158.313012] br-lan: port 1(eth0) entered forwarding state


Tue Oct 17 12:12:06 2017 kern.info kernel: [  200.302308] eth0: link down
Tue Oct 17 12:12:06 2017 kern.info kernel: [  200.305481] br-lan: port 1(eth0) entered disabled state
Tue Oct 17 12:12:06 2017 daemon.notice netifd: Network device 'eth0' link is down

my basic test script

root@LEDE:/etc/hotplug.d/iface# cat 99-my-action

#!/bin/sh

logger test--test Device: $DEVICE / Action: $ACTION

Above script is being called ONLY on boot and I see this message:

user.notice root: test--test Device: br-lan / Action: ifup

Any advice?

Thanks

I guess that is happening because eth0 is bridged into br-lan; even if you plug / unplug a cable into the eth0 port, the br-lan interface is not going up or down, thus no hotplug action is happening.

Right now link state events are explicitely filtered to not trigger hotplug.

1 Like

@jow thanks for the answer here and on IRC channel. I am leaving it here incase someone else runs into the same situation.

jow's advice was to write a ubus listener and look for netifd events.

I don't know how to do it yet, but once I figure it out I'll post it here.
If anyone has resources/pointers on how to get started, please let me know.

Thanks!

Will it work if you add these scripts to /etc/hotplug.d/net/ instead of iface?

hotplug script not call on interface with static ip setup
when plug-in/plug-out the cable no ifup/ifdown event