kernel: Backport patch to automatically bring up DSA master when opening user port
authorHauke Mehrtens <hauke@hauke-m.de>
Mon, 21 Jun 2021 22:45:18 +0000 (00:45 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Tue, 22 Jun 2021 21:52:09 +0000 (23:52 +0200)
Without this patch we have to manually bring up the CPU interface in
failsafe mode.

This was backported from kernel 5.12.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Tested-by: Rafał Miłecki <rafal@milecki.pl>
(cherry picked from commit 2e17c710954bd3506467d700dee23757b138fedd)

target/linux/generic/backport-5.4/765-v5.12-net-dsa-automatically-bring-up-DSA-master-when-openi.patch [new file with mode: 0644]
target/linux/generic/backport-5.4/771-v5.12-net-dsa-be-louder-when-a-non-legacy-FDB-operation-fa.patch
target/linux/generic/backport-5.4/772-v5.12-net-dsa-don-t-use-switchdev_notifier_fdb_info-in-dsa.patch
target/linux/generic/backport-5.4/773-v5.12-net-dsa-move-switchdev-event-implementation-under-th.patch
target/linux/generic/backport-5.4/774-v5.12-net-dsa-exit-early-in-dsa_slave_switchdev_event-if-w.patch
target/linux/generic/backport-5.4/775-v5.12-net-dsa-listen-for-SWITCHDEV_-FDB-DEL-_ADD_TO_DEVICE.patch
target/linux/generic/pending-5.4/647-net-dsa-support-hardware-flow-table-offload.patch
target/linux/generic/pending-5.4/765-net-dsa-Include-local-addresses-in-assisted-CPU-port.patch
target/linux/generic/pending-5.4/766-net-dsa-Include-bridge-addresses-in-assisted-CPU-por.patch
target/linux/generic/pending-5.4/767-net-dsa-Sync-static-FDB-entries-on-foreign-interface.patch

diff --git a/target/linux/generic/backport-5.4/765-v5.12-net-dsa-automatically-bring-up-DSA-master-when-openi.patch b/target/linux/generic/backport-5.4/765-v5.12-net-dsa-automatically-bring-up-DSA-master-when-openi.patch
new file mode 100644 (file)
index 0000000..7ec2689
--- /dev/null
@@ -0,0 +1,85 @@
+From 9d5ef190e5615a7b63af89f88c4106a5bc127974 Mon Sep 17 00:00:00 2001
+From: Vladimir Oltean <vladimir.oltean@nxp.com>
+Date: Fri, 5 Feb 2021 15:37:10 +0200
+Subject: [PATCH] net: dsa: automatically bring up DSA master when opening user
+ port
+
+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) knocking at an open door.
+Even if there still was an issue with promiscuity while down, DSA could
+still just open the master and avoid it.
+
+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.
+
+Tested with two cascaded DSA switches:
+
+$ ip link set sw0p2 up
+fsl_enetc 0000:00:00.2 eno2: configuring for fixed/internal link mode
+fsl_enetc 0000:00:00.2 eno2: Link is Up - 1Gbps/Full - flow control rx/tx
+mscc_felix 0000:00:00.5 swp0: configuring for fixed/sgmii link mode
+mscc_felix 0000:00:00.5 swp0: Link is Up - 1Gbps/Full - flow control off
+8021q: adding VLAN 0 to HW filter on device swp0
+sja1105 spi2.0 sw0p2: configuring for phy/rgmii-id link mode
+IPv6: ADDRCONF(NETDEV_CHANGE): eno2: link becomes ready
+IPv6: ADDRCONF(NETDEV_CHANGE): swp0: link becomes ready
+
+Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
+Reviewed-by: Andrew Lunn <andrew@lunn.ch>
+Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+---
+ Documentation/networking/dsa/dsa.rst | 4 ----
+ net/dsa/slave.c                      | 7 +++++--
+ 2 files changed, 5 insertions(+), 6 deletions(-)
+
+--- a/Documentation/networking/dsa/dsa.rst
++++ b/Documentation/networking/dsa/dsa.rst
+@@ -273,10 +273,6 @@ will not make us go through the switch t
+ 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
+ ==================================
+--- a/net/dsa/slave.c
++++ b/net/dsa/slave.c
+@@ -70,8 +70,11 @@ static int dsa_slave_open(struct net_dev
+       struct dsa_port *dp = dsa_slave_to_port(dev);
+       int err;
+-      if (!(master->flags & IFF_UP))
+-              return -ENETDOWN;
++      err = dev_open(master, 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);
index 297175855bb0dc15f107b139afc450cb6b9bcf83..9ec1a226b5f36e018cea0c8acf006579c2052ea3 100644 (file)
@@ -25,7 +25,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
 
 --- a/net/dsa/slave.c
 +++ b/net/dsa/slave.c
-@@ -1592,7 +1592,9 @@ static void dsa_slave_switchdev_event_wo
+@@ -1595,7 +1595,9 @@ static void dsa_slave_switchdev_event_wo
  
                err = dsa_port_fdb_add(dp, fdb_info->addr, fdb_info->vid);
                if (err) {
@@ -36,7 +36,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
                        break;
                }
                fdb_info->offloaded = true;
-@@ -1607,9 +1609,11 @@ static void dsa_slave_switchdev_event_wo
+@@ -1610,9 +1612,11 @@ static void dsa_slave_switchdev_event_wo
  
                err = dsa_port_fdb_del(dp, fdb_info->addr, fdb_info->vid);
                if (err) {
index e9b74053e0ef13a2ac251c66c73339bafdbcc2b4..bc29fbecc4f7fc8d410cc86146e23fb9937b87f1 100644 (file)
@@ -54,7 +54,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
        struct sk_buff *        (*xmit)(struct sk_buff *skb,
 --- a/net/dsa/slave.c
 +++ b/net/dsa/slave.c
-@@ -1567,76 +1567,66 @@ static int dsa_slave_netdevice_event(str
+@@ -1570,76 +1570,66 @@ static int dsa_slave_netdevice_event(str
        return NOTIFY_DONE;
  }
  
@@ -167,7 +167,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  }
  
  /* Called under rcu_read_lock() */
-@@ -1644,7 +1634,9 @@ static int dsa_slave_switchdev_event(str
+@@ -1647,7 +1637,9 @@ static int dsa_slave_switchdev_event(str
                                     unsigned long event, void *ptr)
  {
        struct net_device *dev = switchdev_notifier_info_to_dev(ptr);
@@ -177,7 +177,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
        int err;
  
        if (event == SWITCHDEV_PORT_ATTR_SET) {
-@@ -1657,20 +1649,32 @@ static int dsa_slave_switchdev_event(str
+@@ -1660,20 +1652,32 @@ static int dsa_slave_switchdev_event(str
        if (!dsa_slave_dev_check(dev))
                return NOTIFY_DONE;
  
@@ -213,7 +213,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
                dev_hold(dev);
                break;
        default:
-@@ -1680,10 +1684,6 @@ static int dsa_slave_switchdev_event(str
+@@ -1683,10 +1687,6 @@ static int dsa_slave_switchdev_event(str
  
        dsa_schedule_work(&switchdev_work->work);
        return NOTIFY_OK;
index b46cd7545e135380452dcb874e91b7db1c662d50..50c7a0859066ffee8700aa1988cc5efd036e2315 100644 (file)
@@ -20,7 +20,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
 
 --- a/net/dsa/slave.c
 +++ b/net/dsa/slave.c
-@@ -1639,31 +1639,29 @@ static int dsa_slave_switchdev_event(str
+@@ -1642,31 +1642,29 @@ static int dsa_slave_switchdev_event(str
        struct dsa_port *dp;
        int err;
  
@@ -68,7 +68,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
                fdb_info = ptr;
  
                if (!fdb_info->added_by_user) {
-@@ -1676,13 +1674,12 @@ static int dsa_slave_switchdev_event(str
+@@ -1679,13 +1677,12 @@ static int dsa_slave_switchdev_event(str
                switchdev_work->vid = fdb_info->vid;
  
                dev_hold(dev);
index d38c3901cf2282503f739e117545578a2b94b57a..dcb6bbdc49482b3821a4f1788c60908dcaf18561 100644 (file)
@@ -30,7 +30,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
 
 --- a/net/dsa/slave.c
 +++ b/net/dsa/slave.c
-@@ -1652,6 +1652,9 @@ static int dsa_slave_switchdev_event(str
+@@ -1655,6 +1655,9 @@ static int dsa_slave_switchdev_event(str
  
                dp = dsa_slave_to_port(dev);
  
index 4aa85e5750531468eda9013ffdbac1f465ccad7d..b49d11a776d64d3d8216e7b4404500aa85274c98 100644 (file)
@@ -172,7 +172,7 @@ Signed-off-by: DENG Qingfang <dqfext@gmail.com>
         */
 --- a/net/dsa/slave.c
 +++ b/net/dsa/slave.c
-@@ -1629,6 +1629,25 @@ static void dsa_slave_switchdev_event_wo
+@@ -1632,6 +1632,25 @@ static void dsa_slave_switchdev_event_wo
                dev_put(dp->slave);
  }
  
@@ -198,7 +198,7 @@ Signed-off-by: DENG Qingfang <dqfext@gmail.com>
  /* Called under rcu_read_lock() */
  static int dsa_slave_switchdev_event(struct notifier_block *unused,
                                     unsigned long event, void *ptr)
-@@ -1647,10 +1666,37 @@ static int dsa_slave_switchdev_event(str
+@@ -1650,10 +1669,37 @@ static int dsa_slave_switchdev_event(str
                return notifier_from_errno(err);
        case SWITCHDEV_FDB_ADD_TO_DEVICE:
        case SWITCHDEV_FDB_DEL_TO_DEVICE:
@@ -239,7 +239,7 @@ Signed-off-by: DENG Qingfang <dqfext@gmail.com>
  
                if (!dp->ds->ops->port_fdb_add || !dp->ds->ops->port_fdb_del)
                        return NOTIFY_DONE;
-@@ -1665,18 +1711,13 @@ static int dsa_slave_switchdev_event(str
+@@ -1668,18 +1714,13 @@ static int dsa_slave_switchdev_event(str
                switchdev_work->port = dp->index;
                switchdev_work->event = event;
  
index 85c606c455593d42568bdd04f0eecf9ceeae3e89..91aae5b65c730d38d2b34949e7ea1e645c294b5e 100644 (file)
@@ -38,7 +38,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  
  #include "dsa_priv.h"
  
-@@ -1223,6 +1227,27 @@ static struct devlink_port *dsa_slave_ge
+@@ -1226,6 +1230,27 @@ static struct devlink_port *dsa_slave_ge
        return dp->ds->devlink ? &dp->devlink_port : NULL;
  }
  
@@ -66,7 +66,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  static const struct net_device_ops dsa_slave_netdev_ops = {
        .ndo_open               = dsa_slave_open,
        .ndo_stop               = dsa_slave_close,
-@@ -1247,6 +1272,9 @@ static const struct net_device_ops dsa_s
+@@ -1250,6 +1275,9 @@ static const struct net_device_ops dsa_s
        .ndo_vlan_rx_add_vid    = dsa_slave_vlan_rx_add_vid,
        .ndo_vlan_rx_kill_vid   = dsa_slave_vlan_rx_kill_vid,
        .ndo_get_devlink_port   = dsa_slave_get_devlink_port,
index e1a7a0e4483da762804089c0ffe69ca73309d9b0..d73481fcc0f5445c6eb676442c3aff8f6e0f2b86 100644 (file)
@@ -18,7 +18,7 @@ Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
 
 --- a/net/dsa/slave.c
 +++ b/net/dsa/slave.c
-@@ -1697,10 +1697,12 @@ static int dsa_slave_switchdev_event(str
+@@ -1700,10 +1700,12 @@ static int dsa_slave_switchdev_event(str
                fdb_info = ptr;
  
                if (dsa_slave_dev_check(dev)) {
index f985adf736087c6e2e5b430d026d31d611fdddd0..e66aa93488b5860219562666218c3ba78e2d79af 100644 (file)
@@ -15,7 +15,7 @@ Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
 
 --- a/net/dsa/slave.c
 +++ b/net/dsa/slave.c
-@@ -1711,7 +1711,11 @@ static int dsa_slave_switchdev_event(str
+@@ -1714,7 +1714,11 @@ static int dsa_slave_switchdev_event(str
                        struct net_device *br_dev;
                        struct dsa_slave_priv *p;
  
index 984d9805f69f3a9e46c74a588824eaab67830d9d..5305e3d114ba2b4e1a7a2b2bcc4931588eada395 100644 (file)
@@ -28,7 +28,7 @@ Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
 
 --- a/net/dsa/slave.c
 +++ b/net/dsa/slave.c
-@@ -1704,9 +1704,12 @@ static int dsa_slave_switchdev_event(str
+@@ -1707,9 +1707,12 @@ static int dsa_slave_switchdev_event(str
                        else if (!fdb_info->added_by_user)
                                return NOTIFY_OK;
                } else {
@@ -44,7 +44,7 @@ Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
                         */
                        struct net_device *br_dev;
                        struct dsa_slave_priv *p;
-@@ -1728,7 +1731,8 @@ static int dsa_slave_switchdev_event(str
+@@ -1731,7 +1734,8 @@ static int dsa_slave_switchdev_event(str
  
                        dp = p->dp->cpu_dp;