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

"found conflict name" when two interfaces are on the same subnet #293

Closed
inetic opened this issue Jan 9, 2025 · 3 comments
Closed

"found conflict name" when two interfaces are on the same subnet #293

inetic opened this issue Jan 9, 2025 · 3 comments

Comments

@inetic
Copy link

inetic commented Jan 9, 2025

I'm still in the process of understanding the mDNS protocol, so may be that I'm misusing the library.

I have two network interfaces on my laptop:

WiFi: inet 192.168.1.41/24 brd 192.168.1.255 scope global dynamic noprefixroute wlp3s0
Ethernet: inet 192.168.1.201/24 brd 192.168.1.255 scope global dynamic noprefixroute enx

One can see they are on the same subnet: 192.168.1.41 & wifi_mask == 192.168.1.201 & ethernet_mask

I initialize ServiceInfo with enable_addr_auto and instance_name is a random u64 like so:

    let service_info = ServiceInfo::new(
        "_foo._udp._local",                 // service_type
        &instance_name,                     // instance_name `rng.gen::<u64>().to_string()`
        &format!("{instance_name}.local."), // host_name
        (),                                 // ip
        55774,                              // port
        &properties[..],                    // properties
    )
    .unwrap()
    .enable_addr_auto();

When I run the example with the above I see this sequence of events:

SearchStarted "_foo._udp.local. on 2 interfaces [192.168.1.201 (enx), 192.168.1.41 (wlp3s0)]"
found conflict name: '51181159829609009.local.' record: TYPE_A: 192.168.1.41 PEER: 192.168.1.201
found conflict name: '51181159829609009.local.' record: TYPE_A: 192.168.1.201 PEER: 192.168.1.41
ServiceFound 51181159829609009._foo._udp.local.
ServiceResolved 51181159829609009._foo._udp.local. {192.168.1.201, 192.168.1.41}
found conflict name: '51181159829609009._foo._udp.local.' record: TYPE_SRV: priority: 0, weight: 0, port: 55774, host: 51181159829609009-2.local. PEER: priority: 0, weight: 0, port: 55774, host: 51181159829609009.local.
SearchStarted "_foo._udp.local. on 2 interfaces [192.168.1.201 (enx), 192.168.1.41 (wlp3s0)]"
ServiceFound 51181159829609009 (2)._foo._udp.local.
ServiceResolved 51181159829609009 (2)._foo._udp.local. {192.168.1.201, 192.168.1.41}
SearchStarted "_foo._udp.local. on 2 interfaces [192.168.1.201 (enx), 192.168.1.41 (wlp3s0)]"
SearchStarted "_foo._udp.local. on 2 interfaces [192.168.1.201 (enx), 192.168.1.41 (wlp3s0)]"

I wonder whether in the conflict_handler when checking for duplicates per interface the check should instead be per interface subnet?

@keepsimple1
Copy link
Owner

keepsimple1 commented Jan 10, 2025

Thanks for opening the issue with much details! I think the problem is that the conflict handler checks one record at a time and in this case there are two TYPE A records for the same hostname, and each record triggers a conflict with another record (different address).

In my understanding, one Resource Record in DNS can only have one address. So I didn't push two addresses into a single RR, instead I came up with a patch that check if address record would match with any address record of the local responder. See PR #294 . In my quick testing, it seems to help. Please let me know if this patch helps in your case, if you got chance.

@inetic
Copy link
Author

inetic commented Jan 10, 2025

This indeed fixed the issue as I no longer see any instance name "-(N)" suffixes nor the "found conflict name" log lines.

Thank you.

@keepsimple1
Copy link
Owner

Thanks for confirming! I've merged the PR.

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

No branches or pull requests

2 participants