From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 9BD975A031A for ; Fri, 02 Aug 2024 18:10:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722615044; 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=8g6jMMFO4PakHtScLS8B9f5qgKAdE37tP82rWX+WCKE=; b=JOc9UQNeXT81xgWAB0AUgL7MG2OQemNkSRkuibb3MHJVsnBnZM/ywIexyGee+GNkbxkIzp H5wp01u9Cdq5HdeIaMP15CcWM3kLuDfA/fJdVGg4/r5JcFlE0bupVM6dhNudJqJ/Lj2YO+ 6HqYoM2qsAW50Mow/leppjepC0vX5AY= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-48-l25YOjb1Osu4HwZplv4UOQ-1; Fri, 02 Aug 2024 12:10:41 -0400 X-MC-Unique: l25YOjb1Osu4HwZplv4UOQ-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 587B41955D50 for ; Fri, 2 Aug 2024 16:10:40 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.39.192.179]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 465FF300018D; Fri, 2 Aug 2024 16:10:39 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH 1/2] udp_flow: Remove udp_meta_t from the parameters of udp_flow_from_sock() Date: Fri, 2 Aug 2024 18:10:35 +0200 Message-ID: <20240802161036.1404559-2-lvivier@redhat.com> In-Reply-To: <20240802161036.1404559-1-lvivier@redhat.com> References: <20240802161036.1404559-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: CBGWDHNIF3HYWGKPP7LA75WV4JY7YRFL X-Message-ID-Hash: CBGWDHNIF3HYWGKPP7LA75WV4JY7YRFL X-MailFrom: lvivier@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: Laurent Vivier 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: To be used with the vhost-user version of udp.c, we need to export the udp_flow functions. To avoid to export udp_meta_t too that is specific to the socket version of udp.c, don't pass udp_meta_t to it, but the only needed field, s_in. Signed-off-by: Laurent Vivier --- udp.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/udp.c b/udp.c index a92014806a73..f27a00bf5610 100644 --- a/udp.c +++ b/udp.c @@ -432,7 +432,7 @@ cancel: * udp_flow_from_sock() - Find or create UDP flow for "listening" socket * @c: Execution context * @ref: epoll reference of the receiving socket - * @meta: Metadata buffer for the datagram + * @s_in: Source socket address, filled in by recvmmsg() * @now: Timestamp * * #syscalls fcntl @@ -441,7 +441,7 @@ cancel: * FLOW_SIDX_NONE if we couldn't find or create a flow. */ static flow_sidx_t udp_flow_from_sock(const struct ctx *c, union epoll_ref ref, - struct udp_meta_t *meta, + const union sockaddr_inany *s_in, const struct timespec *now) { struct udp_flow *uflow; @@ -450,7 +450,7 @@ static flow_sidx_t udp_flow_from_sock(const struct ctx *c, union epoll_ref ref, ASSERT(ref.type == EPOLL_TYPE_UDP_LISTEN); - sidx = flow_lookup_sa(c, IPPROTO_UDP, ref.udp.pif, &meta->s_in, ref.udp.port); + sidx = flow_lookup_sa(c, IPPROTO_UDP, ref.udp.pif, s_in, ref.udp.port); if ((uflow = udp_at_sidx(sidx))) { uflow->ts = now->tv_sec; return flow_sidx_opposite(sidx); @@ -461,11 +461,11 @@ static flow_sidx_t udp_flow_from_sock(const struct ctx *c, union epoll_ref ref, debug("Couldn't allocate flow for UDP datagram from %s %s", pif_name(ref.udp.pif), - sockaddr_ntop(&meta->s_in, sastr, sizeof(sastr))); + sockaddr_ntop(s_in, sastr, sizeof(sastr))); return FLOW_SIDX_NONE; } - flow_initiate_sa(flow, ref.udp.pif, &meta->s_in, ref.udp.port); + flow_initiate_sa(flow, ref.udp.pif, s_in, ref.udp.port); return udp_flow_new(c, flow, ref.fd, now); } @@ -712,7 +712,7 @@ void udp_listen_sock_handler(const struct ctx *c, union epoll_ref ref, * the array, or recalculating tosidx for a single entry, we have to * populate it one entry *ahead* of the loop counter. */ - udp_meta[0].tosidx = udp_flow_from_sock(c, ref, &udp_meta[0], now); + udp_meta[0].tosidx = udp_flow_from_sock(c, ref, &udp_meta[0].s_in, now); for (i = 0; i < n; ) { flow_sidx_t batchsidx = udp_meta[i].tosidx; uint8_t batchpif = pif_at_sidx(batchsidx); @@ -730,7 +730,7 @@ void udp_listen_sock_handler(const struct ctx *c, union epoll_ref ref, break; udp_meta[i].tosidx = udp_flow_from_sock(c, ref, - &udp_meta[i], + &udp_meta[i].s_in, now); } while (flow_sidx_eq(udp_meta[i].tosidx, batchsidx)); -- 2.45.2