Partially fix IPv4 interface routes deletion in RADIX_MPATH.

Noticed by:	Nikolay Denev <ndenev at gmail.com>
MFC after:	1 month
This commit is contained in:
melifaro 2014-01-06 22:36:20 +00:00
parent 353906d3d2
commit 9f8536f282
2 changed files with 11 additions and 8 deletions

View File

@ -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;

View File

@ -1547,10 +1547,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 {
@ -1564,13 +1564,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);