Skip to content

Commit 3bf195a

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: nat: merge nf_nat_ipv4,6 into nat core
before: text data bss dec hex filename 16566 1576 4136 22278 5706 nf_nat.ko 3598 844 0 4442 115a nf_nat_ipv6.ko 3187 844 0 4031 fbf nf_nat_ipv4.ko after: text data bss dec hex filename 22948 1612 4136 28696 7018 nf_nat.ko ... with ipv4/v6 nat now provided directly via nf_nat.ko. Also changes: ret = nf_nat_ipv4_fn(priv, skb, state); if (ret != NF_DROP && ret != NF_STOLEN && into if (ret != NF_ACCEPT) return ret; everywhere. The nat hooks never should return anything other than ACCEPT or DROP (and the latter only in rare error cases). The original code uses multi-line ANDing including assignment-in-if: if (ret != NF_DROP && ret != NF_STOLEN && !(IPCB(skb)->flags & IPSKB_XFRM_TRANSFORMED) && (ct = nf_ct_get(skb, &ctinfo)) != NULL) { I removed this while moving, breaking those in separate conditionals and moving the assignments into extra lines. checkpatch still generates some warnings: 1. Overly long lines (of moved code). Breaking them is even more ugly. so I kept this as-is. 2. use of extern function declarations in a .c file. This is necessary evil, we must call nf_nat_l3proto_register() from the nat core now. All l3proto related functions are removed later in this series, those prototypes are then removed as well. v2: keep empty nf_nat_ipv6_csum_update stub for CONFIG_IPV6=n case. v3: remove IS_ENABLED(NF_NAT_IPV4/6) tests, NF_NAT_IPVx toggles are removed here. v4: also get rid of the assignments in conditionals. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 096d090 commit 3bf195a

12 files changed

Lines changed: 711 additions & 738 deletions

File tree

‎net/ipv4/netfilter/Kconfig‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,7 @@ config NF_REJECT_IPV4
9494
tristate "IPv4 packet rejection"
9595
default m if NETFILTER_ADVANCED=n
9696

97-
config NF_NAT_IPV4
98-
tristate "IPv4 NAT"
99-
depends on NF_CONNTRACK
100-
default m if NETFILTER_ADVANCED=n
101-
select NF_NAT
102-
help
103-
The IPv4 NAT option allows masquerading, port forwarding and other
104-
forms of full Network Address Port Translation. This can be
105-
controlled by iptables or nft.
106-
107-
if NF_NAT_IPV4
97+
if NF_NAT
10898

10999
if NF_TABLES
110100
config NFT_CHAIN_NAT_IPV4
@@ -163,7 +153,7 @@ config NF_NAT_H323
163153
depends on NF_CONNTRACK
164154
default NF_CONNTRACK_H323
165155

166-
endif # NF_NAT_IPV4
156+
endif # NF_NAT
167157

168158
config IP_NF_IPTABLES
169159
tristate "IP tables support (required for filtering/masq/NAT)"
@@ -260,7 +250,6 @@ config IP_NF_NAT
260250
depends on NF_CONNTRACK
261251
default m if NETFILTER_ADVANCED=n
262252
select NF_NAT
263-
select NF_NAT_IPV4
264253
select NETFILTER_XT_NAT
265254
help
266255
This enables the `nat' table in iptables. This allows masquerading,

‎net/ipv4/netfilter/Makefile‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
# Makefile for the netfilter modules on top of IPv4.
44
#
55

6-
nf_nat_ipv4-y := nf_nat_l3proto_ipv4.o
7-
obj-$(CONFIG_NF_NAT_IPV4) += nf_nat_ipv4.o
8-
96
# defrag
107
obj-$(CONFIG_NF_DEFRAG_IPV4) += nf_defrag_ipv4.o
118

‎net/ipv4/netfilter/nf_nat_l3proto_ipv4.c‎

Lines changed: 0 additions & 330 deletions
This file was deleted.

0 commit comments

Comments
 (0)