| --- a/drivers/net/ppp/pptp.c |
| +++ b/drivers/net/ppp/pptp.c |
| @@ -33,6 +33,7 @@ |
| #include <net/route.h> |
| #include <net/gre.h> |
| #include <net/pptp.h> |
| +#include <net/netfilter/nf_flow_table.h> |
| |
| #include <linux/uaccess.h> |
| |
| @@ -40,6 +41,9 @@ |
| |
| #define MAX_CALLID 65535 |
| |
| +int (*mtk_pptp_seq_next)(u16 call_id, u32 *val) = NULL; |
| +EXPORT_SYMBOL(mtk_pptp_seq_next); |
| + |
| static DECLARE_BITMAP(callid_bitmap, MAX_CALLID + 1); |
| static struct pppox_sock __rcu **callid_sock; |
| |
| @@ -128,6 +132,26 @@ static void del_chan(struct pppox_sock * |
| spin_unlock(&chan_lock); |
| } |
| |
| +#if IS_ENABLED(CONFIG_NF_FLOW_TABLE) |
| +static int pptp_flow_offload_check(struct ppp_channel *chan, |
| + struct flow_offload_hw_path *path) |
| +{ |
| + struct sock *sk = (struct sock *)chan->private; |
| + struct pppox_sock *po = pppox_sk(sk); |
| + |
| + if (path->flags & FLOW_OFFLOAD_PATH_TNL) |
| + return -EEXIST; |
| + |
| + if (sk_pppox(po)->sk_state & PPPOX_DEAD) |
| + return -EINVAL; |
| + |
| + path->flags |= FLOW_OFFLOAD_PATH_TNL; |
| + path->tnl_type = FLOW_OFFLOAD_TNL_PPTP; |
| + |
| + return 0; |
| +} |
| +#endif /* IS_ENABLED(CONFIG_NF_FLOW_TABLE) */ |
| + |
| static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb) |
| { |
| struct sock *sk = (struct sock *) chan->private; |
| @@ -140,6 +164,7 @@ static int pptp_xmit(struct ppp_channel |
| int islcp; |
| int len; |
| unsigned char *data; |
| + u32 seq_sent_hw; |
| __u32 seq_recv; |
| |
| |
| @@ -204,7 +229,14 @@ static int pptp_xmit(struct ppp_channel |
| hdr->gre_hd.protocol = GRE_PROTO_PPP; |
| hdr->call_id = htons(opt->dst_addr.call_id); |
| |
| - hdr->seq = htonl(++opt->seq_sent); |
| + if (mtk_pptp_seq_next && !mtk_pptp_seq_next(opt->dst_addr.call_id, |
| + &seq_sent_hw)) { |
| + opt->seq_sent = seq_sent_hw; |
| + hdr->seq = htonl(opt->seq_sent); |
| + } else { |
| + hdr->seq = htonl(++opt->seq_sent); |
| + } |
| + |
| if (opt->ack_sent != seq_recv) { |
| /* send ack with this message */ |
| hdr->gre_hd.flags |= GRE_ACK; |
| @@ -598,6 +630,9 @@ static int pptp_ppp_ioctl(struct ppp_cha |
| static const struct ppp_channel_ops pptp_chan_ops = { |
| .start_xmit = pptp_xmit, |
| .ioctl = pptp_ppp_ioctl, |
| +#if IS_ENABLED(CONFIG_NF_FLOW_TABLE) |
| + .flow_offload_check = pptp_flow_offload_check, |
| +#endif /* IS_ENABLED(CONFIG_NF_FLOW_TABLE) */ |
| }; |
| |
| static struct proto pptp_sk_proto __read_mostly = { |
| --- a/include/net/pptp.h |
| +++ b/include/net/pptp.h |
| @@ -2,6 +2,8 @@ |
| #ifndef _NET_PPTP_H |
| #define _NET_PPTP_H |
| |
| +#include <net/gre.h> |
| + |
| #define PPP_LCP_ECHOREQ 0x09 |
| #define PPP_LCP_ECHOREP 0x0A |
| #define SC_RCV_BITS (SC_RCV_B7_1|SC_RCV_B7_0|SC_RCV_ODDP|SC_RCV_EVNP) |
| @@ -20,5 +22,7 @@ struct pptp_gre_header { |
| __be32 ack; |
| } __packed; |
| |
| +/* symbol exported from linux kernel driver/net/ppp/pptp.c */ |
| +extern int (*mtk_pptp_seq_next)(uint16_t call_id, uint32_t *val); |
| |
| #endif |