Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2473087ybp; Thu, 10 Oct 2019 07:54:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4hwWCl9ejpg+Uqis+L5pQI/3ycEi8a1wom/EB0EebzuwLBSeCc3gDocJqQDKEWIIXYU+D X-Received: by 2002:a05:6402:1b91:: with SMTP id cc17mr8429652edb.180.1570719288256; Thu, 10 Oct 2019 07:54:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570719288; cv=none; d=google.com; s=arc-20160816; b=P+s7Hufllod/478BePffxkGX2afeeEROqm6PRMeuJvVpzSt0NkAdxlHRWg469TbYTp wylyjIXUq5bRrtLaLR8OfV6jmHVtslbNlU6FUgcZkvUDxXGNXWpQeyLDMQGFHKyAcGRn tVUqgmFqxSldVPcdad4Jr26mKy5sgTfgcGehGQr/1Nkg+cKkHXy4BLnCdNrpj7MK3Dc/ mtfvvjJQGQCjzfKtog8UUKkDkL5w4b6NahpvO/Wt6ZYvyaN6NWkn1qH5z20fd0tdFigX jMfCtW152lqpxuU1Yh6ZdBbFt4vKEFmbcgCnwK8dyOkMVH8QESTIkGlIt4q1tsH1Smu6 pd4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=CYjcpvUgMoH2Rnzb5E+S3M0G0FDFC2sjfKceNCh279Y=; b=y5sdgB9zAJDKMv3Gsb0rjJwJm9QVWTvDd3IpEvxLv8wxOUG+XElWHvU8sPnysOGt+J WU5iIRoTSQ+WT3BsV6JhURGSFJe0bZaXBteymMys61PUhFsU8DRcJv4zOAegEWeW5YNw Lb49GNxTN+Dp7ZTs4M4G0FMVLC3C2d5KHHePUlaDMjehadGX60RMxx19ePW3KQb7vsHg C42uronLlD9gnjjDlRRrlmq9Sme0pyrc7qUp30f82AxlewBykdMqX+SJZpPZq/9Swxfo O8n1cqTz2pXVxb46u8jxe/1kZE7dwpvvESEegdawKKF2e1ZxXhC7rkwUGf1j69x86+nX JmOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x14si3238583ejw.208.2019.10.10.07.54.24; Thu, 10 Oct 2019 07:54:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726411AbfJJOvt (ORCPT + 99 others); Thu, 10 Oct 2019 10:51:49 -0400 Received: from cmccmta2.chinamobile.com ([221.176.66.80]:4741 "EHLO cmccmta2.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726166AbfJJOvs (ORCPT ); Thu, 10 Oct 2019 10:51:48 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.3]) by rmmx-syy-dmz-app07-12007 (RichMail) with SMTP id 2ee75d9f45614da-2249b; Thu, 10 Oct 2019 22:51:15 +0800 (CST) X-RM-TRANSID: 2ee75d9f45614da-2249b X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost (unknown[223.105.0.241]) by rmsmtp-syy-appsvr02-12002 (RichMail) with SMTP id 2ee25d9f4560552-55708; Thu, 10 Oct 2019 22:51:15 +0800 (CST) X-RM-TRANSID: 2ee25d9f4560552-55708 From: Haishuang Yan To: Shuah Khan , Pablo Neira Ayuso , "David S. Miller" , Simon Horman Cc: Julian Anastasov , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, lvs-devel@vger.kernel.org, netfilter-devel@vger.kernel.org, Haishuang Yan Subject: [PATCH v6 2/3] selftests: netfilter: add ipvs nat test case Date: Thu, 10 Oct 2019 22:50:54 +0800 Message-Id: <1570719055-25110-3-git-send-email-yanhaishuang@cmss.chinamobile.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1570719055-25110-1-git-send-email-yanhaishuang@cmss.chinamobile.com> References: <1570719055-25110-1-git-send-email-yanhaishuang@cmss.chinamobile.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Test virtual server via NAT. Tested: # selftests: netfilter: ipvs.sh # Testing DR mode... # Testing NAT mode... # ipvs.sh: PASS Signed-off-by: Haishuang Yan --- tools/testing/selftests/netfilter/ipvs.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/netfilter/ipvs.sh b/tools/testing/selftests/netfilter/ipvs.sh index 3d11d87..8b2e618 100755 --- a/tools/testing/selftests/netfilter/ipvs.sh +++ b/tools/testing/selftests/netfilter/ipvs.sh @@ -154,20 +154,40 @@ test_dr() { test_service } +test_nat() { + ip netns exec ns0 ip route add ${vip_v4} via ${gip_v4} dev br0 + + ip netns exec ns1 sysctl -qw net.ipv4.ip_forward=1 + ip netns exec ns1 ipvsadm -A -t ${vip_v4}:${port} -s rr + ip netns exec ns1 ipvsadm -a -m -t ${vip_v4}:${port} -r ${rip_v4}:${port} + ip netns exec ns1 ip addr add ${vip_v4}/32 dev lo:1 + + ip netns exec ns2 ip link del veth20 + ip netns exec ns2 ip route add default via ${dip_v4} dev veth21 + + test_service +} + run_tests() { local errors= echo "Testing DR mode..." + cleanup setup test_dr errors=$(( $errors + $? )) + echo "Testing NAT mode..." + cleanup + setup + test_nat + errors=$(( $errors + $? )) + return $errors } trap cleanup EXIT -cleanup run_tests if [ $? -ne 0 ]; then -- 1.8.3.1