From: Stefano Brivio <sbrivio@redhat.com>
To: Jon Maloy <jmaloy@redhat.com>
Cc: David Gibson <david@gibson.dropbear.id.au>,
passt-dev@passt.top, lvivier@redhat.com, dgibson@redhat.com
Subject: Re: [PATCH] udp: create and send ICMPv4 to local peer when applicable
Date: Thu, 13 Feb 2025 20:17:02 +0100 [thread overview]
Message-ID: <20250213201702.461b034f@elisabeth> (raw)
In-Reply-To: <f745f11b-85ad-411f-9165-827c4244b088@redhat.com>
On Thu, 13 Feb 2025 14:07:22 -0500
Jon Maloy <jmaloy@redhat.com> wrote:
> On 2025-02-12 16:39, Jon Maloy wrote:
> > On 2025-02-10 19:55, David Gibson wrote:
> >> On Sun, Feb 09, 2025 at 12:00:56PM -0500, Jon Maloy wrote:
> >>> + const struct flowside *toside = flowside_at_sidx(tosidx);
> >>> + struct in_addr oaddr = toside->oaddr.v4mapped.a4;
> >>> + struct in_addr eaddr = toside->eaddr.v4mapped.a4;
> >>> + struct iov_tail data = IOV_TAIL(iov, 1, 0);
> >>> + struct {
> >>> + struct icmphdr icmp4h;
> >>> + struct iphdr ip4h;
> >>> + struct udphdr uh;
> >>> + char data[8];
> >>> + } msg;
> >>
> >> Needs a ((packed)) attribute to ensure we don't get compiler padding.
>
> I get
> udp.c:437:23: warning: taking address of packed member of ‘struct
> <anonymous>’ may result in an unaligned pointer value
> [-Waddress-of-packed-member]
> 437 | tap_push_ip4h(&msg.ip4h, eaddr, oaddr, udplen,
> IPPROTO_UDP);
>
> Also, the sizes of these members are 8+20+8+8, so I cannot see how
> this struct can possibly be packed or how there can be an unaligned
> pointer.
Unaligned pointer because it's on the stack, and it can happily be at a
semi-random point of it. Packed needs to be packed because you could
have 8 + 20 + ("oops we are at 28 let's make it 32") 4 + 8 + 8.
> In short: ((packed)) seems unnecessary, and only causes problems.
...well, but it still should be ((packed)) because it goes on the wire,
and ((aligned)) because you need to access the single fields:
__attribute__((packed, aligned(__alignof__(max_align_t))));
meaning: align it to whatever any kind of machine might possibly need.
--
Stefano
next prev parent reply other threads:[~2025-02-13 19:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-09 17:00 [PATCH] udp: create and send ICMPv4 to local peer when applicable Jon Maloy
2025-02-10 10:27 ` Stefano Brivio
2025-02-11 0:55 ` David Gibson
2025-02-12 21:39 ` Jon Maloy
2025-02-12 23:21 ` David Gibson
2025-02-13 19:07 ` Jon Maloy
2025-02-13 19:17 ` Stefano Brivio [this message]
2025-02-13 19:28 ` Jon Maloy
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=20250213201702.461b034f@elisabeth \
--to=sbrivio@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=dgibson@redhat.com \
--cc=jmaloy@redhat.com \
--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).