Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 May 2026 20:01:18 +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: 97f7b21dd525 - main - rtnetlink: Fix weight overflow in RTA_MULTIPATH
Message-ID:  <6a189f0e.26ecf.5c59f70@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=97f7b21dd52542421bc883e336e35af078af47fe

commit 97f7b21dd52542421bc883e336e35af078af47fe
Author:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
AuthorDate: 2026-05-27 09:58:34 +0000
Commit:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
CommitDate: 2026-05-28 20:00:15 +0000

    rtnetlink: Fix weight overflow in RTA_MULTIPATH
    
    If the weight value is larger than 8 bits, set it to the maximum.
    Also, only send RTA_WEIGHT if its value is not the default.
    This reduces message size and matches the behavior of
    non-multipath routes.
    
    Reviewed by:    emaste, markj
    Differential Revision: https://reviews.freebsd.org/D57266
---
 sys/netlink/route/rt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/netlink/route/rt.c b/sys/netlink/route/rt.c
index ee17737426ed..17aae399c10a 100644
--- a/sys/netlink/route/rt.c
+++ b/sys/netlink/route/rt.c
@@ -217,7 +217,7 @@ dump_rc_nhg(struct nl_writer *nw, const struct route_nhop_data *rnd, struct rtms
 			return;
 		rtnh->rtnh_flags = 0;
 		rtnh->rtnh_ifindex = if_getindex(wn[i].nh->nh_ifp);
-		rtnh->rtnh_hops = wn[i].weight;
+		rtnh->rtnh_hops = MIN(wn[i].weight, UINT8_MAX);
 		dump_rc_nhop_gw(nw, wn[i].nh);
 		uint32_t rtflags = nhop_get_rtflags(wn[i].nh);
 		if (rtflags != base_rtflags)
@@ -242,7 +242,8 @@ dump_rc_nhg(struct nl_writer *nw, const struct route_nhop_data *rnd, struct rtms
 	}
 	nlattr_set_len(nw, off);
 	nlattr_add_u32(nw, NL_RTA_PRIORITY, nhop_metric);
-	nlattr_add_u32(nw, NL_RTA_WEIGHT, nhop_weight);
+	if (nhop_weight != RT_DEFAULT_WEIGHT)
+		nlattr_add_u32(nw, NL_RTA_WEIGHT, nhop_weight);
 }
 
 static void


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a189f0e.26ecf.5c59f70>