The legacy ioctls, SIOCGIFADDR, SIOCGIFBRDADDR, SIOCGIFDSTADDR,
SIOCGIFNETMASK should return first address instead of testing against
the address passed in.
Details
Run 'mdnsd --debug' from net/mDNSresponder.
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
Hi Xin,
Can you please explain what problem you were hitting that you'r trying to fix with this patch?
On -CURRENT, the 'mdnsd' will stop right after it starts. With ktrace it shows shows:
1005 mdnsd CALL ioctl(0x6,SIOCGIFNETMASK,0x7fffffffea40) 1005 mdnsd RET ioctl 0 1005 mdnsd CALL ioctl(0x6,SIOCGIFBRDADDR,0x7fffffffea40) 1005 mdnsd RET ioctl -1 errno 49 Can't assign requested address
Older versions of FreeBSD would return successfully. The usage in mdnsd can be found here (they should probably zero the ifreq structure before calling):
https://opensource.apple.com/source/mDNSResponder/mDNSResponder-544/mDNSPosix/mDNSUNP.c
URL: http://svnweb.freebsd.org/changeset/base/257737
Log:
Fix my braino in r257692. For SIOCG*ADDR we don't need exact match on specified address, actually in most cases the address isn't specified.
This looks like the relevant rev which broke it for you. As per my limited knowledge, the commit log says "For SIOCG*ADDR" but that change was only made for SIOCGIFADDR.
in that regard, your changes look good to me.
Here you simply overwrite anything that user has supplied into INADDR_ANY. I will not be surprised if that would break a lot (albeit fixing mDNS).
Updated patch: this reverts the code to previous behavior: match if possible, and
first if not found, finally if nothing found give error.
Updating D667: Return first address for legacy ioctls SIOCGIFBRDADDR, SIOCGIFDSTADDR,
SIOCGIFNETMASK and SIOCGIFADDR.
Good point. I have re-read the code in FreeBSD stable/5 and stable/10 and now have a different patch, can you review it and see if this one would address compatibility concerns?
I think I do need that check: the previous check is on the request (so that jailed process can not use these ioctls to determine if the host system have an IP address). The new check is to prevent jailed process to know the first IP address...
Gleb's version of patch.
Updating D667: Return first address for legacy ioctls SIOCGIFBRDADDR, SIOCGIFDSTADDR,
SIOCGIFNETMASK and SIOCGIFADDR.
Gleb have found another issue that the existing code would return first IP if INADDR_ANY is specified. This would also be a subtle issue when jail is used.
I think this version is good to go.