From: claudio Date: Thu, 25 Aug 2022 08:10:25 +0000 (+0000) Subject: Connected routes use the BGP exit nexthop while other routes need to use X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=59a54550596b0f659036da553054175afec7a6ef;p=openbsd 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@ --- 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 @@ -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 @@ -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;