analogdevicesinc/libiio

DNS-SD PTR record ill formed on Pluto...

rgetz opened this issue · 1 comments

rgetz commented

In iiod, we wait until host name is accessible (in a background thread), I thought that would mean that networking/dbus is ready, and then eventually start avahi
https://github.com/analogdevicesinc/libiio/blob/main/iiod/dns-sd.c#L257-L288

However - it looks like this doesn't actually work robustly. PTR records don't include the name like they are supposed to.

rgetz@brain:~/github/libiio/deps/mdns$  avahi-discover
...
Found service 'iiod on (none)' of type '_iio._tcp' in domain 'local' on 68.0.
Found service 'iiod on analog' of type '_iio._tcp' in domain 'local' on 2.1.
...

the (none) is wrong, it should be the hostname (just like it is from the zedboard - which is named analog).

We can see that it's also a problem in mdns (meaning it's not the client side).

rgetz@brain:~/github/libiio/deps/mdns$ gcc -o mdns mdns.c
rgetz@brain:~/github/libiio/deps/mdns$ ./mdns --query _iio._tcp.local.
...
192.168.2.1:5353 : answer _iio._tcp.local. PTR "iiod on (none)._iio._tcp.local." rclass 0x1 ttl 10 length 17
192.168.1.120:5353 : answer _iio._tcp.local. PTR "iiod on analog._iio._tcp.local." rclass 0x1 ttl 10 length 17
...

according to wireshark, that is what the Pluto Avahi is transmitting...

No.	Time	Source	Destination	Protocol	Length	Info
2	0.000720776	192.168.2.1	192.168.2.10	MDNS	159	Standard query response 0x0000 PTR _iio._tcp.local, "QU" question PTR iiod on (none)._iio._tcp.local TXT SRV 0 0 30431 pluto.local A 192.168.2.1

0000   00 e0 22 6a 6a 3c 00 05 f7 10 1f e3 08 00 45 00   .."jj<........E.
0010   00 91 7a 6b 40 00 ff 11 7b 94 c0 a8 02 01 c0 a8   ..zk@...{.......
0020   02 0a 14 e9 cb 93 00 7d ad bf 00 00 84 00 00 01   .......}........
0030   00 04 00 00 00 00 04 5f 69 69 6f 04 5f 74 63 70   ......._iio._tcp
0040   05 6c 6f 63 61 6c 00 00 0c 80 01 c0 0c 00 0c 00   .local..........
0050   01 00 00 00 0a 00 11 0e 69 69 6f 64 20 6f 6e 20   ........iiod on 
0060   28 6e 6f 6e 65 29 c0 0c c0 2d 00 10 00 01 00 00   (none)...-......
0070   00 0a 00 01 00 c0 2d 00 21 00 01 00 00 00 0a 00   ......-.!.......
0080   0e 00 00 00 00 76 df 05 70 6c 75 74 6f c0 16 c0   .....v..pluto...
0090   5d 00 01 00 01 00 00 00 0a 00 04 c0 a8 02 01      ]..............

Meaning the problem is in the code that I pointed to (I think) - since in Kuiper (where things start later) it works fine...

-Robin

rgetz commented

with the fix in #1080 - things seems to be working:

rgetz@brain:~/github/libiio/deps/mdns$  avahi-discover
...
Found service 'iiod on pluto' of type '_iio._tcp' in domain 'local' on 81.0.

and

rgetz@brain:~/github/libiio/deps/mdns$ ./mdns --query _iio._tcp.local.
...
192.168.2.1:5353 : answer _iio._tcp.local. PTR "iiod on pluto._iio._tcp.local." rclass 0x1 ttl 10 length 16
192.168.2.1:5353 : answer iiod on pluto._iio._tcp.local. SRV pluto.local. priority 0 weight 0 port 30431
192.168.2.1:5353 : answer pluto.local. A 192.168.2.1

when things get merged - I will close.