Index | Thread | Search

From:
Claudio Jeker <cjeker@diehard.n-r-g.com>
Subject:
bgpd: better sync template clones in merge_peers
To:
tech@openbsd.org
Date:
Mon, 11 May 2026 21:08:01 +0200

Download raw body.

Thread
When introducing local_bgpid in the session code the case to update cloned
peers was missed. merge_peers only updates regular peers and templates.

Note: session_template_clone() copies the template->conf into conf so all
the other fixups inside conf (holdtime, etc) get taken over. The problem
is that local_bgpid is not inside conf and so this was missed.
Another option to the diff below is to do the local_bgpid in
session_template_clone() by copying peer->template->local_bgpid into
peer->local_bgpid. It is a bit less direct than the diff below, not sure
if it is worth it.

This should fix this oversight.
-- 
:wq Claudio

Index: session.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/session.c,v
diff -u -p -r1.534 session.c
--- session.c	8 May 2026 12:03:50 -0000	1.534
+++ session.c	11 May 2026 19:02:43 -0000
@@ -1968,6 +1968,8 @@ merge_peers(struct bgpd_config *c, struc
 				session_template_clone(xp, NULL, xp->conf.id,
 				    xp->conf.remote_as);
 
+				xp->local_bgpid = nc->bgpid;
+
 				if (xp->rdesession)
 					imsg_rde(IMSG_SESSION_ADD,
 					    xp->conf.id, &xp->conf,