Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2206611ybp; Sat, 5 Oct 2019 07:38:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwIBwXvpCx0wK9xVgG6mvpHUFhJS7Erd0MSxldCqf9GeOzOBCbHWYkMEjwxN+zdSwkpMIvq X-Received: by 2002:a17:906:2cc8:: with SMTP id r8mr16957959ejr.197.1570286338337; Sat, 05 Oct 2019 07:38:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570286338; cv=none; d=google.com; s=arc-20160816; b=M/V29hy6tLujPrFWaZBQovhrCaKmVX/b6yP0ZtuqquTZzhAO/wX7crX/SeXIdubxWG D7H2Be/sPz1Lie7h7I86xUWBLRYSwhm9G30294NH+XMUyUb9k48WL0+j2e1K6tSXYtTJ +RZ+Zjs4m6iwFNJtcxq2UeURB6WIGxn37AWoQ1JnFFAxURmYrRglOWKWoS3g5yBmBibe kPpfmnkynjXp6AlO5Xsiw+0WjmpIbXTzySEvC2rNMSlhJtwhXMw6nd56nybbIl3vQgtC 2K0F/NNqO0mCF526+fKWi5ICMZujZMGhNtr8foZULMQ/Q2a8PWKE4ehc8zUwRGZ1gmgo n/hg== 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=DEWDcUbTpdA/T9Xihi01EO6Y18epWbL+Ce089uL5+EY=; b=BoLzAmuYs8XjTL2DgfRbJ0fYw1r3PKtQFLKn4JG7EyQ8kB6ZIflWt45zbxT8X3DmSw yFRBobTSHFehsl4YQPtd05T0VdbS6FpI7rgsZMXHn+Jc+c4sdUvnM6UntuLhL7IIpFYn gKrOoPOAkFKaTdHCxATe3Ph8m5i/PmkLsJpDJDHmRkj0m23Nw4VlZ6d3+Osp+Bslu3fI I0Yj+pLoCB55PYkJLPPSkHWwNoGc1N/OhiR9iA1lK2iYv4H49RigmNnirg+ZGwPw0gkc aKApnFLi1Lxv5GHTbtGsEPTHt1l50mppyv0qPQqfVq+ijlDwNQiXp9CYSxQzAERzII3X JOPw== 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 e5si4393983ejj.70.2019.10.05.07.38.34; Sat, 05 Oct 2019 07:38:58 -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 S1728851AbfJEOiY (ORCPT + 99 others); Sat, 5 Oct 2019 10:38:24 -0400 Received: from cmccmta2.chinamobile.com ([221.176.66.80]:2985 "EHLO cmccmta2.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726318AbfJEOiX (ORCPT ); Sat, 5 Oct 2019 10:38:23 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.17]) by rmmx-syy-dmz-app05-12005 (RichMail) with SMTP id 2ee55d98aacc4f9-c334c; Sat, 05 Oct 2019 22:38:04 +0800 (CST) X-RM-TRANSID: 2ee55d98aacc4f9-c334c 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 2ee95d98aacb09d-fd9c6; Sat, 05 Oct 2019 22:38:04 +0800 (CST) X-RM-TRANSID: 2ee95d98aacb09d-fd9c6 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 v4 2/3] selftests: netfilter: add ipvs nat test case Date: Sat, 5 Oct 2019 22:37:44 +0800 Message-Id: <1570286265-15855-3-git-send-email-yanhaishuang@cmss.chinamobile.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1570286265-15855-1-git-send-email-yanhaishuang@cmss.chinamobile.com> References: <1570286265-15855-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 f6da1bd..2601a7c 100755 --- a/tools/testing/selftests/netfilter/ipvs.sh +++ b/tools/testing/selftests/netfilter/ipvs.sh @@ -160,20 +160,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