b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: "Linus Lüssing" <linus.luessing@c0d3.blue>
To: Simon Wunderlich <sw@simonwunderlich.de>
Cc: b.a.t.m.a.n@lists.open-mesh.org
Subject: Re: [PATCH v4 3/5] batman-adv: mcast: implement multicast packet reception and forwarding
Date: Sat, 21 Jan 2023 14:15:55 +0100	[thread overview]
Message-ID: <Y8vli4sEYcl75iS9@sellars> (raw)
In-Reply-To: <2927983.YVBx59ikfs@prime>

On Thu, Jan 19, 2023 at 01:47:25PM +0100, Simon Wunderlich wrote:
> On Tuesday, December 27, 2022 8:34:07 PM CET Linus Lüssing wrote:
> > +/**
> > + * struct batadv_tvlv_mcast_tracker - payload of a multicast tracker tvlv
> > + * @num_dests: number of subsequent destination originator MAC addresses
> > + * @align: (optional) alignment bytes to make the tracker TVLV 4 bytes
> > aligned, + * present if num_dests are even, not present if odd
> > + */
> > +struct batadv_tvlv_mcast_tracker {
> > +       __be16  num_dests;
> > +       __u8    align[2];
> > +};
> > +
> The one thing which I really don't like is to have the alignment in the 
> beginning, and depending on the number of entries. Normally, such alignments 
> should be at the end of the structure so it is straight forward for a parser 
> to omit it.
> 
> My understanding is that the alignment is due to technical reasons (mac 
> address list is assembled by pushing the data to the front), perhaps to save 
> another memove/memcpy. However, the data is collected by traversing various 
> lists, and if performance would be a concern, then this data should be cached 
> and this "technicality" wouldn't be needed either.

The technical reason was to have the payload data from the IP
header 4 bytes aligned. To allow efficient access in there once the
payload is decapsulated.

> 
> So please, skip the alignment in the front and have it in the back.

The reasons to put the aligment at the front are/were the following
two:

1) We do keep a count of receiving nodes, however it might change
while we are pushing destinations. So it is at the moment easier
to push the padding to the front, when we know exactly how many
destinations we have added to the packet. As discussed offline, I
guess that is what you were refering to above.

2) Alignment changes during routing everytime a router removes an
odd number of destinations from the tracker TVLV. Changing
alignment more to the front would in theory less memory movements.
Example for an ideal case:

[MC-HDR][pad][dest1][dest2]...[dest100][PAYLOAD]
-> dest1 is deleted
[MC-HDR][pad][00000][dest2]...[dest100][PAYLOAD]
-> move only MC-HDR:
[MC-HDR][dest2]...[dest100][PAYLOAD]
 
If the alignment were behind dest100 then everything would need to
be moved.


Even though it's unconventional to have the padding in the front,
I found the idea quite tempting and useful to have the padding in
front, saves quite a bit of code and potential bugs I would hope :D.
And would hopefully (potentially allow to) make the packet routing
a bit faster. So from a "purely technical" point-of-view it seemed
advantageous to me :D.

Another idea would be to have the padding at the end by adding and
keeping a zero-MAC destination entry if the number of destinations
were otherwise even. Disadvantage: Might waste 4 more bytes than
necessary.

> 
> The rest of the packet format looks good from what I've seen.

Thanks for having a look at it!

Regards, Linus

  reply	other threads:[~2023-01-21 13:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-27 19:34 [PATCH v4 0/5] Implementation of a Stateless Multicast Packet Type Linus Lüssing
2022-12-27 19:34 ` [PATCH v4 1/5] batman-adv: mcast: remove now redundant single ucast forwarding Linus Lüssing
2023-01-06 17:21   ` Sven Eckelmann
2022-12-27 19:34 ` [PATCH v4 2/5] batman-adv: tvlv: prepare for tvlv enabled multicast packet type Linus Lüssing
2023-01-06 17:54   ` Sven Eckelmann
2022-12-27 19:34 ` [PATCH v4 3/5] batman-adv: mcast: implement multicast packet reception and forwarding Linus Lüssing
2023-01-15 17:56   ` Sven Eckelmann
2023-01-16 18:31     ` Linus Lüssing
2023-01-19 12:47   ` Simon Wunderlich
2023-01-21 13:15     ` Linus Lüssing [this message]
2022-12-27 19:34 ` [PATCH v4 4/5] batman-adv: mcast: implement multicast packet generation Linus Lüssing
2023-01-18 21:15   ` Sven Eckelmann
2022-12-27 19:34 ` [PATCH v4 5/5] batman-adv: mcast: shrink tracker packet after scrubbing Linus Lüssing
2023-01-18 21:29   ` Sven Eckelmann
2023-01-27  9:26 ` [PATCH v4 0/5] Implementation of a Stateless Multicast Packet Type Sven Eckelmann

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=Y8vli4sEYcl75iS9@sellars \
    --to=linus.luessing@c0d3.blue \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=sw@simonwunderlich.de \
    /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).