options.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  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_ack_ratio = DCCPF_INITIAL_ACK_RATIO;
  28. int sysctl_dccp_feat_send_ack_vector = DCCPF_INITIAL_SEND_ACK_VECTOR;
  29. int sysctl_dccp_feat_send_ndp_count = DCCPF_INITIAL_SEND_NDP_COUNT;
  30. static u32 dccp_decode_value_var(const unsigned char *bf, const u8 len)
  31. {
  32. u32 value = 0;
  33. if (len > 3)
  34. value += *bf++ << 24;
  35. if (len > 2)
  36. value += *bf++ << 16;
  37. if (len > 1)
  38. value += *bf++ << 8;
  39. if (len > 0)
  40. value += *bf;
  41. return value;
  42. }
  43. /**
  44. * dccp_parse_options - Parse DCCP options present in @skb
  45. * @sk: client|server|listening dccp socket (when @dreq != NULL)
  46. * @dreq: request socket to use during connection setup, or NULL
  47. */
  48. int dccp_parse_options(struct sock *sk, struct dccp_request_sock *dreq,
  49. struct sk_buff *skb)
  50. {
  51. struct dccp_sock *dp = dccp_sk(sk);
  52. const struct dccp_hdr *dh = dccp_hdr(skb);
  53. const u8 pkt_type = DCCP_SKB_CB(skb)->dccpd_type;
  54. u64 ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq;
  55. unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb);
  56. unsigned char *opt_ptr = options;
  57. const unsigned char *opt_end = (unsigned char *)dh +
  58. (dh->dccph_doff * 4);
  59. struct dccp_options_received *opt_recv = &dp->dccps_options_received;
  60. unsigned char opt, len;
  61. unsigned char *value;
  62. u32 elapsed_time;
  63. __be32 opt_val;
  64. int rc;
  65. int mandatory = 0;
  66. memset(opt_recv, 0, sizeof(*opt_recv));
  67. opt = len = 0;
  68. while (opt_ptr != opt_end) {
  69. opt = *opt_ptr++;
  70. len = 0;
  71. value = NULL;
  72. /* Check if this isn't a single byte option */
  73. if (opt > DCCPO_MAX_RESERVED) {
  74. if (opt_ptr == opt_end)
  75. goto out_invalid_option;
  76. len = *opt_ptr++;
  77. if (len < 3)
  78. goto out_invalid_option;
  79. /*
  80. * Remove the type and len fields, leaving
  81. * just the value size
  82. */
  83. len -= 2;
  84. value = opt_ptr;
  85. opt_ptr += len;
  86. if (opt_ptr > opt_end)
  87. goto out_invalid_option;
  88. }
  89. /*
  90. * CCID-Specific Options (from RFC 4340, sec. 10.3):
  91. *
  92. * Option numbers 128 through 191 are for options sent from the
  93. * HC-Sender to the HC-Receiver; option numbers 192 through 255
  94. * are for options sent from the HC-Receiver to the HC-Sender.
  95. *
  96. * CCID-specific options are ignored during connection setup, as
  97. * negotiation may still be in progress (see RFC 4340, 10.3).
  98. * The same applies to Ack Vectors, as these depend on the CCID.
  99. *
  100. */
  101. if (dreq != NULL && (opt >= 128 ||
  102. opt == DCCPO_ACK_VECTOR_0 || opt == DCCPO_ACK_VECTOR_1))
  103. goto ignore_option;
  104. switch (opt) {
  105. case DCCPO_PADDING:
  106. break;
  107. case DCCPO_MANDATORY:
  108. if (mandatory)
  109. goto out_invalid_option;
  110. if (pkt_type != DCCP_PKT_DATA)
  111. mandatory = 1;
  112. break;
  113. case DCCPO_NDP_COUNT:
  114. if (len > 3)
  115. goto out_invalid_option;
  116. opt_recv->dccpor_ndp = dccp_decode_value_var(value, len);
  117. dccp_pr_debug("%s rx opt: NDP count=%d\n", dccp_role(sk),
  118. opt_recv->dccpor_ndp);
  119. break;
  120. case DCCPO_CHANGE_L:
  121. /* fall through */
  122. case DCCPO_CHANGE_R:
  123. if (pkt_type == DCCP_PKT_DATA)
  124. break;
  125. if (len < 2)
  126. goto out_invalid_option;
  127. rc = dccp_feat_change_recv(sk, opt, *value, value + 1,
  128. len - 1);
  129. /*
  130. * When there is a change error, change_recv is
  131. * responsible for dealing with it. i.e. reply with an
  132. * empty confirm.
  133. * If the change was mandatory, then we need to die.
  134. */
  135. if (rc && mandatory)
  136. goto out_invalid_option;
  137. break;
  138. case DCCPO_CONFIRM_L:
  139. /* fall through */
  140. case DCCPO_CONFIRM_R:
  141. if (pkt_type == DCCP_PKT_DATA)
  142. break;
  143. if (len < 2) /* FIXME this disallows empty confirm */
  144. goto out_invalid_option;
  145. if (dccp_feat_confirm_recv(sk, opt, *value,
  146. value + 1, len - 1))
  147. goto out_invalid_option;
  148. break;
  149. case DCCPO_ACK_VECTOR_0:
  150. case DCCPO_ACK_VECTOR_1:
  151. if (dccp_packet_without_ack(skb)) /* RFC 4340, 11.4 */
  152. break;
  153. if (dccp_msk(sk)->dccpms_send_ack_vector &&
  154. dccp_ackvec_parse(sk, skb, &ackno, opt, value, len))
  155. goto out_invalid_option;
  156. break;
  157. case DCCPO_TIMESTAMP:
  158. if (len != 4)
  159. goto out_invalid_option;
  160. /*
  161. * RFC 4340 13.1: "The precise time corresponding to
  162. * Timestamp Value zero is not specified". We use
  163. * zero to indicate absence of a meaningful timestamp.
  164. */
  165. opt_val = get_unaligned((__be32 *)value);
  166. if (unlikely(opt_val == 0)) {
  167. DCCP_WARN("Timestamp with zero value\n");
  168. break;
  169. }
  170. if (dreq != NULL) {
  171. dreq->dreq_timestamp_echo = ntohl(opt_val);
  172. dreq->dreq_timestamp_time = dccp_timestamp();
  173. } else {
  174. opt_recv->dccpor_timestamp =
  175. dp->dccps_timestamp_echo = ntohl(opt_val);
  176. dp->dccps_timestamp_time = dccp_timestamp();
  177. }
  178. dccp_pr_debug("%s rx opt: TIMESTAMP=%u, ackno=%llu\n",
  179. dccp_role(sk), ntohl(opt_val),
  180. (unsigned long long)
  181. DCCP_SKB_CB(skb)->dccpd_ack_seq);
  182. break;
  183. case DCCPO_TIMESTAMP_ECHO:
  184. if (len != 4 && len != 6 && len != 8)
  185. goto out_invalid_option;
  186. opt_val = get_unaligned((__be32 *)value);
  187. opt_recv->dccpor_timestamp_echo = ntohl(opt_val);
  188. dccp_pr_debug("%s rx opt: TIMESTAMP_ECHO=%u, len=%d, "
  189. "ackno=%llu", dccp_role(sk),
  190. opt_recv->dccpor_timestamp_echo,
  191. len + 2,
  192. (unsigned long long)
  193. DCCP_SKB_CB(skb)->dccpd_ack_seq);
  194. value += 4;
  195. if (len == 4) { /* no elapsed time included */
  196. dccp_pr_debug_cat("\n");
  197. break;
  198. }
  199. if (len == 6) { /* 2-byte elapsed time */
  200. __be16 opt_val2 = get_unaligned((__be16 *)value);
  201. elapsed_time = ntohs(opt_val2);
  202. } else { /* 4-byte elapsed time */
  203. opt_val = get_unaligned((__be32 *)value);
  204. elapsed_time = ntohl(opt_val);
  205. }
  206. dccp_pr_debug_cat(", ELAPSED_TIME=%u\n", elapsed_time);
  207. /* Give precedence to the biggest ELAPSED_TIME */
  208. if (elapsed_time > opt_recv->dccpor_elapsed_time)
  209. opt_recv->dccpor_elapsed_time = elapsed_time;
  210. break;
  211. case DCCPO_ELAPSED_TIME:
  212. if (dccp_packet_without_ack(skb)) /* RFC 4340, 13.2 */
  213. break;
  214. if (len == 2) {
  215. __be16 opt_val2 = get_unaligned((__be16 *)value);
  216. elapsed_time = ntohs(opt_val2);
  217. } else if (len == 4) {
  218. opt_val = get_unaligned((__be32 *)value);
  219. elapsed_time = ntohl(opt_val);
  220. } else {
  221. goto out_invalid_option;
  222. }
  223. if (elapsed_time > opt_recv->dccpor_elapsed_time)
  224. opt_recv->dccpor_elapsed_time = elapsed_time;
  225. dccp_pr_debug("%s rx opt: ELAPSED_TIME=%d\n",
  226. dccp_role(sk), elapsed_time);
  227. break;
  228. case 128 ... 191: {
  229. const u16 idx = value - options;
  230. if (ccid_hc_rx_parse_options(dp->dccps_hc_rx_ccid, sk,
  231. opt, len, idx,
  232. value) != 0)
  233. goto out_invalid_option;
  234. }
  235. break;
  236. case 192 ... 255: {
  237. const u16 idx = value - options;
  238. if (ccid_hc_tx_parse_options(dp->dccps_hc_tx_ccid, sk,
  239. opt, len, idx,
  240. value) != 0)
  241. goto out_invalid_option;
  242. }
  243. break;
  244. default:
  245. DCCP_CRIT("DCCP(%p): option %d(len=%d) not "
  246. "implemented, ignoring", sk, opt, len);
  247. break;
  248. }
  249. ignore_option:
  250. if (opt != DCCPO_MANDATORY)
  251. mandatory = 0;
  252. }
  253. /* mandatory was the last byte in option list -> reset connection */
  254. if (mandatory)
  255. goto out_invalid_option;
  256. return 0;
  257. out_invalid_option:
  258. DCCP_INC_STATS_BH(DCCP_MIB_INVALIDOPT);
  259. DCCP_SKB_CB(skb)->dccpd_reset_code = DCCP_RESET_CODE_OPTION_ERROR;
  260. DCCP_WARN("DCCP(%p): invalid option %d, len=%d", sk, opt, len);
  261. return -1;
  262. }
  263. EXPORT_SYMBOL_GPL(dccp_parse_options);
  264. static void dccp_encode_value_var(const u32 value, unsigned char *to,
  265. const unsigned int len)
  266. {
  267. if (len > 3)
  268. *to++ = (value & 0xFF000000) >> 24;
  269. if (len > 2)
  270. *to++ = (value & 0xFF0000) >> 16;
  271. if (len > 1)
  272. *to++ = (value & 0xFF00) >> 8;
  273. if (len > 0)
  274. *to++ = (value & 0xFF);
  275. }
  276. static inline int dccp_ndp_len(const int ndp)
  277. {
  278. return likely(ndp <= 0xFF) ? 1 : ndp <= 0xFFFF ? 2 : 3;
  279. }
  280. int dccp_insert_option(struct sock *sk, struct sk_buff *skb,
  281. const unsigned char option,
  282. const void *value, const unsigned char len)
  283. {
  284. unsigned char *to;
  285. if (DCCP_SKB_CB(skb)->dccpd_opt_len + len + 2 > DCCP_MAX_OPT_LEN)
  286. return -1;
  287. DCCP_SKB_CB(skb)->dccpd_opt_len += len + 2;
  288. to = skb_push(skb, len + 2);
  289. *to++ = option;
  290. *to++ = len + 2;
  291. memcpy(to, value, len);
  292. return 0;
  293. }
  294. EXPORT_SYMBOL_GPL(dccp_insert_option);
  295. static int dccp_insert_option_ndp(struct sock *sk, struct sk_buff *skb)
  296. {
  297. struct dccp_sock *dp = dccp_sk(sk);
  298. int ndp = dp->dccps_ndp_count;
  299. if (dccp_non_data_packet(skb))
  300. ++dp->dccps_ndp_count;
  301. else
  302. dp->dccps_ndp_count = 0;
  303. if (ndp > 0) {
  304. unsigned char *ptr;
  305. const int ndp_len = dccp_ndp_len(ndp);
  306. const int len = ndp_len + 2;
  307. if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN)
  308. return -1;
  309. DCCP_SKB_CB(skb)->dccpd_opt_len += len;
  310. ptr = skb_push(skb, len);
  311. *ptr++ = DCCPO_NDP_COUNT;
  312. *ptr++ = len;
  313. dccp_encode_value_var(ndp, ptr, ndp_len);
  314. }
  315. return 0;
  316. }
  317. static inline int dccp_elapsed_time_len(const u32 elapsed_time)
  318. {
  319. return elapsed_time == 0 ? 0 : elapsed_time <= 0xFFFF ? 2 : 4;
  320. }
  321. int dccp_insert_option_elapsed_time(struct sock *sk, struct sk_buff *skb,
  322. u32 elapsed_time)
  323. {
  324. const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
  325. const int len = 2 + elapsed_time_len;
  326. unsigned char *to;
  327. if (elapsed_time_len == 0)
  328. return 0;
  329. if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN)
  330. return -1;
  331. DCCP_SKB_CB(skb)->dccpd_opt_len += len;
  332. to = skb_push(skb, len);
  333. *to++ = DCCPO_ELAPSED_TIME;
  334. *to++ = len;
  335. if (elapsed_time_len == 2) {
  336. const __be16 var16 = htons((u16)elapsed_time);
  337. memcpy(to, &var16, 2);
  338. } else {
  339. const __be32 var32 = htonl(elapsed_time);
  340. memcpy(to, &var32, 4);
  341. }
  342. return 0;
  343. }
  344. EXPORT_SYMBOL_GPL(dccp_insert_option_elapsed_time);
  345. int dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb)
  346. {
  347. __be32 now = htonl(dccp_timestamp());
  348. /* yes this will overflow but that is the point as we want a
  349. * 10 usec 32 bit timer which mean it wraps every 11.9 hours */
  350. return dccp_insert_option(sk, skb, DCCPO_TIMESTAMP, &now, sizeof(now));
  351. }
  352. EXPORT_SYMBOL_GPL(dccp_insert_option_timestamp);
  353. static int dccp_insert_option_timestamp_echo(struct dccp_sock *dp,
  354. struct dccp_request_sock *dreq,
  355. struct sk_buff *skb)
  356. {
  357. __be32 tstamp_echo;
  358. unsigned char *to;
  359. u32 elapsed_time, elapsed_time_len, len;
  360. if (dreq != NULL) {
  361. elapsed_time = dccp_timestamp() - dreq->dreq_timestamp_time;
  362. tstamp_echo = htonl(dreq->dreq_timestamp_echo);
  363. dreq->dreq_timestamp_echo = 0;
  364. } else {
  365. elapsed_time = dccp_timestamp() - dp->dccps_timestamp_time;
  366. tstamp_echo = htonl(dp->dccps_timestamp_echo);
  367. dp->dccps_timestamp_echo = 0;
  368. }
  369. elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
  370. len = 6 + elapsed_time_len;
  371. if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN)
  372. return -1;
  373. DCCP_SKB_CB(skb)->dccpd_opt_len += len;
  374. to = skb_push(skb, len);
  375. *to++ = DCCPO_TIMESTAMP_ECHO;
  376. *to++ = len;
  377. memcpy(to, &tstamp_echo, 4);
  378. to += 4;
  379. if (elapsed_time_len == 2) {
  380. const __be16 var16 = htons((u16)elapsed_time);
  381. memcpy(to, &var16, 2);
  382. } else if (elapsed_time_len == 4) {
  383. const __be32 var32 = htonl(elapsed_time);
  384. memcpy(to, &var32, 4);
  385. }
  386. return 0;
  387. }
  388. static int dccp_insert_feat_opt(struct sk_buff *skb, u8 type, u8 feat,
  389. u8 *val, u8 len)
  390. {
  391. u8 *to;
  392. if (DCCP_SKB_CB(skb)->dccpd_opt_len + len + 3 > DCCP_MAX_OPT_LEN) {
  393. DCCP_WARN("packet too small for feature %d option!\n", feat);
  394. return -1;
  395. }
  396. DCCP_SKB_CB(skb)->dccpd_opt_len += len + 3;
  397. to = skb_push(skb, len + 3);
  398. *to++ = type;
  399. *to++ = len + 3;
  400. *to++ = feat;
  401. if (len)
  402. memcpy(to, val, len);
  403. dccp_pr_debug("%s(%s (%d), ...), length %d\n",
  404. dccp_feat_typename(type),
  405. dccp_feat_name(feat), feat, len);
  406. return 0;
  407. }
  408. static int dccp_insert_options_feat(struct sock *sk, struct sk_buff *skb)
  409. {
  410. struct dccp_sock *dp = dccp_sk(sk);
  411. struct dccp_minisock *dmsk = dccp_msk(sk);
  412. struct dccp_opt_pend *opt, *next;
  413. int change = 0;
  414. /* confirm any options [NN opts] */
  415. list_for_each_entry_safe(opt, next, &dmsk->dccpms_conf, dccpop_node) {
  416. dccp_insert_feat_opt(skb, opt->dccpop_type,
  417. opt->dccpop_feat, opt->dccpop_val,
  418. opt->dccpop_len);
  419. /* fear empty confirms */
  420. if (opt->dccpop_val)
  421. kfree(opt->dccpop_val);
  422. kfree(opt);
  423. }
  424. INIT_LIST_HEAD(&dmsk->dccpms_conf);
  425. /* see which features we need to send */
  426. list_for_each_entry(opt, &dmsk->dccpms_pending, dccpop_node) {
  427. /* see if we need to send any confirm */
  428. if (opt->dccpop_sc) {
  429. dccp_insert_feat_opt(skb, opt->dccpop_type + 1,
  430. opt->dccpop_feat,
  431. opt->dccpop_sc->dccpoc_val,
  432. opt->dccpop_sc->dccpoc_len);
  433. BUG_ON(!opt->dccpop_sc->dccpoc_val);
  434. kfree(opt->dccpop_sc->dccpoc_val);
  435. kfree(opt->dccpop_sc);
  436. opt->dccpop_sc = NULL;
  437. }
  438. /* any option not confirmed, re-send it */
  439. if (!opt->dccpop_conf) {
  440. dccp_insert_feat_opt(skb, opt->dccpop_type,
  441. opt->dccpop_feat, opt->dccpop_val,
  442. opt->dccpop_len);
  443. change++;
  444. }
  445. }
  446. /* Retransmit timer.
  447. * If this is the master listening sock, we don't set a timer on it. It
  448. * should be fine because if the dude doesn't receive our RESPONSE
  449. * [which will contain the CHANGE] he will send another REQUEST which
  450. * will "retrnasmit" the change.
  451. */
  452. if (change && dp->dccps_role != DCCP_ROLE_LISTEN) {
  453. dccp_pr_debug("reset feat negotiation timer %p\n", sk);
  454. /* XXX don't reset the timer on re-transmissions. I.e. reset it
  455. * only when sending new stuff i guess. Currently the timer
  456. * never backs off because on re-transmission it just resets it!
  457. */
  458. inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
  459. inet_csk(sk)->icsk_rto, DCCP_RTO_MAX);
  460. }
  461. return 0;
  462. }
  463. /* The length of all options needs to be a multiple of 4 (5.8) */
  464. static void dccp_insert_option_padding(struct sk_buff *skb)
  465. {
  466. int padding = DCCP_SKB_CB(skb)->dccpd_opt_len % 4;
  467. if (padding != 0) {
  468. padding = 4 - padding;
  469. memset(skb_push(skb, padding), 0, padding);
  470. DCCP_SKB_CB(skb)->dccpd_opt_len += padding;
  471. }
  472. }
  473. int dccp_insert_options(struct sock *sk, struct sk_buff *skb)
  474. {
  475. struct dccp_sock *dp = dccp_sk(sk);
  476. struct dccp_minisock *dmsk = dccp_msk(sk);
  477. DCCP_SKB_CB(skb)->dccpd_opt_len = 0;
  478. if (dmsk->dccpms_send_ndp_count &&
  479. dccp_insert_option_ndp(sk, skb))
  480. return -1;
  481. if (!dccp_packet_without_ack(skb)) {
  482. if (dmsk->dccpms_send_ack_vector &&
  483. dccp_ackvec_pending(dp->dccps_hc_rx_ackvec) &&
  484. dccp_insert_option_ackvec(sk, skb))
  485. return -1;
  486. }
  487. if (dp->dccps_hc_rx_insert_options) {
  488. if (ccid_hc_rx_insert_options(dp->dccps_hc_rx_ccid, sk, skb))
  489. return -1;
  490. dp->dccps_hc_rx_insert_options = 0;
  491. }
  492. /* Feature negotiation */
  493. /* Data packets can't do feat negotiation */
  494. if (DCCP_SKB_CB(skb)->dccpd_type != DCCP_PKT_DATA &&
  495. DCCP_SKB_CB(skb)->dccpd_type != DCCP_PKT_DATAACK &&
  496. dccp_insert_options_feat(sk, skb))
  497. return -1;
  498. /*
  499. * Obtain RTT sample from Request/Response exchange.
  500. * This is currently used in CCID 3 initialisation.
  501. */
  502. if (DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_REQUEST &&
  503. dccp_insert_option_timestamp(sk, skb))
  504. return -1;
  505. if (dp->dccps_timestamp_echo != 0 &&
  506. dccp_insert_option_timestamp_echo(dp, NULL, skb))
  507. return -1;
  508. dccp_insert_option_padding(skb);
  509. return 0;
  510. }
  511. int dccp_insert_options_rsk(struct dccp_request_sock *dreq, struct sk_buff *skb)
  512. {
  513. DCCP_SKB_CB(skb)->dccpd_opt_len = 0;
  514. if (dreq->dreq_timestamp_echo != 0 &&
  515. dccp_insert_option_timestamp_echo(NULL, dreq, skb))
  516. return -1;
  517. dccp_insert_option_padding(skb);
  518. return 0;
  519. }