diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-11-17 10:28:25 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-11-17 10:28:25 +0000 |
commit | 3503d0c3074963f30fcbd7bb847fa999655fbfb9 (patch) | |
tree | 18cdcf6a79f24d3d1c329e97ec615457479c6658 /sys/net | |
parent | 124fc35584a05a792e3fed6ce6c51be8b399d2e2 (diff) |
Unbreak next-hop caching on multipath setups.
When multiple gateways are in use, the next-hop entrie might not be
on the same interface. This is due to the fact that ARP entries are
unique and attached to their cloning interface.
Found the hard way by and ok dlg@
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/route.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/sys/net/route.c b/sys/net/route.c index 15ae1d86c40..cbbfb8e785f 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.270 2015/11/11 11:25:16 mpi Exp $ */ +/* $OpenBSD: route.c,v 1.271 2015/11/17 10:28:24 mpi Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -405,10 +405,14 @@ rtalloc(struct sockaddr *dst, int flags, unsigned int rtableid) return (rt); } - /* - * Next hop entry must be UP and on the same interface. - */ - if (!ISSET(nhrt->rt_flags, RTF_UP) || nhrt->rt_ifidx != rt->rt_ifidx) { + /* Next hop entry must be UP... */ + if (!ISSET(nhrt->rt_flags, RTF_UP)) { + rtfree(nhrt); + return (rt); + } + + /* ...and on the same interface unless we have multiple gateways. */ + if (nhrt->rt_ifidx != rt->rt_ifidx && !ISSET(rt->rt_flags, RTF_MPATH)) { rtfree(nhrt); return (rt); } |