Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dns_cache: address record should only flush on the same network #261

Merged
merged 6 commits into from
Oct 5, 2024

Conversation

keepsimple1
Copy link
Owner

@keepsimple1 keepsimple1 commented Oct 4, 2024

When debugging an issue in Discussions #260 , I installed docker on macOS, and the test case integration_success fails intermittently.

With some digging, it seems that: there are IPv6 interfaces that have more than 1 IPv6 address configured. I.e. same interface name same interface index, but different IPv6 address. Because IPv6 sockets joins multicast using their index, not the address, there are two sockets receive packets for both addresses. Depends on the timing, one of the addresses could be flushed by another one and cause the resolved service has less addresses than expected.

The following log shows this happened with two cases, and resolved 16 addr(s) instead of expected 18 addr(s):

Expired addr: DnsAddress { record: DnsRecord { entry: DnsEntry { name: "integration_host.local.", ty: 28, class: 1, cache_flush: true }, ttl: 120, created: 1727984047922, expires: 1727984049923, refresh: 1727984143922 }, address: fd5b:7dca:54f1::2 } at now: 1727984049925
Expired addr: DnsAddress { record: DnsRecord { entry: DnsEntry { name: "integration_host.local.", ty: 28, class: 1, cache_flush: true }, ttl: 120, created: 1727984047922, expires: 1727984049923, refresh: 1727984143922 }, address: fdc9:76a:d895:9ee4:426:ddf3:376f:23d6 } at now: 1727984049925
Expired: integration_host.local. addr {fd5b:7dca:54f1::2, fdc9:76a:d895:9ee4:426:ddf3:376f:23d6}
Resolved a new service: 1727984047917628._mdns-sd-it._udp.local. with 16 addr(s)

This patch adds a check for cache flush: for address records, we only flush if the incoming address and the existing address are on the same network of the interface.

Also, changed a error log into a debug log per the discussions comment.

@keepsimple1 keepsimple1 merged commit 0381e30 into main Oct 5, 2024
3 checks passed
@keepsimple1 keepsimple1 deleted the debug-test branch October 5, 2024 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant