Repository navigation
Description
Having 2 Network interfaces connected to 2 different networks which are not interconnected in any way. I can observe duplication of IPv6 addresses with the scope_id of the other network where the addresses cannot actually be reached.
Query example for _http._tcp
At 348.62µs: SearchStarted("_http._tcp.local. on 6 interfaces [fe80::3236:543d:a120:72e5 (wlp13s0), 192.168.179.7 (wlp13s0), 192.168.178.53 (enp12s0), 2003:e8:bf13:1300:a491:e24f:acbf:68c3 (enp12s0), fe80::b7a:957b:f7e1:9b0e (enp12s0), 2003:e8:bf13:1301:e1f1:dd6c:fb10:b831 (wlp13s0)]")
At 70.418189ms: ServiceFound("_http._tcp.local.", "Denon AVR-X1400H._http._tcp.local.")
At 70.433569ms: Resolved a new service: Denon AVR-X1400H._http._tcp.local.
host: Denon-AVR-X1400H.local.
port: 80
Address: 2003:e8:bf13:1300:205:cdff:fea5:86b0%2
Address: fe80::205:cdff:fea5:86b0%2
Address: 192.168.178.21
Property: path=/settings/
At 70.461459ms: Resolved a new service: Denon AVR-X1400H._http._tcp.local.
host: Denon-AVR-X1400H.local.
port: 80
Address: fe80::205:cdff:fea5:86b0%3
Address: 2003:e8:bf13:1300:205:cdff:fea5:86b0%2
Address: fe80::205:cdff:fea5:86b0%2
Address: 192.168.178.21
Address: 2003:e8:bf13:1300:205:cdff:fea5:86b0%3
Property: path=/settings/
At 332.554357ms: ServiceFound("_http._tcp.local.", "Tibber Bridge Web Server._http._tcp.local.")
At 332.567917ms: Resolved a new service: Tibber Bridge Web Server._http._tcp.local.
host: Bridge20c228000.local.
port: 80
Address: 192.168.178.33
At 332.574957ms: Resolved a new service: Tibber Bridge Web Server._http._tcp.local.
host: Bridge20c228000.local.
port: 80
Address: 192.168.178.33
What's also strange, if one disables WiFi one can only observe one resolve of each instance, in the example before we can could observe 2 for each:
At 280.27µs: SearchStarted("_http._tcp.local. on 3 interfaces [fe80::b7a:957b:f7e1:9b0e (enp12s0), 192.168.178.53 (enp12s0), 2003:e8:bf13:1300:a491:e24f:acbf:68c3 (enp12s0)]")
At 44.121358ms: ServiceFound("_http._tcp.local.", "Denon AVR-X1400H._http._tcp.local.")
At 44.137018ms: Resolved a new service: Denon AVR-X1400H._http._tcp.local.
host: Denon-AVR-X1400H.local.
port: 80
Address: fe80::205:cdff:fea5:86b0%2
Address: 192.168.178.21
Address: 2003:e8:bf13:1300:205:cdff:fea5:86b0%2
Property: path=/settings/
At 712.481579ms: ServiceFound("_http._tcp.local.", "Tibber Bridge Web Server._http._tcp.local.")
At 712.507919ms: Resolved a new service: Tibber Bridge Web Server._http._tcp.local.
host: Bridge20c228000.local.
port: 80
Address: 192.168.178.33
From the output addresses i can only ping link local IPv6 addresses with the interface index 2, not 3.
Ping using index 3 (wlp13s0) which is connected to a guest WiFi:
ping fe80::205:cdff:fea5:86b0%3
PING fe80::205:cdff:fea5:86b0%3 (fe80::205:cdff:fea5:86b0%wlp13s0) 56 data bytes
From fe80::3236:543d:a120:72e5%wlp13s0 icmp_seq=1 Destination unreachable: Address unreachable
From fe80::3236:543d:a120:72e5%wlp13s0 icmp_seq=2 Destination unreachable: Address unreachable
From fe80::3236:543d:a120:72e5%wlp13s0 icmp_seq=3 Destination unreachable: Address unreachable
Ping using index 2(enp12s0):
ping fe80::205:cdff:fea5:86b0%2
PING fe80::205:cdff:fea5:86b0%2 (fe80::205:cdff:fea5:86b0%enp12s0) 56 data bytes
64 bytes from fe80::205:cdff:fea5:86b0%enp12s0: icmp_seq=1 ttl=255 time=0.864 ms
64 bytes from fe80::205:cdff:fea5:86b0%enp12s0: icmp_seq=2 ttl=255 time=0.384 ms
64 bytes from fe80::205:cdff:fea5:86b0%enp12s0: icmp_seq=3 ttl=255 time=0.390 ms
Output of ip addr show:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host proto kernel_lo
valid_lft forever preferred_lft forever
2: enp12s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether d8:43:ae:b3:ea:97 brd ff:ff:ff:ff:ff:ff
inet 192.168.178.53/24 brd 192.168.178.255 scope global dynamic noprefixroute enp12s0
valid_lft 860430sec preferred_lft 860430sec
inet6 2003:e8:bf13:1300:a491:e24f:acbf:68c3/64 scope global dynamic noprefixroute
valid_lft 6861sec preferred_lft 1461sec
inet6 fe80::b7a:957b:f7e1:9b0e/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: wlp13s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 58:cd:c9:86:54:1f brd ff:ff:ff:ff:ff:ff
inet 192.168.179.7/24 brd 192.168.179.255 scope global dynamic noprefixroute wlp13s0
valid_lft 21149sec preferred_lft 21149sec
inet6 2003:e8:bf13:1301:e1f1:dd6c:fb10:b831/64 scope global dynamic noprefixroute
valid_lft 6862sec preferred_lft 1461sec
inet6 fe80::3236:543d:a120:72e5/64 scope link noprefixroute
valid_lft forever preferred_lft forever
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:cb:66:f6 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
5: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 6e:03:f8:11:28:dd brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
The issue was probably hidden behind the HashSet<IpAddr> previously and not noticeable, but now we use HashSet<HostIp> which exposes the issue.
Activity
[-]Duplicate IPv6 addresses[/-][+]Duplicate resolved IPv6 addresses[/+][-]Duplicate resolved IPv6 addresses[/-][+]Duplicate resolved IPv6 addresses when using multiple network interfaces[/+]keepsimple1 commentedon Jul 17, 2025
I was not able to reproduce this locally yet. I suspect that in your test,
wlp13s0interface somehow did also receive the multicast packet of the network ofenp12s0. I am trying to understand that. Meantime, I opened a PR #373 with debugs for you to run withRUST_LOG=DEBUG cargo run ...for your test to verify that.hrzlgnm commentedon Jul 17, 2025
Yes it looks like those duplicates are also received via wlp13s0:
But that's actually not possible, e.g. if I disable enp12s0, I get:
hrzlgnm commentedon Jul 17, 2025
According to socket stats, we bind to any address on any interface on linux, instead of interface specific addresses:
Which explains what we can observe the duplicate packets under Linux.
I'm also able to observe duplication across multiple interfaces on another machine where for example VPN interfaces are also involved, but actually cannot do multicast.
hrzlgnm commentedon Jul 17, 2025
Avahi uses a single socket for each protocol but utilizes IPV6_RECVPKTINFO to also receive information interface the packet was received on:
https://github.com/avahi/avahi/blob/2bb03084505fb9e2041ee8083a0ca08f1665f0f5/avahi-core/socket.c#L276C38-L276C54
https://github.com/avahi/avahi/blob/2bb03084505fb9e2041ee8083a0ca08f1665f0f5/avahi-core/socket.c#L798
keepsimple1 commentedon Jul 18, 2025
yes, but we also specify the interface when calling
join_multicast_v6. It seems that the behavior is different on macOS (where I was not able to reproduce) and Linux. Now running on Linux, I see the same issue.We have a pending issue #65 (and PR #190) which will would also help address this problem. Meanwhile, maybe we can search for some platform specific solutions.
hrzlgnm commentedon Jul 19, 2025
I was also toying around quick and dirty with setsockopt SO_BINDTODEVICE, but that didn't improve the situation.
hrzlgnm commentedon Jul 19, 2025
So searching for a platform specific solution with IP_PKTINFO or IP6_PKTINFO is probably the way to on Linux.
keepsimple1 commentedon Jul 23, 2025
I have updated PR #373 with a fix for Linux (and macOS) platforms. I tested it locally and it seems to work. @hrzlgnm could you please give it a try when you have time? Thanks.
hrzlgnm commentedon Jul 23, 2025
@keepsimple1 I've tested those changes and the duplicate addresses are indeed gone. But there is a catch, on a Linux system having tun interfaces due to using OpenVPN connections, those still get duplicated for the tun interface, but that's not big of a deal as I disable those interfaces in the daemon in my use case.
hrzlgnm commentedon Jul 23, 2025
@keepsimple1 I've tried it out once more, and I still get duplicates it seems, don't know why I did not get any this morning:
keepsimple1 commentedon Jul 26, 2025
@hrzlgnm Thanks for testing and details! I change the approach with a big refactoring in PR #373. Now we use a common socket for all interfaces (separate for IPv4 and IPv6). This is possible because of help from
socket-pktinfocrate. I tested it locally and it seems to help fixing this issue. Could you please give it a try when you have time?hrzlgnm commentedon Jul 27, 2025
@keepsimple1 I've tested the changes, the duplicate addresses are gone now.
I found a panic, when disabling a WiFi interface while the daemon was running and resolving, could not hit it more but it should be clear why that happened, the offending line tries to set a multicast_v4 address but that probably just got removed from the network interface:
keepsimple1 commentedon Jul 27, 2025
@hrzlgnm thank you for testing and found the panic! I have updated the diff to handle it gracefully and also cleaned up a bit. Please let me know if that fixes it. I will also submit a PR to
socket-pktinfocrate for its patch.hrzlgnm commentedon Jul 28, 2025
@keepsimple1 Tested again, but could not reproduce the panic anymore. Code-wise it also looks good to me. I also wasn't able to trigger the respective error message that is logged now. Probably just got lucky with the timing the first time.
keepsimple1 commentedon Jul 29, 2025
Thanks again for verifying, and your previous comments that inspired me to make the changes. Just merged the PR. If any problems, please feel free to reopen this issue or a new issue.