From 8f8eb734828dfe8e07903adbe2a772e2afa46872 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Fri, 5 Jul 2024 20:44:00 +1000 Subject: 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 Signed-off-by: Stefano Brivio --- flow_table.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'flow_table.h') diff --git a/flow_table.h b/flow_table.h index 1b16349..226ddbd 100644 --- a/flow_table.h +++ b/flow_table.h @@ -73,7 +73,7 @@ static inline unsigned flow_idx(const struct flow_common *f) */ static inline union flow *flow_at_sidx(flow_sidx_t sidx) { - if (sidx.flow >= FLOW_MAX) + if (!flow_sidx_valid(sidx)) return NULL; return FLOW(sidx.flow); } -- cgit v1.2.3