Index | Thread | Search

From:
Claudio Jeker <cjeker@diehard.n-r-g.com>
Subject:
bgpd: clear connected flag in nexthop_update
To:
tech@openbsd.org
Date:
Mon, 21 Sep 2026 13:25:39 +0200

Download raw body.

Thread
Clear NEXTHOP_CONNECTED in nexthop_update() if msg->connected is false.

Until now nexthop_update() only set but never reset NEXTHOP_CONNECTED.
As a result once the connected flag was set it remained set even if the
nexthop was no longer directly connected.

Fix for issue #150 but with a lot less words.
-- 
:wq Claudio

Index: rde_rib.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde_rib.c,v
diff -u -p -r1.304 rde_rib.c
--- rde_rib.c	30 Aug 2026 23:43:22 -0000	1.304
+++ rde_rib.c	21 Sep 2026 09:19:06 -0000
@@ -1378,7 +1378,7 @@ nexthop_update(struct kroute_nexthop *ms
 		nh->state = NEXTHOP_UNREACH;
 
 	if (nh->oldstate == NEXTHOP_LOOKUP)
-		/* drop reference which was hold during the lookup */
+		/* drop reference which was held during the lookup */
 		if (nexthop_unref(nh))
 			return;		/* nh lost last ref, no work left */
 
@@ -1394,6 +1394,8 @@ nexthop_update(struct kroute_nexthop *ms
 
 	if (msg->connected)
 		nh->flags |= NEXTHOP_CONNECTED;
+	else
+		nh->flags &= ~NEXTHOP_CONNECTED;
 
 	nh->true_nexthop = msg->gateway;
 	nh->nexthop_net = msg->net;