Closed thom-nic closed 6 years ago
Thanks for the report! I've been thinking about how to handle this in a portable manner ... ideally I'd like to be able to run mdnsd on *BSD as well, so I've tried to avoid listening to netlink to detect interface address changes.
I think the best solution atm. is to call getifaddrs()
whenever we announce the IP, i.e. when the TTL is about to elapse, or when we get a discover message.
Thanks for mentioning the "Failed writing to socket", we should probably add a -p
persistent mode that allows mdnsd to retry the same interface (name, not ifindex since that might change) until it comes back.
should probably add a -p persistent mode that allows mdnsd to retry
That would be great! Yes, at the moment my init
is very simple - no process supervision - so for the time being, if it's possible mdnsd
could die abruptly that's the other reason to restart the daemon on network changes :)
OK, I'll look into it!
(I guess writing an init process form scratch isn't for everyone :rofl: )
I saw finit
, and I definitely like it better than busybox's runsv
! I just haven't gotten around to pulling in something more sophisticated yet.
Awesome! Yeah, we used runsv (or rather djb daemontools) many years ago. Not really my cup of tea. Then we found Finit and I picked up maintaining+extending that -- mostly engineered for our purposes at work, but there are other users as well, not for everyone though (ymmv).
There, hopefully it works OK for you. Let me know otherwise and we'll reopen the issue.
So, I'm running on a device that may boot up with no Ethernet connected, or it could be boot on a DHCP network, then be disconnected and reconnected to a switch without DHCP, falling back to a ZeroConf IP address, etc. Currently I'm using busybox
ifplugd
to detect interface events, which in turn triggerudhcpc
andzcip
(the ZeroConf daemon) to restart.udhcpc
andzcip
then fire their own scripts when e.g. a DHCP lease is obtained or a ZeroConf IP is allocated.In mdnsd.c, it looks like
ina
is assigned once inmain()
and it's assumed that address will not change. I seeSIGHUP
will re-read config files but not reload IP address. So I'm left with killing/restartingmdnsd
when any IP address changes.I don't know if the easiest solution is
rtnetlink
notification, callinggetifaddrs()
periodically and comparing the result, or letting an external program signal that the IP address has changed.I also noticed that mdnsd quit with an error
Failed writing to socket: Invalid argument
presumably when the interface was unplugged. Or maybe there's no "easy" way to handle this, and the right answer is just killing and restarting mdnsd.I imagine this could be related to #8 but that issue didn't mention address changes.