From: Thomas Graf <tgraf@suug.ch>
To: David Laight <David.Laight@ACULAB.COM>
Cc: 'Alexei Starovoitov' <alexei.starovoitov@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Jesse Gross <jesse@nicira.com>,
Stephen Hemminger <stephen@networkplumber.org>,
Pravin Shelar <pshelar@nicira.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"dev@openvswitch.org" <dev@openvswitch.org>
Subject: Re: [PATCH 2/6] vxlan: Group Policy extension
Date: Wed, 7 Jan 2015 11:01:18 +0000 [thread overview]
Message-ID: <20150107110118.GO21820@casper.infradead.org> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D1CAC2740@AcuExch.aculab.com>
On 01/07/15 at 10:03am, David Laight wrote:
> From: Alexei Starovoitov
> > On Tue, Jan 6, 2015 at 6:05 PM, Thomas Graf <tgraf@suug.ch> wrote:
> > > +struct vxlan_gbp {
> > > +#ifdef __LITTLE_ENDIAN_BITFIELD
> > > + __u8 reserved_flags1:3,
> > ...
> > > + __be16 policy_id;
> > > +} __packed;
> >
> > are you sure that compiler will be smart enough
> > to do single short load when you pack
> > u8 + struct vxlan_gbp inside struct vxlanhdr ?
> > I suspect compiler will use two byte loads
> > with shifts and ors every time to access policy_id.
> > Even it works ok, I think this struct layout is ugly.
> > imo would be much easier to read if you replace
> > the whole vxlanhdr with vxlanhdr_gbp
> > or split vxlanhdr into two 32-bit structs.
> > then __packed hacks won't be needed.
If I read objdump output correctly, gcc seems fine with it:
/* For backwards compatibility, only allow reserved fields to be
* used by VXLAN extensions if explicitly requested.
*/
if (vs->exts) {
if (!vxh->vni_present)
2640: 41 0f b6 55 08 movzbl 0x8(%r13),%edx
2645: f6 c2 08 test $0x8,%dl
2648: 74 c2 je 260c <vxlan_udp_encap_recv+0x9c>
[...]
md.gbp = ntohs(vxh->gbp.policy_id);
2652: 41 0f b7 55 0a movzwl 0xa(%r13),%edx
Let me know what I have to do/provide to validate this properly.
> Also, if you are writing the values then you need to write
> all the members of the bitfield in order to get a single write.
>
> Basically you are much better off using explicit masks.
I went back and forth on this and chose to use individual bit fields
and map them to a static bit definition which is exported via Netlink.
That way the user space Netlink interface remains stable should the
wire protocol ever change. Yes, this implies some branching which could
be avoided right now as long as user and wire protocol are identical. I
did not observe any performance differences in benchmarks though.
next prev parent reply other threads:[~2015-01-07 11:01 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-07 3:37 [PATCH 2/6] vxlan: Group Policy extension Alexei Starovoitov
2015-01-07 10:03 ` David Laight
2015-01-07 11:01 ` Thomas Graf [this message]
2015-01-07 11:10 ` Thomas Graf
-- strict thread matches above, loose matches on Subject: below --
2015-01-12 12:26 [PATCH 0/6 net-next v3] VXLAN Group Policy Extension Thomas Graf
2015-01-12 12:26 ` [PATCH 2/6] vxlan: Group Policy extension Thomas Graf
2015-01-12 19:23 ` Jesse Gross
[not found] ` <CAEP_g=8TqGnftZa_scKODa2ra7gsV6ov_5J+Lbfq+4bFDZjiBw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-12 22:47 ` Thomas Graf
2015-01-12 22:50 ` Jesse Gross
2015-01-12 22:59 ` Thomas Graf
2015-01-12 23:19 ` Jesse Gross
2015-01-08 22:47 [PATCH 0/6 net-next v2] VXLAN Group Policy Extension Thomas Graf
2015-01-08 22:47 ` [PATCH 2/6] vxlan: Group Policy extension Thomas Graf
2015-01-09 17:37 ` Alexei Starovoitov
2015-01-09 22:10 ` Thomas Graf
2015-01-12 17:37 ` Nicolas Dichtel
2015-01-12 17:59 ` David Miller
2015-01-13 8:29 ` Nicolas Dichtel
2015-01-13 1:04 ` Thomas Graf
2015-01-12 18:14 ` Tom Herbert
2015-01-13 1:03 ` Thomas Graf
2015-01-13 2:28 ` Tom Herbert
2015-01-13 11:32 ` Thomas Graf
2015-01-13 16:16 ` Tom Herbert
2015-01-07 17:32 Alexei Starovoitov
[not found] ` <CAADnVQJErdNJrXOOSqEqkbC8524VCH2E9vYL-WdTb_6SGsTwvw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-07 23:27 ` Thomas Graf
2015-01-07 23:39 ` Alexei Starovoitov
2015-01-07 2:05 [PATCH 0/6 net-next] VXLAN Group Policy Extension Thomas Graf
2015-01-07 2:05 ` [PATCH 2/6] vxlan: Group Policy extension Thomas Graf
2015-01-07 16:05 ` Tom Herbert
[not found] ` <CA+mtBx_Jj-tUM1nbHd2fHb0-=QpK3tcQgA=smWmg=cB-fupdGg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-07 16:21 ` Thomas Graf
2015-01-07 16:56 ` Tom Herbert
[not found] ` <CA+mtBx_A_M3+irq7w4nNCyPZBgM7ja+wfJT4w4Q0Yo6GMGYVgA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-07 17:21 ` Thomas Graf
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=20150107110118.GO21820@casper.infradead.org \
--to=tgraf@suug.ch \
--cc=David.Laight@ACULAB.COM \
--cc=alexei.starovoitov@gmail.com \
--cc=davem@davemloft.net \
--cc=dev@openvswitch.org \
--cc=jesse@nicira.com \
--cc=netdev@vger.kernel.org \
--cc=pshelar@nicira.com \
--cc=stephen@networkplumber.org \
/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).