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=U6yIEM+6; 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 7BDDE5A004E for ; Thu, 12 Feb 2026 22:51:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770933104; 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=66/sXDJknOMaUuQyfp/zTc5QoXZYaqx6CNLxQMFNZf8=; b=U6yIEM+615n9fo+2BsvLWWAqfx1qKDgup3PuxPBr1nvLWHdAQ/uXxIHEFyPKoRpgz6K6+y 9cbO8iwxVMok3m+WIVXZ7zXeM+vPNxB9NsfO2lZUdQffSIb1prxI5X4Tybm56y8Uk8YTcp 0ynbjiJNdORlmm9tbwagmQgdNI81vok= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-595-HKVQWS8bPHeptWjMcMIsSQ-1; Thu, 12 Feb 2026 16:51:41 -0500 X-MC-Unique: HKVQWS8bPHeptWjMcMIsSQ-1 X-Mimecast-MFC-AGG-ID: HKVQWS8bPHeptWjMcMIsSQ_1770933099 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-4376ecafb7fso192107f8f.2 for ; Thu, 12 Feb 2026 13:51:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770933099; x=1771537899; 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=66/sXDJknOMaUuQyfp/zTc5QoXZYaqx6CNLxQMFNZf8=; b=BlCV5jhSLSuuKRoUlkufFinegQZzE0n6JSaRqDZXVxpG3hFFc+R4c97k/UYaspLaIn 3va43vCBK/Dih/gP6WHC2CxIp8qQ20Sip687cRE7gNXcxyik06TBqMZn/vROBtzee47R dNVQ4RmQFWe+73pR4WHTBkgSiMhCL/1I/jsdYfwcba0Q1vhvz/7GVkplQAJP76Ny2Kre zt0747xMFmFnbvkT82ZSbJ7A48KumYGZ6PtuaqxFGvb2q+5Rw4rJ4yWHYJv5ipqKb2Tr IVQtpJrbdpL6DOl7U4O/6RrVZs2ViVQegWSycn2aTLQfLsxwSab2xYHtt9Kld8psMRqu 6aSg== X-Gm-Message-State: AOJu0Yy5m1caYY6foL2WxtRSdbTvBBxDMripLexW6ZO6U1IZ7tlNEqbe QBybNqJevqZlPsVwjCTU6qbmRWGt1rvSnOHf4MJ6vc6vAoTmeGYvWgZ13OG3Cu0ZP2+JRFNhZec 8zQwH2a8NMdDygtaQfUVGjDwiNmBo4CjjDOAzazXqickv6leSb+SDkA== X-Gm-Gg: AZuq6aKtRvgtj8QYBN9aOaoktfO4ulpPUD6E8MBeo5ozbN3n/CzrzmT7E3/lgXxgBRi ODn27BU8Lwmj40H8lpUWk10JY0TXqwofmb3Ul0f9vjeH6mF8hiHaKwbb4OmwJlRHG1U83UA/mu2 cZ27WIVn3aax8b8anbDPJraoVJtQ4TE15hJ0/8D8ZlbiaLuzI8D6H/swmEEELzDLZfm9oPmFfoR +Ax5g/n0sTQKmGR9jIIGHVkOr5f6O8969FaJN3FxOXDeUdvTl5Q9DVTH+ANVJwrCxJBAFDqRK2+ jeG1cB7CCPGnXLlYaWkOuUkmstpyHwYEZcHjWAlfdoHGp6OgbiZwhNS2fHOpTHk69jpVpIB0bmG oF2rnBowDVpdPpM0tq1m50ASQruqj/pza X-Received: by 2002:a05:6000:144a:b0:436:8061:7f91 with SMTP id ffacd0b85a97d-43796ae72bamr592400f8f.41.1770933099336; Thu, 12 Feb 2026 13:51:39 -0800 (PST) X-Received: by 2002:a05:6000:144a:b0:436:8061:7f91 with SMTP id ffacd0b85a97d-43796ae72bamr592372f8f.41.1770933098765; Thu, 12 Feb 2026 13:51:38 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43796a6b563sm773026f8f.12.2026.02.12.13.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 13:51:38 -0800 (PST) From: Stefano Brivio To: Yumei Huang Subject: Re: [PATCH] udp: Split activity timeouts for UDP flows Message-ID: <20260212225136.2734cfc9@elisabeth> In-Reply-To: <20260212080414.61889-1-yuhuang@redhat.com> References: <20260212080414.61889-1-yuhuang@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Thu, 12 Feb 2026 22:51:37 +0100 (CET) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: sQJXgD4RsZfwp--L7G2BA6uB7iLhK76wK3QBOAuJVLM_1770933099 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: EKNKRRXIAGK6PFNITTBAHEBVQWFRAV6C X-Message-ID-Hash: EKNKRRXIAGK6PFNITTBAHEBVQWFRAV6C 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: 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: > [...] > @@ -954,6 +964,7 @@ void udp_sock_handler(const struct ctx *c, union epoll_ref ref, > > flow_trace(uflow, "Received data on reply socket"); > uflow->ts = now->tv_sec; > + udp_flow_activity(uflow, !tosidx.sidei); ...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 = flow_lookup_sa(c, IPPROTO_UDP, pif, s_in, dst, port); if ((uflow = udp_at_sidx(sidx))) { uflow->ts = 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. Another thing I noticed later: > [...] > > diff --git a/udp_flow.h b/udp_flow.h > index 14e0f92..158a0f6 100644 > --- a/udp_flow.h > +++ b/udp_flow.h > @@ -16,6 +16,7 @@ > * @flush1: @s[1] may have datagrams queued for other flows > * @ts: Activity timestamp > * @s: Socket fd (or -1) for each side of the flow > + * @activity: Activity for each side of the flow > */ > struct udp_flow { > /* Must be first element */ > @@ -29,8 +30,20 @@ struct udp_flow { > > time_t ts; > int s[SIDES]; > + uint8_t activity[SIDES]; > }; > > +/** > + * udp_flow_activity() - Track activity of a udp flow > + * @uflow: UDP flow > + * @sidei: Side index of the flow > + */ > +static inline void udp_flow_activity(struct udp_flow *uflow, unsigned int sidei) > +{ > + if (uflow->activity[sidei] < UINT8_MAX) > + uflow->activity[sidei]++; > +} This is an inline function in a header file for no good reason. It could be a normal static function in udp.c. See also: https://www.kernel.org/doc/html/latest/process/coding-style.html#the-inline-disease ...and yes, it's two lines of code, but there's really no reason to decide we want to inline this instead of letting the compiler decide. -- Stefano