-
Notifications
You must be signed in to change notification settings - Fork 27
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
IPv6 MDNS #35
IPv6 MDNS #35
Conversation
- Multiple addresses per interface (no effect) - Get address changes from route socket - remove all kif_* functions - use getifaddrs to get all addresses for an interface - Define udp4/udp6 structures for MDNS FD and events
mdnsd/kiface.c
Outdated
#ifdef __FreeBSD__ | ||
#define rtm_hdrlen rtm_msglen | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this is wrong -- on OpenBSD rtm_hdrlen is documented as being
u_short rtm_hdrlen; /* sizeof(rt_msghdr) to skip over the header */
while rtm_msglen on both FreeBSD and OpenBSD is documented as being
u_short rtm_msglen; /* to skip over non-understood messages */
so at kiface.c:150
sa = (struct sockaddr *)(buf + rtm->rtm_hdrlen);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
you'll be skipping the whole message rather than just the header of the message.
Yup, my patch does the wrong thing, and should be doing sizeof(&rtm) instead to accomplish the same effect.
…On November 30, 2019 4:14:46 PM PST, Nick Briggs ***@***.***> wrote:
nbriggs commented on this pull request.
> +#ifdef __FreeBSD__
+#define rtm_hdrlen rtm_msglen
+#endif
I suspect this is wrong -- on OpenBSD rtm_hdrlen is documented as being
```
u_short rtm_hdrlen; /* sizeof(rt_msghdr) to skip over the header */
```
while rtm_msglen on both FreeBSD and OpenBSD is documented as being
```
u_short rtm_msglen; /* to skip over non-understood messages */
```
so at kiface.c:150
```
sa = (struct sockaddr *)(buf + rtm->rtm_hdrlen);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
```
you'll be skipping the whole message rather than just the header of the
message.
--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#35 (review)
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
But even with that correction, it still takes a segmentation fault (on FreeBSD) if you add or delete an address on the interface that mdnsd is monitoring. |
The documentation for FreeBSD route(4) says
So while you can walk the messages by the |
mdnsd/kiface.c
Outdated
@@ -275,6 +141,9 @@ kev_dispatch_msg(int fd, short event, void *bula) | |||
if (iface == NULL) /* this interface isn't configured */ | |||
continue; | |||
|
|||
sa = (struct sockaddr *)(buf + rtm->rtm_hdrlen); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are actually multiple messages in buf
, presumably this should be next + rtm->rtm_hdrlen
or you're going to pick up the wrong socket addresses from the 2nd and subsequent messages.
In OpenBSD, |
No SIGSEGVs now. It does get a bit confused if you delete the only IPv4 address off the interface it's listening on -- a situation that wouldn't have made sense before IPv6 support. |
void | ||
kev_init(void) | ||
{ | ||
int opt = 0, rcvbuf, default_rcvbuf; | ||
int rtfilter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're going to #ifdef __OpenBSD__
the rtfilter = ...
perhaps you could #ifdef
the declaration for rtfilter
.
I've added some patches to tone-down the warnings from lack of IPv4 addresses. Still working on a patches to respond to remote DNS queries with all IP addresses and update the cache when changes occur to local interfaces. |
If there are packets going out on multiple interfaces while operating on MDNS IPV4/6, interfaces should not be expected to be dual-stack. IPv6 only requires an index, and doesn't seem to have any problems if there are no IPv6 addresses on the interface. IPv4 requires an address on the interface to do any multicast operations.
@@ -448,6 +473,10 @@ parse_flags(const char *word, int *flags) | |||
*flags |= F_A; | |||
r++; | |||
break; | |||
case '6': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The usage info for the "lookup" subcommand wasn't updated to include the new "6" flag.
I just realized that bug #31 will more easily trigger with this PR, since more addresses are added to the fixed-size array. I'll have to add a fix for that here. |
Adds a check when adding addresses in pge_initprimary to prevent writing to unallocated memory and causing the program to segfault. Fixes #31, but this code should be refactored in the future.
New feature or bug is that responses will contain both A and AAAA without regard for the request specifier for A or AAAA. I need to read the spec more.
Send the correct AF for the RR type and enumerate all interfaces for addresses.
DNS responses from the daemon now send all addresses from all interfaces and can respond to mdnsctl with the appropriate address from any interface (eg. em0 being IPv6 only and bridge0 being IPv4 only). I've tested out the MDNS packet changes with The only other things I can think to commit are style, grammar, and comment changes before rebasing everything for merging. |
This PR is split into 3 commits, but they may not be entirely distinct. It basically goes like this:
I've kept my FreeBSD patch in here as well, since I tested this with FreeBSD-current as well as OpenBSD-current.
Samples
Lookup of IPv6 addresses from
mdnsctl
mdnsd
advertisiment appearing onmdns-sd
from another system.tutti.local
is runningmdnsd
with these patches.Issues
pkt_handle_qst
to respond with multiple A and/or AAAA records.Fixes #4
Cheers!