270379346a4502fc758ce6d2c7894f019c0b89b6
[openwrt/staging/dedeckeh.git] /
1 From: Pablo Neira Ayuso <pablo@netfilter.org>
2 Date: Mon, 27 Nov 2017 22:58:37 +0100
3 Subject: [PATCH] netfilter: remove route_key_size field in struct nf_afinfo
4
5 This is only needed by nf_queue, place this code where it belongs.
6
7 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
8 ---
9
10 --- a/include/linux/netfilter.h
11 +++ b/include/linux/netfilter.h
12 @@ -311,7 +311,6 @@ struct nf_queue_entry;
13
14 struct nf_afinfo {
15 unsigned short family;
16 - int route_key_size;
17 };
18
19 extern const struct nf_afinfo __rcu *nf_afinfo[NFPROTO_NUMPROTO];
20 --- a/net/ipv4/netfilter.c
21 +++ b/net/ipv4/netfilter.c
22 @@ -164,7 +164,6 @@ EXPORT_SYMBOL_GPL(nf_ip_route);
23
24 static const struct nf_afinfo nf_ip_afinfo = {
25 .family = AF_INET,
26 - .route_key_size = sizeof(struct ip_rt_info),
27 };
28
29 static int __init ipv4_netfilter_init(void)
30 --- a/net/ipv6/netfilter.c
31 +++ b/net/ipv6/netfilter.c
32 @@ -178,7 +178,6 @@ static const struct nf_ipv6_ops ipv6ops
33
34 static const struct nf_afinfo nf_ip6_afinfo = {
35 .family = AF_INET6,
36 - .route_key_size = sizeof(struct ip6_rt_info),
37 };
38
39 int __init ipv6_netfilter_init(void)
40 --- a/net/netfilter/nf_queue.c
41 +++ b/net/netfilter/nf_queue.c
42 @@ -15,6 +15,8 @@
43 #include <linux/netfilter_bridge.h>
44 #include <linux/seq_file.h>
45 #include <linux/rcupdate.h>
46 +#include <linux/netfilter_ipv4.h>
47 +#include <linux/netfilter_ipv6.h>
48 #include <net/protocol.h>
49 #include <net/netfilter/nf_queue.h>
50 #include <net/dst.h>
51 @@ -145,9 +147,9 @@ static int __nf_queue(struct sk_buff *sk
52 {
53 int status = -ENOENT;
54 struct nf_queue_entry *entry = NULL;
55 - const struct nf_afinfo *afinfo;
56 const struct nf_queue_handler *qh;
57 struct net *net = state->net;
58 + unsigned int route_key_size;
59
60 /* QUEUE == DROP if no one is waiting, to be safe. */
61 qh = rcu_dereference(net->nf.queue_handler);
62 @@ -156,11 +158,19 @@ static int __nf_queue(struct sk_buff *sk
63 goto err;
64 }
65
66 - afinfo = nf_get_afinfo(state->pf);
67 - if (!afinfo)
68 - goto err;
69 + switch (state->pf) {
70 + case AF_INET:
71 + route_key_size = sizeof(struct ip_rt_info);
72 + break;
73 + case AF_INET6:
74 + route_key_size = sizeof(struct ip6_rt_info);
75 + break;
76 + default:
77 + route_key_size = 0;
78 + break;
79 + }
80
81 - entry = kmalloc(sizeof(*entry) + afinfo->route_key_size, GFP_ATOMIC);
82 + entry = kmalloc(sizeof(*entry) + route_key_size, GFP_ATOMIC);
83 if (!entry) {
84 status = -ENOMEM;
85 goto err;
86 @@ -170,7 +180,7 @@ static int __nf_queue(struct sk_buff *sk
87 .skb = skb,
88 .state = *state,
89 .hook_index = index,
90 - .size = sizeof(*entry) + afinfo->route_key_size,
91 + .size = sizeof(*entry) + route_key_size,
92 };
93
94 nf_queue_entry_get_refs(entry);