From patchwork Thu Mar 15 16:18:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Brivio X-Patchwork-Id: 886338 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 402DKv5H9nz9sP9 for ; Fri, 16 Mar 2018 03:18:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751731AbeCOQSk (ORCPT ); Thu, 15 Mar 2018 12:18:40 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:46448 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751353AbeCOQSi (ORCPT ); Thu, 15 Mar 2018 12:18:38 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5E27820CC6; Thu, 15 Mar 2018 16:18:38 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-65.ams2.redhat.com [10.36.112.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3861D1208F8C; Thu, 15 Mar 2018 16:18:37 +0000 (UTC) From: Stefano Brivio To: "David S . Miller" Cc: Sabrina Dubroca , Steffen Klassert , netdev@vger.kernel.org Subject: [PATCH net-next 1/9] selftests: pmtu: Use namespace command prefix to fetch route mtu Date: Thu, 15 Mar 2018 17:18:21 +0100 Message-Id: <1a7da2a5b882e7dbade51fc7b09cc65db56ff6b0.1521129192.git.sbrivio@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 15 Mar 2018 16:18:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 15 Mar 2018 16:18:38 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'sbrivio@redhat.com' RCPT:'' Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In commit 7af137b72131 ("selftests: net: Introduce first PMTU test") I accidentally assumed route_get_* helpers would run from a single namespace. Make them a bit more generic, by passing the namespace command prefix as a parameter instead. Fixes: 7af137b72131 ("selftests: net: Introduce first PMTU test") Signed-off-by: Stefano Brivio --- tools/testing/selftests/net/pmtu.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh index 6c19c148cef8..7a7845e415e4 100755 --- a/tools/testing/selftests/net/pmtu.sh +++ b/tools/testing/selftests/net/pmtu.sh @@ -106,15 +106,17 @@ mtu() { } route_get_dst_exception() { - dst="${1}" + ns_cmd="${1}" + dst="${2}" - ${ns_a} ip route get "${dst}" + ${ns_cmd} ip route get "${dst}" } route_get_dst_pmtu_from_exception() { - dst="${1}" + ns_cmd="${1}" + dst="${2}" - exception="$(route_get_dst_exception ${dst})" + exception="$(route_get_dst_exception "${ns_cmd}" ${dst})" next=0 for i in ${exception}; do [ ${next} -eq 1 ] && echo "${i}" && return @@ -133,7 +135,7 @@ test_pmtu_vti6_exception() { ${ns_a} ping6 -q -i 0.1 -w 2 -s 60000 ${vti6_b_addr} > /dev/null # Check that exception was created - if [ "$(route_get_dst_pmtu_from_exception ${vti6_b_addr})" = "" ]; then + if [ "$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})" = "" ]; then echo "FAIL: Tunnel exceeding link layer MTU didn't create route exception" exit 1 fi @@ -141,14 +143,14 @@ test_pmtu_vti6_exception() { # Decrease tunnel MTU, check for PMTU decrease in route exception mtu "${ns_a}" vti_a 3000 - if [ "$(route_get_dst_pmtu_from_exception ${vti6_b_addr})" -ne 3000 ]; then + if [ "$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})" -ne 3000 ]; then echo "FAIL: Decreasing tunnel MTU didn't decrease route exception PMTU" exit 1 fi # Increase tunnel MTU, check for PMTU increase in route exception mtu "${ns_a}" vti_a 9000 - if [ "$(route_get_dst_pmtu_from_exception ${vti6_b_addr})" -ne 9000 ]; then + if [ "$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})" -ne 9000 ]; then echo "FAIL: Increasing tunnel MTU didn't increase route exception PMTU" exit 1 fi From patchwork Thu Mar 15 16:18:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Brivio X-Patchwork-Id: 886339 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 402DKy3GJQz9sVZ for ; Fri, 16 Mar 2018 03:18:46 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751951AbeCOQSn (ORCPT ); Thu, 15 Mar 2018 12:18:43 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53878 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751699AbeCOQSk (ORCPT ); Thu, 15 Mar 2018 12:18:40 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EE10C406F8AB; Thu, 15 Mar 2018 16:18:39 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-65.ams2.redhat.com [10.36.112.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id B85D61208F8C; Thu, 15 Mar 2018 16:18:38 +0000 (UTC) From: Stefano Brivio To: "David S . Miller" Cc: Sabrina Dubroca , Steffen Klassert , netdev@vger.kernel.org Subject: [PATCH net-next 2/9] selftests: pmtu: Factor out MTU parsing helper Date: Thu, 15 Mar 2018 17:18:22 +0100 Message-Id: <4667f7185a20101ca24733a837eef7848a289cf3.1521129192.git.sbrivio@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 15 Mar 2018 16:18:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 15 Mar 2018 16:18:40 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'sbrivio@redhat.com' RCPT:'' Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org ...so that it can be used for any iproute command output. Signed-off-by: Stefano Brivio --- tools/testing/selftests/net/pmtu.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh index 7a7845e415e4..fc79cc6f49a6 100755 --- a/tools/testing/selftests/net/pmtu.sh +++ b/tools/testing/selftests/net/pmtu.sh @@ -105,6 +105,16 @@ mtu() { ${ns_cmd} ip link set dev ${dev} mtu ${mtu} } +mtu_parse() { + input="${1}" + + next=0 + for i in ${input}; do + [ ${next} -eq 1 ] && echo "${i}" && return + [ "${i}" = "mtu" ] && next=1 + done +} + route_get_dst_exception() { ns_cmd="${1}" dst="${2}" @@ -116,12 +126,7 @@ route_get_dst_pmtu_from_exception() { ns_cmd="${1}" dst="${2}" - exception="$(route_get_dst_exception "${ns_cmd}" ${dst})" - next=0 - for i in ${exception}; do - [ ${next} -eq 1 ] && echo "${i}" && return - [ "${i}" = "mtu" ] && next=1 - done + mtu_parse "$(route_get_dst_exception "${ns_cmd}" ${dst})" } test_pmtu_vti6_exception() { From patchwork Thu Mar 15 16:18:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Brivio X-Patchwork-Id: 886350 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 402DNg10m6z9sVZ for ; Fri, 16 Mar 2018 03:21:07 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751964AbeCOQVF (ORCPT ); Thu, 15 Mar 2018 12:21:05 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45516 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751738AbeCOQSm (ORCPT ); Thu, 15 Mar 2018 12:18:42 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 900C180AD238; Thu, 15 Mar 2018 16:18:41 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-65.ams2.redhat.com [10.36.112.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B98A1208F8C; Thu, 15 Mar 2018 16:18:40 +0000 (UTC) From: Stefano Brivio To: "David S . Miller" Cc: Sabrina Dubroca , Steffen Klassert , netdev@vger.kernel.org Subject: [PATCH net-next 3/9] selftests: pmtu: Introduce support for multiple tests Date: Thu, 15 Mar 2018 17:18:23 +0100 Message-Id: <2870b8f3ab9ce40d3dbcfc1f308aba580f59197f.1521129192.git.sbrivio@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 15 Mar 2018 16:18:41 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 15 Mar 2018 16:18:41 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'sbrivio@redhat.com' RCPT:'' Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Introduce list of tests and loop on it in main body. Tests will now just take care of calling setup with a list of "units" they need, and return 0 for failure, 1 for success, 2 if the test had to be skipped. Main script body will take care of displaying results and cleaning up after every test. Introduce guard variable so that we don't clean up twice in case of interrupts or unexpected failures. Signed-off-by: Stefano Brivio --- tools/testing/selftests/net/pmtu.sh | 58 ++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh index fc79cc6f49a6..feebb6fcff21 100755 --- a/tools/testing/selftests/net/pmtu.sh +++ b/tools/testing/selftests/net/pmtu.sh @@ -5,13 +5,15 @@ # # Tests currently implemented: # -# - test_pmtu_vti6_exception +# - pmtu_vti6_exception # Set up vti6 tunnel on top of veth, with xfrm states and policies, in two # namespaces with matching endpoints. Check that route exception is # created by exceeding link layer MTU with ping to other endpoint. Then # decrease and increase MTU of tunnel, checking that route exception PMTU # changes accordingly +tests="pmtu_vti6_exception" + NS_A="ns-$(mktemp -u XXXXXX)" NS_B="ns-$(mktemp -u XXXXXX)" ns_a="ip netns exec ${NS_A}" @@ -25,6 +27,8 @@ vti6_a_addr="fd00:2::a" vti6_b_addr="fd00:2::b" vti6_mask="64" +cleanup_done=1 + setup_namespaces() { ip netns add ${NS_A} || return 0 ip netns add ${NS_B} @@ -75,26 +79,21 @@ setup_xfrm() { } setup() { - tunnel_type="$1" + [ "$(id -u)" -ne 0 ] && echo " need to run as root" && return 0 - [ "$(id -u)" -ne 0 ] && echo "SKIP: need to run as root" && exit 0 - - setup_namespaces && echo "SKIP: namespaces not supported" && exit 0 - setup_veth && echo "SKIP: veth not supported" && exit 0 + cleanup_done=0 + for arg do + eval setup_${arg} && echo " ${arg} not supported" && return 0 + done - case ${tunnel_type} in - "vti6") - setup_vti6 && echo "SKIP: vti6 not supported" && exit 0 - setup_xfrm && echo "SKIP: xfrm not supported" && exit 0 - ;; - *) - ;; - esac + return 1 } cleanup() { + [ ${cleanup_done} -eq 1 ] && return ip netns del ${NS_A} 2 > /dev/null ip netns del ${NS_B} 2 > /dev/null + cleanup_done=1 } mtu() { @@ -130,7 +129,7 @@ route_get_dst_pmtu_from_exception() { } test_pmtu_vti6_exception() { - setup vti6 + setup namespaces veth vti6 xfrm && return 2 # Create route exception by exceeding link layer MTU mtu "${ns_a}" veth_a 4000 @@ -141,30 +140,41 @@ test_pmtu_vti6_exception() { # Check that exception was created if [ "$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})" = "" ]; then - echo "FAIL: Tunnel exceeding link layer MTU didn't create route exception" - exit 1 + echo " tunnel exceeding link layer MTU didn't create route exception" + return 0 fi # Decrease tunnel MTU, check for PMTU decrease in route exception mtu "${ns_a}" vti_a 3000 if [ "$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})" -ne 3000 ]; then - echo "FAIL: Decreasing tunnel MTU didn't decrease route exception PMTU" - exit 1 + echo " decreasing tunnel MTU didn't decrease route exception PMTU" + return 0 fi # Increase tunnel MTU, check for PMTU increase in route exception mtu "${ns_a}" vti_a 9000 if [ "$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})" -ne 9000 ]; then - echo "FAIL: Increasing tunnel MTU didn't increase route exception PMTU" - exit 1 + echo " increasing tunnel MTU didn't increase route exception PMTU" + return 0 fi - echo "PASS" + return 1 } trap cleanup EXIT -test_pmtu_vti6_exception +exitcode=0 +for name in ${tests}; do + echo "${name}: START" + eval test_${name} + ret=$? + cleanup + + if [ $ret -eq 0 ]; then echo "${name}: FAIL"; exitcode=1 + elif [ $ret -eq 1 ]; then echo "${name}: PASS" + elif [ $ret -eq 2 ]; then echo "${name}: SKIP" + fi +done -exit 0 +exit ${exitcode} From patchwork Thu Mar 15 16:18:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Brivio X-Patchwork-Id: 886340 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 402DL150Psz9sVZ for ; Fri, 16 Mar 2018 03:18:49 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751975AbeCOQSq (ORCPT ); Thu, 15 Mar 2018 12:18:46 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:46774 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751699AbeCOQSn (ORCPT ); Thu, 15 Mar 2018 12:18:43 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 26DE1406802A; Thu, 15 Mar 2018 16:18:43 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-65.ams2.redhat.com [10.36.112.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id E645B1208F8F; Thu, 15 Mar 2018 16:18:41 +0000 (UTC) From: Stefano Brivio To: "David S . Miller" Cc: Sabrina Dubroca , Steffen Klassert , netdev@vger.kernel.org Subject: [PATCH net-next 4/9] selftests: pmtu: Add pmtu_vti4_default_mtu test Date: Thu, 15 Mar 2018 17:18:24 +0100 Message-Id: <5b85a7d0764f206fcadc6023e5401852a642aca0.1521129192.git.sbrivio@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 15 Mar 2018 16:18:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 15 Mar 2018 16:18:43 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'sbrivio@redhat.com' RCPT:'' Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This test checks that the MTU assigned by default to a vti (IPv4) interface created on top of veth is simply veth's MTU minus the length of the encapsulated IPv4 header. Signed-off-by: Stefano Brivio --- tools/testing/selftests/net/pmtu.sh | 89 +++++++++++++++++++++++++++++++------ 1 file changed, 76 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh index feebb6fcff21..440d2defe592 100755 --- a/tools/testing/selftests/net/pmtu.sh +++ b/tools/testing/selftests/net/pmtu.sh @@ -1,7 +1,8 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 # -# Check that route PMTU values match expectations +# Check that route PMTU values match expectations, and that initial device MTU +# values are assigned correctly # # Tests currently implemented: # @@ -11,18 +12,30 @@ # created by exceeding link layer MTU with ping to other endpoint. Then # decrease and increase MTU of tunnel, checking that route exception PMTU # changes accordingly +# +# - pmtu_vti4_default_mtu +# Set up vti4 tunnel on top of veth, in two namespaces with matching +# endpoints. Check that MTU assigned to vti interface is the MTU of the +# lower layer (veth) minus additional lower layer headers (zero, for veth) +# minus IPv4 header length -tests="pmtu_vti6_exception" +tests="pmtu_vti6_exception pmtu_vti4_default_mtu" NS_A="ns-$(mktemp -u XXXXXX)" NS_B="ns-$(mktemp -u XXXXXX)" ns_a="ip netns exec ${NS_A}" ns_b="ip netns exec ${NS_B}" +veth4_a_addr="192.168.1.1" +veth4_b_addr="192.168.1.2" +veth4_mask="24" veth6_a_addr="fd00:1::a" veth6_b_addr="fd00:1::b" veth6_mask="64" +vti4_a_addr="192.168.2.1" +vti4_b_addr="192.168.2.2" +vti4_mask="24" vti6_a_addr="fd00:2::a" vti6_b_addr="fd00:2::b" vti6_mask="64" @@ -40,6 +53,9 @@ setup_veth() { ${ns_a} ip link add veth_a type veth peer name veth_b || return 0 ${ns_a} ip link set veth_b netns ${NS_B} + ${ns_a} ip addr add ${veth4_a_addr}/${veth4_mask} dev veth_a + ${ns_b} ip addr add ${veth4_b_addr}/${veth4_mask} dev veth_b + ${ns_a} ip addr add ${veth6_a_addr}/${veth6_mask} dev veth_a ${ns_b} ip addr add ${veth6_b_addr}/${veth6_mask} dev veth_b @@ -49,21 +65,40 @@ setup_veth() { return 1 } -setup_vti6() { - ${ns_a} ip link add vti_a type vti6 local ${veth6_a_addr} remote ${veth6_b_addr} key 10 || return 0 - ${ns_b} ip link add vti_b type vti6 local ${veth6_b_addr} remote ${veth6_a_addr} key 10 +setup_vti() { + proto=${1} + veth_a_addr="${2}" + veth_b_addr="${3}" + vti_a_addr="${4}" + vti_b_addr="${5}" + vti_mask=${6} + + [ ${proto} -eq 6 ] && vti_type="vti6" || vti_type="vti" - ${ns_a} ip addr add ${vti6_a_addr}/${vti6_mask} dev vti_a - ${ns_b} ip addr add ${vti6_b_addr}/${vti6_mask} dev vti_b + ${ns_a} ip link add vti${proto}_a type ${vti_type} local ${veth_a_addr} remote ${veth_b_addr} key 10 || return 0 + ${ns_b} ip link add vti${proto}_b type ${vti_type} local ${veth_b_addr} remote ${veth_a_addr} key 10 - ${ns_a} ip link set vti_a up - ${ns_b} ip link set vti_b up + ${ns_a} ip addr add ${vti_a_addr}/${vti_mask} dev vti${proto}_a + ${ns_b} ip addr add ${vti_b_addr}/${vti_mask} dev vti${proto}_b + + ${ns_a} ip link set vti${proto}_a up + ${ns_b} ip link set vti${proto}_b up sleep 1 return 1 } +setup_vti4() { + setup_vti 4 ${veth4_a_addr} ${veth4_b_addr} ${vti4_a_addr} ${vti4_b_addr} ${vti4_mask} + return $? +} + +setup_vti6() { + setup_vti 6 ${veth6_a_addr} ${veth6_b_addr} ${vti6_a_addr} ${vti6_b_addr} ${vti6_mask} + return $? +} + setup_xfrm() { ${ns_a} ip -6 xfrm state add src ${veth6_a_addr} dst ${veth6_b_addr} spi 0x1000 proto esp aead "rfc4106(gcm(aes))" 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel || return 0 ${ns_a} ip -6 xfrm state add src ${veth6_b_addr} dst ${veth6_a_addr} spi 0x1001 proto esp aead "rfc4106(gcm(aes))" 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel @@ -114,6 +149,20 @@ mtu_parse() { done } +link_get() { + ns_cmd="${1}" + name="${2}" + + ${ns_cmd} ip link show dev "${name}" +} + +link_get_mtu() { + ns_cmd="${1}" + name="${2}" + + mtu_parse "$(link_get "${ns_cmd}" ${name})" +} + route_get_dst_exception() { ns_cmd="${1}" dst="${2}" @@ -134,8 +183,8 @@ test_pmtu_vti6_exception() { # Create route exception by exceeding link layer MTU mtu "${ns_a}" veth_a 4000 mtu "${ns_b}" veth_b 4000 - mtu "${ns_a}" vti_a 5000 - mtu "${ns_b}" vti_b 5000 + mtu "${ns_a}" vti6_a 5000 + mtu "${ns_b}" vti6_b 5000 ${ns_a} ping6 -q -i 0.1 -w 2 -s 60000 ${vti6_b_addr} > /dev/null # Check that exception was created @@ -145,7 +194,7 @@ test_pmtu_vti6_exception() { fi # Decrease tunnel MTU, check for PMTU decrease in route exception - mtu "${ns_a}" vti_a 3000 + mtu "${ns_a}" vti6_a 3000 if [ "$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})" -ne 3000 ]; then echo " decreasing tunnel MTU didn't decrease route exception PMTU" @@ -153,7 +202,7 @@ test_pmtu_vti6_exception() { fi # Increase tunnel MTU, check for PMTU increase in route exception - mtu "${ns_a}" vti_a 9000 + mtu "${ns_a}" vti6_a 9000 if [ "$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})" -ne 9000 ]; then echo " increasing tunnel MTU didn't increase route exception PMTU" return 0 @@ -162,6 +211,20 @@ test_pmtu_vti6_exception() { return 1 } +test_pmtu_vti4_default_mtu() { + setup namespaces veth vti4 && return 2 + + # Check that MTU of vti device is MTU of veth minus IPv4 header length + veth_mtu="$(link_get_mtu "${ns_a}" veth_a)" + vti4_mtu="$(link_get_mtu "${ns_a}" vti4_a)" + if [ $((veth_mtu - vti4_mtu)) -ne 20 ]; then + echo " vti MTU ${vti4_mtu} is not veth MTU ${veth_mtu} minus IPv4 header length" + return 0 + fi + + return 1 +} + trap cleanup EXIT exitcode=0 From patchwork Thu Mar 15 16:18:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Brivio X-Patchwork-Id: 886349 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 402DNW5bW0z9sVZ for ; Fri, 16 Mar 2018 03:20:59 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752169AbeCOQU5 (ORCPT ); Thu, 15 Mar 2018 12:20:57 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:46780 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751964AbeCOQSp (ORCPT ); Thu, 15 Mar 2018 12:18:45 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B67C9406802E; Thu, 15 Mar 2018 16:18:44 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-65.ams2.redhat.com [10.36.112.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 802471208F8C; Thu, 15 Mar 2018 16:18:43 +0000 (UTC) From: Stefano Brivio To: "David S . Miller" Cc: Sabrina Dubroca , Steffen Klassert , netdev@vger.kernel.org Subject: [PATCH net-next 5/9] selftests: pmtu: Add pmtu_vti6_default_mtu test Date: Thu, 15 Mar 2018 17:18:25 +0100 Message-Id: <300846068c5a3407061526a8bad57f6d4dfe805d.1521129192.git.sbrivio@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 15 Mar 2018 16:18:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 15 Mar 2018 16:18:44 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'sbrivio@redhat.com' RCPT:'' Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Same as pmtu_vti4_default_mtu, but on IPv6 with vti6. Signed-off-by: Stefano Brivio --- tools/testing/selftests/net/pmtu.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh index 440d2defe592..67b77f9108ee 100755 --- a/tools/testing/selftests/net/pmtu.sh +++ b/tools/testing/selftests/net/pmtu.sh @@ -18,8 +18,11 @@ # endpoints. Check that MTU assigned to vti interface is the MTU of the # lower layer (veth) minus additional lower layer headers (zero, for veth) # minus IPv4 header length +# +# - pmtu_vti6_default_mtu +# Same as above, for IPv6 -tests="pmtu_vti6_exception pmtu_vti4_default_mtu" +tests="pmtu_vti6_exception pmtu_vti4_default_mtu pmtu_vti6_default_mtu" NS_A="ns-$(mktemp -u XXXXXX)" NS_B="ns-$(mktemp -u XXXXXX)" @@ -225,6 +228,20 @@ test_pmtu_vti4_default_mtu() { return 1 } +test_pmtu_vti6_default_mtu() { + setup namespaces veth vti6 && return 2 + + # Check that MTU of vti device is MTU of veth minus IPv6 header length + veth_mtu="$(link_get_mtu "${ns_a}" veth_a)" + vti6_mtu="$(link_get_mtu "${ns_a}" vti6_a)" + if [ $((veth_mtu - vti6_mtu)) -ne 40 ]; then + echo " vti MTU ${vti6_mtu} is not veth MTU ${veth_mtu} minus IPv6 header length" + return 0 + fi + + return 1 +} + trap cleanup EXIT exitcode=0 From patchwork Thu Mar 15 16:18:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Brivio X-Patchwork-Id: 886341 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 402DL249Qpz9sVj for ; Fri, 16 Mar 2018 03:18:50 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751982AbeCOQSs (ORCPT ); Thu, 15 Mar 2018 12:18:48 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:46788 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751976AbeCOQSq (ORCPT ); Thu, 15 Mar 2018 12:18:46 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 510CF406802A; Thu, 15 Mar 2018 16:18:46 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-65.ams2.redhat.com [10.36.112.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C61F1208F8C; Thu, 15 Mar 2018 16:18:44 +0000 (UTC) From: Stefano Brivio To: "David S . Miller" Cc: Sabrina Dubroca , Steffen Klassert , netdev@vger.kernel.org Subject: [PATCH net-next 6/9] selftests: pmtu: Add pmtu_vti4_exception test Date: Thu, 15 Mar 2018 17:18:26 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 15 Mar 2018 16:18:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 15 Mar 2018 16:18:46 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'sbrivio@redhat.com' RCPT:'' Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This test checks that PMTU exceptions are created only when needed on IPv4 routes with vti and xfrm, and their PMTU value is checked as well. We can't adopt the same approach as test_pmtu_vti6_exception() here, because on IPv4 administrative MTU changes won't be reflected directly on PMTU. Signed-off-by: Stefano Brivio --- tools/testing/selftests/net/pmtu.sh | 84 ++++++++++++++++++++++++++++++++----- 1 file changed, 74 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh index 67b77f9108ee..336b8545c4bd 100755 --- a/tools/testing/selftests/net/pmtu.sh +++ b/tools/testing/selftests/net/pmtu.sh @@ -6,6 +6,14 @@ # # Tests currently implemented: # +# - pmtu_vti4_exception +# Set up vti tunnel on top of veth, with xfrm states and policies, in two +# namespaces with matching endpoints. Check that route exception is not +# created if link layer MTU is not exceeded, then exceed it and check that +# exception is created with the expected PMTU. The approach described +# below for IPv6 doesn't apply here, because, on IPv4, administrative MTU +# changes alone won't affect PMTU +# # - pmtu_vti6_exception # Set up vti6 tunnel on top of veth, with xfrm states and policies, in two # namespaces with matching endpoints. Check that route exception is @@ -22,7 +30,8 @@ # - pmtu_vti6_default_mtu # Same as above, for IPv6 -tests="pmtu_vti6_exception pmtu_vti4_default_mtu pmtu_vti6_default_mtu" +tests="pmtu_vti4_exception pmtu_vti6_exception + pmtu_vti4_default_mtu pmtu_vti6_default_mtu" NS_A="ns-$(mktemp -u XXXXXX)" NS_B="ns-$(mktemp -u XXXXXX)" @@ -103,19 +112,33 @@ setup_vti6() { } setup_xfrm() { - ${ns_a} ip -6 xfrm state add src ${veth6_a_addr} dst ${veth6_b_addr} spi 0x1000 proto esp aead "rfc4106(gcm(aes))" 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel || return 0 - ${ns_a} ip -6 xfrm state add src ${veth6_b_addr} dst ${veth6_a_addr} spi 0x1001 proto esp aead "rfc4106(gcm(aes))" 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel - ${ns_a} ip -6 xfrm policy add dir out mark 10 tmpl src ${veth6_a_addr} dst ${veth6_b_addr} proto esp mode tunnel - ${ns_a} ip -6 xfrm policy add dir in mark 10 tmpl src ${veth6_b_addr} dst ${veth6_a_addr} proto esp mode tunnel + proto=${1} + veth_a_addr="${2}" + veth_b_addr="${3}" - ${ns_b} ip -6 xfrm state add src ${veth6_a_addr} dst ${veth6_b_addr} spi 0x1000 proto esp aead "rfc4106(gcm(aes))" 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel - ${ns_b} ip -6 xfrm state add src ${veth6_b_addr} dst ${veth6_a_addr} spi 0x1001 proto esp aead "rfc4106(gcm(aes))" 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel - ${ns_b} ip -6 xfrm policy add dir out mark 10 tmpl src ${veth6_b_addr} dst ${veth6_a_addr} proto esp mode tunnel - ${ns_b} ip -6 xfrm policy add dir in mark 10 tmpl src ${veth6_a_addr} dst ${veth6_b_addr} proto esp mode tunnel + ${ns_a} ip -${proto} xfrm state add src ${veth_a_addr} dst ${veth_b_addr} spi 0x1000 proto esp aead "rfc4106(gcm(aes))" 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel || return 0 + ${ns_a} ip -${proto} xfrm state add src ${veth_b_addr} dst ${veth_a_addr} spi 0x1001 proto esp aead "rfc4106(gcm(aes))" 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel + ${ns_a} ip -${proto} xfrm policy add dir out mark 10 tmpl src ${veth_a_addr} dst ${veth_b_addr} proto esp mode tunnel + ${ns_a} ip -${proto} xfrm policy add dir in mark 10 tmpl src ${veth_b_addr} dst ${veth_a_addr} proto esp mode tunnel + + ${ns_b} ip -${proto} xfrm state add src ${veth_a_addr} dst ${veth_b_addr} spi 0x1000 proto esp aead "rfc4106(gcm(aes))" 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel + ${ns_b} ip -${proto} xfrm state add src ${veth_b_addr} dst ${veth_a_addr} spi 0x1001 proto esp aead "rfc4106(gcm(aes))" 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f 128 mode tunnel + ${ns_b} ip -${proto} xfrm policy add dir out mark 10 tmpl src ${veth_b_addr} dst ${veth_a_addr} proto esp mode tunnel + ${ns_b} ip -${proto} xfrm policy add dir in mark 10 tmpl src ${veth_a_addr} dst ${veth_b_addr} proto esp mode tunnel return 1 } +setup_xfrm4() { + setup_xfrm 4 ${veth4_a_addr} ${veth4_b_addr} + return $? +} + +setup_xfrm6() { + setup_xfrm 6 ${veth6_a_addr} ${veth6_b_addr} + return $? +} + setup() { [ "$(id -u)" -ne 0 ] && echo " need to run as root" && return 0 @@ -180,8 +203,49 @@ route_get_dst_pmtu_from_exception() { mtu_parse "$(route_get_dst_exception "${ns_cmd}" ${dst})" } +test_pmtu_vti4_exception() { + setup namespaces veth vti4 xfrm4 && return 2 + + veth_mtu=1500 + vti_mtu=$((veth_mtu - 20)) + + # SPI SN IV ICV pad length next header + esp_payload_rfc4106=$((vti_mtu - 4 - 4 - 8 - 16 - 1 - 1)) + ping_payload=$((esp_payload_rfc4106 - 28)) + + mtu "${ns_a}" veth_a ${veth_mtu} + mtu "${ns_b}" veth_b ${veth_mtu} + mtu "${ns_a}" vti4_a ${vti_mtu} + mtu "${ns_b}" vti4_b ${vti_mtu} + + # Send DF packet without exceeding link layer MTU, check that no + # exception is created + ${ns_a} ping -q -M want -i 0.1 -w 2 -s ${ping_payload} ${vti4_b_addr} > /dev/null + pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti4_b_addr})" + if [ "${pmtu}" != "" ]; then + echo " unexpected exception created with PMTU ${pmtu} for IP payload length ${esp_payload_rfc4106}" + return 0 + fi + + # Now exceed link layer MTU by one byte, check that exception is created + ${ns_a} ping -q -M want -i 0.1 -w 2 -s $((ping_payload + 1)) ${vti4_b_addr} > /dev/null + pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti4_b_addr})" + if [ "${pmtu}" = "" ]; then + echo " exception not created for IP payload length $((esp_payload_rfc4106 + 1))" + return 0 + fi + + # ...with the right PMTU value + if [ ${pmtu} -ne ${esp_payload_rfc4106} ]; then + echo " wrong PMTU ${pmtu} in exception, expected: ${esp_payload_rfc4106}" + return 0 + fi + + return 1 +} + test_pmtu_vti6_exception() { - setup namespaces veth vti6 xfrm && return 2 + setup namespaces veth vti6 xfrm6 && return 2 # Create route exception by exceeding link layer MTU mtu "${ns_a}" veth_a 4000 From patchwork Thu Mar 15 16:18:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Brivio X-Patchwork-Id: 886344 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 402DLR0xcGz9sVZ for ; Fri, 16 Mar 2018 03:19:11 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752045AbeCOQTI (ORCPT ); Thu, 15 Mar 2018 12:19:08 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53888 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751699AbeCOQSs (ORCPT ); Thu, 15 Mar 2018 12:18:48 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E04DD406F89C; Thu, 15 Mar 2018 16:18:47 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-65.ams2.redhat.com [10.36.112.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8AD21208F8F; Thu, 15 Mar 2018 16:18:46 +0000 (UTC) From: Stefano Brivio To: "David S . Miller" Cc: Sabrina Dubroca , Steffen Klassert , netdev@vger.kernel.org Subject: [PATCH net-next 7/9] selftests: pmtu: Add pmtu_vti4_link_add_mtu test Date: Thu, 15 Mar 2018 17:18:27 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 15 Mar 2018 16:18:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 15 Mar 2018 16:18:47 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'sbrivio@redhat.com' RCPT:'' Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This test checks that MTU given on vti link creation is actually configured, and that tunnel is not created with an invalid MTU. Signed-off-by: Stefano Brivio --- tools/testing/selftests/net/pmtu.sh | 45 ++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh index 336b8545c4bd..2a7ada49d0c0 100755 --- a/tools/testing/selftests/net/pmtu.sh +++ b/tools/testing/selftests/net/pmtu.sh @@ -29,9 +29,14 @@ # # - pmtu_vti6_default_mtu # Same as above, for IPv6 +# +# - pmtu_vti4_link_add_mtu +# Set up vti4 interface passing MTU value at link creation, check MTU is +# configured, and that link is not created with invalid MTU values tests="pmtu_vti4_exception pmtu_vti6_exception - pmtu_vti4_default_mtu pmtu_vti6_default_mtu" + pmtu_vti4_default_mtu pmtu_vti6_default_mtu + pmtu_vti4_link_add_mtu" NS_A="ns-$(mktemp -u XXXXXX)" NS_B="ns-$(mktemp -u XXXXXX)" @@ -306,6 +311,44 @@ test_pmtu_vti6_default_mtu() { return 1 } +test_pmtu_vti4_link_add_mtu() { + setup namespaces && return 2 + + ${ns_a} ip link add vti4_a type vti local ${veth4_a_addr} remote ${veth4_b_addr} key 10 + [ $? -ne 0 ] && echo " vti not supported" && return 2 + ${ns_a} ip link del vti4_a + + pass=1 + + min=68 + max=$((65528 - 20)) + # Check invalid values first + for v in $((min - 1)) $((max + 1)); do + ${ns_a} ip link add vti4_a mtu ${v} type vti local ${veth4_a_addr} remote ${veth4_b_addr} key 10 2>/dev/null + # This can fail, or MTU can be adjusted to a proper value + [ $? -ne 0 ] && continue + mtu="$(link_get_mtu "${ns_a}" vti4_a)" + if [ ${mtu} -lt ${min} -o ${mtu} -gt ${max} ]; then + echo " vti tunnel created with invalid MTU ${mtu}" + pass=0 + fi + ${ns_a} ip link del vti4_a + done + + # Now check valid values + for v in ${min} 1300 ${max}; do + ${ns_a} ip link add vti4_a mtu ${v} type vti local ${veth4_a_addr} remote ${veth4_b_addr} key 10 + mtu="$(link_get_mtu "${ns_a}" vti4_a)" + ${ns_a} ip link del vti4_a + if [ "${mtu}" != "${v}" ]; then + echo " vti MTU ${mtu} doesn't match configured value ${v}" + pass=0 + fi + done + + return ${pass} +} + trap cleanup EXIT exitcode=0 From patchwork Thu Mar 15 16:18:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Brivio X-Patchwork-Id: 886342 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 402DL91HHfz9sVZ for ; Fri, 16 Mar 2018 03:18:57 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752003AbeCOQSy (ORCPT ); Thu, 15 Mar 2018 12:18:54 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48476 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751976AbeCOQSu (ORCPT ); Thu, 15 Mar 2018 12:18:50 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7B9247CBBA; Thu, 15 Mar 2018 16:18:49 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-65.ams2.redhat.com [10.36.112.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4610A1208F8C; Thu, 15 Mar 2018 16:18:48 +0000 (UTC) From: Stefano Brivio To: "David S . Miller" Cc: Sabrina Dubroca , Steffen Klassert , netdev@vger.kernel.org Subject: [PATCH net-next 8/9] selftests: pmtu: Add pmtu_vti6_link_add_mtu test Date: Thu, 15 Mar 2018 17:18:28 +0100 Message-Id: <0ed009e709d7b8d29b8b7b051cd3c6789e568499.1521129192.git.sbrivio@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 15 Mar 2018 16:18:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 15 Mar 2018 16:18:49 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'sbrivio@redhat.com' RCPT:'' Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Same as pmtu_vti4_link_add_mtu test, but for IPv6. Signed-off-by: Stefano Brivio --- tools/testing/selftests/net/pmtu.sh | 43 ++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh index 2a7ada49d0c0..aad9f880c8ee 100755 --- a/tools/testing/selftests/net/pmtu.sh +++ b/tools/testing/selftests/net/pmtu.sh @@ -33,10 +33,13 @@ # - pmtu_vti4_link_add_mtu # Set up vti4 interface passing MTU value at link creation, check MTU is # configured, and that link is not created with invalid MTU values +# +# - pmtu_vti6_link_add_mtu +# Same as above, for IPv6 tests="pmtu_vti4_exception pmtu_vti6_exception pmtu_vti4_default_mtu pmtu_vti6_default_mtu - pmtu_vti4_link_add_mtu" + pmtu_vti4_link_add_mtu pmtu_vti6_link_add_mtu" NS_A="ns-$(mktemp -u XXXXXX)" NS_B="ns-$(mktemp -u XXXXXX)" @@ -349,6 +352,44 @@ test_pmtu_vti4_link_add_mtu() { return ${pass} } +test_pmtu_vti6_link_add_mtu() { + setup namespaces && return 2 + + ${ns_a} ip link add vti6_a type vti6 local ${veth6_a_addr} remote ${veth6_b_addr} key 10 + [ $? -ne 0 ] && echo " vti6 not supported" && return 2 + ${ns_a} ip link del vti6_a + + pass=1 + + min=1280 + max=$((65535 - 40)) + # Check invalid values first + for v in $((min - 1)) $((max + 1)); do + ${ns_a} ip link add vti6_a mtu ${v} type vti6 local ${veth6_a_addr} remote ${veth6_b_addr} key 10 2>/dev/null + # This can fail, or MTU can be adjusted to a proper value + [ $? -ne 0 ] && continue + mtu="$(link_get_mtu "${ns_a}" vti6_a)" + if [ ${mtu} -lt ${min} -o ${mtu} -gt ${max} ]; then + echo " vti6 tunnel created with invalid MTU ${v}" + pass=0 + fi + ${ns_a} ip link del vti6_a + done + + # Now check valid values + for v in 1280 1300 $((65535 - 40)); do + ${ns_a} ip link add vti6_a mtu ${v} type vti6 local ${veth6_a_addr} remote ${veth6_b_addr} key 10 + mtu="$(link_get_mtu "${ns_a}" vti6_a)" + ${ns_a} ip link del vti6_a + if [ "${mtu}" != "${v}" ]; then + echo " vti6 MTU ${mtu} doesn't match configured value ${v}" + pass=0 + fi + done + + return ${pass} +} + trap cleanup EXIT exitcode=0 From patchwork Thu Mar 15 16:18:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Brivio X-Patchwork-Id: 886343 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 402DLF7204z9sVZ for ; Fri, 16 Mar 2018 03:19:01 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751996AbeCOQSx (ORCPT ); Thu, 15 Mar 2018 12:18:53 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:52470 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751983AbeCOQSv (ORCPT ); Thu, 15 Mar 2018 12:18:51 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1FCE64023141; Thu, 15 Mar 2018 16:18:51 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-65.ams2.redhat.com [10.36.112.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id D702D1208F8C; Thu, 15 Mar 2018 16:18:49 +0000 (UTC) From: Stefano Brivio To: "David S . Miller" Cc: Sabrina Dubroca , Steffen Klassert , netdev@vger.kernel.org Subject: [PATCH net-next 9/9] selftests: pmtu: Add pmtu_vti6_link_change_mtu test Date: Thu, 15 Mar 2018 17:18:29 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 15 Mar 2018 16:18:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 15 Mar 2018 16:18:51 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'sbrivio@redhat.com' RCPT:'' Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This test checks that MTU configured from userspace is used on link creation and changes, and that when it's not passed from userspace, it's calculated properly from the MTU of the lower layer. Signed-off-by: Stefano Brivio --- tools/testing/selftests/net/pmtu.sh | 58 ++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh index aad9f880c8ee..937cabe5b969 100755 --- a/tools/testing/selftests/net/pmtu.sh +++ b/tools/testing/selftests/net/pmtu.sh @@ -36,10 +36,17 @@ # # - pmtu_vti6_link_add_mtu # Same as above, for IPv6 +# +# - pmtu_vti6_link_change_mtu +# Set up two dummy interfaces with different MTUs, create a vti6 tunnel +# and check that configured MTU is used on link creation and changes, and +# that MTU is properly calculated instead when MTU is not configured from +# userspace tests="pmtu_vti4_exception pmtu_vti6_exception pmtu_vti4_default_mtu pmtu_vti6_default_mtu - pmtu_vti4_link_add_mtu pmtu_vti6_link_add_mtu" + pmtu_vti4_link_add_mtu pmtu_vti6_link_add_mtu + pmtu_vti6_link_change_mtu" NS_A="ns-$(mktemp -u XXXXXX)" NS_B="ns-$(mktemp -u XXXXXX)" @@ -60,6 +67,10 @@ vti6_a_addr="fd00:2::a" vti6_b_addr="fd00:2::b" vti6_mask="64" +dummy6_0_addr="fc00:1000::0" +dummy6_1_addr="fc00:1001::0" +dummy6_mask="64" + cleanup_done=1 setup_namespaces() { @@ -390,6 +401,51 @@ test_pmtu_vti6_link_add_mtu() { return ${pass} } +test_pmtu_vti6_link_change_mtu() { + setup namespaces && return 2 + + ${ns_a} ip link add dummy0 mtu 1500 type dummy + [ $? -ne 0 ] && echo " dummy not supported" && return 2 + ${ns_a} ip link add dummy1 mtu 3000 type dummy + ${ns_a} ip link set dummy0 up + ${ns_a} ip link set dummy1 up + + ${ns_a} ip addr add ${dummy6_0_addr}/${dummy6_mask} dev dummy0 + ${ns_a} ip addr add ${dummy6_1_addr}/${dummy6_mask} dev dummy1 + + pass=1 + + # Create vti6 interface bound to device, passing MTU, check it + echo "${ns_a} ip link add vti6_a mtu 1300 type vti6 remote ${dummy6_0_addr} local ${dummy6_0_addr}" > /dev/kmsg + ${ns_a} ip link add vti6_a mtu 1300 type vti6 remote ${dummy6_0_addr} local ${dummy6_0_addr} + mtu="$(link_get_mtu "${ns_a}" vti6_a)" + if [ ${mtu} -ne 1300 ]; then + echo " vti6 MTU ${mtu} doesn't match configured value 1300" + pass=0 + fi + + # Move to another device with different MTU, without passing MTU, check + # MTU is adjusted + echo "${ns_a} ip link set vti6_a type vti6 remote ${dummy6_1_addr} local ${dummy6_1_addr}" > /dev/kmsg + ${ns_a} ip link set vti6_a type vti6 remote ${dummy6_1_addr} local ${dummy6_1_addr} + mtu="$(link_get_mtu "${ns_a}" vti6_a)" + if [ ${mtu} -ne $((3000 - 40)) ]; then + echo " vti MTU ${mtu} is not dummy MTU 3000 minus IPv6 header length" + pass=0 + fi + + # Move it back, passing MTU, check MTU is not overridden + echo "${ns_a} ip link set vti6_a mtu 1280 type vti6 remote ${dummy6_0_addr} local ${dummy6_0_addr}" > /dev/kmsg + ${ns_a} ip link set vti6_a mtu 1280 type vti6 remote ${dummy6_0_addr} local ${dummy6_0_addr} + mtu="$(link_get_mtu "${ns_a}" vti6_a)" + if [ ${mtu} -ne 1280 ]; then + echo " vti6 MTU ${mtu} doesn't match configured value 1280" + pass=0 + fi + + return ${pass} +} + trap cleanup EXIT exitcode=0