diff options
Diffstat (limited to 'sbin/routed/if.c')
-rw-r--r-- | sbin/routed/if.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/sbin/routed/if.c b/sbin/routed/if.c index c72c10ed4804..2c8395e9a667 100644 --- a/sbin/routed/if.c +++ b/sbin/routed/if.c @@ -34,13 +34,14 @@ #include "defs.h" #include "pathnames.h" -#if !defined(sgi) && !defined(__NetBSD__) -static char sccsid[] __attribute__((unused)) = "@(#)if.c 8.1 (Berkeley) 6/5/93"; -#elif defined(__NetBSD__) -#include <sys/cdefs.h> +#ifdef __NetBSD__ __RCSID("$NetBSD$"); +#elif defined(__FreeBSD__) +__RCSID("$FreeBSD$"); +#else +__RCSID("$Revision: 2.27 $"); +#ident "$Revision: 2.27 $" #endif -#ident "$Revision: 2.22 $" struct interface *ifnet; /* all interfaces */ @@ -212,14 +213,14 @@ ifwithname(char *name, /* "ec0" or whatever */ struct interface * -ifwithindex(u_short index, +ifwithindex(u_short ifindex, int rescan_ok) { struct interface *ifp; for (;;) { for (ifp = ifnet; 0 != ifp; ifp = ifp->int_next) { - if (ifp->int_index == index) + if (ifp->int_index == ifindex) return ifp; } @@ -242,6 +243,7 @@ struct interface * iflookup(naddr addr) { struct interface *ifp, *maybe; + int once = 0; maybe = 0; for (;;) { @@ -265,9 +267,9 @@ iflookup(naddr addr) } } - if (maybe != 0 - || IF_RESCAN_DELAY()) + if (maybe != 0 || once || IF_RESCAN_DELAY()) return maybe; + once = 1; /* If there is no known interface, maybe there is a * new interface. So just once look for new interfaces. @@ -404,7 +406,8 @@ check_dup(naddr addr, /* IP address, so network byte order */ /* The local address can only be shared with a point-to-point * link. */ - if (ifp->int_addr == addr + if ((!(ifp->int_state & IS_REMOTE) || !(if_flags & IS_REMOTE)) + && ifp->int_addr == addr && (((if_flags|ifp->int_if_flags) & IFF_POINTOPOINT) == 0)) return ifp; @@ -496,10 +499,14 @@ ifdel(struct interface *ifp) #endif && rip_sock >= 0) { m.imr_multiaddr.s_addr = htonl(INADDR_RIP_GROUP); +#ifdef MCAST_IFINDEX + m.imr_interface.s_addr = htonl(ifp->int_index); +#else m.imr_interface.s_addr = ((ifp->int_if_flags & IFF_POINTOPOINT) ? ifp->int_dstaddr : ifp->int_addr); +#endif if (setsockopt(rip_sock,IPPROTO_IP,IP_DROP_MEMBERSHIP, &m, sizeof(m)) < 0 && errno != EADDRNOTAVAIL @@ -735,6 +742,10 @@ ifinit(void) ifam2 = (struct ifa_msghdr*)((char*)ifam + ifam->ifam_msglen); +#ifdef RTM_OIFINFO + if (ifam->ifam_type == RTM_OIFINFO) + continue; /* just ignore compat message */ +#endif if (ifam->ifam_type == RTM_IFINFO) { struct sockaddr_dl *sdl; |