17c657876SArnaldo Carvalho de Melo /* 27c657876SArnaldo Carvalho de Melo * net/dccp/output.c 37c657876SArnaldo Carvalho de Melo * 47c657876SArnaldo Carvalho de Melo * An implementation of the DCCP protocol 57c657876SArnaldo Carvalho de Melo * Arnaldo Carvalho de Melo <acme@conectiva.com.br> 67c657876SArnaldo Carvalho de Melo * 77c657876SArnaldo Carvalho de Melo * This program is free software; you can redistribute it and/or 87c657876SArnaldo Carvalho de Melo * modify it under the terms of the GNU General Public License 97c657876SArnaldo Carvalho de Melo * as published by the Free Software Foundation; either version 107c657876SArnaldo Carvalho de Melo * 2 of the License, or (at your option) any later version. 117c657876SArnaldo Carvalho de Melo */ 127c657876SArnaldo Carvalho de Melo 137c657876SArnaldo Carvalho de Melo #include <linux/dccp.h> 1448918a4dSHerbert Xu #include <linux/kernel.h> 157c657876SArnaldo Carvalho de Melo #include <linux/skbuff.h> 165a0e3ad6STejun Heo #include <linux/slab.h> 177c657876SArnaldo Carvalho de Melo 1814c85021SArnaldo Carvalho de Melo #include <net/inet_sock.h> 197c657876SArnaldo Carvalho de Melo #include <net/sock.h> 207c657876SArnaldo Carvalho de Melo 21ae31c339SArnaldo Carvalho de Melo #include "ackvec.h" 227c657876SArnaldo Carvalho de Melo #include "ccid.h" 237c657876SArnaldo Carvalho de Melo #include "dccp.h" 247c657876SArnaldo Carvalho de Melo 257c657876SArnaldo Carvalho de Melo static inline void dccp_event_ack_sent(struct sock *sk) 267c657876SArnaldo Carvalho de Melo { 277c657876SArnaldo Carvalho de Melo inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK); 287c657876SArnaldo Carvalho de Melo } 297c657876SArnaldo Carvalho de Melo 30c25a18baSArnaldo Carvalho de Melo static void dccp_skb_entail(struct sock *sk, struct sk_buff *skb) 3148918a4dSHerbert Xu { 3248918a4dSHerbert Xu skb_set_owner_w(skb, sk); 3348918a4dSHerbert Xu WARN_ON(sk->sk_send_head); 3448918a4dSHerbert Xu sk->sk_send_head = skb; 3548918a4dSHerbert Xu } 3648918a4dSHerbert Xu 377c657876SArnaldo Carvalho de Melo /* 387c657876SArnaldo Carvalho de Melo * All SKB's seen here are completely headerless. It is our 397c657876SArnaldo Carvalho de Melo * job to build the DCCP header, and pass the packet down to 407c657876SArnaldo Carvalho de Melo * IP so it can do the same plus pass the packet off to the 417c657876SArnaldo Carvalho de Melo * device. 427c657876SArnaldo Carvalho de Melo */ 4348918a4dSHerbert Xu static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb) 447c657876SArnaldo Carvalho de Melo { 457c657876SArnaldo Carvalho de Melo if (likely(skb != NULL)) { 467c657876SArnaldo Carvalho de Melo const struct inet_sock *inet = inet_sk(sk); 4757cca05aSArnaldo Carvalho de Melo const struct inet_connection_sock *icsk = inet_csk(sk); 487c657876SArnaldo Carvalho de Melo struct dccp_sock *dp = dccp_sk(sk); 497c657876SArnaldo Carvalho de Melo struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb); 507c657876SArnaldo Carvalho de Melo struct dccp_hdr *dh; 517c657876SArnaldo Carvalho de Melo /* XXX For now we're using only 48 bits sequence numbers */ 52118b2c95SArnaldo Carvalho de Melo const u32 dccp_header_size = sizeof(*dh) + 537c657876SArnaldo Carvalho de Melo sizeof(struct dccp_hdr_ext) + 547c657876SArnaldo Carvalho de Melo dccp_packet_hdr_len(dcb->dccpd_type); 557c657876SArnaldo Carvalho de Melo int err, set_ack = 1; 567c657876SArnaldo Carvalho de Melo u64 ackno = dp->dccps_gsr; 5773f18fdbSGerrit Renker /* 5873f18fdbSGerrit Renker * Increment GSS here already in case the option code needs it. 5973f18fdbSGerrit Renker * Update GSS for real only if option processing below succeeds. 6073f18fdbSGerrit Renker */ 6173f18fdbSGerrit Renker dcb->dccpd_seq = ADD48(dp->dccps_gss, 1); 627c657876SArnaldo Carvalho de Melo 637c657876SArnaldo Carvalho de Melo switch (dcb->dccpd_type) { 647c657876SArnaldo Carvalho de Melo case DCCP_PKT_DATA: 657c657876SArnaldo Carvalho de Melo set_ack = 0; 66edc9e819SHerbert Xu /* fall through */ 67edc9e819SHerbert Xu case DCCP_PKT_DATAACK: 68ee1a1592SGerrit Renker case DCCP_PKT_RESET: 697c657876SArnaldo Carvalho de Melo break; 70edc9e819SHerbert Xu 71afe00251SAndrea Bittau case DCCP_PKT_REQUEST: 72afe00251SAndrea Bittau set_ack = 0; 7373f18fdbSGerrit Renker /* Use ISS on the first (non-retransmitted) Request. */ 7473f18fdbSGerrit Renker if (icsk->icsk_retransmits == 0) 7573f18fdbSGerrit Renker dcb->dccpd_seq = dp->dccps_iss; 76afe00251SAndrea Bittau /* fall through */ 77afe00251SAndrea Bittau 787c657876SArnaldo Carvalho de Melo case DCCP_PKT_SYNC: 797c657876SArnaldo Carvalho de Melo case DCCP_PKT_SYNCACK: 80b0d045caSGerrit Renker ackno = dcb->dccpd_ack_seq; 81edc9e819SHerbert Xu /* fall through */ 82edc9e819SHerbert Xu default: 83edc9e819SHerbert Xu /* 84ee1a1592SGerrit Renker * Set owner/destructor: some skbs are allocated via 85ee1a1592SGerrit Renker * alloc_skb (e.g. when retransmission may happen). 86ee1a1592SGerrit Renker * Only Data, DataAck, and Reset packets should come 87ee1a1592SGerrit Renker * through here with skb->sk set. 88edc9e819SHerbert Xu */ 89edc9e819SHerbert Xu WARN_ON(skb->sk); 90edc9e819SHerbert Xu skb_set_owner_w(skb, sk); 917c657876SArnaldo Carvalho de Melo break; 927c657876SArnaldo Carvalho de Melo } 937c657876SArnaldo Carvalho de Melo 942d0817d1SArnaldo Carvalho de Melo if (dccp_insert_options(sk, skb)) { 952d0817d1SArnaldo Carvalho de Melo kfree_skb(skb); 962d0817d1SArnaldo Carvalho de Melo return -EPROTO; 972d0817d1SArnaldo Carvalho de Melo } 9824117727SArnaldo Carvalho de Melo 99fda0fd6cSHerbert Xu 1007c657876SArnaldo Carvalho de Melo /* Build DCCP header and checksum it. */ 1019b42078eSGerrit Renker dh = dccp_zeroed_hdr(skb, dccp_header_size); 1027c657876SArnaldo Carvalho de Melo dh->dccph_type = dcb->dccpd_type; 103c720c7e8SEric Dumazet dh->dccph_sport = inet->inet_sport; 104c720c7e8SEric Dumazet dh->dccph_dport = inet->inet_dport; 1057c657876SArnaldo Carvalho de Melo dh->dccph_doff = (dccp_header_size + dcb->dccpd_opt_len) / 4; 1067c657876SArnaldo Carvalho de Melo dh->dccph_ccval = dcb->dccpd_ccval; 1076f4e5fffSGerrit Renker dh->dccph_cscov = dp->dccps_pcslen; 1087c657876SArnaldo Carvalho de Melo /* XXX For now we're using only 48 bits sequence numbers */ 1097c657876SArnaldo Carvalho de Melo dh->dccph_x = 1; 1107c657876SArnaldo Carvalho de Melo 11173f18fdbSGerrit Renker dccp_update_gss(sk, dcb->dccpd_seq); 1127c657876SArnaldo Carvalho de Melo dccp_hdr_set_seq(dh, dp->dccps_gss); 1137c657876SArnaldo Carvalho de Melo if (set_ack) 1147c657876SArnaldo Carvalho de Melo dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), ackno); 1157c657876SArnaldo Carvalho de Melo 1167c657876SArnaldo Carvalho de Melo switch (dcb->dccpd_type) { 1177c657876SArnaldo Carvalho de Melo case DCCP_PKT_REQUEST: 1187690af3fSArnaldo Carvalho de Melo dccp_hdr_request(skb)->dccph_req_service = 11967e6b629SArnaldo Carvalho de Melo dp->dccps_service; 12073f18fdbSGerrit Renker /* 12173f18fdbSGerrit Renker * Limit Ack window to ISS <= P.ackno <= GSS, so that 12273f18fdbSGerrit Renker * only Responses to Requests we sent are considered. 12373f18fdbSGerrit Renker */ 12473f18fdbSGerrit Renker dp->dccps_awl = dp->dccps_iss; 1257c657876SArnaldo Carvalho de Melo break; 1267c657876SArnaldo Carvalho de Melo case DCCP_PKT_RESET: 1277690af3fSArnaldo Carvalho de Melo dccp_hdr_reset(skb)->dccph_reset_code = 1287690af3fSArnaldo Carvalho de Melo dcb->dccpd_reset_code; 1297c657876SArnaldo Carvalho de Melo break; 1307c657876SArnaldo Carvalho de Melo } 1317c657876SArnaldo Carvalho de Melo 132bb296246SHerbert Xu icsk->icsk_af_ops->send_check(sk, skb); 1337c657876SArnaldo Carvalho de Melo 1347ad07e7cSArnaldo Carvalho de Melo if (set_ack) 1357c657876SArnaldo Carvalho de Melo dccp_event_ack_sent(sk); 1367c657876SArnaldo Carvalho de Melo 1377c657876SArnaldo Carvalho de Melo DCCP_INC_STATS(DCCP_MIB_OUTSEGS); 1387c657876SArnaldo Carvalho de Melo 1394e15ed4dSShan Wei err = icsk->icsk_af_ops->queue_xmit(skb); 140b9df3cb8SGerrit Renker return net_xmit_eval(err); 1417c657876SArnaldo Carvalho de Melo } 1427c657876SArnaldo Carvalho de Melo return -ENOBUFS; 1437c657876SArnaldo Carvalho de Melo } 1447c657876SArnaldo Carvalho de Melo 1456179983aSGerrit Renker /** 1466179983aSGerrit Renker * dccp_determine_ccmps - Find out about CCID-specfic packet-size limits 1476179983aSGerrit Renker * We only consider the HC-sender CCID for setting the CCMPS (RFC 4340, 14.), 1486179983aSGerrit Renker * since the RX CCID is restricted to feedback packets (Acks), which are small 1496179983aSGerrit Renker * in comparison with the data traffic. A value of 0 means "no current CCMPS". 1506179983aSGerrit Renker */ 1516179983aSGerrit Renker static u32 dccp_determine_ccmps(const struct dccp_sock *dp) 1526179983aSGerrit Renker { 1536179983aSGerrit Renker const struct ccid *tx_ccid = dp->dccps_hc_tx_ccid; 1546179983aSGerrit Renker 1556179983aSGerrit Renker if (tx_ccid == NULL || tx_ccid->ccid_ops == NULL) 1566179983aSGerrit Renker return 0; 1576179983aSGerrit Renker return tx_ccid->ccid_ops->ccid_ccmps; 1586179983aSGerrit Renker } 1596179983aSGerrit Renker 1607c657876SArnaldo Carvalho de Melo unsigned int dccp_sync_mss(struct sock *sk, u32 pmtu) 1617c657876SArnaldo Carvalho de Melo { 162d83d8461SArnaldo Carvalho de Melo struct inet_connection_sock *icsk = inet_csk(sk); 1637c657876SArnaldo Carvalho de Melo struct dccp_sock *dp = dccp_sk(sk); 1646179983aSGerrit Renker u32 ccmps = dccp_determine_ccmps(dp); 165361a5c1dSGerrit Renker u32 cur_mps = ccmps ? min(pmtu, ccmps) : pmtu; 1667c657876SArnaldo Carvalho de Melo 1676179983aSGerrit Renker /* Account for header lengths and IPv4/v6 option overhead */ 1686179983aSGerrit Renker cur_mps -= (icsk->icsk_af_ops->net_header_len + icsk->icsk_ext_hdr_len + 1696179983aSGerrit Renker sizeof(struct dccp_hdr) + sizeof(struct dccp_hdr_ext)); 1707c657876SArnaldo Carvalho de Melo 1717c657876SArnaldo Carvalho de Melo /* 172361a5c1dSGerrit Renker * Leave enough headroom for common DCCP header options. 173361a5c1dSGerrit Renker * This only considers options which may appear on DCCP-Data packets, as 174361a5c1dSGerrit Renker * per table 3 in RFC 4340, 5.8. When running out of space for other 175361a5c1dSGerrit Renker * options (eg. Ack Vector which can take up to 255 bytes), it is better 176361a5c1dSGerrit Renker * to schedule a separate Ack. Thus we leave headroom for the following: 177361a5c1dSGerrit Renker * - 1 byte for Slow Receiver (11.6) 178361a5c1dSGerrit Renker * - 6 bytes for Timestamp (13.1) 179361a5c1dSGerrit Renker * - 10 bytes for Timestamp Echo (13.3) 180361a5c1dSGerrit Renker * - 8 bytes for NDP count (7.7, when activated) 181361a5c1dSGerrit Renker * - 6 bytes for Data Checksum (9.3) 182361a5c1dSGerrit Renker * - %DCCPAV_MIN_OPTLEN bytes for Ack Vector size (11.4, when enabled) 1837c657876SArnaldo Carvalho de Melo */ 184361a5c1dSGerrit Renker cur_mps -= roundup(1 + 6 + 10 + dp->dccps_send_ndp_count * 8 + 6 + 185361a5c1dSGerrit Renker (dp->dccps_hc_rx_ackvec ? DCCPAV_MIN_OPTLEN : 0), 4); 1867c657876SArnaldo Carvalho de Melo 1877c657876SArnaldo Carvalho de Melo /* And store cached results */ 188d83d8461SArnaldo Carvalho de Melo icsk->icsk_pmtu_cookie = pmtu; 1896179983aSGerrit Renker dp->dccps_mss_cache = cur_mps; 1907c657876SArnaldo Carvalho de Melo 1916179983aSGerrit Renker return cur_mps; 1927c657876SArnaldo Carvalho de Melo } 1937c657876SArnaldo Carvalho de Melo 194f21e68caSArnaldo Carvalho de Melo EXPORT_SYMBOL_GPL(dccp_sync_mss); 195f21e68caSArnaldo Carvalho de Melo 196c530cfb1SArnaldo Carvalho de Melo void dccp_write_space(struct sock *sk) 197c530cfb1SArnaldo Carvalho de Melo { 19843815482SEric Dumazet struct socket_wq *wq; 199c530cfb1SArnaldo Carvalho de Melo 20043815482SEric Dumazet rcu_read_lock(); 20143815482SEric Dumazet wq = rcu_dereference(sk->sk_wq); 20243815482SEric Dumazet if (wq_has_sleeper(wq)) 20343815482SEric Dumazet wake_up_interruptible(&wq->wait); 204c530cfb1SArnaldo Carvalho de Melo /* Should agree with poll, otherwise some programs break */ 205c530cfb1SArnaldo Carvalho de Melo if (sock_writeable(sk)) 2068d8ad9d7SPavel Emelyanov sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); 207c530cfb1SArnaldo Carvalho de Melo 20843815482SEric Dumazet rcu_read_unlock(); 209c530cfb1SArnaldo Carvalho de Melo } 210c530cfb1SArnaldo Carvalho de Melo 211d6809c12SArnaldo Carvalho de Melo /** 212d6809c12SArnaldo Carvalho de Melo * dccp_wait_for_ccid - Wait for ccid to tell us we can send a packet 213d6809c12SArnaldo Carvalho de Melo * @sk: socket to wait for 214bc849872SGerrit Renker * @skb: current skb to pass on for waiting 215bc849872SGerrit Renker * @delay: sleep timeout in milliseconds (> 0) 216bc849872SGerrit Renker * This function is called by default when the socket is closed, and 217bc849872SGerrit Renker * when a non-zero linger time is set on the socket. For consistency 218d6809c12SArnaldo Carvalho de Melo */ 219bc849872SGerrit Renker static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb, int delay) 220d6809c12SArnaldo Carvalho de Melo { 221d6809c12SArnaldo Carvalho de Melo struct dccp_sock *dp = dccp_sk(sk); 222d6809c12SArnaldo Carvalho de Melo DEFINE_WAIT(wait); 223bc849872SGerrit Renker unsigned long jiffdelay; 224d6809c12SArnaldo Carvalho de Melo int rc; 225d6809c12SArnaldo Carvalho de Melo 226bc849872SGerrit Renker do { 227bc849872SGerrit Renker dccp_pr_debug("delayed send by %d msec\n", delay); 228bc849872SGerrit Renker jiffdelay = msecs_to_jiffies(delay); 229bc849872SGerrit Renker 230aa395145SEric Dumazet prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); 231d6809c12SArnaldo Carvalho de Melo 232bc849872SGerrit Renker sk->sk_write_pending++; 233bc849872SGerrit Renker release_sock(sk); 234bc849872SGerrit Renker schedule_timeout(jiffdelay); 235bc849872SGerrit Renker lock_sock(sk); 236bc849872SGerrit Renker sk->sk_write_pending--; 237bc849872SGerrit Renker 23897e5848dSIan McDonald if (sk->sk_err) 239d6809c12SArnaldo Carvalho de Melo goto do_error; 240d6809c12SArnaldo Carvalho de Melo if (signal_pending(current)) 241d6809c12SArnaldo Carvalho de Melo goto do_interrupted; 242d6809c12SArnaldo Carvalho de Melo 2436b57c93dSGerrit Renker rc = ccid_hc_tx_send_packet(dp->dccps_hc_tx_ccid, sk, skb); 244bc849872SGerrit Renker } while ((delay = rc) > 0); 245d6809c12SArnaldo Carvalho de Melo out: 246aa395145SEric Dumazet finish_wait(sk_sleep(sk), &wait); 247d6809c12SArnaldo Carvalho de Melo return rc; 248d6809c12SArnaldo Carvalho de Melo 249d6809c12SArnaldo Carvalho de Melo do_error: 250d6809c12SArnaldo Carvalho de Melo rc = -EPIPE; 251d6809c12SArnaldo Carvalho de Melo goto out; 252d6809c12SArnaldo Carvalho de Melo do_interrupted: 2535cc3741dSIan McDonald rc = -EINTR; 254d6809c12SArnaldo Carvalho de Melo goto out; 255d6809c12SArnaldo Carvalho de Melo } 256d6809c12SArnaldo Carvalho de Melo 25797e5848dSIan McDonald void dccp_write_xmit(struct sock *sk, int block) 25827258ee5SArnaldo Carvalho de Melo { 25997e5848dSIan McDonald struct dccp_sock *dp = dccp_sk(sk); 26097e5848dSIan McDonald struct sk_buff *skb; 26197e5848dSIan McDonald 26297e5848dSIan McDonald while ((skb = skb_peek(&sk->sk_write_queue))) { 2636b57c93dSGerrit Renker int err = ccid_hc_tx_send_packet(dp->dccps_hc_tx_ccid, sk, skb); 264d6809c12SArnaldo Carvalho de Melo 26597e5848dSIan McDonald if (err > 0) { 26697e5848dSIan McDonald if (!block) { 26797e5848dSIan McDonald sk_reset_timer(sk, &dp->dccps_xmit_timer, 26897e5848dSIan McDonald msecs_to_jiffies(err)+jiffies); 26997e5848dSIan McDonald break; 2705cc3741dSIan McDonald } else 271bc849872SGerrit Renker err = dccp_wait_for_ccid(sk, skb, err); 272f6282f4dSGerrit Renker if (err && err != -EINTR) 27359348b19SGerrit Renker DCCP_BUG("err=%d after dccp_wait_for_ccid", err); 27497e5848dSIan McDonald } 27527258ee5SArnaldo Carvalho de Melo 27697e5848dSIan McDonald skb_dequeue(&sk->sk_write_queue); 27727258ee5SArnaldo Carvalho de Melo if (err == 0) { 27827258ee5SArnaldo Carvalho de Melo struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb); 279d6809c12SArnaldo Carvalho de Melo const int len = skb->len; 28027258ee5SArnaldo Carvalho de Melo 28127258ee5SArnaldo Carvalho de Melo if (sk->sk_state == DCCP_PARTOPEN) { 28286739fb9SGerrit Renker const u32 cur_mps = dp->dccps_mss_cache - DCCP_FEATNEG_OVERHEAD; 28386739fb9SGerrit Renker /* 28486739fb9SGerrit Renker * See 8.1.5 - Handshake Completion. 28586739fb9SGerrit Renker * 28686739fb9SGerrit Renker * For robustness we resend Confirm options until the client has 28786739fb9SGerrit Renker * entered OPEN. During the initial feature negotiation, the MPS 28886739fb9SGerrit Renker * is smaller than usual, reduced by the Change/Confirm options. 28986739fb9SGerrit Renker */ 29086739fb9SGerrit Renker if (!list_empty(&dp->dccps_featneg) && len > cur_mps) { 29186739fb9SGerrit Renker DCCP_WARN("Payload too large (%d) for featneg.\n", len); 29286739fb9SGerrit Renker dccp_send_ack(sk); 29386739fb9SGerrit Renker dccp_feat_list_purge(&dp->dccps_featneg); 29486739fb9SGerrit Renker } 29586739fb9SGerrit Renker 29627258ee5SArnaldo Carvalho de Melo inet_csk_schedule_ack(sk); 29727258ee5SArnaldo Carvalho de Melo inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, 29827258ee5SArnaldo Carvalho de Melo inet_csk(sk)->icsk_rto, 29927258ee5SArnaldo Carvalho de Melo DCCP_RTO_MAX); 30027258ee5SArnaldo Carvalho de Melo dcb->dccpd_type = DCCP_PKT_DATAACK; 301ae31c339SArnaldo Carvalho de Melo } else if (dccp_ack_pending(sk)) 30227258ee5SArnaldo Carvalho de Melo dcb->dccpd_type = DCCP_PKT_DATAACK; 30327258ee5SArnaldo Carvalho de Melo else 30427258ee5SArnaldo Carvalho de Melo dcb->dccpd_type = DCCP_PKT_DATA; 30527258ee5SArnaldo Carvalho de Melo 30627258ee5SArnaldo Carvalho de Melo err = dccp_transmit_skb(sk, skb); 30727258ee5SArnaldo Carvalho de Melo ccid_hc_tx_packet_sent(dp->dccps_hc_tx_ccid, sk, 0, len); 30859348b19SGerrit Renker if (err) 30959348b19SGerrit Renker DCCP_BUG("err=%d after ccid_hc_tx_packet_sent", 31059348b19SGerrit Renker err); 311f6282f4dSGerrit Renker } else { 3126626e362SGerrit Renker dccp_pr_debug("packet discarded due to err=%d\n", err); 313b08d5840SPatrick McHardy kfree_skb(skb); 31497e5848dSIan McDonald } 31527258ee5SArnaldo Carvalho de Melo } 316f6282f4dSGerrit Renker } 31727258ee5SArnaldo Carvalho de Melo 31859435444SGerrit Renker /** 31959435444SGerrit Renker * dccp_retransmit_skb - Retransmit Request, Close, or CloseReq packets 32059435444SGerrit Renker * There are only four retransmittable packet types in DCCP: 32159435444SGerrit Renker * - Request in client-REQUEST state (sec. 8.1.1), 32259435444SGerrit Renker * - CloseReq in server-CLOSEREQ state (sec. 8.3), 32359435444SGerrit Renker * - Close in node-CLOSING state (sec. 8.3), 32459435444SGerrit Renker * - Acks in client-PARTOPEN state (sec. 8.1.5, handled by dccp_delack_timer()). 32559435444SGerrit Renker * This function expects sk->sk_send_head to contain the original skb. 32659435444SGerrit Renker */ 32759435444SGerrit Renker int dccp_retransmit_skb(struct sock *sk) 3287c657876SArnaldo Carvalho de Melo { 32959435444SGerrit Renker WARN_ON(sk->sk_send_head == NULL); 33059435444SGerrit Renker 33157cca05aSArnaldo Carvalho de Melo if (inet_csk(sk)->icsk_af_ops->rebuild_header(sk) != 0) 3327c657876SArnaldo Carvalho de Melo return -EHOSTUNREACH; /* Routing failure or similar. */ 3337c657876SArnaldo Carvalho de Melo 33459435444SGerrit Renker /* this count is used to distinguish original and retransmitted skb */ 33559435444SGerrit Renker inet_csk(sk)->icsk_retransmits++; 33659435444SGerrit Renker 33759435444SGerrit Renker return dccp_transmit_skb(sk, skb_clone(sk->sk_send_head, GFP_ATOMIC)); 3387c657876SArnaldo Carvalho de Melo } 3397c657876SArnaldo Carvalho de Melo 3407c657876SArnaldo Carvalho de Melo struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst, 3417c657876SArnaldo Carvalho de Melo struct request_sock *req) 3427c657876SArnaldo Carvalho de Melo { 3437c657876SArnaldo Carvalho de Melo struct dccp_hdr *dh; 34467e6b629SArnaldo Carvalho de Melo struct dccp_request_sock *dreq; 345118b2c95SArnaldo Carvalho de Melo const u32 dccp_header_size = sizeof(struct dccp_hdr) + 3467c657876SArnaldo Carvalho de Melo sizeof(struct dccp_hdr_ext) + 3477c657876SArnaldo Carvalho de Melo sizeof(struct dccp_hdr_response); 348118b2c95SArnaldo Carvalho de Melo struct sk_buff *skb = sock_wmalloc(sk, sk->sk_prot->max_header, 1, 3497c657876SArnaldo Carvalho de Melo GFP_ATOMIC); 3507c657876SArnaldo Carvalho de Melo if (skb == NULL) 3517c657876SArnaldo Carvalho de Melo return NULL; 3527c657876SArnaldo Carvalho de Melo 3537c657876SArnaldo Carvalho de Melo /* Reserve space for headers. */ 354118b2c95SArnaldo Carvalho de Melo skb_reserve(skb, sk->sk_prot->max_header); 3557c657876SArnaldo Carvalho de Melo 356adf30907SEric Dumazet skb_dst_set(skb, dst_clone(dst)); 3577c657876SArnaldo Carvalho de Melo 35867e6b629SArnaldo Carvalho de Melo dreq = dccp_rsk(req); 359e11d9d30SGerrit Renker if (inet_rsk(req)->acked) /* increase ISS upon retransmission */ 360e11d9d30SGerrit Renker dccp_inc_seqno(&dreq->dreq_iss); 3617c657876SArnaldo Carvalho de Melo DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_RESPONSE; 36267e6b629SArnaldo Carvalho de Melo DCCP_SKB_CB(skb)->dccpd_seq = dreq->dreq_iss; 3632d0817d1SArnaldo Carvalho de Melo 3640c116839SGerrit Renker /* Resolve feature dependencies resulting from choice of CCID */ 3650c116839SGerrit Renker if (dccp_feat_server_ccid_dependencies(dreq)) 3660c116839SGerrit Renker goto response_failed; 3670c116839SGerrit Renker 3680c116839SGerrit Renker if (dccp_insert_options_rsk(dreq, skb)) 3690c116839SGerrit Renker goto response_failed; 3707c657876SArnaldo Carvalho de Melo 37109dbc389SGerrit Renker /* Build and checksum header */ 3729b42078eSGerrit Renker dh = dccp_zeroed_hdr(skb, dccp_header_size); 3737c657876SArnaldo Carvalho de Melo 374944f7502SGerrit Renker dh->dccph_sport = inet_rsk(req)->loc_port; 3757c657876SArnaldo Carvalho de Melo dh->dccph_dport = inet_rsk(req)->rmt_port; 3767690af3fSArnaldo Carvalho de Melo dh->dccph_doff = (dccp_header_size + 3777690af3fSArnaldo Carvalho de Melo DCCP_SKB_CB(skb)->dccpd_opt_len) / 4; 3787c657876SArnaldo Carvalho de Melo dh->dccph_type = DCCP_PKT_RESPONSE; 3797c657876SArnaldo Carvalho de Melo dh->dccph_x = 1; 38067e6b629SArnaldo Carvalho de Melo dccp_hdr_set_seq(dh, dreq->dreq_iss); 38167e6b629SArnaldo Carvalho de Melo dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), dreq->dreq_isr); 38267e6b629SArnaldo Carvalho de Melo dccp_hdr_response(skb)->dccph_resp_service = dreq->dreq_service; 3837c657876SArnaldo Carvalho de Melo 3846f4e5fffSGerrit Renker dccp_csum_outgoing(skb); 3856f4e5fffSGerrit Renker 386e11d9d30SGerrit Renker /* We use `acked' to remember that a Response was already sent. */ 387e11d9d30SGerrit Renker inet_rsk(req)->acked = 1; 3887c657876SArnaldo Carvalho de Melo DCCP_INC_STATS(DCCP_MIB_OUTSEGS); 3897c657876SArnaldo Carvalho de Melo return skb; 3900c116839SGerrit Renker response_failed: 3910c116839SGerrit Renker kfree_skb(skb); 3920c116839SGerrit Renker return NULL; 3937c657876SArnaldo Carvalho de Melo } 3947c657876SArnaldo Carvalho de Melo 395f21e68caSArnaldo Carvalho de Melo EXPORT_SYMBOL_GPL(dccp_make_response); 396f21e68caSArnaldo Carvalho de Melo 397e356d37aSGerrit Renker /* answer offending packet in @rcv_skb with Reset from control socket @ctl */ 3987630f026SDenis V. Lunev struct sk_buff *dccp_ctl_make_reset(struct sock *sk, struct sk_buff *rcv_skb) 399e356d37aSGerrit Renker { 400e356d37aSGerrit Renker struct dccp_hdr *rxdh = dccp_hdr(rcv_skb), *dh; 401e356d37aSGerrit Renker struct dccp_skb_cb *dcb = DCCP_SKB_CB(rcv_skb); 402e356d37aSGerrit Renker const u32 dccp_hdr_reset_len = sizeof(struct dccp_hdr) + 403e356d37aSGerrit Renker sizeof(struct dccp_hdr_ext) + 404e356d37aSGerrit Renker sizeof(struct dccp_hdr_reset); 405e356d37aSGerrit Renker struct dccp_hdr_reset *dhr; 406e356d37aSGerrit Renker struct sk_buff *skb; 407e356d37aSGerrit Renker 4087630f026SDenis V. Lunev skb = alloc_skb(sk->sk_prot->max_header, GFP_ATOMIC); 409e356d37aSGerrit Renker if (skb == NULL) 410e356d37aSGerrit Renker return NULL; 411e356d37aSGerrit Renker 4127630f026SDenis V. Lunev skb_reserve(skb, sk->sk_prot->max_header); 413e356d37aSGerrit Renker 414e356d37aSGerrit Renker /* Swap the send and the receive. */ 415e356d37aSGerrit Renker dh = dccp_zeroed_hdr(skb, dccp_hdr_reset_len); 416e356d37aSGerrit Renker dh->dccph_type = DCCP_PKT_RESET; 417e356d37aSGerrit Renker dh->dccph_sport = rxdh->dccph_dport; 418e356d37aSGerrit Renker dh->dccph_dport = rxdh->dccph_sport; 419e356d37aSGerrit Renker dh->dccph_doff = dccp_hdr_reset_len / 4; 420e356d37aSGerrit Renker dh->dccph_x = 1; 421e356d37aSGerrit Renker 422e356d37aSGerrit Renker dhr = dccp_hdr_reset(skb); 423e356d37aSGerrit Renker dhr->dccph_reset_code = dcb->dccpd_reset_code; 424e356d37aSGerrit Renker 425e356d37aSGerrit Renker switch (dcb->dccpd_reset_code) { 426e356d37aSGerrit Renker case DCCP_RESET_CODE_PACKET_ERROR: 427e356d37aSGerrit Renker dhr->dccph_reset_data[0] = rxdh->dccph_type; 428e356d37aSGerrit Renker break; 429e356d37aSGerrit Renker case DCCP_RESET_CODE_OPTION_ERROR: /* fall through */ 430e356d37aSGerrit Renker case DCCP_RESET_CODE_MANDATORY_ERROR: 431e356d37aSGerrit Renker memcpy(dhr->dccph_reset_data, dcb->dccpd_reset_data, 3); 432e356d37aSGerrit Renker break; 433e356d37aSGerrit Renker } 434e356d37aSGerrit Renker /* 435e356d37aSGerrit Renker * From RFC 4340, 8.3.1: 436e356d37aSGerrit Renker * If P.ackno exists, set R.seqno := P.ackno + 1. 437e356d37aSGerrit Renker * Else set R.seqno := 0. 438e356d37aSGerrit Renker */ 439e356d37aSGerrit Renker if (dcb->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ) 440e356d37aSGerrit Renker dccp_hdr_set_seq(dh, ADD48(dcb->dccpd_ack_seq, 1)); 441e356d37aSGerrit Renker dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), dcb->dccpd_seq); 442e356d37aSGerrit Renker 443e356d37aSGerrit Renker dccp_csum_outgoing(skb); 444e356d37aSGerrit Renker return skb; 445e356d37aSGerrit Renker } 446e356d37aSGerrit Renker 447e356d37aSGerrit Renker EXPORT_SYMBOL_GPL(dccp_ctl_make_reset); 448e356d37aSGerrit Renker 449ee1a1592SGerrit Renker /* send Reset on established socket, to close or abort the connection */ 450017487d7SArnaldo Carvalho de Melo int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code) 451017487d7SArnaldo Carvalho de Melo { 452ee1a1592SGerrit Renker struct sk_buff *skb; 453017487d7SArnaldo Carvalho de Melo /* 454017487d7SArnaldo Carvalho de Melo * FIXME: what if rebuild_header fails? 455017487d7SArnaldo Carvalho de Melo * Should we be doing a rebuild_header here? 456017487d7SArnaldo Carvalho de Melo */ 457f53dc67cSGerrit Renker int err = inet_csk(sk)->icsk_af_ops->rebuild_header(sk); 458017487d7SArnaldo Carvalho de Melo 459ee1a1592SGerrit Renker if (err != 0) 460017487d7SArnaldo Carvalho de Melo return err; 461ee1a1592SGerrit Renker 462ee1a1592SGerrit Renker skb = sock_wmalloc(sk, sk->sk_prot->max_header, 1, GFP_ATOMIC); 463ee1a1592SGerrit Renker if (skb == NULL) 464ee1a1592SGerrit Renker return -ENOBUFS; 465ee1a1592SGerrit Renker 466ee1a1592SGerrit Renker /* Reserve space for headers and prepare control bits. */ 467ee1a1592SGerrit Renker skb_reserve(skb, sk->sk_prot->max_header); 468ee1a1592SGerrit Renker DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_RESET; 469ee1a1592SGerrit Renker DCCP_SKB_CB(skb)->dccpd_reset_code = code; 470ee1a1592SGerrit Renker 471ee1a1592SGerrit Renker return dccp_transmit_skb(sk, skb); 472017487d7SArnaldo Carvalho de Melo } 473017487d7SArnaldo Carvalho de Melo 4747c657876SArnaldo Carvalho de Melo /* 4757c657876SArnaldo Carvalho de Melo * Do all connect socket setups that can be done AF independent. 4767c657876SArnaldo Carvalho de Melo */ 47793344af4SGerrit Renker int dccp_connect(struct sock *sk) 4787c657876SArnaldo Carvalho de Melo { 47993344af4SGerrit Renker struct sk_buff *skb; 480f21e68caSArnaldo Carvalho de Melo struct dccp_sock *dp = dccp_sk(sk); 4817c657876SArnaldo Carvalho de Melo struct dst_entry *dst = __sk_dst_get(sk); 4827c657876SArnaldo Carvalho de Melo struct inet_connection_sock *icsk = inet_csk(sk); 4837c657876SArnaldo Carvalho de Melo 4847c657876SArnaldo Carvalho de Melo sk->sk_err = 0; 4857c657876SArnaldo Carvalho de Melo sock_reset_flag(sk, SOCK_DONE); 4867c657876SArnaldo Carvalho de Melo 4877c657876SArnaldo Carvalho de Melo dccp_sync_mss(sk, dst_mtu(dst)); 4887c657876SArnaldo Carvalho de Melo 4899eca0a47SGerrit Renker /* do not connect if feature negotiation setup fails */ 4909eca0a47SGerrit Renker if (dccp_feat_finalise_settings(dccp_sk(sk))) 4919eca0a47SGerrit Renker return -EPROTO; 4929eca0a47SGerrit Renker 49393344af4SGerrit Renker /* Initialise GAR as per 8.5; AWL/AWH are set in dccp_transmit_skb() */ 49493344af4SGerrit Renker dp->dccps_gar = dp->dccps_iss; 4957c657876SArnaldo Carvalho de Melo 496118b2c95SArnaldo Carvalho de Melo skb = alloc_skb(sk->sk_prot->max_header, sk->sk_allocation); 4977c657876SArnaldo Carvalho de Melo if (unlikely(skb == NULL)) 4987c657876SArnaldo Carvalho de Melo return -ENOBUFS; 4997c657876SArnaldo Carvalho de Melo 5007c657876SArnaldo Carvalho de Melo /* Reserve space for headers. */ 501118b2c95SArnaldo Carvalho de Melo skb_reserve(skb, sk->sk_prot->max_header); 5027c657876SArnaldo Carvalho de Melo 5037c657876SArnaldo Carvalho de Melo DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_REQUEST; 5047c657876SArnaldo Carvalho de Melo 50548918a4dSHerbert Xu dccp_skb_entail(sk, skb); 5067c657876SArnaldo Carvalho de Melo dccp_transmit_skb(sk, skb_clone(skb, GFP_KERNEL)); 5077c657876SArnaldo Carvalho de Melo DCCP_INC_STATS(DCCP_MIB_ACTIVEOPENS); 5087c657876SArnaldo Carvalho de Melo 5097c657876SArnaldo Carvalho de Melo /* Timer for repeating the REQUEST until an answer. */ 51093344af4SGerrit Renker icsk->icsk_retransmits = 0; 51127258ee5SArnaldo Carvalho de Melo inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, 51227258ee5SArnaldo Carvalho de Melo icsk->icsk_rto, DCCP_RTO_MAX); 5137c657876SArnaldo Carvalho de Melo return 0; 5147c657876SArnaldo Carvalho de Melo } 5157c657876SArnaldo Carvalho de Melo 516f21e68caSArnaldo Carvalho de Melo EXPORT_SYMBOL_GPL(dccp_connect); 517f21e68caSArnaldo Carvalho de Melo 5187c657876SArnaldo Carvalho de Melo void dccp_send_ack(struct sock *sk) 5197c657876SArnaldo Carvalho de Melo { 5207c657876SArnaldo Carvalho de Melo /* If we have been reset, we may not send again. */ 5217c657876SArnaldo Carvalho de Melo if (sk->sk_state != DCCP_CLOSED) { 522118b2c95SArnaldo Carvalho de Melo struct sk_buff *skb = alloc_skb(sk->sk_prot->max_header, 523118b2c95SArnaldo Carvalho de Melo GFP_ATOMIC); 5247c657876SArnaldo Carvalho de Melo 5257c657876SArnaldo Carvalho de Melo if (skb == NULL) { 5267c657876SArnaldo Carvalho de Melo inet_csk_schedule_ack(sk); 5277c657876SArnaldo Carvalho de Melo inet_csk(sk)->icsk_ack.ato = TCP_ATO_MIN; 5287690af3fSArnaldo Carvalho de Melo inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, 5297690af3fSArnaldo Carvalho de Melo TCP_DELACK_MAX, 5307690af3fSArnaldo Carvalho de Melo DCCP_RTO_MAX); 5317c657876SArnaldo Carvalho de Melo return; 5327c657876SArnaldo Carvalho de Melo } 5337c657876SArnaldo Carvalho de Melo 5347c657876SArnaldo Carvalho de Melo /* Reserve space for headers */ 535118b2c95SArnaldo Carvalho de Melo skb_reserve(skb, sk->sk_prot->max_header); 5367c657876SArnaldo Carvalho de Melo DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_ACK; 5377c657876SArnaldo Carvalho de Melo dccp_transmit_skb(sk, skb); 5387c657876SArnaldo Carvalho de Melo } 5397c657876SArnaldo Carvalho de Melo } 5407c657876SArnaldo Carvalho de Melo 5417c657876SArnaldo Carvalho de Melo EXPORT_SYMBOL_GPL(dccp_send_ack); 5427c657876SArnaldo Carvalho de Melo 5431e2f0e5eSGerrit Renker #if 0 544727ecc5fSGerrit Renker /* FIXME: Is this still necessary (11.3) - currently nowhere used by DCCP. */ 5457c657876SArnaldo Carvalho de Melo void dccp_send_delayed_ack(struct sock *sk) 5467c657876SArnaldo Carvalho de Melo { 5477c657876SArnaldo Carvalho de Melo struct inet_connection_sock *icsk = inet_csk(sk); 5487c657876SArnaldo Carvalho de Melo /* 5497c657876SArnaldo Carvalho de Melo * FIXME: tune this timer. elapsed time fixes the skew, so no problem 5507c657876SArnaldo Carvalho de Melo * with using 2s, and active senders also piggyback the ACK into a 5517c657876SArnaldo Carvalho de Melo * DATAACK packet, so this is really for quiescent senders. 5527c657876SArnaldo Carvalho de Melo */ 5537c657876SArnaldo Carvalho de Melo unsigned long timeout = jiffies + 2 * HZ; 5547c657876SArnaldo Carvalho de Melo 5557c657876SArnaldo Carvalho de Melo /* Use new timeout only if there wasn't a older one earlier. */ 5567c657876SArnaldo Carvalho de Melo if (icsk->icsk_ack.pending & ICSK_ACK_TIMER) { 5577c657876SArnaldo Carvalho de Melo /* If delack timer was blocked or is about to expire, 5587c657876SArnaldo Carvalho de Melo * send ACK now. 5597c657876SArnaldo Carvalho de Melo * 5607c657876SArnaldo Carvalho de Melo * FIXME: check the "about to expire" part 5617c657876SArnaldo Carvalho de Melo */ 5627c657876SArnaldo Carvalho de Melo if (icsk->icsk_ack.blocked) { 5637c657876SArnaldo Carvalho de Melo dccp_send_ack(sk); 5647c657876SArnaldo Carvalho de Melo return; 5657c657876SArnaldo Carvalho de Melo } 5667c657876SArnaldo Carvalho de Melo 5677c657876SArnaldo Carvalho de Melo if (!time_before(timeout, icsk->icsk_ack.timeout)) 5687c657876SArnaldo Carvalho de Melo timeout = icsk->icsk_ack.timeout; 5697c657876SArnaldo Carvalho de Melo } 5707c657876SArnaldo Carvalho de Melo icsk->icsk_ack.pending |= ICSK_ACK_SCHED | ICSK_ACK_TIMER; 5717c657876SArnaldo Carvalho de Melo icsk->icsk_ack.timeout = timeout; 5727c657876SArnaldo Carvalho de Melo sk_reset_timer(sk, &icsk->icsk_delack_timer, timeout); 5737c657876SArnaldo Carvalho de Melo } 5741e2f0e5eSGerrit Renker #endif 5757c657876SArnaldo Carvalho de Melo 576b0d045caSGerrit Renker void dccp_send_sync(struct sock *sk, const u64 ackno, 577e92ae93aSArnaldo Carvalho de Melo const enum dccp_pkt_type pkt_type) 5787c657876SArnaldo Carvalho de Melo { 5797c657876SArnaldo Carvalho de Melo /* 5807c657876SArnaldo Carvalho de Melo * We are not putting this on the write queue, so 5817c657876SArnaldo Carvalho de Melo * dccp_transmit_skb() will set the ownership to this 5827c657876SArnaldo Carvalho de Melo * sock. 5837c657876SArnaldo Carvalho de Melo */ 584118b2c95SArnaldo Carvalho de Melo struct sk_buff *skb = alloc_skb(sk->sk_prot->max_header, GFP_ATOMIC); 5857c657876SArnaldo Carvalho de Melo 586b0d045caSGerrit Renker if (skb == NULL) { 5877c657876SArnaldo Carvalho de Melo /* FIXME: how to make sure the sync is sent? */ 588b0d045caSGerrit Renker DCCP_CRIT("could not send %s", dccp_packet_name(pkt_type)); 5897c657876SArnaldo Carvalho de Melo return; 590b0d045caSGerrit Renker } 5917c657876SArnaldo Carvalho de Melo 5927c657876SArnaldo Carvalho de Melo /* Reserve space for headers and prepare control bits. */ 593118b2c95SArnaldo Carvalho de Melo skb_reserve(skb, sk->sk_prot->max_header); 594e92ae93aSArnaldo Carvalho de Melo DCCP_SKB_CB(skb)->dccpd_type = pkt_type; 595b0d045caSGerrit Renker DCCP_SKB_CB(skb)->dccpd_ack_seq = ackno; 5967c657876SArnaldo Carvalho de Melo 5977c657876SArnaldo Carvalho de Melo dccp_transmit_skb(sk, skb); 5987c657876SArnaldo Carvalho de Melo } 5997c657876SArnaldo Carvalho de Melo 600b61fafc4SArnaldo Carvalho de Melo EXPORT_SYMBOL_GPL(dccp_send_sync); 601b61fafc4SArnaldo Carvalho de Melo 6027690af3fSArnaldo Carvalho de Melo /* 6037690af3fSArnaldo Carvalho de Melo * Send a DCCP_PKT_CLOSE/CLOSEREQ. The caller locks the socket for us. This 6047690af3fSArnaldo Carvalho de Melo * cannot be allowed to fail queueing a DCCP_PKT_CLOSE/CLOSEREQ frame under 6057690af3fSArnaldo Carvalho de Melo * any circumstances. 6067c657876SArnaldo Carvalho de Melo */ 6077ad07e7cSArnaldo Carvalho de Melo void dccp_send_close(struct sock *sk, const int active) 6087c657876SArnaldo Carvalho de Melo { 6097c657876SArnaldo Carvalho de Melo struct dccp_sock *dp = dccp_sk(sk); 6107c657876SArnaldo Carvalho de Melo struct sk_buff *skb; 6117d877f3bSAl Viro const gfp_t prio = active ? GFP_KERNEL : GFP_ATOMIC; 6127c657876SArnaldo Carvalho de Melo 6137ad07e7cSArnaldo Carvalho de Melo skb = alloc_skb(sk->sk_prot->max_header, prio); 6147ad07e7cSArnaldo Carvalho de Melo if (skb == NULL) 6157ad07e7cSArnaldo Carvalho de Melo return; 6167c657876SArnaldo Carvalho de Melo 6177c657876SArnaldo Carvalho de Melo /* Reserve space for headers and prepare control bits. */ 6187c657876SArnaldo Carvalho de Melo skb_reserve(skb, sk->sk_prot->max_header); 619b8599d20SGerrit Renker if (dp->dccps_role == DCCP_ROLE_SERVER && !dp->dccps_server_timewait) 620b8599d20SGerrit Renker DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_CLOSEREQ; 621b8599d20SGerrit Renker else 622b8599d20SGerrit Renker DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_CLOSE; 6237c657876SArnaldo Carvalho de Melo 6247ad07e7cSArnaldo Carvalho de Melo if (active) { 62597e5848dSIan McDonald dccp_write_xmit(sk, 1); 62648918a4dSHerbert Xu dccp_skb_entail(sk, skb); 6277ad07e7cSArnaldo Carvalho de Melo dccp_transmit_skb(sk, skb_clone(skb, prio)); 62892d31920SGerrit Renker /* 62992d31920SGerrit Renker * Retransmission timer for active-close: RFC 4340, 8.3 requires 63092d31920SGerrit Renker * to retransmit the Close/CloseReq until the CLOSING/CLOSEREQ 63192d31920SGerrit Renker * state can be left. The initial timeout is 2 RTTs. 63292d31920SGerrit Renker * Since RTT measurement is done by the CCIDs, there is no easy 63392d31920SGerrit Renker * way to get an RTT sample. The fallback RTT from RFC 4340, 3.4 63492d31920SGerrit Renker * is too low (200ms); we use a high value to avoid unnecessary 63592d31920SGerrit Renker * retransmissions when the link RTT is > 0.2 seconds. 63692d31920SGerrit Renker * FIXME: Let main module sample RTTs and use that instead. 63792d31920SGerrit Renker */ 63892d31920SGerrit Renker inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, 63992d31920SGerrit Renker DCCP_TIMEOUT_INIT, DCCP_RTO_MAX); 6407ad07e7cSArnaldo Carvalho de Melo } else 6417c657876SArnaldo Carvalho de Melo dccp_transmit_skb(sk, skb); 6427c657876SArnaldo Carvalho de Melo } 643