1
0

643-net-bridge-support-hardware-flow-table-offload.patch 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. From: Felix Fietkau <nbd@nbd.name>
  2. Date: Thu, 15 Mar 2018 20:50:37 +0100
  3. Subject: [PATCH] net: bridge: support hardware flow table offload
  4. Look up the real device and pass it on
  5. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  6. ---
  7. --- a/net/bridge/br_device.c
  8. +++ b/net/bridge/br_device.c
  9. @@ -18,6 +18,10 @@
  10. #include <linux/ethtool.h>
  11. #include <linux/list.h>
  12. #include <linux/netfilter_bridge.h>
  13. +#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
  14. +#include <linux/netfilter.h>
  15. +#include <net/netfilter/nf_flow_table.h>
  16. +#endif
  17. #include <linux/uaccess.h>
  18. #include "br_private.h"
  19. @@ -340,6 +344,28 @@ static const struct ethtool_ops br_ethto
  20. .get_link = ethtool_op_get_link,
  21. };
  22. +#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
  23. +static int br_flow_offload_check(struct flow_offload_hw_path *path)
  24. +{
  25. + struct net_device *dev = path->dev;
  26. + struct net_bridge *br = netdev_priv(dev);
  27. + struct net_bridge_fdb_entry *dst;
  28. +
  29. + if (!(path->flags & FLOW_OFFLOAD_PATH_ETHERNET))
  30. + return -EINVAL;
  31. +
  32. + dst = br_fdb_find_rcu(br, path->eth_dest, path->vlan_id);
  33. + if (!dst || !dst->dst)
  34. + return -ENOENT;
  35. +
  36. + path->dev = dst->dst->dev;
  37. + if (path->dev->netdev_ops->ndo_flow_offload_check)
  38. + return path->dev->netdev_ops->ndo_flow_offload_check(path);
  39. +
  40. + return 0;
  41. +}
  42. +#endif /* CONFIG_NF_FLOW_TABLE */
  43. +
  44. static const struct net_device_ops br_netdev_ops = {
  45. .ndo_open = br_dev_open,
  46. .ndo_stop = br_dev_stop,
  47. @@ -367,6 +393,9 @@ static const struct net_device_ops br_ne
  48. .ndo_bridge_setlink = br_setlink,
  49. .ndo_bridge_dellink = br_dellink,
  50. .ndo_features_check = passthru_features_check,
  51. +#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
  52. + .ndo_flow_offload_check = br_flow_offload_check,
  53. +#endif
  54. };
  55. static struct device_type br_type = {