summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authormelifaro <melifaro@FreeBSD.org>2014-05-08 20:41:39 +0000
committermelifaro <melifaro@FreeBSD.org>2014-05-08 20:41:39 +0000
commit5ca6003c5c59fcbccde099c4a5acae82537f80d9 (patch)
treebb8f2e278e828d67030223454dae78d3f19d19dc /sys/net
parentd42ec49fe7376d5d77807fe648fe0af085a8b7ac (diff)
downloadFreeBSD-src-5ca6003c5c59fcbccde099c4a5acae82537f80d9.zip
FreeBSD-src-5ca6003c5c59fcbccde099c4a5acae82537f80d9.tar.gz
Merge r260379, r260460.
r260379: Partially fix IPv4 interface routes deletion in RADIX_MPATH. Noticed by: Nikolay Denev <ndenev at gmail.com> r260460: Constanly use RT_ALL_FIBS everywhere instead of -1.
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/radix_mpath.c13
-rw-r--r--sys/net/route.c10
-rw-r--r--sys/net/route.h3
-rw-r--r--sys/net/rtsock.c11
4 files changed, 20 insertions, 17 deletions
diff --git a/sys/net/radix_mpath.c b/sys/net/radix_mpath.c
index 7a29069..82c0add 100644
--- a/sys/net/radix_mpath.c
+++ b/sys/net/radix_mpath.c
@@ -112,11 +112,16 @@ rt_mpath_matchgate(struct rtentry *rt, struct sockaddr *gate)
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;
diff --git a/sys/net/route.c b/sys/net/route.c
index 015eccb..1db844d 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1532,7 +1532,7 @@ rtinit1(struct ifaddr *ifa, int cmd, int flags, int fibnum)
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 {
@@ -1581,10 +1581,10 @@ rtinit1(struct ifaddr *ifa, int cmd, int flags, int fibnum)
/* 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 {
@@ -1598,13 +1598,11 @@ rtinit1(struct ifaddr *ifa, int cmd, int flags, int fibnum)
*/
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);
@@ -1753,7 +1751,7 @@ rtinit(struct ifaddr *ifa, int cmd, int flags)
case AF_INET6:
case AF_INET:
/* We do support multiple FIBs. */
- fib = -1;
+ fib = RT_ALL_FIBS;
break;
}
return (rtinit1(ifa, cmd, flags, fib));
diff --git a/sys/net/route.h b/sys/net/route.h
index 8f47acf..234b536 100644
--- a/sys/net/route.h
+++ b/sys/net/route.h
@@ -83,7 +83,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 */
/*
* We distinguish between routes to hosts and routes to networks,
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index af51ac6..798ed43 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -161,7 +161,6 @@ int (*carp_get_vhid_p)(struct ifaddr *);
* 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 */
@@ -1281,7 +1280,7 @@ rt_missmsg_fib(int type, struct rt_addrinfo *rtinfo, int flags, int error,
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);
@@ -1299,7 +1298,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);
}
/*
@@ -1395,7 +1394,7 @@ rt_newaddrmsg_fib(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt,
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));
@@ -1410,7 +1409,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);
}
/*
@@ -1907,7 +1906,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);
OpenPOWER on IntegriCloud