From patchwork Thu Jan 9 03:28:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Champetier X-Patchwork-Id: 13931909 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4BA56199238; Thu, 9 Jan 2025 03:28:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736393313; cv=none; b=Z7w2BArbUWabQGo3joCSzekDbhwYSZoT8ON3qJvv3PNYSgqMrWrdM7D3QaOJclhO2ccfcamsJJ3g+S8xYZRLj4VTTQv1GzjRMqQdP7FuZSf96aFJ6zsDKgtkNzxMmNq6bmyvkxIj2uNSRC/IoSoeKSqR5dfa2OOhMNN2U6s2n30= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736393313; c=relaxed/simple; bh=1CvGJBdfsQrSZP0bq41YTjTW80fDNBCU6ihC5Tvay2s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KxCDmCxKNaTgxQah8kYW1eCNw1uUbETBfkCWc1uslzN3VFRrWwIZ7gojopQZKiSmBpf5Bxe3zqA/QIP6lulgLZTjCpH8Yd8APiDQYD78llUFwzM4S7EbMlLXy2FX6O9LUFiuUSp1O43Hx4jMIWkh/2Dmkx6ao0FMw+GGTDCOpwQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fjB3oky0; arc=none smtp.client-ip=209.85.222.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fjB3oky0" Received: by mail-qk1-f181.google.com with SMTP id af79cd13be357-7b8618be68bso33850085a.3; Wed, 08 Jan 2025 19:28:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736393311; x=1736998111; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jXzhdavCNuMsnLueA0771kqTUjEAV7QKi1FIGuZMdYk=; b=fjB3oky03wUN23xEcjeg95z3rDtdSeK7BOIxlbOfsEz64uoVL+O90zeuIR3KFiYhiM EsLWSq89m82OH26tgYyrPaApPIdGYRPRQzuO3pdZYEpek/49ANuQGCeoBRsgCDKaMzuI G9mnIGSVL7xiZnz8sroMYi6OVNno9UE48R8iJmornYm6xsxkB4diD9pSQrKVmWA+gMX8 ExF8pi6dT7EOWmKFnwFJe83dq6zTvby1O9NieMOUbLBp4jvE1nc9oCCIwzo6JyJZqgRn dEq56iIcGrPVvfqeo+fG4kAjQ+x5jML4FlisWIXE3tu8KjxJZSrUU4CqEwr3+S1/expj jPXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736393311; x=1736998111; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jXzhdavCNuMsnLueA0771kqTUjEAV7QKi1FIGuZMdYk=; b=IfvIo8ezOVwQj+fkLSO5+h6fTawlDxZgFAwxYDjWtkcpgmxozL40VyzD7jt2bXknmi KaZHeQKX6sMyTBO1nXIjaGzL89U87ufqM+LVYHN67Wh/0TGxO1xiwIio2uYRdcdzfY30 Nufclb60pGHj8ISP+HqPv38CntNHw9lhj+TwYnUy3h6jsg3xAZ+sedbVp+yPOTKvpo7r JBNGRLuGoJi8KwIkSuOWsSk1qYg7ro0H2q01d2Kw9qh/OTJ1qbt3hMXAEdZrZl5ke3Xm YlPXQ6ng3yK5wZvpamDqnyOPGr2XUFqj7iWcmhbtQdTIa8qKdJAhVxNO/R6MOoU2AiKj 6/Jg== X-Forwarded-Encrypted: i=1; AJvYcCV4DZucK8eOL2q3k+3S6i+ptU3N1zcNlj31Gsa+VBfqqDk9WFnQb/yGyvK4cL9BRZdCgDutGQXK9AiTj2vjrjQ=@vger.kernel.org, AJvYcCWd8w1KyHqHuT1P0a2NXWLM2UQ88mJWmxlyW5hgAQsJRkvcrJCEy5rwpJJI3nV6TVt5FwytoTcd@vger.kernel.org X-Gm-Message-State: AOJu0YziGZEm9gIqus5GoVCRWFz8fduJulH27p4Hqde92YQYoFwORQf9 Dpq4o0D+w6j06bDzZFKgeyDjwxRNbk55BSZAFvmmIiTjnfIbrFk3MlIAd9wt X-Gm-Gg: ASbGnctHJL1KHI4QrK3DXRQduUAHwXMRJcaoUlqVTiu4WiseUSnZL2qcEZWtrAjZODK ACW2KkYtVSHnCTxQCvmRgNVh5LgWA+oQe9hXk+tMGjmuii5400QmzEQ58mkp8ZOwNd0CxFSoSWG Kfrx7lXj/Tcfe2JANY/CXfX+g7xeWV6FeIkvlxaRIc7yDumif0bF262oVbTX2vwMevXC+teaXTm bHuuexHdgvr2Srx6kL49hdyXiQOQQX5qFMgNUpjPR//Asfe6G6ntfGx4g== X-Google-Smtp-Source: AGHT+IGmGky1psL51y6RMRavI8fZGYTmcJUDQZkiQve7kzUZ0k4cwfJnjA4pFibfRMLOGuYp8Dkh7A== X-Received: by 2002:a05:620a:1992:b0:7b6:de3e:1831 with SMTP id af79cd13be357-7bcd972f1eemr896165585a.9.1736393311220; Wed, 08 Jan 2025 19:28:31 -0800 (PST) Received: from echampetier.lan ([2607:fea8:1b9f:c5b0::4c4]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7bce35160c6sm25547085a.114.2025.01.08.19.28.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 19:28:30 -0800 (PST) From: Etienne Champetier To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: Etienne Champetier Subject: [PATCH net-next v2 1/2] ipvlan: Support bonding events Date: Wed, 8 Jan 2025 22:28:18 -0500 Message-ID: <20250109032819.326528-2-champetier.etienne@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109032819.326528-1-champetier.etienne@gmail.com> References: <20250109032819.326528-1-champetier.etienne@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org This allows ipvlan to function properly on top of bonds using active-backup mode. This was implemented for macvlan in 2014 in commit 4c9912556867 ("macvlan: Support bonding events"). Signed-off-by: Etienne Champetier --- drivers/net/ipvlan/ipvlan_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c index ee2c3cf4df36..da3a97a65507 100644 --- a/drivers/net/ipvlan/ipvlan_main.c +++ b/drivers/net/ipvlan/ipvlan_main.c @@ -799,6 +799,12 @@ static int ipvlan_device_event(struct notifier_block *unused, case NETDEV_PRE_TYPE_CHANGE: /* Forbid underlying device to change its type. */ return NOTIFY_BAD; + + case NETDEV_NOTIFY_PEERS: + case NETDEV_BONDING_FAILOVER: + case NETDEV_RESEND_IGMP: + list_for_each_entry(ipvlan, &port->ipvlans, pnode) + call_netdevice_notifiers(event, ipvlan->dev); } return NOTIFY_DONE; } From patchwork Thu Jan 9 03:28:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Champetier X-Patchwork-Id: 13931910 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C95C19CC11; Thu, 9 Jan 2025 03:28:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736393315; cv=none; b=L1acP2SvjiBP83tXk2z6RPPEbcWuxfk+fbUvlh7U81VKtB5JygEDQZr/uYYvVHv+mK4Iiwli9EyVIoTZsJ17yI8H423bbfFf8EX73RrhgnQQqKGg8Y8l38SEMT7RtG/OMLda9hFw8HNjR7yOm+KSalwn4B16MUsxeGi0XE58oxU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736393315; c=relaxed/simple; bh=iDMzVWaBAUc/5dl8JpM6FHVTwG2vTQoB1JP29bznlCc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tCiWfE9anfQ6UpWmNwFXYIvvb/2s+S1ARBXOgFSiDSKdhP9XtEgL7RGF4HB93hyjPkFMgrEU/kZcw4cdPF3FLAo99HAqZ1lS1gM7snQQ677ZqvlN8YIMYfvYIXXWz6DzKiDa05CLkSvF8AtkHOXSCvBCj9cOPdXSx6S6JTMhshs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OWlNLTO8; arc=none smtp.client-ip=209.85.222.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OWlNLTO8" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-7b6fc5bf609so34896385a.1; Wed, 08 Jan 2025 19:28:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736393312; x=1736998112; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Mx066+d16N6jDD1oz7oaqQDJ4chX57pP1FwkUttpBwU=; b=OWlNLTO89xDncg6CvRF9AG7Myk208T75N3PpoTnBuHyD9RKYG5UONtUqnIuotw55m6 hdHR+Qe9Tq/5vknZ9QiK928C1X/6NQky3ixl3NClMKaC5/qs/7Odx/k3dUU96E/2FKKb 7Uv18a/jzjFTnSiLO0QU1+zH6onlPRnY26uET969zq9obVkkQ97Hvy178ks39oh0bvmn Lu8AWP5beeW9eAG9L0okSfV03/uqcRKaw4Zr/yyyVrfUVvXlmeeZRAlSoP5MmBBr9num YIjU1BAooZ6S8Wr2AeNwVUAQig8Qt0uHw4+kowbWHPYRJXzeYYqZjRnjbAxIK6r6iQoU uP6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736393312; x=1736998112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mx066+d16N6jDD1oz7oaqQDJ4chX57pP1FwkUttpBwU=; b=g1Qf4ZHpygLhWVqJ2u5wwy5qaDB4B68ZdIJxpDbdCWsjcY/umxc+w5BEcWONPa9aMK amS40UsWloMfSlmlqn8XjZISzP3x9mA1cH0jxThI3vysIJtfYK3W5qB9G6sCtd44b5or bH7eJgOyRZNkdhE09qN0EzKpgJH312FyIO7xK0bD66MVAn/7g6pycNwR3V2WWHJO0CmK 60sfafdfb4MqDIEIHd+4kxNKtP3XNivVbbDtAY3HrgDrspHFq8XUr4KMzYdpw+b2H59C lMWM2S0CjGvrdVqSYUrKq5NLTAzT4bQZVwQ+OB5k1Syd2ZOBOS/M3hv4G9TLfLEmCr/H bTIw== X-Forwarded-Encrypted: i=1; AJvYcCVlBO1ELr5t4eZAQe8o++6ZKcqFfjnfD+9Swua+7jVBcxuaHmnxBldY5ASz66hjv01R5D6Mqp1bmqfc6p4UTYU=@vger.kernel.org, AJvYcCXBu3/D5UOhcWME+3U/CFzCt09hVaSeL5CqZuo65DM+94cWFz7F9+elJqRuaysjAC+a43WrvAjA@vger.kernel.org X-Gm-Message-State: AOJu0Ywk1BjRseNLrjzjKYQJi9R7vS/oAOFsUoHF6MG+WZX8PkEDRZ+7 F+VslMtvEF6maYrn8wCjkY96z3ZztHQGvvIPIIBSkLhW3IhEtTRx X-Gm-Gg: ASbGncvq1Tc9Ilgj69yYzIfY54qSNmWKoJLIichaJ+xvfP516gXX7m+gfpfA1ZUJaHS U789aetH726Gn3YK3Wi/kMKXK2qwsZxO98139BfBucKmn94C8nrFqbp9OLTODyM/jqjyRdCxUm/ xyXOUXZpCLkMnyc9Qma2ySByOkJnmtORXSx9cngv5xeX/1CxC8KR5kY7A/MpWNDoSnDQN+B/LJO IyhpgnTgxOGwmFoncYgZfmJTfdjOKfkMVWql3N1v3R3xo4wWj2fDrCvIQ== X-Google-Smtp-Source: AGHT+IFVcm7ChxAY/1jPhDoKfJEkSF5O11FH/WiROaLu/4w+Gb2bH3MZZSsrQzHd3KsV4AMk6lIY7A== X-Received: by 2002:a05:620a:4142:b0:7b6:6756:eefb with SMTP id af79cd13be357-7bcd973ad02mr845714185a.14.1736393312109; Wed, 08 Jan 2025 19:28:32 -0800 (PST) Received: from echampetier.lan ([2607:fea8:1b9f:c5b0::4c4]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7bce35160c6sm25547085a.114.2025.01.08.19.28.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 19:28:31 -0800 (PST) From: Etienne Champetier To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: Etienne Champetier Subject: [PATCH net-next v2 2/2] selftests: bonding: add ipvlan over bond testing Date: Wed, 8 Jan 2025 22:28:19 -0500 Message-ID: <20250109032819.326528-3-champetier.etienne@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109032819.326528-1-champetier.etienne@gmail.com> References: <20250109032819.326528-1-champetier.etienne@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org This rework bond_macvlan.sh into bond_macvlan_ipvlan.sh We only test bridge mode for macvlan and l2 mode ]# ./bond_macvlan_ipvlan.sh TEST: active-backup/macvlan_bridge: IPv4: client->server [ OK ] ... TEST: active-backup/ipvlan_l2: IPv4: client->server [ OK ] ... TEST: balance-tlb/macvlan_bridge: IPv4: client->server [ OK ] ... TEST: balance-tlb/ipvlan_l2: IPv4: client->server [ OK ] ... TEST: balance-alb/macvlan_bridge: IPv4: client->server [ OK ] ... TEST: balance-alb/ipvlan_l2: IPv4: client->server [ OK ] ... Signed-off-by: Etienne Champetier --- .../selftests/drivers/net/bonding/Makefile | 2 +- .../drivers/net/bonding/bond_macvlan.sh | 99 ------------------- .../net/bonding/bond_macvlan_ipvlan.sh | 96 ++++++++++++++++++ .../selftests/drivers/net/bonding/config | 1 + 4 files changed, 98 insertions(+), 100 deletions(-) delete mode 100755 tools/testing/selftests/drivers/net/bonding/bond_macvlan.sh create mode 100755 tools/testing/selftests/drivers/net/bonding/bond_macvlan_ipvlan.sh diff --git a/tools/testing/selftests/drivers/net/bonding/Makefile b/tools/testing/selftests/drivers/net/bonding/Makefile index 03a089165d3f..2b10854e4b1e 100644 --- a/tools/testing/selftests/drivers/net/bonding/Makefile +++ b/tools/testing/selftests/drivers/net/bonding/Makefile @@ -10,7 +10,7 @@ TEST_PROGS := \ mode-2-recovery-updelay.sh \ bond_options.sh \ bond-eth-type-change.sh \ - bond_macvlan.sh + bond_macvlan_ipvlan.sh TEST_FILES := \ lag_lib.sh \ diff --git a/tools/testing/selftests/drivers/net/bonding/bond_macvlan.sh b/tools/testing/selftests/drivers/net/bonding/bond_macvlan.sh deleted file mode 100755 index b609fb6231f4..000000000000 --- a/tools/testing/selftests/drivers/net/bonding/bond_macvlan.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: GPL-2.0 -# -# Test macvlan over balance-alb - -lib_dir=$(dirname "$0") -source ${lib_dir}/bond_topo_2d1c.sh - -m1_ns="m1-$(mktemp -u XXXXXX)" -m2_ns="m1-$(mktemp -u XXXXXX)" -m1_ip4="192.0.2.11" -m1_ip6="2001:db8::11" -m2_ip4="192.0.2.12" -m2_ip6="2001:db8::12" - -cleanup() -{ - ip -n ${m1_ns} link del macv0 - ip netns del ${m1_ns} - ip -n ${m2_ns} link del macv0 - ip netns del ${m2_ns} - - client_destroy - server_destroy - gateway_destroy -} - -check_connection() -{ - local ns=${1} - local target=${2} - local message=${3:-"macvlan_over_bond"} - RET=0 - - - ip netns exec ${ns} ping ${target} -c 4 -i 0.1 &>/dev/null - check_err $? "ping failed" - log_test "$mode: $message" -} - -macvlan_over_bond() -{ - local param="$1" - RET=0 - - # setup new bond mode - bond_reset "${param}" - - ip -n ${s_ns} link add link bond0 name macv0 type macvlan mode bridge - ip -n ${s_ns} link set macv0 netns ${m1_ns} - ip -n ${m1_ns} link set dev macv0 up - ip -n ${m1_ns} addr add ${m1_ip4}/24 dev macv0 - ip -n ${m1_ns} addr add ${m1_ip6}/24 dev macv0 - - ip -n ${s_ns} link add link bond0 name macv0 type macvlan mode bridge - ip -n ${s_ns} link set macv0 netns ${m2_ns} - ip -n ${m2_ns} link set dev macv0 up - ip -n ${m2_ns} addr add ${m2_ip4}/24 dev macv0 - ip -n ${m2_ns} addr add ${m2_ip6}/24 dev macv0 - - sleep 2 - - check_connection "${c_ns}" "${s_ip4}" "IPv4: client->server" - check_connection "${c_ns}" "${s_ip6}" "IPv6: client->server" - check_connection "${c_ns}" "${m1_ip4}" "IPv4: client->macvlan_1" - check_connection "${c_ns}" "${m1_ip6}" "IPv6: client->macvlan_1" - check_connection "${c_ns}" "${m2_ip4}" "IPv4: client->macvlan_2" - check_connection "${c_ns}" "${m2_ip6}" "IPv6: client->macvlan_2" - check_connection "${m1_ns}" "${m2_ip4}" "IPv4: macvlan_1->macvlan_2" - check_connection "${m1_ns}" "${m2_ip6}" "IPv6: macvlan_1->macvlan_2" - - - sleep 5 - - check_connection "${s_ns}" "${c_ip4}" "IPv4: server->client" - check_connection "${s_ns}" "${c_ip6}" "IPv6: server->client" - check_connection "${m1_ns}" "${c_ip4}" "IPv4: macvlan_1->client" - check_connection "${m1_ns}" "${c_ip6}" "IPv6: macvlan_1->client" - check_connection "${m2_ns}" "${c_ip4}" "IPv4: macvlan_2->client" - check_connection "${m2_ns}" "${c_ip6}" "IPv6: macvlan_2->client" - check_connection "${m2_ns}" "${m1_ip4}" "IPv4: macvlan_2->macvlan_2" - check_connection "${m2_ns}" "${m1_ip6}" "IPv6: macvlan_2->macvlan_2" - - ip -n ${c_ns} neigh flush dev eth0 -} - -trap cleanup EXIT - -setup_prepare -ip netns add ${m1_ns} -ip netns add ${m2_ns} - -modes="active-backup balance-tlb balance-alb" - -for mode in $modes; do - macvlan_over_bond "mode $mode" -done - -exit $EXIT_STATUS diff --git a/tools/testing/selftests/drivers/net/bonding/bond_macvlan_ipvlan.sh b/tools/testing/selftests/drivers/net/bonding/bond_macvlan_ipvlan.sh new file mode 100755 index 000000000000..c4711272fe45 --- /dev/null +++ b/tools/testing/selftests/drivers/net/bonding/bond_macvlan_ipvlan.sh @@ -0,0 +1,96 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# Test macvlan/ipvlan over bond + +lib_dir=$(dirname "$0") +source ${lib_dir}/bond_topo_2d1c.sh + +xvlan1_ns="xvlan1-$(mktemp -u XXXXXX)" +xvlan2_ns="xvlan2-$(mktemp -u XXXXXX)" +xvlan1_ip4="192.0.2.11" +xvlan1_ip6="2001:db8::11" +xvlan2_ip4="192.0.2.12" +xvlan2_ip6="2001:db8::12" + +cleanup() +{ + client_destroy + server_destroy + gateway_destroy + + ip netns del ${xvlan1_ns} + ip netns del ${xvlan2_ns} +} + +check_connection() +{ + local ns=${1} + local target=${2} + local message=${3} + RET=0 + + ip netns exec ${ns} ping ${target} -c 4 -i 0.1 &>/dev/null + check_err $? "ping failed" + log_test "${bond_mode}/${xvlan_type}_${xvlan_mode}: ${message}" +} + +xvlan_over_bond() +{ + local param="$1" + local xvlan_type="$2" + local xvlan_mode="$3" + RET=0 + + # setup new bond mode + bond_reset "${param}" + + ip -n ${s_ns} link add link bond0 name ${xvlan_type}0 type ${xvlan_type} mode ${xvlan_mode} + ip -n ${s_ns} link set ${xvlan_type}0 netns ${xvlan1_ns} + ip -n ${xvlan1_ns} link set dev ${xvlan_type}0 up + ip -n ${xvlan1_ns} addr add ${xvlan1_ip4}/24 dev ${xvlan_type}0 + ip -n ${xvlan1_ns} addr add ${xvlan1_ip6}/24 dev ${xvlan_type}0 + + ip -n ${s_ns} link add link bond0 name ${xvlan_type}0 type ${xvlan_type} mode ${xvlan_mode} + ip -n ${s_ns} link set ${xvlan_type}0 netns ${xvlan2_ns} + ip -n ${xvlan2_ns} link set dev ${xvlan_type}0 up + ip -n ${xvlan2_ns} addr add ${xvlan2_ip4}/24 dev ${xvlan_type}0 + ip -n ${xvlan2_ns} addr add ${xvlan2_ip6}/24 dev ${xvlan_type}0 + + sleep 2 + + check_connection "${c_ns}" "${s_ip4}" "IPv4: client->server" + check_connection "${c_ns}" "${s_ip6}" "IPv6: client->server" + check_connection "${c_ns}" "${xvlan1_ip4}" "IPv4: client->${xvlan_type}_1" + check_connection "${c_ns}" "${xvlan1_ip6}" "IPv6: client->${xvlan_type}_1" + check_connection "${c_ns}" "${xvlan2_ip4}" "IPv4: client->${xvlan_type}_2" + check_connection "${c_ns}" "${xvlan2_ip6}" "IPv6: client->${xvlan_type}_2" + check_connection "${xvlan1_ns}" "${xvlan2_ip4}" "IPv4: ${xvlan_type}_1->${xvlan_type}_2" + check_connection "${xvlan1_ns}" "${xvlan2_ip6}" "IPv6: ${xvlan_type}_1->${xvlan_type}_2" + + check_connection "${s_ns}" "${c_ip4}" "IPv4: server->client" + check_connection "${s_ns}" "${c_ip6}" "IPv6: server->client" + check_connection "${xvlan1_ns}" "${c_ip4}" "IPv4: ${xvlan_type}_1->client" + check_connection "${xvlan1_ns}" "${c_ip6}" "IPv6: ${xvlan_type}_1->client" + check_connection "${xvlan2_ns}" "${c_ip4}" "IPv4: ${xvlan_type}_2->client" + check_connection "${xvlan2_ns}" "${c_ip6}" "IPv6: ${xvlan_type}_2->client" + check_connection "${xvlan2_ns}" "${xvlan1_ip4}" "IPv4: ${xvlan_type}_2->${xvlan_type}_1" + check_connection "${xvlan2_ns}" "${xvlan1_ip6}" "IPv6: ${xvlan_type}_2->${xvlan_type}_1" + + ip -n ${c_ns} neigh flush dev eth0 +} + +trap cleanup EXIT + +setup_prepare +ip netns add ${xvlan1_ns} +ip netns add ${xvlan2_ns} + +bond_modes="active-backup balance-tlb balance-alb" + +for bond_mode in ${bond_modes}; do + xvlan_over_bond "mode ${bond_mode}" macvlan bridge + xvlan_over_bond "mode ${bond_mode}" ipvlan l2 +done + +exit $EXIT_STATUS diff --git a/tools/testing/selftests/drivers/net/bonding/config b/tools/testing/selftests/drivers/net/bonding/config index 899d7fb6ea8e..dad4e5fda4db 100644 --- a/tools/testing/selftests/drivers/net/bonding/config +++ b/tools/testing/selftests/drivers/net/bonding/config @@ -3,6 +3,7 @@ CONFIG_BRIDGE=y CONFIG_DUMMY=y CONFIG_IPV6=y CONFIG_MACVLAN=y +CONFIG_IPVLAN=y CONFIG_NET_ACT_GACT=y CONFIG_NET_CLS_FLOWER=y CONFIG_NET_SCH_INGRESS=y