SO!

Max had some trouble last night with notdhcp not detecting link state. There turned out to be two problems. The first one was that I'd used an int where it should have been a uin8_t which caused link state detection not to work on any ar71xx hardware. That's fixed now and I tested it on a Bullet M2.

The second issue was not so easily defeated. It turns out that there are no netlink notifications for physical link state on switches. Instead, the kernel always reports the linkstate as connected since the internal ethernet interface is always connected to the internal switch. The N600/N750 boards have integrated switches, and so do the nanostations. I'm not sure about the nanobridges or picostations (I'd think not).

It wouldn't be completely insane to extend the switch driver with the ability to report link state changes using netlink (the switch driver already communicates to userland with netlink), and I've outlined my findings on how this could be done here if anyone is really curious:
However, we have a deadline and it turns out that the link state info can be gotten with the swlib library which exists only as part of the swconfig utility. It's a bit ugly that we can only detect link state changes by polling but real ethernet drivers actually just poll in-kernel for these changes anyway. I've copied the swlib source into the notdhcp repository. Unfortunately that utility uses libnl and libnl-gen so now notdhcp has library dependencies (which needs to be added to the sudowrt-packages makefile and to the packages list).

Writing notdhcp has been much more of a rabbit hole than expected. But! We want to be able to query switch port link status for purposes of the GUI anyway and now we know that this is currently impossible (short of allowing the running of arbitrary commands from the gui). I think once we've gotten all this working I'll go back and move the switch status polling code over to a fork of netifd and then make notdhcp use ubus to listen for the link state changes.

Now the skylights are no longer black and that's my queue to call it a night. I'll try to get this working before Tuesday.

--
marc/juul