output.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. /*
  2. * net/dccp/output.c
  3. *
  4. * An implementation of the DCCP protocol
  5. * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. */
  12. #include <linux/dccp.h>
  13. #include <linux/kernel.h>
  14. #include <linux/skbuff.h>
  15. #include <net/inet_sock.h>
  16. #include <net/sock.h>
  17. #include "ackvec.h"
  18. #include "ccid.h"
  19. #include "dccp.h"
  20. static inline void dccp_event_ack_sent(struct sock *sk)
  21. {
  22. inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK);
  23. }
  24. static void dccp_skb_entail(struct sock *sk, struct sk_buff *skb)
  25. {
  26. skb_set_owner_w(skb, sk);
  27. WARN_ON(sk->sk_send_head);
  28. sk->sk_send_head = skb;
  29. }
  30. /*
  31. * All SKB's seen here are completely headerless. It is our
  32. * job to build the DCCP header, and pass the packet down to
  33. * IP so it can do the same plus pass the packet off to the
  34. * device.
  35. */
  36. static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
  37. {
  38. if (likely(skb != NULL)) {
  39. const struct inet_sock *inet = inet_sk(sk);
  40. const struct inet_connection_sock *icsk = inet_csk(sk);
  41. struct dccp_sock *dp = dccp_sk(sk);
  42. struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
  43. struct dccp_hdr *dh;
  44. /* XXX For now we're using only 48 bits sequence numbers */
  45. const u32 dccp_header_size = sizeof(*dh) +
  46. sizeof(struct dccp_hdr_ext) +
  47. dccp_packet_hdr_len(dcb->dccpd_type);
  48. int err, set_ack = 1;
  49. u64 ackno = dp->dccps_gsr;
  50. dccp_inc_seqno(&dp->dccps_gss);
  51. switch (dcb->dccpd_type) {
  52. case DCCP_PKT_DATA:
  53. set_ack = 0;
  54. /* fall through */
  55. case DCCP_PKT_DATAACK:
  56. break;
  57. case DCCP_PKT_REQUEST:
  58. set_ack = 0;
  59. /* fall through */
  60. case DCCP_PKT_SYNC:
  61. case DCCP_PKT_SYNCACK:
  62. ackno = dcb->dccpd_seq;
  63. /* fall through */
  64. default:
  65. /*
  66. * Only data packets should come through with skb->sk
  67. * set.
  68. */
  69. WARN_ON(skb->sk);
  70. skb_set_owner_w(skb, sk);
  71. break;
  72. }
  73. dcb->dccpd_seq = dp->dccps_gss;
  74. if (dccp_insert_options(sk, skb)) {
  75. kfree_skb(skb);
  76. return -EPROTO;
  77. }
  78. skb->h.raw = skb_push(skb, dccp_header_size);
  79. dh = dccp_hdr(skb);
  80. /* Build DCCP header and checksum it. */
  81. memset(dh, 0, dccp_header_size);
  82. dh->dccph_type = dcb->dccpd_type;
  83. dh->dccph_sport = inet->sport;
  84. dh->dccph_dport = inet->dport;
  85. dh->dccph_doff = (dccp_header_size + dcb->dccpd_opt_len) / 4;
  86. dh->dccph_ccval = dcb->dccpd_ccval;
  87. /* XXX For now we're using only 48 bits sequence numbers */
  88. dh->dccph_x = 1;
  89. dp->dccps_awh = dp->dccps_gss;
  90. dccp_hdr_set_seq(dh, dp->dccps_gss);
  91. if (set_ack)
  92. dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), ackno);
  93. switch (dcb->dccpd_type) {
  94. case DCCP_PKT_REQUEST:
  95. dccp_hdr_request(skb)->dccph_req_service =
  96. dp->dccps_service;
  97. break;
  98. case DCCP_PKT_RESET:
  99. dccp_hdr_reset(skb)->dccph_reset_code =
  100. dcb->dccpd_reset_code;
  101. break;
  102. }
  103. icsk->icsk_af_ops->send_check(sk, skb->len, skb);
  104. if (set_ack)
  105. dccp_event_ack_sent(sk);
  106. DCCP_INC_STATS(DCCP_MIB_OUTSEGS);
  107. memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
  108. err = icsk->icsk_af_ops->queue_xmit(skb, 0);
  109. if (err <= 0)
  110. return err;
  111. /* NET_XMIT_CN is special. It does not guarantee,
  112. * that this packet is lost. It tells that device
  113. * is about to start to drop packets or already
  114. * drops some packets of the same priority and
  115. * invokes us to send less aggressively.
  116. */
  117. return err == NET_XMIT_CN ? 0 : err;
  118. }
  119. return -ENOBUFS;
  120. }
  121. unsigned int dccp_sync_mss(struct sock *sk, u32 pmtu)
  122. {
  123. struct inet_connection_sock *icsk = inet_csk(sk);
  124. struct dccp_sock *dp = dccp_sk(sk);
  125. int mss_now = (pmtu - icsk->icsk_af_ops->net_header_len -
  126. sizeof(struct dccp_hdr) - sizeof(struct dccp_hdr_ext));
  127. /* Now subtract optional transport overhead */
  128. mss_now -= icsk->icsk_ext_hdr_len;
  129. /*
  130. * FIXME: this should come from the CCID infrastructure, where, say,
  131. * TFRC will say it wants TIMESTAMPS, ELAPSED time, etc, for now lets
  132. * put a rough estimate for NDP + TIMESTAMP + TIMESTAMP_ECHO + ELAPSED
  133. * TIME + TFRC_OPT_LOSS_EVENT_RATE + TFRC_OPT_RECEIVE_RATE + padding to
  134. * make it a multiple of 4
  135. */
  136. mss_now -= ((5 + 6 + 10 + 6 + 6 + 6 + 3) / 4) * 4;
  137. /* And store cached results */
  138. icsk->icsk_pmtu_cookie = pmtu;
  139. dp->dccps_mss_cache = mss_now;
  140. return mss_now;
  141. }
  142. EXPORT_SYMBOL_GPL(dccp_sync_mss);
  143. void dccp_write_space(struct sock *sk)
  144. {
  145. read_lock(&sk->sk_callback_lock);
  146. if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
  147. wake_up_interruptible(sk->sk_sleep);
  148. /* Should agree with poll, otherwise some programs break */
  149. if (sock_writeable(sk))
  150. sk_wake_async(sk, 2, POLL_OUT);
  151. read_unlock(&sk->sk_callback_lock);
  152. }
  153. /**
  154. * dccp_wait_for_ccid - Wait for ccid to tell us we can send a packet
  155. * @sk: socket to wait for
  156. * @timeo: for how long
  157. */
  158. static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb,
  159. long *timeo)
  160. {
  161. struct dccp_sock *dp = dccp_sk(sk);
  162. DEFINE_WAIT(wait);
  163. long delay;
  164. int rc;
  165. while (1) {
  166. prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
  167. if (sk->sk_err)
  168. goto do_error;
  169. if (!*timeo)
  170. goto do_nonblock;
  171. if (signal_pending(current))
  172. goto do_interrupted;
  173. rc = ccid_hc_tx_send_packet(dp->dccps_hc_tx_ccid, sk, skb,
  174. skb->len);
  175. if (rc <= 0)
  176. break;
  177. delay = msecs_to_jiffies(rc);
  178. if (delay > *timeo || delay < 0)
  179. goto do_nonblock;
  180. sk->sk_write_pending++;
  181. release_sock(sk);
  182. *timeo -= schedule_timeout(delay);
  183. lock_sock(sk);
  184. sk->sk_write_pending--;
  185. }
  186. out:
  187. finish_wait(sk->sk_sleep, &wait);
  188. return rc;
  189. do_error:
  190. rc = -EPIPE;
  191. goto out;
  192. do_nonblock:
  193. rc = -EAGAIN;
  194. goto out;
  195. do_interrupted:
  196. rc = sock_intr_errno(*timeo);
  197. goto out;
  198. }
  199. static void dccp_write_xmit_timer(unsigned long data) {
  200. struct sock *sk = (struct sock *)data;
  201. struct dccp_sock *dp = dccp_sk(sk);
  202. bh_lock_sock(sk);
  203. if (sock_owned_by_user(sk))
  204. sk_reset_timer(sk, &dp->dccps_xmit_timer, jiffies+1);
  205. else
  206. dccp_write_xmit(sk, 0);
  207. bh_unlock_sock(sk);
  208. sock_put(sk);
  209. }
  210. void dccp_write_xmit(struct sock *sk, int block)
  211. {
  212. struct dccp_sock *dp = dccp_sk(sk);
  213. struct sk_buff *skb;
  214. long timeo = 30000; /* If a packet is taking longer than 2 secs
  215. we have other issues */
  216. while ((skb = skb_peek(&sk->sk_write_queue))) {
  217. int err = ccid_hc_tx_send_packet(dp->dccps_hc_tx_ccid, sk, skb,
  218. skb->len);
  219. if (err > 0) {
  220. if (!block) {
  221. sk_reset_timer(sk, &dp->dccps_xmit_timer,
  222. msecs_to_jiffies(err)+jiffies);
  223. break;
  224. } else
  225. err = dccp_wait_for_ccid(sk, skb, &timeo);
  226. if (err) {
  227. printk(KERN_CRIT "%s:err at dccp_wait_for_ccid"
  228. " %d\n", __FUNCTION__, err);
  229. dump_stack();
  230. }
  231. }
  232. skb_dequeue(&sk->sk_write_queue);
  233. if (err == 0) {
  234. struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
  235. const int len = skb->len;
  236. if (sk->sk_state == DCCP_PARTOPEN) {
  237. /* See 8.1.5. Handshake Completion */
  238. inet_csk_schedule_ack(sk);
  239. inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
  240. inet_csk(sk)->icsk_rto,
  241. DCCP_RTO_MAX);
  242. dcb->dccpd_type = DCCP_PKT_DATAACK;
  243. } else if (dccp_ack_pending(sk))
  244. dcb->dccpd_type = DCCP_PKT_DATAACK;
  245. else
  246. dcb->dccpd_type = DCCP_PKT_DATA;
  247. err = dccp_transmit_skb(sk, skb);
  248. ccid_hc_tx_packet_sent(dp->dccps_hc_tx_ccid, sk, 0, len);
  249. if (err) {
  250. printk(KERN_CRIT "%s:err from "
  251. "ccid_hc_tx_packet_sent %d\n",
  252. __FUNCTION__, err);
  253. dump_stack();
  254. }
  255. } else
  256. kfree(skb);
  257. }
  258. }
  259. int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
  260. {
  261. if (inet_csk(sk)->icsk_af_ops->rebuild_header(sk) != 0)
  262. return -EHOSTUNREACH; /* Routing failure or similar. */
  263. return dccp_transmit_skb(sk, (skb_cloned(skb) ?
  264. pskb_copy(skb, GFP_ATOMIC):
  265. skb_clone(skb, GFP_ATOMIC)));
  266. }
  267. struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst,
  268. struct request_sock *req)
  269. {
  270. struct dccp_hdr *dh;
  271. struct dccp_request_sock *dreq;
  272. const u32 dccp_header_size = sizeof(struct dccp_hdr) +
  273. sizeof(struct dccp_hdr_ext) +
  274. sizeof(struct dccp_hdr_response);
  275. struct sk_buff *skb = sock_wmalloc(sk, sk->sk_prot->max_header, 1,
  276. GFP_ATOMIC);
  277. if (skb == NULL)
  278. return NULL;
  279. /* Reserve space for headers. */
  280. skb_reserve(skb, sk->sk_prot->max_header);
  281. skb->dst = dst_clone(dst);
  282. skb->csum = 0;
  283. dreq = dccp_rsk(req);
  284. DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_RESPONSE;
  285. DCCP_SKB_CB(skb)->dccpd_seq = dreq->dreq_iss;
  286. if (dccp_insert_options(sk, skb)) {
  287. kfree_skb(skb);
  288. return NULL;
  289. }
  290. skb->h.raw = skb_push(skb, dccp_header_size);
  291. dh = dccp_hdr(skb);
  292. memset(dh, 0, dccp_header_size);
  293. dh->dccph_sport = inet_sk(sk)->sport;
  294. dh->dccph_dport = inet_rsk(req)->rmt_port;
  295. dh->dccph_doff = (dccp_header_size +
  296. DCCP_SKB_CB(skb)->dccpd_opt_len) / 4;
  297. dh->dccph_type = DCCP_PKT_RESPONSE;
  298. dh->dccph_x = 1;
  299. dccp_hdr_set_seq(dh, dreq->dreq_iss);
  300. dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), dreq->dreq_isr);
  301. dccp_hdr_response(skb)->dccph_resp_service = dreq->dreq_service;
  302. DCCP_INC_STATS(DCCP_MIB_OUTSEGS);
  303. return skb;
  304. }
  305. EXPORT_SYMBOL_GPL(dccp_make_response);
  306. static struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst,
  307. const enum dccp_reset_codes code)
  308. {
  309. struct dccp_hdr *dh;
  310. struct dccp_sock *dp = dccp_sk(sk);
  311. const u32 dccp_header_size = sizeof(struct dccp_hdr) +
  312. sizeof(struct dccp_hdr_ext) +
  313. sizeof(struct dccp_hdr_reset);
  314. struct sk_buff *skb = sock_wmalloc(sk, sk->sk_prot->max_header, 1,
  315. GFP_ATOMIC);
  316. if (skb == NULL)
  317. return NULL;
  318. /* Reserve space for headers. */
  319. skb_reserve(skb, sk->sk_prot->max_header);
  320. skb->dst = dst_clone(dst);
  321. skb->csum = 0;
  322. dccp_inc_seqno(&dp->dccps_gss);
  323. DCCP_SKB_CB(skb)->dccpd_reset_code = code;
  324. DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_RESET;
  325. DCCP_SKB_CB(skb)->dccpd_seq = dp->dccps_gss;
  326. if (dccp_insert_options(sk, skb)) {
  327. kfree_skb(skb);
  328. return NULL;
  329. }
  330. skb->h.raw = skb_push(skb, dccp_header_size);
  331. dh = dccp_hdr(skb);
  332. memset(dh, 0, dccp_header_size);
  333. dh->dccph_sport = inet_sk(sk)->sport;
  334. dh->dccph_dport = inet_sk(sk)->dport;
  335. dh->dccph_doff = (dccp_header_size +
  336. DCCP_SKB_CB(skb)->dccpd_opt_len) / 4;
  337. dh->dccph_type = DCCP_PKT_RESET;
  338. dh->dccph_x = 1;
  339. dccp_hdr_set_seq(dh, dp->dccps_gss);
  340. dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), dp->dccps_gsr);
  341. dccp_hdr_reset(skb)->dccph_reset_code = code;
  342. inet_csk(sk)->icsk_af_ops->send_check(sk, skb->len, skb);
  343. DCCP_INC_STATS(DCCP_MIB_OUTSEGS);
  344. return skb;
  345. }
  346. int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code)
  347. {
  348. /*
  349. * FIXME: what if rebuild_header fails?
  350. * Should we be doing a rebuild_header here?
  351. */
  352. int err = inet_sk_rebuild_header(sk);
  353. if (err == 0) {
  354. struct sk_buff *skb = dccp_make_reset(sk, sk->sk_dst_cache,
  355. code);
  356. if (skb != NULL) {
  357. memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
  358. err = inet_csk(sk)->icsk_af_ops->queue_xmit(skb, 0);
  359. if (err == NET_XMIT_CN)
  360. err = 0;
  361. }
  362. }
  363. return err;
  364. }
  365. /*
  366. * Do all connect socket setups that can be done AF independent.
  367. */
  368. static inline void dccp_connect_init(struct sock *sk)
  369. {
  370. struct dccp_sock *dp = dccp_sk(sk);
  371. struct dst_entry *dst = __sk_dst_get(sk);
  372. struct inet_connection_sock *icsk = inet_csk(sk);
  373. sk->sk_err = 0;
  374. sock_reset_flag(sk, SOCK_DONE);
  375. dccp_sync_mss(sk, dst_mtu(dst));
  376. dccp_update_gss(sk, dp->dccps_iss);
  377. /*
  378. * SWL and AWL are initially adjusted so that they are not less than
  379. * the initial Sequence Numbers received and sent, respectively:
  380. * SWL := max(GSR + 1 - floor(W/4), ISR),
  381. * AWL := max(GSS - W' + 1, ISS).
  382. * These adjustments MUST be applied only at the beginning of the
  383. * connection.
  384. */
  385. dccp_set_seqno(&dp->dccps_awl, max48(dp->dccps_awl, dp->dccps_iss));
  386. icsk->icsk_retransmits = 0;
  387. init_timer(&dp->dccps_xmit_timer);
  388. dp->dccps_xmit_timer.data = (unsigned long)sk;
  389. dp->dccps_xmit_timer.function = dccp_write_xmit_timer;
  390. }
  391. int dccp_connect(struct sock *sk)
  392. {
  393. struct sk_buff *skb;
  394. struct inet_connection_sock *icsk = inet_csk(sk);
  395. dccp_connect_init(sk);
  396. skb = alloc_skb(sk->sk_prot->max_header, sk->sk_allocation);
  397. if (unlikely(skb == NULL))
  398. return -ENOBUFS;
  399. /* Reserve space for headers. */
  400. skb_reserve(skb, sk->sk_prot->max_header);
  401. DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_REQUEST;
  402. skb->csum = 0;
  403. dccp_skb_entail(sk, skb);
  404. dccp_transmit_skb(sk, skb_clone(skb, GFP_KERNEL));
  405. DCCP_INC_STATS(DCCP_MIB_ACTIVEOPENS);
  406. /* Timer for repeating the REQUEST until an answer. */
  407. inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
  408. icsk->icsk_rto, DCCP_RTO_MAX);
  409. return 0;
  410. }
  411. EXPORT_SYMBOL_GPL(dccp_connect);
  412. void dccp_send_ack(struct sock *sk)
  413. {
  414. /* If we have been reset, we may not send again. */
  415. if (sk->sk_state != DCCP_CLOSED) {
  416. struct sk_buff *skb = alloc_skb(sk->sk_prot->max_header,
  417. GFP_ATOMIC);
  418. if (skb == NULL) {
  419. inet_csk_schedule_ack(sk);
  420. inet_csk(sk)->icsk_ack.ato = TCP_ATO_MIN;
  421. inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
  422. TCP_DELACK_MAX,
  423. DCCP_RTO_MAX);
  424. return;
  425. }
  426. /* Reserve space for headers */
  427. skb_reserve(skb, sk->sk_prot->max_header);
  428. skb->csum = 0;
  429. DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_ACK;
  430. dccp_transmit_skb(sk, skb);
  431. }
  432. }
  433. EXPORT_SYMBOL_GPL(dccp_send_ack);
  434. void dccp_send_delayed_ack(struct sock *sk)
  435. {
  436. struct inet_connection_sock *icsk = inet_csk(sk);
  437. /*
  438. * FIXME: tune this timer. elapsed time fixes the skew, so no problem
  439. * with using 2s, and active senders also piggyback the ACK into a
  440. * DATAACK packet, so this is really for quiescent senders.
  441. */
  442. unsigned long timeout = jiffies + 2 * HZ;
  443. /* Use new timeout only if there wasn't a older one earlier. */
  444. if (icsk->icsk_ack.pending & ICSK_ACK_TIMER) {
  445. /* If delack timer was blocked or is about to expire,
  446. * send ACK now.
  447. *
  448. * FIXME: check the "about to expire" part
  449. */
  450. if (icsk->icsk_ack.blocked) {
  451. dccp_send_ack(sk);
  452. return;
  453. }
  454. if (!time_before(timeout, icsk->icsk_ack.timeout))
  455. timeout = icsk->icsk_ack.timeout;
  456. }
  457. icsk->icsk_ack.pending |= ICSK_ACK_SCHED | ICSK_ACK_TIMER;
  458. icsk->icsk_ack.timeout = timeout;
  459. sk_reset_timer(sk, &icsk->icsk_delack_timer, timeout);
  460. }
  461. void dccp_send_sync(struct sock *sk, const u64 seq,
  462. const enum dccp_pkt_type pkt_type)
  463. {
  464. /*
  465. * We are not putting this on the write queue, so
  466. * dccp_transmit_skb() will set the ownership to this
  467. * sock.
  468. */
  469. struct sk_buff *skb = alloc_skb(sk->sk_prot->max_header, GFP_ATOMIC);
  470. if (skb == NULL)
  471. /* FIXME: how to make sure the sync is sent? */
  472. return;
  473. /* Reserve space for headers and prepare control bits. */
  474. skb_reserve(skb, sk->sk_prot->max_header);
  475. skb->csum = 0;
  476. DCCP_SKB_CB(skb)->dccpd_type = pkt_type;
  477. DCCP_SKB_CB(skb)->dccpd_seq = seq;
  478. dccp_transmit_skb(sk, skb);
  479. }
  480. EXPORT_SYMBOL_GPL(dccp_send_sync);
  481. /*
  482. * Send a DCCP_PKT_CLOSE/CLOSEREQ. The caller locks the socket for us. This
  483. * cannot be allowed to fail queueing a DCCP_PKT_CLOSE/CLOSEREQ frame under
  484. * any circumstances.
  485. */
  486. void dccp_send_close(struct sock *sk, const int active)
  487. {
  488. struct dccp_sock *dp = dccp_sk(sk);
  489. struct sk_buff *skb;
  490. const gfp_t prio = active ? GFP_KERNEL : GFP_ATOMIC;
  491. skb = alloc_skb(sk->sk_prot->max_header, prio);
  492. if (skb == NULL)
  493. return;
  494. /* Reserve space for headers and prepare control bits. */
  495. skb_reserve(skb, sk->sk_prot->max_header);
  496. skb->csum = 0;
  497. DCCP_SKB_CB(skb)->dccpd_type = dp->dccps_role == DCCP_ROLE_CLIENT ?
  498. DCCP_PKT_CLOSE : DCCP_PKT_CLOSEREQ;
  499. if (active) {
  500. dccp_write_xmit(sk, 1);
  501. dccp_skb_entail(sk, skb);
  502. dccp_transmit_skb(sk, skb_clone(skb, prio));
  503. /* FIXME do we need a retransmit timer here? */
  504. } else
  505. dccp_transmit_skb(sk, skb);
  506. }