From: David Gibson <david@gibson.dropbear.id.au>
To: Laurent Vivier <lvivier@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH v8 4/8] udp: Prepare udp.c to be shared with vhost-user
Date: Mon, 14 Oct 2024 15:29:07 +1100 [thread overview]
Message-ID: <ZwyeE2nRaeLaXkJO@zatzit.fritz.box> (raw)
In-Reply-To: <20241010122903.1188992-5-lvivier@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 7659 bytes --]
On Thu, Oct 10, 2024 at 02:28:58PM +0200, Laurent Vivier wrote:
> Export udp_payload_t, udp_update_hdr4(), udp_update_hdr6() and
> udp_sock_errs().
>
> Rename udp_listen_sock_handler() to udp_buf_listen_sock_handler() and
> udp_reply_sock_handler to udp_buf_reply_sock_handler().
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> udp.c | 74 ++++++++++++++++++++++++++++++--------------------
> udp_internal.h | 34 +++++++++++++++++++++++
> 2 files changed, 79 insertions(+), 29 deletions(-)
> create mode 100644 udp_internal.h
>
> diff --git a/udp.c b/udp.c
> index 100610f2472e..8fc5d8099310 100644
> --- a/udp.c
> +++ b/udp.c
> @@ -109,8 +109,7 @@
> #include "pcap.h"
> #include "log.h"
> #include "flow_table.h"
> -
> -#define UDP_MAX_FRAMES 32 /* max # of frames to receive at once */
> +#include "udp_internal.h"
>
> /* "Spliced" sockets indexed by bound port (host order) */
> static int udp_splice_ns [IP_VERSIONS][NUM_PORTS];
> @@ -118,20 +117,8 @@ static int udp_splice_init[IP_VERSIONS][NUM_PORTS];
>
> /* Static buffers */
>
> -/**
> - * struct udp_payload_t - UDP header and data for inbound messages
> - * @uh: UDP header
> - * @data: UDP data
> - */
> -static struct udp_payload_t {
> - struct udphdr uh;
> - char data[USHRT_MAX - sizeof(struct udphdr)];
> -#ifdef __AVX2__
> -} __attribute__ ((packed, aligned(32)))
> -#else
> -} __attribute__ ((packed, aligned(__alignof__(unsigned int))))
> -#endif
> -udp_payload[UDP_MAX_FRAMES];
> +/* UDP header and data for inbound messages */
> +static struct udp_payload_t udp_payload[UDP_MAX_FRAMES];
>
> /* Ethernet header for IPv4 frames */
> static struct ethhdr udp4_eth_hdr;
> @@ -302,9 +289,9 @@ static void udp_splice_send(const struct ctx *c, size_t start, size_t n,
> *
> * Return: size of IPv4 payload (UDP header + data)
> */
> -static size_t udp_update_hdr4(struct iphdr *ip4h, struct udp_payload_t *bp,
> - const struct flowside *toside, size_t dlen,
> - bool no_udp_csum)
> +size_t udp_update_hdr4(struct iphdr *ip4h, struct udp_payload_t *bp,
> + const struct flowside *toside, size_t dlen,
> + bool no_udp_csum)
> {
> const struct in_addr *src = inany_v4(&toside->oaddr);
> const struct in_addr *dst = inany_v4(&toside->eaddr);
> @@ -345,9 +332,9 @@ static size_t udp_update_hdr4(struct iphdr *ip4h, struct udp_payload_t *bp,
> *
> * Return: size of IPv6 payload (UDP header + data)
> */
> -static size_t udp_update_hdr6(struct ipv6hdr *ip6h, struct udp_payload_t *bp,
> - const struct flowside *toside, size_t dlen,
> - bool no_udp_csum)
> +size_t udp_update_hdr6(struct ipv6hdr *ip6h, struct udp_payload_t *bp,
> + const struct flowside *toside, size_t dlen,
> + bool no_udp_csum)
> {
> uint16_t l4len = dlen + sizeof(bp->uh);
>
> @@ -477,7 +464,7 @@ static int udp_sock_recverr(int s)
> *
> * Return: Number of errors handled, or < 0 if we have an unrecoverable error
> */
> -static int udp_sock_errs(const struct ctx *c, int s, uint32_t events)
> +int udp_sock_errs(const struct ctx *c, int s, uint32_t events)
> {
> unsigned n_err = 0;
> socklen_t errlen;
> @@ -554,7 +541,7 @@ static int udp_sock_recv(const struct ctx *c, int s, uint32_t events,
> }
>
> /**
> - * udp_listen_sock_handler() - Handle new data from socket
> + * udp_buf_listen_sock_handler() - Handle new data from socket
> * @c: Execution context
> * @ref: epoll reference
> * @events: epoll events bitmap
> @@ -562,8 +549,9 @@ static int udp_sock_recv(const struct ctx *c, int s, uint32_t events,
> *
> * #syscalls recvmmsg
> */
> -void udp_listen_sock_handler(const struct ctx *c, union epoll_ref ref,
> - uint32_t events, const struct timespec *now)
> +static void udp_buf_listen_sock_handler(const struct ctx *c,
> + union epoll_ref ref, uint32_t events,
> + const struct timespec *now)
> {
> const socklen_t sasize = sizeof(udp_meta[0].s_in);
> int n, i;
> @@ -630,7 +618,21 @@ void udp_listen_sock_handler(const struct ctx *c, union epoll_ref ref,
> }
>
> /**
> - * udp_reply_sock_handler() - Handle new data from flow specific socket
> + * udp_listen_sock_handler() - Handle new data from socket
> + * @c: Execution context
> + * @ref: epoll reference
> + * @events: epoll events bitmap
> + * @now: Current timestamp
> + */
> +void udp_listen_sock_handler(const struct ctx *c,
> + union epoll_ref ref, uint32_t events,
> + const struct timespec *now)
> +{
> + udp_buf_listen_sock_handler(c, ref, events, now);
> +}
> +
> +/**
> + * udp_buf_reply_sock_handler() - Handle new data from flow specific socket
> * @c: Execution context
> * @ref: epoll reference
> * @events: epoll events bitmap
> @@ -638,8 +640,9 @@ void udp_listen_sock_handler(const struct ctx *c, union epoll_ref ref,
> *
> * #syscalls recvmmsg
> */
> -void udp_reply_sock_handler(const struct ctx *c, union epoll_ref ref,
> - uint32_t events, const struct timespec *now)
> +static void udp_buf_reply_sock_handler(const struct ctx *c, union epoll_ref ref,
> + uint32_t events,
> + const struct timespec *now)
> {
> flow_sidx_t tosidx = flow_sidx_opposite(ref.flowside);
> const struct flowside *toside = flowside_at_sidx(tosidx);
> @@ -684,6 +687,19 @@ void udp_reply_sock_handler(const struct ctx *c, union epoll_ref ref,
> }
> }
>
> +/**
> + * udp_reply_sock_handler() - Handle new data from flow specific socket
> + * @c: Execution context
> + * @ref: epoll reference
> + * @events: epoll events bitmap
> + * @now: Current timestamp
> + */
> +void udp_reply_sock_handler(const struct ctx *c, union epoll_ref ref,
> + uint32_t events, const struct timespec *now)
> +{
> + udp_buf_reply_sock_handler(c, ref, events, now);
> +}
> +
> /**
> * udp_tap_handler() - Handle packets from tap
> * @c: Execution context
> diff --git a/udp_internal.h b/udp_internal.h
> new file mode 100644
> index 000000000000..cc80e3055423
> --- /dev/null
> +++ b/udp_internal.h
> @@ -0,0 +1,34 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later
> + * Copyright (c) 2021 Red Hat GmbH
> + * Author: Stefano Brivio <sbrivio@redhat.com>
> + */
> +
> +#ifndef UDP_INTERNAL_H
> +#define UDP_INTERNAL_H
> +
> +#include "tap.h" /* needed by udp_meta_t */
> +
> +#define UDP_MAX_FRAMES 32 /* max # of frames to receive at once */
> +
> +/**
> + * struct udp_payload_t - UDP header and data for inbound messages
> + * @uh: UDP header
> + * @data: UDP data
> + */
> +struct udp_payload_t {
> + struct udphdr uh;
> + char data[USHRT_MAX - sizeof(struct udphdr)];
> +#ifdef __AVX2__
> +} __attribute__ ((packed, aligned(32)));
> +#else
> +} __attribute__ ((packed, aligned(__alignof__(unsigned int))));
> +#endif
> +
> +size_t udp_update_hdr4(struct iphdr *ip4h, struct udp_payload_t *bp,
> + const struct flowside *toside, size_t dlen,
> + bool no_udp_csum);
> +size_t udp_update_hdr6(struct ipv6hdr *ip6h, struct udp_payload_t *bp,
> + const struct flowside *toside, size_t dlen,
> + bool no_udp_csum);
> +int udp_sock_errs(const struct ctx *c, int s, uint32_t events);
> +#endif /* UDP_INTERNAL_H */
--
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 --]
next prev parent reply other threads:[~2024-10-14 5:03 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-10 12:28 [PATCH v8 0/8] Add vhost-user support to passt. (part 3) Laurent Vivier
2024-10-10 12:28 ` [PATCH v8 1/8] packet: replace struct desc by struct iovec Laurent Vivier
2024-10-10 12:28 ` [PATCH v8 2/8] vhost-user: introduce virtio API Laurent Vivier
2024-10-10 12:28 ` [PATCH v8 3/8] vhost-user: introduce vhost-user API Laurent Vivier
2024-10-10 12:28 ` [PATCH v8 4/8] udp: Prepare udp.c to be shared with vhost-user Laurent Vivier
2024-10-14 4:29 ` David Gibson [this message]
2024-10-10 12:28 ` [PATCH v8 5/8] tcp: Export headers functions Laurent Vivier
2024-10-14 4:29 ` David Gibson
2024-10-10 12:29 ` [PATCH v8 6/8] passt: rename tap_sock_init() to tap_backend_init() Laurent Vivier
2024-10-14 4:30 ` David Gibson
2024-10-14 22:38 ` Stefano Brivio
2024-10-10 12:29 ` [PATCH v8 7/8] vhost-user: add vhost-user Laurent Vivier
2024-10-15 3:23 ` David Gibson
2024-10-16 10:07 ` Laurent Vivier
2024-10-16 16:26 ` Stefano Brivio
2024-10-15 19:54 ` Stefano Brivio
2024-10-16 0:41 ` David Gibson
2024-10-17 0:10 ` Stefano Brivio
2024-10-17 11:25 ` Stefano Brivio
2024-10-17 11:54 ` Laurent Vivier
2024-10-17 17:18 ` Laurent Vivier
2024-10-17 17:25 ` Laurent Vivier
2024-10-17 17:33 ` Stefano Brivio
2024-10-17 21:21 ` Stefano Brivio
2024-10-22 12:59 ` Laurent Vivier
2024-10-22 13:19 ` Stefano Brivio
2024-10-22 18:19 ` Stefano Brivio
2024-10-22 18:22 ` Stefano Brivio
2024-10-23 15:27 ` Laurent Vivier
2024-10-23 16:23 ` Stefano Brivio
2024-10-17 0:10 ` Stefano Brivio
2024-10-17 7:28 ` Laurent Vivier
2024-10-17 8:33 ` Stefano Brivio
2024-11-14 10:20 ` Laurent Vivier
2024-11-14 14:23 ` Stefano Brivio
2024-11-14 15:16 ` Laurent Vivier
2024-11-14 15:38 ` Stefano Brivio
2024-11-14 10:23 ` Laurent Vivier
2024-11-14 14:23 ` Stefano Brivio
2024-11-15 8:30 ` Laurent Vivier
2024-11-15 10:08 ` Stefano Brivio
2024-11-14 10:29 ` Laurent Vivier
2024-11-14 14:23 ` Stefano Brivio
2024-11-15 11:13 ` Laurent Vivier
2024-11-15 11:23 ` Stefano Brivio
2024-10-10 12:29 ` [PATCH v8 8/8] test: Add tests for passt in vhost-user mode Laurent Vivier
2024-10-15 3:40 ` David Gibson
2024-10-15 19:54 ` Stefano Brivio
2024-10-16 8:06 ` Laurent Vivier
2024-10-16 9:47 ` 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=ZwyeE2nRaeLaXkJO@zatzit.fritz.box \
--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).