options.c 16 KB

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