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?
+bool batadv_frag_send_packet(struct sk_buff *skb,
struct batadv_orig_node *orig_node,
struct batadv_neigh_node *neigh_node)
+{
- struct batadv_priv *bat_priv;
- struct batadv_hard_iface *primary_if;
- struct batadv_frag_packet frag_header;
- struct sk_buff *skb_fragment;
- unsigned mtu = neigh_node->if_incoming->net_dev->mtu;
- unsigned header_size = sizeof(frag_header);
- unsigned max_fragment_size, max_packet_size;
- /* To avoid merge and refragmentation at next-hops we never send
* fragments larger than BATADV_FRAG_MAX_FRAG_SIZE
*/
- mtu = min_t(int, mtu, BATADV_FRAG_MAX_FRAG_SIZE);
if mtu is unsigned (int), why not using unsigned (int) inside the min_t function?
- /* Send the last fragment */
- batadv_inc_counter(bat_priv, BATADV_CNT_FRAG_TX);
- batadv_add_counter(bat_priv, BATADV_CNT_FRAG_TX_BYTES,
skb->len + ETH_HLEN);
Like int he previous patch: do we really need to count ETH_HLEN? (I'm not sure about this)
Thanks again :)