From owner-svn-src-all@FreeBSD.ORG Thu May 8 20:33:48 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B95287D9; Thu, 8 May 2014 20:33:48 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 99A4C95; Thu, 8 May 2014 20:33:48 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s48KXmMA092820; Thu, 8 May 2014 20:33:48 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s48KXleJ092791; Thu, 8 May 2014 20:33:47 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201405082033.s48KXleJ092791@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Thu, 8 May 2014 20:33:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r265710 - stable/9/sys/net X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 May 2014 20:33:48 -0000 Author: melifaro Date: Thu May 8 20:33:47 2014 New Revision: 265710 URL: http://svnweb.freebsd.org/changeset/base/265710 Log: Merge r260379, r260460. r260379: Partially fix IPv4 interface routes deletion in RADIX_MPATH. Noticed by: Nikolay Denev r260460: Constanly use RT_ALL_FIBS everywhere instead of -1. Modified: stable/9/sys/net/radix_mpath.c stable/9/sys/net/route.c stable/9/sys/net/route.h stable/9/sys/net/rtsock.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/net/ (props changed) Modified: stable/9/sys/net/radix_mpath.c ============================================================================== --- stable/9/sys/net/radix_mpath.c Thu May 8 20:28:22 2014 (r265709) +++ stable/9/sys/net/radix_mpath.c Thu May 8 20:33:47 2014 (r265710) @@ -112,11 +112,16 @@ rt_mpath_matchgate(struct rtentry *rt, s if (rt->rt_gateway->sa_family == AF_LINK) { if (!memcmp(rt->rt_ifa->ifa_addr, gate, gate->sa_len)) break; - } else { - if (rt->rt_gateway->sa_len == gate->sa_len && - !memcmp(rt->rt_gateway, gate, gate->sa_len)) - break; } + + /* + * Check for other options: + * 1) Routes with 'real' IPv4/IPv6 gateway + * 2) Loopback host routes (another AF_LINK/sockadd_dl check) + * */ + if (rt->rt_gateway->sa_len == gate->sa_len && + !memcmp(rt->rt_gateway, gate, gate->sa_len)) + break; } while ((rn = rn_mpath_next(rn)) != NULL); return (struct rtentry *)rn; Modified: stable/9/sys/net/route.c ============================================================================== --- stable/9/sys/net/route.c Thu May 8 20:28:22 2014 (r265709) +++ stable/9/sys/net/route.c Thu May 8 20:33:47 2014 (r265710) @@ -1515,7 +1515,7 @@ rtinit1(struct ifaddr *ifa, int cmd, int fibnum = RT_DEFAULT_FIB; break; } - if (fibnum == -1) { + if (fibnum == RT_ALL_FIBS) { if (rt_add_addr_allfibs == 0 && cmd == (int)RTM_ADD) { startfib = endfib = curthread->td_proc->p_fibnum; } else { @@ -1564,10 +1564,10 @@ rtinit1(struct ifaddr *ifa, int cmd, int /* this table doesn't exist but others might */ continue; RADIX_NODE_HEAD_RLOCK(rnh); + rn = rnh->rnh_lookup(dst, netmask, rnh); #ifdef RADIX_MPATH if (rn_mpath_capable(rnh)) { - rn = rnh->rnh_matchaddr(dst, rnh); if (rn == NULL) error = ESRCH; else { @@ -1581,13 +1581,11 @@ rtinit1(struct ifaddr *ifa, int cmd, int */ rt = rt_mpath_matchgate(rt, ifa->ifa_addr); - if (!rt) + if (rt == NULL) error = ESRCH; } } - else #endif - rn = rnh->rnh_lookup(dst, netmask, rnh); error = (rn == NULL || (rn->rn_flags & RNF_ROOT) || RNTORT(rn)->rt_ifa != ifa); @@ -1721,7 +1719,7 @@ rtinit1(struct ifaddr *ifa, int cmd, int int rtinit_fib(struct ifaddr *ifa, int cmd, int flags) { - return (rtinit1(ifa, cmd, flags, -1)); + return (rtinit1(ifa, cmd, flags, RT_ALL_FIBS)); } #endif @@ -1745,7 +1743,7 @@ rtinit(struct ifaddr *ifa, int cmd, int case AF_INET6: case AF_INET: /* We do support multiple FIBs. */ - fib = -1; + fib = RT_ALL_FIBS; break; } return (rtinit1(ifa, cmd, flags, fib)); Modified: stable/9/sys/net/route.h ============================================================================== --- stable/9/sys/net/route.h Thu May 8 20:28:22 2014 (r265709) +++ stable/9/sys/net/route.h Thu May 8 20:33:47 2014 (r265710) @@ -92,7 +92,8 @@ struct rt_metrics { #define RTTTOPRHZ(r) ((r) / (RTM_RTTUNIT / PR_SLOWHZ)) #define RT_DEFAULT_FIB 0 /* Explicitly mark fib=0 restricted cases */ -extern u_int rt_numfibs; /* number fo usable routing tables */ +#define RT_ALL_FIBS -1 /* Announce event for every fib */ +extern u_int rt_numfibs; /* number of usable routing tables */ /* * XXX kernel function pointer `rt_output' is visible to applications. */ Modified: stable/9/sys/net/rtsock.c ============================================================================== --- stable/9/sys/net/rtsock.c Thu May 8 20:28:22 2014 (r265709) +++ stable/9/sys/net/rtsock.c Thu May 8 20:33:47 2014 (r265710) @@ -154,7 +154,6 @@ static struct sockaddr sa_zero = { siz * notification to a socket bound to a particular FIB. */ #define RTS_FILTER_FIB M_PROTO8 -#define RTS_ALLFIBS -1 static struct { int ip_count; /* attached w/ AF_INET */ @@ -1218,7 +1217,7 @@ rt_missmsg_fib(int type, struct rt_addri if (m == NULL) return; - if (fibnum != RTS_ALLFIBS) { + if (fibnum != RT_ALL_FIBS) { KASSERT(fibnum >= 0 && fibnum < rt_numfibs, ("%s: fibnum out " "of range 0 <= %d < %d", __func__, fibnum, rt_numfibs)); M_SETFIB(m, fibnum); @@ -1236,7 +1235,7 @@ void rt_missmsg(int type, struct rt_addrinfo *rtinfo, int flags, int error) { - rt_missmsg_fib(type, rtinfo, flags, error, RTS_ALLFIBS); + rt_missmsg_fib(type, rtinfo, flags, error, RT_ALL_FIBS); } /* @@ -1332,7 +1331,7 @@ rt_newaddrmsg_fib(int cmd, struct ifaddr rtm->rtm_errno = error; rtm->rtm_addrs = info.rti_addrs; } - if (fibnum != RTS_ALLFIBS) { + if (fibnum != RT_ALL_FIBS) { KASSERT(fibnum >= 0 && fibnum < rt_numfibs, ("%s: " "fibnum out of range 0 <= %d < %d", __func__, fibnum, rt_numfibs)); @@ -1347,7 +1346,7 @@ void rt_newaddrmsg(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt) { - rt_newaddrmsg_fib(cmd, ifa, error, rt, RTS_ALLFIBS); + rt_newaddrmsg_fib(cmd, ifa, error, rt, RT_ALL_FIBS); } /* @@ -1818,7 +1817,7 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS) if (namelen == 3) fib = req->td->td_proc->p_fibnum; else if (namelen == 4) - fib = (name[3] == -1) ? + fib = (name[3] == RT_ALL_FIBS) ? req->td->td_proc->p_fibnum : name[3]; else return ((namelen < 3) ? EISDIR : ENOTDIR);