From nobody Thu Apr 30 22:07:49 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4g67Zs6bjdz6cMbC for ; Thu, 30 Apr 2026 22:07:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4g67Zs5pjyz3k6r for ; Thu, 30 Apr 2026 22:07:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777586869; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=X3sCDpBsYakALu5wRvVbwyum44Yb+iBfePuV/usxE9s=; b=RcSdbZZQsDJxLCZutCs+ANQryEZvKVSalSTlqFV96isAMVyvK1KgZPjWDeRJjj6qcWo7eg A2CPWch5tC2/S1Y5S1jhCzsJrTr7imp6Z9wsyZaCSQqm5iia/ca57CC2qM2ZXOYUt3Z6T6 i1O4sjy7O9FuFHCdcMhV1Ici3R7yNhH/QmcRAcVLL69Zhq0jtRdAkibqqMa+O8rcD/NfaB 8DsDWI77trn21wc+OGzbtwVOlo8VmVsqb7ISbhYVidag/oBT7ubtLSsOC2GbtSJ2HU7SKZ b2s6WW50fYdefqD4QSykOBwTBln1WxwPEBQoJgn0LnGGEc7qaQCkuh/2vxqO1g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1777586869; a=rsa-sha256; cv=none; b=xIdKgNn0IDely2c0roRK7ZVIolwPcoEVDR4ZT8ByQCIwIm6c6B+2XVs5DY48itNR+5psuK RyT3DBAa0DOm7yFB7eP8hjCw8asbF9bbiS+PNwQggdDcC9nGxtXTCopzRWUcVEsQ9D5Nki kzpFEoJ8TucMhbkAIongeN9FtSbOGJbfpCKQXApLNpHdbYhE8ZJd5qWh/YXmBXVqZEM6c+ K0Eu817GLsvcvlX4WW4Ts2h1vLutpKA8hfNyp27er/VWKzidHKY+IYZ2yc3qYEUG7PbWlu gmHtWu4cwNOBIHbx2VeXXGSf/nVH0pj8FmVBUDrz26T0Q4Z2xrZlThHQ2EzHwg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777586869; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=X3sCDpBsYakALu5wRvVbwyum44Yb+iBfePuV/usxE9s=; b=eorI7i/LotTrE9Q5w2so0EL6FWT6S2tTBlbiqpxQKbyZpGc6NLUR9kF8jAyJH8UBe7PPwE ScVobyHxUgSK3dgTMLF/EL9I3qwuJgdNxGC7NWsyyqqf6v0QFzLSDUM+OqCAUVROE+2OTp m6w89C9euVM4RzqTv2hlUh53swYMzNECvv6RoxTlrBohxEduANx0ySoN8uMP4H4Yj72v+c Xe/5E0Z65ZSwt4heZ5b5ppdfcwkJipHI0/HpXJJ1XOz4qNm8Axyf2QC1UNu9lkTR0VQRi5 w0k7ZmHrKiKHIDUxsC01SqeaFcy8lFHs2XYOUhIOF3qJxrkUHqGxJoQJjw9vpA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4g67Zs4Kr5zVgb for ; Thu, 30 Apr 2026 22:07:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1c7b7 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 30 Apr 2026 22:07:49 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Pouria Mousavizadeh Tehrani Subject: git: 84bb3648d215 - main - netlink: Fix RTA_MULTIPATH on RTM_GETROUTE List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pouria X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 84bb3648d2151576ebd707b592942a1fd77aa2c4 Auto-Submitted: auto-generated Date: Thu, 30 Apr 2026 22:07:49 +0000 Message-Id: <69f3d2b5.1c7b7.7d20d1f5@gitrepo.freebsd.org> The branch main has been updated by pouria: URL: https://cgit.FreeBSD.org/src/commit/?id=84bb3648d2151576ebd707b592942a1fd77aa2c4 commit 84bb3648d2151576ebd707b592942a1fd77aa2c4 Author: Pouria Mousavizadeh Tehrani AuthorDate: 2026-04-08 19:16:35 +0000 Commit: Pouria Mousavizadeh Tehrani CommitDate: 2026-04-30 22:05:44 +0000 netlink: Fix RTA_MULTIPATH on RTM_GETROUTE Before this patch, netlink never returned RTA_MULTIPATH. Also, add RTA_MULTIPATH attribute in way that don't confuse non-mpath support consumers. Differential Revision: https://reviews.freebsd.org/D56188 --- sys/netlink/route/rt.c | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/sys/netlink/route/rt.c b/sys/netlink/route/rt.c index 39ae65217620..cb2d737f34e3 100644 --- a/sys/netlink/route/rt.c +++ b/sys/netlink/route/rt.c @@ -175,18 +175,36 @@ dump_rc_nhop_mtu(struct nl_writer *nw, const struct nhop_object *nh) } static void -dump_rc_nhg(struct nl_writer *nw, const struct nhgrp_object *nhg, struct rtmsg *rtm) +dump_rc_nhg(struct nl_writer *nw, const struct route_nhop_data *rnd, struct rtmsg *rtm) { - uint32_t uidx = nhgrp_get_uidx(nhg); - uint32_t num_nhops, nh_expire; - const struct weightened_nhop *wn = nhgrp_get_nhops(nhg, &num_nhops); - uint32_t base_rtflags = nhop_get_rtflags(wn[0].nh); + const struct nhgrp_object *nhg = rnd->rnd_nhgrp; + const struct weightened_nhop *wn; + struct nhop_object *nh; + uint32_t uidx, num_nhops, nh_expire; + uint32_t base_rtflags, rtflags, nhop_weight; + MPASS((NH_IS_NHGRP(rnd->rnd_nhop))); + + /* select a nhop from nhgrp to not confuse non-mpath consumers */ + nhop_weight = RT_DEFAULT_WEIGHT; + nh = nhop_select_func(rnd->rnd_nhop, 0); + rtflags = nhop_get_rtflags(nh); + if (nh->nh_flags & NHF_GATEWAY) + dump_rc_nhop_gw(nw, nh); + + wn = nhgrp_get_nhops(nhg, &num_nhops); + base_rtflags = nhop_get_rtflags(wn[0].nh); + uidx = nhgrp_get_uidx(nhg); if (uidx != 0) nlattr_add_u32(nw, NL_RTA_NH_ID, uidx); nlattr_add_u32(nw, NL_RTA_KNH_ID, nhgrp_get_idx(nhg)); - nlattr_add_u32(nw, NL_RTA_RTFLAGS, base_rtflags); + + if (rtflags & RTF_FIXEDMTU) + dump_rc_nhop_mtu(nw, nh); + /* In any case, fill outgoing interface */ + nlattr_add_u32(nw, NL_RTA_OIF, if_getindex(nh->nh_ifp)); + int off = nlattr_add_nested(nw, NL_RTA_MULTIPATH); if (off == 0) return; @@ -209,6 +227,9 @@ dump_rc_nhg(struct nl_writer *nw, const struct nhgrp_object *nhg, struct rtmsg * if (nh_expire > 0) nlattr_add_u32(nw, NL_RTA_EXPIRES, nh_expire - time_uptime); rtnh = nlattr_restore_offset(nw, nh_off, struct rtnexthop); + + if (nh == wn[i].nh) + nhop_weight = wn[i].weight; /* * nlattr_add() allocates 4-byte aligned storage, no need to aligh * length here @@ -216,6 +237,7 @@ dump_rc_nhg(struct nl_writer *nw, const struct nhgrp_object *nhg, struct rtmsg * rtnh->rtnh_len = nlattr_save_offset(nw) - nh_off; } nlattr_set_len(nw, off); + nlattr_add_u32(nw, NL_RTA_WEIGHT, nhop_weight); } static void @@ -225,7 +247,7 @@ dump_rc_nhop(struct nl_writer *nw, const struct route_nhop_data *rnd, struct rtm uint32_t rtflags, uidx, nh_expire; if (NH_IS_NHGRP(rnd->rnd_nhop)) { - dump_rc_nhg(nw, rnd->rnd_nhgrp, rtm); + dump_rc_nhg(nw, rnd, rtm); return; } @@ -324,7 +346,10 @@ dump_px(uint32_t fibnum, const struct nlmsghdr *hdr, rtm = nlattr_restore_offset(nw, rtm_off, struct rtmsg); if (plen > 0) rtm->rtm_dst_len = plen; - dump_rc_nhop(nw, rnd, rtm); + if (NH_IS_NHGRP(rnd->rnd_nhop)) + dump_rc_nhg(nw, rnd, rtm); + else + dump_rc_nhop(nw, rnd, rtm); if (nlmsg_end(nw)) return (0); @@ -655,7 +680,6 @@ handle_rtm_getroute(struct nlpcb *nlp, struct nl_parsed_route *attrs, } rt_get_rnd(rt, &rnd); - rnd.rnd_nhop = nhop_select_func(rnd.rnd_nhop, 0); RIB_RUNLOCK(rnh);