From 1d8bb99db9ae66554760a5927268631916be5adf Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 8 Jul 2010 15:59:58 -0500 Subject: [PATCH] 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 Tested-by: Derrick Brashear --- src/rx/rx_getaddr.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/rx/rx_getaddr.c b/src/rx/rx_getaddr.c index b917f8e..ea8fa59 100644 --- a/src/rx/rx_getaddr.c +++ b/src/rx/rx_getaddr.c @@ -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) -- 1.9.4