From: wenxu <wenxu@xxxxxxxxx> Add nft_chan_nat_bridge to handle nat rule in bridge family Signed-off-by: wenxu <wenxu@xxxxxxxxx> --- net/netfilter/nft_chain_nat.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/net/netfilter/nft_chain_nat.c b/net/netfilter/nft_chain_nat.c index 2f89bde..2ae3fbb 100644 --- a/net/netfilter/nft_chain_nat.c +++ b/net/netfilter/nft_chain_nat.c @@ -104,6 +104,23 @@ static void nft_nat_inet_unreg(struct net *net, const struct nf_hook_ops *ops) }; #endif +#ifdef CONFIG_NF_TABLES_BRIDGE +static const struct nft_chain_type nft_chain_nat_bridge = { + .name = "nat", + .type = NFT_CHAIN_T_NAT, + .family = NFPROTO_BRIDGE, + .owner = THIS_MODULE, + .hook_mask = (1 << NF_INET_PRE_ROUTING) | + (1 << NF_INET_POST_ROUTING), + .hooks = { + [NF_INET_PRE_ROUTING] = nft_nat_do_chain, + [NF_INET_POST_ROUTING] = nft_nat_do_chain, + }, + .ops_register = nf_nat_bridge_register_fn, + .ops_unregister = nf_nat_bridge_unregister_fn, +}; +#endif + static int __init nft_chain_nat_init(void) { #ifdef CONFIG_NF_TABLES_IPV6 @@ -115,6 +132,9 @@ static int __init nft_chain_nat_init(void) #ifdef CONFIG_NF_TABLES_INET nft_register_chain_type(&nft_chain_nat_inet); #endif +#ifdef CONFIG_NF_TABLES_BRIDGE + nft_register_chain_type(&nft_chain_nat_bridge); +#endif return 0; } @@ -130,6 +150,9 @@ static void __exit nft_chain_nat_exit(void) #ifdef CONFIG_NF_TABLES_INET nft_unregister_chain_type(&nft_chain_nat_inet); #endif +#ifdef CONFIG_NF_TABLES_BRIDGE + nft_unregister_chain_type(&nft_chain_nat_bridge); +#endif } module_init(nft_chain_nat_init); @@ -142,3 +165,6 @@ static void __exit nft_chain_nat_exit(void) #ifdef CONFIG_NF_TABLES_IPV6 MODULE_ALIAS_NFT_CHAIN(AF_INET6, "nat"); #endif +#ifdef CONFIG_NF_TABLES_BRIDGE +MODULE_ALIAS_NFT_CHAIN(AF_BRIDGE, "nat"); +#endif -- 1.8.3.1