RX: ignore all local 127/8 IFF_LOOPBACK interfaces

Currently RX lists all non-127.0.0.1 interfaces in the interface list,
even those that are specified as IFF_LOOPBACK, to accomodate certain
special cases where IFF_LOOPBACK interfaces should be advertised.
However, this makes us advertise e.g. a 127.0.0.2 lo interface. So
instead, skip all interfaces that are both in 127/8 and claim they are
IFF_LOOPBACK, as this will skip a stray 127.0.0.2, but should not
confuse the special cases.

Change-Id: I60a4ed5330252078e2f58894195f9b68ec70dcfa
Reviewed-on: http://gerrit.openafs.org/2376
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
Andrew Deason 2010-07-08 15:59:58 -05:00 committed by Derrick Brashear
parent 4b7d224d17
commit 1d8bb99db9

View File

@ -139,6 +139,18 @@ rt_xaddrs(caddr_t cp, caddr_t cplim, struct rt_addrinfo *rtinfo)
}
#endif
static_inline int
rxi_IsLoopbackIface(struct sockaddr_in *a, unsigned long flags)
{
afs_uint32 addr = ntohl(a->sin_addr.s_addr);
if (rx_IsLoopbackAddr(addr)) {
return 1;
}
if ((flags & IFF_LOOPBACK) && ((addr & 0xff000000) == 0x7f000000)) {
return 1;
}
return 0;
}
/* this function returns the total number of interface addresses
** the buffer has to be passed in by the caller
@ -240,7 +252,7 @@ rx_getAllAddr_internal(afs_uint32 buffer[], int maxSize, int loopbacks)
if (count >= maxSize) /* no more space */
dpf(("Too many interfaces..ignoring 0x%x\n",
a->sin_addr.s_addr));
else if (!loopbacks && rx_IsLoopbackAddr(ntohl(a->sin_addr.s_addr))) {
else if (!loopbacks && rxi_IsLoopbackIface(a, ifm->ifm_flags)) {
addrcount--;
continue; /* skip loopback address as well. */
} else if (loopbacks && ifm->ifm_flags & IFF_LOOPBACK) {
@ -430,7 +442,7 @@ rx_getAllAddr_internal(afs_uint32 buffer[], int maxSize, int loopbacks)
}
if (a->sin_addr.s_addr != 0) {
if (!loopbacks) {
if (rx_IsLoopbackAddr(ntohl(a->sin_addr.s_addr)))
if (rxi_IsLoopbackIface(a, ifr->ifr_flags))
continue; /* skip loopback address as well. */
} else {
if (ifr->ifr_flags & IFF_LOOPBACK)