aboutgitcodebugslistschat
path: root/flow.h
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-07-05 20:44:00 +1000
committerStefano Brivio <sbrivio@redhat.com>2024-07-05 15:26:25 +0200
commit8f8eb734828dfe8e07903adbe2a772e2afa46872 (patch)
tree5be1c29b510ca355075290d78f560c919b0bcb8b /flow.h
parent74c1c5efcfec9fcdb6efe0c8d377af2a7d8e4b0a (diff)
downloadpasst-8f8eb734828dfe8e07903adbe2a772e2afa46872.tar
passt-8f8eb734828dfe8e07903adbe2a772e2afa46872.tar.gz
passt-8f8eb734828dfe8e07903adbe2a772e2afa46872.tar.bz2
passt-8f8eb734828dfe8e07903adbe2a772e2afa46872.tar.lz
passt-8f8eb734828dfe8e07903adbe2a772e2afa46872.tar.xz
passt-8f8eb734828dfe8e07903adbe2a772e2afa46872.tar.zst
passt-8f8eb734828dfe8e07903adbe2a772e2afa46872.zip
flow: Add flow_sidx_valid() helper
To implement the TCP hash table, we need an invalid (NULL-like) value for flow_sidx_t. We use FLOW_SIDX_NONE for that, but for defensiveness, we treat (usually) anything with an out of bounds flow index the same way. That's not always done consistently though. In flow_at_sidx() we open code a check on the flow index. In tcp_hash_probe() we instead compare against FLOW_SIDX_NONE, and in some other places we use the fact that flow_at_sidx() will return NULL in this case, even if we don't otherwise need the flow it returns. Clean this up a bit, by adding an explicit flow_sidx_valid() test function. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'flow.h')
-rw-r--r--flow.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/flow.h b/flow.h
index 29ef9f1..d1f49c6 100644
--- a/flow.h
+++ b/flow.h
@@ -177,6 +177,17 @@ static_assert(sizeof(flow_sidx_t) <= sizeof(uint32_t),
#define FLOW_SIDX_NONE ((flow_sidx_t){ .flow = FLOW_MAX })
/**
+ * flow_sidx_valid() - Test if a sidx is valid
+ * @sidx: sidx value
+ *
+ * Return: true if @sidx refers to a valid flow & side
+ */
+static inline bool flow_sidx_valid(flow_sidx_t sidx)
+{
+ return sidx.flow < FLOW_MAX;
+}
+
+/**
* flow_sidx_eq() - Test if two sidx values are equal
* @a, @b: sidx values
*