From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=X/vZEwee; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 152EA5A068E for ; Fri, 16 Jan 2026 13:56:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768568162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=S6SyZIBfOmn7XEhHiH2PbwUnzeGUq5JjWrPzAoycz9Y=; b=X/vZEweeK5L5Vxvw3O5l/GhMyJSCnfuS+/G7OsEAm3BAS2dHrfaj+ZIrxO1Agl41nEAaxt u4HhT8b2cKRPQ5O7/4lN2+6INgaKVVEXnK2/IoSMUSZyZAR+P/seK5y5jjTt3K0gog+nSf mdo2cykrflYCFlpjbRolgWhMqGHh3JM= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-318-4OhF3IbROX6x5Cht_hQ3Ow-1; Fri, 16 Jan 2026 07:56:01 -0500 X-MC-Unique: 4OhF3IbROX6x5Cht_hQ3Ow-1 X-Mimecast-MFC-AGG-ID: 4OhF3IbROX6x5Cht_hQ3Ow_1768568160 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9390F19560B5 for ; Fri, 16 Jan 2026 12:56:00 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.44.32.149]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8ADFE19560A7; Fri, 16 Jan 2026 12:55:59 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH] tcp: Close timer fd when removing it from epoll Date: Fri, 16 Jan 2026 13:55:57 +0100 Message-ID: <20260116125557.1426451-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ssrWKPMtJQP91rksKBrTUfU_UqkKJGbCfRK0i3Zgq1A_1768568160 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: VZVPQBHDDYOA57LA5XOSVABAKN3TXZZI X-Message-ID-Hash: VZVPQBHDDYOA57LA5XOSVABAKN3TXZZI X-MailFrom: lvivier@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Laurent Vivier X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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