diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-07-08 08:03:47 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-07-08 08:03:47 +0000 |
commit | c29f097509f63ada9244c800edb94327c2c07867 (patch) | |
tree | 3943f77b9335f8292e0880d358948c53008a03c5 | |
parent | 01d38b21903899f9771cd07a54f45188c969a7bc (diff) |
Check for RTF_CONNECTED to track interface (connected) routes.
Make bgpd(8) properly handle interface routes since they no
longer have a "gateway" sockaddr of type AF_LINK. Regression
reported by <mxb AT alumni DOT chalmers DOT se> and benno@
While here document traditional BSD connected route assumption.
ok claudio@, benno@
-rw-r--r-- | usr.sbin/bgpd/kroute.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c index 99060908ec3..10e35826e22 100644 --- a/usr.sbin/bgpd/kroute.c +++ b/usr.sbin/bgpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.202 2015/02/11 05:48:53 claudio Exp $ */ +/* $OpenBSD: kroute.c,v 1.203 2015/07/08 08:03:46 mpi Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -2821,7 +2821,8 @@ fetchtable(struct ktable *kt, u_int8_t fib_prio) if ((sa = rti_info[RTAX_DST]) == NULL) continue; - if (rtm->rtm_flags & RTF_LLINFO) /* arp cache */ + /* Skip ARP/ND cache and local routes. */ + if (rtm->rtm_flags & (RTF_LLINFO|RTF_LOCAL|RTF_BROADCAST)) continue; switch (sa->sa_family) { @@ -2900,17 +2901,33 @@ fetchtable(struct ktable *kt, u_int8_t fib_prio) case AF_INET: if (kr == NULL) fatalx("v4 gateway for !v4 dst?!"); + + if (rtm->rtm_flags & RTF_CONNECTED) { + kr->r.flags |= F_CONNECTED; + break; + } + kr->r.nexthop.s_addr = ((struct sockaddr_in *)gw)->sin_addr.s_addr; break; case AF_INET6: if (kr6 == NULL) fatalx("v6 gateway for !v6 dst?!"); + + if (rtm->rtm_flags & RTF_CONNECTED) { + kr6->r.flags |= F_CONNECTED; + break; + } + memcpy(&kr6->r.nexthop, &((struct sockaddr_in6 *)gw)->sin6_addr, sizeof(kr6->r.nexthop)); break; case AF_LINK: + /* + * Traditional BSD connected routes have + * a gateway of type AF_LINK. + */ if (sa->sa_family == AF_INET) kr->r.flags |= F_CONNECTED; else if (sa->sa_family == AF_INET6) |