From patchwork Fri Dec 29 10:08:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dichtel X-Patchwork-Id: 13506425 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wr1-f99.google.com (mail-wr1-f99.google.com [209.85.221.99]) (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 B99D110A09 for ; Fri, 29 Dec 2023 10:08:45 +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="QS0s+loO" Received: by mail-wr1-f99.google.com with SMTP id ffacd0b85a97d-3369339f646so5656815f8f.0 for ; Fri, 29 Dec 2023 02:08:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; t=1703844524; x=1704449324; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qN2AySqHIVWazQbwOSCTBYt1qaBst2lx7B05hPGcnJw=; b=QS0s+loO5hmdVclRL5EKBAwciePETSkeDYk8oebwNuUj+f+3vjqdpt2wCeQZ1tQDJp +RnaC42U2ut390H8aOHOhq3alTsfMIkBW0nwTvKTAkbq/VOKG9YQ1Bd6xa/TeCctO6+m 9llU3SjnHEglf/QFUbXvoZ2ZRfnWl7GrAdDj8HwqyNOt2sPTV4dqoehDK9AxG4rFX61X thN4+Q/rIzuTTlXl33n3LIpOpVJJbK4HcCwxkd4vBtp+nZfzwLx8zo6SagsbM2DWVvw0 YPAYKpcEm4LSTslEtNT+3sJ/nufDRkX85MHDLmFd0asa1bmoOxhffrbCJCkDoNCz5rwA 1z/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703844524; x=1704449324; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qN2AySqHIVWazQbwOSCTBYt1qaBst2lx7B05hPGcnJw=; b=AN8pIHRklrRB6sutYR5a3rIAC61c/z4nk0k9Y4GGIWYDwdb/RI+rkyq8TbBQiA9T8e RiZiBDV4f3z0w8lsXaBuYQHaU0qI5cGdRLTvdesTbOatvGDZE41De/S+c/mikkMP3gVQ MgADPyAWKWUhJmb1HN8K8i219OKUyMoSH7iuVwIApSsobxCKyLIrIEl28lWB4BY7gbO+ B7fh0VNsMmN8871lx2Km3yl08NB1pz1PLuD/JxRD1kcNR9Pq1UdUsn8O04H01nxnFUde VhflgTiEReqx2OVK6DuYqWmsvW7ElvfubEiZHcwK2ZBa4JWNvE1OewNo077sHhPrbb11 i/Xg== X-Gm-Message-State: AOJu0YyRCyxx0ja2Shh/JImrwcEEEC2NuWgcog5UwQrWYfoUtVFJaj4v Sc2fjXQnv5SJNGo0C6ME3ZQWQl8RbQHCJnHymF1SHux0CnIabKBoTLeq9w== X-Google-Smtp-Source: AGHT+IE3Msn/QkpYTu3dm8ZvoeghZneX0m4ay0PqWn2cDbh+KgTRbOhot869pbvPEsCG/qDIeYZyDQoU82c5 X-Received: by 2002:a5d:644b:0:b0:336:6919:9180 with SMTP id d11-20020a5d644b000000b0033669199180mr5578845wrw.38.1703844523914; Fri, 29 Dec 2023 02:08:43 -0800 (PST) Received: from smtpservice.6wind.com ([185.13.181.2]) by smtp-relay.gmail.com with ESMTP id b10-20020a05600003ca00b003372b662986sm28217wrg.41.2023.12.29.02.08.43; Fri, 29 Dec 2023 02:08:43 -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 A2170600F0; Fri, 29 Dec 2023 11:08:43 +0100 (CET) Received: from dichtel by bretzel with local (Exim 4.94.2) (envelope-from ) id 1rJ9nH-00GlmZ-Bi; Fri, 29 Dec 2023 11:08:43 +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] rtnetlink: allow to set iface down before enslaving it Date: Fri, 29 Dec 2023 11:08:35 +0100 Message-Id: <20231229100835.3996906-1-nicolas.dichtel@6wind.com> X-Mailer: git-send-email 2.39.2 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 --- 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)