kernel: bump 4.14 to 4.14.93
[openwrt/staging/chunkeey.git] / target / linux / generic / hack-4.14 / 647-netfilter-flow-acct.patch
1 --- a/include/net/netfilter/nf_flow_table.h
2 +++ b/include/net/netfilter/nf_flow_table.h
3 @@ -164,6 +164,8 @@ struct nf_flow_table_hw {
4 int nf_flow_table_hw_register(const struct nf_flow_table_hw *offload);
5 void nf_flow_table_hw_unregister(const struct nf_flow_table_hw *offload);
6
7 +void nf_flow_table_acct(struct flow_offload *flow, struct sk_buff *skb, int dir);
8 +
9 extern struct work_struct nf_flow_offload_hw_work;
10
11 #define MODULE_ALIAS_NF_FLOWTABLE(family) \
12 --- a/net/netfilter/nf_flow_table_core.c
13 +++ b/net/netfilter/nf_flow_table_core.c
14 @@ -11,6 +11,7 @@
15 #include <net/netfilter/nf_conntrack.h>
16 #include <net/netfilter/nf_conntrack_core.h>
17 #include <net/netfilter/nf_conntrack_tuple.h>
18 +#include <net/netfilter/nf_conntrack_acct.h>
19
20 struct flow_offload_entry {
21 struct flow_offload flow;
22 @@ -151,6 +152,22 @@ void flow_offload_free(struct flow_offlo
23 }
24 EXPORT_SYMBOL_GPL(flow_offload_free);
25
26 +void nf_flow_table_acct(struct flow_offload *flow, struct sk_buff *skb, int dir)
27 +{
28 + struct flow_offload_entry *entry;
29 + struct nf_conn_acct *acct;
30 +
31 + entry = container_of(flow, struct flow_offload_entry, flow);
32 + acct = nf_conn_acct_find(entry->ct);
33 + if (acct) {
34 + struct nf_conn_counter *counter = acct->counter;
35 +
36 + atomic64_inc(&counter[dir].packets);
37 + atomic64_add(skb->len, &counter[dir].bytes);
38 + }
39 +}
40 +EXPORT_SYMBOL_GPL(nf_flow_table_acct);
41 +
42 static u32 flow_offload_hash(const void *data, u32 len, u32 seed)
43 {
44 const struct flow_offload_tuple *tuple = data;
45 --- a/net/netfilter/nf_flow_table_ip.c
46 +++ b/net/netfilter/nf_flow_table_ip.c
47 @@ -11,6 +11,7 @@
48 #include <net/ip6_route.h>
49 #include <net/neighbour.h>
50 #include <net/netfilter/nf_flow_table.h>
51 +
52 /* For layer 4 checksum field offset. */
53 #include <linux/tcp.h>
54 #include <linux/udp.h>
55 @@ -265,6 +266,7 @@ nf_flow_offload_ip_hook(void *priv, stru
56 skb->dev = outdev;
57 nexthop = rt_nexthop(rt, flow->tuplehash[!dir].tuple.src_v4.s_addr);
58 skb_dst_set_noref(skb, &rt->dst);
59 + nf_flow_table_acct(flow, skb, dir);
60 neigh_xmit(NEIGH_ARP_TABLE, outdev, &nexthop, skb);
61
62 return NF_STOLEN;
63 @@ -482,6 +484,7 @@ nf_flow_offload_ipv6_hook(void *priv, st
64 skb->dev = outdev;
65 nexthop = rt6_nexthop(rt, &flow->tuplehash[!dir].tuple.src_v6);
66 skb_dst_set_noref(skb, &rt->dst);
67 + nf_flow_table_acct(flow, skb, dir);
68 neigh_xmit(NEIGH_ND_TABLE, outdev, nexthop, skb);
69
70 return NF_STOLEN;