netfilter: ebtables: allow use of ebt_do_table as hookfn
authorFlorian Westphal <fw@strlen.de>
Mon, 11 Oct 2021 15:15:14 +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 via *priv.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/linux/netfilter_bridge/ebtables.h
net/bridge/netfilter/ebtable_broute.c
net/bridge/netfilter/ebtable_filter.c
net/bridge/netfilter/ebtable_nat.c
net/bridge/netfilter/ebtables.c

index 10a0197..a13296d 100644 (file)
@@ -112,9 +112,8 @@ extern int ebt_register_table(struct net *net,
                              const struct nf_hook_ops *ops);
 extern void ebt_unregister_table(struct net *net, const char *tablename);
 void ebt_unregister_table_pre_exit(struct net *net, const char *tablename);
-extern unsigned int ebt_do_table(struct sk_buff *skb,
-                                const struct nf_hook_state *state,
-                                struct ebt_table *table);
+extern unsigned int ebt_do_table(void *priv, struct sk_buff *skb,
+                                const struct nf_hook_state *state);
 
 /* True if the hook mask denotes that the rule is in a base chain,
  * used in the check() functions */
index a7af4ea..1a11064 100644 (file)
@@ -66,7 +66,7 @@ static unsigned int ebt_broute(void *priv, struct sk_buff *skb,
                           NFPROTO_BRIDGE, s->in, NULL, NULL,
                           s->net, NULL);
 
-       ret = ebt_do_table(skb, &state, priv);
+       ret = ebt_do_table(priv, skb, &state);
        if (ret != NF_DROP)
                return ret;
 
index c0b121d..cb94943 100644 (file)
@@ -58,28 +58,21 @@ static const struct ebt_table frame_filter = {
        .me             = THIS_MODULE,
 };
 
-static unsigned int
-ebt_filter_hook(void *priv, struct sk_buff *skb,
-               const struct nf_hook_state *state)
-{
-       return ebt_do_table(skb, state, priv);
-}
-
 static const struct nf_hook_ops ebt_ops_filter[] = {
        {
-               .hook           = ebt_filter_hook,
+               .hook           = ebt_do_table,
                .pf             = NFPROTO_BRIDGE,
                .hooknum        = NF_BR_LOCAL_IN,
                .priority       = NF_BR_PRI_FILTER_BRIDGED,
        },
        {
-               .hook           = ebt_filter_hook,
+               .hook           = ebt_do_table,
                .pf             = NFPROTO_BRIDGE,
                .hooknum        = NF_BR_FORWARD,
                .priority       = NF_BR_PRI_FILTER_BRIDGED,
        },
        {
-               .hook           = ebt_filter_hook,
+               .hook           = ebt_do_table,
                .pf             = NFPROTO_BRIDGE,
                .hooknum        = NF_BR_LOCAL_OUT,
                .priority       = NF_BR_PRI_FILTER_OTHER,
index 4078151..5ee0531 100644 (file)
@@ -58,27 +58,21 @@ static const struct ebt_table frame_nat = {
        .me             = THIS_MODULE,
 };
 
-static unsigned int ebt_nat_hook(void *priv, struct sk_buff *skb,
-                                const struct nf_hook_state *state)
-{
-       return ebt_do_table(skb, state, priv);
-}
-
 static const struct nf_hook_ops ebt_ops_nat[] = {
        {
-               .hook           = ebt_nat_hook,
+               .hook           = ebt_do_table,
                .pf             = NFPROTO_BRIDGE,
                .hooknum        = NF_BR_LOCAL_OUT,
                .priority       = NF_BR_PRI_NAT_DST_OTHER,
        },
        {
-               .hook           = ebt_nat_hook,
+               .hook           = ebt_do_table,
                .pf             = NFPROTO_BRIDGE,
                .hooknum        = NF_BR_POST_ROUTING,
                .priority       = NF_BR_PRI_NAT_SRC,
        },
        {
-               .hook           = ebt_nat_hook,
+               .hook           = ebt_do_table,
                .pf             = NFPROTO_BRIDGE,
                .hooknum        = NF_BR_PRE_ROUTING,
                .priority       = NF_BR_PRI_NAT_DST_BRIDGED,
index 83d1798..4a1508a 100644 (file)
@@ -189,10 +189,10 @@ ebt_get_target_c(const struct ebt_entry *e)
 }
 
 /* Do some firewalling */
-unsigned int ebt_do_table(struct sk_buff *skb,
-                         const struct nf_hook_state *state,
-                         struct ebt_table *table)
+unsigned int ebt_do_table(void *priv, struct sk_buff *skb,
+                         const struct nf_hook_state *state)
 {
+       struct ebt_table *table = priv;
        unsigned int hook = state->hook;
        int i, nentries;
        struct ebt_entry *point;