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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user