aboutgitcodebugslistschat
path: root/tcp_splice.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_splice.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_splice.c')
-rw-r--r--tcp_splice.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/tcp_splice.c b/tcp_splice.c
index d8be91b..7dcd1cb 100644
--- a/tcp_splice.c
+++ b/tcp_splice.c
@@ -242,6 +242,19 @@ static void conn_event_do(const struct ctx *c, struct tcp_splice_conn *conn,
conn_event_do(c, conn, event); \
} while (0)
+
+/**
+ * tcp_splice_conn_update() - Update tcp_splice_conn when being moved in the table
+ * @c: Execution context
+ * @new: New location of tcp_splice_conn
+ */
+static void tcp_splice_conn_update(struct ctx *c, struct tcp_splice_conn *new)
+{
+ tcp_splice_epoll_ctl(c, new);
+ if (tcp_splice_epoll_ctl(c, new))
+ conn_flag(c, new, CLOSING);
+}
+
/**
* tcp_table_splice_compact - Compact spliced connection table
* @c: Execution context
@@ -269,9 +282,7 @@ static void tcp_table_splice_compact(struct ctx *c,
debug("TCP (spliced): index %li moved to %li",
CONN_IDX(move), CONN_IDX(hole));
- tcp_splice_epoll_ctl(c, hole);
- if (tcp_splice_epoll_ctl(c, hole))
- conn_flag(c, hole, CLOSING);
+ tcp_splice_conn_update(c, hole);
}
/**