netfilter: arp_tables: allow use of arpt_do_table as hookfn
authorFlorian Westphal <fw@strlen.de>
Mon, 11 Oct 2021 15:15:12 +0000 (17:15 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 14 Oct 2021 21:06:53 +0000 (23:06 +0200)
This is possible now that the xt_table structure is passed in via *priv.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/linux/netfilter_arp/arp_tables.h
net/ipv4/netfilter/arp_tables.c
net/ipv4/netfilter/arptable_filter.c

index 4f9a4b3c589261397225b436a4f1abcbc0b294e2..a40aaf645fa4798b4d517f515d77a6d3d312ef52 100644 (file)
@@ -54,9 +54,8 @@ int arpt_register_table(struct net *net, const struct xt_table *table,
                        const struct nf_hook_ops *ops);
 void arpt_unregister_table(struct net *net, const char *name);
 void arpt_unregister_table_pre_exit(struct net *net, const char *name);
-extern unsigned int arpt_do_table(struct sk_buff *skb,
-                                 const struct nf_hook_state *state,
-                                 struct xt_table *table);
+extern unsigned int arpt_do_table(void *priv, struct sk_buff *skb,
+                                 const struct nf_hook_state *state);
 
 #ifdef CONFIG_NETFILTER_XTABLES_COMPAT
 #include <net/compat.h>
index c53f14b943560766d38dfffbd7b5d529e95902fd..ffc0cab7cf189f92e0c735007972b90fef117754 100644 (file)
@@ -179,10 +179,11 @@ struct arpt_entry *arpt_next_entry(const struct arpt_entry *entry)
        return (void *)entry + entry->next_offset;
 }
 
-unsigned int arpt_do_table(struct sk_buff *skb,
-                          const struct nf_hook_state *state,
-                          struct xt_table *table)
+unsigned int arpt_do_table(void *priv,
+                          struct sk_buff *skb,
+                          const struct nf_hook_state *state)
 {
+       const struct xt_table *table = priv;
        unsigned int hook = state->hook;
        static const char nulldevname[IFNAMSIZ] __attribute__((aligned(sizeof(long))));
        unsigned int verdict = NF_DROP;
index 3de78416ec76292aff24d0b4be4edcd507f98ca3..78cd5ee24448f624526ea6595e4ad8252b927425 100644 (file)
@@ -26,14 +26,6 @@ static const struct xt_table packet_filter = {
        .priority       = NF_IP_PRI_FILTER,
 };
 
-/* The work comes in here from netfilter.c */
-static unsigned int
-arptable_filter_hook(void *priv, struct sk_buff *skb,
-                    const struct nf_hook_state *state)
-{
-       return arpt_do_table(skb, state, priv);
-}
-
 static struct nf_hook_ops *arpfilter_ops __read_mostly;
 
 static int arptable_filter_table_init(struct net *net)
@@ -72,7 +64,7 @@ static int __init arptable_filter_init(void)
        if (ret < 0)
                return ret;
 
-       arpfilter_ops = xt_hook_ops_alloc(&packet_filter, arptable_filter_hook);
+       arpfilter_ops = xt_hook_ops_alloc(&packet_filter, arpt_do_table);
        if (IS_ERR(arpfilter_ops)) {
                xt_unregister_template(&packet_filter);
                return PTR_ERR(arpfilter_ops);