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=Hec9EPA9; 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 CE6FE5A0274 for ; Mon, 07 Apr 2025 23:49:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744062571; 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=GqjW8+B/M0wxPY29vrB596o64MCHhGr7qYEaoE2S9pg=; b=Hec9EPA96YybZIql3pDuWqZCgpffGefzHp9ZXV9pZnppnctifyoNYOiD8ABws5WhY5gvHs y5fvIAWby60RltiFNYUY+pgpWXlFZcFoPkOBiuiutBET4so/p2Pp9+3KjXjQ+LHmxbdzr2 XV4bVL7xs9XLvOUcatBuYXl6cMgyb/s= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-251-0P2Ue9qCN726CWBIHIMwPA-1; Mon, 07 Apr 2025 17:49:30 -0400 X-MC-Unique: 0P2Ue9qCN726CWBIHIMwPA-1 X-Mimecast-MFC-AGG-ID: 0P2Ue9qCN726CWBIHIMwPA_1744062569 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-39ac9b0cb6aso3160395f8f.2 for ; Mon, 07 Apr 2025 14:49:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744062569; x=1744667369; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=GqjW8+B/M0wxPY29vrB596o64MCHhGr7qYEaoE2S9pg=; b=gtHIPng27bUlRPEz2dwfbxNiStrTX30V6L1LjI28vTmBhnuHdi73Ya5xgrr9BjPaWp u9R0lM81ifu8nf4ZapAIzSFtxLQrxHBTRCP9VA0eje4yDMmuWUDNBbhmP8ExhjSYs0++ tYCrNTAQUHSIZ2efYO/uUGV0qFgjCFN7dc38yQvwUW7BNt8sdBReZ9lLF5IIyUkFNuAB 8fF1q510qHiaEDYkmgUJEGnVykjvrWbzs15pKlB8ZIrFdA+hQPjCqI0i3yPCu/EWVvC8 PSS/XZ5I4naoBwndGOmqQGJw02IKvkEzpFE+BdX9EdQfy9DRrAIAzietqh+KyyL2rcIV vNaQ== X-Gm-Message-State: AOJu0YwKDPs9MvifkaRVExQbAcJ7i99PlYuaSw2DoOvhqJ7ZAH2J2DrP Tgi//Y8Y4eli+vKTGYhKuoYlC2dYBCtDOdC74xD/iQi+CSIzHzc3RuqdBzKMjRRj8UsmzWdNerI uFjQi4x9Vkt7qGriBritM42SUdnG1BI/LosNPbCx1JyHPbRR7XytrWSHg0Q== X-Gm-Gg: ASbGncvGFcJqTwFGo0kX+RE8/FOhkK7F/WRPA+E4OqjzzOwO0GDIEIiQSF01FiYo62q fBZZEW+Fa1w0nSA33TqfNbZtLN+S2wb/j/GIFYFKIhiqx4/Ds2wPBVUEcs7k4w210sX6kksuu1n eDNEG1T1H9/bUboMV2tkN18tKyjFd0GzCS5c4N7xE9q/YDQgCThCOw26SdcJ0vCAfbPiddMuOfW PXl1QvaC+w7aLhG/qbIkmFwrHsrwX/j0m6TcvS8pf8TGhO+mO+qJi+JVj8p4d9TU9vSCyEstia4 Ila7v7dG+hwR3/A80e3tf7DTY2k= X-Received: by 2002:a05:6000:2281:b0:39c:cc7:3c97 with SMTP id ffacd0b85a97d-39d6fd3646cmr6448770f8f.50.1744062569271; Mon, 07 Apr 2025 14:49:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFW0r+qz/sxgckklLmta+BbE3KI4PMN1HPWApEOQuNJI02SyRhaap5bpQTQ/ayLH7uqoT0U+g== X-Received: by 2002:a05:6000:2281:b0:39c:cc7:3c97 with SMTP id ffacd0b85a97d-39d6fd3646cmr6448764f8f.50.1744062568871; Mon, 07 Apr 2025 14:49:28 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43ec1795db7sm148706155e9.25.2025.04.07.14.49.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 14:49:28 -0700 (PDT) Date: Mon, 7 Apr 2025 23:49:27 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 09/12] udp_flow: Take pif and port as explicit parameters to udp_flow_from_sock() Message-ID: <20250407234927.767cca47@elisabeth> In-Reply-To: <20250404101542.3729316-10-david@gibson.dropbear.id.au> References: <20250404101542.3729316-1-david@gibson.dropbear.id.au> <20250404101542.3729316-10-david@gibson.dropbear.id.au> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: CgNz0A-bipkDGp9mmi3Zn-beB7mDRzPRboHrC49d0jQ_1744062569 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: 4HA7H5S3GY25UUFCW5XCZFMXXATAZ777 X-Message-ID-Hash: 4HA7H5S3GY25UUFCW5XCZFMXXATAZ777 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 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, 4 Apr 2025 21:15:39 +1100 David Gibson wrote: > Currently udp_flow_from_sock() is only used when receiving a datagram > from a "listening" socket. It takes the listening socket's epoll > reference to get the interface and port on which the datagram arrived. > > We have some upcoming cases where we want to use this in different > contexts, so make it take the pif and port as direct parameters instead. > > Signed-off-by: David Gibson > --- > udp.c | 4 +++- > udp_flow.c | 15 +++++++-------- > udp_flow.h | 2 +- > 3 files changed, 11 insertions(+), 10 deletions(-) > > diff --git a/udp.c b/udp.c > index f6de2924..dbb33f2a 100644 > --- a/udp.c > +++ b/udp.c > @@ -728,7 +728,9 @@ static void udp_listen_sock_data(const struct ctx *c, union epoll_ref ref, > union sockaddr_inany src; > > while (udp_peek_addr(ref.fd, &src) == 0) { > - flow_sidx_t tosidx = udp_flow_from_sock(c, ref, &src, now); > + flow_sidx_t tosidx = udp_flow_from_sock(c, ref.udp.pif, > + ref.udp.port, &src, > + now); > uint8_t topif = pif_at_sidx(tosidx); > > if (pif_is_socket(topif)) { > diff --git a/udp_flow.c b/udp_flow.c > index d50bddb2..b95c3176 100644 > --- a/udp_flow.c > +++ b/udp_flow.c > @@ -160,8 +160,10 @@ cancel: > } > > /** > - * udp_flow_from_sock() - Find or create UDP flow for "listening" socket > + * udp_flow_from_sock() - Find or create UDP flow for incoming datagram > * @c: Execution context > + * @pif: Interface the datagram is arriving from > + * @port: Our (local) port number to which the datagram is arriving > * @ref: epoll reference of the receiving socket @ref went away. Fixed on merge. > * @s_in: Source socket address, filled in by recvmmsg() > * @now: Timestamp > @@ -171,7 +173,7 @@ cancel: > * Return: sidx for the destination side of the flow for this packet, or > * FLOW_SIDX_NONE if we couldn't find or create a flow. > */ > -flow_sidx_t udp_flow_from_sock(const struct ctx *c, union epoll_ref ref, > +flow_sidx_t udp_flow_from_sock(const struct ctx *c, uint8_t pif, in_port_t port, > const union sockaddr_inany *s_in, > const struct timespec *now) > { > @@ -180,9 +182,7 @@ flow_sidx_t udp_flow_from_sock(const struct ctx *c, union epoll_ref ref, > union flow *flow; > flow_sidx_t sidx; > > - ASSERT(ref.type == EPOLL_TYPE_UDP_LISTEN); > - > - sidx = flow_lookup_sa(c, IPPROTO_UDP, ref.udp.pif, s_in, ref.udp.port); > + sidx = flow_lookup_sa(c, IPPROTO_UDP, pif, s_in, port); > if ((uflow = udp_at_sidx(sidx))) { > uflow->ts = now->tv_sec; > return flow_sidx_opposite(sidx); > @@ -192,12 +192,11 @@ flow_sidx_t udp_flow_from_sock(const struct ctx *c, union epoll_ref ref, > char sastr[SOCKADDR_STRLEN]; > > debug("Couldn't allocate flow for UDP datagram from %s %s", > - pif_name(ref.udp.pif), > - sockaddr_ntop(s_in, sastr, sizeof(sastr))); > + pif_name(pif), sockaddr_ntop(s_in, sastr, sizeof(sastr))); > return FLOW_SIDX_NONE; > } > > - ini = flow_initiate_sa(flow, ref.udp.pif, s_in, ref.udp.port); > + ini = flow_initiate_sa(flow, pif, s_in, port); > > if (!inany_is_unicast(&ini->eaddr) || > ini->eport == 0 || ini->oport == 0) { > diff --git a/udp_flow.h b/udp_flow.h > index 9a1b059c..d4e4c8b9 100644 > --- a/udp_flow.h > +++ b/udp_flow.h > @@ -24,7 +24,7 @@ struct udp_flow { > }; > > struct udp_flow *udp_at_sidx(flow_sidx_t sidx); > -flow_sidx_t udp_flow_from_sock(const struct ctx *c, union epoll_ref ref, > +flow_sidx_t udp_flow_from_sock(const struct ctx *c, uint8_t pif, in_port_t port, > const union sockaddr_inany *s_in, > const struct timespec *now); > flow_sidx_t udp_flow_from_tap(const struct ctx *c, -- Stefano