From 35598995869b0966eb97a16411d6ba5053005431 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 1 May 2024 16:53:52 +1000 Subject: iov: Helper macro to construct iovs covering existing variables or fields 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 Signed-off-by: Stefano Brivio --- udp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'udp.c') diff --git a/udp.c b/udp.c index 2d27eae..7186fae 100644 --- a/udp.c +++ b/udp.c @@ -113,6 +113,7 @@ #include "checksum.h" #include "util.h" +#include "iov.h" #include "ip.h" #include "siphash.h" #include "inany.h" @@ -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); mh->msg_name = &buf->s_in6; mh->msg_namelen = sizeof(buf->s_in6); -- cgit v1.2.3