@@ -246,68 +246,6 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, unsigned int len)
246246#endif
247247}
248248
249- /* XXX Lame code duplication!
250- * returns -1 if none was found.
251- * else returns the next offset to use in the function call.
252- */
253- static int ccid2_ackvector (struct sock * sk , struct sk_buff * skb , int offset ,
254- unsigned char * * vec , unsigned char * veclen )
255- {
256- const struct dccp_hdr * dh = dccp_hdr (skb );
257- unsigned char * options = (unsigned char * )dh + dccp_hdr_len (skb );
258- unsigned char * opt_ptr ;
259- const unsigned char * opt_end = (unsigned char * )dh +
260- (dh -> dccph_doff * 4 );
261- unsigned char opt , len ;
262- unsigned char * value ;
263-
264- BUG_ON (offset < 0 );
265- options += offset ;
266- opt_ptr = options ;
267- if (opt_ptr >= opt_end )
268- return -1 ;
269-
270- while (opt_ptr != opt_end ) {
271- opt = * opt_ptr ++ ;
272- len = 0 ;
273- value = NULL ;
274-
275- /* Check if this isn't a single byte option */
276- if (opt > DCCPO_MAX_RESERVED ) {
277- if (opt_ptr == opt_end )
278- goto out_invalid_option ;
279-
280- len = * opt_ptr ++ ;
281- if (len < 3 )
282- goto out_invalid_option ;
283- /*
284- * Remove the type and len fields, leaving
285- * just the value size
286- */
287- len -= 2 ;
288- value = opt_ptr ;
289- opt_ptr += len ;
290-
291- if (opt_ptr > opt_end )
292- goto out_invalid_option ;
293- }
294-
295- switch (opt ) {
296- case DCCPO_ACK_VECTOR_0 :
297- case DCCPO_ACK_VECTOR_1 :
298- * vec = value ;
299- * veclen = len ;
300- return offset + (opt_ptr - options );
301- }
302- }
303-
304- return -1 ;
305-
306- out_invalid_option :
307- DCCP_BUG ("Invalid option - this should not happen (previous parsing)!" );
308- return -1 ;
309- }
310-
311249/**
312250 * ccid2_rtt_estimator - Sample RTT and compute RTO using RFC2988 algorithm
313251 * This code is almost identical with TCP's tcp_rtt_estimator(), since
@@ -432,16 +370,28 @@ static void ccid2_congestion_event(struct sock *sk, struct ccid2_seq *seqp)
432370 ccid2_change_l_ack_ratio (sk , hc -> tx_cwnd );
433371}
434372
373+ static int ccid2_hc_tx_parse_options (struct sock * sk , u8 packet_type ,
374+ u8 option , u8 * optval , u8 optlen )
375+ {
376+ struct ccid2_hc_tx_sock * hc = ccid2_hc_tx_sk (sk );
377+
378+ switch (option ) {
379+ case DCCPO_ACK_VECTOR_0 :
380+ case DCCPO_ACK_VECTOR_1 :
381+ return dccp_ackvec_parsed_add (& hc -> tx_av_chunks , optval , optlen ,
382+ option - DCCPO_ACK_VECTOR_0 );
383+ }
384+ return 0 ;
385+ }
386+
435387static void ccid2_hc_tx_packet_recv (struct sock * sk , struct sk_buff * skb )
436388{
437389 struct dccp_sock * dp = dccp_sk (sk );
438390 struct ccid2_hc_tx_sock * hc = ccid2_hc_tx_sk (sk );
439391 const bool sender_was_blocked = ccid2_cwnd_network_limited (hc );
392+ struct dccp_ackvec_parsed * avp ;
440393 u64 ackno , seqno ;
441394 struct ccid2_seq * seqp ;
442- unsigned char * vector ;
443- unsigned char veclen ;
444- int offset = 0 ;
445395 int done = 0 ;
446396 unsigned int maxincr = 0 ;
447397
@@ -475,17 +425,12 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
475425 }
476426
477427 /* check forward path congestion */
478- /* still didn't send out new data packets */
479- if (hc -> tx_seqh == hc -> tx_seqt )
428+ if (dccp_packet_without_ack (skb ))
480429 return ;
481430
482- switch (DCCP_SKB_CB (skb )-> dccpd_type ) {
483- case DCCP_PKT_ACK :
484- case DCCP_PKT_DATAACK :
485- break ;
486- default :
487- return ;
488- }
431+ /* still didn't send out new data packets */
432+ if (hc -> tx_seqh == hc -> tx_seqt )
433+ goto done ;
489434
490435 ackno = DCCP_SKB_CB (skb )-> dccpd_ack_seq ;
491436 if (after48 (ackno , hc -> tx_high_ack ))
@@ -509,15 +454,16 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
509454 maxincr = DIV_ROUND_UP (dp -> dccps_l_ack_ratio , 2 );
510455
511456 /* go through all ack vectors */
512- while ((offset = ccid2_ackvector (sk , skb , offset ,
513- & vector , & veclen )) != -1 ) {
457+ list_for_each_entry (avp , & hc -> tx_av_chunks , node ) {
514458 /* go through this ack vector */
515- while (veclen -- ) {
516- u64 ackno_end_rl = SUB48 (ackno , dccp_ackvec_runlen (vector ));
459+ for (; avp -> len -- ; avp -> vec ++ ) {
460+ u64 ackno_end_rl = SUB48 (ackno ,
461+ dccp_ackvec_runlen (avp -> vec ));
517462
518- ccid2_pr_debug ("ackvec start: %llu end:%llu \n" ,
463+ ccid2_pr_debug ("ackvec %llu |%u,%u| \n" ,
519464 (unsigned long long )ackno ,
520- (unsigned long long )ackno_end_rl );
465+ dccp_ackvec_state (avp -> vec ) >> 6 ,
466+ dccp_ackvec_runlen (avp -> vec ));
521467 /* if the seqno we are analyzing is larger than the
522468 * current ackno, then move towards the tail of our
523469 * seqnos.
@@ -536,7 +482,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
536482 * run length
537483 */
538484 while (between48 (seqp -> ccid2s_seq ,ackno_end_rl ,ackno )) {
539- const u8 state = dccp_ackvec_state (vector );
485+ const u8 state = dccp_ackvec_state (avp -> vec );
540486
541487 /* new packet received or marked */
542488 if (state != DCCPAV_NOT_RECEIVED &&
@@ -563,7 +509,6 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
563509 break ;
564510
565511 ackno = SUB48 (ackno_end_rl , 1 );
566- vector ++ ;
567512 }
568513 if (done )
569514 break ;
@@ -631,10 +576,11 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
631576 sk_stop_timer (sk , & hc -> tx_rtotimer );
632577 else
633578 sk_reset_timer (sk , & hc -> tx_rtotimer , jiffies + hc -> tx_rto );
634-
579+ done :
635580 /* check if incoming Acks allow pending packets to be sent */
636581 if (sender_was_blocked && !ccid2_cwnd_network_limited (hc ))
637582 tasklet_schedule (& dccp_sk (sk )-> dccps_xmitlet );
583+ dccp_ackvec_parsed_cleanup (& hc -> tx_av_chunks );
638584}
639585
640586static int ccid2_hc_tx_init (struct ccid * ccid , struct sock * sk )
@@ -663,6 +609,7 @@ static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk)
663609 hc -> tx_last_cong = ccid2_time_stamp ;
664610 setup_timer (& hc -> tx_rtotimer , ccid2_hc_tx_rto_expire ,
665611 (unsigned long )sk );
612+ INIT_LIST_HEAD (& hc -> tx_av_chunks );
666613 return 0 ;
667614}
668615
@@ -696,16 +643,17 @@ static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
696643}
697644
698645struct ccid_operations ccid2_ops = {
699- .ccid_id = DCCPC_CCID2 ,
700- .ccid_name = "TCP-like" ,
701- .ccid_hc_tx_obj_size = sizeof (struct ccid2_hc_tx_sock ),
702- .ccid_hc_tx_init = ccid2_hc_tx_init ,
703- .ccid_hc_tx_exit = ccid2_hc_tx_exit ,
704- .ccid_hc_tx_send_packet = ccid2_hc_tx_send_packet ,
705- .ccid_hc_tx_packet_sent = ccid2_hc_tx_packet_sent ,
706- .ccid_hc_tx_packet_recv = ccid2_hc_tx_packet_recv ,
707- .ccid_hc_rx_obj_size = sizeof (struct ccid2_hc_rx_sock ),
708- .ccid_hc_rx_packet_recv = ccid2_hc_rx_packet_recv ,
646+ .ccid_id = DCCPC_CCID2 ,
647+ .ccid_name = "TCP-like" ,
648+ .ccid_hc_tx_obj_size = sizeof (struct ccid2_hc_tx_sock ),
649+ .ccid_hc_tx_init = ccid2_hc_tx_init ,
650+ .ccid_hc_tx_exit = ccid2_hc_tx_exit ,
651+ .ccid_hc_tx_send_packet = ccid2_hc_tx_send_packet ,
652+ .ccid_hc_tx_packet_sent = ccid2_hc_tx_packet_sent ,
653+ .ccid_hc_tx_parse_options = ccid2_hc_tx_parse_options ,
654+ .ccid_hc_tx_packet_recv = ccid2_hc_tx_packet_recv ,
655+ .ccid_hc_rx_obj_size = sizeof (struct ccid2_hc_rx_sock ),
656+ .ccid_hc_rx_packet_recv = ccid2_hc_rx_packet_recv ,
709657};
710658
711659#ifdef CONFIG_IP_DCCP_CCID2_DEBUG
0 commit comments