Index | Thread | Search

From:
Claudio Jeker <cjeker@diehard.n-r-g.com>
Subject:
bgpd: fix bitmap stat collection
To:
tech@openbsd.org
Date:
Fri, 6 Mar 2026 13:17:10 +0100

Download raw body.

Thread
Doh, I changed the code last minute to not use rdemem in bitmap.c since
that binds the code directly to the rde. Instead local variables have been
used and now I need to export those to rdemem before shipping the result
to bgpctl.

The types are a bit messed up because rdemem ususe long long for all the
things. Maybe the size members should be switched to size_t and the counts
should probably be unsigned long long. This is probably something to
tackle later.

-- 
:wq Claudio

Index: bgpd.h
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/bgpd.h,v
diff -u -p -r1.535 bgpd.h
--- bgpd.h	5 Mar 2026 09:54:06 -0000	1.535
+++ bgpd.h	5 Mar 2026 19:56:55 -0000
@@ -1616,6 +1616,8 @@ void		 bitmap_id_put(struct bitmap *, ui
 void		 bitmap_init(struct bitmap *);
 void		 bitmap_reset(struct bitmap *);
 
+void		 bitmap_get_stats(long long *, long long *);
+
 /* rde_sets.c */
 struct as_set	*as_sets_lookup(struct as_set_head *, const char *);
 struct as_set	*as_sets_new(struct as_set_head *, const char *, size_t,
Index: bitmap.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/bitmap.c,v
diff -u -p -r1.2 bitmap.c
--- bitmap.c	5 Mar 2026 09:54:06 -0000	1.2
+++ bitmap.c	5 Mar 2026 19:58:17 -0000
@@ -244,3 +244,10 @@ bitmap_reset(struct bitmap *map)
 	bitmap_free(map);
 	bitmap_init(map);
 }
+
+void
+bitmap_get_stats(long long *cnt, long long *size)
+{
+	*cnt = bitmap_cnt;
+	*size = bitmap_size;
+}
Index: rde.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde.c,v
diff -u -p -r1.688 rde.c
--- rde.c	2 Mar 2026 10:00:31 -0000	1.688
+++ rde.c	5 Mar 2026 19:56:27 -0000
@@ -741,6 +741,8 @@ badnetdel:
 			    peerid, pid, -1, &stats, sizeof(stats));
 			break;
 		case IMSG_CTL_SHOW_RIB_MEM:
+			bitmap_get_stats(&rdemem.bitmap_cnt,
+			    &rdemem.bitmap_size);
 			imsg_compose(ibuf_se_ctl, IMSG_CTL_SHOW_RIB_MEM, 0,
 			    pid, -1, &rdemem, sizeof(rdemem));
 			break;