Page MenuHomeFreeBSD

Allow host name addresses to be set in mountd -h flag
ClosedPublic

Authored by rstone on Jan 12 2015, 9:47 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 26, 9:36 AM
Unknown Object (File)
Wed, Apr 17, 7:14 PM
Unknown Object (File)
Wed, Apr 17, 7:07 PM
Unknown Object (File)
Wed, Apr 17, 7:05 PM
Unknown Object (File)
Tue, Apr 16, 4:22 PM
Unknown Object (File)
Mar 24 2024, 9:54 PM
Unknown Object (File)
Mar 15 2024, 10:53 PM
Unknown Object (File)
Mar 12 2024, 3:39 AM
Subscribers

Details

Reviewers
rstone
Summary

When mountd is creating sockets, it iterates over all addresses specified
in the "hosts" array and eventually looks up the network address with
getaddrinfo. At one point it checks for a numeric address and if it
sees one, it sets a hint parameter to force getaddrinfo to interpret the
host as a numeric address. However that hint is not cleared for subsequent
iterations of the loop and if any hosts seen after this point are host names,
getaddrinfo will fail on the name.

Unfortunately, the first iteration will either process ::1 or 127.0.0.1,
so the flag is set on the first iteration and all host names will fail
to be processed.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

rstone retitled this revision from to Allow host name addresses to be set in mountd -h flag.
rstone updated this object.
rstone edited the test plan for this revision. (Show Details)

Patch looks fine to me. I introduced this bug in r222623 when I "fixed" the code
from:

hints,ai_flags &= AI_NUMERICHOST;

to:

hints.ai_flags |= AI_NUMERICHOST;

(I still believe my fix was correct, since I can't see why clearing the bit would
make any sense at that place in the code.)
However, I believe you are correct that hints.ai_flags should be reset to AI_PASSIVE
in the loop.

The same fix is needed in:
usr.sbin/rpc.lockd/lockd.c at about line#360
and
usr.sbin/rpc.statd/statd.c at about line#540
since they got related commits with the same "fix".

Apply same fix to rpc.statd and rpc.lockd

rstone added a reviewer: rstone.

I did a quick sanity check in a vm. lockd and statd were affected by the same problem, so I applied the fix to them to. Thanks for catching this.

With the fix applied they all open sockets to the right IP:

ps axwww | egrep 'mountd|rpc\.'

520 - Is 0:00.01 /usr/sbin/mountd -r -h mountd-hostname
524 - Ss 0:00.00 /usr/sbin/rpc.statd -h mountd-hostname
527 - Ss 0:00.00 /usr/sbin/rpc.lockd -h mountd-hostname
660 u0 S+ 0:00.00 egrep mountd|rpc\\.

sockstat | egrep 'mountd|rpc\.'

root rpc.lockd 527 4 dgram -> /var/run/logpriv
root rpc.statd 524 4 udp6 ::1:929 *:*
root rpc.statd 524 5 tcp6 ::1:929 *:*
root rpc.statd 524 6 dgram -> /var/run/logpriv
root rpc.statd 524 7 udp4 127.0.0.1:929 *:*
root rpc.statd 524 8 udp4 172.16.2.124:929 *:*
root rpc.statd 524 9 tcp4 127.0.0.1:929 *:*
root rpc.statd 524 10 tcp4 172.16.2.124:929 *:*
root mountd 520 5 udp6 ::1:933 *:*
root mountd 520 6 tcp6 ::1:933 *:*
root mountd 520 7 dgram -> /var/run/logpriv
root mountd 520 8 udp4 127.0.0.1:933 *:*
root mountd 520 9 udp4 172.16.2.124:933 *:*
root mountd 520 10 tcp4 127.0.0.1:933 *:*
root mountd 520 11 tcp4 172.16.2.124:933 *:*

This revision is now accepted and ready to land.Jan 18 2015, 8:40 PM