From: Stefano Brivio <sbrivio@redhat.com>
To: Yumei Huang <yuhuang@redhat.com>
Cc: passt-dev@passt.top, david@gibson.dropbear.id.au
Subject: Re: [PATCH] udp: Split activity timeouts for UDP flows
Date: Thu, 12 Feb 2026 22:51:37 +0100 (CET) [thread overview]
Message-ID: <20260212225136.2734cfc9@elisabeth> (raw)
In-Reply-To: <20260212080414.61889-1-yuhuang@redhat.com>
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 <yuhuang@redhat.com> 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
next prev parent reply other threads:[~2026-02-12 21:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-12 8:04 Yumei Huang
2026-02-12 8:59 ` Stefano Brivio
2026-02-12 21:51 ` Stefano Brivio [this message]
[not found] ` <CANsz47mGXDgJSKpLqFiW_n5bXW13ZiayC_xhBEEGeBJTZwN5Xw@mail.gmail.com>
2026-02-13 7:08 ` Stefano Brivio
[not found] ` <CANsz47m8BPdUK2N-_Ka5GUHP_USnyHgO01Accktf-wxuX5rxDw@mail.gmail.com>
2026-02-13 9:12 ` Stefano Brivio
2026-02-13 9:54 ` Yumei Huang
2026-02-13 10:00 ` Stefano Brivio
2026-02-13 10:04 ` Yumei Huang
2026-02-13 10:17 ` Stefano Brivio
2026-02-14 7:20 ` Yumei Huang
2026-02-14 9:15 ` Stefano Brivio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260212225136.2734cfc9@elisabeth \
--to=sbrivio@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
--cc=yuhuang@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).