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
5 This is only needed by nf_queue, place this code where it belongs.
7 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 --- a/include/linux/netfilter.h
11 +++ b/include/linux/netfilter.h
12 @@ -311,7 +311,6 @@ struct nf_queue_entry;
15 unsigned short family;
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);
24 static const struct nf_afinfo nf_ip_afinfo = {
26 - .route_key_size = sizeof(struct ip_rt_info),
29 static int __init ipv4_netfilter_init(void)
30 --- a/net/ipv6/netfilter.c
31 +++ b/net/ipv6/netfilter.c
32 @@ -177,7 +177,6 @@ static const struct nf_ipv6_ops ipv6ops
34 static const struct nf_afinfo nf_ip6_afinfo = {
36 - .route_key_size = sizeof(struct ip6_rt_info),
39 int __init ipv6_netfilter_init(void)
40 --- a/net/netfilter/nf_queue.c
41 +++ b/net/netfilter/nf_queue.c
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>
51 @@ -145,9 +147,9 @@ static int __nf_queue(struct sk_buff *sk
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;
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
66 - afinfo = nf_get_afinfo(state->pf);
69 + switch (state->pf) {
71 + route_key_size = sizeof(struct ip_rt_info);
74 + route_key_size = sizeof(struct ip6_rt_info);
81 - entry = kmalloc(sizeof(*entry) + afinfo->route_key_size, GFP_ATOMIC);
82 + entry = kmalloc(sizeof(*entry) + route_key_size, GFP_ATOMIC);
86 @@ -170,7 +180,7 @@ static int __nf_queue(struct sk_buff *sk
90 - .size = sizeof(*entry) + afinfo->route_key_size,
91 + .size = sizeof(*entry) + route_key_size,
94 nf_queue_entry_get_refs(entry);