Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  *  net/dccp/options.c
0004  *
0005  *  An implementation of the DCCP protocol
0006  *  Copyright (c) 2005 Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org>
0007  *  Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
0008  *  Copyright (c) 2005 Ian McDonald <ian.mcdonald@jandi.co.nz>
0009  */
0010 #include <linux/dccp.h>
0011 #include <linux/module.h>
0012 #include <linux/types.h>
0013 #include <asm/unaligned.h>
0014 #include <linux/kernel.h>
0015 #include <linux/skbuff.h>
0016 
0017 #include "ackvec.h"
0018 #include "ccid.h"
0019 #include "dccp.h"
0020 #include "feat.h"
0021 
0022 u64 dccp_decode_value_var(const u8 *bf, const u8 len)
0023 {
0024     u64 value = 0;
0025 
0026     if (len >= DCCP_OPTVAL_MAXLEN)
0027         value += ((u64)*bf++) << 40;
0028     if (len > 4)
0029         value += ((u64)*bf++) << 32;
0030     if (len > 3)
0031         value += ((u64)*bf++) << 24;
0032     if (len > 2)
0033         value += ((u64)*bf++) << 16;
0034     if (len > 1)
0035         value += ((u64)*bf++) << 8;
0036     if (len > 0)
0037         value += *bf;
0038 
0039     return value;
0040 }
0041 
0042 /**
0043  * dccp_parse_options  -  Parse DCCP options present in @skb
0044  * @sk: client|server|listening dccp socket (when @dreq != NULL)
0045  * @dreq: request socket to use during connection setup, or NULL
0046  * @skb: frame to parse
0047  */
0048 int dccp_parse_options(struct sock *sk, struct dccp_request_sock *dreq,
0049                struct sk_buff *skb)
0050 {
0051     struct dccp_sock *dp = dccp_sk(sk);
0052     const struct dccp_hdr *dh = dccp_hdr(skb);
0053     const u8 pkt_type = DCCP_SKB_CB(skb)->dccpd_type;
0054     unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb);
0055     unsigned char *opt_ptr = options;
0056     const unsigned char *opt_end = (unsigned char *)dh +
0057                     (dh->dccph_doff * 4);
0058     struct dccp_options_received *opt_recv = &dp->dccps_options_received;
0059     unsigned char opt, len;
0060     unsigned char *value;
0061     u32 elapsed_time;
0062     __be32 opt_val;
0063     int rc;
0064     int mandatory = 0;
0065 
0066     memset(opt_recv, 0, sizeof(*opt_recv));
0067 
0068     opt = len = 0;
0069     while (opt_ptr != opt_end) {
0070         opt   = *opt_ptr++;
0071         len   = 0;
0072         value = NULL;
0073 
0074         /* Check if this isn't a single byte option */
0075         if (opt > DCCPO_MAX_RESERVED) {
0076             if (opt_ptr == opt_end)
0077                 goto out_nonsensical_length;
0078 
0079             len = *opt_ptr++;
0080             if (len < 2)
0081                 goto out_nonsensical_length;
0082             /*
0083              * Remove the type and len fields, leaving
0084              * just the value size
0085              */
0086             len -= 2;
0087             value   = opt_ptr;
0088             opt_ptr += len;
0089 
0090             if (opt_ptr > opt_end)
0091                 goto out_nonsensical_length;
0092         }
0093 
0094         /*
0095          * CCID-specific options are ignored during connection setup, as
0096          * negotiation may still be in progress (see RFC 4340, 10.3).
0097          * The same applies to Ack Vectors, as these depend on the CCID.
0098          */
0099         if (dreq != NULL && (opt >= DCCPO_MIN_RX_CCID_SPECIFIC ||
0100             opt == DCCPO_ACK_VECTOR_0 || opt == DCCPO_ACK_VECTOR_1))
0101             goto ignore_option;
0102 
0103         switch (opt) {
0104         case DCCPO_PADDING:
0105             break;
0106         case DCCPO_MANDATORY:
0107             if (mandatory)
0108                 goto out_invalid_option;
0109             if (pkt_type != DCCP_PKT_DATA)
0110                 mandatory = 1;
0111             break;
0112         case DCCPO_NDP_COUNT:
0113             if (len > 6)
0114                 goto out_invalid_option;
0115 
0116             opt_recv->dccpor_ndp = dccp_decode_value_var(value, len);
0117             dccp_pr_debug("%s opt: NDP count=%llu\n", dccp_role(sk),
0118                       (unsigned long long)opt_recv->dccpor_ndp);
0119             break;
0120         case DCCPO_CHANGE_L ... DCCPO_CONFIRM_R:
0121             if (pkt_type == DCCP_PKT_DATA)      /* RFC 4340, 6 */
0122                 break;
0123             if (len == 0)
0124                 goto out_invalid_option;
0125             rc = dccp_feat_parse_options(sk, dreq, mandatory, opt,
0126                             *value, value + 1, len - 1);
0127             if (rc)
0128                 goto out_featneg_failed;
0129             break;
0130         case DCCPO_TIMESTAMP:
0131             if (len != 4)
0132                 goto out_invalid_option;
0133             /*
0134              * RFC 4340 13.1: "The precise time corresponding to
0135              * Timestamp Value zero is not specified". We use
0136              * zero to indicate absence of a meaningful timestamp.
0137              */
0138             opt_val = get_unaligned((__be32 *)value);
0139             if (unlikely(opt_val == 0)) {
0140                 DCCP_WARN("Timestamp with zero value\n");
0141                 break;
0142             }
0143 
0144             if (dreq != NULL) {
0145                 dreq->dreq_timestamp_echo = ntohl(opt_val);
0146                 dreq->dreq_timestamp_time = dccp_timestamp();
0147             } else {
0148                 opt_recv->dccpor_timestamp =
0149                     dp->dccps_timestamp_echo = ntohl(opt_val);
0150                 dp->dccps_timestamp_time = dccp_timestamp();
0151             }
0152             dccp_pr_debug("%s rx opt: TIMESTAMP=%u, ackno=%llu\n",
0153                       dccp_role(sk), ntohl(opt_val),
0154                       (unsigned long long)
0155                       DCCP_SKB_CB(skb)->dccpd_ack_seq);
0156             /* schedule an Ack in case this sender is quiescent */
0157             inet_csk_schedule_ack(sk);
0158             break;
0159         case DCCPO_TIMESTAMP_ECHO:
0160             if (len != 4 && len != 6 && len != 8)
0161                 goto out_invalid_option;
0162 
0163             opt_val = get_unaligned((__be32 *)value);
0164             opt_recv->dccpor_timestamp_echo = ntohl(opt_val);
0165 
0166             dccp_pr_debug("%s rx opt: TIMESTAMP_ECHO=%u, len=%d, "
0167                       "ackno=%llu", dccp_role(sk),
0168                       opt_recv->dccpor_timestamp_echo,
0169                       len + 2,
0170                       (unsigned long long)
0171                       DCCP_SKB_CB(skb)->dccpd_ack_seq);
0172 
0173             value += 4;
0174 
0175             if (len == 4) {     /* no elapsed time included */
0176                 dccp_pr_debug_cat("\n");
0177                 break;
0178             }
0179 
0180             if (len == 6) {     /* 2-byte elapsed time */
0181                 __be16 opt_val2 = get_unaligned((__be16 *)value);
0182                 elapsed_time = ntohs(opt_val2);
0183             } else {        /* 4-byte elapsed time */
0184                 opt_val = get_unaligned((__be32 *)value);
0185                 elapsed_time = ntohl(opt_val);
0186             }
0187 
0188             dccp_pr_debug_cat(", ELAPSED_TIME=%u\n", elapsed_time);
0189 
0190             /* Give precedence to the biggest ELAPSED_TIME */
0191             if (elapsed_time > opt_recv->dccpor_elapsed_time)
0192                 opt_recv->dccpor_elapsed_time = elapsed_time;
0193             break;
0194         case DCCPO_ELAPSED_TIME:
0195             if (dccp_packet_without_ack(skb))   /* RFC 4340, 13.2 */
0196                 break;
0197 
0198             if (len == 2) {
0199                 __be16 opt_val2 = get_unaligned((__be16 *)value);
0200                 elapsed_time = ntohs(opt_val2);
0201             } else if (len == 4) {
0202                 opt_val = get_unaligned((__be32 *)value);
0203                 elapsed_time = ntohl(opt_val);
0204             } else {
0205                 goto out_invalid_option;
0206             }
0207 
0208             if (elapsed_time > opt_recv->dccpor_elapsed_time)
0209                 opt_recv->dccpor_elapsed_time = elapsed_time;
0210 
0211             dccp_pr_debug("%s rx opt: ELAPSED_TIME=%d\n",
0212                       dccp_role(sk), elapsed_time);
0213             break;
0214         case DCCPO_MIN_RX_CCID_SPECIFIC ... DCCPO_MAX_RX_CCID_SPECIFIC:
0215             if (ccid_hc_rx_parse_options(dp->dccps_hc_rx_ccid, sk,
0216                              pkt_type, opt, value, len))
0217                 goto out_invalid_option;
0218             break;
0219         case DCCPO_ACK_VECTOR_0:
0220         case DCCPO_ACK_VECTOR_1:
0221             if (dccp_packet_without_ack(skb))   /* RFC 4340, 11.4 */
0222                 break;
0223             /*
0224              * Ack vectors are processed by the TX CCID if it is
0225              * interested. The RX CCID need not parse Ack Vectors,
0226              * since it is only interested in clearing old state.
0227              */
0228             fallthrough;
0229         case DCCPO_MIN_TX_CCID_SPECIFIC ... DCCPO_MAX_TX_CCID_SPECIFIC:
0230             if (ccid_hc_tx_parse_options(dp->dccps_hc_tx_ccid, sk,
0231                              pkt_type, opt, value, len))
0232                 goto out_invalid_option;
0233             break;
0234         default:
0235             DCCP_CRIT("DCCP(%p): option %d(len=%d) not "
0236                   "implemented, ignoring", sk, opt, len);
0237             break;
0238         }
0239 ignore_option:
0240         if (opt != DCCPO_MANDATORY)
0241             mandatory = 0;
0242     }
0243 
0244     /* mandatory was the last byte in option list -> reset connection */
0245     if (mandatory)
0246         goto out_invalid_option;
0247 
0248 out_nonsensical_length:
0249     /* RFC 4340, 5.8: ignore option and all remaining option space */
0250     return 0;
0251 
0252 out_invalid_option:
0253     DCCP_INC_STATS(DCCP_MIB_INVALIDOPT);
0254     rc = DCCP_RESET_CODE_OPTION_ERROR;
0255 out_featneg_failed:
0256     DCCP_WARN("DCCP(%p): Option %d (len=%d) error=%u\n", sk, opt, len, rc);
0257     DCCP_SKB_CB(skb)->dccpd_reset_code = rc;
0258     DCCP_SKB_CB(skb)->dccpd_reset_data[0] = opt;
0259     DCCP_SKB_CB(skb)->dccpd_reset_data[1] = len > 0 ? value[0] : 0;
0260     DCCP_SKB_CB(skb)->dccpd_reset_data[2] = len > 1 ? value[1] : 0;
0261     return -1;
0262 }
0263 
0264 EXPORT_SYMBOL_GPL(dccp_parse_options);
0265 
0266 void dccp_encode_value_var(const u64 value, u8 *to, const u8 len)
0267 {
0268     if (len >= DCCP_OPTVAL_MAXLEN)
0269         *to++ = (value & 0xFF0000000000ull) >> 40;
0270     if (len > 4)
0271         *to++ = (value & 0xFF00000000ull) >> 32;
0272     if (len > 3)
0273         *to++ = (value & 0xFF000000) >> 24;
0274     if (len > 2)
0275         *to++ = (value & 0xFF0000) >> 16;
0276     if (len > 1)
0277         *to++ = (value & 0xFF00) >> 8;
0278     if (len > 0)
0279         *to++ = (value & 0xFF);
0280 }
0281 
0282 static inline u8 dccp_ndp_len(const u64 ndp)
0283 {
0284     if (likely(ndp <= 0xFF))
0285         return 1;
0286     return likely(ndp <= USHRT_MAX) ? 2 : (ndp <= UINT_MAX ? 4 : 6);
0287 }
0288 
0289 int dccp_insert_option(struct sk_buff *skb, const unsigned char option,
0290                const void *value, const unsigned char len)
0291 {
0292     unsigned char *to;
0293 
0294     if (DCCP_SKB_CB(skb)->dccpd_opt_len + len + 2 > DCCP_MAX_OPT_LEN)
0295         return -1;
0296 
0297     DCCP_SKB_CB(skb)->dccpd_opt_len += len + 2;
0298 
0299     to    = skb_push(skb, len + 2);
0300     *to++ = option;
0301     *to++ = len + 2;
0302 
0303     memcpy(to, value, len);
0304     return 0;
0305 }
0306 
0307 EXPORT_SYMBOL_GPL(dccp_insert_option);
0308 
0309 static int dccp_insert_option_ndp(struct sock *sk, struct sk_buff *skb)
0310 {
0311     struct dccp_sock *dp = dccp_sk(sk);
0312     u64 ndp = dp->dccps_ndp_count;
0313 
0314     if (dccp_non_data_packet(skb))
0315         ++dp->dccps_ndp_count;
0316     else
0317         dp->dccps_ndp_count = 0;
0318 
0319     if (ndp > 0) {
0320         unsigned char *ptr;
0321         const int ndp_len = dccp_ndp_len(ndp);
0322         const int len = ndp_len + 2;
0323 
0324         if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN)
0325             return -1;
0326 
0327         DCCP_SKB_CB(skb)->dccpd_opt_len += len;
0328 
0329         ptr = skb_push(skb, len);
0330         *ptr++ = DCCPO_NDP_COUNT;
0331         *ptr++ = len;
0332         dccp_encode_value_var(ndp, ptr, ndp_len);
0333     }
0334 
0335     return 0;
0336 }
0337 
0338 static inline int dccp_elapsed_time_len(const u32 elapsed_time)
0339 {
0340     return elapsed_time == 0 ? 0 : elapsed_time <= 0xFFFF ? 2 : 4;
0341 }
0342 
0343 static int dccp_insert_option_timestamp(struct sk_buff *skb)
0344 {
0345     __be32 now = htonl(dccp_timestamp());
0346     /* yes this will overflow but that is the point as we want a
0347      * 10 usec 32 bit timer which mean it wraps every 11.9 hours */
0348 
0349     return dccp_insert_option(skb, DCCPO_TIMESTAMP, &now, sizeof(now));
0350 }
0351 
0352 static int dccp_insert_option_timestamp_echo(struct dccp_sock *dp,
0353                          struct dccp_request_sock *dreq,
0354                          struct sk_buff *skb)
0355 {
0356     __be32 tstamp_echo;
0357     unsigned char *to;
0358     u32 elapsed_time, elapsed_time_len, len;
0359 
0360     if (dreq != NULL) {
0361         elapsed_time = dccp_timestamp() - dreq->dreq_timestamp_time;
0362         tstamp_echo  = htonl(dreq->dreq_timestamp_echo);
0363         dreq->dreq_timestamp_echo = 0;
0364     } else {
0365         elapsed_time = dccp_timestamp() - dp->dccps_timestamp_time;
0366         tstamp_echo  = htonl(dp->dccps_timestamp_echo);
0367         dp->dccps_timestamp_echo = 0;
0368     }
0369 
0370     elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
0371     len = 6 + elapsed_time_len;
0372 
0373     if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN)
0374         return -1;
0375 
0376     DCCP_SKB_CB(skb)->dccpd_opt_len += len;
0377 
0378     to    = skb_push(skb, len);
0379     *to++ = DCCPO_TIMESTAMP_ECHO;
0380     *to++ = len;
0381 
0382     memcpy(to, &tstamp_echo, 4);
0383     to += 4;
0384 
0385     if (elapsed_time_len == 2) {
0386         const __be16 var16 = htons((u16)elapsed_time);
0387         memcpy(to, &var16, 2);
0388     } else if (elapsed_time_len == 4) {
0389         const __be32 var32 = htonl(elapsed_time);
0390         memcpy(to, &var32, 4);
0391     }
0392 
0393     return 0;
0394 }
0395 
0396 static int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb)
0397 {
0398     struct dccp_sock *dp = dccp_sk(sk);
0399     struct dccp_ackvec *av = dp->dccps_hc_rx_ackvec;
0400     struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
0401     const u16 buflen = dccp_ackvec_buflen(av);
0402     /* Figure out how many options do we need to represent the ackvec */
0403     const u8 nr_opts = DIV_ROUND_UP(buflen, DCCP_SINGLE_OPT_MAXLEN);
0404     u16 len = buflen + 2 * nr_opts;
0405     u8 i, nonce = 0;
0406     const unsigned char *tail, *from;
0407     unsigned char *to;
0408 
0409     if (dcb->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) {
0410         DCCP_WARN("Lacking space for %u bytes on %s packet\n", len,
0411               dccp_packet_name(dcb->dccpd_type));
0412         return -1;
0413     }
0414     /*
0415      * Since Ack Vectors are variable-length, we can not always predict
0416      * their size. To catch exception cases where the space is running out
0417      * on the skb, a separate Sync is scheduled to carry the Ack Vector.
0418      */
0419     if (len > DCCPAV_MIN_OPTLEN &&
0420         len + dcb->dccpd_opt_len + skb->len > dp->dccps_mss_cache) {
0421         DCCP_WARN("No space left for Ack Vector (%u) on skb (%u+%u), "
0422               "MPS=%u ==> reduce payload size?\n", len, skb->len,
0423               dcb->dccpd_opt_len, dp->dccps_mss_cache);
0424         dp->dccps_sync_scheduled = 1;
0425         return 0;
0426     }
0427     dcb->dccpd_opt_len += len;
0428 
0429     to   = skb_push(skb, len);
0430     len  = buflen;
0431     from = av->av_buf + av->av_buf_head;
0432     tail = av->av_buf + DCCPAV_MAX_ACKVEC_LEN;
0433 
0434     for (i = 0; i < nr_opts; ++i) {
0435         int copylen = len;
0436 
0437         if (len > DCCP_SINGLE_OPT_MAXLEN)
0438             copylen = DCCP_SINGLE_OPT_MAXLEN;
0439 
0440         /*
0441          * RFC 4340, 12.2: Encode the Nonce Echo for this Ack Vector via
0442          * its type; ack_nonce is the sum of all individual buf_nonce's.
0443          */
0444         nonce ^= av->av_buf_nonce[i];
0445 
0446         *to++ = DCCPO_ACK_VECTOR_0 + av->av_buf_nonce[i];
0447         *to++ = copylen + 2;
0448 
0449         /* Check if buf_head wraps */
0450         if (from + copylen > tail) {
0451             const u16 tailsize = tail - from;
0452 
0453             memcpy(to, from, tailsize);
0454             to  += tailsize;
0455             len -= tailsize;
0456             copylen -= tailsize;
0457             from    = av->av_buf;
0458         }
0459 
0460         memcpy(to, from, copylen);
0461         from += copylen;
0462         to   += copylen;
0463         len  -= copylen;
0464     }
0465     /*
0466      * Each sent Ack Vector is recorded in the list, as per A.2 of RFC 4340.
0467      */
0468     if (dccp_ackvec_update_records(av, dcb->dccpd_seq, nonce))
0469         return -ENOBUFS;
0470     return 0;
0471 }
0472 
0473 /**
0474  * dccp_insert_option_mandatory  -  Mandatory option (5.8.2)
0475  * @skb: frame into which to insert option
0476  *
0477  * Note that since we are using skb_push, this function needs to be called
0478  * _after_ inserting the option it is supposed to influence (stack order).
0479  */
0480 int dccp_insert_option_mandatory(struct sk_buff *skb)
0481 {
0482     if (DCCP_SKB_CB(skb)->dccpd_opt_len >= DCCP_MAX_OPT_LEN)
0483         return -1;
0484 
0485     DCCP_SKB_CB(skb)->dccpd_opt_len++;
0486     *(u8 *)skb_push(skb, 1) = DCCPO_MANDATORY;
0487     return 0;
0488 }
0489 
0490 /**
0491  * dccp_insert_fn_opt  -  Insert single Feature-Negotiation option into @skb
0492  * @skb: frame to insert feature negotiation option into
0493  * @type: %DCCPO_CHANGE_L, %DCCPO_CHANGE_R, %DCCPO_CONFIRM_L, %DCCPO_CONFIRM_R
0494  * @feat: one out of %dccp_feature_numbers
0495  * @val: NN value or SP array (preferred element first) to copy
0496  * @len: true length of @val in bytes (excluding first element repetition)
0497  * @repeat_first: whether to copy the first element of @val twice
0498  *
0499  * The last argument is used to construct Confirm options, where the preferred
0500  * value and the preference list appear separately (RFC 4340, 6.3.1). Preference
0501  * lists are kept such that the preferred entry is always first, so we only need
0502  * to copy twice, and avoid the overhead of cloning into a bigger array.
0503  */
0504 int dccp_insert_fn_opt(struct sk_buff *skb, u8 type, u8 feat,
0505                u8 *val, u8 len, bool repeat_first)
0506 {
0507     u8 tot_len, *to;
0508 
0509     /* take the `Feature' field and possible repetition into account */
0510     if (len > (DCCP_SINGLE_OPT_MAXLEN - 2)) {
0511         DCCP_WARN("length %u for feature %u too large\n", len, feat);
0512         return -1;
0513     }
0514 
0515     if (unlikely(val == NULL || len == 0))
0516         len = repeat_first = false;
0517     tot_len = 3 + repeat_first + len;
0518 
0519     if (DCCP_SKB_CB(skb)->dccpd_opt_len + tot_len > DCCP_MAX_OPT_LEN) {
0520         DCCP_WARN("packet too small for feature %d option!\n", feat);
0521         return -1;
0522     }
0523     DCCP_SKB_CB(skb)->dccpd_opt_len += tot_len;
0524 
0525     to    = skb_push(skb, tot_len);
0526     *to++ = type;
0527     *to++ = tot_len;
0528     *to++ = feat;
0529 
0530     if (repeat_first)
0531         *to++ = *val;
0532     if (len)
0533         memcpy(to, val, len);
0534     return 0;
0535 }
0536 
0537 /* The length of all options needs to be a multiple of 4 (5.8) */
0538 static void dccp_insert_option_padding(struct sk_buff *skb)
0539 {
0540     int padding = DCCP_SKB_CB(skb)->dccpd_opt_len % 4;
0541 
0542     if (padding != 0) {
0543         padding = 4 - padding;
0544         memset(skb_push(skb, padding), 0, padding);
0545         DCCP_SKB_CB(skb)->dccpd_opt_len += padding;
0546     }
0547 }
0548 
0549 int dccp_insert_options(struct sock *sk, struct sk_buff *skb)
0550 {
0551     struct dccp_sock *dp = dccp_sk(sk);
0552 
0553     DCCP_SKB_CB(skb)->dccpd_opt_len = 0;
0554 
0555     if (dp->dccps_send_ndp_count && dccp_insert_option_ndp(sk, skb))
0556         return -1;
0557 
0558     if (DCCP_SKB_CB(skb)->dccpd_type != DCCP_PKT_DATA) {
0559 
0560         /* Feature Negotiation */
0561         if (dccp_feat_insert_opts(dp, NULL, skb))
0562             return -1;
0563 
0564         if (DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_REQUEST) {
0565             /*
0566              * Obtain RTT sample from Request/Response exchange.
0567              * This is currently used for TFRC initialisation.
0568              */
0569             if (dccp_insert_option_timestamp(skb))
0570                 return -1;
0571 
0572         } else if (dccp_ackvec_pending(sk) &&
0573                dccp_insert_option_ackvec(sk, skb)) {
0574                 return -1;
0575         }
0576     }
0577 
0578     if (dp->dccps_hc_rx_insert_options) {
0579         if (ccid_hc_rx_insert_options(dp->dccps_hc_rx_ccid, sk, skb))
0580             return -1;
0581         dp->dccps_hc_rx_insert_options = 0;
0582     }
0583 
0584     if (dp->dccps_timestamp_echo != 0 &&
0585         dccp_insert_option_timestamp_echo(dp, NULL, skb))
0586         return -1;
0587 
0588     dccp_insert_option_padding(skb);
0589     return 0;
0590 }
0591 
0592 int dccp_insert_options_rsk(struct dccp_request_sock *dreq, struct sk_buff *skb)
0593 {
0594     DCCP_SKB_CB(skb)->dccpd_opt_len = 0;
0595 
0596     if (dccp_feat_insert_opts(NULL, dreq, skb))
0597         return -1;
0598 
0599     /* Obtain RTT sample from Response/Ack exchange (used by TFRC). */
0600     if (dccp_insert_option_timestamp(skb))
0601         return -1;
0602 
0603     if (dreq->dreq_timestamp_echo != 0 &&
0604         dccp_insert_option_timestamp_echo(NULL, dreq, skb))
0605         return -1;
0606 
0607     dccp_insert_option_padding(skb);
0608     return 0;
0609 }