fragmentation.c (9f6446c7f9af084763037334d37e85dacfcbd403) fragmentation.c (53e771457e823fbc21834f60508c42a4270534fd)
1/* Copyright (C) 2013-2015 B.A.T.M.A.N. contributors:
2 *
3 * Martin Hundebøll <martin@hundeboll.net>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public
7 * License as published by the Free Software Foundation.
8 *

--- 147 unchanged lines hidden (view full) ---

156 * if the list is empty at return.
157 */
158 chain = &orig_node->fragments[bucket];
159 spin_lock_bh(&chain->lock);
160 if (batadv_frag_init_chain(chain, seqno)) {
161 hlist_add_head(&frag_entry_new->list, &chain->head);
162 chain->size = skb->len - hdr_size;
163 chain->timestamp = jiffies;
1/* Copyright (C) 2013-2015 B.A.T.M.A.N. contributors:
2 *
3 * Martin Hundebøll <martin@hundeboll.net>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public
7 * License as published by the Free Software Foundation.
8 *

--- 147 unchanged lines hidden (view full) ---

156 * if the list is empty at return.
157 */
158 chain = &orig_node->fragments[bucket];
159 spin_lock_bh(&chain->lock);
160 if (batadv_frag_init_chain(chain, seqno)) {
161 hlist_add_head(&frag_entry_new->list, &chain->head);
162 chain->size = skb->len - hdr_size;
163 chain->timestamp = jiffies;
164 chain->total_size = ntohs(frag_packet->total_size);
164 ret = true;
165 goto out;
166 }
167
168 /* Find the position for the new fragment. */
169 hlist_for_each_entry(frag_entry_curr, &chain->head, list) {
170 /* Drop packet if fragment already exists. */
171 if (frag_entry_curr->no == frag_entry_new->no)

--- 18 unchanged lines hidden (view full) ---

190 hlist_add_behind(&frag_entry_new->list, &frag_entry_last->list);
191 chain->size += skb->len - hdr_size;
192 chain->timestamp = jiffies;
193 ret = true;
194 }
195
196out:
197 if (chain->size > batadv_frag_size_limit() ||
165 ret = true;
166 goto out;
167 }
168
169 /* Find the position for the new fragment. */
170 hlist_for_each_entry(frag_entry_curr, &chain->head, list) {
171 /* Drop packet if fragment already exists. */
172 if (frag_entry_curr->no == frag_entry_new->no)

--- 18 unchanged lines hidden (view full) ---

191 hlist_add_behind(&frag_entry_new->list, &frag_entry_last->list);
192 chain->size += skb->len - hdr_size;
193 chain->timestamp = jiffies;
194 ret = true;
195 }
196
197out:
198 if (chain->size > batadv_frag_size_limit() ||
198 ntohs(frag_packet->total_size) > batadv_frag_size_limit()) {
199 chain->total_size != ntohs(frag_packet->total_size) ||
200 chain->total_size > batadv_frag_size_limit()) {
199 /* Clear chain if total size of either the list or the packet
201 /* Clear chain if total size of either the list or the packet
200 * exceeds the maximum size of one merged packet.
202 * exceeds the maximum size of one merged packet. Don't allow
203 * packets to have different total_size.
201 */
202 batadv_frag_clear_chain(&chain->head);
203 chain->size = 0;
204 } else if (ntohs(frag_packet->total_size) == chain->size) {
205 /* All fragments received. Hand over chain to caller. */
206 hlist_move_list(&chain->head, chain_out);
207 chain->size = 0;
208 }

--- 289 unchanged lines hidden ---
204 */
205 batadv_frag_clear_chain(&chain->head);
206 chain->size = 0;
207 } else if (ntohs(frag_packet->total_size) == chain->size) {
208 /* All fragments received. Hand over chain to caller. */
209 hlist_move_list(&chain->head, chain_out);
210 chain->size = 0;
211 }

--- 289 unchanged lines hidden ---