aboutgitcodebugslistschat
path: root/tcp.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2022-11-17 16:58:45 +1100
committerStefano Brivio <sbrivio@redhat.com>2022-11-25 01:34:48 +0100
commit181ce83d9bc52487f99401afe39a73499bd128fe (patch)
treef0ec533fedc615dbd9487813c33e2931256bdbaa /tcp.c
parentff27fd63cdd95490e2f9f4e67dbf70324ed6ed9b (diff)
downloadpasst-181ce83d9bc52487f99401afe39a73499bd128fe.tar
passt-181ce83d9bc52487f99401afe39a73499bd128fe.tar.gz
passt-181ce83d9bc52487f99401afe39a73499bd128fe.tar.bz2
passt-181ce83d9bc52487f99401afe39a73499bd128fe.tar.lz
passt-181ce83d9bc52487f99401afe39a73499bd128fe.tar.xz
passt-181ce83d9bc52487f99401afe39a73499bd128fe.tar.zst
passt-181ce83d9bc52487f99401afe39a73499bd128fe.zip
tcp: Improved helpers to update connections after moving
When we compact the connection tables (both spliced and non-spliced) we need to move entries from one slot to another. That requires some updates in the entries themselves. Add helpers to make all the necessary updates for the spliced and non-spliced cases. This will simplify later cleanups. 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.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/tcp.c b/tcp.c
index 05eed85..90eb840 100644
--- a/tcp.c
+++ b/tcp.c
@@ -1291,11 +1291,13 @@ static void tcp_hash_remove(const struct tcp_tap_conn *conn)
}
/**
- * tcp_hash_update() - Update pointer for given connection
- * @old: Old connection pointer
- * @new: New connection pointer
+ * tcp_tap_conn_update() - Update tcp_tap_conn when being moved in the table
+ * @c: Execution context
+ * @old: Old location of tcp_tap_conn
+ * @new: New location of tcp_tap_conn
*/
-static void tcp_hash_update(struct tcp_tap_conn *old, struct tcp_tap_conn *new)
+static void tcp_tap_conn_update(struct ctx *c, struct tcp_tap_conn *old,
+ struct tcp_tap_conn *new)
{
struct tcp_tap_conn *entry, *prev = NULL;
int b = old->hash_bucket;
@@ -1314,6 +1316,8 @@ static void tcp_hash_update(struct tcp_tap_conn *old, struct tcp_tap_conn *new)
debug("TCP: hash table update: old index %li, new index %li, sock %i, "
"bucket: %i, old: %p, new: %p",
CONN_IDX(old), CONN_IDX(new), new->sock, b, old, new);
+
+ tcp_epoll_ctl(c, new);
}
/**
@@ -1362,9 +1366,7 @@ static void tcp_table_compact(struct ctx *c, struct tcp_tap_conn *hole)
memcpy(hole, from, sizeof(*hole));
to = hole;
- tcp_hash_update(from, to);
-
- tcp_epoll_ctl(c, to);
+ tcp_tap_conn_update(c, from, to);
debug("TCP: hash table compaction: old index %li, new index %li, "
"sock %i, from: %p, to: %p",