developer | aeabeec | 2024-10-21 12:23:01 +0800 | [diff] [blame^] | 1 | diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h |
| 2 | index 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 | }; |
developer | c35bbbc | 2023-06-12 11:00:41 +0800 | [diff] [blame] | 11 | |
developer | aeabeec | 2024-10-21 12:23:01 +0800 | [diff] [blame^] | 12 | struct net_device_path { |
| 13 | diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c |
| 14 | index 7d3c782..d7a5a9a 100644 |
developer | c35bbbc | 2023-06-12 11:00:41 +0800 | [diff] [blame] | 15 | --- 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; |
developer | aeabeec | 2024-10-21 12:23:01 +0800 | [diff] [blame^] | 40 | @@ -335,6 +341,26 @@ static int pppol2tp_sendmsg(struct socket *sock, struct msghdr *m, |
developer | c35bbbc | 2023-06-12 11:00:41 +0800 | [diff] [blame] | 41 | 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 | + |
developer | aeabeec | 2024-10-21 12:23:01 +0800 | [diff] [blame^] | 51 | + if (path->flags & BIT(DEV_PATH_TNL)) |
developer | c35bbbc | 2023-06-12 11:00:41 +0800 | [diff] [blame] | 52 | + return -EEXIST; |
| 53 | + |
| 54 | + session = pppol2tp_sock_to_session(sk); |
| 55 | + if (!session) |
| 56 | + return -EINVAL; |
| 57 | + |
developer | aeabeec | 2024-10-21 12:23:01 +0800 | [diff] [blame^] | 58 | + path->flags |= BIT(DEV_PATH_TNL); |
developer | c35bbbc | 2023-06-12 11:00:41 +0800 | [diff] [blame] | 59 | + |
| 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 | * |