From 7a8ec4f7ff2dea03c98fba486a0b2d2cfb854d0e Mon Sep 17 00:00:00 2001 From: guido Date: Sun, 17 Mar 1996 20:12:53 +0000 Subject: Work around a bug in the Sun rpc code. This fixes a problem where a machine with aliase ip addresses on the same subnet of an interfaces' `real' ip addresses would generate duplicate broadcasts in clnt_broadcast(). Basically, this fix does a purge on the list of bradcast addresses. --- lib/libc/rpc/pmap_rmt.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'lib/libc/rpc/pmap_rmt.c') diff --git a/lib/libc/rpc/pmap_rmt.c b/lib/libc/rpc/pmap_rmt.c index 8511206..4b907ab 100644 --- a/lib/libc/rpc/pmap_rmt.c +++ b/lib/libc/rpc/pmap_rmt.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)pmap_rmt.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: pmap_rmt.c,v 1.3 1995/10/22 14:51:32 phk Exp $"; +static char *rcsid = "$Id: pmap_rmt.c,v 1.4 1995/12/07 12:50:55 bde Exp $"; #endif /* @@ -171,6 +171,7 @@ getbroadcastnets(addrs, sock, buf) struct ifconf ifc; struct ifreq ifreq, *ifr; struct sockaddr_in *sin; + struct in_addr addr; char *cp, *cplim; int n, i = 0; @@ -198,17 +199,24 @@ getbroadcastnets(addrs, sock, buf) sin = (struct sockaddr_in *)&ifr->ifr_addr; #ifdef SIOCGIFBRDADDR /* 4.3BSD */ if (ioctl(sock, SIOCGIFBRDADDR, (char *)&ifreq) < 0) { - addrs[i++] = + addr = inet_makeaddr(inet_netof(sin->sin_addr), INADDR_ANY); } else { - addrs[i++] = ((struct sockaddr_in*) + addr = ((struct sockaddr_in*) &ifreq.ifr_addr)->sin_addr; } #else /* 4.2 BSD */ - addrs[i++] = inet_makeaddr(inet_netof(sin->sin_addr), + addr = inet_makeaddr(inet_netof(sin->sin_addr), INADDR_ANY); #endif + for (n=i-1; n>=0; n--) { + if (addr.s_addr == addrs[n].s_addr) + break; + } + if (n<0) { + addrs[i++] = addr; + } } } return (i); -- cgit v1.1