610-v5.13-13-net-bridge-resolve-forwarding-path-for-bridge-device.patch 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. From: Pablo Neira Ayuso <[email protected]>
  2. Date: Wed, 24 Mar 2021 02:30:34 +0100
  3. Subject: [PATCH] net: bridge: resolve forwarding path for bridge devices
  4. Add .ndo_fill_forward_path for bridge devices.
  5. Signed-off-by: Pablo Neira Ayuso <[email protected]>
  6. ---
  7. --- a/include/linux/netdevice.h
  8. +++ b/include/linux/netdevice.h
  9. @@ -830,6 +830,7 @@ typedef u16 (*select_queue_fallback_t)(s
  10. enum net_device_path_type {
  11. DEV_PATH_ETHERNET = 0,
  12. DEV_PATH_VLAN,
  13. + DEV_PATH_BRIDGE,
  14. };
  15. struct net_device_path {
  16. --- a/net/bridge/br_device.c
  17. +++ b/net/bridge/br_device.c
  18. @@ -398,6 +398,32 @@ static int br_del_slave(struct net_devic
  19. return br_del_if(br, slave_dev);
  20. }
  21. +static int br_fill_forward_path(struct net_device_path_ctx *ctx,
  22. + struct net_device_path *path)
  23. +{
  24. + struct net_bridge_fdb_entry *f;
  25. + struct net_bridge_port *dst;
  26. + struct net_bridge *br;
  27. +
  28. + if (netif_is_bridge_port(ctx->dev))
  29. + return -1;
  30. +
  31. + br = netdev_priv(ctx->dev);
  32. + f = br_fdb_find_rcu(br, ctx->daddr, 0);
  33. + if (!f || !f->dst)
  34. + return -1;
  35. +
  36. + dst = READ_ONCE(f->dst);
  37. + if (!dst)
  38. + return -1;
  39. +
  40. + path->type = DEV_PATH_BRIDGE;
  41. + path->dev = dst->br->dev;
  42. + ctx->dev = dst->dev;
  43. +
  44. + return 0;
  45. +}
  46. +
  47. static const struct ethtool_ops br_ethtool_ops = {
  48. .get_drvinfo = br_getinfo,
  49. .get_link = ethtool_op_get_link,
  50. @@ -432,6 +458,7 @@ static const struct net_device_ops br_ne
  51. .ndo_bridge_setlink = br_setlink,
  52. .ndo_bridge_dellink = br_dellink,
  53. .ndo_features_check = passthru_features_check,
  54. + .ndo_fill_forward_path = br_fill_forward_path,
  55. };
  56. static struct device_type br_type = {