All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] netfilter: nft_ct: Add ct id support
@ 2019-04-23 20:17 Brett Mastbergen
  2019-04-23 20:47 ` Florian Westphal
  0 siblings, 1 reply; 2+ messages in thread
From: Brett Mastbergen @ 2019-04-23 20:17 UTC (permalink / raw)
  To: netfilter-devel

The 'id' key returns the unique id of the conntrack entry as returned
by nf_ct_get_id()

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

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..418a17d2df31 100644
--- a/net/netfilter/nft_ct.c
+++ b/net/netfilter/nft_ct.c
@@ -178,6 +178,9 @@ static void nft_ct_get_eval(const struct nft_expr *expr,
 		return;
 	}
 #endif
+	case NFT_CT_ID:
+		*dest = nf_ct_get_id(ct);
+		return;
 	default:
 		break;
 	}
@@ -479,6 +482,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;
 	}
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] netfilter: nft_ct: Add ct id support
  2019-04-23 20:17 [PATCH] netfilter: nft_ct: Add ct id support Brett Mastbergen
@ 2019-04-23 20:47 ` Florian Westphal
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Westphal @ 2019-04-23 20:47 UTC (permalink / raw)
  To: Brett Mastbergen; +Cc: netfilter-devel

Brett Mastbergen <bmastbergen@untangle.com> wrote:
> diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c
> index 7b717fad6cdc..418a17d2df31 100644
> --- a/net/netfilter/nft_ct.c
> +++ b/net/netfilter/nft_ct.c
> @@ -178,6 +178,9 @@ static void nft_ct_get_eval(const struct nft_expr *expr,
>  		return;
>  	}
>  #endif
> +	case NFT_CT_ID:
> +		*dest = nf_ct_get_id(ct);
> +		return;

This should perhaps be

if (!nfct_is_confirmed(ct))
	goto err;
*dest = ...

Otherwise we'll need to change nf_ct_get_id() to only
consider immutable properties of nf_conn.

ctnetlink never generates events until conntrack confirmation,
so I think the nfct_is_confirmed() check would be ok.

Other than this this looks great.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-23 20:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-23 20:17 [PATCH] netfilter: nft_ct: Add ct id support Brett Mastbergen
2019-04-23 20:47 ` Florian Westphal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.