b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Linus Luessing <Linus.Luessing@ascom.CH>
To: Andrew Lunn <andrew@lunn.ch>
Cc: The list for a Better Approach To Mobile Ad-hoc Networking
	<b.a.t.m.a.n@lists.open-mesh.org>
Subject: Re: [B.A.T.M.A.N.] [PATCH 02/13] batman-adv: Add explicit batman header structure
Date: Wed, 16 Feb 2011 16:05:39 +0100	[thread overview]
Message-ID: <OF1CE3C18F.65202C60-ONC1257839.0051202F-C1257839.0052EAAC@ln.ascom.ch> (raw)
In-Reply-To: <20110216060811.GB11570@lunn.ch>

Andrew Lunn <andrew@lunn.ch> schrieb am 16.02.2011 07:08:11:

> [Bild entfernt] 
> 
> Re: [B.A.T.M.A.N.] [PATCH 02/13] batman-adv: Add explicit batman 
> header structure
> 
> Andrew Lunn 
> 
> an:
> 
> The list for a Better Approach To Mobile Ad-hoc Networking
> 
> 16.02.2011 07:08
> 
> Kopie:
> 
> Linus L??ssing
> 
> On Tue, Feb 15, 2011 at 06:12:17PM +0100, Linus L??ssing wrote:
> > Just a minor style adjustment, to give people a hint which fields 
should
> > not be reordered and need to be at the beginning of each packet with
> > batman-adv's frame type.
> 
> Hi Linus
> 
> > +struct batman_header {
> > +   uint8_t  packet_type;
> > +   uint8_t  version;  /* batman version field */
> > +   uint8_t  ttl;
> > +   uint8_t  align;
> > +} __packed;
> > +
> >  struct batman_packet {
> > -   uint8_t  packet_type;
> > -   uint8_t  version;  /* batman version field */
> > +   struct   batman_header header;
> > +   uint32_t seqno;
> >     uint8_t  flags;    /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER 
flag... */
> >     uint8_t  tq;
> > -   uint32_t seqno;
> >     uint8_t  orig[6];
> >     uint8_t  prev_sender[6];
> > -   uint8_t  ttl;
> >     uint8_t  num_hna;
> >     uint8_t  gw_flags;  /* flags related to gateway class */
> > -   uint8_t  align;
> >  } __packed;
> 
> Two different ideas, both triggered by the align byte in header. This
> byte is a waste of space, it is not used, and it is probably not easy
> to find something which all packet types are going to need in the
> future.

Sure, anything that not all packet types have in common can't go inside of
the batman_header. But are those three variables something we could agree
on, being something that all packet types will need today and in the 
future?
version + packet_type is something we'll always need I think, the TTL 
might
be something to argue about, as packets that do not get routed would not
necessarily need them (though it could be a "safety belt" in case of bugs,
to really make sure packets only intended for one hop will not be routed).

> 
> 1) Did you try not having it. So long header is __packed, and all the
> structures it is used in are __packed, i think the compiler will do
> the right thing. The downside is that alignment is not obvious. Most
> people will assume header is 4 bytes, not 3, and think the alignment
> of the packets is wrong. 
> 
> 2) Did you consider using a union? It is a more invasive patch, but
> the alignment is then clear. The downside is sizeof() no longer gives
> you the per packet type size, rather it gives you the size of the
> biggest member of the union. So this makes the change even more
> invasive and bug prone.

Hmm, no, actually haven't thought about that. So we'd actually put the 
batman
packet types as a union inside of the batman-header structure, instead of
putting the header structure at the front of each packet type. Don't know
if I'd like that either, due to the reason you've mentioned.

> 
> I think i prefer 1), with appropriate comments to explain the
> alignment issue.

So I think I'd prefer the first option, that should work too :). Just 
didn't think
that an extra Byte would matter that much, and had the readability / 
making the
alignment a little more obvious in mind. (And who knows when we might need 
to increase
the version number size already ;) ) 


> 
>      Andrew

Cheers, Linus

  reply	other threads:[~2011-02-16 15:05 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-15 17:12 [B.A.T.M.A.N.] Redundancy bonding mode patches, v1 Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 01/13] batman-adv: Remove unused hdr_size variable in route_unicast_packet() Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 02/13] batman-adv: Add explicit batman header structure Linus Lüssing
2011-02-16  6:08   ` Andrew Lunn
2011-02-16 15:05     ` Linus Luessing [this message]
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 03/13] batman-adv: Unify TTL handling Linus Lüssing
2011-02-16  6:16   ` Andrew Lunn
2011-02-16 14:42     ` Linus Luessing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 04/13] batman-adv: Make route_unicast_packet() packet_type independent Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 05/13] batman-adv: Add rcu-refcount wrapper for orig_node hash_find() Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 06/13] batman-adv: Use route_unicast_packet() for sending own unicast packets Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 07/13] batman-adv: Avoid redundant hash_find() call for " Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 08/13] batman-adv: Use packet lists for unicast packet sending Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 09/13] batman-adv: Add sysfs option for enabling redundant bonding mode Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 10/13] batman-adv: Adding redundant bonding mode transmission Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 11/13] batman-adv: Adding unicast_safe packet reception Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 12/13] batman-adv: Generic sequence number checking for data packets Linus Lüssing
2011-02-15 17:12 ` [B.A.T.M.A.N.] [PATCH 13/13] batman-adv: Add sequence number and duplicate checks for unicasts_safe Linus Lüssing

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=OF1CE3C18F.65202C60-ONC1257839.0051202F-C1257839.0052EAAC@ln.ascom.ch \
    --to=linus.luessing@ascom.ch \
    --cc=andrew@lunn.ch \
    --cc=b.a.t.m.a.n@lists.open-mesh.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).