From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top, Laurent Vivier <lvivier@redhat.com>
Subject: Re: [PATCH 6/7] iov: Helper macro to construct iovs covering existing variables or fields
Date: Wed, 1 May 2024 10:09:02 +1000 [thread overview]
Message-ID: <ZjGIHrmZCR38K-rT@zatzit> (raw)
In-Reply-To: <20240430204746.6441f86b@elisabeth>
[-- Attachment #1: Type: text/plain, Size: 2253 bytes --]
On Tue, Apr 30, 2024 at 08:47:46PM +0200, Stefano Brivio wrote:
> On Mon, 29 Apr 2024 17:09:32 +1000
> David Gibson <david@gibson.dropbear.id.au> wrote:
>
> > Laurent's recent changes mean we use IO vectors much more heavily in the
> > TCP code. In many of those cases, and few others around the code base,
> > individual iovs of these vectors are constructed to exactly cover existing
> > variables or fields. We can make initializing such iovs shorter and
> > clearer with a macro for the purpose.
> >
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---
> > iov.h | 3 +++
> > tap.c | 3 +--
> > tcp.c | 24 +++++++++---------------
> > udp.c | 7 +++----
> > 4 files changed, 16 insertions(+), 21 deletions(-)
> >
> > diff --git a/iov.h b/iov.h
> > index 6058af77..5668ca5f 100644
> > --- a/iov.h
> > +++ b/iov.h
> > @@ -18,6 +18,9 @@
> > #include <unistd.h>
> > #include <string.h>
> >
> > +#define IOV_OF_LVALUE(lval) \
> > + (struct iovec){ .iov_base = &(lval), .iov_len = sizeof(lval) }
>
> I'm not sure if IOV_OF_LVALUE() is much clearer than IOV_FROM() or
> IOV_OF(). No strong preference though.
Yeah, I don't love the name but it was the best I came up with. I
wanted to emphasise the fact that it must be given an lvalue - this
has to be a macro, not a function (even inline).
[snip]
> > @@ -315,8 +316,7 @@ static void udp_sock4_iov_init_one(const struct ctx *c, size_t i)
> > .iph = L2_BUF_IP4_INIT(IPPROTO_UDP)
> > };
> >
> > - siov->iov_base = buf->data;
> > - siov->iov_len = sizeof(buf->data);
> > + *siov = IOV_OF_LVALUE(buf->data);
> >
> > mh->msg_name = &buf->s_in;
> > mh->msg_namelen = sizeof(buf->s_in);
> > @@ -343,8 +343,7 @@ static void udp_sock6_iov_init_one(const struct ctx *c, size_t i)
> > .ip6h = L2_BUF_IP6_INIT(IPPROTO_UDP)
> > };
> >
> > - siov->iov_base = buf->data;
> > - siov->iov_len = sizeof(buf->data);
> > + *siov = IOV_OF_LVALUE(buf->data);
>
> Extra whitespace between tabs and =.
Oops, fixed.
--
David Gibson | 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-05-01 0:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-29 7:09 [PATCH 0/7] Small improvements to IOV handling David Gibson
2024-04-29 7:09 ` [PATCH 1/7] checksum: Use proto_ipv6_header_psum() for ICMPv6 as well David Gibson
2024-04-29 7:09 ` [PATCH 2/7] tap: Split tap specific and L2 (ethernet) headers David Gibson
2024-04-30 18:46 ` Stefano Brivio
2024-04-30 23:53 ` David Gibson
2024-04-29 7:09 ` [PATCH 3/7] treewide: Standardise variable names for various packet lengths David Gibson
2024-04-30 18:46 ` Stefano Brivio
2024-05-01 0:05 ` David Gibson
2024-04-29 7:09 ` [PATCH 4/7] tcp: Simplify packet length calculation when preparing headers David Gibson
2024-04-29 7:09 ` [PATCH 5/7] tap, tcp: (Re-)abstract TAP specific header handling David Gibson
2024-04-30 18:47 ` Stefano Brivio
2024-05-01 0:06 ` David Gibson
2024-04-29 7:09 ` [PATCH 6/7] iov: Helper macro to construct iovs covering existing variables or fields David Gibson
2024-04-30 18:47 ` Stefano Brivio
2024-05-01 0:09 ` David Gibson [this message]
2024-04-29 7:09 ` [PATCH 7/7] tcp: Update tap specific header too in tcp_fill_headers[46]() David Gibson
2024-04-30 18:48 ` Stefano Brivio
2024-05-01 0:10 ` David Gibson
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=ZjGIHrmZCR38K-rT@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=lvivier@redhat.com \
--cc=passt-dev@passt.top \
--cc=sbrivio@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).