public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH v2] tcp: Update EPOLL_TYPE_TCP_TIMER fd
@ 2025-12-18 14:57 Laurent Vivier
  2025-12-20  5:49 ` David Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: Laurent Vivier @ 2025-12-18 14:57 UTC (permalink / raw)
  To: passt-dev; +Cc: Laurent Vivier

For consistency with other epoll events, set the fd field to the file
descriptor actually added by epoll_ctl() (conn->timer), rather than
conn->sock.

This is a no-op change as ref.fd is not currently used in
tcp_timer_handler().

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 tcp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tcp.c b/tcp.c
index b179e3991236..6e6156098c12 100644
--- a/tcp.c
+++ b/tcp.c
@@ -554,7 +554,7 @@ static int tcp_epoll_ctl(const struct ctx *c, struct tcp_tap_conn *conn)
 
 	if (conn->timer != -1) {
 		union epoll_ref ref_t = { .type = EPOLL_TYPE_TCP_TIMER,
-					  .fd = conn->sock,
+					  .fd = conn->timer,
 					  .flow = FLOW_IDX(conn) };
 		struct epoll_event ev_t = { .data.u64 = ref_t.u64,
 					    .events = EPOLLIN | EPOLLET };
@@ -582,7 +582,6 @@ static void tcp_timer_ctl(const struct ctx *c, struct tcp_tap_conn *conn)
 
 	if (conn->timer == -1) {
 		union epoll_ref ref = { .type = EPOLL_TYPE_TCP_TIMER,
-					.fd = conn->sock,
 					.flow = FLOW_IDX(conn) };
 		struct epoll_event ev = { .data.u64 = ref.u64,
 					  .events = EPOLLIN | EPOLLET };
@@ -598,6 +597,7 @@ static void tcp_timer_ctl(const struct ctx *c, struct tcp_tap_conn *conn)
 			return;
 		}
 		conn->timer = fd;
+		ref.fd = conn->timer;
 
 		if (epoll_ctl(epollfd, EPOLL_CTL_ADD, conn->timer, &ev)) {
 			flow_dbg_perror(conn, "failed to add timer");
-- 
2.51.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] tcp: Update EPOLL_TYPE_TCP_TIMER fd
  2025-12-18 14:57 [PATCH v2] tcp: Update EPOLL_TYPE_TCP_TIMER fd Laurent Vivier
@ 2025-12-20  5:49 ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2025-12-20  5:49 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: passt-dev

[-- Attachment #1: Type: text/plain, Size: 1870 bytes --]

On Thu, Dec 18, 2025 at 03:57:24PM +0100, Laurent Vivier wrote:
> For consistency with other epoll events, set the fd field to the file
> descriptor actually added by epoll_ctl() (conn->timer), rather than
> conn->sock.
> 
> This is a no-op change as ref.fd is not currently used in
> tcp_timer_handler().
> 
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  tcp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tcp.c b/tcp.c
> index b179e3991236..6e6156098c12 100644
> --- a/tcp.c
> +++ b/tcp.c
> @@ -554,7 +554,7 @@ static int tcp_epoll_ctl(const struct ctx *c, struct tcp_tap_conn *conn)
>  
>  	if (conn->timer != -1) {
>  		union epoll_ref ref_t = { .type = EPOLL_TYPE_TCP_TIMER,
> -					  .fd = conn->sock,
> +					  .fd = conn->timer,
>  					  .flow = FLOW_IDX(conn) };
>  		struct epoll_event ev_t = { .data.u64 = ref_t.u64,
>  					    .events = EPOLLIN | EPOLLET };
> @@ -582,7 +582,6 @@ static void tcp_timer_ctl(const struct ctx *c, struct tcp_tap_conn *conn)
>  
>  	if (conn->timer == -1) {
>  		union epoll_ref ref = { .type = EPOLL_TYPE_TCP_TIMER,
> -					.fd = conn->sock,
>  					.flow = FLOW_IDX(conn) };
>  		struct epoll_event ev = { .data.u64 = ref.u64,
>  					  .events = EPOLLIN | EPOLLET };
> @@ -598,6 +597,7 @@ static void tcp_timer_ctl(const struct ctx *c, struct tcp_tap_conn *conn)
>  			return;
>  		}
>  		conn->timer = fd;
> +		ref.fd = conn->timer;
>  
>  		if (epoll_ctl(epollfd, EPOLL_CTL_ADD, conn->timer, &ev)) {
>  			flow_dbg_perror(conn, "failed to add timer");
> -- 
> 2.51.1
> 

-- 
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] 2+ messages in thread

end of thread, other threads:[~2025-12-20  6:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-18 14:57 [PATCH v2] tcp: Update EPOLL_TYPE_TCP_TIMER fd Laurent Vivier
2025-12-20  5:49 ` David Gibson

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).