Commit 46435623 authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso

netfilter: remove route_key_size field in struct nf_afinfo

This is only needed by nf_queue, place this code where it belongs.
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent ce388f45
...@@ -311,7 +311,6 @@ struct nf_queue_entry; ...@@ -311,7 +311,6 @@ struct nf_queue_entry;
struct nf_afinfo { struct nf_afinfo {
unsigned short family; unsigned short family;
int route_key_size;
}; };
extern const struct nf_afinfo __rcu *nf_afinfo[NFPROTO_NUMPROTO]; extern const struct nf_afinfo __rcu *nf_afinfo[NFPROTO_NUMPROTO];
......
...@@ -164,7 +164,6 @@ EXPORT_SYMBOL_GPL(nf_ip_route); ...@@ -164,7 +164,6 @@ EXPORT_SYMBOL_GPL(nf_ip_route);
static const struct nf_afinfo nf_ip_afinfo = { static const struct nf_afinfo nf_ip_afinfo = {
.family = AF_INET, .family = AF_INET,
.route_key_size = sizeof(struct ip_rt_info),
}; };
static int __init ipv4_netfilter_init(void) static int __init ipv4_netfilter_init(void)
......
...@@ -176,7 +176,6 @@ static const struct nf_ipv6_ops ipv6ops = { ...@@ -176,7 +176,6 @@ static const struct nf_ipv6_ops ipv6ops = {
static const struct nf_afinfo nf_ip6_afinfo = { static const struct nf_afinfo nf_ip6_afinfo = {
.family = AF_INET6, .family = AF_INET6,
.route_key_size = sizeof(struct ip6_rt_info),
}; };
int __init ipv6_netfilter_init(void) int __init ipv6_netfilter_init(void)
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#include <linux/netfilter_bridge.h> #include <linux/netfilter_bridge.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/rcupdate.h> #include <linux/rcupdate.h>
#include <linux/netfilter_ipv4.h>
#include <linux/netfilter_ipv6.h>
#include <net/protocol.h> #include <net/protocol.h>
#include <net/netfilter/nf_queue.h> #include <net/netfilter/nf_queue.h>
#include <net/dst.h> #include <net/dst.h>
...@@ -145,9 +147,9 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state, ...@@ -145,9 +147,9 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state,
{ {
int status = -ENOENT; int status = -ENOENT;
struct nf_queue_entry *entry = NULL; struct nf_queue_entry *entry = NULL;
const struct nf_afinfo *afinfo;
const struct nf_queue_handler *qh; const struct nf_queue_handler *qh;
struct net *net = state->net; struct net *net = state->net;
unsigned int route_key_size;
/* QUEUE == DROP if no one is waiting, to be safe. */ /* QUEUE == DROP if no one is waiting, to be safe. */
qh = rcu_dereference(net->nf.queue_handler); qh = rcu_dereference(net->nf.queue_handler);
...@@ -156,11 +158,19 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state, ...@@ -156,11 +158,19 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state,
goto err; goto err;
} }
afinfo = nf_get_afinfo(state->pf); switch (state->pf) {
if (!afinfo) case AF_INET:
goto err; route_key_size = sizeof(struct ip_rt_info);
break;
case AF_INET6:
route_key_size = sizeof(struct ip6_rt_info);
break;
default:
route_key_size = 0;
break;
}
entry = kmalloc(sizeof(*entry) + afinfo->route_key_size, GFP_ATOMIC); entry = kmalloc(sizeof(*entry) + route_key_size, GFP_ATOMIC);
if (!entry) { if (!entry) {
status = -ENOMEM; status = -ENOMEM;
goto err; goto err;
...@@ -170,7 +180,7 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state, ...@@ -170,7 +180,7 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state,
.skb = skb, .skb = skb,
.state = *state, .state = *state,
.hook_index = index, .hook_index = index,
.size = sizeof(*entry) + afinfo->route_key_size, .size = sizeof(*entry) + route_key_size,
}; };
nf_queue_entry_get_refs(entry); nf_queue_entry_get_refs(entry);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment