From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202512 header.b=U64H3Y8F; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 5AA9B5A0625 for ; Mon, 19 Jan 2026 05:51:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1768798267; bh=ewzDT2i8c1VbqK1RoGZrfay8Zz2zpg9uNPwP0ye2EMg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=U64H3Y8FrdPUBmM3HRaTvYqlLp5bsmIRbGBDN+v6dlmNfBko8wBCDPIBlkk16h2d/ BtKk69ZQdbU3Xfha6w939JsriaW4HXo0aY0z7Xd13CrWFaDY/crRYuEiW9/SMB1rfa 1+7DXbgSTvT7jc+SKNCC86day3/ss+XPHkrDXQsOYAmg2l7jDK1bNsg9B32d/Nhle7 FFZmzqanRs/hNuoxsBZsnlcn7MdFsmzmyraVo4Y6tbF7jFB3YgJw7M5VSbJvXwrRaf J+orIQjumtBMlmWF/QbttyRw+g6cuDoMA2ulFfY40/bs1R8eSDnXA+/iMUx+ozIEZN 6Vo7z3Ug4sGVA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dvdMH0ZdRz4wDm; Mon, 19 Jan 2026 15:51:07 +1100 (AEDT) Date: Mon, 19 Jan 2026 15:40:01 +1100 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH] tcp: Close timer fd when removing it from epoll Message-ID: References: <20260116125557.1426451-1-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Rfkn5IMtYpEl/gw6" Content-Disposition: inline In-Reply-To: <20260116125557.1426451-1-lvivier@redhat.com> Message-ID-Hash: 36VWNFO6EPXNWB7KYRIVZAC7CDO2B3YG X-Message-ID-Hash: 36VWNFO6EPXNWB7KYRIVZAC7CDO2B3YG X-MailFrom: dgibson@gandalf.ozlabs.org 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: passt-dev@passt.top 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: --Rfkn5IMtYpEl/gw6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > 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? >=20 > Signed-off-by: Laurent Vivier > --- > tcp.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) >=20 > 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 =3D flow_epollfd(&conn->f); > =20 > epoll_del(epollfd, conn->sock); > - if (conn->timer !=3D -1) > + if (conn->timer !=3D -1) { > epoll_del(epollfd, conn->timer); > + close(conn->timer); > + conn->timer =3D -1; > + } > } > =20 > return 0; > --=20 > 2.52.0 >=20 --=20 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 --Rfkn5IMtYpEl/gw6 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmlttZAACgkQzQJF27ox 2GcabQ/+IRNa2gpe3tEqefe8pZ1IHkf++GnCzK91VM9GYq5RhBpy5SPr9i4+KP5h th+6brEt4M8j5wrTvRuIBjXyFQfW5+bBA2sZVbYJ1IYIEo7yfVIw4LgxgzkXYNjL wmk9+RoBYBzkONxRGv1+bshFb955v9qtOKrkQWt8zQqLXSqeZ3Fu7QZnTXbOG72d uhHguG8K/evjelsg5ewTTnpo/YJOFlELCV/NLxpvNI+yL1HEV78QUR5ujnA5mJYc jVMF1ensJqDNBfPnk8oXuObgCpXe3st6tjwHZiodhymMxaFMKUtqvwtfGoTz47ID xq8Do6skbhl3qtBEzJuaJ5MQm8Ko/APy7MAHzuEb5uwddzJXVpBX/uULB35aSegU wKYxVgwbw1jquoZ/xStzxMIEfIn7T7cyOACHzZkdki3Hygh1Z1aAcXxv9XksTXo8 tzo53PFOV/ptErv+ATFqj8gHGZGPvsSi6w3ngSnvHj+DrbOCg+leO4JkRGNzP3s1 6oVyBuwPiXfyoUg/cii7rP+AVpc/zDQISOjgZfNHA0mf6Z/shh29lMJG0lkXBCId Y6EH3mdanWG6gZBS/+aO377xOS47eIUlawB2LsCyDCAACUk5m2FHhufs4jIZAPZw QsPzYCd41/SkB+sphEjrDmfbcIDwXdNwDjC449qf2Aev0M1Slho= =Ds5R -----END PGP SIGNATURE----- --Rfkn5IMtYpEl/gw6--