762-net-bridge-switchdev-Refactor-br_switchdev_fdb_notif.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. From 46fe6cecb296d850c1ee2b333e57093ac4b733f3 Mon Sep 17 00:00:00 2001
  2. From: Tobias Waldekranz <[email protected]>
  3. Date: Sat, 16 Jan 2021 02:25:09 +0100
  4. Subject: [PATCH] net: bridge: switchdev: Refactor br_switchdev_fdb_notify
  5. Instead of having to add more and more arguments to
  6. br_switchdev_fdb_call_notifiers, get rid of it and build the info
  7. struct directly in br_switchdev_fdb_notify.
  8. Signed-off-by: Tobias Waldekranz <[email protected]>
  9. Reviewed-by: Vladimir Oltean <[email protected]>
  10. ---
  11. net/bridge/br_switchdev.c | 41 +++++++++++----------------------------
  12. 1 file changed, 11 insertions(+), 30 deletions(-)
  13. --- a/net/bridge/br_switchdev.c
  14. +++ b/net/bridge/br_switchdev.c
  15. @@ -102,25 +102,16 @@ int br_switchdev_set_port_flag(struct ne
  16. return 0;
  17. }
  18. -static void
  19. -br_switchdev_fdb_call_notifiers(bool adding, const unsigned char *mac,
  20. - u16 vid, struct net_device *dev,
  21. - bool added_by_user, bool offloaded)
  22. -{
  23. - struct switchdev_notifier_fdb_info info;
  24. - unsigned long notifier_type;
  25. -
  26. - info.addr = mac;
  27. - info.vid = vid;
  28. - info.added_by_user = added_by_user;
  29. - info.offloaded = offloaded;
  30. - notifier_type = adding ? SWITCHDEV_FDB_ADD_TO_DEVICE : SWITCHDEV_FDB_DEL_TO_DEVICE;
  31. - call_switchdev_notifiers(notifier_type, dev, &info.info, NULL);
  32. -}
  33. -
  34. void
  35. br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
  36. {
  37. + struct switchdev_notifier_fdb_info info = {
  38. + .addr = fdb->key.addr.addr,
  39. + .vid = fdb->key.vlan_id,
  40. + .added_by_user = test_bit(BR_FDB_ADDED_BY_USER, &fdb->flags),
  41. + .offloaded = test_bit(BR_FDB_OFFLOADED, &fdb->flags),
  42. + };
  43. +
  44. if (!fdb->dst)
  45. return;
  46. if (test_bit(BR_FDB_LOCAL, &fdb->flags))
  47. @@ -128,22 +119,12 @@ br_switchdev_fdb_notify(const struct net
  48. switch (type) {
  49. case RTM_DELNEIGH:
  50. - br_switchdev_fdb_call_notifiers(false, fdb->key.addr.addr,
  51. - fdb->key.vlan_id,
  52. - fdb->dst->dev,
  53. - test_bit(BR_FDB_ADDED_BY_USER,
  54. - &fdb->flags),
  55. - test_bit(BR_FDB_OFFLOADED,
  56. - &fdb->flags));
  57. + call_switchdev_notifiers(SWITCHDEV_FDB_DEL_TO_DEVICE,
  58. + fdb->dst->dev, &info.info, NULL);
  59. break;
  60. case RTM_NEWNEIGH:
  61. - br_switchdev_fdb_call_notifiers(true, fdb->key.addr.addr,
  62. - fdb->key.vlan_id,
  63. - fdb->dst->dev,
  64. - test_bit(BR_FDB_ADDED_BY_USER,
  65. - &fdb->flags),
  66. - test_bit(BR_FDB_OFFLOADED,
  67. - &fdb->flags));
  68. + call_switchdev_notifiers(SWITCHDEV_FDB_ADD_TO_DEVICE,
  69. + fdb->dst->dev, &info.info, NULL);
  70. break;
  71. }
  72. }