From patchwork Thu Sep 26 16:48:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haishuang Yan X-Patchwork-Id: 11163025 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9148912 for ; Thu, 26 Sep 2019 16:59:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 92028222CE for ; Thu, 26 Sep 2019 16:59:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727444AbfIZQ64 (ORCPT ); Thu, 26 Sep 2019 12:58:56 -0400 Received: from cmccmta2.chinamobile.com ([221.176.66.80]:4845 "EHLO cmccmta2.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727512AbfIZQ64 (ORCPT ); Thu, 26 Sep 2019 12:58:56 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.15]) by rmmx-syy-dmz-app06-12006 (RichMail) with SMTP id 2ee65d8cec1ff87-2eb90; Fri, 27 Sep 2019 00:49:37 +0800 (CST) X-RM-TRANSID: 2ee65d8cec1ff87-2eb90 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost (unknown[223.105.0.241]) by rmsmtp-syy-appsvr08-12008 (RichMail) with SMTP id 2ee85d8cec20ac9-71c3b; Fri, 27 Sep 2019 00:49:37 +0800 (CST) X-RM-TRANSID: 2ee85d8cec20ac9-71c3b 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 3/3] selftests: netfilter: add ipvs tunnel test case Date: Fri, 27 Sep 2019 00:48:52 +0800 Message-Id: <1569516532-708-4-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-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Test virtual server via ipip tunnel. Tested: # selftests: netfilter: ipvs.sh # Testing DR mode... # Testing NAT mode... # Testing Tunnel mode... # ipvs.sh: PASS ok 6 selftests: netfilter: ipvs.sh Signed-off-by: Haishuang Yan --- tools/testing/selftests/netfilter/ipvs.sh | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tools/testing/selftests/netfilter/ipvs.sh b/tools/testing/selftests/netfilter/ipvs.sh index 40058f9..2012cec 100755 --- a/tools/testing/selftests/netfilter/ipvs.sh +++ b/tools/testing/selftests/netfilter/ipvs.sh @@ -167,6 +167,33 @@ test_nat() { test_service } +test_tun() { + ip netns exec ns0 ip route add ${vip_v4} via ${gip_v4} dev br0 + + ip netns exec ns1 modprobe ipip + ip netns exec ns1 ip link set tunl0 up + ip netns exec ns1 sysctl -qw net.ipv4.ip_forward=0 + ip netns exec ns1 sysctl -qw net.ipv4.conf.all.send_redirects=0 + ip netns exec ns1 sysctl -qw net.ipv4.conf.default.send_redirects=0 + ip netns exec ns1 ipvsadm -A -t ${vip_v4}:${port} -s rr + ip netns exec ns1 ipvsadm -a -i -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 modprobe ipip + ip netns exec ns2 ip link set tunl0 up + ip netns exec ns2 sysctl -qw net.ipv4.conf.all.arp_ignore=1 + ip netns exec ns2 sysctl -qw net.ipv4.conf.all.arp_announce=2 + ip netns exec ns2 sysctl -qw net.ipv4.conf.all.rp_filter=0 + ip netns exec ns2 sysctl -qw net.ipv4.conf.lo.arp_ignore=1 + ip netns exec ns2 sysctl -qw net.ipv4.conf.lo.arp_announce=2 + ip netns exec ns2 sysctl -qw net.ipv4.conf.lo.rp_filter=0 + ip netns exec ns2 sysctl -qw net.ipv4.conf.tunl0.rp_filter=0 + ip netns exec ns2 sysctl -qw net.ipv4.conf.veth21.rp_filter=0 + ip netns exec ns2 ip addr add ${vip_v4}/32 dev lo:1 + + test_service +} + run_tests() { local errors= @@ -182,6 +209,12 @@ run_tests() { test_nat errors=$(( $errors + $? )) + echo "Testing Tunnel mode..." + cleanup + setup + test_tun + errors=$(( $errors + $? )) + return $errors }