From patchwork Wed Jan 3 09:48:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dichtel X-Patchwork-Id: 13509821 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wm1-f98.google.com (mail-wm1-f98.google.com [209.85.128.98]) (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 F202518AF6 for ; Wed, 3 Jan 2024 09:48:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=6wind.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=6wind.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=6wind.com header.i=@6wind.com header.b="T5YfhKX3" Received: by mail-wm1-f98.google.com with SMTP id 5b1f17b1804b1-40d5f402571so69249025e9.0 for ; Wed, 03 Jan 2024 01:48:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; t=1704275331; x=1704880131; 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=ks0oa0YKogNtQyDRYtTec5mz65pLjC2m8lMsaisLSP0=; b=T5YfhKX3pmytkryLeMeC7YkwOYTgwxt4K4QGyPEhhloJoSRqtAmwivRGYWHJ8+EiMW GLtJyJExvW7so9fs61oIe5I7lzS16kYdLuv3/+/BAxVpVl+ke6B+wzlwqPpeDOPTn0/r 7PeTRDkiSO584a1a3M6lo8pvNZfN1KmUE6ori+AX7VXVA6W1GQMLdKxxC13625DggJej E/c4etG9bWF9tZ6/W7ANNhLwhAv9o8RE4sbHkVPk1AFdmhU0MgiFMiZXnOvztqKqdPsQ jAMRXklctbxQXrdR4mjaRMjSZxMRsn8q6icpZprjovlJHc04zwLfMBnsG33byNcIrmsl D5Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704275331; x=1704880131; 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=ks0oa0YKogNtQyDRYtTec5mz65pLjC2m8lMsaisLSP0=; b=hb8G2hzyG8tWQUWTILHOVzHVZJTs9VgcQnMHBa7SPEEFnAZrR3OHUd9tgg7Kbi2UkN QY0xFdJsNgVoj7q/XulXX/AX8B8r9HiRDMRqf/u4KRgf/Rp03BCtJzBEG1gRNFD3gh8I JYlkb8TFncLVvpkspGrXJfCJN/xS8eKWzC56Ma3X6HJyPHd4OMrdGn38lsjw6qqTFy+6 HVej7GFeU1mTQuZrySCrWAF/Li9dSH562xgD/K5T3tJndvn52Sv/kQPPYOZv7guGDvti 9eNmYuImerDs8EipGWt4Js3pDiPrhJONk+XkFs8CjjZJ6PCxldy1uYekx7mO6INpYlzD OuXw== X-Gm-Message-State: AOJu0YzJIIJUgvPWvKNqP2/CNMcihi0/3dTn09oqTevKktep+d7QMbI4 uJFmL8k02SxRITaBukJXUuDEK0P9AdtWTssRi5+T6TnXB0wgpBl6ynFuAg== X-Google-Smtp-Source: AGHT+IGMP8tYoKtal31XwkHdMkNwswtiE9lm9Bx5A7p3hzqHaJBYNdOUaZISIkGA0l7Up8IfRIC+gCRgsj2r X-Received: by 2002:a05:600c:34cf:b0:40d:924d:9417 with SMTP id d15-20020a05600c34cf00b0040d924d9417mr84525wmq.67.1704275331209; Wed, 03 Jan 2024 01:48:51 -0800 (PST) Received: from smtpservice.6wind.com ([185.13.181.2]) by smtp-relay.gmail.com with ESMTP id ba20-20020a0560001c1400b00337092f3e28sm974780wrb.89.2024.01.03.01.48.51; Wed, 03 Jan 2024 01:48:51 -0800 (PST) X-Relaying-Domain: 6wind.com Received: from bretzel (bretzel.dev.6wind.com [10.17.1.57]) by smtpservice.6wind.com (Postfix) with ESMTPS id EE1E360301; Wed, 3 Jan 2024 10:48:50 +0100 (CET) Received: from dichtel by bretzel with local (Exim 4.94.2) (envelope-from ) id 1rKxrm-00A3cp-Lt; Wed, 03 Jan 2024 10:48:50 +0100 From: Nicolas Dichtel To: "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , Phil Sutter , David Ahern Cc: netdev@vger.kernel.org, Nicolas Dichtel , stable@vger.kernel.org Subject: [PATCH net v2 1/2] rtnetlink: allow to set iface down before enslaving it Date: Wed, 3 Jan 2024 10:48:45 +0100 Message-Id: <20240103094846.2397083-2-nicolas.dichtel@6wind.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240103094846.2397083-1-nicolas.dichtel@6wind.com> References: <20240103094846.2397083-1-nicolas.dichtel@6wind.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 The below commit adds support for: > ip link set dummy0 down > ip link set dummy0 master bond0 up but breaks the opposite: > ip link set dummy0 up > ip link set dummy0 master bond0 down Let's add a workaround to have both commands working. Cc: stable@vger.kernel.org Fixes: a4abfa627c38 ("net: rtnetlink: Enslave device before bringing it up") Signed-off-by: Nicolas Dichtel Acked-by: Phil Sutter Reviewed-by: David Ahern --- net/core/rtnetlink.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index e8431c6c8490..dd79693c2d91 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -2905,6 +2905,14 @@ static int do_setlink(const struct sk_buff *skb, call_netdevice_notifiers(NETDEV_CHANGEADDR, dev); } + /* Backward compat: enable to set interface down before enslaving it */ + if (!(ifm->ifi_flags & IFF_UP) && ifm->ifi_change & IFF_UP) { + err = dev_change_flags(dev, rtnl_dev_combine_flags(dev, ifm), + extack); + if (err < 0) + goto errout; + } + if (tb[IFLA_MASTER]) { err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]), extack); if (err) From patchwork Wed Jan 3 09:48:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dichtel X-Patchwork-Id: 13509820 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wr1-f100.google.com (mail-wr1-f100.google.com [209.85.221.100]) (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 25D0C18B10 for ; Wed, 3 Jan 2024 09:48:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=6wind.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=6wind.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=6wind.com header.i=@6wind.com header.b="B8A0G8rD" Received: by mail-wr1-f100.google.com with SMTP id ffacd0b85a97d-336746c7b6dso9247185f8f.0 for ; Wed, 03 Jan 2024 01:48:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; t=1704275331; x=1704880131; 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=yIa4kG4qt5bUO3xzFheVS/ahZwWAiFJ8Wb4M2t36nOE=; b=B8A0G8rDZCmLnLddzYBVAiJHS/Hn5aQ+UO69ZBGYx0/qtDE3m4tlmGtZtJuyrri0ID rIx1Udc7sNwjdDe3+62xht/VSL8QWeOteIs92LjY5SZfb19SlrNpdNzjgV/1aiS6DL2l EWinqJYPB8I+s0qio/lTmpxZhsKtqtYhTwPfZ6GlAz4U3N4fyqwgMv1LiyFvp9em+xCx f1z0BGtCvZjgQC0CLcVw8N/+XrqeOn7v9QMD1Om5RYqHBbix26VKhv2rud9qWtPxQeOH F+I1JnG3nhDLCeRxvPHZ7E7PeyQIMjXpipMrQVFfEuv33U3EFDpY87EbWrChi6KJkBHH S8gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704275331; x=1704880131; 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=yIa4kG4qt5bUO3xzFheVS/ahZwWAiFJ8Wb4M2t36nOE=; b=s5TumiatCeU6rhVqPqGYth8ejL/oTTjRv3f7qXsUT9VRFx04t/ZocinE1eRbei3GUn 30vEr9956oyriAI+vauJcjh/yPgILln/TFHrENnuYDwhW3BLK0KEwhqStkKWvL1Yi9X/ N/fSUFUPRxQ71JqRORRt3b+ia8NarKyVREXAIkJd+EMLtyiiiWhO9nx36CyJUNhvh96i h1OmEZBypowY6uUUQJGqvA7NT8vz7F5W6yWbpZMP3wDNtsrojyQR6QSxNgNxiM1vxijR g0pTvJjqAsEEMiUR/tqEGlHus9tMO+16WdkM4fWrqL6Y2WylewUqqxAY2h967cjEUEp1 Xk1Q== X-Gm-Message-State: AOJu0YwoM58IKvWTQjDnwztoXljQd6krEzNIlcwMHFlRNtBK+26R8Soa pnUQPSp1r2QP35oA6D9gW23RQKcC/rIR9UxxV06gN4pduWg7w8P7kdTHaQ== X-Google-Smtp-Source: AGHT+IGdmnr6+p7hz/i8bGMCyMOVBhrXO1BjPKxOznQkdXBw0GXW8hPNnc/h3KYMKaqEwyVLMePlaUJcqj2B X-Received: by 2002:a05:6000:1b03:b0:336:80c1:f6a8 with SMTP id f3-20020a0560001b0300b0033680c1f6a8mr10565041wrz.88.1704275331296; Wed, 03 Jan 2024 01:48:51 -0800 (PST) Received: from smtpservice.6wind.com ([185.13.181.2]) by smtp-relay.gmail.com with ESMTP id bs24-20020a056000071800b003374c867a26sm21924wrb.48.2024.01.03.01.48.51; Wed, 03 Jan 2024 01:48:51 -0800 (PST) X-Relaying-Domain: 6wind.com Received: from bretzel (bretzel.dev.6wind.com [10.17.1.57]) by smtpservice.6wind.com (Postfix) with ESMTPS id 09A6A6045F; Wed, 3 Jan 2024 10:48:51 +0100 (CET) Received: from dichtel by bretzel with local (Exim 4.94.2) (envelope-from ) id 1rKxrm-00A3cs-MJ; Wed, 03 Jan 2024 10:48:50 +0100 From: Nicolas Dichtel To: "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , Phil Sutter , David Ahern Cc: netdev@vger.kernel.org, Nicolas Dichtel Subject: [PATCH net v2 2/2] selftests: rtnetlink: check enslaving iface in a bond Date: Wed, 3 Jan 2024 10:48:46 +0100 Message-Id: <20240103094846.2397083-3-nicolas.dichtel@6wind.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240103094846.2397083-1-nicolas.dichtel@6wind.com> References: <20240103094846.2397083-1-nicolas.dichtel@6wind.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 The goal is to check the following two sequences: > ip link set dummy0 down > ip link set dummy0 master bond0 up and > ip link set dummy0 up > ip link set dummy0 master bond0 down Signed-off-by: Nicolas Dichtel Reviewed-by: David Ahern --- tools/testing/selftests/net/rtnetlink.sh | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh index 26827ea4e3e5..130be7de76af 100755 --- a/tools/testing/selftests/net/rtnetlink.sh +++ b/tools/testing/selftests/net/rtnetlink.sh @@ -28,6 +28,7 @@ ALL_TESTS=" kci_test_neigh_get kci_test_bridge_parent_id kci_test_address_proto + kci_test_enslave_bonding " devdummy="test-dummy0" @@ -1239,6 +1240,44 @@ kci_test_address_proto() return $ret } +kci_test_enslave_bonding() +{ + local testns="testns" + local bond="bond123" + local dummy="dummy123" + local ret=0 + + run_cmd ip netns add "$testns" + if [ $? -ne 0 ]; then + end_test "SKIP bonding tests: cannot add net namespace $testns" + return $ksft_skip + fi + + # test native tunnel + run_cmd ip -netns $testns link add dev $bond type bond mode balance-rr + run_cmd ip -netns $testns link add dev $dummy type dummy + run_cmd ip -netns $testns link set dev $dummy up + run_cmd ip -netns $testns link set dev $dummy master $bond down + if [ $ret -ne 0 ]; then + end_test "FAIL: enslave an up interface in a bonding" + ip netns del "$testns" + return 1 + fi + + run_cmd ip -netns $testns link del dev $dummy + run_cmd ip -netns $testns link add dev $dummy type dummy + run_cmd ip -netns $testns link set dev $dummy down + run_cmd ip -netns $testns link set dev $dummy master $bond up + if [ $ret -ne 0 ]; then + end_test "FAIL: enslave an down interface in a bonding and set it up" + ip netns del "$testns" + return 1 + fi + + end_test "PASS: enslave iface in a bonding" + ip netns del "$testns" +} + kci_test_rtnl() { local current_test