diff mbox series

[v2] netfilter: nft_ct: Add ct id support

Message ID 20190424144844.20345-1-bmastbergen@untangle.com
State Accepted
Delegated to: Pablo Neira
Headers show
Series [v2] netfilter: nft_ct: Add ct id support | expand

Commit Message

Brett Mastbergen April 24, 2019, 2:48 p.m. UTC
The 'id' key returns the unique id of the conntrack entry as returned
by nf_ct_get_id()

v2: Add nfct_is_confirmed check

Signed-off-by: Brett Mastbergen <bmastbergen@untangle.com>
---
 include/uapi/linux/netfilter/nf_tables.h | 2 ++
 net/netfilter/nft_ct.c                   | 8 ++++++++
 2 files changed, 10 insertions(+)

Comments

Florian Westphal April 25, 2019, 12:54 a.m. UTC | #1
Brett Mastbergen <bmastbergen@untangle.com> wrote:
> The 'id' key returns the unique id of the conntrack entry as returned
> by nf_ct_get_id()
> 
> v2: Add nfct_is_confirmed check
> 
> Signed-off-by: Brett Mastbergen <bmastbergen@untangle.com>

Acked-by: Florian Westphal <fw@strlen.de>
Pablo Neira Ayuso April 30, 2019, 11:44 a.m. UTC | #2
On Wed, Apr 24, 2019 at 10:48:44AM -0400, Brett Mastbergen wrote:
> The 'id' key returns the unique id of the conntrack entry as returned
> by nf_ct_get_id()

Applied, thanks.
diff mbox series

Patch

diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h
index 061bb3eb20c3..f0cf7b0f4f35 100644
--- a/include/uapi/linux/netfilter/nf_tables.h
+++ b/include/uapi/linux/netfilter/nf_tables.h
@@ -967,6 +967,7 @@  enum nft_socket_keys {
  * @NFT_CT_SRC_IP6: conntrack layer 3 protocol source (IPv6 address)
  * @NFT_CT_DST_IP6: conntrack layer 3 protocol destination (IPv6 address)
  * @NFT_CT_TIMEOUT: connection tracking timeout policy assigned to conntrack
+ * @NFT_CT_ID: conntrack id
  */
 enum nft_ct_keys {
 	NFT_CT_STATE,
@@ -993,6 +994,7 @@  enum nft_ct_keys {
 	NFT_CT_SRC_IP6,
 	NFT_CT_DST_IP6,
 	NFT_CT_TIMEOUT,
+	NFT_CT_ID,
 	__NFT_CT_MAX
 };
 #define NFT_CT_MAX		(__NFT_CT_MAX - 1)
diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c
index 7b717fad6cdc..7706db36f8b9 100644
--- a/net/netfilter/nft_ct.c
+++ b/net/netfilter/nft_ct.c
@@ -178,6 +178,11 @@  static void nft_ct_get_eval(const struct nft_expr *expr,
 		return;
 	}
 #endif
+	case NFT_CT_ID:
+		if (!nf_ct_is_confirmed(ct))
+			goto err;
+		*dest = nf_ct_get_id(ct);
+		return;
 	default:
 		break;
 	}
@@ -479,6 +484,9 @@  static int nft_ct_get_init(const struct nft_ctx *ctx,
 		len = sizeof(u16);
 		break;
 #endif
+	case NFT_CT_ID:
+		len = sizeof(u32);
+		break;
 	default:
 		return -EOPNOTSUPP;
 	}