719-v5.12-net-dsa-automatically-bring-up-DSA-master-when-openi.patch 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. From 9d5ef190e5615a7b63af89f88c4106a5bc127974 Mon Sep 17 00:00:00 2001
  2. From: Vladimir Oltean <[email protected]>
  3. Date: Fri, 5 Feb 2021 15:37:10 +0200
  4. Subject: [PATCH] net: dsa: automatically bring up DSA master when opening user
  5. port
  6. DSA wants the master interface to be open before the user port is due to
  7. historical reasons. The promiscuity of interfaces that are down used to
  8. have issues, as referenced Lennert Buytenhek in commit df02c6ff2e39
  9. ("dsa: fix master interface allmulti/promisc handling").
  10. The bugfix mentioned there, commit b6c40d68ff64 ("net: only invoke
  11. dev->change_rx_flags when device is UP"), was basically a "don't do
  12. that" approach to working around the promiscuity while down issue.
  13. Further work done by Vlad Yasevich in commit d2615bf45069 ("net: core:
  14. Always propagate flag changes to interfaces") has resolved the
  15. underlying issue, and it is strictly up to the DSA and 8021q drivers
  16. now, it is no longer mandated by the networking core that the master
  17. interface must be up when changing its promiscuity.
  18. From DSA's point of view, deciding to error out in dsa_slave_open
  19. because the master isn't up is
  20. (a) a bad user experience and
  21. (b) knocking at an open door.
  22. Even if there still was an issue with promiscuity while down, DSA could
  23. still just open the master and avoid it.
  24. Doing it this way has the additional benefit that user space can now
  25. remove DSA-specific workarounds, like systemd-networkd with BindCarrier:
  26. https://github.com/systemd/systemd/issues/7478
  27. And we can finally remove one of the 2 bullets in the "Common pitfalls
  28. using DSA setups" chapter.
  29. Tested with two cascaded DSA switches:
  30. $ ip link set sw0p2 up
  31. fsl_enetc 0000:00:00.2 eno2: configuring for fixed/internal link mode
  32. fsl_enetc 0000:00:00.2 eno2: Link is Up - 1Gbps/Full - flow control rx/tx
  33. mscc_felix 0000:00:00.5 swp0: configuring for fixed/sgmii link mode
  34. mscc_felix 0000:00:00.5 swp0: Link is Up - 1Gbps/Full - flow control off
  35. 8021q: adding VLAN 0 to HW filter on device swp0
  36. sja1105 spi2.0 sw0p2: configuring for phy/rgmii-id link mode
  37. IPv6: ADDRCONF(NETDEV_CHANGE): eno2: link becomes ready
  38. IPv6: ADDRCONF(NETDEV_CHANGE): swp0: link becomes ready
  39. Signed-off-by: Vladimir Oltean <[email protected]>
  40. Reviewed-by: Andrew Lunn <[email protected]>
  41. Reviewed-by: Florian Fainelli <[email protected]>
  42. Signed-off-by: Jakub Kicinski <[email protected]>
  43. ---
  44. Documentation/networking/dsa/dsa.rst | 4 ----
  45. net/dsa/slave.c | 7 +++++--
  46. 2 files changed, 5 insertions(+), 6 deletions(-)
  47. --- a/Documentation/networking/dsa/dsa.rst
  48. +++ b/Documentation/networking/dsa/dsa.rst
  49. @@ -273,10 +273,6 @@ will not make us go through the switch t
  50. the Ethernet switch on the other end, expecting a tag will typically drop this
  51. frame.
  52. -Slave network devices check that the master network device is UP before allowing
  53. -you to administratively bring UP these slave network devices. A common
  54. -configuration mistake is forgetting to bring UP the master network device first.
  55. -
  56. Interactions with other subsystems
  57. ==================================
  58. --- a/net/dsa/slave.c
  59. +++ b/net/dsa/slave.c
  60. @@ -68,8 +68,11 @@ static int dsa_slave_open(struct net_dev
  61. struct dsa_port *dp = dsa_slave_to_port(dev);
  62. int err;
  63. - if (!(master->flags & IFF_UP))
  64. - return -ENETDOWN;
  65. + err = dev_open(master, NULL);
  66. + if (err < 0) {
  67. + netdev_err(dev, "failed to open master %s\n", master->name);
  68. + goto out;
  69. + }
  70. if (!ether_addr_equal(dev->dev_addr, master->dev_addr)) {
  71. err = dev_uc_add(master, dev->dev_addr);