Lines Matching full:chain
31 * batadv_frag_clear_chain() - delete entries in the fragment buffer chain
32 * @head: head of chain with entries.
33 * @dropped: whether the chain is cleared because all fragments are dropped
62 struct batadv_frag_table_entry *chain; in batadv_frag_purge_orig() local
66 chain = &orig_node->fragments[i]; in batadv_frag_purge_orig()
67 spin_lock_bh(&chain->lock); in batadv_frag_purge_orig()
69 if (!check_cb || check_cb(chain)) { in batadv_frag_purge_orig()
70 batadv_frag_clear_chain(&chain->fragment_list, true); in batadv_frag_purge_orig()
71 chain->size = 0; in batadv_frag_purge_orig()
74 spin_unlock_bh(&chain->lock); in batadv_frag_purge_orig()
94 * batadv_frag_init_chain() - check and prepare fragment chain for new fragment
95 * @chain: chain in fragments table to init
98 * Make chain ready for a fragment with sequence number "seqno". Delete existing
101 * Caller must hold chain->lock.
103 * Return: true if chain is empty and the caller can just insert the new
106 static bool batadv_frag_init_chain(struct batadv_frag_table_entry *chain, in batadv_frag_init_chain() argument
109 lockdep_assert_held(&chain->lock); in batadv_frag_init_chain()
111 if (chain->seqno == seqno) in batadv_frag_init_chain()
114 if (!hlist_empty(&chain->fragment_list)) in batadv_frag_init_chain()
115 batadv_frag_clear_chain(&chain->fragment_list, true); in batadv_frag_init_chain()
117 chain->size = 0; in batadv_frag_init_chain()
118 chain->seqno = seqno; in batadv_frag_init_chain()
124 * batadv_frag_insert_packet() - insert a fragment into a fragment chain
129 * Insert a new fragment into the reverse ordered chain in the right table
132 * Return: true if skb is buffered, false on error. If the chain has all the
133 * fragments needed to merge the packet, the chain is moved to the passed head
134 * to avoid locking the chain in the table.
140 struct batadv_frag_table_entry *chain; in batadv_frag_insert_packet() local
166 /* Select entry in the "chain table" and delete any prior fragments in batadv_frag_insert_packet()
170 chain = &orig_node->fragments[bucket]; in batadv_frag_insert_packet()
171 spin_lock_bh(&chain->lock); in batadv_frag_insert_packet()
172 if (batadv_frag_init_chain(chain, seqno)) { in batadv_frag_insert_packet()
173 hlist_add_head(&frag_entry_new->list, &chain->fragment_list); in batadv_frag_insert_packet()
174 chain->size = skb->len - hdr_size; in batadv_frag_insert_packet()
175 chain->timestamp = jiffies; in batadv_frag_insert_packet()
176 chain->total_size = ntohs(frag_packet->total_size); in batadv_frag_insert_packet()
182 hlist_for_each_entry(frag_entry_curr, &chain->fragment_list, list) { in batadv_frag_insert_packet()
191 chain->size += skb->len - hdr_size; in batadv_frag_insert_packet()
192 chain->timestamp = jiffies; in batadv_frag_insert_packet()
204 chain->size += skb->len - hdr_size; in batadv_frag_insert_packet()
205 chain->timestamp = jiffies; in batadv_frag_insert_packet()
210 if (chain->size > batadv_frag_size_limit() || in batadv_frag_insert_packet()
211 chain->total_size != ntohs(frag_packet->total_size) || in batadv_frag_insert_packet()
212 chain->total_size > batadv_frag_size_limit()) { in batadv_frag_insert_packet()
213 /* Clear chain if total size of either the list or the packet in batadv_frag_insert_packet()
217 batadv_frag_clear_chain(&chain->fragment_list, true); in batadv_frag_insert_packet()
218 chain->size = 0; in batadv_frag_insert_packet()
219 } else if (ntohs(frag_packet->total_size) == chain->size) { in batadv_frag_insert_packet()
220 /* All fragments received. Hand over chain to caller. */ in batadv_frag_insert_packet()
221 hlist_move_list(&chain->fragment_list, chain_out); in batadv_frag_insert_packet()
222 chain->size = 0; in batadv_frag_insert_packet()
226 spin_unlock_bh(&chain->lock); in batadv_frag_insert_packet()
238 * batadv_frag_merge_packets() - merge a chain of fragments
239 * @chain: head of chain with fragments
241 * Expand the first skb in the chain and copy the content of the remaining
242 * skb's into the expanded one. After doing so, clear the chain.
247 batadv_frag_merge_packets(struct hlist_head *chain) in batadv_frag_merge_packets() argument
258 entry = hlist_entry(chain->first, struct batadv_frag_list_entry, list); in batadv_frag_merge_packets()
285 hlist_for_each_entry(entry, chain, list) { in batadv_frag_merge_packets()
291 /* Locking is not needed, because 'chain' is not part of any orig. */ in batadv_frag_merge_packets()
292 batadv_frag_clear_chain(chain, dropped); in batadv_frag_merge_packets()