The following commit has been merged in the merge/master branch: commit 9364ea649aa4e7405b2e769aceef8a6627e1bd9c Merge: 95cf345276bb0089e00df24c3564a3c0ad6d05ce 287f80bc1649bc831bbff54bab27694ae244c5ad Author: Sven Eckelmann sven@narfation.org Date: Tue Jan 25 23:52:28 2011 +0100
Merge remote branch 'origin/standalone/next' into merge/master
diff --combined net/batman-adv/packet.h index 2284e81,03ce0d3..03ce0d3 --- a/net/batman-adv/packet.h +++ b/net/batman-adv/packet.h @@@ -50,6 -50,7 +50,7 @@@
/* fragmentation defines */ #define UNI_FRAG_HEAD 0x01 + #define UNI_FRAG_LARGETAIL 0x02
struct batman_packet { uint8_t packet_type; diff --combined net/batman-adv/routing.c index 8828edd,a8cd389..a8cd389 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@@ -1193,7 -1193,7 +1193,7 @@@ int route_unicast_packet(struct sk_buf dstaddr);
if (unicast_packet->packet_type == BAT_UNICAST_FRAG && - 2 * skb->len - hdr_size <= batman_if->net_dev->mtu) { + frag_can_reassemble(skb, batman_if->net_dev->mtu)) {
ret = frag_reassemble_skb(skb, bat_priv, &new_skb);
diff --combined net/batman-adv/unicast.c index ee41fef,fc77079..fc77079 --- a/net/batman-adv/unicast.c +++ b/net/batman-adv/unicast.c @@@ -224,7 -224,8 +224,8 @@@ int frag_send_skb(struct sk_buff *skb, struct unicast_frag_packet *frag1, *frag2; int uc_hdr_len = sizeof(struct unicast_packet); int ucf_hdr_len = sizeof(struct unicast_frag_packet); - int data_len = skb->len; + int data_len = skb->len - uc_hdr_len; + int large_tail = 0;
if (!bat_priv->primary_if) goto dropped; @@@ -232,10 -233,11 +233,11 @@@ frag_skb = dev_alloc_skb(data_len - (data_len / 2) + ucf_hdr_len); if (!frag_skb) goto dropped; + skb_reserve(frag_skb, ucf_hdr_len);
unicast_packet = (struct unicast_packet *) skb->data; memcpy(&tmp_uc, unicast_packet, uc_hdr_len); - skb_split(skb, frag_skb, data_len / 2); + skb_split(skb, frag_skb, data_len / 2 + uc_hdr_len);
if (my_skb_head_push(skb, ucf_hdr_len - uc_hdr_len) < 0 || my_skb_head_push(frag_skb, ucf_hdr_len) < 0) @@@ -253,8 -255,11 +255,11 @@@ memcpy(frag1->orig, bat_priv->primary_if->net_dev->dev_addr, ETH_ALEN); memcpy(frag2, frag1, sizeof(struct unicast_frag_packet));
- frag1->flags |= UNI_FRAG_HEAD; - frag2->flags &= ~UNI_FRAG_HEAD; + if (data_len & 1) + large_tail = UNI_FRAG_LARGETAIL; + + frag1->flags = UNI_FRAG_HEAD | large_tail; + frag2->flags = large_tail;
frag1->seqno = htons((uint16_t)atomic_inc_return( &batman_if->frag_seqno)); diff --combined net/batman-adv/unicast.h index e32b786,e7211c2..e7211c2 --- a/net/batman-adv/unicast.h +++ b/net/batman-adv/unicast.h @@@ -22,6 -22,8 +22,8 @@@ #ifndef _NET_BATMAN_ADV_UNICAST_H_ #define _NET_BATMAN_ADV_UNICAST_H_
+ #include "packet.h" + #define FRAG_TIMEOUT 10000 /* purge frag list entrys after time in ms */ #define FRAG_BUFFER_SIZE 6 /* number of list elements in buffer */
@@@ -32,4 -34,25 +34,25 @@@ int unicast_send_skb(struct sk_buff *sk int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, struct batman_if *batman_if, uint8_t dstaddr[]);
+ static inline int frag_can_reassemble(struct sk_buff *skb, int mtu) + { + struct unicast_frag_packet *unicast_packet; + int uneven_correction = 0; + unsigned int merged_size; + + unicast_packet = (struct unicast_frag_packet *)skb->data; + + if (unicast_packet->flags & UNI_FRAG_LARGETAIL) { + if (unicast_packet->flags & UNI_FRAG_HEAD) + uneven_correction = 1; + else + uneven_correction = -1; + } + + merged_size = (skb->len - sizeof(struct unicast_frag_packet)) * 2; + merged_size += sizeof(struct unicast_packet) + uneven_correction; + + return merged_size <= mtu; + } + #endif /* _NET_BATMAN_ADV_UNICAST_H_ */ diff --combined net/batman-adv/vis.c index cd4c423,f69a374..f69a374 --- a/net/batman-adv/vis.c +++ b/net/batman-adv/vis.c @@@ -268,10 -268,10 +268,10 @@@ int vis_seq_print_text(struct seq_file buff_pos += sprintf(buff + buff_pos, "%pM,", entry->addr);
- for (i = 0; i < packet->entries; i++) + for (j = 0; j < packet->entries; j++) buff_pos += vis_data_read_entry( buff + buff_pos, - &entries[i], + &entries[j], entry->addr, entry->primary);