770-v5.12-net-bridge-notify-switchdev-of-disappearance-of-old-.patch 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. From 90dc8fd36078a536671adae884d0b929cce6480a Mon Sep 17 00:00:00 2001
  2. From: Vladimir Oltean <[email protected]>
  3. Date: Wed, 6 Jan 2021 11:51:30 +0200
  4. Subject: [PATCH] net: bridge: notify switchdev of disappearance of old FDB
  5. entry upon migration
  6. Currently the bridge emits atomic switchdev notifications for
  7. dynamically learnt FDB entries. Monitoring these notifications works
  8. wonders for switchdev drivers that want to keep their hardware FDB in
  9. sync with the bridge's FDB.
  10. For example station A wants to talk to station B in the diagram below,
  11. and we are concerned with the behavior of the bridge on the DUT device:
  12. DUT
  13. +-------------------------------------+
  14. | br0 |
  15. | +------+ +------+ +------+ +------+ |
  16. | | | | | | | | | |
  17. | | swp0 | | swp1 | | swp2 | | eth0 | |
  18. +-------------------------------------+
  19. | | |
  20. Station A | |
  21. | |
  22. +--+------+--+ +--+------+--+
  23. | | | | | | | |
  24. | | swp0 | | | | swp0 | |
  25. Another | +------+ | | +------+ | Another
  26. switch | br0 | | br0 | switch
  27. | +------+ | | +------+ |
  28. | | | | | | | |
  29. | | swp1 | | | | swp1 | |
  30. +--+------+--+ +--+------+--+
  31. |
  32. Station B
  33. Interfaces swp0, swp1, swp2 are handled by a switchdev driver that has
  34. the following property: frames injected from its control interface bypass
  35. the internal address analyzer logic, and therefore, this hardware does
  36. not learn from the source address of packets transmitted by the network
  37. stack through it. So, since bridging between eth0 (where Station B is
  38. attached) and swp0 (where Station A is attached) is done in software,
  39. the switchdev hardware will never learn the source address of Station B.
  40. So the traffic towards that destination will be treated as unknown, i.e.
  41. flooded.
  42. This is where the bridge notifications come in handy. When br0 on the
  43. DUT sees frames with Station B's MAC address on eth0, the switchdev
  44. driver gets these notifications and can install a rule to send frames
  45. towards Station B's address that are incoming from swp0, swp1, swp2,
  46. only towards the control interface. This is all switchdev driver private
  47. business, which the notification makes possible.
  48. All is fine until someone unplugs Station B's cable and moves it to the
  49. other switch:
  50. DUT
  51. +-------------------------------------+
  52. | br0 |
  53. | +------+ +------+ +------+ +------+ |
  54. | | | | | | | | | |
  55. | | swp0 | | swp1 | | swp2 | | eth0 | |
  56. +-------------------------------------+
  57. | | |
  58. Station A | |
  59. | |
  60. +--+------+--+ +--+------+--+
  61. | | | | | | | |
  62. | | swp0 | | | | swp0 | |
  63. Another | +------+ | | +------+ | Another
  64. switch | br0 | | br0 | switch
  65. | +------+ | | +------+ |
  66. | | | | | | | |
  67. | | swp1 | | | | swp1 | |
  68. +--+------+--+ +--+------+--+
  69. |
  70. Station B
  71. Luckily for the use cases we care about, Station B is noisy enough that
  72. the DUT hears it (on swp1 this time). swp1 receives the frames and
  73. delivers them to the bridge, who enters the unlikely path in br_fdb_update
  74. of updating an existing entry. It moves the entry in the software bridge
  75. to swp1 and emits an addition notification towards that.
  76. As far as the switchdev driver is concerned, all that it needs to ensure
  77. is that traffic between Station A and Station B is not forever broken.
  78. If it does nothing, then the stale rule to send frames for Station B
  79. towards the control interface remains in place. But Station B is no
  80. longer reachable via the control interface, but via a port that can
  81. offload the bridge port learning attribute. It's just that the port is
  82. prevented from learning this address, since the rule overrides FDB
  83. updates. So the rule needs to go. The question is via what mechanism.
  84. It sure would be possible for this switchdev driver to keep track of all
  85. addresses which are sent to the control interface, and then also listen
  86. for bridge notifier events on its own ports, searching for the ones that
  87. have a MAC address which was previously sent to the control interface.
  88. But this is cumbersome and inefficient. Instead, with one small change,
  89. the bridge could notify of the address deletion from the old port, in a
  90. symmetrical manner with how it did for the insertion. Then the switchdev
  91. driver would not be required to monitor learn/forget events for its own
  92. ports. It could just delete the rule towards the control interface upon
  93. bridge entry migration. This would make hardware address learning be
  94. possible again. Then it would take a few more packets until the hardware
  95. and software FDB would be in sync again.
  96. Signed-off-by: Vladimir Oltean <[email protected]>
  97. Acked-by: Nikolay Aleksandrov <[email protected]>
  98. Reviewed-by: Ido Schimmel <[email protected]>
  99. Reviewed-by: Andrew Lunn <[email protected]>
  100. Reviewed-by: Florian Fainelli <[email protected]>
  101. Signed-off-by: Jakub Kicinski <[email protected]>
  102. ---
  103. net/bridge/br_fdb.c | 1 +
  104. 1 file changed, 1 insertion(+)
  105. --- a/net/bridge/br_fdb.c
  106. +++ b/net/bridge/br_fdb.c
  107. @@ -581,6 +581,7 @@ void br_fdb_update(struct net_bridge *br
  108. /* fastpath: update of existing entry */
  109. if (unlikely(source != fdb->dst && !fdb->is_sticky)) {
  110. + br_switchdev_fdb_notify(fdb, RTM_DELNEIGH);
  111. fdb->dst = source;
  112. fdb_modified = true;
  113. /* Take over HW learned entry */