aboutgitcodebugslistschat
path: root/udp_flow.h
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-07-18 15:26:47 +1000
committerStefano Brivio <sbrivio@redhat.com>2024-07-19 18:33:42 +0200
commite0647ad80c63fcad6a9dc31541881fa02aeaac98 (patch)
tree875373b69da2ee73d7051aae36ab83c24e77bfbd /udp_flow.h
parenta45a7e97982acc7c9d00fddb0192fbbfcd2030d6 (diff)
downloadpasst-e0647ad80c63fcad6a9dc31541881fa02aeaac98.tar
passt-e0647ad80c63fcad6a9dc31541881fa02aeaac98.tar.gz
passt-e0647ad80c63fcad6a9dc31541881fa02aeaac98.tar.bz2
passt-e0647ad80c63fcad6a9dc31541881fa02aeaac98.tar.lz
passt-e0647ad80c63fcad6a9dc31541881fa02aeaac98.tar.xz
passt-e0647ad80c63fcad6a9dc31541881fa02aeaac98.tar.zst
passt-e0647ad80c63fcad6a9dc31541881fa02aeaac98.zip
udp: Handle "spliced" datagrams with per-flow sockets
When forwarding a datagram to a socket, we need to find a socket with a suitable local address to send it. Currently we keep track of such sockets in an array indexed by local port, but this can't properly handle cases where we have multiple local addresses in active use. For "spliced" (socket to socket) cases, improve this by instead opening a socket specifically for the target side of the flow. We connect() as well as bind()ing that socket, so that it will only receive the flow's reply packets, not anything else. We direct datagrams sent via that socket using the addresses from the flow table, effectively replacing bespoke addressing logic with the unified logic in fwd.c When we create the flow, we also take a duplicate of the originating socket, and use that to deliver reply datagrams back to the origin, again using addresses from the flow table entry. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'udp_flow.h')
-rw-r--r--udp_flow.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/udp_flow.h b/udp_flow.h
index 18af9ac..e0736f8 100644
--- a/udp_flow.h
+++ b/udp_flow.h
@@ -11,15 +11,17 @@
* struct udp - Descriptor for a flow of UDP packets
* @f: Generic flow information
* @ts: Activity timestamp
+ * @s: Socket fd (or -1) for each side of the flow
*/
struct udp_flow {
/* Must be first element */
struct flow_common f;
time_t ts;
+ int s[SIDES];
};
-bool udp_flow_timer(const struct ctx *c, const struct udp_flow *uflow,
+bool udp_flow_timer(const struct ctx *c, struct udp_flow *uflow,
const struct timespec *now);
#endif /* UDP_FLOW_H */