netfilter: fix hardware offload regression (FS#1551)
[openwrt/openwrt.git] / target / linux / generic / pending-4.14 / 642-net-8021q-support-hardware-flow-table-offload.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Thu, 15 Mar 2018 20:49:58 +0100
3 Subject: [PATCH] net: 8021q: support hardware flow table offload
4
5 Add the VLAN ID and protocol information
6
7 Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 ---
9
10 --- a/net/8021q/vlan_dev.c
11 +++ b/net/8021q/vlan_dev.c
12 @@ -32,6 +32,10 @@
13 #include <linux/phy.h>
14 #include <net/arp.h>
15 #include <net/switchdev.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 "vlan.h"
22 #include "vlanproc.h"
23 @@ -766,6 +770,27 @@ static int vlan_dev_get_iflink(const str
24 return real_dev->ifindex;
25 }
26
27 +#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
28 +static int vlan_dev_flow_offload_check(struct flow_offload_hw_path *path)
29 +{
30 + struct net_device *dev = path->dev;
31 + struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
32 +
33 + if (path->flags & FLOW_OFFLOAD_PATH_VLAN)
34 + return -EEXIST;
35 +
36 + path->flags |= FLOW_OFFLOAD_PATH_VLAN;
37 + path->vlan_proto = vlan->vlan_proto;
38 + path->vlan_id = vlan->vlan_id;
39 + path->dev = vlan->real_dev;
40 +
41 + if (vlan->real_dev->netdev_ops->ndo_flow_offload_check)
42 + return vlan->real_dev->netdev_ops->ndo_flow_offload_check(path);
43 +
44 + return 0;
45 +}
46 +#endif /* CONFIG_NF_FLOW_TABLE */
47 +
48 static const struct ethtool_ops vlan_ethtool_ops = {
49 .get_link_ksettings = vlan_ethtool_get_link_ksettings,
50 .get_drvinfo = vlan_ethtool_get_drvinfo,
51 @@ -803,6 +828,9 @@ static const struct net_device_ops vlan_
52 .ndo_fix_features = vlan_dev_fix_features,
53 .ndo_get_lock_subclass = vlan_dev_get_lock_subclass,
54 .ndo_get_iflink = vlan_dev_get_iflink,
55 +#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
56 + .ndo_flow_offload_check = vlan_dev_flow_offload_check,
57 +#endif
58 };
59
60 static void vlan_dev_free(struct net_device *dev)