Index | Thread | Search

From:
Claudio Jeker <cjeker@diehard.n-r-g.com>
Subject:
bgpd: IMSG_CTL_SHOW_NEIGHBOR handling
To:
tech@openbsd.org
Date:
Wed, 12 Feb 2025 13:32:25 +0100

Download raw body.

Thread
As requested by tb@ move the getpeerbyid() call from control_imsg_relay()
back to the session imsg dispatcher. So all of them are in the same place.

I left the p == NULL check just in case but I'm torn about that.
-- 
:wq Claudio

Index: control.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/control.c,v
diff -u -p -r1.132 control.c
--- control.c	2 Dec 2024 15:03:17 -0000	1.132
+++ control.c	12 Feb 2025 12:28:15 -0000
@@ -552,11 +552,9 @@ control_imsg_relay(struct imsg *imsg, st
 		struct rde_peer_stats stats;
 		struct peer peer;
 
-		if (p == NULL) {
-			log_warnx("%s: no such peer: id=%u", __func__,
-			    imsg_get_id(imsg));
+		if (p == NULL)
 			return (0);
-		}
+
 		if (imsg_get_data(imsg, &stats, sizeof(stats)) == -1) {
 			log_warnx("%s: imsg_get_data", __func__);
 			return (0);
Index: session.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/session.c,v
diff -u -p -r1.513 session.c
--- session.c	11 Feb 2025 19:28:45 -0000	1.513
+++ session.c	11 Feb 2025 19:33:15 -0000
@@ -3317,7 +3317,11 @@ session_dispatch_imsg(struct imsgbuf *im
 		case IMSG_CTL_SHOW_NEIGHBOR:
 			if (idx != PFD_PIPE_ROUTE_CTL)
 				fatalx("ctl rib request not from RDE");
-			p = getpeerbyid(conf, peerid);
+			if ((p = getpeerbyid(conf, peerid)) == NULL) {
+				log_warnx("%s: no such peer: id=%u",
+				    "IMSG_CTL_SHOW_NEIGHBOR", peerid);
+				break;
+			}
 			control_imsg_relay(&imsg, p);
 			break;
 		case IMSG_CTL_SHOW_RIB: