module-tunnel sinks disappear on multihomed machine when one of the interfaces is disconnected
Submitted by Rudd-O
Assigned to pul..@..op.org
At home, I have a multihomed machine (same IP on both interfaces) that has two network interfaces: LAN, WLAN. These two network interfaces are configured to have the same IP address, but different routing priorities (higher for the LAN), and NetworkManager enables/disables them based on the presence or absence of network connection.
(I am oversimplifying a bit here -- there is a VPN network interface that is only used if I am on the go, and that's also multihomed, and it works flawlessly too -- it is exactly as if I was home, barring latency -- but this bug is present regardless of that).
This is highly advantageous because it lets me unplug my network cable when I need mobility, then re-plug it again when I need high throughput, and programs using the network connection continue to work normally without the need to "reconnect" (NFS mounts, Skype, Web sites, et cetera).
Even PulseAudio works well in that scenario -- plug the network cable and the traffic begins to be automatically transmitted by the LAN interface.
There's one problem, though:
~@karen.dragonfear α: avahi-browse -a | grep pulse
- wlan0 IPv4 firstname.lastname@example.org: Internal Audio PulseAudio Sound Sink local
- wlan0 IPv4 email@example.com PulseAudio Sound Server local
- eth0 IPv4 firstname.lastname@example.org: Internal Audio PulseAudio Sound Sink local
- eth0 IPv4 email@example.com PulseAudio Sound Server local
When the multihomed machine is running fine, my network PulseAudio server connected to my stereo appears twice in Avahi, and once in paman/pavucontrol. This would not be much of a problem, since PulseAudio works fine.
Except, when I unplug one of the cables, of course, the server and sink attached to the specific network interface disappears. Which leaves the other one (WLAN) STILL available, but for some reason PulseAudio on my multihomed machine thinks it's "gone" and, of course, the sinks just disappear even though avahi-browse clearly shows them.
connect WLAN: sink becomes available in local server connect LAN: everything continues as normal disconnect LAN: sink disappears from local paman/pavucontrol connect LAN: sink no longer appears anymore, have to restart server to force another MDNS announcement
To "fix this", I must restart the server either locally or in my stereo computer.
I would think the proper fix is to double-check with Avahi to see whether the server and sink with the same name are still available before deciding "oops, it's gone" and making it unavailable. Another fix would be to verify that the TCP connection to the server is still vaild before deciding "oops, it's gone". Or, to keep a counter per server keyed to the server name, so that the sequence would be 0 1 2 1 0, and only when it reaches 0, it is made unavailable.