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=202510 header.b=xkwB1UNg; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 2738D5A061C for ; Fri, 05 Dec 2025 04:09:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202510; t=1764904181; bh=Km1sMtc04Iox8dbuwwTdTs4YYTQHpXL/gMt9+hrSd/Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=xkwB1UNgkxmsHl1vzM8OXPgE5J1a2Kr6FufNLrTe8u//28mbPRrhMtlFsSi1z4uuT 8fX1ujCQUQ/d+5TBotkpNqqYtC2BYJ+c5p+BJiDBW+jaolCyTX9AoGNFJo/M+PnkWG kWKr4Rq8dSFOoVp4IWPqimqy4ratMzx1R5nnY6ILOw2bl0HRY9UpjcRyyTqR19c4UM 36jA3N/V8174y9nSyHtB/CJOrVP1cE392WoIRYEp9+OEgu73oQ7CmC8/LcJICFljh5 PTWJ60BepDC1gaxJ+CTK4qNupRXDyBApOgC8RiWQnhLL1A7jc6X/1FJsjorJMy4Tlv DZNzZ4KesAJLA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dMxF16gj8z4wH2; Fri, 05 Dec 2025 14:09:41 +1100 (AEDT) Date: Fri, 5 Dec 2025 13:54:39 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] tcp: Enable SO_KEEPALIVE if we see keep-alive segments from container / guest Message-ID: References: <20251204212530.2237432-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="JVi7BH5cR9Mv9lOE" Content-Disposition: inline In-Reply-To: <20251204212530.2237432-1-sbrivio@redhat.com> Message-ID-Hash: QRV5Q5DTZX2ENFWFUTTO4VAE3JBL66XU X-Message-ID-Hash: QRV5Q5DTZX2ENFWFUTTO4VAE3JBL66XU 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, Dominic Kohls 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: --JVi7BH5cR9Mv9lOE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Dec 04, 2025 at 10:25:30PM +0100, Stefano Brivio wrote: > This is an approximation, as enabling SO_KEEPALIVE doesn't mean that > a keep-alive segment will be sent right away, rather that keep-alive > segments will start being sent if the connection is idle. >=20 > On the other hand, we don't have direct control over the host-side > TCP, so this is probably the best approximation we can get. >=20 > By default, namespaces inherit keep-alive parameters from their parent > namespace, so we can assume that, in case of a container, we'll wait > for the same interval it took for the container to start sending us > keep-alives, effectively doubling that interval. >=20 > To keep this simple, set SO_KEEPALIVE whenever we see a keep-alive > segment, instead of tracking its state. Keep-alive segments are > relatively infrequent, so we don't expect any substantial cost from > doing that. Makes sense to me. >=20 > Reported-by: Dominic Kohls > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > tcp.c | 3 +++ > 1 file changed, 3 insertions(+) >=20 > diff --git a/tcp.c b/tcp.c > index 8357c0e..c5486bc 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -1838,6 +1838,9 @@ static int tcp_data_from_tap(const struct ctx *c, s= truct tcp_tap_conn *conn, > tcp_send_flag(c, conn, ACK); > tcp_timer_ctl(c, conn); > =20 > + setsockopt(conn->sock, SOL_SOCKET, SO_KEEPALIVE, > + &((int){ 1 }), sizeof(int)); > + > if (p->count =3D=3D 1) { > tcp_tap_window_update(c, conn, > ntohs(th->window)); > --=20 > 2.43.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 --JVi7BH5cR9Mv9lOE Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmkySW4ACgkQzQJF27ox 2Gcmrg/9HcTJ95bHsxLs9/Tgem/WkijbVi7IL2URvkvkgll4MbLDLmCWgSHeaDvf U4d18ZsT/4HJTR2ReLj3ev90uLg3N8vW4Bmynz5nPYEpp1Q/nulPGr5QN1PTp8Dp BKYc1RqGLFzLAb7w7A6ev0GKnI1fHo8CVj1eelxz8Ok5fcD4YI4v7/RQ6+O9BYrx isT//MU0ui/vNCKzZU451p4hZ1kwWWDzF9WPwxCE2Co4461PDUSjJizERyHd9bKb mIyuLkJYSvptTBxC4KPENbBieNvN3CKhYXU8kGyb8NrtCEEGLPGfsgs5hy0tXLix HXNhJMC2GLEtV8M8PkxByctOmRbJ3usVyyuAS2merzUAptWnRf885weV1yVnAQ2u QWEJnR75taREtSdu0qjn7yXVSaCFKylkIIBhTEJVGDrQXlyAu/wMHq93aqoZMJE1 Le9nlPIqey9UPDjweyuLuojz8gx9jMBh1Cmcyi/0Pt0S3ntbqhmhvWsQYbaEDKnj U6CwmKMt1hxrmaLDIQ0oX9hps45WRwSaMGP8ROzTgU62BHlC5EFMpINjXzwa4FAD 9M2keg3tqbyxbYVqQVMlZvmIXlmGBChjnZnAyHgX1v49ef5mYu1tVDRVGlebPuf1 aQb+ujnW6naEVjZZiE2FD4Y3bFngRue1F6NraN6LFwJN4bLz4k4= =aVj6 -----END PGP SIGNATURE----- --JVi7BH5cR9Mv9lOE--