diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2022-08-25 08:10:26 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2022-08-25 08:10:26 +0000 |
commit | 910747d9f36c9ad4fc935b1bc2683be24e98836e (patch) | |
tree | 27908a0fa9b6155641b60c1496a45fc8e358674a | |
parent | 572bfb4cb47460dae7029424104fbbf2867d52ef (diff) |
Connected routes use the BGP exit nexthop while other routes need to use
the nexthop from the covering route. Move this logic from RDE to the
kroute code so it is all in one place.
OK tb@
-rw-r--r-- | usr.sbin/bgpd/kroute.c | 15 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_rib.c | 8 |
2 files changed, 10 insertions, 13 deletions
diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c index b7778fb1cb5..8867aaaf935 100644 --- a/usr.sbin/bgpd/kroute.c +++ b/usr.sbin/bgpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.295 2022/08/19 09:11:18 claudio Exp $ */ +/* $OpenBSD: kroute.c,v 1.296 2022/08/25 08:10:25 claudio Exp $ */ /* * Copyright (c) 2022 Claudio Jeker <claudio@openbsd.org> @@ -2265,11 +2265,11 @@ knexthop_send_update(struct knexthop *kn) kr = kn->kroute; n.valid = kroute_validate(kr); n.connected = kr->flags & F_CONNECTED; - if (kr->nexthop.s_addr != 0) { + if (!n.connected) { n.gateway.aid = AID_INET; n.gateway.v4.s_addr = kr->nexthop.s_addr; - } - if (n.connected) { + } else { + n.gateway = n.nexthop; n.net.aid = AID_INET; n.net.v4.s_addr = kr->prefix.s_addr; n.netlen = kr->prefixlen; @@ -2279,13 +2279,12 @@ knexthop_send_update(struct knexthop *kn) kr6 = kn->kroute; n.valid = kroute6_validate(kr6); n.connected = kr6->flags & F_CONNECTED; - if (memcmp(&kr6->nexthop, &in6addr_any, - sizeof(struct in6_addr)) != 0) { + if (!n.connected) { n.gateway.aid = AID_INET6; n.gateway.v6 = kr6->nexthop; n.gateway.scope_id = kr6->nexthop_scope_id; - } - if (n.connected) { + } else { + n.gateway = n.nexthop; n.net.aid = AID_INET6; n.net.v6 = kr6->prefix; n.net.scope_id = kr6->prefix_scope_id; diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c index 151944456a8..87a154633c8 100644 --- a/usr.sbin/bgpd/rde_rib.c +++ b/usr.sbin/bgpd/rde_rib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_rib.c,v 1.243 2022/08/10 14:17:01 claudio Exp $ */ +/* $OpenBSD: rde_rib.c,v 1.244 2022/08/25 08:10:25 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -1739,12 +1739,10 @@ nexthop_update(struct kroute_nexthop *msg) TAILQ_REMOVE(&nexthop_runners, nh, runner_l); } - if (msg->connected) { + if (msg->connected) nh->flags |= NEXTHOP_CONNECTED; - nh->true_nexthop = nh->exit_nexthop; - } else - nh->true_nexthop = msg->gateway; + nh->true_nexthop = msg->gateway; nh->nexthop_net = msg->net; nh->nexthop_netlen = msg->netlen; |