@@ -108,7 +108,7 @@ struct sctp_packet *sctp_packet_init(struct sctp_packet *packet,
108108 packet -> transport = transport ;
109109 packet -> source_port = sport ;
110110 packet -> destination_port = dport ;
111- skb_queue_head_init (& packet -> chunks );
111+ INIT_LIST_HEAD (& packet -> chunk_list );
112112 if (asoc ) {
113113 struct sctp_sock * sp = sctp_sk (asoc -> base .sk );
114114 overhead = sp -> pf -> af -> net_header_len ;
@@ -129,12 +129,14 @@ struct sctp_packet *sctp_packet_init(struct sctp_packet *packet,
129129/* Free a packet. */
130130void sctp_packet_free (struct sctp_packet * packet )
131131{
132- struct sctp_chunk * chunk ;
132+ struct sctp_chunk * chunk , * tmp ;
133133
134134 SCTP_DEBUG_PRINTK ("%s: packet:%p\n" , __FUNCTION__ , packet );
135135
136- while ((chunk = (struct sctp_chunk * )__skb_dequeue (& packet -> chunks )) != NULL )
136+ list_for_each_entry_safe (chunk , tmp , & packet -> chunk_list , list ) {
137+ list_del_init (& chunk -> list );
137138 sctp_chunk_free (chunk );
139+ }
138140
139141 if (packet -> malloced )
140142 kfree (packet );
@@ -276,7 +278,7 @@ sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *packet,
276278 packet -> has_sack = 1 ;
277279
278280 /* It is OK to send this chunk. */
279- __skb_queue_tail ( & packet -> chunks , ( struct sk_buff * ) chunk );
281+ list_add_tail ( & chunk -> list , & packet -> chunk_list );
280282 packet -> size += chunk_len ;
281283 chunk -> transport = packet -> transport ;
282284finish :
@@ -295,7 +297,7 @@ int sctp_packet_transmit(struct sctp_packet *packet)
295297 struct sctphdr * sh ;
296298 __u32 crc32 ;
297299 struct sk_buff * nskb ;
298- struct sctp_chunk * chunk ;
300+ struct sctp_chunk * chunk , * tmp ;
299301 struct sock * sk ;
300302 int err = 0 ;
301303 int padding ; /* How much padding do we need? */
@@ -305,11 +307,11 @@ int sctp_packet_transmit(struct sctp_packet *packet)
305307 SCTP_DEBUG_PRINTK ("%s: packet:%p\n" , __FUNCTION__ , packet );
306308
307309 /* Do NOT generate a chunkless packet. */
308- chunk = (struct sctp_chunk * )skb_peek (& packet -> chunks );
309- if (unlikely (!chunk ))
310+ if (list_empty (& packet -> chunk_list ))
310311 return err ;
311312
312313 /* Set up convenience variables... */
314+ chunk = list_entry (packet -> chunk_list .next , struct sctp_chunk , list );
313315 sk = chunk -> skb -> sk ;
314316
315317 /* Allocate the new skb. */
@@ -370,7 +372,8 @@ int sctp_packet_transmit(struct sctp_packet *packet)
370372 * [This whole comment explains WORD_ROUND() below.]
371373 */
372374 SCTP_DEBUG_PRINTK ("***sctp_transmit_packet***\n" );
373- while ((chunk = (struct sctp_chunk * )__skb_dequeue (& packet -> chunks )) != NULL ) {
375+ list_for_each_entry_safe (chunk , tmp , & packet -> chunk_list , list ) {
376+ list_del_init (& chunk -> list );
374377 if (sctp_chunk_is_data (chunk )) {
375378
376379 if (!chunk -> has_tsn ) {
@@ -511,7 +514,8 @@ int sctp_packet_transmit(struct sctp_packet *packet)
511514 * will get resent or dropped later.
512515 */
513516
514- while ((chunk = (struct sctp_chunk * )__skb_dequeue (& packet -> chunks )) != NULL ) {
517+ list_for_each_entry_safe (chunk , tmp , & packet -> chunk_list , list ) {
518+ list_del_init (& chunk -> list );
515519 if (!sctp_chunk_is_data (chunk ))
516520 sctp_chunk_free (chunk );
517521 }
0 commit comments