Skip to content

Commit d83447f

Browse files
author
Gerrit Renker
committed
dccp ccid-2: Schedule Sync as out-of-band mechanism
The problem with Ack Vectors is that i) their length is variable and can in principle grow quite large, ii) it is hard to predict exactly how large they will be. Due to the second point it seems not a good idea to reduce the MPS; in particular when on average there is enough room for the Ack Vector and an increase in length is momentarily due to some burst loss, after which the Ack Vector returns to its normal/average length. The solution taken by this patch is to subtract a minimum-expected Ack Vector length from the MPS, and to defer any larger Ack Vectors onto a separate Sync - but only if indeed there is no space left on the skb. This patch provides the infrastructure to schedule Sync-packets for transporting (urgent) out-of-band data. Its signalling is quicker than scheduling an Ack, since it does not need to wait for new application data. Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
1 parent 1821946 commit d83447f

3 files changed

Lines changed: 37 additions & 4 deletions

File tree

‎include/linux/dccp.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ struct dccp_ackvec;
462462
* @dccps_hc_rx_insert_options - receiver wants to add options when acking
463463
* @dccps_hc_tx_insert_options - sender wants to add options when sending
464464
* @dccps_server_timewait - server holds timewait state on close (RFC 4340, 8.3)
465+
* @dccps_sync_scheduled - flag which signals "send out-of-band message soon"
465466
* @dccps_xmitlet - tasklet scheduled by the TX CCID to dequeue data packets
466467
* @dccps_xmit_timer - used by the TX CCID to delay sending (rate-based pacing)
467468
* @dccps_syn_rtt - RTT sample from Request/Response exchange (in usecs)
@@ -503,6 +504,7 @@ struct dccp_sock {
503504
__u8 dccps_hc_rx_insert_options:1;
504505
__u8 dccps_hc_tx_insert_options:1;
505506
__u8 dccps_server_timewait:1;
507+
__u8 dccps_sync_scheduled:1;
506508
struct tasklet_struct dccps_xmitlet;
507509
struct timer_list dccps_xmit_timer;
508510
};

‎net/dccp/options.c‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ static int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb)
427427
{
428428
struct dccp_sock *dp = dccp_sk(sk);
429429
struct dccp_ackvec *av = dp->dccps_hc_rx_ackvec;
430+
struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
430431
const u16 buflen = dccp_ackvec_buflen(av);
431432
/* Figure out how many options do we need to represent the ackvec */
432433
const u8 nr_opts = DIV_ROUND_UP(buflen, DCCP_SINGLE_OPT_MAXLEN);
@@ -435,10 +436,25 @@ static int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb)
435436
const unsigned char *tail, *from;
436437
unsigned char *to;
437438

438-
if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN)
439+
if (dcb->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) {
440+
DCCP_WARN("Lacking space for %u bytes on %s packet\n", len,
441+
dccp_packet_name(dcb->dccpd_type));
439442
return -1;
440-
441-
DCCP_SKB_CB(skb)->dccpd_opt_len += len;
443+
}
444+
/*
445+
* Since Ack Vectors are variable-length, we can not always predict
446+
* their size. To catch exception cases where the space is running out
447+
* on the skb, a separate Sync is scheduled to carry the Ack Vector.
448+
*/
449+
if (len > DCCPAV_MIN_OPTLEN &&
450+
len + dcb->dccpd_opt_len + skb->len > dp->dccps_mss_cache) {
451+
DCCP_WARN("No space left for Ack Vector (%u) on skb (%u+%u), "
452+
"MPS=%u ==> reduce payload size?\n", len, skb->len,
453+
dcb->dccpd_opt_len, dp->dccps_mss_cache);
454+
dp->dccps_sync_scheduled = 1;
455+
return 0;
456+
}
457+
dcb->dccpd_opt_len += len;
442458

443459
to = skb_push(skb, len);
444460
len = buflen;
@@ -479,7 +495,7 @@ static int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb)
479495
/*
480496
* Each sent Ack Vector is recorded in the list, as per A.2 of RFC 4340.
481497
*/
482-
if (dccp_ackvec_update_records(av, DCCP_SKB_CB(skb)->dccpd_seq, nonce))
498+
if (dccp_ackvec_update_records(av, dcb->dccpd_seq, nonce))
483499
return -ENOBUFS;
484500
return 0;
485501
}

‎net/dccp/output.c‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,15 @@ static void dccp_xmit_packet(struct sock *sk)
283283
* any local drop will eventually be reported via receiver feedback.
284284
*/
285285
ccid_hc_tx_packet_sent(dp->dccps_hc_tx_ccid, sk, len);
286+
287+
/*
288+
* If the CCID needs to transfer additional header options out-of-band
289+
* (e.g. Ack Vectors or feature-negotiation options), it activates this
290+
* flag to schedule a Sync. The Sync will automatically incorporate all
291+
* currently pending header options, thus clearing the backlog.
292+
*/
293+
if (dp->dccps_sync_scheduled)
294+
dccp_send_sync(sk, dp->dccps_gsr, DCCP_PKT_SYNC);
286295
}
287296

288297
/**
@@ -636,6 +645,12 @@ void dccp_send_sync(struct sock *sk, const u64 ackno,
636645
DCCP_SKB_CB(skb)->dccpd_type = pkt_type;
637646
DCCP_SKB_CB(skb)->dccpd_ack_seq = ackno;
638647

648+
/*
649+
* Clear the flag in case the Sync was scheduled for out-of-band data,
650+
* such as carrying a long Ack Vector.
651+
*/
652+
dccp_sk(sk)->dccps_sync_scheduled = 0;
653+
639654
dccp_transmit_skb(sk, skb);
640655
}
641656

0 commit comments

Comments
 (0)