git: 7982875dc4bc - stable/14 - rtnetlink: Use default weight for unset weights in NHA_GROUP
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 27 Nov 2026 09:07:33 UTC
The branch stable/14 has been updated by pouria:
URL: https://cgit.FreeBSD.org/src/commit/?id=7982875dc4bc44ff1b1d11a7bf8b83aa53fe8d50
commit 7982875dc4bc44ff1b1d11a7bf8b83aa53fe8d50
Author: Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
AuthorDate: 2026-11-13 21:40:45 +0000
Commit: Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
CommitDate: 2026-11-27 06:34:47 +0000
rtnetlink: Use default weight for unset weights in NHA_GROUP
newnhg() copied the weights of a nhgrp as is and a group
whose members all have a zero weight, which is what
userland sends when it leaves the weight unset, made
calc_min_mpath_slots_fast() divide by zero.
Therefore replace weight of zero with RT_DEFAULT_WEIGHT.
While here, return early from calc_min_mpath_slots_fast()
if all weights are zero.
MFC after: 3 days
Fixes: 7e5bf68495cc ("netlink: add netlink support")
(cherry picked from commit 1db6e2c6c3554efe5acdcc20bc7aa889e1efe372)
---
sys/net/route/nhgrp_ctl.c | 2 +-
sys/netlink/route/nexthop.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/sys/net/route/nhgrp_ctl.c b/sys/net/route/nhgrp_ctl.c
index 77062eefefd8..78de6d5dadfa 100644
--- a/sys/net/route/nhgrp_ctl.c
+++ b/sys/net/route/nhgrp_ctl.c
@@ -166,7 +166,7 @@ calc_min_mpath_slots_fast(struct weightened_nhop *wn, size_t num_items,
}
*ptotal = total;
/* xmin is the minimum unit of desired capacity */
- if ((total % xmin) != 0)
+ if (xmin == 0 || (total % xmin) != 0)
return (0);
for (i = 0; i < num_items; i++) {
if ((wn[i].weight % xmin) != 0)
diff --git a/sys/netlink/route/nexthop.c b/sys/netlink/route/nexthop.c
index e7f08f2f8f3a..a659507414fa 100644
--- a/sys/netlink/route/nexthop.c
+++ b/sys/netlink/route/nexthop.c
@@ -782,7 +782,7 @@ newnhg(struct unhop_ctl *ctl, struct nl_parsed_nhop *attrs, struct user_nhop *un
* restrict nexthops with the same gateway
*/
wn[i].nh = unhop->un_nhop_src;
- wn[i].weight = grp[i].weight;
+ wn[i].weight = grp[i].weight > 0 ? grp[i].weight : RT_DEFAULT_WEIGHT;
}
unhop->un_nhgrp_src = wn;
unhop->un_nhgrp_count = count;