Skip to content

refactoring: read_name and name compression - #492

Open
keepsimple1 wants to merge 5 commits into
mainfrom
name-pointer
Open

refactoring: read_name and name compression#492
keepsimple1 wants to merge 5 commits into
mainfrom
name-pointer

Conversation

@keepsimple1

Copy link
Copy Markdown
Owner

Re-implemented read_name that hopefully help resolve this comment: #468 (comment)

@Phyks

Phyks commented Aug 17, 2026

Copy link
Copy Markdown

Hi,

I did a quick test rebuilding netmuxd against this branch, and it seems the issue is still present:

$ sudo -u usbmux RUST_LOG=debug ./netmuxd --disable-unix --host 127.0.0.1
Starting netmuxd
[2026-08-17T18:34:31Z INFO  netmuxd] Logger initialized
[2026-08-17T18:34:31Z INFO  netmuxd] Collected arguments, proceeding
[2026-08-17T18:34:31Z INFO  netmuxd::mdns] Starting mDNS discovery for _apple-mobdev2._tcp.local. with mdns-sd
Listening on 127.0.0.1:27015
WARNING: Running in host mode will not work unless you are running a daemon in unix mode as well
[2026-08-17T18:34:31Z DEBUG mdns_sd::service_daemon] join multicast group V4 on lo addr 127.0.0.1
[2026-08-17T18:34:31Z DEBUG mdns_sd::service_daemon] join multicast group V4 on ens18 addr 10.42.4.102
[2026-08-17T18:34:31Z DEBUG mdns_sd::service_daemon] join multicast group V4 on br-c2548c7b1cc0 addr 172.18.0.1
[2026-08-17T18:34:31Z DEBUG mdns_sd::service_daemon] join multicast group V4 on br-f78b176b13fe addr 172.19.0.1
[2026-08-17T18:34:31Z DEBUG mdns_sd::service_daemon] join multicast group V6 on lo addr ::1 with index 1
[2026-08-17T18:34:31Z DEBUG mdns_sd::service_daemon] join multicast group V6 on ens18 addr 2a01:XXX with index 2
[2026-08-17T18:34:31Z DEBUG mdns_sd::service_daemon] join multicast group V6 on ens18 addr fe80::XXX with index 2
[2026-08-17T18:34:31Z DEBUG mdns_sd::service_daemon] failed to join multicast: fe80::XXX: PKT join multicast group on addr fe80::XXX: Address already in use (os error 98). Skipped.
[2026-08-17T18:34:31Z DEBUG mdns_sd::service_daemon] join multicast group V6 on br-c2548c7b1cc0 addr fe80::XXX with index 21
[2026-08-17T18:34:31Z DEBUG mdns_sd::service_daemon] join multicast group V6 on br-f78b176b13fe addr fe80::XXX with index 22
[2026-08-17T18:34:31Z DEBUG mdns_sd::service_daemon] join multicast group V6 on vethc2fd722 addr fe80::XXX with index 23
[2026-08-17T18:34:31Z DEBUG mdns_sd::service_daemon] join multicast group V6 on vethfcd878d addr fe80::XXX with index 24
[2026-08-17T18:34:31Z DEBUG mdns_sd::service_daemon] join multicast group V6 on vethd5c140a addr fe80::XXX with index 25
[2026-08-17T18:34:31Z DEBUG mdns_sd::service_daemon] join multicast group V6 on vethf260437 addr fe80::XXX with index 26
[2026-08-17T18:34:31Z DEBUG mdns_sd::service_daemon] join multicast group V6 on veth1a365cc addr fe80::XXX with index 27
[2026-08-17T18:34:31Z DEBUG mdns_sd::service_daemon] join multicast group V6 on veth70758b7 addr fe80::XXX with index 28
[2026-08-17T18:37:05Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 106 must be less than the start offset 100
[2026-08-17T18:38:13Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 106 must be less than the start offset 100

RUST_LOG=trace is very verbose, and does not seem to provide much more details. I'm not sure if there is any extra logging that would be helpful?

I'll make a proper and clean tcpdump and report back with it! :)

@keepsimple1

keepsimple1 commented Aug 18, 2026

Copy link
Copy Markdown
Owner Author

I did a quick test rebuilding netmuxd against this branch, and it seems the issue is still present:

from your log, it seems that the test was not using this PR branch? The following log line no longer exists in this branch:

[2026-08-17T18:37:05Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 106 must be less than the start offset 100

Just a note, you can update the dependency using the following :

mdns-sd = { git = "https://github.com/keepsimple1/mdns-sd", branch = "name-pointer" }

@Phyks

Phyks commented Aug 18, 2026

Copy link
Copy Markdown

Oops, sorry, thanks for pointing out. I had updated the Cargo.toml but forgot to run a cargo update prior to build. Upon rebuild, these are the typical log lines that I get:

2026-08-18T07:15:58Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 150 at offset 148 must point backwards
[2026-08-18T07:15:59Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 169 at offset 125 must point backwards
[2026-08-18T07:15:59Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 150 at offset 148 must point backwards
[2026-08-18T07:16:00Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 169 at offset 125 must point backwards
[2026-08-18T07:16:01Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 169 at offset 125 must point backwards
[2026-08-18T07:16:05Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 169 at offset 125 must point backwards
[2026-08-18T07:25:06Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 150 at offset 148 must point backwards
[2026-08-18T07:25:07Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 169 at offset 125 must point backwards
[2026-08-18T07:25:07Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 150 at offset 148 must point backwards
[2026-08-18T07:25:08Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 169 at offset 125 must point backwards
[2026-08-18T07:25:09Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 169 at offset 125 must point backwards
[2026-08-18T07:25:13Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 169 at offset 125 must point backwards
[2026-08-18T07:34:41Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 150 at offset 148 must point backwards
[2026-08-18T07:34:42Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 150 at offset 148 must point backwards
[2026-08-18T07:34:42Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 169 at offset 125 must point backwards
[2026-08-18T07:34:43Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 169 at offset 125 must point backwards
[2026-08-18T07:34:44Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 150 at offset 148 must point backwards
[2026-08-18T07:34:45Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 169 at offset 125 must point backwards
[2026-08-18T07:34:48Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 169 at offset 125 must point backwards
[2026-08-18T07:39:54Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Bad name with invalid length: 0x6e offset 80, data (so far): [0, 0, 84, 0, 0, 0, 0, d, 0, 0, 0, 0, 8, 5f, 61, 69, 72, 70, 6c, 61, 79, 4, 5f, 74, 63, 70, 5, 6c, 6f, 63, 61, 6c, 0, 0, c, 0, 1, 0, 0, 11, 94, 0, 13, 10, 44, 65, 6e, 6f, 6e, 20, 41, 56, 43, 2d, 58, 33, 38, 30, 30, 48, c0, c, 1d, 38, 43, 41, 39, 36, 46, 33, 35, 31, 32, 36, 31, 40, 44, 65, 6e, 6f]

Thanks!

@keepsimple1

Copy link
Copy Markdown
Owner Author

Thanks for rebuilding with the PR branch. I decoded the packet from the Bad name dump:

0..11   00 00 84 00 00 00 00 0d 00 00 00 00   response, 13 answers, 0 questions
12..32  08 "_airplay" 04 "_tcp" 05 "local" 00  name: _airplay._tcp.local.
33..42  00 0c 00 01 00 00 11 94 00 13          PTR, IN, TTL 4500, RDLENGTH 19
43..61  10 "Denon AVC-X3800H" c0 0c            RDATA: Denon AVC-X3800H + pointer -> 12
62      1d                                     next owner name: a 29-byte label
63..91  "8CA96F351261@Denon AVC-X3800H"        (label runs to offset 91)

Line 43..61 is clean (c0 0c is a valid backward pointer). The failure is that a later name contains a pointer to offset 80, which is in the middle of the "Denon" label at the last line — a pointer that doesn't land on a label boundary.

The 169 at offset 125 / 150 at offset 148 errors are the other kind: pointers that point forward, which RFC 1035 section 4.1.4 forbids ("a pointer to a prior occurrence"). Note those offsets are identical to what the old build reported (169 ... 125), so it's the same reproducible packet.

I suspect it might be the reflector that re-constructs a new packet that coalesces records, and might not enforce RFC's backward only pointers.

To find out more, I have updated the PR diff to log the full packet when this error happens. Could you please do cargo update and try it again and collect the log?

And, If it's easy, a raw capture on the IoT VLAN as a cross-check, using tcpdump getting the raw packets. With the exact bytes we can confirm whether avahi is emitting the bad pointer.

Thanks again for the persistence here; the captures have been really useful.

@Phyks

Phyks commented Aug 20, 2026

Copy link
Copy Markdown

Hey!

Many thanks for looking into it!

I have captured the following errors:

[2026-08-20T16:42:03Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 150 at offset 148 must point backwards; raw packet (282 bytes): [00, 00, 84, 00, 00, 00, 00, 06, 00, 00, 00, 00, 03, 31, 30, 34, 01, 32, 02, 34, 32, 02, 31, 30, 07, 69, 6e, 2d, 61, 64, 64, 72, 04, 61, 72, 70, 61, 00, 00, 0c, 80, 01, 00, 00, 00, 78, 00, 14, 0c, 30, 30, 31, 37, 38, 38, 62, 30, 35, 61, 64, 30, 05, 6c, 6f, 63, 61, 6c, 00, 01, 30, 01, 44, 01, 41, 01, 35, 01, 30, 01, 42, 01, 45, 01, 46, 01, 46, 01, 46, 01, 38, 01, 38, 01, 37, 01, 31, 01, 32, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 38, 01, 45, 01, 46, 03, 69, 70, 36, c0, 20, 00, 2f, 80, 01, 00, 00, 00, 78, 00, 06, c0, 96, 00, 02, 00, 08, 01, 30, 01, 44, 01, 41, 01, 35, 01, 30, 01, 42, 01, 45, 01, 46, 01, 46, 01, 46, 01, 38, 01, 38, 01, 37, 01, 31, 01, 32, 01, 30, 01, 32, 01, 32, 01, 35, 01, 35, 01, 42, 01, 43, 01, 39, 01, 30, 01, 41, 01, 30, 01, 45, 01, 30, 01, 31, 01, 30, 01, 41, 01, 32, c0, 84, 00, 2f, 80, 01, 00, 00, 00, 78, 00, 06, c0, 44, 00, 02, 00, 08, c0, 0c, 00, 2f, 80, 01, 00, 00, 00, 78, 00, 06, c0, 0c, 00, 02, 00, 08, c0, 44, 00, 0c, 80, 01, 00, 00, 00, 78, 00, 02, c0, 30, c0, 9a, 00, 0c, 80, 01, 00, 00, 00, 78, 00, 02, c0, 30]
[2026-08-20T16:42:03Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 169 at offset 125 must point backwards; raw packet (269 bytes): [00, 00, 84, 00, 00, 00, 00, 08, 00, 00, 00, 00, 13, 48, 75, 65, 20, 42, 72, 69, 64, 67, 65, 20, 2d, 20, 42, 30, 35, 41, 44, 30, 04, 5f, 68, 75, 65, 04, 5f, 74, 63, 70, 05, 6c, 6f, 63, 61, 6c, 00, 00, 10, 80, 01, 00, 00, 11, 94, 00, 29, 19, 62, 72, 69, 64, 67, 65, 69, 64, 3d, 30, 30, 31, 37, 38, 38, 66, 66, 66, 65, 62, 30, 35, 61, 64, 30, 0e, 6d, 6f, 64, 65, 6c, 69, 64, 3d, 42, 53, 42, 30, 30, 32, 0c, 30, 30, 31, 37, 38, 38, 62, 30, 35, 61, 64, 30, c0, 2a, 00, 2f, 80, 01, 00, 00, 00, 78, 00, 08, c0, a9, 00, 04, 40, 00, 00, 08, c0, 0c, 00, 2f, 80, 01, 00, 00, 11, 94, 00, 09, c0, 0c, 00, 05, 00, 00, 80, 00, 40, c0, 64, 00, 1c, 80, 01, 00, 00, 00, 78, 00, 10, 2a, 01, 0e, 0a, 09, cb, 55, 22, 02, 17, 88, ff, fe, b0, 5a, d0, c0, 64, 00, 01, 80, 01, 00, 00, 00, 78, 00, 04, 0a, 2a, 02, 68, c0, 0c, 00, 21, 80, 01, 00, 00, 00, 78, 00, 08, 00, 00, 00, 00, 01, bb, c0, 64, c0, 20, 00, 0c, 00, 01, 00, 00, 11, 94, 00, 02, c0, 0c, 09, 5f, 73, 65, 72, 76, 69, 63, 65, 73, 07, 5f, 64, 6e, 73, 2d, 73, 64, 04, 5f, 75, 64, 70, c0, 2a, 00, 0c, 00, 01, 00, 00, 11, 94, 00, 02, c0, 20]
[2026-08-20T16:42:04Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 150 at offset 148 must point backwards; raw packet (282 bytes): [00, 00, 84, 00, 00, 00, 00, 06, 00, 00, 00, 00, 03, 31, 30, 34, 01, 32, 02, 34, 32, 02, 31, 30, 07, 69, 6e, 2d, 61, 64, 64, 72, 04, 61, 72, 70, 61, 00, 00, 0c, 80, 01, 00, 00, 00, 78, 00, 14, 0c, 30, 30, 31, 37, 38, 38, 62, 30, 35, 61, 64, 30, 05, 6c, 6f, 63, 61, 6c, 00, 01, 30, 01, 44, 01, 41, 01, 35, 01, 30, 01, 42, 01, 45, 01, 46, 01, 46, 01, 46, 01, 38, 01, 38, 01, 37, 01, 31, 01, 32, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 38, 01, 45, 01, 46, 03, 69, 70, 36, c0, 20, 00, 2f, 80, 01, 00, 00, 00, 78, 00, 06, c0, 96, 00, 02, 00, 08, 01, 30, 01, 44, 01, 41, 01, 35, 01, 30, 01, 42, 01, 45, 01, 46, 01, 46, 01, 46, 01, 38, 01, 38, 01, 37, 01, 31, 01, 32, 01, 30, 01, 32, 01, 32, 01, 35, 01, 35, 01, 42, 01, 43, 01, 39, 01, 30, 01, 41, 01, 30, 01, 45, 01, 30, 01, 31, 01, 30, 01, 41, 01, 32, c0, 84, 00, 2f, 80, 01, 00, 00, 00, 78, 00, 06, c0, 44, 00, 02, 00, 08, c0, 0c, 00, 2f, 80, 01, 00, 00, 00, 78, 00, 06, c0, 0c, 00, 02, 00, 08, c0, 44, 00, 0c, 80, 01, 00, 00, 00, 78, 00, 02, c0, 30, c0, 9a, 00, 0c, 80, 01, 00, 00, 00, 78, 00, 02, c0, 30]
[2026-08-20T16:42:04Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 169 at offset 125 must point backwards; raw packet (269 bytes): [00, 00, 84, 00, 00, 00, 00, 08, 00, 00, 00, 00, 13, 48, 75, 65, 20, 42, 72, 69, 64, 67, 65, 20, 2d, 20, 42, 30, 35, 41, 44, 30, 04, 5f, 68, 75, 65, 04, 5f, 74, 63, 70, 05, 6c, 6f, 63, 61, 6c, 00, 00, 10, 80, 01, 00, 00, 11, 94, 00, 29, 19, 62, 72, 69, 64, 67, 65, 69, 64, 3d, 30, 30, 31, 37, 38, 38, 66, 66, 66, 65, 62, 30, 35, 61, 64, 30, 0e, 6d, 6f, 64, 65, 6c, 69, 64, 3d, 42, 53, 42, 30, 30, 32, 0c, 30, 30, 31, 37, 38, 38, 62, 30, 35, 61, 64, 30, c0, 2a, 00, 2f, 80, 01, 00, 00, 00, 78, 00, 08, c0, a9, 00, 04, 40, 00, 00, 08, c0, 0c, 00, 2f, 80, 01, 00, 00, 11, 94, 00, 09, c0, 0c, 00, 05, 00, 00, 80, 00, 40, c0, 64, 00, 1c, 80, 01, 00, 00, 00, 78, 00, 10, 2a, 01, 0e, 0a, 09, cb, 55, 22, 02, 17, 88, ff, fe, b0, 5a, d0, c0, 64, 00, 01, 80, 01, 00, 00, 00, 78, 00, 04, 0a, 2a, 02, 68, c0, 0c, 00, 21, 80, 01, 00, 00, 00, 78, 00, 08, 00, 00, 00, 00, 01, bb, c0, 64, c0, 20, 00, 0c, 00, 01, 00, 00, 11, 94, 00, 02, c0, 0c, 09, 5f, 73, 65, 72, 76, 69, 63, 65, 73, 07, 5f, 64, 6e, 73, 2d, 73, 64, 04, 5f, 75, 64, 70, c0, 2a, 00, 0c, 00, 01, 00, 00, 11, 94, 00, 02, c0, 20]
[2026-08-20T16:42:06Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 169 at offset 125 must point backwards; raw packet (521 bytes): [00, 00, 84, 00, 00, 00, 00, 0e, 00, 00, 00, 00, 13, 48, 75, 65, 20, 42, 72, 69, 64, 67, 65, 20, 2d, 20, 42, 30, 35, 41, 44, 30, 04, 5f, 68, 75, 65, 04, 5f, 74, 63, 70, 05, 6c, 6f, 63, 61, 6c, 00, 00, 10, 80, 01, 00, 00, 11, 94, 00, 29, 19, 62, 72, 69, 64, 67, 65, 69, 64, 3d, 30, 30, 31, 37, 38, 38, 66, 66, 66, 65, 62, 30, 35, 61, 64, 30, 0e, 6d, 6f, 64, 65, 6c, 69, 64, 3d, 42, 53, 42, 30, 30, 32, 0c, 30, 30, 31, 37, 38, 38, 62, 30, 35, 61, 64, 30, c0, 2a, 00, 2f, 80, 01, 00, 00, 00, 78, 00, 08, c0, a9, 00, 04, 40, 00, 00, 08, 01, 30, 01, 44, 01, 41, 01, 35, 01, 30, 01, 42, 01, 45, 01, 46, 01, 46, 01, 46, 01, 38, 01, 38, 01, 37, 01, 31, 01, 32, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 38, 01, 45, 01, 46, 03, 69, 70, 36, 04, 61, 72, 70, 61, 00, 00, 2f, 80, 01, 00, 00, 00, 78, 00, 06, c1, 30, 00, 02, 00, 08, 01, 30, 01, 44, 01, 41, 01, 35, 01, 30, 01, 42, 01, 45, 01, 46, 01, 46, 01, 46, 01, 38, 01, 38, 01, 37, 01, 31, 01, 32, 01, 30, 01, 32, 01, 32, 01, 35, 01, 35, 01, 42, 01, 43, 01, 39, 01, 30, 01, 41, 01, 30, 01, 45, 01, 30, 01, 31, 01, 30, 01, 41, 01, 32, c0, c5, 00, 2f, 80, 01, 00, 00, 00, 78, 00, 06, c0, de, 00, 02, 00, 08, 03, 31, 30, 34, 01, 32, 02, 34, 32, 02, 31, 30, 07, 69, 6e, 2d, 61, 64, 64, 72, c0, c9, 00, 2f, 80, 01, 00, 00, 00, 78, 00, 06, c0, b8, 00, 02, 00, 08, c0, 0c, 00, 2f, 80, 01, 00, 00, 11, 94, 00, 09, c0, 0c, 00, 05, 00, 00, 80, 00, 40, c0, 64, 00, 1c, 80, 01, 00, 00, 00, 78, 00, 10, 2a, 01, 0e, 0a, 09, cb, 55, 22, 02, 17, 88, ff, fe, b0, 5a, d0, c0, 64, 00, 01, 80, 01, 00, 00, 00, 78, 00, 04, 0a, 2a, 02, 68, c0, 85, 00, 0c, 80, 01, 00, 00, 00, 78, 00, 02, c0, 64, c0, df, 00, 0c, 80, 01, 00, 00, 00, 78, 00, 02, c0, 64, c1, 31, 00, 0c, 80, 01, 00, 00, 00, 78, 00, 02, c0, 64, c0, 0c, 00, 21, 80, 01, 00, 00, 00, 78, 00, 08, 00, 00, 00, 00, 01, bb, c0, 64, c0, 20, 00, 0c, 00, 01, 00, 00, 11, 94, 00, 02, c0, 0c, 09, 5f, 73, 65, 72, 76, 69, 63, 65, 73, 07, 5f, 64, 6e, 73, 2d, 73, 64, 04, 5f, 75, 64, 70, c0, 2a, 00, 0c, 00, 01, 00, 00, 11, 94, 00, 02, c0, 20]
[2026-08-20T16:42:10Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 169 at offset 125 must point backwards; raw packet (521 bytes): [00, 00, 84, 00, 00, 00, 00, 0e, 00, 00, 00, 00, 13, 48, 75, 65, 20, 42, 72, 69, 64, 67, 65, 20, 2d, 20, 42, 30, 35, 41, 44, 30, 04, 5f, 68, 75, 65, 04, 5f, 74, 63, 70, 05, 6c, 6f, 63, 61, 6c, 00, 00, 10, 80, 01, 00, 00, 11, 94, 00, 29, 19, 62, 72, 69, 64, 67, 65, 69, 64, 3d, 30, 30, 31, 37, 38, 38, 66, 66, 66, 65, 62, 30, 35, 61, 64, 30, 0e, 6d, 6f, 64, 65, 6c, 69, 64, 3d, 42, 53, 42, 30, 30, 32, 0c, 30, 30, 31, 37, 38, 38, 62, 30, 35, 61, 64, 30, c0, 2a, 00, 2f, 80, 01, 00, 00, 00, 78, 00, 08, c0, a9, 00, 04, 40, 00, 00, 08, 01, 30, 01, 44, 01, 41, 01, 35, 01, 30, 01, 42, 01, 45, 01, 46, 01, 46, 01, 46, 01, 38, 01, 38, 01, 37, 01, 31, 01, 32, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 30, 01, 38, 01, 45, 01, 46, 03, 69, 70, 36, 04, 61, 72, 70, 61, 00, 00, 2f, 80, 01, 00, 00, 00, 78, 00, 06, c1, 30, 00, 02, 00, 08, 01, 30, 01, 44, 01, 41, 01, 35, 01, 30, 01, 42, 01, 45, 01, 46, 01, 46, 01, 46, 01, 38, 01, 38, 01, 37, 01, 31, 01, 32, 01, 30, 01, 32, 01, 32, 01, 35, 01, 35, 01, 42, 01, 43, 01, 39, 01, 30, 01, 41, 01, 30, 01, 45, 01, 30, 01, 31, 01, 30, 01, 41, 01, 32, c0, c5, 00, 2f, 80, 01, 00, 00, 00, 78, 00, 06, c0, de, 00, 02, 00, 08, 03, 31, 30, 34, 01, 32, 02, 34, 32, 02, 31, 30, 07, 69, 6e, 2d, 61, 64, 64, 72, c0, c9, 00, 2f, 80, 01, 00, 00, 00, 78, 00, 06, c0, b8, 00, 02, 00, 08, c0, 0c, 00, 2f, 80, 01, 00, 00, 11, 94, 00, 09, c0, 0c, 00, 05, 00, 00, 80, 00, 40, c0, 64, 00, 1c, 80, 01, 00, 00, 00, 78, 00, 10, 2a, 01, 0e, 0a, 09, cb, 55, 22, 02, 17, 88, ff, fe, b0, 5a, d0, c0, 64, 00, 01, 80, 01, 00, 00, 00, 78, 00, 04, 0a, 2a, 02, 68, c0, 85, 00, 0c, 80, 01, 00, 00, 00, 78, 00, 02, c0, 64, c0, df, 00, 0c, 80, 01, 00, 00, 00, 78, 00, 02, c0, 64, c1, 31, 00, 0c, 80, 01, 00, 00, 00, 78, 00, 02, c0, 64, c0, 0c, 00, 21, 80, 01, 00, 00, 00, 78, 00, 08, 00, 00, 00, 00, 01, bb, c0, 64, c0, 20, 00, 0c, 00, 01, 00, 00, 11, 94, 00, 02, c0, 0c, 09, 5f, 73, 65, 72, 76, 69, 63, 65, 73, 07, 5f, 64, 6e, 73, 2d, 73, 64, 04, 5f, 75, 64, 70, c0, 2a, 00, 0c, 00, 01, 00, 00, 11, 94, 00, 02, c0, 20] 

I missed the tcpdump for these, but I have the following one with tcpdump attached:

[2026-08-20T16:50:55Z DEBUG mdns_sd::service_daemon] Invalid incoming DNS message: Invalid name compression: pointer 121 at offset 121 must point backwards; raw packet (193 bytes): [00, 00, 84, 00, 00, 00, 00, 05, 00, 00, 00, 00, 05, 5f, 6d, 69, 69, 6f, 04, 5f, 75, 64, 70, 05, 6c, 6f, 63, 61, 6c, 00, 00, 0c, 00, 01, 00, 00, 00, 78, 00, 24, 21, 64, 72, 65, 61, 6d, 65, 2d, 76, 61, 63, 75, 75, 6d, 2d, 70, 32, 30, 32, 39, 5f, 6d, 69, 69, 6f, 34, 34, 37, 33, 30, 35, 32, 34, 37, c0, 0c, 21, 64, 72, 65, 61, 6d, 65, 2d, 76, 61, 63, 75, 75, 6d, 2d, 70, 32, 30, 32, 39, 5f, 6d, 69, 69, 6f, 34, 34, 37, 33, 30, 35, 32, 34, 37, 00, 00, 2f, 80, 01, 00, 00, 00, 78, 00, 09, c0, 79, 00, 05, 40, 00, 00, 00, 00, c0, 4c, 00, 01, 80, 01, 00, 00, 00, 78, 00, 04, 0a, 2a, 02, 32, c0, 28, 00, 21, 80, 01, 00, 00, 00, 78, 00, 08, 00, 00, 00, 00, d4, 31, c0, 4c, c0, 28, 00, 10, 80, 01, 00, 00, 00, 78, 00, 0f, 0e, 70, 61, 74, 68, 3d, 2f, 6d, 79, 64, 65, 76, 69, 63, 65]

and tcpdump:

   10.42.4.1.5353 > 224.0.0.251.5353: [udp sum ok] 0*- [0q] 5/0/0 _miio._udp.local. PTR dreame-vacuum-p2029_miio447305247._miio._udp.local., dreame-vacuum-p2029_miio447305247. (Cache flush) NSEC, dreame-vacuum-p2029_miio447305247. (Cache flush) A 10.42.2.50, dreame-vacuum-p2029_miio447305247._miio._udp.local. (Cache flush) SRV dreame-vacuum-p2029_miio447305247.:54321 0 0, dreame-vacuum-p2029_miio447305247._miio._udp.local. (Cache flush) TXT "path=/mydevice" (193)

@keepsimple1

Copy link
Copy Markdown
Owner Author

@Phyks thanks for your test data! It's very helpful. It shows the NSEC records in the packet was malformed (bad compression pointer). To handle such packets, I've updated the diff to skip malformed records while still keep the rest of the packet decoded.

Can you help try out the updated diff and see if that works for you? Thanks!

@Phyks

Phyks commented Aug 21, 2026

Copy link
Copy Markdown

Thanks a lot! I've successfully rebuilt and deployed. The issue was happening no matter the actual use case (netmuxd, iPhone backup) as it was caused by the relay of mdns packets. I can notice now that a lot of packets are dropped, typically:

[2026-08-21T17:40:23Z DEBUG mdns_sd::dns_parser] skipping record '001788b05ad0.local.' (type 47) with invalid RDATA: Invalid name compression: pointer 169 at offset 125 must point backwards

It's slightly unclear to me whether ALL packets are dropped (therefore, not really enabling mdns features) or whether only a fraction of them are blocked. Also, I won't be able to test the real use case involving netmuxd and an iPhone before next week. I'll report back ASAP.

Also, another question, if this is stemming from avahi not conforming to the RFC, would it make sense to report it somewhere upstream? (I must confess I know very little about the mdns RFC and specs, and am quite surprised that Avahi would not honor it)

@keepsimple1

keepsimple1 commented Aug 22, 2026

Copy link
Copy Markdown
Owner Author

It's slightly unclear to me whether ALL packets are dropped (therefore, not really enabling mdns features) or whether only a fraction of them are blocked.

Not whole packets. The drop (skip) is per record (only NSEC record in this case). Other records (PTR/SRV/A/AAAA records) in the same packet should be processed and it shouldn't stop the mDNS from working. Let me know if that works in a real use case when you get chance.

The main fix is making mdns-sd resilient to malformed records, and not to drop whole packets.

Also, another question, if this is stemming from avahi not conforming to the RFC, would it make sense to report it somewhere upstream?

I don't think it's a RFC conforming issue. As NSEC is not very commonly used in mDNS, I'm not surprised if there is a bug in handling (copying?) NSEC RDATA that has name compression, especially acting as a repeater.

I think reporting to avahi is reasonable, and to make it airtight, the definitive evidence is a before/after capture: the same device's NSEC announcement on its own VLAN (these devices are on 10.42.2.x, e.g. the Dreame at 10.42.2.50) with a valid next-domain pointer, vs. the reflected copy on the mdns-sd VLAN (10.42.4.x) with the broken one. That proves avahi mangles it rather than the device shipping it broken. Without that, avahi could reasonably say "the device sent it that way."

@Phyks

Phyks commented Aug 27, 2026

Copy link
Copy Markdown

Hi,

So I got a chance to test with real devices and it is not working so far. I'll make a proper tcpdump capture to further audit it.

I get this kind of errors:

[2026-08-27T16:38:27Z DEBUG mdns_sd::dns_parser] skipping record '001788b05ad0.local.' (type 47) with invalid RDATA: Invalid name compression: pointer 169 at offset 125 must point backwards
[2026-08-27T16:38:27Z DEBUG mdns_sd::dns_parser] skipping record '0.D.A.5.0.B.E.F.F.F.8.8.7.1.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.E.F.ip6.arpa.' (type 47) with invalid RDATA: Invalid name compression: pointer 304 at offset 217 must point backwards
[2026-08-27T16:38:27Z DEBUG mdns_sd::dns_parser] skipping record '104.2.42.10.in-addr.arpa.' (type 47) with invalid RDATA: read_labels: from_utf8: invalid utf-8 sequence of 1 bytes from index 24

Meanwhile, is there an easy way to have the positive dump of devices, that is the list of devices properly parsed by mdns-sd? The log in debug level would only show the negative one (ie devices that have incorrect fields and resulting in errors).

Thanks!

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.

2 participants