From: Claudio Jeker Subject: bgpd: remove nhflags and dmetric for adj-rib-out To: tech@openbsd.org Date: Thu, 20 Nov 2025 14:50:54 +0100 In the Adj-RIB-Out dmetric has no meaning (by default there is only one path). Also nhflags are not needed any more since the nexthop selection happens right before addition to the Adj-RIB-Out in up_prep_adjout(). -- :wq Claudio ? obj Index: rde.c =================================================================== RCS file: /cvs/src/usr.sbin/bgpd/rde.c,v diff -u -p -r1.668 rde.c --- rde.c 20 Nov 2025 13:46:22 -0000 1.668 +++ rde.c 20 Nov 2025 13:47:46 -0000 @@ -2994,7 +2994,6 @@ rde_dump_adjout_as(struct prefix_adjout rib.prefixlen = p->pt->prefixlen; rib.origin = asp->origin; /* roa and aspa vstate skipped, they don't matter in adj-rib-out */ - rib.dmetric = p->dmetric; rib.flags = 0; rib.flags |= F_PREF_ELIGIBLE; if (!peer->conf.ebgp) Index: rde.h =================================================================== RCS file: /cvs/src/usr.sbin/bgpd/rde.h,v diff -u -p -r1.323 rde.h --- rde.h 20 Nov 2025 13:46:22 -0000 1.323 +++ rde.h 20 Nov 2025 13:47:46 -0000 @@ -314,8 +314,6 @@ struct prefix_adjout { uint32_t path_id_tx; uint8_t flags; uint8_t validation_state; - uint8_t nhflags; - int8_t dmetric; /* decision metric */ }; #define PREFIX_ADJOUT_FLAG_WITHDRAW 0x01 /* enqueued on withdraw queue */ #define PREFIX_ADJOUT_FLAG_UPDATE 0x02 /* enqueued on update queue */ @@ -770,12 +768,6 @@ static inline struct nexthop * prefix_adjout_nexthop(struct prefix_adjout *p) { return (p->nexthop); -} - -static inline uint8_t -prefix_adjout_nhflags(struct prefix_adjout *p) -{ - return (p->nhflags & NEXTHOP_MASK); } /* rde_update.c */ Index: rde_adjout.c =================================================================== RCS file: /cvs/src/usr.sbin/bgpd/rde_adjout.c,v diff -u -p -r1.5 rde_adjout.c --- rde_adjout.c 20 Nov 2025 13:46:22 -0000 1.5 +++ rde_adjout.c 20 Nov 2025 13:47:46 -0000 @@ -63,7 +63,7 @@ prefix_is_dead(struct prefix_adjout *p) static void prefix_adjout_link(struct prefix_adjout *, struct pt_entry *, struct rde_peer *, uint32_t, uint32_t, struct rde_aspath *, struct rde_community *, - struct nexthop *, uint8_t, uint8_t); + struct nexthop *, uint8_t); static void prefix_adjout_unlink(struct prefix_adjout *); static struct prefix_adjout *prefix_adjout_alloc(void); @@ -101,8 +101,6 @@ prefix_cmp(struct prefix_adjout *a, stru return (a->communities > b->communities ? 1 : -1); if (a->nexthop != b->nexthop) return (a->nexthop > b->nexthop ? 1 : -1); - if (a->nhflags != b->nhflags) - return (a->nhflags > b->nhflags ? 1 : -1); return prefix_index_cmp(a, b); } @@ -249,7 +247,6 @@ prefix_adjout_update(struct prefix_adjou * paths. */ if (p->path_id_tx == path_id_tx && - prefix_adjout_nhflags(p) == state->nhflags && prefix_adjout_nexthop(p) == state->nexthop && communities_equal(&state->communities, prefix_adjout_communities(p)) && @@ -296,7 +293,7 @@ prefix_adjout_update(struct prefix_adjou } prefix_adjout_link(p, p->pt, peer, 0, p->path_id_tx, asp, comm, - state->nexthop, state->nhflags, state->vstate); + state->nexthop, state->vstate); peer->stats.prefix_out_cnt++; if (p->flags & PREFIX_ADJOUT_FLAG_MASK) @@ -572,7 +569,7 @@ static void prefix_adjout_link(struct prefix_adjout *p, struct pt_entry *pt, struct rde_peer *peer, uint32_t path_id, uint32_t path_id_tx, struct rde_aspath *asp, struct rde_community *comm, - struct nexthop *nexthop, uint8_t nhflags, uint8_t vstate) + struct nexthop *nexthop, uint8_t vstate) { p->aspath = path_ref(asp); p->communities = communities_ref(comm); @@ -582,9 +579,6 @@ prefix_adjout_link(struct prefix_adjout p->path_id_tx = path_id_tx; p->validation_state = vstate; p->nexthop = nexthop_ref(nexthop); - p->nhflags = nhflags; - /* All nexthops are valid in Adj-RIB-Out */ - p->nhflags |= NEXTHOP_VALID; p->lastchange = getmonotime(); } @@ -598,7 +592,6 @@ prefix_adjout_unlink(struct prefix_adjou /* remove nexthop ref ... */ nexthop_unref(p->nexthop); p->nexthop = NULL; - p->nhflags = 0; /* ... communities ... */ communities_unref(p->communities); p->communities = NULL; Index: rde_update.c =================================================================== RCS file: /cvs/src/usr.sbin/bgpd/rde_update.c,v diff -u -p -r1.182 rde_update.c --- rde_update.c 20 Nov 2025 13:46:22 -0000 1.182 +++ rde_update.c 20 Nov 2025 13:47:46 -0000 @@ -855,7 +855,6 @@ up_dump_prefix(struct ibuf *buf, struct np->aspath != p->aspath || np->communities != p->communities || np->nexthop != p->nexthop || - np->nhflags != p->nhflags || (np->flags & PREFIX_ADJOUT_FLAG_EOR)) done = 1;