aboutgitcodebugslistschat
path: root/flow_table.h
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-07-18 15:26:46 +1000
committerStefano Brivio <sbrivio@redhat.com>2024-07-19 18:33:39 +0200
commita45a7e97982acc7c9d00fddb0192fbbfcd2030d6 (patch)
tree371c1d0ce44f09463702386c6dc0c75a6b65cf1c /flow_table.h
parent8abd06e9fac93b60cc98d90f7310d94cfc295090 (diff)
downloadpasst-a45a7e97982acc7c9d00fddb0192fbbfcd2030d6.tar
passt-a45a7e97982acc7c9d00fddb0192fbbfcd2030d6.tar.gz
passt-a45a7e97982acc7c9d00fddb0192fbbfcd2030d6.tar.bz2
passt-a45a7e97982acc7c9d00fddb0192fbbfcd2030d6.tar.lz
passt-a45a7e97982acc7c9d00fddb0192fbbfcd2030d6.tar.xz
passt-a45a7e97982acc7c9d00fddb0192fbbfcd2030d6.tar.zst
passt-a45a7e97982acc7c9d00fddb0192fbbfcd2030d6.zip
udp: Create flows for datagrams from originating sockets
This implements the first steps of tracking UDP packets with the flow table rather than its own (buggy) set of port maps. Specifically we create flow table entries for datagrams received from a socket (PIF_HOST or PIF_SPLICE). When splitting datagrams from sockets into batches, we group by the flow as well as splicesrc. This may result in smaller batches, but makes things easier down the line. We can re-optimise this later if necessary. For now we don't do anything else with the flow, not even match reply packets to the same flow. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'flow_table.h')
-rw-r--r--flow_table.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/flow_table.h b/flow_table.h
index 9d912c8..df253be 100644
--- a/flow_table.h
+++ b/flow_table.h
@@ -9,6 +9,7 @@
#include "tcp_conn.h"
#include "icmp_flow.h"
+#include "udp_flow.h"
/**
* struct flow_free_cluster - Information about a cluster of free entries
@@ -35,6 +36,7 @@ union flow {
struct tcp_tap_conn tcp;
struct tcp_splice_conn tcp_splice;
struct icmp_ping_flow ping;
+ struct udp_flow udp;
};
/* Global Flow Table */
@@ -98,6 +100,19 @@ static inline uint8_t pif_at_sidx(flow_sidx_t sidx)
return flow->f.pif[sidx.sidei];
}
+/** flow_sidx_opposite() - Get the other side of the same flow
+ * @sidx: Flow & side index
+ *
+ * Return: sidx for the other side of the same flow as @sidx
+ */
+static inline flow_sidx_t flow_sidx_opposite(flow_sidx_t sidx)
+{
+ if (!flow_sidx_valid(sidx))
+ return FLOW_SIDX_NONE;
+
+ return (flow_sidx_t){.flowi = sidx.flowi, .sidei = !sidx.sidei};
+}
+
/** flow_sidx() - Index of one side of a flow from common structure
* @f: Common flow fields pointer
* @sidei: Which side to refer to (0 or 1)