blob: 5f8bf62ea3b5e0628a92961aeafb9022734654b9 [file] [log] [blame]
developeraeabeec2024-10-21 12:23:01 +08001diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
2index c30952f..6c0860b 100644
3--- a/include/linux/netdevice.h
4+++ b/include/linux/netdevice.h
5@@ -851,6 +851,7 @@ enum net_device_path_type {
6 DEV_PATH_DSA,
7 DEV_PATH_DSLITE,
8 DEV_PATH_6RD,
9+ DEV_PATH_TNL,
10 };
developerc35bbbc2023-06-12 11:00:41 +080011
developeraeabeec2024-10-21 12:23:01 +080012 struct net_device_path {
13diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
14index 7d3c782..d7a5a9a 100644
developerc35bbbc2023-06-12 11:00:41 +080015--- a/net/l2tp/l2tp_ppp.c
16+++ b/net/l2tp/l2tp_ppp.c
17@@ -89,6 +89,7 @@
18 #include <linux/nsproxy.h>
19 #include <net/net_namespace.h>
20 #include <net/netns/generic.h>
21+#include <net/netfilter/nf_flow_table.h>
22 #include <net/ip.h>
23 #include <net/udp.h>
24 #include <net/inet_common.h>
25@@ -124,9 +125,14 @@ struct pppol2tp_session {
26 };
27
28 static int pppol2tp_xmit(struct ppp_channel *chan, struct sk_buff *skb);
29+static int l2tp_ppp_flow_offload_check(struct ppp_channel *chan,
30+ struct flow_offload_hw_path *path);
31
32 static const struct ppp_channel_ops pppol2tp_chan_ops = {
33 .start_xmit = pppol2tp_xmit,
34+#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
35+ .flow_offload_check = l2tp_ppp_flow_offload_check,
36+#endif /* IS_ENABLED(CONFIG_NF_FLOW_TABLE) */
37 };
38
39 static const struct proto_ops pppol2tp_ops;
developeraeabeec2024-10-21 12:23:01 +080040@@ -335,6 +341,26 @@ static int pppol2tp_sendmsg(struct socket *sock, struct msghdr *m,
developerc35bbbc2023-06-12 11:00:41 +080041 return error;
42 }
43
44+#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
45+static int l2tp_ppp_flow_offload_check(struct ppp_channel *chan,
46+ struct flow_offload_hw_path *path)
47+{
48+ struct sock *sk = (struct sock *)chan->private;
49+ struct l2tp_session *session;
50+
developeraeabeec2024-10-21 12:23:01 +080051+ if (path->flags & BIT(DEV_PATH_TNL))
developerc35bbbc2023-06-12 11:00:41 +080052+ return -EEXIST;
53+
54+ session = pppol2tp_sock_to_session(sk);
55+ if (!session)
56+ return -EINVAL;
57+
developeraeabeec2024-10-21 12:23:01 +080058+ path->flags |= BIT(DEV_PATH_TNL);
developerc35bbbc2023-06-12 11:00:41 +080059+
60+ return 0;
61+}
62+#endif /* IS_ENABLED(CONFIG_NF_FLOW_TABLE) */
63+
64 /* Transmit function called by generic PPP driver. Sends PPP frame
65 * over PPPoL2TP socket.
66 *