Commit 98319cb9 authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso

netfilter: nf_tables: get rid of struct nft_af_info abstraction

Remove the infrastructure to register/unregister nft_af_info structure,
this structure stores no useful information anymore.
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent dd4cbef7
...@@ -960,28 +960,12 @@ struct nft_table { ...@@ -960,28 +960,12 @@ struct nft_table {
struct list_head flowtables; struct list_head flowtables;
u64 hgenerator; u64 hgenerator;
u32 use; u32 use;
u16 flags:14, u16 family:6,
flags:8,
genmask:2; genmask:2;
struct nft_af_info *afi;
char *name; char *name;
}; };
/**
* struct nft_af_info - nf_tables address family info
*
* @list: used internally
* @family: address family
* @owner: module owner
*/
struct nft_af_info {
struct list_head list;
int family;
struct module *owner;
};
int nft_register_afinfo(struct nft_af_info *);
void nft_unregister_afinfo(struct nft_af_info *);
int nft_register_chain_type(const struct nf_chain_type *); int nft_register_chain_type(const struct nf_chain_type *);
void nft_unregister_chain_type(const struct nf_chain_type *); void nft_unregister_chain_type(const struct nf_chain_type *);
...@@ -1146,9 +1130,6 @@ void nft_trace_init(struct nft_traceinfo *info, const struct nft_pktinfo *pkt, ...@@ -1146,9 +1130,6 @@ void nft_trace_init(struct nft_traceinfo *info, const struct nft_pktinfo *pkt,
void nft_trace_notify(struct nft_traceinfo *info); void nft_trace_notify(struct nft_traceinfo *info);
#define MODULE_ALIAS_NFT_FAMILY(family) \
MODULE_ALIAS("nft-afinfo-" __stringify(family))
#define MODULE_ALIAS_NFT_CHAIN(family, name) \ #define MODULE_ALIAS_NFT_CHAIN(family, name) \
MODULE_ALIAS("nft-chain-" __stringify(family) "-" name) MODULE_ALIAS("nft-chain-" __stringify(family) "-" name)
......
...@@ -42,11 +42,6 @@ nft_do_chain_bridge(void *priv, ...@@ -42,11 +42,6 @@ nft_do_chain_bridge(void *priv,
return nft_do_chain(&pkt, priv); return nft_do_chain(&pkt, priv);
} }
static struct nft_af_info nft_af_bridge __read_mostly = {
.family = NFPROTO_BRIDGE,
.owner = THIS_MODULE,
};
static const struct nf_chain_type filter_bridge = { static const struct nf_chain_type filter_bridge = {
.name = "filter", .name = "filter",
.type = NFT_CHAIN_T_DEFAULT, .type = NFT_CHAIN_T_DEFAULT,
...@@ -68,28 +63,12 @@ static const struct nf_chain_type filter_bridge = { ...@@ -68,28 +63,12 @@ static const struct nf_chain_type filter_bridge = {
static int __init nf_tables_bridge_init(void) static int __init nf_tables_bridge_init(void)
{ {
int ret; return nft_register_chain_type(&filter_bridge);
ret = nft_register_afinfo(&nft_af_bridge);
if (ret < 0)
return ret;
ret = nft_register_chain_type(&filter_bridge);
if (ret < 0)
goto err_register_chain;
return ret;
err_register_chain:
nft_unregister_chain_type(&filter_bridge);
return ret;
} }
static void __exit nf_tables_bridge_exit(void) static void __exit nf_tables_bridge_exit(void)
{ {
nft_unregister_chain_type(&filter_bridge); nft_unregister_chain_type(&filter_bridge);
nft_unregister_afinfo(&nft_af_bridge);
} }
module_init(nf_tables_bridge_init); module_init(nf_tables_bridge_init);
...@@ -97,4 +76,4 @@ module_exit(nf_tables_bridge_exit); ...@@ -97,4 +76,4 @@ module_exit(nf_tables_bridge_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>"); MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
MODULE_ALIAS_NFT_FAMILY(AF_BRIDGE); MODULE_ALIAS_NFT_CHAIN(AF_BRIDGE, "filter");
...@@ -27,11 +27,6 @@ nft_do_chain_arp(void *priv, ...@@ -27,11 +27,6 @@ nft_do_chain_arp(void *priv,
return nft_do_chain(&pkt, priv); return nft_do_chain(&pkt, priv);
} }
static struct nft_af_info nft_af_arp __read_mostly = {
.family = NFPROTO_ARP,
.owner = THIS_MODULE,
};
static const struct nf_chain_type filter_arp = { static const struct nf_chain_type filter_arp = {
.name = "filter", .name = "filter",
.type = NFT_CHAIN_T_DEFAULT, .type = NFT_CHAIN_T_DEFAULT,
...@@ -47,28 +42,12 @@ static const struct nf_chain_type filter_arp = { ...@@ -47,28 +42,12 @@ static const struct nf_chain_type filter_arp = {
static int __init nf_tables_arp_init(void) static int __init nf_tables_arp_init(void)
{ {
int ret; return nft_register_chain_type(&filter_arp);
ret = nft_register_afinfo(&nft_af_arp);
if (ret < 0)
return ret;
ret = nft_register_chain_type(&filter_arp);
if (ret < 0)
goto err_register_chain;
return 0;
err_register_chain:
nft_unregister_chain_type(&filter_arp);
return ret;
} }
static void __exit nf_tables_arp_exit(void) static void __exit nf_tables_arp_exit(void)
{ {
nft_unregister_chain_type(&filter_arp); nft_unregister_chain_type(&filter_arp);
nft_unregister_afinfo(&nft_af_arp);
} }
module_init(nf_tables_arp_init); module_init(nf_tables_arp_init);
...@@ -76,4 +55,4 @@ module_exit(nf_tables_arp_exit); ...@@ -76,4 +55,4 @@ module_exit(nf_tables_arp_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>"); MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
MODULE_ALIAS_NFT_FAMILY(3); /* NFPROTO_ARP */ MODULE_ALIAS_NFT_CHAIN(3, "filter"); /* NFPROTO_ARP */
...@@ -30,11 +30,6 @@ static unsigned int nft_do_chain_ipv4(void *priv, ...@@ -30,11 +30,6 @@ static unsigned int nft_do_chain_ipv4(void *priv,
return nft_do_chain(&pkt, priv); return nft_do_chain(&pkt, priv);
} }
static struct nft_af_info nft_af_ipv4 __read_mostly = {
.family = NFPROTO_IPV4,
.owner = THIS_MODULE,
};
static const struct nf_chain_type filter_ipv4 = { static const struct nf_chain_type filter_ipv4 = {
.name = "filter", .name = "filter",
.type = NFT_CHAIN_T_DEFAULT, .type = NFT_CHAIN_T_DEFAULT,
...@@ -56,27 +51,12 @@ static const struct nf_chain_type filter_ipv4 = { ...@@ -56,27 +51,12 @@ static const struct nf_chain_type filter_ipv4 = {
static int __init nf_tables_ipv4_init(void) static int __init nf_tables_ipv4_init(void)
{ {
int ret; return nft_register_chain_type(&filter_ipv4);
ret = nft_register_afinfo(&nft_af_ipv4);
if (ret < 0)
return ret;
ret = nft_register_chain_type(&filter_ipv4);
if (ret < 0)
goto err_register_chain;
return 0;
err_register_chain:
nft_unregister_afinfo(&nft_af_ipv4);
return ret;
} }
static void __exit nf_tables_ipv4_exit(void) static void __exit nf_tables_ipv4_exit(void)
{ {
nft_unregister_chain_type(&filter_ipv4); nft_unregister_chain_type(&filter_ipv4);
nft_unregister_afinfo(&nft_af_ipv4);
} }
module_init(nf_tables_ipv4_init); module_init(nf_tables_ipv4_init);
...@@ -84,4 +64,4 @@ module_exit(nf_tables_ipv4_exit); ...@@ -84,4 +64,4 @@ module_exit(nf_tables_ipv4_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>"); MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
MODULE_ALIAS_NFT_FAMILY(AF_INET); MODULE_ALIAS_NFT_CHAIN(AF_INET, "filter");
...@@ -28,11 +28,6 @@ static unsigned int nft_do_chain_ipv6(void *priv, ...@@ -28,11 +28,6 @@ static unsigned int nft_do_chain_ipv6(void *priv,
return nft_do_chain(&pkt, priv); return nft_do_chain(&pkt, priv);
} }
static struct nft_af_info nft_af_ipv6 __read_mostly = {
.family = NFPROTO_IPV6,
.owner = THIS_MODULE,
};
static const struct nf_chain_type filter_ipv6 = { static const struct nf_chain_type filter_ipv6 = {
.name = "filter", .name = "filter",
.type = NFT_CHAIN_T_DEFAULT, .type = NFT_CHAIN_T_DEFAULT,
...@@ -54,26 +49,11 @@ static const struct nf_chain_type filter_ipv6 = { ...@@ -54,26 +49,11 @@ static const struct nf_chain_type filter_ipv6 = {
static int __init nf_tables_ipv6_init(void) static int __init nf_tables_ipv6_init(void)
{ {
int ret; return nft_register_chain_type(&filter_ipv6);
ret = nft_register_afinfo(&nft_af_ipv6);
if (ret < 0)
return ret;
ret = nft_register_chain_type(&filter_ipv6);
if (ret < 0)
goto err_register_chain;
return 0;
err_register_chain:
nft_unregister_afinfo(&nft_af_ipv6);
return ret;
} }
static void __exit nf_tables_ipv6_exit(void) static void __exit nf_tables_ipv6_exit(void)
{ {
nft_unregister_afinfo(&nft_af_ipv6);
nft_unregister_chain_type(&filter_ipv6); nft_unregister_chain_type(&filter_ipv6);
} }
...@@ -82,4 +62,4 @@ module_exit(nf_tables_ipv6_exit); ...@@ -82,4 +62,4 @@ module_exit(nf_tables_ipv6_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>"); MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
MODULE_ALIAS_NFT_FAMILY(AF_INET6); MODULE_ALIAS_NFT_CHAIN(AF_INET6, "filter");
This diff is collapsed.
...@@ -38,11 +38,6 @@ static unsigned int nft_do_chain_inet(void *priv, struct sk_buff *skb, ...@@ -38,11 +38,6 @@ static unsigned int nft_do_chain_inet(void *priv, struct sk_buff *skb,
return nft_do_chain(&pkt, priv); return nft_do_chain(&pkt, priv);
} }
static struct nft_af_info nft_af_inet __read_mostly = {
.family = NFPROTO_INET,
.owner = THIS_MODULE,
};
static const struct nf_chain_type filter_inet = { static const struct nf_chain_type filter_inet = {
.name = "filter", .name = "filter",
.type = NFT_CHAIN_T_DEFAULT, .type = NFT_CHAIN_T_DEFAULT,
...@@ -64,26 +59,12 @@ static const struct nf_chain_type filter_inet = { ...@@ -64,26 +59,12 @@ static const struct nf_chain_type filter_inet = {
static int __init nf_tables_inet_init(void) static int __init nf_tables_inet_init(void)
{ {
int ret; return nft_register_chain_type(&filter_inet);
if (nft_register_afinfo(&nft_af_inet) < 0)
return ret;
ret = nft_register_chain_type(&filter_inet);
if (ret < 0)
goto err_register_chain;
return ret;
err_register_chain:
nft_unregister_afinfo(&nft_af_inet);
return ret;
} }
static void __exit nf_tables_inet_exit(void) static void __exit nf_tables_inet_exit(void)
{ {
nft_unregister_chain_type(&filter_inet); nft_unregister_chain_type(&filter_inet);
nft_unregister_afinfo(&nft_af_inet);
} }
module_init(nf_tables_inet_init); module_init(nf_tables_inet_init);
...@@ -91,4 +72,4 @@ module_exit(nf_tables_inet_exit); ...@@ -91,4 +72,4 @@ module_exit(nf_tables_inet_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>"); MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
MODULE_ALIAS_NFT_FAMILY(1); MODULE_ALIAS_NFT_CHAIN(1, "filter");
...@@ -38,11 +38,6 @@ nft_do_chain_netdev(void *priv, struct sk_buff *skb, ...@@ -38,11 +38,6 @@ nft_do_chain_netdev(void *priv, struct sk_buff *skb,
return nft_do_chain(&pkt, priv); return nft_do_chain(&pkt, priv);
} }
static struct nft_af_info nft_af_netdev __read_mostly = {
.family = NFPROTO_NETDEV,
.owner = THIS_MODULE,
};
static const struct nf_chain_type nft_filter_chain_netdev = { static const struct nf_chain_type nft_filter_chain_netdev = {
.name = "filter", .name = "filter",
.type = NFT_CHAIN_T_DEFAULT, .type = NFT_CHAIN_T_DEFAULT,
...@@ -91,10 +86,10 @@ static int nf_tables_netdev_event(struct notifier_block *this, ...@@ -91,10 +86,10 @@ static int nf_tables_netdev_event(struct notifier_block *this,
nfnl_lock(NFNL_SUBSYS_NFTABLES); nfnl_lock(NFNL_SUBSYS_NFTABLES);
list_for_each_entry(table, &ctx.net->nft.tables, list) { list_for_each_entry(table, &ctx.net->nft.tables, list) {
if (table->afi->family != NFPROTO_NETDEV) if (table->family != NFPROTO_NETDEV)
continue; continue;
ctx.family = table->afi->family; ctx.family = table->family;
ctx.table = table; ctx.table = table;
list_for_each_entry_safe(chain, nr, &table->chains, list) { list_for_each_entry_safe(chain, nr, &table->chains, list) {
if (!nft_is_base_chain(chain)) if (!nft_is_base_chain(chain))
...@@ -117,12 +112,9 @@ static int __init nf_tables_netdev_init(void) ...@@ -117,12 +112,9 @@ static int __init nf_tables_netdev_init(void)
{ {
int ret; int ret;
if (nft_register_afinfo(&nft_af_netdev) < 0)
return ret;
ret = nft_register_chain_type(&nft_filter_chain_netdev); ret = nft_register_chain_type(&nft_filter_chain_netdev);
if (ret) if (ret)
goto err_register_chain_type; return ret;
ret = register_netdevice_notifier(&nf_tables_netdev_notifier); ret = register_netdevice_notifier(&nf_tables_netdev_notifier);
if (ret) if (ret)
...@@ -132,8 +124,6 @@ static int __init nf_tables_netdev_init(void) ...@@ -132,8 +124,6 @@ static int __init nf_tables_netdev_init(void)
err_register_netdevice_notifier: err_register_netdevice_notifier:
nft_unregister_chain_type(&nft_filter_chain_netdev); nft_unregister_chain_type(&nft_filter_chain_netdev);
err_register_chain_type:
nft_unregister_afinfo(&nft_af_netdev);
return ret; return ret;
} }
...@@ -142,7 +132,6 @@ static void __exit nf_tables_netdev_exit(void) ...@@ -142,7 +132,6 @@ static void __exit nf_tables_netdev_exit(void)
{ {
unregister_netdevice_notifier(&nf_tables_netdev_notifier); unregister_netdevice_notifier(&nf_tables_netdev_notifier);
nft_unregister_chain_type(&nft_filter_chain_netdev); nft_unregister_chain_type(&nft_filter_chain_netdev);
nft_unregister_afinfo(&nft_af_netdev);
} }
module_init(nf_tables_netdev_init); module_init(nf_tables_netdev_init);
...@@ -150,4 +139,4 @@ module_exit(nf_tables_netdev_exit); ...@@ -150,4 +139,4 @@ module_exit(nf_tables_netdev_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR("Pablo Neira Ayuso <pablo@netfilter.org>"); MODULE_AUTHOR("Pablo Neira Ayuso <pablo@netfilter.org>");
MODULE_ALIAS_NFT_FAMILY(5); /* NFPROTO_NETDEV */ MODULE_ALIAS_NFT_CHAIN(5, "filter"); /* NFPROTO_NETDEV */
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