2018-03-12 19:51:55 +00:00
|
|
|
From: Felix Fietkau <nbd@nbd.name>
|
|
|
|
Date: Thu, 15 Mar 2018 20:50:37 +0100
|
|
|
|
Subject: [PATCH] net: bridge: support hardware flow table offload
|
|
|
|
|
|
|
|
Look up the real device and pass it on
|
|
|
|
|
|
|
|
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
|
|
---
|
|
|
|
|
|
|
|
--- a/net/bridge/br_device.c
|
|
|
|
+++ b/net/bridge/br_device.c
|
2018-05-08 21:17:36 +00:00
|
|
|
@@ -18,6 +18,10 @@
|
2018-03-12 19:51:55 +00:00
|
|
|
#include <linux/ethtool.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/netfilter_bridge.h>
|
2018-05-17 05:53:57 +00:00
|
|
|
+#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
|
2018-03-12 19:51:55 +00:00
|
|
|
+#include <linux/netfilter.h>
|
|
|
|
+#include <net/netfilter/nf_flow_table.h>
|
2018-05-08 21:17:36 +00:00
|
|
|
+#endif
|
2018-03-12 19:51:55 +00:00
|
|
|
|
|
|
|
#include <linux/uaccess.h>
|
|
|
|
#include "br_private.h"
|
2018-05-08 21:17:36 +00:00
|
|
|
@@ -340,6 +344,28 @@ static const struct ethtool_ops br_ethto
|
2018-03-12 19:51:55 +00:00
|
|
|
.get_link = ethtool_op_get_link,
|
|
|
|
};
|
|
|
|
|
2018-05-17 05:53:57 +00:00
|
|
|
+#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
|
2018-03-12 19:51:55 +00:00
|
|
|
+static int br_flow_offload_check(struct flow_offload_hw_path *path)
|
|
|
|
+{
|
|
|
|
+ struct net_device *dev = path->dev;
|
|
|
|
+ struct net_bridge *br = netdev_priv(dev);
|
|
|
|
+ struct net_bridge_fdb_entry *dst;
|
|
|
|
+
|
|
|
|
+ if (!(path->flags & FLOW_OFFLOAD_PATH_ETHERNET))
|
|
|
|
+ return -EINVAL;
|
|
|
|
+
|
|
|
|
+ dst = br_fdb_find_rcu(br, path->eth_dest, path->vlan_id);
|
|
|
|
+ if (!dst || !dst->dst)
|
|
|
|
+ return -ENOENT;
|
|
|
|
+
|
|
|
|
+ path->dev = dst->dst->dev;
|
|
|
|
+ if (path->dev->netdev_ops->ndo_flow_offload_check)
|
|
|
|
+ return path->dev->netdev_ops->ndo_flow_offload_check(path);
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
2018-05-08 21:17:36 +00:00
|
|
|
+#endif /* CONFIG_NF_FLOW_TABLE */
|
2018-03-12 19:51:55 +00:00
|
|
|
+
|
|
|
|
static const struct net_device_ops br_netdev_ops = {
|
|
|
|
.ndo_open = br_dev_open,
|
|
|
|
.ndo_stop = br_dev_stop,
|
2018-05-08 21:17:36 +00:00
|
|
|
@@ -367,6 +393,9 @@ static const struct net_device_ops br_ne
|
2018-03-12 19:51:55 +00:00
|
|
|
.ndo_bridge_setlink = br_setlink,
|
|
|
|
.ndo_bridge_dellink = br_dellink,
|
|
|
|
.ndo_features_check = passthru_features_check,
|
2018-05-17 05:53:57 +00:00
|
|
|
+#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
|
2018-03-12 19:51:55 +00:00
|
|
|
+ .ndo_flow_offload_check = br_flow_offload_check,
|
2018-05-08 21:17:36 +00:00
|
|
|
+#endif
|
2018-03-12 19:51:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct device_type br_type = {
|