options.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  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 > 6)
  115. goto out_invalid_option;
  116. opt_recv->dccpor_ndp = dccp_decode_value_var(value, len);
  117. dccp_pr_debug("%s opt: NDP count=%llu\n", dccp_role(sk),
  118. (unsigned long long)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 u8 dccp_ndp_len(const u64 ndp)
  277. {
  278. if (likely(ndp <= 0xFF))
  279. return 1;
  280. return likely(ndp <= USHORT_MAX) ? 2 : (ndp <= UINT_MAX ? 4 : 6);
  281. }
  282. int dccp_insert_option(struct sock *sk, struct sk_buff *skb,
  283. const unsigned char option,
  284. const void *value, const unsigned char len)
  285. {
  286. unsigned char *to;
  287. if (DCCP_SKB_CB(skb)->dccpd_opt_len + len + 2 > DCCP_MAX_OPT_LEN)
  288. return -1;
  289. DCCP_SKB_CB(skb)->dccpd_opt_len += len + 2;
  290. to = skb_push(skb, len + 2);
  291. *to++ = option;
  292. *to++ = len + 2;
  293. memcpy(to, value, len);
  294. return 0;
  295. }
  296. EXPORT_SYMBOL_GPL(dccp_insert_option);
  297. static int dccp_insert_option_ndp(struct sock *sk, struct sk_buff *skb)
  298. {
  299. struct dccp_sock *dp = dccp_sk(sk);
  300. u64 ndp = dp->dccps_ndp_count;
  301. if (dccp_non_data_packet(skb))
  302. ++dp->dccps_ndp_count;
  303. else
  304. dp->dccps_ndp_count = 0;
  305. if (ndp > 0) {
  306. unsigned char *ptr;
  307. const int ndp_len = dccp_ndp_len(ndp);
  308. const int len = ndp_len + 2;
  309. if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN)
  310. return -1;
  311. DCCP_SKB_CB(skb)->dccpd_opt_len += len;
  312. ptr = skb_push(skb, len);
  313. *ptr++ = DCCPO_NDP_COUNT;
  314. *ptr++ = len;
  315. dccp_encode_value_var(ndp, ptr, ndp_len);
  316. }
  317. return 0;
  318. }
  319. static inline int dccp_elapsed_time_len(const u32 elapsed_time)
  320. {
  321. return elapsed_time == 0 ? 0 : elapsed_time <= 0xFFFF ? 2 : 4;
  322. }
  323. int dccp_insert_option_elapsed_time(struct sock *sk, struct sk_buff *skb,
  324. u32 elapsed_time)
  325. {
  326. const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
  327. const int len = 2 + elapsed_time_len;
  328. unsigned char *to;
  329. if (elapsed_time_len == 0)
  330. return 0;
  331. if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN)
  332. return -1;
  333. DCCP_SKB_CB(skb)->dccpd_opt_len += len;
  334. to = skb_push(skb, len);
  335. *to++ = DCCPO_ELAPSED_TIME;
  336. *to++ = len;
  337. if (elapsed_time_len == 2) {
  338. const __be16 var16 = htons((u16)elapsed_time);
  339. memcpy(to, &var16, 2);
  340. } else {
  341. const __be32 var32 = htonl(elapsed_time);
  342. memcpy(to, &var32, 4);
  343. }
  344. return 0;
  345. }
  346. EXPORT_SYMBOL_GPL(dccp_insert_option_elapsed_time);
  347. int dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb)
  348. {
  349. __be32 now = htonl(dccp_timestamp());
  350. /* yes this will overflow but that is the point as we want a
  351. * 10 usec 32 bit timer which mean it wraps every 11.9 hours */
  352. return dccp_insert_option(sk, skb, DCCPO_TIMESTAMP, &now, sizeof(now));
  353. }
  354. EXPORT_SYMBOL_GPL(dccp_insert_option_timestamp);
  355. static int dccp_insert_option_timestamp_echo(struct dccp_sock *dp,
  356. struct dccp_request_sock *dreq,
  357. struct sk_buff *skb)
  358. {
  359. __be32 tstamp_echo;
  360. unsigned char *to;
  361. u32 elapsed_time, elapsed_time_len, len;
  362. if (dreq != NULL) {
  363. elapsed_time = dccp_timestamp() - dreq->dreq_timestamp_time;
  364. tstamp_echo = htonl(dreq->dreq_timestamp_echo);
  365. dreq->dreq_timestamp_echo = 0;
  366. } else {
  367. elapsed_time = dccp_timestamp() - dp->dccps_timestamp_time;
  368. tstamp_echo = htonl(dp->dccps_timestamp_echo);
  369. dp->dccps_timestamp_echo = 0;
  370. }
  371. elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
  372. len = 6 + elapsed_time_len;
  373. if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN)
  374. return -1;
  375. DCCP_SKB_CB(skb)->dccpd_opt_len += len;
  376. to = skb_push(skb, len);
  377. *to++ = DCCPO_TIMESTAMP_ECHO;
  378. *to++ = len;
  379. memcpy(to, &tstamp_echo, 4);
  380. to += 4;
  381. if (elapsed_time_len == 2) {
  382. const __be16 var16 = htons((u16)elapsed_time);
  383. memcpy(to, &var16, 2);
  384. } else if (elapsed_time_len == 4) {
  385. const __be32 var32 = htonl(elapsed_time);
  386. memcpy(to, &var32, 4);
  387. }
  388. return 0;
  389. }
  390. static int dccp_insert_feat_opt(struct sk_buff *skb, u8 type, u8 feat,
  391. u8 *val, u8 len)
  392. {
  393. u8 *to;
  394. if (DCCP_SKB_CB(skb)->dccpd_opt_len + len + 3 > DCCP_MAX_OPT_LEN) {
  395. DCCP_WARN("packet too small for feature %d option!\n", feat);
  396. return -1;
  397. }
  398. DCCP_SKB_CB(skb)->dccpd_opt_len += len + 3;
  399. to = skb_push(skb, len + 3);
  400. *to++ = type;
  401. *to++ = len + 3;
  402. *to++ = feat;
  403. if (len)
  404. memcpy(to, val, len);
  405. dccp_pr_debug("%s(%s (%d), ...), length %d\n",
  406. dccp_feat_typename(type),
  407. dccp_feat_name(feat), feat, len);
  408. return 0;
  409. }
  410. static int dccp_insert_options_feat(struct sock *sk, struct sk_buff *skb)
  411. {
  412. struct dccp_sock *dp = dccp_sk(sk);
  413. struct dccp_minisock *dmsk = dccp_msk(sk);
  414. struct dccp_opt_pend *opt, *next;
  415. int change = 0;
  416. /* confirm any options [NN opts] */
  417. list_for_each_entry_safe(opt, next, &dmsk->dccpms_conf, dccpop_node) {
  418. dccp_insert_feat_opt(skb, opt->dccpop_type,
  419. opt->dccpop_feat, opt->dccpop_val,
  420. opt->dccpop_len);
  421. /* fear empty confirms */
  422. if (opt->dccpop_val)
  423. kfree(opt->dccpop_val);
  424. kfree(opt);
  425. }
  426. INIT_LIST_HEAD(&dmsk->dccpms_conf);
  427. /* see which features we need to send */
  428. list_for_each_entry(opt, &dmsk->dccpms_pending, dccpop_node) {
  429. /* see if we need to send any confirm */
  430. if (opt->dccpop_sc) {
  431. dccp_insert_feat_opt(skb, opt->dccpop_type + 1,
  432. opt->dccpop_feat,
  433. opt->dccpop_sc->dccpoc_val,
  434. opt->dccpop_sc->dccpoc_len);
  435. BUG_ON(!opt->dccpop_sc->dccpoc_val);
  436. kfree(opt->dccpop_sc->dccpoc_val);
  437. kfree(opt->dccpop_sc);
  438. opt->dccpop_sc = NULL;
  439. }
  440. /* any option not confirmed, re-send it */
  441. if (!opt->dccpop_conf) {
  442. dccp_insert_feat_opt(skb, opt->dccpop_type,
  443. opt->dccpop_feat, opt->dccpop_val,
  444. opt->dccpop_len);
  445. change++;
  446. }
  447. }
  448. /* Retransmit timer.
  449. * If this is the master listening sock, we don't set a timer on it. It
  450. * should be fine because if the dude doesn't receive our RESPONSE
  451. * [which will contain the CHANGE] he will send another REQUEST which
  452. * will "retrnasmit" the change.
  453. */
  454. if (change && dp->dccps_role != DCCP_ROLE_LISTEN) {
  455. dccp_pr_debug("reset feat negotiation timer %p\n", sk);
  456. /* XXX don't reset the timer on re-transmissions. I.e. reset it
  457. * only when sending new stuff i guess. Currently the timer
  458. * never backs off because on re-transmission it just resets it!
  459. */
  460. inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
  461. inet_csk(sk)->icsk_rto, DCCP_RTO_MAX);
  462. }
  463. return 0;
  464. }
  465. /* The length of all options needs to be a multiple of 4 (5.8) */
  466. static void dccp_insert_option_padding(struct sk_buff *skb)
  467. {
  468. int padding = DCCP_SKB_CB(skb)->dccpd_opt_len % 4;
  469. if (padding != 0) {
  470. padding = 4 - padding;
  471. memset(skb_push(skb, padding), 0, padding);
  472. DCCP_SKB_CB(skb)->dccpd_opt_len += padding;
  473. }
  474. }
  475. int dccp_insert_options(struct sock *sk, struct sk_buff *skb)
  476. {
  477. struct dccp_sock *dp = dccp_sk(sk);
  478. struct dccp_minisock *dmsk = dccp_msk(sk);
  479. DCCP_SKB_CB(skb)->dccpd_opt_len = 0;
  480. if (dmsk->dccpms_send_ndp_count &&
  481. dccp_insert_option_ndp(sk, skb))
  482. return -1;
  483. if (!dccp_packet_without_ack(skb)) {
  484. if (dmsk->dccpms_send_ack_vector &&
  485. dccp_ackvec_pending(dp->dccps_hc_rx_ackvec) &&
  486. dccp_insert_option_ackvec(sk, skb))
  487. return -1;
  488. }
  489. if (dp->dccps_hc_rx_insert_options) {
  490. if (ccid_hc_rx_insert_options(dp->dccps_hc_rx_ccid, sk, skb))
  491. return -1;
  492. dp->dccps_hc_rx_insert_options = 0;
  493. }
  494. /* Feature negotiation */
  495. /* Data packets can't do feat negotiation */
  496. if (DCCP_SKB_CB(skb)->dccpd_type != DCCP_PKT_DATA &&
  497. DCCP_SKB_CB(skb)->dccpd_type != DCCP_PKT_DATAACK &&
  498. dccp_insert_options_feat(sk, skb))
  499. return -1;
  500. /*
  501. * Obtain RTT sample from Request/Response exchange.
  502. * This is currently used in CCID 3 initialisation.
  503. */
  504. if (DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_REQUEST &&
  505. dccp_insert_option_timestamp(sk, skb))
  506. return -1;
  507. if (dp->dccps_timestamp_echo != 0 &&
  508. dccp_insert_option_timestamp_echo(dp, NULL, skb))
  509. return -1;
  510. dccp_insert_option_padding(skb);
  511. return 0;
  512. }
  513. int dccp_insert_options_rsk(struct dccp_request_sock *dreq, struct sk_buff *skb)
  514. {
  515. DCCP_SKB_CB(skb)->dccpd_opt_len = 0;
  516. if (dreq->dreq_timestamp_echo != 0 &&
  517. dccp_insert_option_timestamp_echo(NULL, dreq, skb))
  518. return -1;
  519. dccp_insert_option_padding(skb);
  520. return 0;
  521. }