ipq806x: add support for GL.iNet GL-B1300
[openwrt/staging/kaloz.git] / target / linux / mediatek / patches-4.9 / 0041-net-next-dsa-fix-flow-dissection.patch
1 From 04c825484d6ecdcc8ce09b350235c9077eaca6e3 Mon Sep 17 00:00:00 2001
2 From: John Crispin <john@phrozen.org>
3 Date: Wed, 9 Aug 2017 08:20:21 +0200
4 Subject: [PATCH 41/57] net-next: dsa: fix flow dissection
5
6 RPS and probably other kernel features are currently broken on some if not
7 all DSA devices. The root cause of this is that skb_hash will call the
8 flow_dissector. At this point the skb still contains the magic switch
9 header and the skb->protocol field is not set up to the correct 802.3
10 value yet. By the time the tag specific code is called, removing the header
11 and =roperly setting the protocol an invalid hash is already set. In the
12 case of the mt7530 this will result in all flows always having the same
13 hash.
14
15 This patch makes the flow dissector honour the nh and protocol offset
16 defined by the dsa tag driver thus fixing dissection, hashing and RPS.
17
18 Signed-off-by: John Crispin <john@phrozen.org>
19 ---
20 net/core/flow_dissector.c | 14 +++++++++++++-
21 1 file changed, 13 insertions(+), 1 deletion(-)
22
23 --- a/net/core/flow_dissector.c
24 +++ b/net/core/flow_dissector.c
25 @@ -4,6 +4,7 @@
26 #include <linux/ip.h>
27 #include <linux/ipv6.h>
28 #include <linux/if_vlan.h>
29 +#include <net/dsa.h>
30 #include <net/ip.h>
31 #include <net/ipv6.h>
32 #include <net/gre.h>
33 @@ -123,13 +124,23 @@ bool __skb_flow_dissect(const struct sk_
34 bool skip_vlan = false;
35 u8 ip_proto = 0;
36 bool ret;
37 -
38 if (!data) {
39 data = skb->data;
40 proto = skb_vlan_tag_present(skb) ?
41 skb->vlan_proto : skb->protocol;
42 nhoff = skb_network_offset(skb);
43 hlen = skb_headlen(skb);
44 + if (unlikely(netdev_uses_dsa(skb->dev))) {
45 + const struct dsa_device_ops *ops;
46 + int offset;
47 +
48 + ops = skb->dev->dsa_ptr->tag_ops;
49 + if (ops->flow_dissect &&
50 + !ops->flow_dissect(skb, &proto, &offset)) {
51 + hlen -= offset;
52 + nhoff += offset;
53 + }
54 + }
55 }
56
57 /* It is ensured by skb_flow_dissector_init() that control key will
58 @@ -162,6 +173,7 @@ again:
59 case htons(ETH_P_IP): {
60 const struct iphdr *iph;
61 struct iphdr _iph;
62 +
63 ip:
64 iph = __skb_header_pointer(skb, nhoff, sizeof(_iph), data, hlen, &_iph);
65 if (!iph || iph->ihl < 5)