aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorLaurent Vivier <lvivier@redhat.com>2025-10-21 23:01:10 +0200
committerStefano Brivio <sbrivio@redhat.com>2025-10-30 15:32:03 +0100
commit8bfa47a5cf0576dd18e8716e1c1e142954a0b72d (patch)
tree9a7e32e6962a0047f24b72ab5f4304022e6824dc
parent3a9dbe05a10fa110e8559ec89e3fdf4019e3845e (diff)
downloadpasst-8bfa47a5cf0576dd18e8716e1c1e142954a0b72d.tar
passt-8bfa47a5cf0576dd18e8716e1c1e142954a0b72d.tar.gz
passt-8bfa47a5cf0576dd18e8716e1c1e142954a0b72d.tar.bz2
passt-8bfa47a5cf0576dd18e8716e1c1e142954a0b72d.tar.lz
passt-8bfa47a5cf0576dd18e8716e1c1e142954a0b72d.tar.xz
passt-8bfa47a5cf0576dd18e8716e1c1e142954a0b72d.tar.zst
passt-8bfa47a5cf0576dd18e8716e1c1e142954a0b72d.zip
util: Simplify epoll_del() interface to take epollfd directly
Change epoll_del() to accept the epoll file descriptor directly instead of the full context structure. This simplifies the interface and aligns with the threading refactoring by reducing dependency on the context structure for basic epoll operations as we will manage an epollfd per thread. Signed-off-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--icmp.c2
-rw-r--r--tap.c2
-rw-r--r--tcp.c6
-rw-r--r--tcp_splice.c4
-rw-r--r--udp_flow.c4
-rw-r--r--util.c6
-rw-r--r--util.h2
-rw-r--r--vhost_user.c6
8 files changed, 16 insertions, 16 deletions
diff --git a/icmp.c b/icmp.c
index 158b98f..d2fd7c8 100644
--- a/icmp.c
+++ b/icmp.c
@@ -155,7 +155,7 @@ unexpected:
static void icmp_ping_close(const struct ctx *c,
const struct icmp_ping_flow *pingf)
{
- epoll_del(c, pingf->sock);
+ epoll_del(c->epollfd, pingf->sock);
close(pingf->sock);
flow_hash_remove(c, FLOW_SIDX(pingf, INISIDE));
}
diff --git a/tap.c b/tap.c
index 7d79f95..114dade 100644
--- a/tap.c
+++ b/tap.c
@@ -1146,7 +1146,7 @@ void tap_sock_reset(struct ctx *c)
}
/* Close the connected socket, wait for a new connection */
- epoll_del(c, c->fd_tap);
+ epoll_del(c->epollfd, c->fd_tap);
close(c->fd_tap);
c->fd_tap = -1;
if (c->mode == MODE_VU)
diff --git a/tcp.c b/tcp.c
index 27c38b5..398785c 100644
--- a/tcp.c
+++ b/tcp.c
@@ -511,9 +511,9 @@ static int tcp_epoll_ctl(const struct ctx *c, struct tcp_tap_conn *conn)
if (conn->events == CLOSED) {
if (conn->in_epoll)
- epoll_del(c, conn->sock);
+ epoll_del(c->epollfd, conn->sock);
if (conn->timer != -1)
- epoll_del(c, conn->timer);
+ epoll_del(c->epollfd, conn->timer);
return 0;
}
@@ -3488,7 +3488,7 @@ int tcp_flow_migrate_source_ext(const struct ctx *c,
if (c->migrate_no_linger)
close(s);
else
- epoll_del(c, s);
+ epoll_del(c->epollfd, s);
/* Adjustments unrelated to FIN segments: sequence numbers we dumped are
* based on the end of the queues.
diff --git a/tcp_splice.c b/tcp_splice.c
index 26cb630..666ee62 100644
--- a/tcp_splice.c
+++ b/tcp_splice.c
@@ -204,8 +204,8 @@ static void conn_flag_do(const struct ctx *c, struct tcp_splice_conn *conn,
}
if (flag == CLOSING) {
- epoll_del(c, conn->s[0]);
- epoll_del(c, conn->s[1]);
+ epoll_del(c->epollfd, conn->s[0]);
+ epoll_del(c->epollfd, conn->s[1]);
}
}
diff --git a/udp_flow.c b/udp_flow.c
index cef3fb5..84973f8 100644
--- a/udp_flow.c
+++ b/udp_flow.c
@@ -51,7 +51,7 @@ void udp_flow_close(const struct ctx *c, struct udp_flow *uflow)
flow_foreach_sidei(sidei) {
flow_hash_remove(c, FLOW_SIDX(uflow, sidei));
if (uflow->s[sidei] >= 0) {
- epoll_del(c, uflow->s[sidei]);
+ epoll_del(c->epollfd, uflow->s[sidei]);
close(uflow->s[sidei]);
uflow->s[sidei] = -1;
}
@@ -88,7 +88,7 @@ static int udp_flow_sock(const struct ctx *c,
if (flowside_connect(c, s, pif, side) < 0) {
int rc = -errno;
- epoll_del(c, s);
+ epoll_del(c->epollfd, s);
close(s);
flow_dbg_perror(uflow, "Couldn't connect flow socket");
diff --git a/util.c b/util.c
index c492f90..1067486 100644
--- a/util.c
+++ b/util.c
@@ -996,12 +996,12 @@ void raw_random(void *buf, size_t buflen)
/**
* epoll_del() - Remove a file descriptor from our passt epoll
- * @c: Execution context
+ * @epollfd: epoll file descriptor to remove from
* @fd: File descriptor to remove
*/
-void epoll_del(const struct ctx *c, int fd)
+void epoll_del(int epollfd, int fd)
{
- epoll_ctl(c->epollfd, EPOLL_CTL_DEL, fd, NULL);
+ epoll_ctl(epollfd, EPOLL_CTL_DEL, fd, NULL);
}
diff --git a/util.h b/util.h
index 6fc8f5d..743f0b0 100644
--- a/util.h
+++ b/util.h
@@ -302,7 +302,7 @@ static inline bool mod_between(unsigned x, unsigned i, unsigned j, unsigned m)
#define FPRINTF(f, ...) (void)fprintf(f, __VA_ARGS__)
void raw_random(void *buf, size_t buflen);
-void epoll_del(const struct ctx *c, int fd);
+void epoll_del(int epollfd, int fd);
/*
* Starting from glibc 2.40.9000 and commit 25a5eb4010df ("string: strerror,
diff --git a/vhost_user.c b/vhost_user.c
index 223332d..f8324c5 100644
--- a/vhost_user.c
+++ b/vhost_user.c
@@ -733,7 +733,7 @@ static bool vu_get_vring_base_exec(struct vu_dev *vdev,
vdev->vq[idx].call_fd = -1;
}
if (vdev->vq[idx].kick_fd != -1) {
- epoll_del(vdev->context, vdev->vq[idx].kick_fd);
+ epoll_del(vdev->context->epollfd, vdev->vq[idx].kick_fd);
close(vdev->vq[idx].kick_fd);
vdev->vq[idx].kick_fd = -1;
}
@@ -801,7 +801,7 @@ static bool vu_set_vring_kick_exec(struct vu_dev *vdev,
vu_check_queue_msg_file(vmsg);
if (vdev->vq[idx].kick_fd != -1) {
- epoll_del(vdev->context, vdev->vq[idx].kick_fd);
+ epoll_del(vdev->context->epollfd, vdev->vq[idx].kick_fd);
close(vdev->vq[idx].kick_fd);
vdev->vq[idx].kick_fd = -1;
}
@@ -1093,7 +1093,7 @@ void vu_cleanup(struct vu_dev *vdev)
vq->err_fd = -1;
}
if (vq->kick_fd != -1) {
- epoll_del(vdev->context, vq->kick_fd);
+ epoll_del(vdev->context->epollfd, vq->kick_fd);
close(vq->kick_fd);
vq->kick_fd = -1;
}