netfilter: remove route_key_size field in struct nf_afinfo
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 27 Nov 2017 21:58:37 +0000 (22:58 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 8 Jan 2018 17:11:01 +0000 (18:11 +0100)
This is only needed by nf_queue, place this code where it belongs.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/linux/netfilter.h
net/ipv4/netfilter.c
net/ipv6/netfilter.c
net/netfilter/nf_queue.c

index 8358e717eabdc290da50c0ef4c862a766e10bbe2..58a169e425f7c414f85308d1217a391a3baa1a6b 100644 (file)
@@ -311,7 +311,6 @@ struct nf_queue_entry;
 
 struct nf_afinfo {
        unsigned short  family;
-       int             route_key_size;
 };
 
 extern const struct nf_afinfo __rcu *nf_afinfo[NFPROTO_NUMPROTO];
index ec73be3b2f141d9f696c5aeec4bf63b7f573f611..bd8e161c2f958d3d00436f38225139c7bad29008 100644 (file)
@@ -164,7 +164,6 @@ EXPORT_SYMBOL_GPL(nf_ip_route);
 
 static const struct nf_afinfo nf_ip_afinfo = {
        .family                 = AF_INET,
-       .route_key_size         = sizeof(struct ip_rt_info),
 };
 
 static int __init ipv4_netfilter_init(void)
index d633b78be06f3351cc139f9d98e38c1d2a7f4071..18f82a3fb0c01a6a066e1bdcac4224f87f10c41c 100644 (file)
@@ -176,7 +176,6 @@ static const struct nf_ipv6_ops ipv6ops = {
 
 static const struct nf_afinfo nf_ip6_afinfo = {
        .family                 = AF_INET6,
-       .route_key_size         = sizeof(struct ip6_rt_info),
 };
 
 int __init ipv6_netfilter_init(void)
index 15382ff83e7a51135ffb2865bbb9f81c0af61992..7f55af5f3d1a59b71cc4ab8b948587197376add4 100644 (file)
@@ -15,6 +15,8 @@
 #include <linux/netfilter_bridge.h>
 #include <linux/seq_file.h>
 #include <linux/rcupdate.h>
+#include <linux/netfilter_ipv4.h>
+#include <linux/netfilter_ipv6.h>
 #include <net/protocol.h>
 #include <net/netfilter/nf_queue.h>
 #include <net/dst.h>
@@ -145,9 +147,9 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state,
 {
        int status = -ENOENT;
        struct nf_queue_entry *entry = NULL;
-       const struct nf_afinfo *afinfo;
        const struct nf_queue_handler *qh;
        struct net *net = state->net;
+       unsigned int route_key_size;
 
        /* QUEUE == DROP if no one is waiting, to be safe. */
        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,
                goto err;
        }
 
-       afinfo = nf_get_afinfo(state->pf);
-       if (!afinfo)
-               goto err;
+       switch (state->pf) {
+       case AF_INET:
+               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) {
                status = -ENOMEM;
                goto err;
@@ -170,7 +180,7 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state,
                .skb    = skb,
                .state  = *state,
                .hook_index = index,
-               .size   = sizeof(*entry) + afinfo->route_key_size,
+               .size   = sizeof(*entry) + route_key_size,
        };
 
        nf_queue_entry_get_refs(entry);