From nobody Fri Jul 08 08:55:22 2022 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 4D9BF3E659D; Fri, 8 Jul 2022 08:55:23 +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 4LfRtz1qWKz3y8C; Fri, 8 Jul 2022 08:55:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657270523; 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=huNtn2yjOq/tqargXMmxjdQDyD8KBWHtcdYG9OFoKMc=; b=HlBuXPHue2i6ahsVF1pr0fiC3Wms8tstAOLDEOAWsHwSfhovQZLAWFUAvQ1Z2pHVwY4+cW BEasQkabLKdpcQDgLMyjNiLNkEHgoPqMu7SWVJsZ3Hzu1vyJpP542nmqAliqb8XvC9Kr55 7dB+UtM2f/KkRbmQrM88kLPUJBTdaFJ5UGhZga5eshW7TzHz0mfON8kvM3zgArqK9W0Sax Q8QBNYKEq58/Uy/SJW5AOf91RF2rY6JnZ9ekPa3kiFwIzRVI7LDg++ZDRwDjrmGE2euZQM QSy0WoSlCKhnmmjsiefXhiJMp7x1T3QnG9IawDcVkEhcpCt/yVTpcSmnWvdjqQ== 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 4LfRtz0n1sz1G8K; Fri, 8 Jul 2022 08:55:23 +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 2688tMmE044793; Fri, 8 Jul 2022 08:55:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2688tMND044792; Fri, 8 Jul 2022 08:55:22 GMT (envelope-from git) Date: Fri, 8 Jul 2022 08:55:22 GMT Message-Id: <202207080855.2688tMND044792@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: 78d11a350853 - main - netinet6: add ip6_output() scope tests 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: 78d11a350853188921b84c83e32d14c8a6aa16fa Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657270523; 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=huNtn2yjOq/tqargXMmxjdQDyD8KBWHtcdYG9OFoKMc=; b=UaRcUTHRVvJWaUsyLsDHsKnnrMJCugDooEjzykMpOSh2yadYswCLg0XXyC186rVOzf1bDa gyl1jYKF8Y9RKxv9V4Rg1kccb8UjmhBwaQG0GYT8v5SL5BDS0mgkq7Feqc/HLyUJkChUun 28JdhM81fOv4T0jp6Gjwr1dG392CBXNfxAVJzKPubwTiZxlRnf/dt6JOqsrIsZ+t8JpvaV tfLTv3a7Flb+EaEL4c0QFtUHR16QhHGOCLvyP2U3FkM/kXLMe85BD6DQIX4ELr6Tg2x6ds WXafOvONzcSGLxMa+/dWSpdPuZwzIqEyj+YWDm4qv13FJVzayarcZdRSaCtYbA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657270523; a=rsa-sha256; cv=none; b=kV1Lkw21+nQNoXuzm459MNjNJgoFI6EsR9gIUumtFsRLrg/4vfqlkNhjVc/mx5vVT++IZ4 w6HsEf7CykLAkFgCeEECwIlDFWBRqgF9p7S08QhXmQtDvzK8/OgruvNLp/TJU3TDt1m1a6 DvSkB9sEbU1KQ+cIT/5RPI+B7gLu6WQ0U9ua7EIPdevV2LQvQIPx+BqFYqyRGEELUV9YMU /CMTOFFitIplt2ZL/7cg0clHnZxqUJ6s4/INL/eLcQHvyn5FZMhxTx1FL4rM9+UpWcJYlK lWtawrIc835MVjWML8e06ZO5/46ZIP0MAwzkOdmVhpNm1qsSC6nesogsfx1x9g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=78d11a350853188921b84c83e32d14c8a6aa16fa commit 78d11a350853188921b84c83e32d14c8a6aa16fa Author: Alexander V. Chernikov AuthorDate: 2022-07-07 13:08:35 +0000 Commit: Alexander V. Chernikov CommitDate: 2022-07-08 08:54:25 +0000 netinet6: add ip6_output() scope tests Differential Revision: https://reviews.freebsd.org/D35742 --- tests/sys/netinet6/test_ip6_output.py | 106 ++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/tests/sys/netinet6/test_ip6_output.py b/tests/sys/netinet6/test_ip6_output.py index be578fb88c02..a84e1f9d4d60 100644 --- a/tests/sys/netinet6/test_ip6_output.py +++ b/tests/sys/netinet6/test_ip6_output.py @@ -296,6 +296,112 @@ class TestIP6OutputNhopLL(BaseTestIP6Ouput): assert rx_obj["dst_iface_alias"] == "if1" +class TestIP6OutputScope(BaseTestIP6Ouput): + def vnet2_handler(self, vnet, obj_map, pipe): + """Generic listener that sends first received packet with metadata + back to the sender via pipw + """ + bind_ip, bind_ifp = self.wait_object(pipe) + if bind_ip is None: + os_ifname = vnet.iface_alias_map[bind_ifp].name + ll_data = ToolsHelper.get_linklocals() + bind_ip, _ = ll_data[os_ifname][0] + if bind_ifp is not None: + bind_ifp = vnet.iface_alias_map[bind_ifp].name + print("## BIND {}%{}".format(bind_ip, bind_ifp)) + self._vnet2_handler(vnet, obj_map, pipe, bind_ip, bind_ifp) + + @pytest.mark.parametrize( + "params", + [ + # sif/dif: source/destination interface (for link-local addr) + # sip/dip: source/destination ip (for non-LL addr) + # ex: OSError errno that sendto() must raise + pytest.param({"sif": "if2", "dif": "if2"}, id="same"), + pytest.param( + { + "sif": "if1", + "dif": "if2", + "ex": errno.EHOSTUNREACH, + }, + id="ll_differentif1", + ), + pytest.param( + { + "sif": "if1", + "dip": "2001:db8:b::2", + "ex": errno.EHOSTUNREACH, + }, + id="ll_differentif2", + ), + pytest.param( + { + "sip": "2001:db8:a::1", + "dif": "if2", + }, + id="gu_to_ll", + ), + ], + ) + @pytest.mark.require_user("root") + def test_output6_linklocal_scope(self, params): + """Tests simple UDP output""" + second_vnet = self.vnet_map["vnet2"] + + src_ifp = params.get("sif") + src_ip = params.get("sip") + dst_ifp = params.get("dif") + dst_ip = params.get("dip") + errno = params.get("ex", 0) + + # Sent ifp/IP to bind on + second_vnet = self.vnet_map["vnet2"] + second_vnet.pipe.send((dst_ip, dst_ifp)) + + # Wait for the child to become ready + ll_data = self.wait_object(second_vnet.pipe) + + if dst_ip is None: + # Pick LL address on dst_ifp vnet2's end + dst_ip, _ = ll_data[second_vnet.iface_alias_map[dst_ifp].name][0] + # Get local interface scope + os_ifname = self.vnet.iface_alias_map[dst_ifp].name + scopeid = socket.if_nametoindex(os_ifname) + target = (dst_ip, self.DEFAULT_PORT, 0, scopeid) + else: + target = (dst_ip, self.DEFAULT_PORT, 0, 0) + + # Bind + if src_ip is None: + ll_data = ToolsHelper.get_linklocals() + os_ifname = self.vnet.iface_alias_map[src_ifp].name + src_ip, _ = ll_data[os_ifname][0] + scopeid = socket.if_nametoindex(os_ifname) + src = (src_ip, self.DEFAULT_PORT, 0, scopeid) + else: + src = (src_ip, self.DEFAULT_PORT, 0, 0) + + s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM, socket.IPPROTO_UDP) + s.bind(src) + data = bytes("AAAA", "utf-8") + print("## TX packet {} -> {}".format(src, target)) + + try: + s.sendto(data, target) + except OSError as e: + if not errno: + raise + assert e.errno == errno + print("Correctly raised {}".format(e)) + return + + # Wait for the received object + rx_obj = self.wait_object(second_vnet.pipe) + assert rx_obj["dst_ip"] == dst_ip + assert rx_obj["src_ip"] == src_ip + # assert rx_obj["dst_iface_alias"] == "if2" + + class TestIP6OutputMulticast(BaseTestIP6Ouput): def vnet2_handler(self, vnet, obj_map, pipe): group = self.wait_object(pipe)