From owner-freebsd-net@FreeBSD.ORG Thu Sep 7 18:32:38 2006 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5EF1C16A4DA for ; Thu, 7 Sep 2006 18:32:38 +0000 (UTC) (envelope-from ambrisko@ambrisko.com) Received: from mail.ambrisko.com (mail.ambrisko.com [64.174.51.43]) by mx1.FreeBSD.org (Postfix) with ESMTP id A511743E35 for ; Thu, 7 Sep 2006 18:31:05 +0000 (GMT) (envelope-from ambrisko@ambrisko.com) Received: from server2.ambrisko.com (HELO www.ambrisko.com) ([192.168.1.2]) by mail.ambrisko.com with ESMTP; 07 Sep 2006 11:28:21 -0700 Received: from ambrisko.com (localhost [127.0.0.1]) by www.ambrisko.com (8.13.1/8.12.11) with ESMTP id k87IUtKL034481 for ; Thu, 7 Sep 2006 11:30:55 -0700 (PDT) (envelope-from ambrisko@ambrisko.com) Received: (from ambrisko@localhost) by ambrisko.com (8.13.1/8.13.1/Submit) id k87IUt5a034480 for freebsd-net@freebsd.org; Thu, 7 Sep 2006 11:30:55 -0700 (PDT) (envelope-from ambrisko) From: Doug Ambrisko Message-Id: <200609071830.k87IUt5a034480@ambrisko.com> To: freebsd-net@freebsd.org Date: Thu, 7 Sep 2006 11:30:55 -0700 (PDT) X-Mailer: ELM [version 2.4ME+ PL94b (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Subject: patch to not route on down interfaces X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Sep 2006 18:32:38 -0000 Hi guys, We "hack" a feature to have 2 NIC's configured with the same IP and netmask. We down one and up the other to bounce between then. We also set the MAC's to be the same. This fixes a few routing problems in which the route would be tied to the down interface and not the up one :-( --- ../src/sys/net/if.c Tue Feb 14 19:37:15 2006 +++ ./sys/net/if.c Tue Sep 5 12:21:46 2006 @@ -986,7 +986,9 @@ ifa_ifwithaddr(struct sockaddr *addr) struct ifaddr *ifa; IFNET_RLOCK(); - TAILQ_FOREACH(ifp, &ifnet, if_link) + TAILQ_FOREACH(ifp, &ifnet, if_link) { + if (!ifp->if_flags & IFF_UP) + continue; TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != addr->sa_family) continue; @@ -999,6 +1001,7 @@ ifa_ifwithaddr(struct sockaddr *addr) sa_equal(ifa->ifa_broadaddr, addr)) goto done; } + } ifa = NULL; done: IFNET_RUNLOCK(); @@ -1017,6 +1020,8 @@ ifa_ifwithdstaddr(struct sockaddr *addr) IFNET_RLOCK(); TAILQ_FOREACH(ifp, &ifnet, if_link) { + if (!ifp->if_flags & IFF_UP) + continue; if ((ifp->if_flags & IFF_POINTOPOINT) == 0) continue; TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { @@ -1062,6 +1067,8 @@ ifa_ifwithnet(struct sockaddr *addr) */ IFNET_RLOCK(); TAILQ_FOREACH(ifp, &ifnet, if_link) { + if (!ifp->if_flags & IFF_UP) + continue; TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { char *cp, *cp2, *cp3; --- ../src/sys/netinet/in.c Tue Jan 31 08:11:37 2006 +++ ./sys/netinet/in.c Tue Sep 5 16:09:00 2006 @@ -870,6 +871,8 @@ in_scrubprefix(target) } TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) { + if (ia->ia_ifp && !(ia->ia_ifp->if_flags & IFF_UP)) + continue; if (rtinitflags(ia)) p = ia->ia_dstaddr.sin_addr; else { Thanks, Doug A.