Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Apr 2026 22:07:50 +0000
From:      Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 8a64738f5a93 - main - routing: Expire nhops inside the nhgrp
Message-ID:  <69f3d2b6.1ce23.a69ad9d@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by pouria:

URL: https://cgit.FreeBSD.org/src/commit/?id=8a64738f5a93ea878425ee3f51e1b9efbd3f5d6e

commit 8a64738f5a93ea878425ee3f51e1b9efbd3f5d6e
Author:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
AuthorDate: 2026-04-19 10:58:25 +0000
Commit:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
CommitDate: 2026-04-30 22:06:07 +0000

    routing: Expire nhops inside the nhgrp
    
    Fix route expiration of nhops that exists inside a nhgrp.
    
    Differential Revision: https://reviews.freebsd.org/D56189
---
 sys/net/route/route_ctl.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/sys/net/route/route_ctl.c b/sys/net/route/route_ctl.c
index fe00c762905d..7612c2bdfb58 100644
--- a/sys/net/route/route_ctl.c
+++ b/sys/net/route/route_ctl.c
@@ -1183,6 +1183,26 @@ change_route_byinfo(struct rib_head *rnh, struct rtentry *rt,
 	return (error);
 }
 
+static void
+update_tmproutes_mpath(struct rib_head *rnh, struct rtentry *rt,
+    struct route_nhop_data *rnd)
+{
+	const struct weightened_nhop *wn;
+	uint32_t i, nhops;
+
+	if (NH_IS_NHGRP(rnd->rnd_nhop)) {
+		wn = nhgrp_get_nhops(rnd->rnd_nhgrp, &nhops);
+
+		for (i = 0; i < nhops; i++) {
+			if (nhop_get_expire(wn[i].nh) == 0)
+				continue;
+
+			tmproutes_update(rnh, rt, wn[i].nh);
+		}
+	} else if (nhop_get_expire(rnd->rnd_nhop) != 0)
+		tmproutes_update(rnh, rt, rnd->rnd_nhop);
+}
+
 /*
  * Insert @rt with nhop data from @rnd_new to @rnh.
  * Returns 0 on success and stores operation results in @rc.
@@ -1200,9 +1220,7 @@ add_route(struct rib_head *rnh, struct rtentry *rt,
 	rn = rnh->rnh_addaddr(rt_key(rt), rt_mask_const(rt), &rnh->head, rt->rt_nodes);
 
 	if (rn != NULL) {
-		if (!NH_IS_NHGRP(rnd->rnd_nhop) && nhop_get_expire(rnd->rnd_nhop))
-			tmproutes_update(rnh, rt, rnd->rnd_nhop);
-
+		update_tmproutes_mpath(rnh, rt, rnd);
 		/* Finalize notification */
 		rib_bump_gen(rnh);
 		rnh->rnh_prefixes++;
@@ -1272,8 +1290,7 @@ change_route(struct rib_head *rnh, struct rtentry *rt,
 	/* Changing nexthop & weight to a new one */
 	rt->rt_nhop = rnd->rnd_nhop;
 	rt->rt_weight = rnd->rnd_weight;
-	if (!NH_IS_NHGRP(rnd->rnd_nhop) && nhop_get_expire(rnd->rnd_nhop))
-		tmproutes_update(rnh, rt, rnd->rnd_nhop);
+	update_tmproutes_mpath(rnh, rt, rnd);
 
 	/* Finalize notification */
 	rib_bump_gen(rnh);


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69f3d2b6.1ce23.a69ad9d>