netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: jengelh@medozas.de
Cc: pchifflier@edenwall.com, netfilter-devel@vger.kernel.org,
	eleblond@inl.fr
Subject: Re: [PATCH 1/2] Add new input plugin UNIXSOCK
Date: Sun, 01 Nov 2009 22:22:49 -0800 (PST)	[thread overview]
Message-ID: <20091101.222249.93035620.davem@davemloft.net> (raw)
In-Reply-To: <alpine.LSU.2.00.0911011432160.26262@obet.zrqbmnf.qr>

From: Jan Engelhardt <jengelh@medozas.de>
Date: Sun, 1 Nov 2009 14:41:21 +0100 (CET)

> +static inline uint32_t deref_get_32(const void *ptr)
> +{
> +       uint32_t ret;
> +       memcpy(&ret, ptr, sizeof(ret));
> +       return ret;
> +}
> 
> Is what I use in one project; however, trying to minimize the
> unalignedness - iptables is a "perfect" example, and netlink
> may do the same tho I am not sure - seems to be the best
> approach in serialized streams.

This will not work all the time.

If GCC can see at the inlining point that 'ptr' is of a type that
should be properly aligned it can inline the memcpy and still emit
the very unaligned load or store that you're trying to avoid.

Using a void pointer doesn't create a sort of "barrier" for typing
visibility like you think it does.

So I would argue against using this construct, because it only gives
you a false sense of security.

  parent reply	other threads:[~2009-11-02  6:22 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-01 10:53 [ULOGD2] UNIXSOCK plugin (v3) Pierre Chifflier
2009-11-01 10:53 ` [PATCH 1/2] Add new input plugin UNIXSOCK Pierre Chifflier
2009-11-01 12:45   ` Jan Engelhardt
2009-11-01 13:07     ` Pierre Chifflier
2009-11-01 13:41       ` Jan Engelhardt
2009-11-01 17:01         ` Pierre Chifflier
2009-11-02  6:22         ` David Miller [this message]
2009-11-03 17:01           ` Jan Engelhardt
2009-11-06 20:09             ` Pierre Chifflier
2009-11-09 13:09               ` Patrick McHardy
2009-11-01 10:53 ` [PATCH 2/2] Add helper script pcap2ulog Pierre Chifflier
  -- strict thread matches above, loose matches on Subject: below --
2010-01-14 19:41 [ULOGD2] UNIXSOCK plugin (v4) Pierre Chifflier
2010-01-14 19:41 ` [PATCH 1/2] Add new input plugin UNIXSOCK Pierre Chifflier
2010-02-26 20:54 [ULOGD2] UNIXSOCK plugin (v5) Pierre Chifflier
2010-02-26 20:54 ` [PATCH 1/2] Add new input plugin UNIXSOCK Pierre Chifflier
2010-02-27 13:55   ` Pablo Neira Ayuso
2010-02-28 14:06     ` Pierre Chifflier
2010-02-28 16:28       ` Pablo Neira Ayuso
2010-02-28 17:29         ` Jan Engelhardt
2010-02-28 18:05         ` Pierre Chifflier
2010-03-01 19:33           ` Pablo Neira Ayuso
2010-03-01 22:16             ` Pierre Chifflier
2010-03-03 17:42             ` Jan Engelhardt
2010-03-03 18:14               ` Jan Engelhardt
2010-03-05 11:15           ` Patrick McHardy
2010-03-05 17:10             ` Pablo Neira Ayuso
2010-03-08 11:13               ` Patrick McHardy
2010-10-20 11:44 [ULOGD2] UNIXSOCK plugin (v5b) Pierre Chifflier
2010-10-20 11:44 ` [PATCH 1/2] Add new input plugin UNIXSOCK Pierre Chifflier

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=20091101.222249.93035620.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=eleblond@inl.fr \
    --cc=jengelh@medozas.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pchifflier@edenwall.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.
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 NNTP newsgroup(s).