public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: "Martin Hundebøll" <martin@hundeboll.net>
To: Antonio Quartulli <ordex@autistici.org>
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.] [PATCHv3 3/3] batman-adv: Fragment and send skbs larger than mtu
Date: Thu, 23 May 2013 07:38:33 +0200	[thread overview]
Message-ID: <519DAB59.9070001@hundeboll.net> (raw)
In-Reply-To: <20130521191926.GB3435@ritirata.org>

Hi Antonio,

On 2013-05-21 21:19, Antonio Quartulli wrote:
> On Tue, May 21, 2013 at 12:48:19PM +0200, Martin Hundebøll wrote:
>> +static struct sk_buff *batadv_frag_create(struct sk_buff *skb,
>> +					  struct batadv_frag_packet *frag_head,
>> +					  unsigned int mtu)
>> +{
>> +	struct sk_buff *skb_fragment;
>> +	unsigned header_size = sizeof(*frag_head);
>> +	unsigned fragment_size = mtu - header_size;
>> +
>> +	skb_fragment = dev_alloc_skb(mtu + ETH_HLEN);
>> +	if (!skb_fragment)
>> +		goto err;
>> +
>> +	/* Eat the last mtu-bytes of the skb */
>> +	skb_reserve(skb_fragment, header_size + ETH_HLEN);
>> +	skb_split(skb, skb_fragment, skb->len - fragment_size);
>> +
>> +	/* Add the header */
>> +	skb_push(skb_fragment, header_size);
>> +	memcpy(skb_fragment->data, frag_head, header_size);
>
> here we are copying the data right after the Fragment header. However I am not
> sure we are accessing aligned memory because:
>
> ETH_HLEN + header_size = 14 + 20 = 34
>
> To speed up the copy, wouldn't it be better to allocate ETH_HLEN +
> header_size + IP_ALIGN bytes like we do for other packets? (you can use
> netdev_alloc_skb_ip_align() like we do somewhere else).
>
> In this way the memcpy will access a 4bytes aligned memory (if I am not wrong).
>
> Can somebody else comment on this?

I did a quick test by adding some printk-debugging after skb_split() and 
skb_push():
	printk("data: %lu\n", (unsigned long)skb->data % 4);

and it seems like the skb->data pointer is aligned to boundaries of 4 in 
both with and without the use of netdev_alloc_skb_ip_align().

This was done on x86_64 virtual machines. Is there another way this 
should be tested or maybe on some different architecture?

The next revision is pretty much ready, but I will keep it back a bit, 
until someone clarifies this align stuff :)

// Martin



-- 
Kind Regards
Martin Hundebøll
Frederiks Allé 99, 1.th
8000 Aarhus C
Denmark

+45 61 65 54 61
martin@hundeboll.net

  reply	other threads:[~2013-05-23  5:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-21 10:48 [B.A.T.M.A.N.] [PATCHv3 0/3] Fragmentation version 2 Martin Hundebøll
2013-05-21 10:48 ` [B.A.T.M.A.N.] [PATCHv3 1/3] batman-adv: Remove old fragmentation code Martin Hundebøll
2013-05-21 10:48 ` [B.A.T.M.A.N.] [PATCHv3 2/3] batman-adv: Receive fragmented packets and merge Martin Hundebøll
2013-05-21 19:10   ` Antonio Quartulli
2013-05-23  5:07     ` Martin Hundebøll
2013-05-21 10:48 ` [B.A.T.M.A.N.] [PATCHv3 3/3] batman-adv: Fragment and send skbs larger than mtu Martin Hundebøll
2013-05-21 19:19   ` Antonio Quartulli
2013-05-23  5:38     ` Martin Hundebøll [this message]
2013-05-23  7:29       ` Antonio Quartulli
2013-05-23  8:46         ` Antonio Quartulli
2013-05-23  8:51 ` [B.A.T.M.A.N.] [PATCHv3 0/3] Fragmentation version 2 Antonio Quartulli

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=519DAB59.9070001@hundeboll.net \
    --to=martin@hundeboll.net \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=ordex@autistici.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