764-net-bridge-switchdev-Send-FDB-notifications-for-host.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. From 2e50fd9322047253c327550b4485cf8761035a8c Mon Sep 17 00:00:00 2001
  2. From: Tobias Waldekranz <[email protected]>
  3. Date: Sat, 16 Jan 2021 02:25:11 +0100
  4. Subject: [PATCH] net: bridge: switchdev: Send FDB notifications for host
  5. addresses
  6. Treat addresses added to the bridge itself in the same way as regular
  7. ports and send out a notification so that drivers may sync it down to
  8. the hardware FDB.
  9. Signed-off-by: Tobias Waldekranz <[email protected]>
  10. ---
  11. net/bridge/br_fdb.c | 4 ++--
  12. net/bridge/br_private.h | 7 ++++---
  13. net/bridge/br_switchdev.c | 11 +++++------
  14. 3 files changed, 11 insertions(+), 11 deletions(-)
  15. --- a/net/bridge/br_fdb.c
  16. +++ b/net/bridge/br_fdb.c
  17. @@ -602,7 +602,7 @@ void br_fdb_update(struct net_bridge *br
  18. /* fastpath: update of existing entry */
  19. if (unlikely(source != fdb->dst &&
  20. !test_bit(BR_FDB_STICKY, &fdb->flags))) {
  21. - br_switchdev_fdb_notify(fdb, RTM_DELNEIGH);
  22. + br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH);
  23. fdb->dst = source;
  24. fdb_modified = true;
  25. /* Take over HW learned entry */
  26. @@ -735,7 +735,7 @@ static void fdb_notify(struct net_bridge
  27. int err = -ENOBUFS;
  28. if (swdev_notify)
  29. - br_switchdev_fdb_notify(fdb, type);
  30. + br_switchdev_fdb_notify(br, fdb, type);
  31. skb = nlmsg_new(fdb_nlmsg_size(), GFP_ATOMIC);
  32. if (skb == NULL)
  33. --- a/net/bridge/br_private.h
  34. +++ b/net/bridge/br_private.h
  35. @@ -1525,8 +1525,8 @@ bool nbp_switchdev_allowed_egress(const
  36. int br_switchdev_set_port_flag(struct net_bridge_port *p,
  37. unsigned long flags,
  38. unsigned long mask);
  39. -void br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb,
  40. - int type);
  41. +void br_switchdev_fdb_notify(struct net_bridge *br,
  42. + const struct net_bridge_fdb_entry *fdb, int type);
  43. int br_switchdev_port_vlan_add(struct net_device *dev, u16 vid, u16 flags,
  44. struct netlink_ext_ack *extack);
  45. int br_switchdev_port_vlan_del(struct net_device *dev, u16 vid);
  46. @@ -1572,7 +1572,8 @@ static inline int br_switchdev_port_vlan
  47. }
  48. static inline void
  49. -br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
  50. +br_switchdev_fdb_notify(struct net_bridge *br,
  51. + const struct net_bridge_fdb_entry *fdb, int type)
  52. {
  53. }
  54. --- a/net/bridge/br_switchdev.c
  55. +++ b/net/bridge/br_switchdev.c
  56. @@ -103,7 +103,8 @@ int br_switchdev_set_port_flag(struct ne
  57. }
  58. void
  59. -br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
  60. +br_switchdev_fdb_notify(struct net_bridge *br,
  61. + const struct net_bridge_fdb_entry *fdb, int type)
  62. {
  63. struct switchdev_notifier_fdb_info info = {
  64. .addr = fdb->key.addr.addr,
  65. @@ -112,20 +113,19 @@ br_switchdev_fdb_notify(const struct net
  66. .local = test_bit(BR_FDB_LOCAL, &fdb->flags),
  67. .offloaded = test_bit(BR_FDB_OFFLOADED, &fdb->flags),
  68. };
  69. + struct net_device *dev = fdb->dst ? fdb->dst->dev : br->dev;
  70. - if (!fdb->dst)
  71. - return;
  72. if (test_bit(BR_FDB_LOCAL, &fdb->flags))
  73. return;
  74. switch (type) {
  75. case RTM_DELNEIGH:
  76. call_switchdev_notifiers(SWITCHDEV_FDB_DEL_TO_DEVICE,
  77. - fdb->dst->dev, &info.info, NULL);
  78. + dev, &info.info, NULL);
  79. break;
  80. case RTM_NEWNEIGH:
  81. call_switchdev_notifiers(SWITCHDEV_FDB_ADD_TO_DEVICE,
  82. - fdb->dst->dev, &info.info, NULL);
  83. + dev, &info.info, NULL);
  84. break;
  85. }
  86. }