From nobody Sat Apr 08 19:45:09 2023 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 4Pv5LG0Q7Qz44nqS; Sat, 8 Apr 2023 19:45:10 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Pv5LF1sFcz4536; Sat, 8 Apr 2023 19:45:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680983109; 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=87dO9jQ1RVyIYLOvDV3AFLETBw99/zO2HWxDmT4v5kM=; b=Tp4IleTX0GQsHy42K4BQpiMspYctz3sCcVAt05MZwM1ssOlzr3TNrvoZMESSbYdkv6a/BV 5w9yPPPM2GvfR3lDPHjuzoWEcy+e9RBJq57JvoRD1SXMHAteuuaWvgOf47mMKdGbte6RPC lqFtYSGuxujZon3ygH1t1fua9T1wDON043PK2jN0STlaaKHpufVqIfPOawnoCG3uIMulqv XhaKVIK7/39vifpsQuvyGnpT5xbWPc9myRMkSwvadAfMgp7pfTTwM7x5UYb5UadU06e2pp S2STEt+ImUcZ+bmw9BVqIy9d9ou3+NLMuHFmnOaKW684qpmhyDHq+v9ZrvyfMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680983109; 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=87dO9jQ1RVyIYLOvDV3AFLETBw99/zO2HWxDmT4v5kM=; b=UqCQujbt7vRco8znK/AtcEtujdSPIcoON7I00pxHUqgOY55f5aFPc6LjET3MnxAOL0xGQq fK+tcjwsKcVMXDH3Ev31RC1a6lCRK9ON8OmNJqV//QaJqm5EA9Tbc0Yp4UrxaTraOK1pif AeVtveU8xZHxNAU+N0NX93sigSbG3WmlaE9Fy3PWkvLRjgSl4vaHt9FyO6VCNgj8Jc4Nsr eQjAAH42LVWLnyvcgG2P/GvAMp+VvIT4q/qYy2ZU1HLSu8GAl7UZPfevnE/yKtni0ee678 JYUTRoZu4p+Ag65YvigNQ/fTxCaXjvWNl1J7Oqx3+AIKiUm8RLf4n3uPdqsb3Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1680983109; a=rsa-sha256; cv=none; b=NZnNY9s+PXLM2TPiW5wE5SFwwXVwCc81tFlWsk/aFDZRDG9I4i6qGh76am/KKWxaxeYKDI Tzp8z8bUDwxQXHa12RDlb9BI52cCCypaTvWxqJ8h/bXOw8QRJVqD0NG5Ux4vFwQ8PEcNQ6 xNAVWFP6Nb9Hd6OXVFXxOJneFTSXhjgdXpUPmuID/smKt9/Oo7ytV6Vjlz27q+ECj/Di/L SMvMrvRIxm2E3bp5P5TgGo8q2K7SMpZ6y2PvrgozuCaH015htZ4Dsmz2lfbFf9BmGvpoZZ tCpNmPgvGqW7JvAce8yHzVIItBqLl2Zco+wooXpuQafF25oQGBVGAup9elaK9g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Pv5LF0yX9zfxb; Sat, 8 Apr 2023 19:45:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 338Jj9HT019054; Sat, 8 Apr 2023 19:45:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 338Jj9rV019053; Sat, 8 Apr 2023 19:45:09 GMT (envelope-from git) Date: Sat, 8 Apr 2023 19:45:09 GMT Message-Id: <202304081945.338Jj9rV019053@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: e18df856ef9a - stable/13 - routing: fix panic when adding an interface route to the p2p interface without and inet/inet6 addresses attached. 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e18df856ef9a87339f179faafac2219335245662 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=e18df856ef9a87339f179faafac2219335245662 commit e18df856ef9a87339f179faafac2219335245662 Author: Alexander V. Chernikov AuthorDate: 2023-03-29 20:28:24 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-04-08 19:19:24 +0000 routing: fix panic when adding an interface route to the p2p interface without and inet/inet6 addresses attached. MFC after: 3 days (cherry picked from commit badcb3fd5710a511e35ac3afd724ef68c77614b7) --- sys/net/if.c | 2 +- tests/sys/net/routing/test_routing_l3.py | 39 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/sys/net/if.c b/sys/net/if.c index 9de81b7da248..f53b98aca923 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -2133,7 +2133,7 @@ ifaof_ifpforaddr(const struct sockaddr *addr, struct ifnet *ifp) continue; } if (ifp->if_flags & IFF_POINTOPOINT) { - if (sa_equal(addr, ifa->ifa_dstaddr)) + if (ifa->ifa_dstaddr && sa_equal(addr, ifa->ifa_dstaddr)) goto done; } else { cp = addr->sa_data; diff --git a/tests/sys/net/routing/test_routing_l3.py b/tests/sys/net/routing/test_routing_l3.py index 74017ae0459c..3a3822293424 100755 --- a/tests/sys/net/routing/test_routing_l3.py +++ b/tests/sys/net/routing/test_routing_l3.py @@ -1,7 +1,13 @@ import ipaddress +import socket import pytest +from atf_python.sys.net.rtsock import RtConst +from atf_python.sys.net.rtsock import Rtsock +from atf_python.sys.net.rtsock import RtsockRtMessage +from atf_python.sys.net.rtsock import SaHelper from atf_python.sys.net.tools import ToolsHelper +from atf_python.sys.net.vnet import SingleVnetTestTemplate from atf_python.sys.net.vnet import VnetTestTemplate @@ -79,3 +85,36 @@ class TestIfOps(VnetTestTemplate): nhops = ToolsHelper.get_nhops(family) nh = [nh for nh in nhops if nh["index"] == nhop_kidx][0] assert nh["ifa"] == str(second_addr.ip) + + +class TestRouteCornerCase1(SingleVnetTestTemplate): + @pytest.mark.parametrize("family", ["inet", "inet6"]) + @pytest.mark.require_user("root") + def test_add_direct_route_p2p_wo_ifa(self, family): + + tun_ifname = ToolsHelper.get_output("/sbin/ifconfig tun create").rstrip() + tun_ifindex = socket.if_nametoindex(tun_ifname) + assert tun_ifindex > 0 + rtsock = Rtsock() + + if family == "inet": + prefix = "172.16.0.0/12" + else: + prefix = "2a02:6b8::/64" + IFT_ETHER = 0x06 + gw_link = SaHelper.link_sa(ifindex=tun_ifindex, iftype=IFT_ETHER) + + msg = rtsock.new_rtm_add(prefix, gw_link) + msg.add_link_attr(RtConst.RTA_IFP, tun_ifindex) + rtsock.write_message(msg) + + data = rtsock.read_data(msg.rtm_seq) + msg_in = RtsockRtMessage.from_bytes(data) + msg_in.print_in_message() + + desired_sa = { + RtConst.RTA_DST: msg.get_sa(RtConst.RTA_DST), + RtConst.RTA_NETMASK: msg.get_sa(RtConst.RTA_NETMASK), + } + + msg_in.verify(msg.rtm_type, desired_sa)