Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: nat: merge ipv4/ipv6 masquerade code into main nat module

Instead of using extra modules for these, turn the config options into
an implicit dependency that adds masq feature to the protocol specific nf_nat module.

before:
text data bss dec hex filename
2001 860 4 2865 b31 net/ipv4/netfilter/nf_nat_masquerade_ipv4.ko
5579 780 2 6361 18d9 net/ipv4/netfilter/nf_nat_ipv4.ko
2860 836 8 3704 e78 net/ipv6/netfilter/nf_nat_masquerade_ipv6.ko
6648 780 2 7430 1d06 net/ipv6/netfilter/nf_nat_ipv6.ko

after:
text data bss dec hex filename
7245 872 8 8125 1fbd net/ipv4/netfilter/nf_nat_ipv4.ko
9165 848 12 10025 2729 net/ipv6/netfilter/nf_nat_ipv6.ko

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

Florian Westphal and committed by
Pablo Neira Ayuso
0168e8b3 e5a10bb2

+4 -20
+1 -4
net/ipv4/netfilter/Kconfig
··· 129 129 source and destination ports. 130 130 131 131 config NF_NAT_MASQUERADE_IPV4 132 - tristate "IPv4 masquerade support" 133 - help 134 - This is the kernel functionality to provide NAT in the masquerade 135 - flavour (automatic source address selection). 132 + bool 136 133 137 134 config NFT_MASQ_IPV4 138 135 tristate "IPv4 masquerading support for nf_tables"
+1 -3
net/ipv4/netfilter/Makefile
··· 10 10 obj-$(CONFIG_NF_CONNTRACK_IPV4) += nf_conntrack_ipv4.o 11 11 12 12 nf_nat_ipv4-y := nf_nat_l3proto_ipv4.o nf_nat_proto_icmp.o 13 + nf_nat_ipv4-$(CONFIG_NF_NAT_MASQUERADE_IPV4) += nf_nat_masquerade_ipv4.o 13 14 obj-$(CONFIG_NF_NAT_IPV4) += nf_nat_ipv4.o 14 15 15 16 # defrag ··· 32 31 nf_nat_snmp_basic-y := nf_nat_snmp_basic.asn1.o nf_nat_snmp_basic_main.o 33 32 $(obj)/nf_nat_snmp_basic_main.o: $(obj)/nf_nat_snmp_basic.asn1.h 34 33 obj-$(CONFIG_NF_NAT_SNMP_BASIC) += nf_nat_snmp_basic.o 35 - 36 - obj-$(CONFIG_NF_NAT_MASQUERADE_IPV4) += nf_nat_masquerade_ipv4.o 37 - 38 34 39 35 # NAT protocols (nf_nat) 40 36 obj-$(CONFIG_NF_NAT_PROTO_GRE) += nf_nat_proto_gre.o
-4
net/ipv4/netfilter/nf_nat_masquerade_ipv4.c
··· 7 7 */ 8 8 9 9 #include <linux/types.h> 10 - #include <linux/module.h> 11 10 #include <linux/atomic.h> 12 11 #include <linux/inetdevice.h> 13 12 #include <linux/ip.h> ··· 156 157 unregister_inetaddr_notifier(&masq_inet_notifier); 157 158 } 158 159 EXPORT_SYMBOL_GPL(nf_nat_masquerade_ipv4_unregister_notifier); 159 - 160 - MODULE_LICENSE("GPL"); 161 - MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>");
+1 -4
net/ipv6/netfilter/Kconfig
··· 136 136 if NF_NAT_IPV6 137 137 138 138 config NF_NAT_MASQUERADE_IPV6 139 - tristate "IPv6 masquerade support" 140 - help 141 - This is the kernel functionality to provide NAT in the masquerade 142 - flavour (automatic source address selection) for IPv6. 139 + bool 143 140 144 141 endif # NF_NAT_IPV6 145 142
+1 -1
net/ipv6/netfilter/Makefile
··· 18 18 obj-$(CONFIG_NF_CONNTRACK_IPV6) += nf_conntrack_ipv6.o 19 19 20 20 nf_nat_ipv6-y := nf_nat_l3proto_ipv6.o nf_nat_proto_icmpv6.o 21 + nf_nat_ipv6-$(CONFIG_NF_NAT_MASQUERADE_IPV6) += nf_nat_masquerade_ipv6.o 21 22 obj-$(CONFIG_NF_NAT_IPV6) += nf_nat_ipv6.o 22 - obj-$(CONFIG_NF_NAT_MASQUERADE_IPV6) += nf_nat_masquerade_ipv6.o 23 23 24 24 # defrag 25 25 nf_defrag_ipv6-y := nf_defrag_ipv6_hooks.o nf_conntrack_reasm.o
-4
net/ipv6/netfilter/nf_nat_masquerade_ipv6.c
··· 10 10 */ 11 11 12 12 #include <linux/kernel.h> 13 - #include <linux/module.h> 14 13 #include <linux/atomic.h> 15 14 #include <linux/netdevice.h> 16 15 #include <linux/ipv6.h> ··· 185 186 unregister_netdevice_notifier(&masq_dev_notifier); 186 187 } 187 188 EXPORT_SYMBOL_GPL(nf_nat_masquerade_ipv6_unregister_notifier); 188 - 189 - MODULE_LICENSE("GPL"); 190 - MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");