aboutgitcodebugslistschat
path: root/tcp.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-11-19 09:29:54 +0100
committerStefano Brivio <sbrivio@redhat.com>2022-11-25 01:37:36 +0100
commitb06014a6b2f35bb3ca58e94a6ef84e3644e49fb0 (patch)
tree658deedb11e2f17417339ec16ad4f577d2338286 /tcp.c
parent8e914238b6def7abc61d97482dd618cfc3a061bd (diff)
downloadpasst-b06014a6b2f35bb3ca58e94a6ef84e3644e49fb0.tar
passt-b06014a6b2f35bb3ca58e94a6ef84e3644e49fb0.tar.gz
passt-b06014a6b2f35bb3ca58e94a6ef84e3644e49fb0.tar.bz2
passt-b06014a6b2f35bb3ca58e94a6ef84e3644e49fb0.tar.lz
passt-b06014a6b2f35bb3ca58e94a6ef84e3644e49fb0.tar.xz
passt-b06014a6b2f35bb3ca58e94a6ef84e3644e49fb0.tar.zst
passt-b06014a6b2f35bb3ca58e94a6ef84e3644e49fb0.zip
tcp: Pass union tcp_conn pointer to destroy and splice timer functions
The pointers are actually the same, but we later pass the container union to tcp_table_compact(), which might zero the size of the whole union, and this confuses Coverity Scan. Given that we have pointers to the container union to start with, just pass those instead, all the way down to tcp_table_compact(). Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'tcp.c')
-rw-r--r--tcp.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/tcp.c b/tcp.c
index 8044617..cfdae06 100644
--- a/tcp.c
+++ b/tcp.c
@@ -1372,16 +1372,18 @@ void tcp_table_compact(struct ctx *c, union tcp_conn *hole)
/**
* tcp_conn_destroy() - Close sockets, trigger hash table removal and compaction
* @c: Execution context
- * @conn: Connection pointer
+ * @conn_union: Connection pointer (container union)
*/
-static void tcp_conn_destroy(struct ctx *c, struct tcp_tap_conn *conn)
+static void tcp_conn_destroy(struct ctx *c, union tcp_conn *conn_union)
{
+ struct tcp_tap_conn *conn = &conn_union->tap;
+
close(conn->sock);
if (conn->timer != -1)
close(conn->timer);
tcp_hash_remove(c, conn);
- tcp_table_compact(c, (union tcp_conn *)conn);
+ tcp_table_compact(c, conn_union);
}
static void tcp_rst_do(struct ctx *c, struct tcp_tap_conn *conn);
@@ -1531,13 +1533,12 @@ void tcp_defer_handler(struct ctx *c)
for (conn = tc + c->tcp.conn_count - 1; conn >= tc; conn--) {
if (conn->c.spliced) {
if (conn->splice.flags & CLOSING)
- tcp_splice_destroy(c, &conn->splice);
+ tcp_splice_destroy(c, conn);
} else {
if (conn->tap.events == CLOSED)
- tcp_conn_destroy(c, &conn->tap);
+ tcp_conn_destroy(c, conn);
}
}
-
}
/**
@@ -3391,10 +3392,10 @@ void tcp_timer(struct ctx *c, const struct timespec *ts)
for (conn = tc + c->tcp.conn_count - 1; conn >= tc; conn--) {
if (conn->c.spliced) {
- tcp_splice_timer(c, &conn->splice);
+ tcp_splice_timer(c, conn);
} else {
if (conn->tap.events == CLOSED)
- tcp_conn_destroy(c, &conn->tap);
+ tcp_conn_destroy(c, conn);
}
}