aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2011-02-10 09:33:56 -0500
committerSven Eckelmann <sven@narfation.org>2011-02-10 18:25:10 -0500
commitc2f7f0e7b3ce55eee32892d6aa5cd88a7512ea25 (patch)
tree93be054cc3f80e20e704bafa6073fd8b44e89514 /net
parent091b948306d2628320e77977eb7ae4a757b12180 (diff)
batman-adv: Use successive sequence numbers for fragments
The two fragments of an unicast packet must have successive sequence numbers to allow the receiver side to detect matching fragments and merge them again. The current implementation doesn't provide that property because a sequence of two atomic_inc_return may be interleaved with another sequence which also changes the variable. The access to the fragment sequence number pool has either to be protected by correct locking or it has to reserve two sequence numbers in a single fetch. The latter one can easily be done by increasing the value of the last used sequence number by 2 in a single step. The generated window of two currently unused sequence numbers can now be scattered across the two fragments. Reported-by: Linus Lüssing <linus.luessing@web.de> Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net')
-rw-r--r--net/batman-adv/unicast.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
index cbf022cb3121..9b2a222518f7 100644
--- a/net/batman-adv/unicast.c
+++ b/net/batman-adv/unicast.c
@@ -226,6 +226,7 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
226 int ucf_hdr_len = sizeof(struct unicast_frag_packet); 226 int ucf_hdr_len = sizeof(struct unicast_frag_packet);
227 int data_len = skb->len - uc_hdr_len; 227 int data_len = skb->len - uc_hdr_len;
228 int large_tail = 0; 228 int large_tail = 0;
229 uint16_t seqno;
229 230
230 if (!bat_priv->primary_if) 231 if (!bat_priv->primary_if)
231 goto dropped; 232 goto dropped;
@@ -261,10 +262,9 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
261 frag1->flags = UNI_FRAG_HEAD | large_tail; 262 frag1->flags = UNI_FRAG_HEAD | large_tail;
262 frag2->flags = large_tail; 263 frag2->flags = large_tail;
263 264
264 frag1->seqno = htons((uint16_t)atomic_inc_return( 265 seqno = atomic_add_return(2, &batman_if->frag_seqno);
265 &batman_if->frag_seqno)); 266 frag1->seqno = htons(seqno - 1);
266 frag2->seqno = htons((uint16_t)atomic_inc_return( 267 frag2->seqno = htons(seqno);
267 &batman_if->frag_seqno));
268 268
269 send_skb_packet(skb, batman_if, dstaddr); 269 send_skb_packet(skb, batman_if, dstaddr);
270 send_skb_packet(frag_skb, batman_if, dstaddr); 270 send_skb_packet(frag_skb, batman_if, dstaddr);