diff options
author | wpaul <wpaul@FreeBSD.org> | 1997-06-20 17:54:11 +0000 |
---|---|---|
committer | wpaul <wpaul@FreeBSD.org> | 1997-06-20 17:54:11 +0000 |
commit | 24968494546dd7b4544d322f1ff342fed30205e6 (patch) | |
tree | bb9829cc7c7296297e91426655447bc5b8aff487 /lib | |
parent | 50bef408d8bc90fe72fac702e6f286e90a29c896 (diff) | |
download | FreeBSD-src-24968494546dd7b4544d322f1ff342fed30205e6.zip FreeBSD-src-24968494546dd7b4544d322f1ff342fed30205e6.tar.gz |
Hm... wonder how long this has been here.
The logic in get_myaddress() is broken: it always returns the loopback
address due to the following rule:
if ((ifreq.ifr_flags & IFF_UP) &&
ifr->ifr_addr.sa_family == AF_INET &&
(loopback == 1 && (ifreq.ifr_flags & IFF_LOOPBACK))) {
The idea is that we want to select the interface address only if it's
up and it's in the AF_INET family. If it turns uout we don't have
such an interface available, we make a second pass through the loop,
this time settling for the loopback interface. But the logic inadvertently
locks out all cases when loopback == 0, so nothing is ever selected until
the second pass (when loopback == 1).
This is changed to:
if (((ifreq.ifr_flags & IFF_UP) &&
ifr->ifr_addr.sa_family == AF_INET) ||
(loopback == 1 && (ifreq.ifr_flags & IFF_LOOPBACK))) {
which I think does the right thing.
This is yet another bogon I discovered during NIS+ testing; I need
get_myaddress() to work correctly so that the callback code in the
client library will work.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/rpc/get_myaddress.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libc/rpc/get_myaddress.c b/lib/libc/rpc/get_myaddress.c index f8bfa7c..a96b84b 100644 --- a/lib/libc/rpc/get_myaddress.c +++ b/lib/libc/rpc/get_myaddress.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)get_myaddress.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: get_myaddress.c,v 1.6 1996/12/30 14:26:28 peter Exp $"; +static char *rcsid = "$Id: get_myaddress.c,v 1.11 1997/05/28 05:05:11 wpaul Exp $"; #endif /* @@ -86,8 +86,8 @@ again: close(s); return(-1); } - if ((ifreq.ifr_flags & IFF_UP) && - ifr->ifr_addr.sa_family == AF_INET && + if (((ifreq.ifr_flags & IFF_UP) && + ifr->ifr_addr.sa_family == AF_INET) || (loopback == 1 && (ifreq.ifr_flags & IFF_LOOPBACK))) { *addr = *((struct sockaddr_in *)&ifr->ifr_addr); addr->sin_port = htons(PMAPPORT); |