public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Laurent Vivier <lvivier@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH 1/2] udp_flow: Remove udp_meta_t from the parameters of udp_flow_from_sock()
Date: Sat, 3 Aug 2024 17:47:40 +1000	[thread overview]
Message-ID: <Zq3gnHOqvnzHQ-rG@zatzit> (raw)
In-Reply-To: <20240802161036.1404559-2-lvivier@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 3350 bytes --]

On Fri, Aug 02, 2024 at 06:10:35PM +0200, Laurent Vivier wrote:
> 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 <lvivier@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  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));
>  

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2024-08-03  7:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-02 16:10 [PATCH 0/2] udp_flow: move all udp_flow functions to udp_flow.c Laurent Vivier
2024-08-02 16:10 ` [PATCH 1/2] udp_flow: Remove udp_meta_t from the parameters of udp_flow_from_sock() Laurent Vivier
2024-08-03  7:47   ` David Gibson [this message]
2024-08-02 16:10 ` [PATCH 2/2] udp_flow: move all udp_flow functions to udp_flow.c Laurent Vivier
2024-08-03  7:51   ` David Gibson
2024-08-05  7:11     ` Laurent Vivier
2024-08-05 12:17       ` David Gibson
2024-08-05 19:02 ` [PATCH 0/2] " 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=Zq3gnHOqvnzHQ-rG@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=lvivier@redhat.com \
    --cc=passt-dev@passt.top \
    /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).