* [PATCH] tcp: Close timer fd when removing it from epoll
@ 2026-01-16 12:55 Laurent Vivier
2026-01-19 4:40 ` David Gibson
0 siblings, 1 reply; 3+ messages in thread
From: Laurent Vivier @ 2026-01-16 12:55 UTC (permalink / raw)
To: passt-dev; +Cc: Laurent Vivier
When tcp_epoll_ctl() handles a CLOSED connection, it removes the timer
from epoll but leaves the fd open until tcp_flow_defer() eventually
closes it.
Close the timer fd immediately when removing it from epoll, since
there's no reason to keep an fd around that's no longer monitored.
Set conn->timer to -1 to prevent a double-close in tcp_flow_defer().
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
tcp.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tcp.c b/tcp.c
index 1db861705ddb..62064efcc1ef 100644
--- a/tcp.c
+++ b/tcp.c
@@ -535,8 +535,11 @@ static int tcp_epoll_ctl(struct tcp_tap_conn *conn)
int epollfd = flow_epollfd(&conn->f);
epoll_del(epollfd, conn->sock);
- if (conn->timer != -1)
+ if (conn->timer != -1) {
epoll_del(epollfd, conn->timer);
+ close(conn->timer);
+ conn->timer = -1;
+ }
}
return 0;
--
2.52.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tcp: Close timer fd when removing it from epoll
2026-01-16 12:55 [PATCH] tcp: Close timer fd when removing it from epoll Laurent Vivier
@ 2026-01-19 4:40 ` David Gibson
2026-01-20 8:08 ` Laurent Vivier
0 siblings, 1 reply; 3+ messages in thread
From: David Gibson @ 2026-01-19 4:40 UTC (permalink / raw)
To: Laurent Vivier; +Cc: passt-dev
[-- Attachment #1: Type: text/plain, Size: 1330 bytes --]
On Fri, Jan 16, 2026 at 01:55:57PM +0100, Laurent Vivier wrote:
> When tcp_epoll_ctl() handles a CLOSED connection, it removes the timer
> from epoll but leaves the fd open until tcp_flow_defer() eventually
> closes it.
>
> Close the timer fd immediately when removing it from epoll, since
> there's no reason to keep an fd around that's no longer monitored.
> Set conn->timer to -1 to prevent a double-close in tcp_flow_defer().
This seems safe to me, but is there any actual advantage to it?
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> tcp.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tcp.c b/tcp.c
> index 1db861705ddb..62064efcc1ef 100644
> --- a/tcp.c
> +++ b/tcp.c
> @@ -535,8 +535,11 @@ static int tcp_epoll_ctl(struct tcp_tap_conn *conn)
> int epollfd = flow_epollfd(&conn->f);
>
> epoll_del(epollfd, conn->sock);
> - if (conn->timer != -1)
> + if (conn->timer != -1) {
> epoll_del(epollfd, conn->timer);
> + close(conn->timer);
> + conn->timer = -1;
> + }
> }
>
> return 0;
> --
> 2.52.0
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tcp: Close timer fd when removing it from epoll
2026-01-19 4:40 ` David Gibson
@ 2026-01-20 8:08 ` Laurent Vivier
0 siblings, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2026-01-20 8:08 UTC (permalink / raw)
To: David Gibson; +Cc: passt-dev
On 1/19/26 05:40, David Gibson wrote:
> On Fri, Jan 16, 2026 at 01:55:57PM +0100, Laurent Vivier wrote:
>> When tcp_epoll_ctl() handles a CLOSED connection, it removes the timer
>> from epoll but leaves the fd open until tcp_flow_defer() eventually
>> closes it.
>>
>> Close the timer fd immediately when removing it from epoll, since
>> there's no reason to keep an fd around that's no longer monitored.
>> Set conn->timer to -1 to prevent a double-close in tcp_flow_defer().
>
> This seems safe to me, but is there any actual advantage to it?
>
No, you're right, there's no real advantage. Please drop this patch.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-20 8:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-16 12:55 [PATCH] tcp: Close timer fd when removing it from epoll Laurent Vivier
2026-01-19 4:40 ` David Gibson
2026-01-20 8:08 ` Laurent Vivier
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).