diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-05-26 12:02:12 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-05-26 12:02:12 +0000 |
commit | e8a1fa3bb04d9801d9e0b908997abbdb55499e1b (patch) | |
tree | ee41ee0d1668aef00de11458005f03a5b1aa8d98 | |
parent | af01db59fdcd33a0680440f45c27ed4d4365c6d8 (diff) |
Normalize route destination before checking for MPATH conflicts.
This makes rt_mpath_conflict() work as expected when adding routes
with the same destination and the same netmask.
With and ok claudio@
-rw-r--r-- | sys/net/route.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/sys/net/route.c b/sys/net/route.c index d2f8260d27a..d364fa93296 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.210 2015/05/15 12:00:57 claudio Exp $ */ +/* $OpenBSD: route.c,v 1.211 2015/05/26 12:02:11 mpi Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -841,25 +841,33 @@ rtrequest1(int req, struct rt_addrinfo *info, u_int8_t prio, ifa = info->rti_ifa; if (prio == 0) prio = ifa->ifa_ifp->if_priority + RTP_STATIC; + + dlen = info->rti_info[RTAX_DST]->sa_len; + ndst = malloc(dlen, M_RTABLE, M_NOWAIT); + if (ndst == NULL) + return (ENOBUFS); + + if (info->rti_info[RTAX_NETMASK] != NULL) + rt_maskedcopy(info->rti_info[RTAX_DST], ndst, + info->rti_info[RTAX_NETMASK]); + else + memcpy(ndst, info->rti_info[RTAX_DST], dlen); + #ifndef SMALL_KERNEL if (rn_mpath_capable(rnh)) { /* do not permit exactly the same dst/mask/gw pair */ - if (rt_mpath_conflict(rnh, info->rti_info[RTAX_DST], + if (rt_mpath_conflict(rnh, ndst, info->rti_info[RTAX_NETMASK], info->rti_info[RTAX_GATEWAY], prio, info->rti_flags & RTF_MPATH)) { + free(ndst, M_RTABLE, 0); return (EEXIST); } } #endif rt = pool_get(&rtentry_pool, PR_NOWAIT | PR_ZERO); - if (rt == NULL) - return (ENOBUFS); - - dlen = info->rti_info[RTAX_DST]->sa_len; - ndst = malloc(dlen, M_RTABLE, M_NOWAIT); - if (ndst == NULL) { - pool_put(&rtentry_pool, rt); + if (rt == NULL) { + free(ndst, M_RTABLE, 0); return (ENOBUFS); } @@ -868,18 +876,14 @@ rtrequest1(int req, struct rt_addrinfo *info, u_int8_t prio, rt->rt_priority = prio; /* init routing priority */ LIST_INIT(&rt->rt_timer); rt->rt_nodes->rn_key = (caddr_t)ndst; - memcpy(ndst, info->rti_info[RTAX_DST], dlen); if ((error = rt_setgate(rt, info->rti_info[RTAX_GATEWAY], tableid))) { + free(ndst, M_RTABLE, 0); pool_put(&rtentry_pool, rt); return (error); } - if (info->rti_info[RTAX_NETMASK] != NULL) - rt_maskedcopy(info->rti_info[RTAX_DST], ndst, - info->rti_info[RTAX_NETMASK]); - #ifndef SMALL_KERNEL if (rn_mpath_capable(rnh)) { /* check the link state since the table supports it */ |