Index | Thread | Search

From:
Claudio Jeker <cjeker@diehard.n-r-g.com>
Subject:
bgpd: add const to a few more functions
To:
tech@openbsd.org
Date:
Tue, 3 Feb 2026 10:27:50 +0100

Download raw body.

Thread
For an upcomming diff I need to const correct some additional functions.
This allows to make bits in rde_apply_set const.

-- 
:wq Claudio

Index: rde.h
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde.h,v
diff -u -p -r1.337 rde.h
--- rde.h	28 Dec 2025 17:52:44 -0000	1.337
+++ rde.h	3 Feb 2026 09:24:55 -0000
@@ -495,9 +495,9 @@ aspath_origin(struct aspath *aspath)
 int	community_match(struct rde_community *, struct community *,
 	    struct rde_peer *);
 int	community_count(struct rde_community *, uint8_t type);
-int	community_set(struct rde_community *, struct community *,
+int	community_set(struct rde_community *, const struct community *,
 	    struct rde_peer *);
-void	community_delete(struct rde_community *, struct community *,
+void	community_delete(struct rde_community *, const struct community *,
 	    struct rde_peer *);
 
 int	community_add(struct rde_community *, int, struct ibuf *);
@@ -740,7 +740,7 @@ void		 nexthop_modify(struct nexthop *, 
 void		 nexthop_link(struct prefix *);
 void		 nexthop_unlink(struct prefix *);
 void		 nexthop_update(struct kroute_nexthop *);
-struct nexthop	*nexthop_get(struct bgpd_addr *);
+struct nexthop	*nexthop_get(const struct bgpd_addr *);
 struct nexthop	*nexthop_ref(struct nexthop *);
 int		 nexthop_unref(struct nexthop *);
 
Index: rde_community.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde_community.c,v
diff -u -p -r1.22 rde_community.c
--- rde_community.c	16 Dec 2025 15:38:55 -0000	1.22
+++ rde_community.c	3 Feb 2026 09:24:55 -0000
@@ -59,7 +59,7 @@ apply_flag(uint32_t in, uint8_t flag, st
 }
 
 static int
-fc2c(struct community *fc, struct rde_peer *peer, struct community *c,
+fc2c(const struct community *fc, struct rde_peer *peer, struct community *c,
     struct community *m)
 {
 	int type;
@@ -218,7 +218,7 @@ mask_match(struct community *a, struct c
  * Insert a community keeping the list sorted. Don't add if already present.
  */
 static void
-insert_community(struct rde_community *comm, struct community *c)
+insert_community(struct rde_community *comm, const struct community *c)
 {
 	int l;
 	int r;
@@ -339,8 +339,8 @@ community_count(struct rde_community *co
  * Insert a community, expanding local-as and neighbor-as if needed.
  */
 int
-community_set(struct rde_community *comm, struct community *fc,
-struct rde_peer *peer)
+community_set(struct rde_community *comm, const struct community *fc,
+    struct rde_peer *peer)
 {
 	struct community set;
 
@@ -378,8 +378,8 @@ struct rde_peer *peer)
  * neighbor-as and also mask of bits to support partial matches.
  */
 void
-community_delete(struct rde_community *comm, struct community *fc,
-struct rde_peer *peer)
+community_delete(struct rde_community *comm, const struct community *fc,
+    struct rde_peer *peer)
 {
 	struct community test, mask;
 	struct community *match;
Index: rde_rib.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde_rib.c,v
diff -u -p -r1.287 rde_rib.c
--- rde_rib.c	28 Dec 2025 17:52:44 -0000	1.287
+++ rde_rib.c	3 Feb 2026 09:24:55 -0000
@@ -1190,7 +1190,7 @@ prefix_free(struct prefix *p)
 /*
  * nexthop functions
  */
-struct nexthop		*nexthop_lookup(struct bgpd_addr *);
+static struct nexthop		*nexthop_lookup(const struct bgpd_addr *);
 
 /*
  * In BGP there exist two nexthops: the exit nexthop which was announced via
@@ -1386,7 +1386,7 @@ nexthop_unlink(struct prefix *p)
 }
 
 struct nexthop *
-nexthop_get(struct bgpd_addr *nexthop)
+nexthop_get(const struct bgpd_addr *nexthop)
 {
 	struct nexthop	*nh;
 
@@ -1475,8 +1475,8 @@ nexthop_cmp(struct nexthop *na, struct n
 	return (-1);
 }
 
-struct nexthop *
-nexthop_lookup(struct bgpd_addr *nexthop)
+static struct nexthop *
+nexthop_lookup(const struct bgpd_addr *nexthop)
 {
 	struct nexthop	needle = { 0 };