Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp784078ybp; Wed, 9 Oct 2019 04:17:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwbSs91aaukxaG6kB/l/JBvgsWE3zIqBzv20GioClnP3VTDK/Fr1+Pj6QbosZKNOLlA2HJ9 X-Received: by 2002:a50:ed06:: with SMTP id j6mr2419711eds.274.1570619871337; Wed, 09 Oct 2019 04:17:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570619871; cv=none; d=google.com; s=arc-20160816; b=tUEKXwxvOJH5nHcY5f8JnK1a11h7CgLEE3kPhAJS/A7KWW2k6CiarZxZSZ/O3M9oGL AkmIlGekmJ2owh9lzfpK0+PI1nqgaxegTLv7jXIA8hqh4zRMnVuIJstSURPOXcwLtLFE rZFHPYJRT0VrQzQbKXWshkNTVOinADa2untO0lAK75aI2q4ukm7AfiU7oM1fkaqvgMOb qQbf/B6Z69WQD1W16kPZKyTmJgqA5yFbXr4CRPi1V59UoEbPyHPlqBAVnkTzBgLsEVnR UYCIe0SuD+mrU/gGHzB14tLarGYF76iZgf/vsdMFuNJJjQb85eo5PwveupoEz/6FXEts mM7g== 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=kW/wDGMCBPvfzEywZq8n8G+1oXymll4KoNLylSfmU48=; b=ElnoYD0pJsPKr/tC/rYH76Vxvl7dx0dB0NGy3z1dZ/gnTihjzGdv2D9i1c0FH13dc7 a5Xpk0qrUgT2XIvSC/FCUTRDeAPPuR9uYRjo2OxePklV6YBqsdmnhMwKf3y10mhTdkkp p6LMD2VYukDQFqp9TvpasX3sc8xxh/Fditlk6PD0nodLKXF81LAs3NEXGs0AcO8pDlZf OVvhGHo58gSf1jymYyAp43RcZ36oxloRwr4zVCZ7sqpCioatT21vGpnStIBzi8JtdBVy WQbgVb4gMuBmzp+467DqBA2kKrz8Leb4Yc+Nu//n/XReZGnOek1OLsv9/jpZQqWwnKQD I5MQ== 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 b8si856958eju.351.2019.10.09.04.17.23; Wed, 09 Oct 2019 04:17:51 -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 S1730692AbfJILRP (ORCPT + 99 others); Wed, 9 Oct 2019 07:17:15 -0400 Received: from cmccmta3.chinamobile.com ([221.176.66.81]:2362 "EHLO cmccmta3.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726734AbfJILRM (ORCPT ); Wed, 9 Oct 2019 07:17:12 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.17]) by rmmx-syy-dmz-app10-12010 (RichMail) with SMTP id 2eea5d9dc1a184f-0879a; Wed, 09 Oct 2019 19:16:50 +0800 (CST) X-RM-TRANSID: 2eea5d9dc1a184f-0879a X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost (unknown[223.105.0.241]) by rmsmtp-syy-appsvr09-12009 (RichMail) with SMTP id 2ee95d9dc1a06c5-f78e7; Wed, 09 Oct 2019 19:16:49 +0800 (CST) X-RM-TRANSID: 2ee95d9dc1a06c5-f78e7 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 v5 2/3] selftests: netfilter: add ipvs nat test case Date: Wed, 9 Oct 2019 19:16:29 +0800 Message-Id: <1570619790-6086-3-git-send-email-yanhaishuang@cmss.chinamobile.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1570619790-6086-1-git-send-email-yanhaishuang@cmss.chinamobile.com> References: <1570619790-6086-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 f844c0a..60250f7 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