Skip to contentSkip to conversation

nf_tables: dormant tables

RFC PATCH New [email protected] 1 participant 2 messages Nov 13, 2012

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

RFC PATCH 1/1 nf_tables: dormant tables

From: Pablo Neira Ayuso <[email protected]>

Hi,

The following patch adds the concept of dormant tables. Basically, it's a flag that you can set to get a table (and all they chains) inactive. Dormant tables have no effect and see no traffic.

This operation can be also used to support atomic replacement at chain level, that can be done following these steps:

1) set table as dormant
2) flush the rule-set in all their chains
3) add the new rule-set
4) set table as active

The main target of this patch is to provide a way to load the rule-set in a chain at once, avoiding possible some inconsistent state at the chain level.

Coments welcome.

Pablo Neira Ayuso (1):
netfilter: nf_tables: add support for dormant tables

 include/linux/netfilter/nf_tables.h |   10 ++++
 include/net/netfilter/nf_tables.h   |    2 +
 net/netfilter/nf_tables_api.c       |   90 +++++++++++++++++++++++++++++++++--
 3 files changed, 98 insertions(+), 4 deletions(-)
Signature · 1 line
1.7.10.4
author maintainer
#1 lore raw

PATCH 1/1 netfilter: nf_tables: add support for dormant tables

From: Pablo Neira Ayuso <[email protected]>

Dormant tables are those whose chains are not registered, thus, they are not active. You can change the state of a dormant table via NFT_MSG_NEWTABLE messages. Using this operation you can wake up a table, so their chains are registered.

This provides atomicity at chain level. Thus, the rule-set of one chain is applied at once, avoiding any possible intermediate state in every chain. Still, the chains that belongs to a table are registered consecutively. This also allows you to have inactive tables in the kernel.

Atomicity at table level is desired, eg. to ensure that the INPUT and OUTPUT chains of the filter table are loaded at once. However, it still does not avoid possible temporary inconsistent configurations for inter-dependant rules located in different tables. During the loading stage, the connection tracking system also opens the door to allow unwanted connections if the iptables stateful rule-set is loaded having existing established flows.

---
 include/linux/netfilter/nf_tables.h |   10 ++++
 include/net/netfilter/nf_tables.h   |    2 +
 net/netfilter/nf_tables_api.c       |   90 +++++++++++++++++++++++++++++++++--
 3 files changed, 98 insertions(+), 4 deletions(-)
include/linux/netfilter/nf_tables.h +10 -0
index 1242e62..a3989fd 100644
@@ -55,9 +55,19 @@ enum nft_hook_attributes {
 };
 #define NFTA_HOOK_MAX		(__NFTA_HOOK_MAX - 1)
 
+/**
+ * enum nft_table_flags - nf_tables table flags
+ *
+ * @NFT_TABLE_F_DORMANT: this table is not active
+ */
+enum nft_table_flags {
+	NFT_TABLE_F_DORMANT	= 0x1,
+};
+
 enum nft_table_attributes {
 	NFTA_TABLE_UNSPEC,
 	NFTA_TABLE_NAME,
+	NFTA_TABLE_FLAGS,
 	__NFTA_TABLE_MAX
 };
 #define NFTA_TABLE_MAX		(__NFTA_TABLE_MAX - 1)
include/net/netfilter/nf_tables.h +2 -0
index 0916685..2301b74 100644
@@ -396,12 +396,14 @@ extern unsigned int nft_do_chain(const struct nf_hook_ops *ops,
  *	@list: used internally
  *	@chains: chains in the table
  *	@sets: sets in the table
+ *	@flags: table flag (see enum nft_table_flags)
  *	@name: name of the table
  */
 struct nft_table {
 	struct list_head		list;
 	struct list_head		chains;
 	struct list_head		sets;
+	u16				flags;
 	char				name[];
 };
 
net/netfilter/nf_tables_api.c +86 -4

132 lines not on this page · raw message

Signature · 1 line
1.7.10.4