kernel: bump 4.14 to 4.14.34
[openwrt/openwrt.git] / target / linux / generic / pending-4.14 / 644-net-pppoe-support-hardware-flow-table-offload.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Thu, 15 Mar 2018 21:15:00 +0100
3 Subject: [PATCH] net: pppoe: support hardware flow table offload
4
5 Pass on the PPPoE session ID and the remote MAC address
6
7 Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 ---
9
10 --- a/drivers/net/ppp/ppp_generic.c
11 +++ b/drivers/net/ppp/ppp_generic.c
12 @@ -56,6 +56,9 @@
13 #include <net/net_namespace.h>
14 #include <net/netns/generic.h>
15
16 +#include <linux/netfilter.h>
17 +#include <net/netfilter/nf_flow_table.h>
18 +
19 #define PPP_VERSION "2.4.2"
20
21 /*
22 @@ -1382,12 +1385,33 @@ static void ppp_dev_priv_destructor(stru
23 ppp_destroy_interface(ppp);
24 }
25
26 +static int ppp_flow_offload_check(struct flow_offload_hw_path *path)
27 +{
28 + struct ppp *ppp = netdev_priv(path->dev);
29 + struct ppp_channel *chan;
30 + struct channel *pch;
31 +
32 + if (ppp->flags & SC_MULTILINK)
33 + return -EOPNOTSUPP;
34 +
35 + if (list_empty(&ppp->channels))
36 + return -ENODEV;
37 +
38 + pch = list_first_entry(&ppp->channels, struct channel, clist);
39 + chan = pch->chan;
40 + if (!chan->ops->flow_offload_check)
41 + return -EOPNOTSUPP;
42 +
43 + return chan->ops->flow_offload_check(chan, path);
44 +}
45 +
46 static const struct net_device_ops ppp_netdev_ops = {
47 .ndo_init = ppp_dev_init,
48 .ndo_uninit = ppp_dev_uninit,
49 .ndo_start_xmit = ppp_start_xmit,
50 .ndo_do_ioctl = ppp_net_ioctl,
51 .ndo_get_stats64 = ppp_get_stats64,
52 + .ndo_flow_offload_check = ppp_flow_offload_check,
53 };
54
55 static struct device_type ppp_type = {
56 --- a/drivers/net/ppp/pppoe.c
57 +++ b/drivers/net/ppp/pppoe.c
58 @@ -77,6 +77,8 @@
59 #include <linux/file.h>
60 #include <linux/proc_fs.h>
61 #include <linux/seq_file.h>
62 +#include <linux/netfilter.h>
63 +#include <net/netfilter/nf_flow_table.h>
64
65 #include <linux/nsproxy.h>
66 #include <net/net_namespace.h>
67 @@ -970,8 +972,32 @@ static int pppoe_xmit(struct ppp_channel
68 return __pppoe_xmit(sk, skb);
69 }
70
71 +static int pppoe_flow_offload_check(struct ppp_channel *chan,
72 + struct flow_offload_hw_path *path)
73 +{
74 + struct sock *sk = (struct sock *)chan->private;
75 + struct pppox_sock *po = pppox_sk(sk);
76 + struct net_device *dev = po->pppoe_dev;
77 +
78 + if (sock_flag(sk, SOCK_DEAD) ||
79 + !(sk->sk_state & PPPOX_CONNECTED) || !dev)
80 + return -ENODEV;
81 +
82 + path->dev = po->pppoe_dev;
83 + path->flags |= FLOW_OFFLOAD_PATH_PPPOE;
84 + memcpy(path->eth_src, po->pppoe_dev->dev_addr, ETH_ALEN);
85 + memcpy(path->eth_dest, po->pppoe_pa.remote, ETH_ALEN);
86 + path->pppoe_sid = be16_to_cpu(po->num);
87 +
88 + if (path->dev->netdev_ops->ndo_flow_offload_check)
89 + return path->dev->netdev_ops->ndo_flow_offload_check(path);
90 +
91 + return 0;
92 +}
93 +
94 static const struct ppp_channel_ops pppoe_chan_ops = {
95 .start_xmit = pppoe_xmit,
96 + .flow_offload_check = pppoe_flow_offload_check,
97 };
98
99 static int pppoe_recvmsg(struct socket *sock, struct msghdr *m,
100 --- a/include/linux/ppp_channel.h
101 +++ b/include/linux/ppp_channel.h
102 @@ -32,6 +32,8 @@ struct ppp_channel_ops {
103 int (*start_xmit)(struct ppp_channel *, struct sk_buff *);
104 /* Handle an ioctl call that has come in via /dev/ppp. */
105 int (*ioctl)(struct ppp_channel *, unsigned int, unsigned long);
106 +
107 + int (*flow_offload_check)(struct ppp_channel *, struct flow_offload_hw_path *);
108 };
109
110 struct ppp_channel {