aboutgitcodebugslistschat
path: root/tcp.c
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 /tcp.c
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 'tcp.c')
-rw-r--r--tcp.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/tcp.c b/tcp.c
index a15b6f5..969f5b1 100644
--- a/tcp.c
+++ b/tcp.c
@@ -1948,6 +1948,8 @@ static void tcp_conn_from_tap(struct ctx *c, sa_family_t af,
if (!(flow = flow_alloc()))
return;
+ flow_initiate(flow, PIF_TAP);
+
if (af == AF_INET) {
if (IN4_IS_ADDR_UNSPECIFIED(saddr) ||
IN4_IS_ADDR_BROADCAST(saddr) ||
@@ -2000,6 +2002,7 @@ static void tcp_conn_from_tap(struct ctx *c, sa_family_t af,
goto cancel;
}
+ flow_target(flow, PIF_HOST);
conn = FLOW_SET_TYPE(flow, FLOW_TCP, tcp);
conn->tapside = INISIDE;
conn->sock = s;
@@ -2713,7 +2716,10 @@ static void tcp_tap_conn_from_sock(struct ctx *c, in_port_t dstport,
const union sockaddr_inany *sa,
const struct timespec *now)
{
- struct tcp_tap_conn *conn = FLOW_SET_TYPE(flow, FLOW_TCP, tcp);
+ struct tcp_tap_conn *conn;
+
+ flow_target(flow, PIF_TAP);
+ conn = FLOW_SET_TYPE(flow, FLOW_TCP, tcp);
conn->tapside = TGTSIDE;
conn->sock = s;
@@ -2763,6 +2769,8 @@ void tcp_listen_handler(struct ctx *c, union epoll_ref ref,
if (s < 0)
goto cancel;
+ flow_initiate(flow, ref.tcp_listen.pif);
+
if (sa.sa_family == AF_INET) {
const struct in_addr *addr = &sa.sa4.sin_addr;
in_port_t port = sa.sa4.sin_port;