blob: 150087a56aac4c1bc41318db4d25ad46b353d79e [file] [log] [blame]
developerfd40db22021-04-29 10:08:25 +08001diff --git a/include/net/netfilter/nf_flow_table.h b/include/net/netfilter/nf_flow_table.h
2index 3d73c0c..960ade1 100644
3--- a/include/net/netfilter/nf_flow_table.h
4+++ b/include/net/netfilter/nf_flow_table.h
5@@ -92,9 +92,12 @@ struct flow_offload {
6 #define FLOW_OFFLOAD_PATH_VLAN BIT(1)
7 #define FLOW_OFFLOAD_PATH_PPPOE BIT(2)
8 #define FLOW_OFFLOAD_PATH_DSA BIT(3)
9+#define FLOW_OFFLOAD_PATH_DSLITE BIT(4)
10+#define FLOW_OFFLOAD_PATH_6RD BIT(5)
11
12 struct flow_offload_hw_path {
13 struct net_device *dev;
14+ struct net_device *virt_dev;
15 u32 flags;
16
17 u8 eth_src[ETH_ALEN];
18diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
19index be6801524..c51af70f6 100644
20--- a/net/8021q/vlan_dev.c
21+++ b/net/8021q/vlan_dev.c
22@@ -761,6 +761,7 @@ static int vlan_dev_flow_offload_check(struct flow_offload_hw_path *path)
23 path->flags |= FLOW_OFFLOAD_PATH_VLAN;
24 path->vlan_proto = vlan->vlan_proto;
25 path->vlan_id = vlan->vlan_id;
26+ path->virt_dev = dev;
27 path->dev = vlan->real_dev;
28
29 if (vlan->real_dev->netdev_ops->ndo_flow_offload_check)
30diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
31index 1b7e3141c..da4e34f74 100644
32--- a/net/ipv6/ip6_tunnel.c
33+++ b/net/ipv6/ip6_tunnel.c
34@@ -57,6 +57,11 @@
35 #include <net/netns/generic.h>
36 #include <net/dst_metadata.h>
37
38+#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
39+#include <linux/netfilter.h>
40+#include <net/netfilter/nf_flow_table.h>
41+#endif
42+
43 MODULE_AUTHOR("Ville Nuorvala");
44 MODULE_DESCRIPTION("IPv6 tunneling device");
45 MODULE_LICENSE("GPL");
46@@ -1880,6 +1885,22 @@ int ip6_tnl_get_iflink(const struct net_device *dev)
47 }
48 EXPORT_SYMBOL(ip6_tnl_get_iflink);
49
50+#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
51+static int ipip6_dev_flow_offload_check(struct flow_offload_hw_path *path)
52+{
53+ struct net_device *dev = path->dev;
54+ struct ip6_tnl *tnl = netdev_priv(dev);
55+
56+ if (path->flags & FLOW_OFFLOAD_PATH_DSLITE)
57+ return -EEXIST;
58+
59+ path->flags |= FLOW_OFFLOAD_PATH_DSLITE;
60+ path->dev = tnl->dev;
61+
62+ return 0;
63+}
64+#endif /* CONFIG_NF_FLOW_TABLE */
65+
66 int ip6_tnl_encap_add_ops(const struct ip6_tnl_encap_ops *ops,
67 unsigned int num)
68 {
69@@ -1941,6 +1962,9 @@ static const struct net_device_ops ip6_tnl_netdev_ops = {
70 .ndo_change_mtu = ip6_tnl_change_mtu,
71 .ndo_get_stats = ip6_get_stats,
72 .ndo_get_iflink = ip6_tnl_get_iflink,
73+#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
74+ .ndo_flow_offload_check = ipip6_dev_flow_offload_check,
75+#endif
76 };
77
78 #define IPXIPX_FEATURES (NETIF_F_SG | \
79diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
80index 98954830c..42b6e8c4c 100644
81--- a/net/ipv6/sit.c
82+++ b/net/ipv6/sit.c
83@@ -52,6 +52,11 @@
84 #include <net/net_namespace.h>
85 #include <net/netns/generic.h>
86
87+#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
88+#include <linux/netfilter.h>
89+#include <net/netfilter/nf_flow_table.h>
90+#endif
91+
92 /*
93 This version of net/ipv6/sit.c is cloned of net/ipv4/ip_gre.c
94
95@@ -1345,6 +1350,22 @@ ipip6_tunnel_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
96 return err;
97 }
98
99+#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
100+static int ipip6_dev_flow_offload_check(struct flow_offload_hw_path *path)
101+{
102+ struct net_device *dev = path->dev;
103+ struct ip_tunnel *tnl = netdev_priv(dev);
104+
105+ if (path->flags & FLOW_OFFLOAD_PATH_6RD)
106+ return -EEXIST;
107+
108+ path->flags |= FLOW_OFFLOAD_PATH_6RD;
109+ path->dev = tnl->dev;
110+
111+ return 0;
112+}
113+#endif /* CONFIG_NF_FLOW_TABLE */
114+
115 static const struct net_device_ops ipip6_netdev_ops = {
116 .ndo_init = ipip6_tunnel_init,
117 .ndo_uninit = ipip6_tunnel_uninit,
118@@ -1352,6 +1373,9 @@ static const struct net_device_ops ipip6_netdev_ops = {
119 .ndo_do_ioctl = ipip6_tunnel_ioctl,
120 .ndo_get_stats64 = ip_tunnel_get_stats64,
121 .ndo_get_iflink = ip_tunnel_get_iflink,
122+#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
123+ .ndo_flow_offload_check = ipip6_dev_flow_offload_check,
124+#endif
125 };
126
127 static void ipip6_dev_free(struct net_device *dev)