From nobody Mon Jan 23 08:23:06 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 4P0jlv1Nd0z312V3; Mon, 23 Jan 2023 08:23:07 +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 4P0jlt6NrZz4381; Mon, 23 Jan 2023 08:23:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674462186; 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=GILxgg7/X081aMc4bY0pieymV55BOQXsa0x07g4gE7g=; b=wqb82qnj/ehBZwAJKkEr1u+SqgVW+FLyx9sKCAssmwn/twQ0hyXvCiFF+Qjw1obYmUhuxX BhDk/h6aOX/gguwowFd8ox0lrQ4bciPF4aP/YvHRAFjpBH7IfI/6NxUgRT6CQu9jQcDzHQ M2AsNh4C8AfXwZkc3sZhQRnsciWynUT44ragdSsD8gtD8g9q1yHuYzMEs78p1mdp/X1Tc0 NoVI1GUH7DCufs9rlQvu1W0zdRS0TBzRPCT0x1lsHtTEyqLIcmyNO7xKrK9RyfaUVNt2/x Rk6/ZrWrPyg50dIOitzl0tkkMVe1JRQE8TBQMfvYCpKMeId7W+olyhZsmhNQ2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674462186; 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=GILxgg7/X081aMc4bY0pieymV55BOQXsa0x07g4gE7g=; b=kbir88gFiFZDvAbeWktsK/3wf17aezrMc1w2Uu3v73BTEteUjA1vg6tWh1vuWV+sNQ1THg SP/qIb2P2zpDwhZFGH3jg6TqJ76hmd/YCgrW0BAagLZ6QiKLOdB6nzTXvB95nM6SU24BM9 mEaBjbrx1SbeHVd5RUJIGY99QzExeHQbQDFhMH2kYYbHGGE+PWMeTrztoobOIg28wWFMP3 BaAxsZ6v2elouDtiRhapecdvxsMSOTRJjWa+OWNOLgAp7FkLVZRMeNW6BUK7jax6KCSaVK GpkD4YoEUWirxEbt8U31kRS82p/armqfhJ92pVOeWk2VD86noTnUkeO0srTVig== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674462186; a=rsa-sha256; cv=none; b=jUuDvKFXOI5mDfm32GePr+DM0QFK7ZFNruXEd7DRWJM9opT0spolSQZvbr98UxfxT7kkhz TDrBTyzYszlbt60tw1v7mZGRqX59ioN3etfDJQFh8yL1tV/7TbUEa0MDt91t1kvLvW+9jH Ytet798dgPpxo0jDNYcaDI4+jnyTySCGraC5/6+Rv/GzfKUlvPBFB0QB7s3up63Zw0Rjuo z0C7lFrHJhTMBaGMo5AMZwVh5AVX/E4GecrbjFyWqlRxDZanKG6vy6JmGK+P07VJhBeEvw fLW6HwjIXBajAQoas6xmWl4GFH7lxwLDoOquUTPp+QRn4Yy1ra276MMNhl/lHw== 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 4P0jlt5QrczNGZ; Mon, 23 Jan 2023 08:23:06 +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 30N8N6dv027966; Mon, 23 Jan 2023 08:23:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30N8N6TK027965; Mon, 23 Jan 2023 08:23:06 GMT (envelope-from git) Date: Mon, 23 Jan 2023 08:23:06 GMT Message-Id: <202301230823.30N8N6TK027965@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: fbdde1029e92 - stable/13 - pf tests: properly destroy renamed interfaces 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: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fbdde1029e9202cf44ed3ce3e38a4d11e418eda5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=fbdde1029e9202cf44ed3ce3e38a4d11e418eda5 commit fbdde1029e9202cf44ed3ce3e38a4d11e418eda5 Author: Kajetan Staszkiewicz AuthorDate: 2023-01-16 06:19:41 +0000 Commit: Kristof Provost CommitDate: 2023-01-23 02:26:25 +0000 pf tests: properly destroy renamed interfaces The pfsync:pbr tests leaves lot of interfaces when they finish, making other tests slower due to long time of loading scapy from pft_ping.py when more interfaces are present. When both sides of epair are assigned to jails, they are both removed from created_interfaces.lst and thus won't be removed during cleanup from this file. An interface assigned to jail is stored in created_jails.lst but if it is renamed, it won't be cleaned up either. Furthermore this test uses identical names for multiple interfaces across multiple jails which after destroying those jails adds to overall confusion. To address this issue a new function is provided for renaming interfaces in jails and storing their new names in created_jails.lst for deletion during cleanup. MFC after: 1 week Sponsored by: InnoGames GmbH Differential Revision: https://reviews.freebsd.org/D38024 (cherry picked from commit ddcdb534b7669f186184baf164e7647d544f7bd6) --- tests/sys/common/vnet.subr | 10 ++++++ tests/sys/netpfil/pf/pfsync.sh | 77 ++++++++++++------------------------------ 2 files changed, 31 insertions(+), 56 deletions(-) diff --git a/tests/sys/common/vnet.subr b/tests/sys/common/vnet.subr index 590e8dea992e..9ba41ec3c365 100644 --- a/tests/sys/common/vnet.subr +++ b/tests/sys/common/vnet.subr @@ -53,6 +53,16 @@ vnet_mkjail() echo $jailname >> created_jails.lst } +vnet_ifrename_jail() +{ + jailname=$1 + ifname=$2 + ifnewname=$3 + + jexec ${jailname} ifconfig $ifname name $ifnewname + sed -i "" "/^${jailname}/s/${ifname}/${ifnewname}/" created_jails.lst +} + vnet_cleanup() { if [ -f created_jails.lst ]; then diff --git a/tests/sys/netpfil/pf/pfsync.sh b/tests/sys/netpfil/pf/pfsync.sh index 8929e14ec7dd..bbe3fbcb1d2a 100644 --- a/tests/sys/netpfil/pf/pfsync.sh +++ b/tests/sys/netpfil/pf/pfsync.sh @@ -413,12 +413,11 @@ pbr_common_body() alias 198.18.1.10/32 vhid 11 pass 3WjvVVw7 advskew 50 jexec gw_route_to_master sysctl net.inet.ip.forwarding=1 jexec gw_route_to_master sysctl net.inet.carp.preempt=1 - jexec gw_route_to_master ifconfig ${epair_sync_gw_route_to}a name if_pfsync - sed -i '' -e 's/'${epair_sync_gw_route_to}'a/if_pfsync/g' created_interfaces.lst - jexec gw_route_to_master ifconfig ${epair_gw_route_to_master_bridge0}a name if_br0 - sed -i '' -e 's/'${epair_gw_route_to_master_bridge0}'a/if_br0/g' created_interfaces.lst - jexec gw_route_to_master ifconfig ${epair_gw_route_to_master_bridge1}a name if_br1 - sed -i '' -e 's/'${epair_gw_route_to_master_bridge1}'a/if_br1/g' created_interfaces.lst + + vnet_ifrename_jail gw_route_to_master ${epair_sync_gw_route_to}a if_pfsync + vnet_ifrename_jail gw_route_to_master ${epair_gw_route_to_master_bridge0}a if_br0 + vnet_ifrename_jail gw_route_to_master ${epair_gw_route_to_master_bridge1}a if_br1 + jexec gw_route_to_master ifconfig pfsync0 \ syncpeer 198.19.10.2 \ syncdev if_pfsync \ @@ -447,12 +446,11 @@ pbr_common_body() alias 198.18.1.10/32 vhid 11 pass 3WjvVVw7 advskew 100 jexec gw_route_to_backup sysctl net.inet.ip.forwarding=1 jexec gw_route_to_backup sysctl net.inet.carp.preempt=1 - jexec gw_route_to_backup ifconfig ${epair_sync_gw_route_to}b name if_pfsync - sed -i '' -e 's/'${epair_sync_gw_route_to}'b/if_pfsync/g' created_interfaces.lst - jexec gw_route_to_backup ifconfig ${epair_gw_route_to_backup_bridge0}a name if_br0 - sed -i '' -e 's/'${epair_gw_route_to_backup_bridge0}'a/if_br0/g' created_interfaces.lst - jexec gw_route_to_backup ifconfig ${epair_gw_route_to_backup_bridge1}a name if_br1 - sed -i '' -e 's/'${epair_gw_route_to_backup_bridge1}'a/if_br1/g' created_interfaces.lst + + vnet_ifrename_jail gw_route_to_backup ${epair_sync_gw_route_to}b if_pfsync + vnet_ifrename_jail gw_route_to_backup ${epair_gw_route_to_backup_bridge0}a if_br0 + vnet_ifrename_jail gw_route_to_backup ${epair_gw_route_to_backup_bridge1}a if_br1 + jexec gw_route_to_backup ifconfig pfsync0 \ syncpeer 198.19.10.1 \ syncdev if_pfsync \ @@ -480,12 +478,11 @@ pbr_common_body() alias 198.18.2.20/32 vhid 22 pass 3WjvVVw7 advskew 50 jexec gw_reply_to_master sysctl net.inet.ip.forwarding=1 jexec gw_reply_to_master sysctl net.inet.carp.preempt=1 - jexec gw_reply_to_master ifconfig ${epair_sync_gw_reply_to}a name if_pfsync - sed -i '' -e 's/'${epair_sync_gw_reply_to}'a/if_pfsync/g' created_interfaces.lst - jexec gw_reply_to_master ifconfig ${epair_gw_reply_to_master_bridge1}a name if_br1 - sed -i '' -e 's/'${epair_gw_reply_to_master_bridge1}'a/if_br1/g' created_interfaces.lst - jexec gw_reply_to_master ifconfig ${epair_gw_reply_to_master_bridge2}a name if_br2 - sed -i '' -e 's/'${epair_gw_reply_to_master_bridge2}'a/if_br2/g' created_interfaces.lst + + vnet_ifrename_jail gw_reply_to_master ${epair_sync_gw_reply_to}a if_pfsync + vnet_ifrename_jail gw_reply_to_master ${epair_gw_reply_to_master_bridge1}a if_br1 + vnet_ifrename_jail gw_reply_to_master ${epair_gw_reply_to_master_bridge2}a if_br2 + jexec gw_reply_to_master ifconfig pfsync0 \ syncpeer 198.19.20.2 \ syncdev if_pfsync \ @@ -513,12 +510,11 @@ pbr_common_body() alias 198.18.2.20/32 vhid 22 pass 3WjvVVw7 advskew 100 jexec gw_reply_to_backup sysctl net.inet.ip.forwarding=1 jexec gw_reply_to_backup sysctl net.inet.carp.preempt=1 - jexec gw_reply_to_backup ifconfig ${epair_sync_gw_reply_to}b name if_pfsync - sed -i '' -e 's/'${epair_sync_gw_reply_to}'b/if_pfsync/g' created_interfaces.lst - jexec gw_reply_to_backup ifconfig ${epair_gw_reply_to_backup_bridge1}a name if_br1 - sed -i '' -e 's/'${epair_gw_reply_to_backup_bridge1}'a/if_br1/g' created_interfaces.lst - jexec gw_reply_to_backup ifconfig ${epair_gw_reply_to_backup_bridge2}a name if_br2 - sed -i '' -e 's/'${epair_gw_reply_to_backup_bridge2}'a/if_br2/g' created_interfaces.lst + + vnet_ifrename_jail gw_reply_to_backup ${epair_sync_gw_reply_to}b if_pfsync + vnet_ifrename_jail gw_reply_to_backup ${epair_gw_reply_to_backup_bridge1}a if_br1 + vnet_ifrename_jail gw_reply_to_backup ${epair_gw_reply_to_backup_bridge2}a if_br2 + jexec gw_reply_to_backup ifconfig pfsync0 \ syncpeer 198.19.20.1 \ syncdev if_pfsync \ @@ -580,43 +576,12 @@ pbr_common_body() sleep 1 done - # As cleanup is long and may lead to a timeout, - # it's run directly into the body part. - # (as cleanup timeout is not settable) - jail -r \ - client \ - gw_route_to_master \ - gw_route_to_backup \ - gw_reply_to_master \ - gw_reply_to_backup \ - server - for ifname in $(grep -E -e 'if_' -e 'epair.*a' -e 'bridge' created_interfaces.lst) - do - ifconfig $ifname >/dev/null 2>&1 && ifconfig $ifname destroy - done - atf_check -s exit:0 -e ignore -o ignore grep ', 0.0% packet loss' ping.stdout } pbr_common_cleanup() { - for jailname in client gw_route_to_master gw_route_to_backup gw_reply_to_master gw_reply_to_backup server - do - if $(jls | grep -q $jailname); then - jail -r $jailname - else - echo "$jailname already cleaned" - fi - done - for ifname in $(grep -E -e 'if_' -e 'epair.*a' -e 'bridge' created_interfaces.lst) - do - ifconfig $ifname >/dev/null 2>&1 - if [ "$?" -eq "0" ]; then - ifconfig $ifname destroy - else - echo "$ifname already destroyed" - fi - done + pft_cleanup } atf_init_test_cases()