From nobody Wed Mar 29 20:29:36 2023 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 4Pmyp835DCz41pYL; Wed, 29 Mar 2023 20:29:36 +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 4Pmyp82W7qz3n5d; Wed, 29 Mar 2023 20:29:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680121776; 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=ucRyY92svluETEWwTr+CU8NBOuQuZNV8/uVIPPlP+4w=; b=RN1J5UYo5pwUBJ3Ka+y+Ia4uBixf0Z4NScueS4I/9klBJ9UESGzGjaZjt28IRv4r3H3/MM tkylOo9bqyuo78lRW9k65JeMLffsYkZn+p8n/rKUhlqckTb4Gd6ZiwWhsGdTM6KbPLU5z9 pzucXlsZj7vD3ztsb5iXb5B3EFqDA+q3la1AOHQNSy24CgLs8l4G6JSShFkZrbmFSSQ0uI cGu1x01Pibqc2g7AOAkMOEwxO4xCt1eSb/m/u6m9mBns5nlfxasSpF+EkGliHzjUaQzp9a ORTxMY8P2e+lU49JTQ8KwM3cl3PkYw+bckqsUeLmEM3ohZsW4VjCMmTm2Colng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680121776; 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=ucRyY92svluETEWwTr+CU8NBOuQuZNV8/uVIPPlP+4w=; b=noMjbl5Wjzm8VO9pV4jqwL8aFSdDujlg6wrpsliAVwFUiuODCbouqJgM7vtjPcQzg21/Dm v8zls+9BeM7PWyWftW7RhbTIS/U8B7dwRlPAwQCIL5Ut54aRvxp1fkVzRCLOdX54T5xfHN NDe85NsxEU/fdNC3RL0q3lDdF5sgejXHI984UXTBInuZ5JgLfXojixK9YDOiftyVnLIjJU 8fyNo/orYOVsn+Wvr0wieXmLM1OSQrPonANRZWFdeVVFvgvutsVZYQxzad9UESNq1GG3Dk SJllehMKiZLhwSdQVTh0udLa+p7QPfarlWl+AbhaMWxRum6sRf81IWHNAY1tEQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1680121776; a=rsa-sha256; cv=none; b=a5zqTtyejpQlR3OZUS334nUBHi7cH4F4yBDQmpanG27GFgERNtZEh/Q0A3vL8FHuzLQxkb NkNzfhFs5bJznvW5PzChYzf1wArgU51xgbOohGffJCRwsZfybzstJ13+UrMGY7zV48YjXJ q1OIBx29xBcFSJq2RZofUk9Bcqxt2ph8KW2492yKtpq49TXWb6HZTtOF4xKCK4aTt/Tb3w qyAA8WamRA/251SyR3q9SU0cyHR3OOSWw/Llotzo1EYPdih344qRNkcLFgRre2fdNZ7HW5 CxwHnx8uQsM/BdiRqogAbGb/T50Bg9A2/QFF+xqVD3+1QgOzgxh+aAV/kYaEfg== 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 4Pmyp81ZlGzkMB; Wed, 29 Mar 2023 20:29:36 +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 32TKTasp087285; Wed, 29 Mar 2023 20:29:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32TKTaOh087284; Wed, 29 Mar 2023 20:29:36 GMT (envelope-from git) Date: Wed, 29 Mar 2023 20:29:36 GMT Message-Id: <202303292029.32TKTaOh087284@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: badcb3fd5710 - main - routing: fix panic when adding an interface route to the p2p interface without and inet/inet6 addresses attached. 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: badcb3fd5710a511e35ac3afd724ef68c77614b7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=badcb3fd5710a511e35ac3afd724ef68c77614b7 commit badcb3fd5710a511e35ac3afd724ef68c77614b7 Author: Alexander V. Chernikov AuthorDate: 2023-03-29 20:28:24 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-03-29 20:28:24 +0000 routing: fix panic when adding an interface route to the p2p interface without and inet/inet6 addresses attached. MFC after: 3 days --- 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 ff942bceb090..4b3b7d5b121b 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -2056,7 +2056,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)