|
@@ -150,14 +150,71 @@ unsigned int dccp_sync_mss(struct sock *sk, u32 pmtu)
|
|
return mss_now;
|
|
return mss_now;
|
|
}
|
|
}
|
|
|
|
|
|
-int dccp_write_xmit(struct sock *sk, struct sk_buff *skb, const int len)
|
|
|
|
|
|
+/**
|
|
|
|
+ * dccp_wait_for_ccid - Wait for ccid to tell us we can send a packet
|
|
|
|
+ * @sk: socket to wait for
|
|
|
|
+ * @timeo: for how long
|
|
|
|
+ */
|
|
|
|
+static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb,
|
|
|
|
+ long *timeo)
|
|
|
|
+{
|
|
|
|
+ struct dccp_sock *dp = dccp_sk(sk);
|
|
|
|
+ DEFINE_WAIT(wait);
|
|
|
|
+ long delay;
|
|
|
|
+ int rc;
|
|
|
|
+
|
|
|
|
+ while (1) {
|
|
|
|
+ prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
|
|
|
|
+
|
|
|
|
+ if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))
|
|
|
|
+ goto do_error;
|
|
|
|
+ if (!*timeo)
|
|
|
|
+ goto do_nonblock;
|
|
|
|
+ if (signal_pending(current))
|
|
|
|
+ goto do_interrupted;
|
|
|
|
+
|
|
|
|
+ rc = ccid_hc_tx_send_packet(dp->dccps_hc_tx_ccid, sk, skb,
|
|
|
|
+ skb->len);
|
|
|
|
+ if (rc <= 0)
|
|
|
|
+ break;
|
|
|
|
+ delay = msecs_to_jiffies(rc);
|
|
|
|
+ if (delay > *timeo || delay < 0)
|
|
|
|
+ goto do_nonblock;
|
|
|
|
+
|
|
|
|
+ sk->sk_write_pending++;
|
|
|
|
+ release_sock(sk);
|
|
|
|
+ *timeo -= schedule_timeout(delay);
|
|
|
|
+ lock_sock(sk);
|
|
|
|
+ sk->sk_write_pending--;
|
|
|
|
+ }
|
|
|
|
+out:
|
|
|
|
+ finish_wait(sk->sk_sleep, &wait);
|
|
|
|
+ return rc;
|
|
|
|
+
|
|
|
|
+do_error:
|
|
|
|
+ rc = -EPIPE;
|
|
|
|
+ goto out;
|
|
|
|
+do_nonblock:
|
|
|
|
+ rc = -EAGAIN;
|
|
|
|
+ goto out;
|
|
|
|
+do_interrupted:
|
|
|
|
+ rc = sock_intr_errno(*timeo);
|
|
|
|
+ goto out;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int dccp_write_xmit(struct sock *sk, struct sk_buff *skb, long *timeo)
|
|
{
|
|
{
|
|
const struct dccp_sock *dp = dccp_sk(sk);
|
|
const struct dccp_sock *dp = dccp_sk(sk);
|
|
- int err = ccid_hc_tx_send_packet(dp->dccps_hc_tx_ccid, sk, skb, len);
|
|
|
|
|
|
+ int err = ccid_hc_tx_send_packet(dp->dccps_hc_tx_ccid, sk, skb,
|
|
|
|
+ skb->len);
|
|
|
|
+
|
|
|
|
+ if (err > 0)
|
|
|
|
+ err = dccp_wait_for_ccid(sk, skb, timeo);
|
|
|
|
|
|
if (err == 0) {
|
|
if (err == 0) {
|
|
const struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts;
|
|
const struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts;
|
|
struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
|
|
struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
|
|
|
|
+ const int len = skb->len;
|
|
|
|
|
|
if (sk->sk_state == DCCP_PARTOPEN) {
|
|
if (sk->sk_state == DCCP_PARTOPEN) {
|
|
/* See 8.1.5. Handshake Completion */
|
|
/* See 8.1.5. Handshake Completion */
|