Connected routes use the BGP exit nexthop while other routes need to use
authorclaudio <claudio@openbsd.org>
Thu, 25 Aug 2022 08:10:25 +0000 (08:10 +0000)
committerclaudio <claudio@openbsd.org>
Thu, 25 Aug 2022 08:10:25 +0000 (08:10 +0000)
the nexthop from the covering route. Move this logic from RDE to the
kroute code so it is all in one place.
OK tb@

usr.sbin/bgpd/kroute.c
usr.sbin/bgpd/rde_rib.c

index b7778fb..8867aaa 100644 (file)
@@ -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;
index 1519444..87a1546 100644 (file)
@@ -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;