options.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. /*
  2. * net/dccp/options.c
  3. *
  4. * An implementation of the DCCP protocol
  5. * Copyright (c) 2005 Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org>
  6. * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
  7. * Copyright (c) 2005 Ian McDonald <ian.mcdonald@jandi.co.nz>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. */
  14. #include <linux/dccp.h>
  15. #include <linux/module.h>
  16. #include <linux/types.h>
  17. #include <asm/unaligned.h>
  18. #include <linux/kernel.h>
  19. #include <linux/skbuff.h>
  20. #include "ackvec.h"
  21. #include "ccid.h"
  22. #include "dccp.h"
  23. #include "feat.h"
  24. int sysctl_dccp_feat_sequence_window = DCCPF_INITIAL_SEQUENCE_WINDOW;
  25. int sysctl_dccp_feat_rx_ccid = DCCPF_INITIAL_CCID;
  26. int sysctl_dccp_feat_tx_ccid = DCCPF_INITIAL_CCID;
  27. int sysctl_dccp_feat_send_ack_vector = DCCPF_INITIAL_SEND_ACK_VECTOR;
  28. int sysctl_dccp_feat_send_ndp_count = DCCPF_INITIAL_SEND_NDP_COUNT;
  29. u64 dccp_decode_value_var(const u8 *bf, const u8 len)
  30. {
  31. u64 value = 0;
  32. if (len >= DCCP_OPTVAL_MAXLEN)
  33. value += ((u64)*bf++) << 40;
  34. if (len > 4)
  35. value += ((u64)*bf++) << 32;
  36. if (len > 3)
  37. value += ((u64)*bf++) << 24;
  38. if (len > 2)
  39. value += ((u64)*bf++) << 16;
  40. if (len > 1)
  41. value += ((u64)*bf++) << 8;
  42. if (len > 0)
  43. value += *bf;
  44. return value;
  45. }
  46. /**
  47. * dccp_parse_options - Parse DCCP options present in @skb
  48. * @sk: client|server|listening dccp socket (when @dreq != NULL)
  49. * @dreq: request socket to use during connection setup, or NULL
  50. */
  51. int dccp_parse_options(struct sock *sk, struct dccp_request_sock *dreq,
  52. struct sk_buff *skb)
  53. {
  54. struct dccp_sock *dp = dccp_sk(sk);
  55. const struct dccp_hdr *dh = dccp_hdr(skb);
  56. const u8 pkt_type = DCCP_SKB_CB(skb)->dccpd_type;
  57. u64 ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq;
  58. unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb);
  59. unsigned char *opt_ptr = options;
  60. const unsigned char *opt_end = (unsigned char *)dh +
  61. (dh->dccph_doff * 4);
  62. struct dccp_options_received *opt_recv = &dp->dccps_options_received;
  63. unsigned char opt, len;
  64. unsigned char *uninitialized_var(value);
  65. u32 elapsed_time;
  66. __be32 opt_val;
  67. int rc;
  68. int mandatory = 0;
  69. memset(opt_recv, 0, sizeof(*opt_recv));
  70. opt = len = 0;
  71. while (opt_ptr != opt_end) {
  72. opt = *opt_ptr++;
  73. len = 0;
  74. value = NULL;
  75. /* Check if this isn't a single byte option */
  76. if (opt > DCCPO_MAX_RESERVED) {
  77. if (opt_ptr == opt_end)
  78. goto out_nonsensical_length;
  79. len = *opt_ptr++;
  80. if (len < 2)
  81. goto out_nonsensical_length;
  82. /*
  83. * Remove the type and len fields, leaving
  84. * just the value size
  85. */
  86. len -= 2;
  87. value = opt_ptr;
  88. opt_ptr += len;
  89. if (opt_ptr > opt_end)
  90. goto out_nonsensical_length;
  91. }
  92. /*
  93. * CCID-Specific Options (from RFC 4340, sec. 10.3):
  94. *
  95. * Option numbers 128 through 191 are for options sent from the
  96. * HC-Sender to the HC-Receiver; option numbers 192 through 255
  97. * are for options sent from the HC-Receiver to the HC-Sender.
  98. *
  99. * CCID-specific options are ignored during connection setup, as
  100. * negotiation may still be in progress (see RFC 4340, 10.3).
  101. * The same applies to Ack Vectors, as these depend on the CCID.
  102. *
  103. */
  104. if (dreq != NULL && (opt >= 128 ||
  105. opt == DCCPO_ACK_VECTOR_0 || opt == DCCPO_ACK_VECTOR_1))
  106. goto ignore_option;
  107. switch (opt) {
  108. case DCCPO_PADDING:
  109. break;
  110. case DCCPO_MANDATORY:
  111. if (mandatory)
  112. goto out_invalid_option;
  113. if (pkt_type != DCCP_PKT_DATA)
  114. mandatory = 1;
  115. break;
  116. case DCCPO_NDP_COUNT:
  117. if (len > 6)
  118. goto out_invalid_option;
  119. opt_recv->dccpor_ndp = dccp_decode_value_var(value, len);
  120. dccp_pr_debug("%s opt: NDP count=%llu\n", dccp_role(sk),
  121. (unsigned long long)opt_recv->dccpor_ndp);
  122. break;
  123. case DCCPO_CHANGE_L:
  124. case DCCPO_CHANGE_R:
  125. if (pkt_type == DCCP_PKT_DATA)
  126. break;
  127. rc = dccp_feat_parse_options(sk, dreq, mandatory, opt,
  128. *value, value + 1, len - 1);
  129. if (rc)
  130. goto out_featneg_failed;
  131. break;
  132. case DCCPO_CONFIRM_L:
  133. /* fall through */
  134. case DCCPO_CONFIRM_R:
  135. if (pkt_type == DCCP_PKT_DATA)
  136. break;
  137. if (len < 2) /* FIXME this disallows empty confirm */
  138. goto out_invalid_option;
  139. if (dccp_feat_confirm_recv(sk, opt, *value,
  140. value + 1, len - 1))
  141. goto out_invalid_option;
  142. break;
  143. case DCCPO_ACK_VECTOR_0:
  144. case DCCPO_ACK_VECTOR_1:
  145. if (dccp_packet_without_ack(skb)) /* RFC 4340, 11.4 */
  146. break;
  147. if (dccp_msk(sk)->dccpms_send_ack_vector &&
  148. dccp_ackvec_parse(sk, skb, &ackno, opt, value, len))
  149. goto out_invalid_option;
  150. break;
  151. case DCCPO_TIMESTAMP:
  152. if (len != 4)
  153. goto out_invalid_option;
  154. /*
  155. * RFC 4340 13.1: "The precise time corresponding to
  156. * Timestamp Value zero is not specified". We use
  157. * zero to indicate absence of a meaningful timestamp.
  158. */
  159. opt_val = get_unaligned((__be32 *)value);
  160. if (unlikely(opt_val == 0)) {
  161. DCCP_WARN("Timestamp with zero value\n");
  162. break;
  163. }
  164. if (dreq != NULL) {
  165. dreq->dreq_timestamp_echo = ntohl(opt_val);
  166. dreq->dreq_timestamp_time = dccp_timestamp();
  167. } else {
  168. opt_recv->dccpor_timestamp =
  169. dp->dccps_timestamp_echo = ntohl(opt_val);
  170. dp->dccps_timestamp_time = dccp_timestamp();
  171. }
  172. dccp_pr_debug("%s rx opt: TIMESTAMP=%u, ackno=%llu\n",
  173. dccp_role(sk), ntohl(opt_val),
  174. (unsigned long long)
  175. DCCP_SKB_CB(skb)->dccpd_ack_seq);
  176. break;
  177. case DCCPO_TIMESTAMP_ECHO:
  178. if (len != 4 && len != 6 && len != 8)
  179. goto out_invalid_option;
  180. opt_val = get_unaligned((__be32 *)value);
  181. opt_recv->dccpor_timestamp_echo = ntohl(opt_val);
  182. dccp_pr_debug("%s rx opt: TIMESTAMP_ECHO=%u, len=%d, "
  183. "ackno=%llu", dccp_role(sk),
  184. opt_recv->dccpor_timestamp_echo,
  185. len + 2,
  186. (unsigned long long)
  187. DCCP_SKB_CB(skb)->dccpd_ack_seq);
  188. value += 4;
  189. if (len == 4) { /* no elapsed time included */
  190. dccp_pr_debug_cat("\n");
  191. break;
  192. }
  193. if (len == 6) { /* 2-byte elapsed time */
  194. __be16 opt_val2 = get_unaligned((__be16 *)value);
  195. elapsed_time = ntohs(opt_val2);
  196. } else { /* 4-byte elapsed time */
  197. opt_val = get_unaligned((__be32 *)value);
  198. elapsed_time = ntohl(opt_val);
  199. }
  200. dccp_pr_debug_cat(", ELAPSED_TIME=%u\n", elapsed_time);
  201. /* Give precedence to the biggest ELAPSED_TIME */
  202. if (elapsed_time > opt_recv->dccpor_elapsed_time)
  203. opt_recv->dccpor_elapsed_time = elapsed_time;
  204. break;
  205. case DCCPO_ELAPSED_TIME:
  206. if (dccp_packet_without_ack(skb)) /* RFC 4340, 13.2 */
  207. break;
  208. if (len == 2) {
  209. __be16 opt_val2 = get_unaligned((__be16 *)value);
  210. elapsed_time = ntohs(opt_val2);
  211. } else if (len == 4) {
  212. opt_val = get_unaligned((__be32 *)value);
  213. elapsed_time = ntohl(opt_val);
  214. } else {
  215. goto out_invalid_option;
  216. }
  217. if (elapsed_time > opt_recv->dccpor_elapsed_time)
  218. opt_recv->dccpor_elapsed_time = elapsed_time;
  219. dccp_pr_debug("%s rx opt: ELAPSED_TIME=%d\n",
  220. dccp_role(sk), elapsed_time);
  221. break;
  222. case 128 ... 191: {
  223. const u16 idx = value - options;
  224. if (ccid_hc_rx_parse_options(dp->dccps_hc_rx_ccid, sk,
  225. opt, len, idx,
  226. value) != 0)
  227. goto out_invalid_option;
  228. }
  229. break;
  230. case 192 ... 255: {
  231. const u16 idx = value - options;
  232. if (ccid_hc_tx_parse_options(dp->dccps_hc_tx_ccid, sk,
  233. opt, len, idx,
  234. value) != 0)
  235. goto out_invalid_option;
  236. }
  237. break;
  238. default:
  239. DCCP_CRIT("DCCP(%p): option %d(len=%d) not "
  240. "implemented, ignoring", sk, opt, len);
  241. break;
  242. }
  243. ignore_option:
  244. if (opt != DCCPO_MANDATORY)
  245. mandatory = 0;
  246. }
  247. /* mandatory was the last byte in option list -> reset connection */
  248. if (mandatory)
  249. goto out_invalid_option;
  250. out_nonsensical_length:
  251. /* RFC 4340, 5.8: ignore option and all remaining option space */
  252. return 0;
  253. out_invalid_option:
  254. DCCP_INC_STATS_BH(DCCP_MIB_INVALIDOPT);
  255. rc = DCCP_RESET_CODE_OPTION_ERROR;
  256. out_featneg_failed:
  257. DCCP_WARN("DCCP(%p): Option %d (len=%d) error=%u\n", sk, opt, len, rc);
  258. DCCP_SKB_CB(skb)->dccpd_reset_code = rc;
  259. DCCP_SKB_CB(skb)->dccpd_reset_data[0] = opt;
  260. DCCP_SKB_CB(skb)->dccpd_reset_data[1] = len > 0 ? value[0] : 0;
  261. DCCP_SKB_CB(skb)->dccpd_reset_data[2] = len > 1 ? value[1] : 0;
  262. return -1;
  263. }
  264. EXPORT_SYMBOL_GPL(dccp_parse_options);
  265. void dccp_encode_value_var(const u64 value, u8 *to, const u8 len)
  266. {
  267. if (len >= DCCP_OPTVAL_MAXLEN)
  268. *to++ = (value & 0xFF0000000000ull) >> 40;
  269. if (len > 4)
  270. *to++ = (value & 0xFF00000000ull) >> 32;
  271. if (len > 3)
  272. *to++ = (value & 0xFF000000) >> 24;
  273. if (len > 2)
  274. *to++ = (value & 0xFF0000) >> 16;
  275. if (len > 1)
  276. *to++ = (value & 0xFF00) >> 8;
  277. if (len > 0)
  278. *to++ = (value & 0xFF);
  279. }
  280. static inline u8 dccp_ndp_len(const u64 ndp)
  281. {
  282. if (likely(ndp <= 0xFF))
  283. return 1;
  284. return likely(ndp <= USHORT_MAX) ? 2 : (ndp <= UINT_MAX ? 4 : 6);
  285. }
  286. int dccp_insert_option(struct sock *sk, struct sk_buff *skb,
  287. const unsigned char option,
  288. const void *value, const unsigned char len)
  289. {
  290. unsigned char *to;
  291. if (DCCP_SKB_CB(skb)->dccpd_opt_len + len + 2 > DCCP_MAX_OPT_LEN)
  292. return -1;
  293. DCCP_SKB_CB(skb)->dccpd_opt_len += len + 2;
  294. to = skb_push(skb, len + 2);
  295. *to++ = option;
  296. *to++ = len + 2;
  297. memcpy(to, value, len);
  298. return 0;
  299. }
  300. EXPORT_SYMBOL_GPL(dccp_insert_option);
  301. static int dccp_insert_option_ndp(struct sock *sk, struct sk_buff *skb)
  302. {
  303. struct dccp_sock *dp = dccp_sk(sk);
  304. u64 ndp = dp->dccps_ndp_count;
  305. if (dccp_non_data_packet(skb))
  306. ++dp->dccps_ndp_count;
  307. else
  308. dp->dccps_ndp_count = 0;
  309. if (ndp > 0) {
  310. unsigned char *ptr;
  311. const int ndp_len = dccp_ndp_len(ndp);
  312. const int len = ndp_len + 2;
  313. if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN)
  314. return -1;
  315. DCCP_SKB_CB(skb)->dccpd_opt_len += len;
  316. ptr = skb_push(skb, len);
  317. *ptr++ = DCCPO_NDP_COUNT;
  318. *ptr++ = len;
  319. dccp_encode_value_var(ndp, ptr, ndp_len);
  320. }
  321. return 0;
  322. }
  323. static inline int dccp_elapsed_time_len(const u32 elapsed_time)
  324. {
  325. return elapsed_time == 0 ? 0 : elapsed_time <= 0xFFFF ? 2 : 4;
  326. }
  327. int dccp_insert_option_elapsed_time(struct sock *sk, struct sk_buff *skb,
  328. u32 elapsed_time)
  329. {
  330. const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
  331. const int len = 2 + elapsed_time_len;
  332. unsigned char *to;
  333. if (elapsed_time_len == 0)
  334. return 0;
  335. if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN)
  336. return -1;
  337. DCCP_SKB_CB(skb)->dccpd_opt_len += len;
  338. to = skb_push(skb, len);
  339. *to++ = DCCPO_ELAPSED_TIME;
  340. *to++ = len;
  341. if (elapsed_time_len == 2) {
  342. const __be16 var16 = htons((u16)elapsed_time);
  343. memcpy(to, &var16, 2);
  344. } else {
  345. const __be32 var32 = htonl(elapsed_time);
  346. memcpy(to, &var32, 4);
  347. }
  348. return 0;
  349. }
  350. EXPORT_SYMBOL_GPL(dccp_insert_option_elapsed_time);
  351. int dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb)
  352. {
  353. __be32 now = htonl(dccp_timestamp());
  354. /* yes this will overflow but that is the point as we want a
  355. * 10 usec 32 bit timer which mean it wraps every 11.9 hours */
  356. return dccp_insert_option(sk, skb, DCCPO_TIMESTAMP, &now, sizeof(now));
  357. }
  358. EXPORT_SYMBOL_GPL(dccp_insert_option_timestamp);
  359. static int dccp_insert_option_timestamp_echo(struct dccp_sock *dp,
  360. struct dccp_request_sock *dreq,
  361. struct sk_buff *skb)
  362. {
  363. __be32 tstamp_echo;
  364. unsigned char *to;
  365. u32 elapsed_time, elapsed_time_len, len;
  366. if (dreq != NULL) {
  367. elapsed_time = dccp_timestamp() - dreq->dreq_timestamp_time;
  368. tstamp_echo = htonl(dreq->dreq_timestamp_echo);
  369. dreq->dreq_timestamp_echo = 0;
  370. } else {
  371. elapsed_time = dccp_timestamp() - dp->dccps_timestamp_time;
  372. tstamp_echo = htonl(dp->dccps_timestamp_echo);
  373. dp->dccps_timestamp_echo = 0;
  374. }
  375. elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
  376. len = 6 + elapsed_time_len;
  377. if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN)
  378. return -1;
  379. DCCP_SKB_CB(skb)->dccpd_opt_len += len;
  380. to = skb_push(skb, len);
  381. *to++ = DCCPO_TIMESTAMP_ECHO;
  382. *to++ = len;
  383. memcpy(to, &tstamp_echo, 4);
  384. to += 4;
  385. if (elapsed_time_len == 2) {
  386. const __be16 var16 = htons((u16)elapsed_time);
  387. memcpy(to, &var16, 2);
  388. } else if (elapsed_time_len == 4) {
  389. const __be32 var32 = htonl(elapsed_time);
  390. memcpy(to, &var32, 4);
  391. }
  392. return 0;
  393. }
  394. /**
  395. * dccp_insert_option_mandatory - Mandatory option (5.8.2)
  396. * Note that since we are using skb_push, this function needs to be called
  397. * _after_ inserting the option it is supposed to influence (stack order).
  398. */
  399. int dccp_insert_option_mandatory(struct sk_buff *skb)
  400. {
  401. if (DCCP_SKB_CB(skb)->dccpd_opt_len >= DCCP_MAX_OPT_LEN)
  402. return -1;
  403. DCCP_SKB_CB(skb)->dccpd_opt_len++;
  404. *skb_push(skb, 1) = DCCPO_MANDATORY;
  405. return 0;
  406. }
  407. /**
  408. * dccp_insert_fn_opt - Insert single Feature-Negotiation option into @skb
  409. * @type: %DCCPO_CHANGE_L, %DCCPO_CHANGE_R, %DCCPO_CONFIRM_L, %DCCPO_CONFIRM_R
  410. * @feat: one out of %dccp_feature_numbers
  411. * @val: NN value or SP array (preferred element first) to copy
  412. * @len: true length of @val in bytes (excluding first element repetition)
  413. * @repeat_first: whether to copy the first element of @val twice
  414. * The last argument is used to construct Confirm options, where the preferred
  415. * value and the preference list appear separately (RFC 4340, 6.3.1). Preference
  416. * lists are kept such that the preferred entry is always first, so we only need
  417. * to copy twice, and avoid the overhead of cloning into a bigger array.
  418. */
  419. int dccp_insert_fn_opt(struct sk_buff *skb, u8 type, u8 feat,
  420. u8 *val, u8 len, bool repeat_first)
  421. {
  422. u8 tot_len, *to;
  423. /* take the `Feature' field and possible repetition into account */
  424. if (len > (DCCP_SINGLE_OPT_MAXLEN - 2)) {
  425. DCCP_WARN("length %u for feature %u too large\n", len, feat);
  426. return -1;
  427. }
  428. if (unlikely(val == NULL || len == 0))
  429. len = repeat_first = 0;
  430. tot_len = 3 + repeat_first + len;
  431. if (DCCP_SKB_CB(skb)->dccpd_opt_len + tot_len > DCCP_MAX_OPT_LEN) {
  432. DCCP_WARN("packet too small for feature %d option!\n", feat);
  433. return -1;
  434. }
  435. DCCP_SKB_CB(skb)->dccpd_opt_len += tot_len;
  436. to = skb_push(skb, tot_len);
  437. *to++ = type;
  438. *to++ = tot_len;
  439. *to++ = feat;
  440. if (repeat_first)
  441. *to++ = *val;
  442. if (len)
  443. memcpy(to, val, len);
  444. dccp_pr_debug("%s(%s (%d), ...), length %d\n",
  445. dccp_feat_typename(type),
  446. dccp_feat_name(feat), feat, len);
  447. return 0;
  448. }
  449. /* The length of all options needs to be a multiple of 4 (5.8) */
  450. static void dccp_insert_option_padding(struct sk_buff *skb)
  451. {
  452. int padding = DCCP_SKB_CB(skb)->dccpd_opt_len % 4;
  453. if (padding != 0) {
  454. padding = 4 - padding;
  455. memset(skb_push(skb, padding), 0, padding);
  456. DCCP_SKB_CB(skb)->dccpd_opt_len += padding;
  457. }
  458. }
  459. int dccp_insert_options(struct sock *sk, struct sk_buff *skb)
  460. {
  461. struct dccp_sock *dp = dccp_sk(sk);
  462. struct dccp_minisock *dmsk = dccp_msk(sk);
  463. DCCP_SKB_CB(skb)->dccpd_opt_len = 0;
  464. if (dmsk->dccpms_send_ndp_count &&
  465. dccp_insert_option_ndp(sk, skb))
  466. return -1;
  467. if (DCCP_SKB_CB(skb)->dccpd_type != DCCP_PKT_DATA) {
  468. /* Feature Negotiation */
  469. if (dccp_feat_insert_opts(dp, NULL, skb))
  470. return -1;
  471. if (DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_REQUEST) {
  472. /*
  473. * Obtain RTT sample from Request/Response exchange.
  474. * This is currently used in CCID 3 initialisation.
  475. */
  476. if (dccp_insert_option_timestamp(sk, skb))
  477. return -1;
  478. } else if (dmsk->dccpms_send_ack_vector &&
  479. dccp_ackvec_pending(dp->dccps_hc_rx_ackvec) &&
  480. dccp_insert_option_ackvec(sk, skb)) {
  481. return -1;
  482. }
  483. }
  484. if (dp->dccps_hc_rx_insert_options) {
  485. if (ccid_hc_rx_insert_options(dp->dccps_hc_rx_ccid, sk, skb))
  486. return -1;
  487. dp->dccps_hc_rx_insert_options = 0;
  488. }
  489. if (dp->dccps_timestamp_echo != 0 &&
  490. dccp_insert_option_timestamp_echo(dp, NULL, skb))
  491. return -1;
  492. dccp_insert_option_padding(skb);
  493. return 0;
  494. }
  495. int dccp_insert_options_rsk(struct dccp_request_sock *dreq, struct sk_buff *skb)
  496. {
  497. DCCP_SKB_CB(skb)->dccpd_opt_len = 0;
  498. if (dccp_feat_insert_opts(NULL, dreq, skb))
  499. return -1;
  500. if (dreq->dreq_timestamp_echo != 0 &&
  501. dccp_insert_option_timestamp_echo(NULL, dreq, skb))
  502. return -1;
  503. dccp_insert_option_padding(skb);
  504. return 0;
  505. }