From patchwork Wed Feb 3 16:08:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12064695 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8559CC433E6 for ; Wed, 3 Feb 2021 16:10:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 41C0F64E36 for ; Wed, 3 Feb 2021 16:10:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234803AbhBCQJm (ORCPT ); Wed, 3 Feb 2021 11:09:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234876AbhBCQJY (ORCPT ); Wed, 3 Feb 2021 11:09:24 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3FA1C0613D6 for ; Wed, 3 Feb 2021 08:08:42 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id f14so12383460ejc.8 for ; Wed, 03 Feb 2021 08:08:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8ybgqix3kyeUq3RKDuuhyNef4XyLVRGqFwbLZYyCLiY=; b=JTIr3SLF0R2cjTNmsAOW8bJFEPf1Onk8+6Vw8yU8nHBMlkn/9w54hx9zI7/iRW+0Jn vKybe+3j9SFvHjEaDh8KZxU8zz7ySWa7QqvMrHM6oAu9eNRx74HJTbYqfr0W6x5gfu0u bMZyX60WcoEWZJx9rC/XPD6BZfqjK82NXkIF+n+Fbd9Eqr1qz7Bdvtlq3lyLknU+m2eG eWNJoL22g48NAYjfLkOjdNLwfbSwgbmjrYUZU+7guawkwzcnE/CHSHSsaSIiPrim55yc eMmG9wJ9e9iBmPVKQpFNc0yVzVq1YfX7oWn2umG5Z+7No7LPu7whX8bSMw/i5a+M9f9e 1swA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8ybgqix3kyeUq3RKDuuhyNef4XyLVRGqFwbLZYyCLiY=; b=OC39t8GQC99Nnqk5wt5wVdTD0HZUBogfYwjZJ/c3zkA94wwAqg9MU3cR4EfGxuL/52 CSMpicJIeeI1m3VAB+oR/Qq+Bq3KEHEoUmIJnNloO54OJE4oDVM6SpfNbAo/jxk8SEeh +WzPG3U+O7thw/jpYslErkoeFHQ+41kdqFm4DF/wb0BCmPh4381qm3wY+SqlornzOvRY 2FaqdODck1K1XocLEoV9fncip3bfCzQX6rKU57F7a33l9Cv3T5wti1ILropxUEcKY8YQ 6naldi2ceIFYhmeml/HCcuiC2Zqeyv1fo2zOf8t8PFDCAMi51qAj1bsx1dWJmeKcZNxj wSug== X-Gm-Message-State: AOAM533s8Jn7gb6ropb/Um7vKlAobgnyZw6zkj2FTO0sOoKuM17hS5QV g8N3gN4GrOqbQtw5WzJjaxE= X-Google-Smtp-Source: ABdhPJwwZyfWGdwaiF5fmJ0Fga2tl7ZLYKPYuMKw8+gIGWmPfvVCgE6imDX0k0/pTXqJ5n4nvkPXXw== X-Received: by 2002:a17:906:4442:: with SMTP id i2mr3961838ejp.41.1612368521199; Wed, 03 Feb 2021 08:08:41 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id u16sm1085589eds.71.2021.02.03.08.08.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 08:08:40 -0800 (PST) From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Andrew Lunn , Florian Fainelli , Vivien Didelot , Hideaki YOSHIFUJI Subject: [PATCH v2 net-next 1/4] net: dsa: automatically bring up DSA master when opening user port Date: Wed, 3 Feb 2021 18:08:20 +0200 Message-Id: <20210203160823.2163194-2-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203160823.2163194-1-olteanv@gmail.com> References: <20210203160823.2163194-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vladimir Oltean DSA wants the master interface to be open before the user port is due to historical reasons. The promiscuity of interfaces that are down used to have issues, as referenced Lennert Buytenhek in commit df02c6ff2e39 ("dsa: fix master interface allmulti/promisc handling"). The bugfix mentioned there, commit b6c40d68ff64 ("net: only invoke dev->change_rx_flags when device is UP"), was basically a "don't do that" approach to working around the promiscuity while down issue. Further work done by Vlad Yasevich in commit d2615bf45069 ("net: core: Always propagate flag changes to interfaces") has resolved the underlying issue, and it is strictly up to the DSA and 8021q drivers now, it is no longer mandated by the networking core that the master interface must be up when changing its promiscuity. From DSA's point of view, deciding to error out in dsa_slave_open because the master isn't up is (a) a bad user experience and (b) missing the forest for the trees. Even if there still was an issue with promiscuity while down, DSA could still do this and avoid it: open the DSA master manually, then do whatever. Voila, the DSA master is now up, no need to error out. Doing it this way has the additional benefit that user space can now remove DSA-specific workarounds, like systemd-networkd with BindCarrier: https://github.com/systemd/systemd/issues/7478 And we can finally remove one of the 2 bullets in the "Common pitfalls using DSA setups" chapter. Signed-off-by: Vladimir Oltean Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli --- Changes in v2: None. Documentation/networking/dsa/dsa.rst | 4 ---- net/dsa/slave.c | 10 ++++++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Documentation/networking/dsa/dsa.rst b/Documentation/networking/dsa/dsa.rst index a8d15dd2b42b..e9517af5fe02 100644 --- a/Documentation/networking/dsa/dsa.rst +++ b/Documentation/networking/dsa/dsa.rst @@ -273,10 +273,6 @@ will not make us go through the switch tagging protocol transmit function, so the Ethernet switch on the other end, expecting a tag will typically drop this frame. -Slave network devices check that the master network device is UP before allowing -you to administratively bring UP these slave network devices. A common -configuration mistake is forgetting to bring UP the master network device first. - Interactions with other subsystems ================================== diff --git a/net/dsa/slave.c b/net/dsa/slave.c index b0571ab4e5a7..4616bd7c8684 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -68,8 +68,14 @@ static int dsa_slave_open(struct net_device *dev) struct dsa_port *dp = dsa_slave_to_port(dev); int err; - if (!(master->flags & IFF_UP)) - return -ENETDOWN; + if (!(master->flags & IFF_UP)) { + err = dev_change_flags(master, master->flags | IFF_UP, NULL); + if (err < 0) { + netdev_err(dev, "failed to open master %s\n", + master->name); + goto out; + } + } if (!ether_addr_equal(dev->dev_addr, master->dev_addr)) { err = dev_uc_add(master, dev->dev_addr);