Skip to contentSkip to conversation

Add support for ct set

PATCH In review Kristian Evensen 2 participants 2 messages Jan 11, 2014 – Jan 15, 2014 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 Add support for ct set

From: Kristian Evensen <[email protected]>

This patch adds userspace support for setting properties of tracked connections. Currently, the connection mark is supported. This can be used to implemented the same functionality as iptables -j CONNMARK --save-mark.

v1->v2:
- Fixed a style error.
- Improved error handling. Fail if neither sreg nor dreg is set (was already present when parsing XML).

v2->v3:
- Set sreg type to enum nft_registers.
- Let user specify any combination of sreg and dreg, and let the kernel do the error checking (and return -EINVAL). We avoid masking any errors and users will know that they have to fix their code.

v3->v4:
- Bugs in the json and XML snprintf-functions.

---
 include/libnftables/expr.h          |   1 +
 include/linux/netfilter/nf_tables.h |   2 +
 src/expr/ct.c                       | 127 ++++++++++++++++++++++++++++--------
 3 files changed, 104 insertions(+), 26 deletions(-)
include/libnftables/expr.h +1 -0
index 25455e4..653bbb0 100644
@@ -124,6 +124,7 @@ enum {
 	NFT_EXPR_CT_DREG	= NFT_RULE_EXPR_ATTR_BASE,
 	NFT_EXPR_CT_KEY,
 	NFT_EXPR_CT_DIR,
+	NFT_EXPR_CT_SREG,
 };
 
 enum {
include/linux/netfilter/nf_tables.h +2 -0
index fc0f669..6a22a37 100644
@@ -530,12 +530,14 @@ enum nft_ct_keys {
  * @NFTA_CT_DREG: destination register (NLA_U32)
  * @NFTA_CT_KEY: conntrack data item to load (NLA_U32: nft_ct_keys)
  * @NFTA_CT_DIRECTION: direction in case of directional keys (NLA_U8)
+ * @NFTA_CT_SREG: source register (NLA_U32)
  */
 enum nft_ct_attributes {
 	NFTA_CT_UNSPEC,
 	NFTA_CT_DREG,
 	NFTA_CT_KEY,
 	NFTA_CT_DIRECTION,
+	NFTA_CT_SREG,
 	__NFTA_CT_MAX
 };
 #define NFTA_CT_MAX		(__NFTA_CT_MAX - 1)
src/expr/ct.c +101 -26

212 lines not on this page · raw message

Signature · 1 line
1.8.3.2
#1 lore raw
Quoted 5 lines · Kristian Evensen

From: Kristian Evensen <[email protected]>

This patch adds userspace support for setting properties of tracked connections. Currently, the connection mark is supported. This can be used to implemented the same functionality as iptables -j CONNMARK --save-mark.

Also applied to next-3.14, thanks.