From nobody Tue Jul 28 20:57:42 2026 X-Original-To: dev-commits-src-main@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 4h8npv3kZgz6nHc9 for ; Tue, 28 Jul 2026 20:57:43 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4h8npv22y8z3LLn for ; Tue, 28 Jul 2026 20:57:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785272263; 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=W1dI0+DKD+BTaC0rAEfQLAitpsszCfg/0NfX2ZVGKs8=; b=GyDwFRfadbCsbhA37da50DsSLPBqZvwmfAx0dD17g6hCEquf4Iey4uUi/JxvgEUtENRlCt Mds+MLj9J8kIyUM7IcAWwljmcw6tkbZw0wqeAzzh6VtOXUJIfYovUpxsgcBqbcpO51ccrS LG4z6hbxn/M4B+0OKmPS9fKdotMcCk2Js4MVXB0tTvbH2OdD8LWwzJw32z9V/sdKzVG11+ mm1jMPa8b0l2umPg1qqyM5mSZqxbktmnTRkZ2v74eYnAXnDcl2XSvTT6bLLKmA9ydwE6ZJ NntdjKdSForFPv5yr2NTtvV+Mf1gmi1l2SBrjbF3svpldO+2mfDOUEveoGKkig== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785272263; a=rsa-sha256; cv=none; b=hGoyZhGMMRFYR8uhUyhDV675q3UStJxqUW+pb80P87Va+/FDZb74lRqOMmxDkMmaTyL//g b7lqlnepbE8XvjgFhCdlYhvnr9heDt2noKR8nv0RQue6kDj7r9b1ifH3PPbwRW4ki0rDDx MN84+y8aPpAYhO48NyL/4vafgOKej0B0ji+TFQAo7lTmHB+0qgNpR6RBOHZI41PHIGeFqt sEfj8NhsDDt9GSg6FSHe+liheom4MpSWH7RpcvyQjcD/0lg49eHhIPV6vEiL//pO9uzj5L AB1caveM0/KUWFtEmgLSVq/5sLmd8WEQuY3zEnbZJhdVVGS5q0mAc0f9JuHEwg== 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=1785272263; 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=W1dI0+DKD+BTaC0rAEfQLAitpsszCfg/0NfX2ZVGKs8=; b=ZxC9Zd9Gxz9Gj5lEqBBS24cSCq+Blq51PYaDJDac3kVOSgbXlfmO89m3qr4RJi1sbhx2XD EOjYamUPJlW0szw4wA8z5YidJcNk8kb85nz0lNcTa2pR1ID8oTEfzHnO6FaTU7jiBKg16R 0wrXPv8IU99Dgtfi6bGSK7MmoueVcNPPLSUW4fGvBtXUjNjE9eTrHSxNXnGyGLh5etDeof jiERWzlFcSSqv4IjYZU8dc1CF4BofIXdBZScCYHjE9X2JZRJLA5eVlUSNNfp+GoyRaTS+D Epb/cUSLkeR6B8tzIQVKLqi9AJ76ett2/x+UZzYwU6eDxCYswvQUIPezU4b2XQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h8npt5jmNzw30 for ; Tue, 28 Jul 2026 20:57:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1c6b6 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 28 Jul 2026 20:57:42 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Pouria Mousavizadeh Tehrani Subject: git: 2d0b73338ab7 - main - routing: Add tests for prefsrc route attribute List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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: 2d0b73338ab74ff47fd1a220b86f6eb15148e055 Auto-Submitted: auto-generated Date: Tue, 28 Jul 2026 20:57:42 +0000 Message-Id: <6a6917c6.1c6b6.2b5f4821@gitrepo.freebsd.org> The branch main has been updated by pouria: URL: https://cgit.FreeBSD.org/src/commit/?id=2d0b73338ab74ff47fd1a220b86f6eb15148e055 commit 2d0b73338ab74ff47fd1a220b86f6eb15148e055 Author: Pouria Mousavizadeh Tehrani AuthorDate: 2026-07-18 14:41:28 +0000 Commit: Pouria Mousavizadeh Tehrani CommitDate: 2026-07-28 20:54:38 +0000 routing: Add tests for prefsrc route attribute Add tests for both IPv4 and IPv6 routes with the prefsrc attribute. Also test IPv4 routes over IPv6 nexthops and borrow their IPv4 addresses from the loopback interface. Reviewed by: glebius Differential Revision: https://reviews.freebsd.org/D58326 --- tests/sys/net/routing/test_routing.sh | 154 ++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/tests/sys/net/routing/test_routing.sh b/tests/sys/net/routing/test_routing.sh index 644b0381bca5..b3b7e6b65a8c 100755 --- a/tests/sys/net/routing/test_routing.sh +++ b/tests/sys/net/routing/test_routing.sh @@ -26,6 +26,16 @@ jq_nhop_filter() .gateway' } +jq_get_ifaof_nhop() +{ + local nhop_id="$1" + local aifp_name="$2" + + jq -r '.statistics."route-nhop-information"."nhop-table"."rt-family".[]."nh-entry".[] | + select(.index == '${nhop_id}') | + select(."address-interface-name" == "'${aifp_name}'") | + .ifa' +} atf_test_case "add_lowest_metric" "cleanup" add_lowest_metric_head() @@ -299,6 +309,147 @@ test_ecmp_routes_by_event_cleanup() vnet_cleanup } +atf_test_case "add_v4route_with_prefsrc" "cleanup" +add_v4route_with_prefsrc_head() +{ + atf_set descr 'Test prefsrc attribute on IPv4 route' + atf_set require.user root + atf_set require.progs jq +} +add_v4route_with_prefsrc_body() +{ + local jname epair0 lo0_addr ep0_prefix testprefix nhop_id ifa + + jname="add_v4route_with_prefsrc" + lo0_addr="192.168.1.1" + ep0_prefix="172.16.1." + testprefix="10.0.0.0/24" + + vnet_init + epair0=$(vnet_mkepair) + + vnet_mkjail ${jname} ${epair0}b + + atf_check ifconfig lo0 inet ${lo0_addr}/32 alias up + atf_check ifconfig ${epair0}a inet ${ep0_prefix}1/30 up + atf_check ifconfig -j ${jname} ${epair0}b inet ${ep0_prefix}2/30 up + + # Create an IPv4 route via epair0 with loopback address as its prefsrc + atf_check -o ignore \ + route -4 add -net ${testprefix} -gateway ${ep0_prefix}2 \ + -prefsrc ${lo0_addr} + + # Check the connection + atf_check -o ignore ping -c1 -t1 ${ep0_prefix}2 + + # Verify that nexthop's ifa is set to our prefsrc + atf_check -o save:netstat \ + netstat -rn4 --libxo json + nhop_id=$(cat netstat | jq_rtentry ${testprefix} | jq '."nhop-kidx"') + atf_check -o save:netstat \ + netstat -on4W --libxo json + ifa=$(cat netstat | jq_get_ifaof_nhop ${nhop_id} lo0) + atf_check_equal "$ifa" "$lo0_addr" +} +add_v4route_with_prefsrc_cleanup() +{ + vnet_cleanup +} + +atf_test_case "add_v6route_with_prefsrc" "cleanup" +add_v6route_with_prefsrc_head() +{ + atf_set descr 'Test prefsrc attribute on IPv6 route' + atf_set require.user root + atf_set require.progs jq +} +add_v6route_with_prefsrc_body() +{ + local jname epair0 lo0_addr ep0_prefix testprefix nhop_id ifa + + jname="add_v6route_with_prefsrc" + lo0_addr="3fff::1" + ep0_prefix="3fff:a::" + testprefix="2001:db8::/48" + + vnet_init + epair0=$(vnet_mkepair) + + vnet_mkjail ${jname} ${epair0}b + + atf_check ifconfig lo0 inet6 ${lo0_addr}/128 up + atf_check ifconfig ${epair0}a inet6 ${ep0_prefix}a/127 up + atf_check ifconfig -j ${jname} ${epair0}b inet6 ${ep0_prefix}b/127 up + + # Create an IPv6 route via epair0 with loopback address as its prefsrc + atf_check -o ignore \ + route -6 add -net ${testprefix} -gateway ${ep0_prefix}b \ + -prefsrc ${lo0_addr} + + # Check the connection + atf_check -o ignore ping -c1 -t1 ${ep0_prefix}b + + # Verify that nexthop's ifa is set to our prefsrc + atf_check -o save:netstat \ + netstat -rn6 --libxo json + nhop_id=$(cat netstat | jq_rtentry ${testprefix} | jq '."nhop-kidx"') + atf_check -o save:netstat \ + netstat -on6W --libxo json + ifa=$(cat netstat | jq_get_ifaof_nhop ${nhop_id} lo0) + atf_check_equal "$ifa" "$lo0_addr" +} +add_v6route_with_prefsrc_cleanup() +{ + vnet_cleanup +} + +atf_test_case "add_v4v6route_with_prefsrc" "cleanup" +add_v4v6route_with_prefsrc_head() +{ + atf_set descr 'Test prefsrc attribute on IPv4 route over IPv6 nexthop' + atf_set require.user root + atf_set require.progs jq +} +add_v4v6route_with_prefsrc_body() +{ + local jname epair0 lo0_addr ep0_prefix testprefix nhop_id ifa + + jname="add_v4v6route_with_prefsrc" + lo0_addr="192.168.1.1" + ep0_prefix="3fff:a::" + testprefix="10.0.0.0/24" + + vnet_init + epair0=$(vnet_mkepair) + + vnet_mkjail ${jname} ${epair0}b + + atf_check ifconfig lo0 inet ${lo0_addr}/32 alias up + atf_check ifconfig ${epair0}a inet6 ${ep0_prefix}a/127 up + atf_check ifconfig -j ${jname} ${epair0}b inet6 ${ep0_prefix}b/127 up + + # Create an IPv4 route via epair0 with IPv6 nexthop + # and loopback address as its prefsrc + atf_check -o ignore \ + route -4 add -net ${testprefix} -inet6 -gateway ${ep0_prefix}b \ + -inet -prefsrc ${lo0_addr} + + # Check the connection + atf_check -o ignore ping -c1 -t1 ${ep0_prefix}b + + # Verify that nexthop's ifa is set to our prefsrc + atf_check -o save:netstat \ + netstat -rn4 --libxo json + nhop_id=$(cat netstat | jq_rtentry ${testprefix} | jq '."nhop-kidx"') + atf_check -o save:netstat \ + netstat -on6W --libxo json + ifa=$(cat netstat | jq_get_ifaof_nhop ${nhop_id} lo0) + atf_check_equal "$ifa" "$lo0_addr" +} +add_v4v6route_with_prefsrc_cleanup() +{ + vnet_cleanup +} atf_init_test_cases() { @@ -306,4 +457,7 @@ atf_init_test_cases() atf_add_test_case "add_default_metric" atf_add_test_case "delete_route_with_metric" atf_add_test_case "test_ecmp_routes_by_event" + atf_add_test_case "add_v4route_with_prefsrc" + atf_add_test_case "add_v6route_with_prefsrc" + atf_add_test_case "add_v4v6route_with_prefsrc" }