options.c 16 KB

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