netfilter: remove obsolete hook wrappers
Subsystems (3)
Florian Westphal
maintainercover netfilter: remove obsolete hook wrappers
An earlier series, starting with
commit a4aeafa28cf706f65f ("netfilter: xt_nat: pass table to hookfn"), converted the x_tables table implementations to store the hook blob in the ->priv pointer that gets passed to the hook function.
Before this, the blobs were stored in struct net, so each table required its own wrapper to fetch the correct table blob.
Nowadays, allmost all hook functions in x_table land just call the hook evaluation loop.
This series converts the table evaluation loop so it can be used directly, then removes most of the wrappers.
Florian Westphal (4):
netfilter: iptables: allow use of ipt_do_table as hookfn
netfilter: arp_tables: allow use of arpt_do_table as hookfn
netfilter: ip6tables: allow use of ip6t_do_table as hookfn
netfilter: ebtables: allow use of ebt_do_table as hookfn
include/linux/netfilter_arp/arp_tables.h | 5 ++--- include/linux/netfilter_bridge/ebtables.h | 5 ++--- include/linux/netfilter_ipv4/ip_tables.h | 6 +++--- include/linux/netfilter_ipv6/ip6_tables.h | 5 ++--- net/bridge/netfilter/ebtable_broute.c | 2 +- net/bridge/netfilter/ebtable_filter.c | 13 +++---------- net/bridge/netfilter/ebtable_nat.c | 12 +++--------- net/bridge/netfilter/ebtables.c | 6 +++--- net/ipv4/netfilter/arp_tables.c | 7 ++++--- net/ipv4/netfilter/arptable_filter.c | 10 +--------- net/ipv4/netfilter/ip_tables.c | 7 ++++--- net/ipv4/netfilter/iptable_filter.c | 9 +-------- net/ipv4/netfilter/iptable_mangle.c | 8 ++++---- net/ipv4/netfilter/iptable_nat.c | 15 ++++----------- net/ipv4/netfilter/iptable_raw.c | 10 +--------- net/ipv4/netfilter/iptable_security.c | 9 +-------- net/ipv6/netfilter/ip6_tables.c | 6 +++--- net/ipv6/netfilter/ip6table_filter.c | 10 +--------- net/ipv6/netfilter/ip6table_mangle.c | 8 ++++---- net/ipv6/netfilter/ip6table_nat.c | 15 ++++----------- net/ipv6/netfilter/ip6table_raw.c | 10 +--------- net/ipv6/netfilter/ip6table_security.c | 9 +-------- 22 files changed, 53 insertions(+), 134 deletions(-)
Signature · 1 line
2.32.0
Florian Westphal
maintainerPATCH 1/4 netfilter: iptables: allow use of ipt_do_table as hookfn
This is possible now that the xt_table structure is passed in via *priv.
--- include/linux/netfilter_ipv4/ip_tables.h | 6 +++--- net/ipv4/netfilter/ip_tables.c | 7 ++++--- net/ipv4/netfilter/iptable_filter.c | 9 +-------- net/ipv4/netfilter/iptable_mangle.c | 8 ++++---- net/ipv4/netfilter/iptable_nat.c | 15 ++++----------- net/ipv4/netfilter/iptable_raw.c | 10 +--------- net/ipv4/netfilter/iptable_security.c | 9 +-------- 7 files changed, 18 insertions(+), 46 deletions(-)
include/linux/netfilter_ipv4/ip_tables.h +3 -3
@@ -63,9 +63,9 @@ struct ipt_error { }extern void *ipt_alloc_initial_table (const struct xt_table *); -extern unsigned int ipt_do_table (struct sk_buff *skb, -const struct nf_hook_state *state, -struct xt_table *table); +extern unsigned int ipt_do_table (void *priv, +struct sk_buff *skb, +const struct nf_hook_state *state);#ifdef CONFIG_NETFILTER_XTABLES_COMPAT #include <net/compat.h>
net/ipv4/netfilter/ip_tables.c +4 -3
@@ -222,10 +222,11 @@ struct ipt_entry *ipt_next_entry(const struct ipt_entry *entry)/* Returns one of the generic firewall policies, like NF_ACCEPT. */ unsigned int -ipt_do_table (struct sk_buff *skb, -const struct nf_hook_state *state, -struct xt_table *table) +ipt_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))));const struct iphdr *ip;
net/ipv4/netfilter/iptable_filter.c +1 -8
@@ -28,13 +28,6 @@ static const struct xt_table packet_filter = { .priority = NF_IP_PRI_FILTER, }; -static unsigned int -iptable_filter_hook (void *priv,struct sk_buff *skb, -const struct nf_hook_state *state) -{ -return ipt_do_table (skb, state, priv); -} -static struct nf_hook_ops *filter_ops__read_mostly ;/* Default to forward because I got too much mail already. */
@@ -90,7 +83,7 @@ static int __init iptable_filter_init(void)if (ret <0 )return ret; - filter_ops =xt_hook_ops_alloc (&packet_filter, iptable_filter_hook); + filter_ops =xt_hook_ops_alloc (&packet_filter, ipt_do_table);if (IS_ERR (filter_ops)) {xt_unregister_template (&packet_filter);return PTR_ERR (filter_ops);
net/ipv4/netfilter/iptable_mangle.c +4 -4
@@ -34,7 +34,7 @@ static const struct xt_table packet_mangler = { };static unsigned int -ipt_mangle_out (struct sk_buff *skb,const struct nf_hook_state *state,void *priv) +ipt_mangle_out (void *priv,struct sk_buff *skb,const struct nf_hook_state *state) {unsigned int ret;const struct iphdr *iph;
@@ -50,7 +50,7 @@ ipt_mangle_out(struct sk_buff *skb, const struct nf_hook_state *state, void *pri daddr = iph->daddr; tos = iph->tos; - ret =ipt_do_table (skb, state, priv); + ret =ipt_do_table (priv, skb, state);/* Reroute for ANY change. */ if (ret !=NF_DROP && ret !=NF_STOLEN ) { iph =ip_hdr (skb);
@@ -75,8 +75,8 @@ iptable_mangle_hook(void *priv, const struct nf_hook_state *state) {if (state->hook ==NF_INET_LOCAL_OUT ) -return ipt_mangle_out (skb, state, priv); -return ipt_do_table (skb, state, priv); +return ipt_mangle_out (priv, skb, state); +return ipt_do_table (priv, skb, state); }static struct nf_hook_ops *mangle_ops__read_mostly ;
net/ipv4/netfilter/iptable_nat.c +4 -11
@@ -29,34 +29,27 @@ static const struct xt_table nf_nat_ipv4_table = { .af = NFPROTO_IPV4, }; -static unsigned int iptable_nat_do_chain (void *priv, -struct sk_buff *skb, -const struct nf_hook_state *state) -{ -return ipt_do_table (skb, state, priv); -} -static const struct nf_hook_ops nf_nat_ipv4_ops[] = { { - .hook = iptable_nat_do_chain, + .hook = ipt_do_table, .pf =NFPROTO_IPV4 , .hooknum =NF_INET_PRE_ROUTING , .priority =NF_IP_PRI_NAT_DST , }, { - .hook = iptable_nat_do_chain, + .hook = ipt_do_table, .pf =NFPROTO_IPV4 , .hooknum =NF_INET_POST_ROUTING , .priority =NF_IP_PRI_NAT_SRC , }, { - .hook = iptable_nat_do_chain, + .hook = ipt_do_table, .pf =NFPROTO_IPV4 , .hooknum =NF_INET_LOCAL_OUT , .priority =NF_IP_PRI_NAT_DST , }, { - .hook = iptable_nat_do_chain, + .hook = ipt_do_table, .pf =NFPROTO_IPV4 , .hooknum =NF_INET_LOCAL_IN , .priority =NF_IP_PRI_NAT_SRC ,
net/ipv4/netfilter/iptable_raw.c +1 -9
@@ -32,14 +32,6 @@ static const struct xt_table packet_raw_before_defrag = { .priority = NF_IP_PRI_RAW_BEFORE_DEFRAG, }; -/* The work comes in here from netfilter.c. */ -static unsigned int -iptable_raw_hook (void *priv,struct sk_buff *skb, -const struct nf_hook_state *state) -{ -return ipt_do_table (skb, state, priv); -} -static struct nf_hook_ops *rawtable_ops__read_mostly ;static int iptable_raw_table_init (struct net *net)
@@ -90,7 +82,7 @@ static int __init iptable_raw_init(void)if (ret <0 )return ret; - rawtable_ops =xt_hook_ops_alloc (table, iptable_raw_hook); + rawtable_ops =xt_hook_ops_alloc (table, ipt_do_table);if (IS_ERR (rawtable_ops)) {xt_unregister_template (table);return PTR_ERR (rawtable_ops);
net/ipv4/netfilter/iptable_security.c +1 -8
@@ -33,13 +33,6 @@ static const struct xt_table security_table = { .priority = NF_IP_PRI_SECURITY, }; -static unsigned int -iptable_security_hook (void *priv,struct sk_buff *skb, -const struct nf_hook_state *state) -{ -return ipt_do_table (skb, state, priv); -} -static struct nf_hook_ops *sectbl_ops__read_mostly ;static int iptable_security_table_init (struct net *net)
@@ -78,7 +71,7 @@ static int __init iptable_security_init(void)if (ret <0 )return ret; - sectbl_ops =xt_hook_ops_alloc (&security_table, iptable_security_hook); + sectbl_ops =xt_hook_ops_alloc (&security_table, ipt_do_table);if (IS_ERR (sectbl_ops)) {xt_unregister_template (&security_table);return PTR_ERR (sectbl_ops);
Signature · 1 line
2.32.0
Florian Westphal
maintainerPATCH 1/4 netfilter: ipv4: allow use of ipt_do_table as hookfn
In reply to Florian WestphalThis is possible now that the xt_table structure is passed in via *priv.
--- include/linux/netfilter_ipv4/ip_tables.h | 6 +++--- net/ipv4/netfilter/ip_tables.c | 7 ++++--- net/ipv4/netfilter/iptable_filter.c | 9 +-------- net/ipv4/netfilter/iptable_mangle.c | 8 ++++---- net/ipv4/netfilter/iptable_nat.c | 15 ++++----------- net/ipv4/netfilter/iptable_raw.c | 10 +--------- net/ipv4/netfilter/iptable_security.c | 9 +-------- 7 files changed, 18 insertions(+), 46 deletions(-)
include/linux/netfilter_ipv4/ip_tables.h +3 -3
@@ -63,9 +63,9 @@ struct ipt_error { }extern void *ipt_alloc_initial_table (const struct xt_table *); -extern unsigned int ipt_do_table (struct sk_buff *skb, -const struct nf_hook_state *state, -struct xt_table *table); +extern unsigned int ipt_do_table (void *priv, +struct sk_buff *skb, +const struct nf_hook_state *state);#ifdef CONFIG_NETFILTER_XTABLES_COMPAT #include <net/compat.h>
net/ipv4/netfilter/ip_tables.c +4 -3
@@ -222,10 +222,11 @@ struct ipt_entry *ipt_next_entry(const struct ipt_entry *entry)/* Returns one of the generic firewall policies, like NF_ACCEPT. */ unsigned int -ipt_do_table (struct sk_buff *skb, -const struct nf_hook_state *state, -struct xt_table *table) +ipt_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))));const struct iphdr *ip;
net/ipv4/netfilter/iptable_filter.c +1 -8
@@ -28,13 +28,6 @@ static const struct xt_table packet_filter = { .priority = NF_IP_PRI_FILTER, }; -static unsigned int -iptable_filter_hook (void *priv,struct sk_buff *skb, -const struct nf_hook_state *state) -{ -return ipt_do_table (skb, state, priv); -} -static struct nf_hook_ops *filter_ops__read_mostly ;/* Default to forward because I got too much mail already. */
@@ -90,7 +83,7 @@ static int __init iptable_filter_init(void)if (ret <0 )return ret; - filter_ops =xt_hook_ops_alloc (&packet_filter, iptable_filter_hook); + filter_ops =xt_hook_ops_alloc (&packet_filter, ipt_do_table);if (IS_ERR (filter_ops)) {xt_unregister_template (&packet_filter);return PTR_ERR (filter_ops);
net/ipv4/netfilter/iptable_mangle.c +4 -4
@@ -34,7 +34,7 @@ static const struct xt_table packet_mangler = { };static unsigned int -ipt_mangle_out (struct sk_buff *skb,const struct nf_hook_state *state,void *priv) +ipt_mangle_out (void *priv,struct sk_buff *skb,const struct nf_hook_state *state) {unsigned int ret;const struct iphdr *iph;
@@ -50,7 +50,7 @@ ipt_mangle_out(struct sk_buff *skb, const struct nf_hook_state *state, void *pri daddr = iph->daddr; tos = iph->tos; - ret =ipt_do_table (skb, state, priv); + ret =ipt_do_table (priv, skb, state);/* Reroute for ANY change. */ if (ret !=NF_DROP && ret !=NF_STOLEN ) { iph =ip_hdr (skb);
@@ -75,8 +75,8 @@ iptable_mangle_hook(void *priv, const struct nf_hook_state *state) {if (state->hook ==NF_INET_LOCAL_OUT ) -return ipt_mangle_out (skb, state, priv); -return ipt_do_table (skb, state, priv); +return ipt_mangle_out (priv, skb, state); +return ipt_do_table (priv, skb, state); }static struct nf_hook_ops *mangle_ops__read_mostly ;
net/ipv4/netfilter/iptable_nat.c +4 -11
@@ -29,34 +29,27 @@ static const struct xt_table nf_nat_ipv4_table = { .af = NFPROTO_IPV4, }; -static unsigned int iptable_nat_do_chain (void *priv, -struct sk_buff *skb, -const struct nf_hook_state *state) -{ -return ipt_do_table (skb, state, priv); -} -static const struct nf_hook_ops nf_nat_ipv4_ops[] = { { - .hook = iptable_nat_do_chain, + .hook = ipt_do_table, .pf =NFPROTO_IPV4 , .hooknum =NF_INET_PRE_ROUTING , .priority =NF_IP_PRI_NAT_DST , }, { - .hook = iptable_nat_do_chain, + .hook = ipt_do_table, .pf =NFPROTO_IPV4 , .hooknum =NF_INET_POST_ROUTING , .priority =NF_IP_PRI_NAT_SRC , }, { - .hook = iptable_nat_do_chain, + .hook = ipt_do_table, .pf =NFPROTO_IPV4 , .hooknum =NF_INET_LOCAL_OUT , .priority =NF_IP_PRI_NAT_DST , }, { - .hook = iptable_nat_do_chain, + .hook = ipt_do_table, .pf =NFPROTO_IPV4 , .hooknum =NF_INET_LOCAL_IN , .priority =NF_IP_PRI_NAT_SRC ,
net/ipv4/netfilter/iptable_raw.c +1 -9
@@ -32,14 +32,6 @@ static const struct xt_table packet_raw_before_defrag = { .priority = NF_IP_PRI_RAW_BEFORE_DEFRAG, }; -/* The work comes in here from netfilter.c. */ -static unsigned int -iptable_raw_hook (void *priv,struct sk_buff *skb, -const struct nf_hook_state *state) -{ -return ipt_do_table (skb, state, priv); -} -static struct nf_hook_ops *rawtable_ops__read_mostly ;static int iptable_raw_table_init (struct net *net)
@@ -90,7 +82,7 @@ static int __init iptable_raw_init(void)if (ret <0 )return ret; - rawtable_ops =xt_hook_ops_alloc (table, iptable_raw_hook); + rawtable_ops =xt_hook_ops_alloc (table, ipt_do_table);if (IS_ERR (rawtable_ops)) {xt_unregister_template (table);return PTR_ERR (rawtable_ops);
net/ipv4/netfilter/iptable_security.c +1 -8
@@ -33,13 +33,6 @@ static const struct xt_table security_table = { .priority = NF_IP_PRI_SECURITY, }; -static unsigned int -iptable_security_hook (void *priv,struct sk_buff *skb, -const struct nf_hook_state *state) -{ -return ipt_do_table (skb, state, priv); -} -static struct nf_hook_ops *sectbl_ops__read_mostly ;static int iptable_security_table_init (struct net *net)
@@ -78,7 +71,7 @@ static int __init iptable_security_init(void)if (ret <0 )return ret; - sectbl_ops =xt_hook_ops_alloc (&security_table, iptable_security_hook); + sectbl_ops =xt_hook_ops_alloc (&security_table, ipt_do_table);if (IS_ERR (sectbl_ops)) {xt_unregister_template (&security_table);return PTR_ERR (sectbl_ops);
Signature · 1 line
2.32.0
Florian Westphal
maintainerPATCH 2/4 netfilter: arp_tables: allow use of arpt_do_table as hookfn
In reply to Florian WestphalThis is possible now that the xt_table structure is passed in via *priv.
--- include/linux/netfilter_arp/arp_tables.h | 5 ++--- net/ipv4/netfilter/arp_tables.c | 7 ++++--- net/ipv4/netfilter/arptable_filter.c | 10 +--------- 3 files changed, 7 insertions(+), 15 deletions(-)
include/linux/netfilter_arp/arp_tables.h +2 -3
@@ -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>
net/ipv4/netfilter/arp_tables.c +4 -3
@@ -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 ;
net/ipv4/netfilter/arptable_filter.c +1 -9
@@ -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);
Signature · 1 line
2.32.0
Florian Westphal
maintainerPATCH 3/4 netfilter: ip6tables: allow use of ip6t_do_table as hookfn
In reply to Florian WestphalThis is possible now that the xt_table structure is passed via *priv.
--- include/linux/netfilter_ipv6/ip6_tables.h | 5 ++--- net/ipv6/netfilter/ip6_tables.c | 6 +++--- net/ipv6/netfilter/ip6table_filter.c | 10 +--------- net/ipv6/netfilter/ip6table_mangle.c | 8 ++++---- net/ipv6/netfilter/ip6table_nat.c | 15 ++++----------- net/ipv6/netfilter/ip6table_raw.c | 10 +--------- net/ipv6/netfilter/ip6table_security.c | 9 +-------- 7 files changed, 16 insertions(+), 47 deletions(-)
include/linux/netfilter_ipv6/ip6_tables.h +2 -3
@@ -29,9 +29,8 @@ int ip6t_register_table(struct net *net, const struct xt_table *table, const struct nf_hook_ops *ops);void ip6t_unregister_table_pre_exit (struct net *net,const char *name);void ip6t_unregister_table_exit (struct net *net,const char *name); -extern unsigned int ip6t_do_table (struct sk_buff *skb, -const struct nf_hook_state *state, -struct xt_table *table); +extern unsigned int ip6t_do_table (void *priv,struct sk_buff *skb, +const struct nf_hook_state *state);#ifdef CONFIG_NETFILTER_XTABLES_COMPAT #include <net/compat.h>
net/ipv6/netfilter/ip6_tables.c +3 -3
@@ -247,10 +247,10 @@ ip6t_next_entry(const struct ip6t_entry *entry)/* Returns one of the generic firewall policies, like NF_ACCEPT. */ unsigned int -ip6t_do_table (struct sk_buff *skb, -const struct nf_hook_state *state, -struct xt_table *table) +ip6t_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))));/* Initializing verdict to NF_DROP keeps gcc happy. */
net/ipv6/netfilter/ip6table_filter.c +1 -9
@@ -27,14 +27,6 @@ static const struct xt_table packet_filter = { .priority = NF_IP6_PRI_FILTER, }; -/* The work comes in here from netfilter.c. */ -static unsigned int -ip6table_filter_hook (void *priv,struct sk_buff *skb, -const struct nf_hook_state *state) -{ -return ip6t_do_table (skb, state, priv); -} -static struct nf_hook_ops *filter_ops__read_mostly ;/* Default to forward because I got too much mail already. */
@@ -90,7 +82,7 @@ static int __init ip6table_filter_init(void)if (ret <0 )return ret; - filter_ops =xt_hook_ops_alloc (&packet_filter, ip6table_filter_hook); + filter_ops =xt_hook_ops_alloc (&packet_filter, ip6t_do_table);if (IS_ERR (filter_ops)) {xt_unregister_template (&packet_filter);return PTR_ERR (filter_ops);
net/ipv6/netfilter/ip6table_mangle.c +4 -4
@@ -29,7 +29,7 @@ static const struct xt_table packet_mangler = { };static unsigned int -ip6t_mangle_out (struct sk_buff *skb,const struct nf_hook_state *state,void *priv) +ip6t_mangle_out (void *priv,struct sk_buff *skb,const struct nf_hook_state *state) {unsigned int ret;struct in6_addr saddr, daddr;
@@ -46,7 +46,7 @@ ip6t_mangle_out(struct sk_buff *skb, const struct nf_hook_state *state, void *pr/* flowlabel and prio (includes version, which shouldn't change either */ flowlabel = *((u_int32_t *)ipv6_hdr (skb)); - ret =ip6t_do_table (skb, state, priv); + ret =ip6t_do_table (priv, skb, state); if (ret != NF_DROP && ret != NF_STOLEN && (!ipv6_addr_equal(&ipv6_hdr(skb)->saddr, &saddr) ||
@@ -68,8 +68,8 @@ ip6table_mangle_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *state) {if (state->hook ==NF_INET_LOCAL_OUT ) -return ip6t_mangle_out (skb, state, priv); -return ip6t_do_table (skb, state, priv); +return ip6t_mangle_out (priv, skb, state); +return ip6t_do_table (priv, skb, state); }static struct nf_hook_ops *mangle_ops__read_mostly ;
net/ipv6/netfilter/ip6table_nat.c +4 -11
@@ -31,34 +31,27 @@ static const struct xt_table nf_nat_ipv6_table = { .af = NFPROTO_IPV6, }; -static unsigned int ip6table_nat_do_chain (void *priv, -struct sk_buff *skb, -const struct nf_hook_state *state) -{ -return ip6t_do_table (skb, state, priv); -} -static const struct nf_hook_ops nf_nat_ipv6_ops[] = { { - .hook = ip6table_nat_do_chain, + .hook = ip6t_do_table, .pf =NFPROTO_IPV6 , .hooknum =NF_INET_PRE_ROUTING , .priority =NF_IP6_PRI_NAT_DST , }, { - .hook = ip6table_nat_do_chain, + .hook = ip6t_do_table, .pf =NFPROTO_IPV6 , .hooknum =NF_INET_POST_ROUTING , .priority =NF_IP6_PRI_NAT_SRC , }, { - .hook = ip6table_nat_do_chain, + .hook = ip6t_do_table, .pf =NFPROTO_IPV6 , .hooknum =NF_INET_LOCAL_OUT , .priority =NF_IP6_PRI_NAT_DST , }, { - .hook = ip6table_nat_do_chain, + .hook = ip6t_do_table, .pf =NFPROTO_IPV6 , .hooknum =NF_INET_LOCAL_IN , .priority =NF_IP6_PRI_NAT_SRC ,
net/ipv6/netfilter/ip6table_raw.c +1 -9
@@ -31,14 +31,6 @@ static const struct xt_table packet_raw_before_defrag = { .priority = NF_IP6_PRI_RAW_BEFORE_DEFRAG, }; -/* The work comes in here from netfilter.c. */ -static unsigned int -ip6table_raw_hook (void *priv,struct sk_buff *skb, -const struct nf_hook_state *state) -{ -return ip6t_do_table (skb, state, priv); -} -static struct nf_hook_ops *rawtable_ops__read_mostly ;static int ip6table_raw_table_init (struct net *net)
@@ -88,7 +80,7 @@ static int __init ip6table_raw_init(void)return ret;/* Register hooks */ - rawtable_ops =xt_hook_ops_alloc (table, ip6table_raw_hook); + rawtable_ops =xt_hook_ops_alloc (table, ip6t_do_table);if (IS_ERR (rawtable_ops)) {xt_unregister_template (table);return PTR_ERR (rawtable_ops);
net/ipv6/netfilter/ip6table_security.c +1 -8
@@ -32,13 +32,6 @@ static const struct xt_table security_table = { .priority = NF_IP6_PRI_SECURITY, }; -static unsigned int -ip6table_security_hook (void *priv,struct sk_buff *skb, -const struct nf_hook_state *state) -{ -return ip6t_do_table (skb, state, priv); -} -static struct nf_hook_ops *sectbl_ops__read_mostly ;static int ip6table_security_table_init (struct net *net)
@@ -77,7 +70,7 @@ static int __init ip6table_security_init(void)if (ret <0 )return ret; - sectbl_ops =xt_hook_ops_alloc (&security_table, ip6table_security_hook); + sectbl_ops =xt_hook_ops_alloc (&security_table, ip6t_do_table);if (IS_ERR (sectbl_ops)) {xt_unregister_template (&security_table);return PTR_ERR (sectbl_ops);
Signature · 1 line
2.32.0
Florian Westphal
maintainerPATCH 4/4 netfilter: ebtables: allow use of ebt_do_table as hookfn
In reply to Florian WestphalThis is possible now that the xt_table structure is passed via *priv.
--- include/linux/netfilter_bridge/ebtables.h | 5 ++--- net/bridge/netfilter/ebtable_broute.c | 2 +- net/bridge/netfilter/ebtable_filter.c | 13 +++---------- net/bridge/netfilter/ebtable_nat.c | 12 +++--------- net/bridge/netfilter/ebtables.c | 6 +++--- 5 files changed, 12 insertions(+), 26 deletions(-)
include/linux/netfilter_bridge/ebtables.h +2 -3
@@ -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 */
net/bridge/netfilter/ebtable_broute.c +1 -1
@@ -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;
net/bridge/netfilter/ebtable_filter.c +3 -10
@@ -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 ,
net/bridge/netfilter/ebtable_nat.c +3 -9
@@ -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 ,
net/bridge/netfilter/ebtables.c +3 -3
@@ -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;
Signature · 1 line
2.32.0
Pablo Neira Ayuso
maintainerQuoted 5 lines · Florian Westphal
An earlier series, starting with
commita4aeafa28cf706f65f("netfilter:xt_nat: pass table to hookfn"), converted thex_tablestable implementations to store the hook blob in the ->priv pointer that gets passed to the hook function.
Quoted 8 lines
Before this, the blobs were stored in struct net, so each table required its own wrapper to fetch the correct table blob.
Nowadays, allmost all hook functions in
x_tableland just call the hook evaluation loop.This series converts the table evaluation loop so it can be used directly, then removes most of the wrappers.
Series applied, thanks