Skip to content

Commit 84fc240

Browse files
committed
Florian Westphal says: ==================== nf-next pr 2024-01-29 This batch contains updates for your *next* tree. First three changes, from Phil Sutter, allow userspace to define a table that is exclusively owned by a daemon (via netlink socket aliveness) without auto-removing this table when the userspace program exits. Such table gets marked as orphaned and a restarting management daemon may re-attach/reassume ownership. Next patch, from Pablo, passes already-validated flags variable around rather than having called code re-fetch it from netlnik message. Patches 5 and 6 update ipvs and nf_conncount to use the recently introduced KMEM_CACHE() macro. Last three patches, from myself, tweak kconfig logic a little to permit a kernel configuration that can run iptables-over-nftables but not classic (setsockopt) iptables. Such builds lack the builtin-filter/mangle/raw/nat/security tables, the set/getsockopt interface and the "old blob format" interpreter/traverser. For now, this is 'oldconfig friendly', users need to manually deselect existing config options for this. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents a9c3d39 + 7ad2697 commit 84fc240

File tree

12 files changed

+94
-53
lines changed

12 files changed

+94
-53
lines changed

include/net/netfilter/nf_tables.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,12 @@ static inline bool nft_table_has_owner(const struct nft_table *table)
12711271
return table->flags & NFT_TABLE_F_OWNER;
12721272
}
12731273

1274+
static inline bool nft_table_is_orphan(const struct nft_table *table)
1275+
{
1276+
return (table->flags & (NFT_TABLE_F_OWNER | NFT_TABLE_F_PERSIST)) ==
1277+
NFT_TABLE_F_PERSIST;
1278+
}
1279+
12741280
static inline bool nft_base_chain_netdev(int family, u32 hooknum)
12751281
{
12761282
return family == NFPROTO_NETDEV ||

include/uapi/linux/netfilter/nf_tables.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,17 @@ enum nft_hook_attributes {
179179
* enum nft_table_flags - nf_tables table flags
180180
*
181181
* @NFT_TABLE_F_DORMANT: this table is not active
182+
* @NFT_TABLE_F_OWNER: this table is owned by a process
183+
* @NFT_TABLE_F_PERSIST: this table shall outlive its owner
182184
*/
183185
enum nft_table_flags {
184186
NFT_TABLE_F_DORMANT = 0x1,
185187
NFT_TABLE_F_OWNER = 0x2,
188+
NFT_TABLE_F_PERSIST = 0x4,
186189
};
187190
#define NFT_TABLE_F_MASK (NFT_TABLE_F_DORMANT | \
188-
NFT_TABLE_F_OWNER)
191+
NFT_TABLE_F_OWNER | \
192+
NFT_TABLE_F_PERSIST)
189193

190194
/**
191195
* enum nft_table_attributes - nf_tables table netlink attributes

net/bridge/netfilter/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ config NF_CONNTRACK_BRIDGE
3939

4040
To compile it as a module, choose M here. If unsure, say N.
4141

42+
# old sockopt interface and eval loop
43+
config BRIDGE_NF_EBTABLES_LEGACY
44+
tristate
45+
4246
menuconfig BRIDGE_NF_EBTABLES
4347
tristate "Ethernet Bridge tables (ebtables) support"
4448
depends on BRIDGE && NETFILTER && NETFILTER_XTABLES
@@ -55,6 +59,7 @@ if BRIDGE_NF_EBTABLES
5559
#
5660
config BRIDGE_EBT_BROUTE
5761
tristate "ebt: broute table support"
62+
select BRIDGE_NF_EBTABLES_LEGACY
5863
help
5964
The ebtables broute table is used to define rules that decide between
6065
bridging and routing frames, giving Linux the functionality of a
@@ -65,6 +70,7 @@ config BRIDGE_EBT_BROUTE
6570

6671
config BRIDGE_EBT_T_FILTER
6772
tristate "ebt: filter table support"
73+
select BRIDGE_NF_EBTABLES_LEGACY
6874
help
6975
The ebtables filter table is used to define frame filtering rules at
7076
local input, forwarding and local output. See the man page for
@@ -74,6 +80,7 @@ config BRIDGE_EBT_T_FILTER
7480

7581
config BRIDGE_EBT_T_NAT
7682
tristate "ebt: nat table support"
83+
select BRIDGE_NF_EBTABLES_LEGACY
7784
help
7885
The ebtables nat table is used to define rules that alter the MAC
7986
source address (MAC SNAT) or the MAC destination address (MAC DNAT).

net/bridge/netfilter/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ obj-$(CONFIG_NFT_BRIDGE_REJECT) += nft_reject_bridge.o
99
# connection tracking
1010
obj-$(CONFIG_NF_CONNTRACK_BRIDGE) += nf_conntrack_bridge.o
1111

12-
obj-$(CONFIG_BRIDGE_NF_EBTABLES) += ebtables.o
12+
obj-$(CONFIG_BRIDGE_NF_EBTABLES_LEGACY) += ebtables.o
1313

1414
# tables
1515
obj-$(CONFIG_BRIDGE_EBT_BROUTE) += ebtable_broute.o

net/ipv4/netfilter/Kconfig

Lines changed: 25 additions & 18 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.
@@ -309,36 +318,34 @@ endif # IP_NF_IPTABLES
309318

310319
# ARP tables
311320
config IP_NF_ARPTABLES
312-
tristate "ARP tables support"
313-
select NETFILTER_XTABLES
314-
select NETFILTER_FAMILY_ARP
315-
depends on NETFILTER_ADVANCED
316-
help
317-
arptables is a general, extensible packet identification framework.
318-
The ARP packet filtering and mangling (manipulation)subsystems
319-
use this: say Y or M here if you want to use either of those.
320-
321-
To compile it as a module, choose M here. If unsure, say N.
321+
tristate
322322

323-
if IP_NF_ARPTABLES
323+
config NFT_COMPAT_ARP
324+
tristate
325+
depends on NF_TABLES_ARP && NFT_COMPAT
326+
default m if NFT_COMPAT=m
327+
default y if NFT_COMPAT=y
324328

325329
config IP_NF_ARPFILTER
326-
tristate "ARP packet filtering"
330+
tristate "arptables-legacy packet filtering support"
331+
select IP_NF_ARPTABLES
327332
help
328333
ARP packet filtering defines a table `filter', which has a series of
329334
rules for simple ARP packet filtering at local input and
330-
local output. On a bridge, you can also specify filtering rules
331-
for forwarded ARP packets. See the man page for arptables(8).
335+
local output. This is only needed for arptables-legacy(8).
336+
Neither arptables-nft nor nftables need this to work.
332337

333338
To compile it as a module, choose M here. If unsure, say N.
334339

335340
config IP_NF_ARP_MANGLE
336341
tristate "ARP payload mangling"
342+
depends on IP_NF_ARPTABLES || NFT_COMPAT_ARP
337343
help
338344
Allows altering the ARP packet payload: source and destination
339345
hardware and network addresses.
340346

341-
endif # IP_NF_ARPTABLES
347+
This option is needed by both arptables-legacy and arptables-nft.
348+
It is not used by nftables.
342349

343350
endmenu
344351

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

net/netfilter/ipvs/ip_vs_conn.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,9 +1511,7 @@ int __init ip_vs_conn_init(void)
15111511
return -ENOMEM;
15121512

15131513
/* Allocate ip_vs_conn slab cache */
1514-
ip_vs_conn_cachep = kmem_cache_create("ip_vs_conn",
1515-
sizeof(struct ip_vs_conn), 0,
1516-
SLAB_HWCACHE_ALIGN, NULL);
1514+
ip_vs_conn_cachep = KMEM_CACHE(ip_vs_conn, SLAB_HWCACHE_ALIGN);
15171515
if (!ip_vs_conn_cachep) {
15181516
kvfree(ip_vs_conn_tab);
15191517
return -ENOMEM;

0 commit comments

Comments
 (0)