troglobit / mdnsd

Jeremie Miller's original mdnsd
BSD 3-Clause "New" or "Revised" License
55 stars 35 forks source link

Why is IP_PKTINFO set? #67

Closed fzs closed 1 year ago

fzs commented 1 year ago

At some point the socket option IP_PKTINFO was getting set on the server's socket. I found no explanation for this. Since the code doesn't even use sendmsg or recvmsg, can this be removed?

https://github.com/troglobit/mdnsd/blob/5fb29c76cb8a310f3f9bfdf16ce5bcbe1e40ca7e/src/mdnsd.c#L245

troglobit commented 1 year ago

It's probably a remnant from when I tried out various methods for the multiple-interface support. I had this idea to use a single socket and the IP_PKTINFO to fish out the ingressing interface.

So yes, I believe we can remove it. You're more than welcome to submit a PR.

fzs commented 1 year ago

I will have to do a bit of cleanup when adding IPv6 multicast sockets.

fzs commented 1 year ago

The function does a lot more than it used to way back, setting values explicitly where before the default was kept. Examples are multicast loop and all. Is this on purpose to make sure to override defaults on different systems with consistent values?

troglobit commented 1 year ago

Yes. The others are quite well hashed out over the years in other daemon's I maintain that do multicast on multiple interfaces.

troglobit commented 1 year ago

You can have a look at SMCRoute and pim6sd for inspiration, and perhaps some help, when going through the socket setup. Both support IPv6.