The branch main has been updated by pouria:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=97f7b21dd52542421bc883e336e35af078af47fe

commit 97f7b21dd52542421bc883e336e35af078af47fe
Author:     Pouria Mousavizadeh Tehrani <[email protected]>
AuthorDate: 2026-05-27 09:58:34 +0000
Commit:     Pouria Mousavizadeh Tehrani <[email protected]>
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

Reply via email to