developer | e5e687d | 2023-08-08 16:05:33 +0800 | [diff] [blame] | 1 | --- a/net/ipv4/ip_gre.c |
| 2 | +++ b/net/ipv4/ip_gre.c |
| 3 | @@ -39,6 +39,7 @@ |
| 4 | #include <net/inet_ecn.h> |
| 5 | #include <net/xfrm.h> |
| 6 | #include <net/net_namespace.h> |
| 7 | +#include <net/netfilter/nf_flow_table.h> |
| 8 | #include <net/netns/generic.h> |
| 9 | #include <net/rtnetlink.h> |
| 10 | #include <net/gre.h> |
| 11 | @@ -901,6 +902,24 @@ static int ipgre_close(struct net_device |
| 12 | } |
| 13 | #endif |
| 14 | |
| 15 | +#if IS_ENABLED(CONFIG_NF_FLOW_TABLE) |
| 16 | +static int gre_dev_flow_offload_check(struct flow_offload_hw_path *path) |
| 17 | +{ |
| 18 | + struct net_device *dev = path->dev; |
| 19 | + struct ip_tunnel *tunnel = netdev_priv(dev); |
| 20 | + |
| 21 | + if (path->flags & FLOW_OFFLOAD_PATH_TNL) |
| 22 | + return -EEXIST; |
| 23 | + |
| 24 | + path->flags |= FLOW_OFFLOAD_PATH_TNL; |
| 25 | + path->tnl_type = FLOW_OFFLOAD_TNL_GRETAP; |
| 26 | + path->virt_dev = dev; |
| 27 | + path->dev = tunnel->dev; |
| 28 | + |
| 29 | + return 0; |
| 30 | +} |
| 31 | +#endif /* CONFIG_NF_FLOW_TABLE */ |
| 32 | + |
| 33 | static const struct net_device_ops ipgre_netdev_ops = { |
| 34 | .ndo_init = ipgre_tunnel_init, |
| 35 | .ndo_uninit = ip_tunnel_uninit, |
| 36 | @@ -1264,6 +1283,9 @@ static const struct net_device_ops gre_t |
| 37 | .ndo_get_stats64 = ip_tunnel_get_stats64, |
| 38 | .ndo_get_iflink = ip_tunnel_get_iflink, |
| 39 | .ndo_fill_metadata_dst = gre_fill_metadata_dst, |
| 40 | +#if IS_ENABLED(CONFIG_NF_FLOW_TABLE) |
| 41 | + .ndo_flow_offload_check = gre_dev_flow_offload_check, |
| 42 | +#endif |
| 43 | }; |
| 44 | |
| 45 | static int erspan_tunnel_init(struct net_device *dev) |