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