mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
netfilter: nf_tables: make chain types override the default AF functions
Currently the AF-specific hook functions override the chain-type specific hook functions. That doesn't make too much sense since the chain types are a special case of the AF-specific hooks. Make the AF-specific hook functions the default and make the optional chain type hooks override them. As a side effect, the necessary code restructuring reduces the code size, f.i. in case of nf_tables_ipv4.o: nf_tables_ipv4_init_net | -24 nft_do_chain_ipv4 | -113 2 functions changed, 137 bytes removed, diff: -137 Signed-off-by: Patrick McHardy <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
This commit is contained in:
parent
688d18636f
commit
3b088c4bc0
5 changed files with 81 additions and 96 deletions
|
|
@ -14,10 +14,29 @@
|
|||
#include <linux/netfilter_bridge.h>
|
||||
#include <net/netfilter/nf_tables.h>
|
||||
|
||||
static unsigned int
|
||||
nft_do_chain_bridge(const struct nf_hook_ops *ops,
|
||||
struct sk_buff *skb,
|
||||
const struct net_device *in,
|
||||
const struct net_device *out,
|
||||
int (*okfn)(struct sk_buff *))
|
||||
{
|
||||
struct nft_pktinfo pkt;
|
||||
|
||||
nft_set_pktinfo(&pkt, ops, skb, in, out);
|
||||
|
||||
return nft_do_chain_pktinfo(&pkt, ops);
|
||||
}
|
||||
|
||||
static struct nft_af_info nft_af_bridge __read_mostly = {
|
||||
.family = NFPROTO_BRIDGE,
|
||||
.nhooks = NF_BR_NUMHOOKS,
|
||||
.owner = THIS_MODULE,
|
||||
.hooks = {
|
||||
[NF_BR_LOCAL_IN] = nft_do_chain_bridge,
|
||||
[NF_BR_FORWARD] = nft_do_chain_bridge,
|
||||
[NF_BR_LOCAL_OUT] = nft_do_chain_bridge,
|
||||
},
|
||||
};
|
||||
|
||||
static int nf_tables_bridge_init_net(struct net *net)
|
||||
|
|
@ -48,20 +67,6 @@ static struct pernet_operations nf_tables_bridge_net_ops = {
|
|||
.exit = nf_tables_bridge_exit_net,
|
||||
};
|
||||
|
||||
static unsigned int
|
||||
nft_do_chain_bridge(const struct nf_hook_ops *ops,
|
||||
struct sk_buff *skb,
|
||||
const struct net_device *in,
|
||||
const struct net_device *out,
|
||||
int (*okfn)(struct sk_buff *))
|
||||
{
|
||||
struct nft_pktinfo pkt;
|
||||
|
||||
nft_set_pktinfo(&pkt, ops, skb, in, out);
|
||||
|
||||
return nft_do_chain_pktinfo(&pkt, ops);
|
||||
}
|
||||
|
||||
static struct nf_chain_type filter_bridge = {
|
||||
.family = NFPROTO_BRIDGE,
|
||||
.name = "filter",
|
||||
|
|
@ -69,11 +74,6 @@ static struct nf_chain_type filter_bridge = {
|
|||
.hook_mask = (1 << NF_BR_LOCAL_IN) |
|
||||
(1 << NF_BR_FORWARD) |
|
||||
(1 << NF_BR_LOCAL_OUT),
|
||||
.fn = {
|
||||
[NF_BR_LOCAL_IN] = nft_do_chain_bridge,
|
||||
[NF_BR_FORWARD] = nft_do_chain_bridge,
|
||||
[NF_BR_LOCAL_OUT] = nft_do_chain_bridge,
|
||||
},
|
||||
};
|
||||
|
||||
static int __init nf_tables_bridge_init(void)
|
||||
|
|
|
|||
Loading…
Reference in a new issue