aboutgitcodebugslistschat
path: root/flow.h
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-05-21 15:57:07 +1000
committerStefano Brivio <sbrivio@redhat.com>2024-05-22 23:21:03 +0200
commit8a2accb847926d0354f3a45d8c3e00933c9d7e00 (patch)
tree712f1c59549d8a540425160433b8c5c2ff9dfc94 /flow.h
parent43571852e62dae90fd0404b8a7c73e727930718e (diff)
downloadpasst-8a2accb847926d0354f3a45d8c3e00933c9d7e00.tar
passt-8a2accb847926d0354f3a45d8c3e00933c9d7e00.tar.gz
passt-8a2accb847926d0354f3a45d8c3e00933c9d7e00.tar.bz2
passt-8a2accb847926d0354f3a45d8c3e00933c9d7e00.tar.lz
passt-8a2accb847926d0354f3a45d8c3e00933c9d7e00.tar.xz
passt-8a2accb847926d0354f3a45d8c3e00933c9d7e00.tar.zst
passt-8a2accb847926d0354f3a45d8c3e00933c9d7e00.zip
flow: Record the pifs for each side of each flow
Currently we have no generic information flows apart from the type and state, everything else is specific to the flow type. Start introducing generic flow information by recording the pifs which the flow connects. To keep track of what information is valid, introduce new flow states: INI for when the initiating side information is complete, and TGT for when both sides information is complete, but we haven't chosen the flow type yet. For now, these states don't do an awful lot, but they'll become more important as we add more generic information. 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.h44
1 files changed, 38 insertions, 6 deletions
diff --git a/flow.h b/flow.h
index 9530938..29ef9f1 100644
--- a/flow.h
+++ b/flow.h
@@ -25,14 +25,42 @@
* NEW - Freshly allocated, uninitialised entry
* Operations:
* - flow_alloc_cancel() returns the entry to FREE
+ * - flow_initiate() sets the entry's INISIDE details and moves to
+ * INI
* - FLOW_SET_TYPE() sets the entry's type and moves to TYPED
* Caveats:
* - No fields other than state may be accessed
- * - At most one entry may be NEW or TYPED at a time, so it's unsafe
- * to use flow_alloc() again until this entry moves to ACTIVE or
- * FREE
+ * - At most one entry may be NEW, INI, TGT or TYPED at a time, so
+ * it's unsafe to use flow_alloc() again until this entry moves to
+ * ACTIVE or FREE
* - You may not return to the main epoll loop while any flow is NEW
*
+ * INI - An entry with INISIDE common information completed
+ * Operations:
+ * - Common fields related to INISIDE may be read
+ * - flow_alloc_cancel() returns the entry to FREE
+ * - flow_target() sets the entry's TGTSIDE details and moves to TGT
+ * Caveats:
+ * - Other common fields may not be read
+ * - Type specific fields may not be read or written
+ * - At most one entry may be NEW, INI, TGT or TYPED at a time, so
+ * it's unsafe to use flow_alloc() again until this entry moves to
+ * ACTIVE or FREE
+ * - You may not return to the main epoll loop while any flow is INI
+ *
+ * TGT - An entry with only INISIDE and TGTSIDE common information completed
+ * Operations:
+ * - Common fields related to INISIDE & TGTSIDE may be read
+ * - flow_alloc_cancel() returns the entry to FREE
+ * - FLOW_SET_TYPE() sets the entry's type and moves to TYPED
+ * Caveats:
+ * - Other common fields may not be read
+ * - Type specific fields may not be read or written
+ * - At most one entry may be NEW, INI, TGT or TYPED at a time, so
+ * it's unsafe to use flow_alloc() again until this entry moves to
+ * ACTIVE or FREE
+ * - You may not return to the main epoll loop while any flow is TGT
+ *
* TYPED - Generic info initialised, type specific initialisation underway
* Operations:
* - All common fields may be read
@@ -40,9 +68,9 @@
* - flow_alloc_cancel() returns the entry to FREE
* - FLOW_ACTIVATE() moves the entry to ACTIVE
* Caveats:
- * - At most one entry may be NEW or TYPED at a time, so it's unsafe
- * to use flow_alloc() again until this entry moves to ACTIVE or
- * FREE
+ * - At most one entry may be NEW, INI, TGT or TYPED at a time, so
+ * it's unsafe to use flow_alloc() again until this entry moves to
+ * ACTIVE or FREE
* - You may not return to the main epoll loop while any flow is
* TYPED
*
@@ -58,6 +86,8 @@
enum flow_state {
FLOW_STATE_FREE,
FLOW_STATE_NEW,
+ FLOW_STATE_INI,
+ FLOW_STATE_TGT,
FLOW_STATE_TYPED,
FLOW_STATE_ACTIVE,
@@ -109,6 +139,7 @@ extern const uint8_t flow_proto[];
* struct flow_common - Common fields for packet flows
* @state: State of the flow table entry
* @type: Type of packet flow
+ * @pif[]: Interface for each side of the flow
*/
struct flow_common {
#ifdef __GNUC__
@@ -122,6 +153,7 @@ struct flow_common {
static_assert(sizeof(uint8_t) * 8 >= FLOW_TYPE_BITS,
"Not enough bits for type field");
#endif
+ uint8_t pif[SIDES];
};
#define FLOW_INDEX_BITS 17 /* 128k - 1 */