Skip to content

Commit a9525c7

Browse files
author
Florian Westphal
committed
netfilter: xtables: allow xtables-nft only builds
Add hidden IP(6)_NF_IPTABLES_LEGACY symbol. When any of the "old" builtin tables are enabled the "old" iptables interface will be supported. To disable the old set/getsockopt interface the existing options for the builtin tables need to be turned off: CONFIG_IP_NF_IPTABLES=m CONFIG_IP_NF_FILTER is not set CONFIG_IP_NF_NAT is not set CONFIG_IP_NF_MANGLE is not set CONFIG_IP_NF_RAW is not set CONFIG_IP_NF_SECURITY is not set Same for CONFIG_IP6_NF_ variants. This allows to build a kernel that only supports ip(6)tables-nft (iptables-over-nftables api). In the future the _LEGACY symbol will become visible and the select statements will be turned into 'depends on', but for now be on safe side so "make oldconfig" won't break things. Signed-off-by: Florian Westphal <[email protected]>
1 parent 4654467 commit a9525c7

File tree

5 files changed

+34
-17
lines changed

5 files changed

+34
-17
lines changed

net/ipv4/netfilter/Kconfig

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ config NF_DEFRAG_IPV4
1010
tristate
1111
default n
1212

13+
# old sockopt interface and eval loop
14+
config IP_NF_IPTABLES_LEGACY
15+
tristate
16+
1317
config NF_SOCKET_IPV4
1418
tristate "IPv4 socket lookup support"
1519
help
@@ -152,7 +156,7 @@ config IP_NF_MATCH_ECN
152156
config IP_NF_MATCH_RPFILTER
153157
tristate '"rpfilter" reverse path filter match support'
154158
depends on NETFILTER_ADVANCED
155-
depends on IP_NF_MANGLE || IP_NF_RAW
159+
depends on IP_NF_MANGLE || IP_NF_RAW || NFT_COMPAT
156160
help
157161
This option allows you to match packets whose replies would
158162
go out via the interface the packet came in.
@@ -173,6 +177,7 @@ config IP_NF_MATCH_TTL
173177
config IP_NF_FILTER
174178
tristate "Packet filtering"
175179
default m if NETFILTER_ADVANCED=n
180+
select IP_NF_IPTABLES_LEGACY
176181
help
177182
Packet filtering defines a table `filter', which has a series of
178183
rules for simple packet filtering at local input, forwarding and
@@ -182,7 +187,7 @@ config IP_NF_FILTER
182187

183188
config IP_NF_TARGET_REJECT
184189
tristate "REJECT target support"
185-
depends on IP_NF_FILTER
190+
depends on IP_NF_FILTER || NFT_COMPAT
186191
select NF_REJECT_IPV4
187192
default m if NETFILTER_ADVANCED=n
188193
help
@@ -212,6 +217,7 @@ config IP_NF_NAT
212217
default m if NETFILTER_ADVANCED=n
213218
select NF_NAT
214219
select NETFILTER_XT_NAT
220+
select IP6_NF_IPTABLES_LEGACY
215221
help
216222
This enables the `nat' table in iptables. This allows masquerading,
217223
port forwarding and other forms of full Network Address Port
@@ -252,6 +258,7 @@ endif # IP_NF_NAT
252258
config IP_NF_MANGLE
253259
tristate "Packet mangling"
254260
default m if NETFILTER_ADVANCED=n
261+
select IP_NF_IPTABLES_LEGACY
255262
help
256263
This option adds a `mangle' table to iptables: see the man page for
257264
iptables(8). This table is used for various packet alterations
@@ -261,7 +268,7 @@ config IP_NF_MANGLE
261268

262269
config IP_NF_TARGET_ECN
263270
tristate "ECN target support"
264-
depends on IP_NF_MANGLE
271+
depends on IP_NF_MANGLE || NFT_COMPAT
265272
depends on NETFILTER_ADVANCED
266273
help
267274
This option adds a `ECN' target, which can be used in the iptables mangle
@@ -286,6 +293,7 @@ config IP_NF_TARGET_TTL
286293
# raw + specific targets
287294
config IP_NF_RAW
288295
tristate 'raw table support (required for NOTRACK/TRACE)'
296+
select IP_NF_IPTABLES_LEGACY
289297
help
290298
This option adds a `raw' table to iptables. This table is the very
291299
first in the netfilter framework and hooks in at the PREROUTING
@@ -299,6 +307,7 @@ config IP_NF_SECURITY
299307
tristate "Security table"
300308
depends on SECURITY
301309
depends on NETFILTER_ADVANCED
310+
select IP_NF_IPTABLES_LEGACY
302311
help
303312
This option adds a `security' table to iptables, for use
304313
with Mandatory Access Control (MAC) policy.

net/ipv4/netfilter/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ obj-$(CONFIG_NFT_FIB_IPV4) += nft_fib_ipv4.o
2525
obj-$(CONFIG_NFT_DUP_IPV4) += nft_dup_ipv4.o
2626

2727
# generic IP tables
28-
obj-$(CONFIG_IP_NF_IPTABLES) += ip_tables.o
28+
obj-$(CONFIG_IP_NF_IPTABLES_LEGACY) += ip_tables.o
2929

3030
# the three instances of ip_tables
3131
obj-$(CONFIG_IP_NF_FILTER) += iptable_filter.o

net/ipv6/netfilter/Kconfig

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
menu "IPv6: Netfilter Configuration"
77
depends on INET && IPV6 && NETFILTER
88

9+
# old sockopt interface and eval loop
10+
config IP6_NF_IPTABLES_LEGACY
11+
tristate
12+
913
config NF_SOCKET_IPV6
1014
tristate "IPv6 socket lookup support"
1115
help
@@ -147,7 +151,7 @@ config IP6_NF_MATCH_MH
147151
config IP6_NF_MATCH_RPFILTER
148152
tristate '"rpfilter" reverse path filter match support'
149153
depends on NETFILTER_ADVANCED
150-
depends on IP6_NF_MANGLE || IP6_NF_RAW
154+
depends on IP6_NF_MANGLE || IP6_NF_RAW || NFT_COMPAT
151155
help
152156
This option allows you to match packets whose replies would
153157
go out via the interface the packet came in.
@@ -186,6 +190,8 @@ config IP6_NF_TARGET_HL
186190
config IP6_NF_FILTER
187191
tristate "Packet filtering"
188192
default m if NETFILTER_ADVANCED=n
193+
select IP6_NF_IPTABLES_LEGACY
194+
tristate
189195
help
190196
Packet filtering defines a table `filter', which has a series of
191197
rules for simple packet filtering at local input, forwarding and
@@ -195,7 +201,7 @@ config IP6_NF_FILTER
195201

196202
config IP6_NF_TARGET_REJECT
197203
tristate "REJECT target support"
198-
depends on IP6_NF_FILTER
204+
depends on IP6_NF_FILTER || NFT_COMPAT
199205
select NF_REJECT_IPV6
200206
default m if NETFILTER_ADVANCED=n
201207
help
@@ -221,6 +227,7 @@ config IP6_NF_TARGET_SYNPROXY
221227
config IP6_NF_MANGLE
222228
tristate "Packet mangling"
223229
default m if NETFILTER_ADVANCED=n
230+
select IP6_NF_IPTABLES_LEGACY
224231
help
225232
This option adds a `mangle' table to iptables: see the man page for
226233
iptables(8). This table is used for various packet alterations
@@ -230,6 +237,7 @@ config IP6_NF_MANGLE
230237

231238
config IP6_NF_RAW
232239
tristate 'raw table support (required for TRACE)'
240+
select IP6_NF_IPTABLES_LEGACY
233241
help
234242
This option adds a `raw' table to ip6tables. This table is the very
235243
first in the netfilter framework and hooks in at the PREROUTING
@@ -243,6 +251,7 @@ config IP6_NF_SECURITY
243251
tristate "Security table"
244252
depends on SECURITY
245253
depends on NETFILTER_ADVANCED
254+
select IP6_NF_IPTABLES_LEGACY
246255
help
247256
This option adds a `security' table to iptables, for use
248257
with Mandatory Access Control (MAC) policy.
@@ -254,6 +263,7 @@ config IP6_NF_NAT
254263
depends on NF_CONNTRACK
255264
depends on NETFILTER_ADVANCED
256265
select NF_NAT
266+
select IP6_NF_IPTABLES_LEGACY
257267
select NETFILTER_XT_NAT
258268
help
259269
This enables the `nat' table in ip6tables. This allows masquerading,
@@ -262,25 +272,23 @@ config IP6_NF_NAT
262272

263273
To compile it as a module, choose M here. If unsure, say N.
264274

265-
if IP6_NF_NAT
266-
267275
config IP6_NF_TARGET_MASQUERADE
268276
tristate "MASQUERADE target support"
269277
select NETFILTER_XT_TARGET_MASQUERADE
278+
depends on IP6_NF_NAT
270279
help
271280
This is a backwards-compat option for the user's convenience
272281
(e.g. when running oldconfig). It selects NETFILTER_XT_TARGET_MASQUERADE.
273282

274283
config IP6_NF_TARGET_NPT
275284
tristate "NPT (Network Prefix translation) target support"
285+
depends on IP6_NF_NAT || NFT_COMPAT
276286
help
277287
This option adds the `SNPT' and `DNPT' target, which perform
278288
stateless IPv6-to-IPv6 Network Prefix Translation per RFC 6296.
279289

280290
To compile it as a module, choose M here. If unsure, say N.
281291

282-
endif # IP6_NF_NAT
283-
284292
endif # IP6_NF_IPTABLES
285293
endmenu
286294

net/ipv6/netfilter/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55

66
# Link order matters here.
7-
obj-$(CONFIG_IP6_NF_IPTABLES) += ip6_tables.o
7+
obj-$(CONFIG_IP6_NF_IPTABLES_LEGACY) += ip6_tables.o
88
obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o
99
obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o
1010
obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o

net/netfilter/Kconfig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ config NETFILTER_XT_TARGET_AUDIT
818818

819819
config NETFILTER_XT_TARGET_CHECKSUM
820820
tristate "CHECKSUM target support"
821-
depends on IP_NF_MANGLE || IP6_NF_MANGLE
821+
depends on IP_NF_MANGLE || IP6_NF_MANGLE || NFT_COMPAT
822822
depends on NETFILTER_ADVANCED
823823
help
824824
This option adds a `CHECKSUM' target, which can be used in the iptables mangle
@@ -869,7 +869,7 @@ config NETFILTER_XT_TARGET_CONNSECMARK
869869
config NETFILTER_XT_TARGET_CT
870870
tristate '"CT" target support'
871871
depends on NF_CONNTRACK
872-
depends on IP_NF_RAW || IP6_NF_RAW
872+
depends on IP_NF_RAW || IP6_NF_RAW || NFT_COMPAT
873873
depends on NETFILTER_ADVANCED
874874
help
875875
This options adds a `CT' target, which allows to specify initial
@@ -880,7 +880,7 @@ config NETFILTER_XT_TARGET_CT
880880

881881
config NETFILTER_XT_TARGET_DSCP
882882
tristate '"DSCP" and "TOS" target support'
883-
depends on IP_NF_MANGLE || IP6_NF_MANGLE
883+
depends on IP_NF_MANGLE || IP6_NF_MANGLE || NFT_COMPAT
884884
depends on NETFILTER_ADVANCED
885885
help
886886
This option adds a `DSCP' target, which allows you to manipulate
@@ -896,7 +896,7 @@ config NETFILTER_XT_TARGET_DSCP
896896

897897
config NETFILTER_XT_TARGET_HL
898898
tristate '"HL" hoplimit target support'
899-
depends on IP_NF_MANGLE || IP6_NF_MANGLE
899+
depends on IP_NF_MANGLE || IP6_NF_MANGLE || NFT_COMPAT
900900
depends on NETFILTER_ADVANCED
901901
help
902902
This option adds the "HL" (for IPv6) and "TTL" (for IPv4)
@@ -1080,7 +1080,7 @@ config NETFILTER_XT_TARGET_TPROXY
10801080
depends on NETFILTER_ADVANCED
10811081
depends on IPV6 || IPV6=n
10821082
depends on IP6_NF_IPTABLES || IP6_NF_IPTABLES=n
1083-
depends on IP_NF_MANGLE
1083+
depends on IP_NF_MANGLE || NFT_COMPAT
10841084
select NF_DEFRAG_IPV4
10851085
select NF_DEFRAG_IPV6 if IP6_NF_IPTABLES != n
10861086
select NF_TPROXY_IPV4
@@ -1147,7 +1147,7 @@ config NETFILTER_XT_TARGET_TCPMSS
11471147

11481148
config NETFILTER_XT_TARGET_TCPOPTSTRIP
11491149
tristate '"TCPOPTSTRIP" target support'
1150-
depends on IP_NF_MANGLE || IP6_NF_MANGLE
1150+
depends on IP_NF_MANGLE || IP6_NF_MANGLE || NFT_COMPAT
11511151
depends on NETFILTER_ADVANCED
11521152
help
11531153
This option adds a "TCPOPTSTRIP" target, which allows you to strip

0 commit comments

Comments
 (0)