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=SbMo6p4K; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id 0F6615A0265 for ; Fri, 13 Feb 2026 08:08:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770966529; 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: in-reply-to:in-reply-to:references:references; bh=n/7WviZDAchhf7VuRq9K2w7ghr1fpxVnsYB+nt49WAM=; b=SbMo6p4KTkVodANveibC3UCPZJ0Q9mgyqODffHv/sqqMDaS1e8acaewTpqYUzHNSD9mfqW qSEXWbZ5XHoAKZCDgy2Gh6AKvb6hDSncbySrJfbzBC5MRYX2QQN9j30BNQIarcCNzMbMRq dxGL435w+LGHkpxB7pArWfIMYst8014= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-453-CxdxnPmePcO5ZB1oo2eTMg-1; Fri, 13 Feb 2026 02:08:47 -0500 X-MC-Unique: CxdxnPmePcO5ZB1oo2eTMg-1 X-Mimecast-MFC-AGG-ID: CxdxnPmePcO5ZB1oo2eTMg_1770966526 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4802bb29400so5639755e9.0 for ; Thu, 12 Feb 2026 23:08:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770966526; x=1771571326; h=date:content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cEvBGfGt3322UWagKr7WtHClMSiZHo3NGaUHIp5RgKY=; b=okMqFigN+CxnWWfUnR6rH70xjHjA1UV9Z14dYtQ+6Trk2BcbVHQuBgNduLFCSY49Yw NjjYoDKwZFcRfx7kxVhkTxg2whVKG+b/FwRmq+5XeQqXYoziepVekXcTvGX4tjNvPGCT PFSlPOsh3yh/omrG3Ps/9Lh2Z+hU02bLEYGnr65bvfzrtC5bi/3juUl1dW1HVu8b0/Tf GX5Wd01j4PgUy13xwPU7gQ/rUa4xwWU4u2qXKuxJBm8q0M1zXgeZ5jZeA2iZsiNg0+D9 QuBItk0qBXjEJZDyodpyhJ0FUie/tEYL4h0naMvsUGpA3Dkdaos0avCGBydueqgaig7z IHdw== X-Gm-Message-State: AOJu0YzPgWI8J3rYFqv2Oi/OpOQSrhmCzVeehjltegjaImfwvT7G8e/8 mTkcuxE51bQzxhn777u7p9rxClXJh2hfik9eUkTuxjGOCWkz3fjxCtz1z3zh2/pNBTweMmlW5BM H8KKUiohQczSHCqf38E5JUvO0JU2OIMMdkiqlFEInURnBJcRd0yUvHA== X-Gm-Gg: AZuq6aJzlk0maBWaYyUur93oQpm8UqOcOIOFzsPoD09LBobtP0M/H4Ew11H9178kOMI cSUrU8Dfgp1L/s9cBGqrPJg7mQavKw83T+aWNXRRhe0DN7R6VwF3pdaOpogxXaAxrqaWq7g6Jbw y7JJ1X5nlwv8ybBkIzhn55IpFq41/ZxpUC6MClwbxV901OmtPLdGVw+HK/N8WWAvdpP48QlPrZZ GUIwhoz+KjD0BJtcF1hM75+8d6dkpkU4orsPggIfHgNfwKw6Xb6wozYEpGHvTjNy1eKFtIELkST VN/tRypgsz9/QF1AYYhpUFO95nPNh3QOeVZ5yDrgcPD1CsPO9syIsi227oAEy0eL+4MYuK8OzqX 5SLDLEkDMAjc6BFyFMviNzD8i+UKlD6GWKMA0u/gpwcbmX1oE5g== X-Received: by 2002:a05:600c:64c5:b0:47d:6856:9bd9 with SMTP id 5b1f17b1804b1-48373a3e73dmr11683805e9.23.1770966526097; Thu, 12 Feb 2026 23:08:46 -0800 (PST) X-Received: by 2002:a05:600c:64c5:b0:47d:6856:9bd9 with SMTP id 5b1f17b1804b1-48373a3e73dmr11683465e9.23.1770966525551; Thu, 12 Feb 2026 23:08:45 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43796a6a6desm3450469f8f.10.2026.02.12.23.08.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 23:08:44 -0800 (PST) From: Stefano Brivio To: Yumei Huang Subject: Re: [PATCH] udp: Split activity timeouts for UDP flows Message-ID: <20260213080843.5186d859@elisabeth> In-Reply-To: References: <20260212080414.61889-1-yuhuang@redhat.com> <20260212225136.2734cfc9@elisabeth> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Fri, 13 Feb 2026 08:08:44 +0100 (CET) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ZPnr9axNKz0l-ler1CvnBfX-b7KkazFQth9n3SlXtPU_1770966526 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: EUXO6DHZUKIXKAMG62XYDSMJV3YD2SAH X-Message-ID-Hash: EUXO6DHZUKIXKAMG62XYDSMJV3YD2SAH X-MailFrom: sbrivio@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: passt-dev@passt.top, david@gibson.dropbear.id.au 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: On Fri, 13 Feb 2026 14:45:24 +0800 Yumei Huang wrote: > On Fri, Feb 13, 2026 at 5:51=E2=80=AFAM Stefano Brivio wrote: >=20 > > Oops, I missed one point at a first review, and also during a quick > > test. > > > > I just tried outbound DNS queries in pasta with single responses, not > > inbound traffic or passt in vhost-user mode. Then I realised > > that: > > > > On Thu, 12 Feb 2026 16:04:14 +0800 > > Yumei Huang wrote: > > =20 > > > [...] > > > @@ -954,6 +964,7 @@ void udp_sock_handler(const struct ctx *c, union = =20 > > epoll_ref ref, =20 > > > > > > flow_trace(uflow, "Received data on reply socket"); > > > uflow->ts =3D now->tv_sec; > > > + udp_flow_activity(uflow, !tosidx.sidei); =20 > > > > ...this only covers three of the four paths we need to act upon: > > > > 1. inbound datagrams received on the reply socket via > > udp_buf_sock_to_tap(), called from here > > > > 2. inbound datagrams received on the reply socket in passt's vhost-user > > mode, that's udp_vu_sock_recv(), also called from here > > > > 3. "spliced" sockets (that's not really the case for UDP, we can't call > > splice(), but a pair of recvmmsg() / sendmmsg()), that is, loopback > > UDP traffic, handled by udp_sock_to_sock(), called from here as well > > > > but not: > > > > 4. outbound, non-spliced datagrams from container/guest: that's > > udp_tap_handler(), in both vhost-user and non-vhost-user cases, or > > udp_flow_from_tap() in udp_flow.c. > > > > I guess we want to take care of this directly from udp_flow_from_tap= (), > > for consistency, because that's also where we update the timestamp > > value: > > > > sidx =3D flow_lookup_sa(c, IPPROTO_UDP, pif, s_in, dst, port); > > if ((uflow =3D udp_at_sidx(sidx))) { > > uflow->ts =3D now->tv_sec; > > > > ^^^ here > > > > return flow_sidx_opposite(sidx); > > } > > > > I haven't really tested this side of it but it should be fairly easy > > with socat and a UDP "server" inside pasta or a guest. >=20 > Somehow, it worked well in my tests with pasta, it looks like the if > condition always returns false. Hmm, weird, it should return false only for the first *inbound* datagram of a UDP flow. > But now when I test with passt, it becomes > an issue and we need to track the activity here as you mentioned. >=20 > Besides, I also noticed we update the timestamp value in > udp_flow_from_sock() as well. I feel we should call udp_flow_activity() > there too, but couldn't come up with a test to prove it. I haven't really checked, but udp_sock_handler() should anyway be called for the datagram triggering udp_flow_from_sock(), so I don't think you need an extra call to udp_flow_activity() there. But you should check that with a pair of debugging prints, I guess. > On top of it, I just found two other issues. > 1. in udp_flow_new(), we should initialize uflow->activity[INISIDE] to 1 > instead of 0. Otherwise, we fail to track the first datagram. Same here, I *thought* that calling udp_flow_activity() from udp_sock_handler() *and* udp_tap_handler() would anyway account for the first datagram, but I didn't check. > 2. I guess we need to add the profs entries (nf_conntrack_udp_timeout > and nf_conntrack_udp_timeout_stream) to apparmor like the tcp ones in > https://passt.top/passt/commit/?id=3D2aa63237109b97a55c85e4c86c72db0d055b= fe7a. > I don't have an environment to test it now. Maybe I can set up a debian v= m > later. Ah, right, good catch. The rules are quite obvious, so you can just add them to the patch, and I'll test them later on Debian anyway. --=20 Stefano