Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp2313051ybn; Thu, 26 Sep 2019 10:01:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzIueMmcH9lgxwKHnPkspZEObwxztOK7YVxOyTawaq1CJuXA83LtUgP0QY1lHsxdFd5OBfw X-Received: by 2002:a50:e79b:: with SMTP id b27mr4875920edn.186.1569517299674; Thu, 26 Sep 2019 10:01:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569517299; cv=none; d=google.com; s=arc-20160816; b=sbZfd3gIMHe4yvaio2Y08pGhq5gldIQyHxJ9onulN7I4Bm9zWlOqxfM7Jujhudb3c1 VJJDkTRiEuL33UEiRbAOVdr6+PPGoDXcGlhUssbUYqO8CLq3T/RNvBZpKrCeIz/9RNtv CrOMQrpJ3EeexU9fywpNQ8y9E6s7gJ07e+qkutdifP3WG91t9bELKGBXiR6LN7Lm7fw+ i+qGIuVmPMUXvd1wmIbqw27FCragQ3Cqu75AvHd4HKAnj6oFonSODB26g9PiA81I1W6n iOVD84bOz+U6GfuY/ZDaza934xkSES+0MTO3YQhe9311akzJyAim9ESQ/2Xd3P2t7fsS VRmQ== 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=XlIcar+E7ZTFIsyJ1JQbZ+HTsNwI5Zb2QVWCasvxtrY=; b=o467pnHGQkv4ZhNOvT4Yg4D9JolA2BmWzCm/cBCg5Q96IUOrBrhmeWCj+s5J1D7TKM WBeijXo4aWA1Cb3CbCRzbRgnTOjlw/zfcOoHtBSP09e4kBZQYxYDpVuNM8erzNXNt9ir f3gTowCo6yesp6LGy1MZ+L2n1U3rNuYsKUTVUxONr4O46uPwpjjyx7WMkhou32IudXkC xlhHmbpwT+sUuYlIGdy5D/odIaeR3M+mCmHlPTPAxpDqofwSb6G+ABxbI+lR2bKjaQEm cwu8D3aXVuiA9QdQMMCkVBiRupngwmxjEJMZv8AdcWaSjGk8tpCWBR1vzoxU6A3c5LlD h2aQ== 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 w54si1745429edd.427.2019.09.26.10.01.15; Thu, 26 Sep 2019 10:01:39 -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 S1727638AbfIZQ7C (ORCPT + 99 others); Thu, 26 Sep 2019 12:59:02 -0400 Received: from cmccmta3.chinamobile.com ([221.176.66.81]:2540 "EHLO cmccmta3.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727605AbfIZQ7B (ORCPT ); Thu, 26 Sep 2019 12:59:01 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.7]) by rmmx-syy-dmz-app09-12009 (RichMail) with SMTP id 2ee95d8cec2520e-2ef84; Fri, 27 Sep 2019 00:49:43 +0800 (CST) X-RM-TRANSID: 2ee95d8cec2520e-2ef84 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost (unknown[223.105.0.241]) by rmsmtp-syy-appsvr04-12004 (RichMail) with SMTP id 2ee45d8cec1a45d-8276d; Fri, 27 Sep 2019 00:49:31 +0800 (CST) X-RM-TRANSID: 2ee45d8cec1a45d-8276d From: Haishuang Yan To: Shuah Khan , Pablo Neira Ayuso , "David S. Miller" Cc: Julian Anastasov , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Haishuang Yan Subject: [PATCH 2/3] selftests: netfilter: add ipvs nat test case Date: Fri, 27 Sep 2019 00:48:51 +0800 Message-Id: <1569516532-708-3-git-send-email-yanhaishuang@cmss.chinamobile.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1569516532-708-1-git-send-email-yanhaishuang@cmss.chinamobile.com> References: <1569516532-708-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 15c386b..40058f9 100755 --- a/tools/testing/selftests/netfilter/ipvs.sh +++ b/tools/testing/selftests/netfilter/ipvs.sh @@ -153,20 +153,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