aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/socket.c')
-rw-r--r--net/tipc/socket.c48
1 files changed, 23 insertions, 25 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 1762323156af..ede78b144dcf 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -207,7 +207,7 @@ static int tipc_sk_create(struct net *net, struct socket *sock,
207 sk->sk_data_ready = tipc_data_ready; 207 sk->sk_data_ready = tipc_data_ready;
208 sk->sk_write_space = tipc_write_space; 208 sk->sk_write_space = tipc_write_space;
209 tsk->conn_timeout = CONN_TIMEOUT_DEFAULT; 209 tsk->conn_timeout = CONN_TIMEOUT_DEFAULT;
210 tsk->port.sent = 0; 210 tsk->sent_unacked = 0;
211 atomic_set(&tsk->dupl_rcvcnt, 0); 211 atomic_set(&tsk->dupl_rcvcnt, 0);
212 tipc_port_unlock(port); 212 tipc_port_unlock(port);
213 213
@@ -513,12 +513,12 @@ static unsigned int tipc_poll(struct file *file, struct socket *sock,
513 513
514 switch ((int)sock->state) { 514 switch ((int)sock->state) {
515 case SS_UNCONNECTED: 515 case SS_UNCONNECTED:
516 if (!tsk->port.congested) 516 if (!tsk->link_cong)
517 mask |= POLLOUT; 517 mask |= POLLOUT;
518 break; 518 break;
519 case SS_READY: 519 case SS_READY:
520 case SS_CONNECTED: 520 case SS_CONNECTED:
521 if (!tsk->port.congested) 521 if (!tsk->link_cong && !tipc_sk_conn_cong(tsk))
522 mask |= POLLOUT; 522 mask |= POLLOUT;
523 /* fall thru' */ 523 /* fall thru' */
524 case SS_CONNECTING: 524 case SS_CONNECTING:
@@ -546,7 +546,7 @@ int tipc_sk_proto_rcv(struct tipc_sock *tsk, u32 *dnode, struct sk_buff *buf)
546{ 546{
547 struct tipc_msg *msg = buf_msg(buf); 547 struct tipc_msg *msg = buf_msg(buf);
548 struct tipc_port *port = &tsk->port; 548 struct tipc_port *port = &tsk->port;
549 int wakeable; 549 int conn_cong;
550 550
551 /* Ignore if connection cannot be validated: */ 551 /* Ignore if connection cannot be validated: */
552 if (!port->connected || !tipc_port_peer_msg(port, msg)) 552 if (!port->connected || !tipc_port_peer_msg(port, msg))
@@ -555,13 +555,10 @@ int tipc_sk_proto_rcv(struct tipc_sock *tsk, u32 *dnode, struct sk_buff *buf)
555 port->probing_state = TIPC_CONN_OK; 555 port->probing_state = TIPC_CONN_OK;
556 556
557 if (msg_type(msg) == CONN_ACK) { 557 if (msg_type(msg) == CONN_ACK) {
558 wakeable = tipc_port_congested(port) && port->congested; 558 conn_cong = tipc_sk_conn_cong(tsk);
559 port->acked += msg_msgcnt(msg); 559 tsk->sent_unacked -= msg_msgcnt(msg);
560 if (!tipc_port_congested(port)) { 560 if (conn_cong)
561 port->congested = 0; 561 tipc_sock_wakeup(tsk);
562 if (wakeable)
563 tipc_port_wakeup(port);
564 }
565 } else if (msg_type(msg) == CONN_PROBE) { 562 } else if (msg_type(msg) == CONN_PROBE) {
566 if (!tipc_msg_reverse(buf, dnode, TIPC_OK)) 563 if (!tipc_msg_reverse(buf, dnode, TIPC_OK))
567 return TIPC_OK; 564 return TIPC_OK;
@@ -626,7 +623,7 @@ static int tipc_wait_for_sndmsg(struct socket *sock, long *timeo_p)
626 return sock_intr_errno(*timeo_p); 623 return sock_intr_errno(*timeo_p);
627 624
628 prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); 625 prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
629 done = sk_wait_event(sk, timeo_p, !tsk->port.congested); 626 done = sk_wait_event(sk, timeo_p, !tsk->link_cong);
630 finish_wait(sk_sleep(sk), &wait); 627 finish_wait(sk_sleep(sk), &wait);
631 } while (!done); 628 } while (!done);
632 return 0; 629 return 0;
@@ -800,7 +797,6 @@ static int tipc_wait_for_sndpkt(struct socket *sock, long *timeo_p)
800{ 797{
801 struct sock *sk = sock->sk; 798 struct sock *sk = sock->sk;
802 struct tipc_sock *tsk = tipc_sk(sk); 799 struct tipc_sock *tsk = tipc_sk(sk);
803 struct tipc_port *port = &tsk->port;
804 DEFINE_WAIT(wait); 800 DEFINE_WAIT(wait);
805 int done; 801 int done;
806 802
@@ -819,7 +815,9 @@ static int tipc_wait_for_sndpkt(struct socket *sock, long *timeo_p)
819 815
820 prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); 816 prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
821 done = sk_wait_event(sk, timeo_p, 817 done = sk_wait_event(sk, timeo_p,
822 (!port->congested || !port->connected)); 818 (!tsk->link_cong &&
819 !tipc_sk_conn_cong(tsk)) ||
820 !tsk->port.connected);
823 finish_wait(sk_sleep(sk), &wait); 821 finish_wait(sk_sleep(sk), &wait);
824 } while (!done); 822 } while (!done);
825 return 0; 823 return 0;
@@ -856,7 +854,7 @@ static int tipc_send_stream(struct kiocb *iocb, struct socket *sock,
856 if (unlikely(dest)) { 854 if (unlikely(dest)) {
857 rc = tipc_sendmsg(iocb, sock, m, dsz); 855 rc = tipc_sendmsg(iocb, sock, m, dsz);
858 if (dsz && (dsz == rc)) 856 if (dsz && (dsz == rc))
859 tsk->port.sent = 1; 857 tsk->sent_unacked = 1;
860 return rc; 858 return rc;
861 } 859 }
862 if (dsz > (uint)INT_MAX) 860 if (dsz > (uint)INT_MAX)
@@ -875,7 +873,6 @@ static int tipc_send_stream(struct kiocb *iocb, struct socket *sock,
875 873
876 timeo = sock_sndtimeo(sk, m->msg_flags & MSG_DONTWAIT); 874 timeo = sock_sndtimeo(sk, m->msg_flags & MSG_DONTWAIT);
877 dnode = tipc_port_peernode(port); 875 dnode = tipc_port_peernode(port);
878 port->congested = 1;
879 876
880next: 877next:
881 mtu = port->max_pkt; 878 mtu = port->max_pkt;
@@ -884,11 +881,10 @@ next:
884 if (unlikely(rc < 0)) 881 if (unlikely(rc < 0))
885 goto exit; 882 goto exit;
886 do { 883 do {
887 port->congested = 1; 884 if (likely(!tipc_sk_conn_cong(tsk))) {
888 if (likely(!tipc_port_congested(port))) {
889 rc = tipc_link_xmit2(buf, dnode, ref); 885 rc = tipc_link_xmit2(buf, dnode, ref);
890 if (likely(!rc)) { 886 if (likely(!rc)) {
891 port->sent++; 887 tsk->sent_unacked++;
892 sent += send; 888 sent += send;
893 if (sent == dsz) 889 if (sent == dsz)
894 break; 890 break;
@@ -903,8 +899,6 @@ next:
903 } 899 }
904 rc = tipc_wait_for_sndpkt(sock, &timeo); 900 rc = tipc_wait_for_sndpkt(sock, &timeo);
905 } while (!rc); 901 } while (!rc);
906
907 port->congested = 0;
908exit: 902exit:
909 if (iocb) 903 if (iocb)
910 release_sock(sk); 904 release_sock(sk);
@@ -1169,8 +1163,10 @@ restart:
1169 /* Consume received message (optional) */ 1163 /* Consume received message (optional) */
1170 if (likely(!(flags & MSG_PEEK))) { 1164 if (likely(!(flags & MSG_PEEK))) {
1171 if ((sock->state != SS_READY) && 1165 if ((sock->state != SS_READY) &&
1172 (++port->conn_unacked >= TIPC_CONNACK_INTV)) 1166 (++tsk->rcv_unacked >= TIPC_CONNACK_INTV)) {
1173 tipc_acknowledge(port->ref, port->conn_unacked); 1167 tipc_acknowledge(port->ref, tsk->rcv_unacked);
1168 tsk->rcv_unacked = 0;
1169 }
1174 advance_rx_queue(sk); 1170 advance_rx_queue(sk);
1175 } 1171 }
1176exit: 1172exit:
@@ -1278,8 +1274,10 @@ restart:
1278 1274
1279 /* Consume received message (optional) */ 1275 /* Consume received message (optional) */
1280 if (likely(!(flags & MSG_PEEK))) { 1276 if (likely(!(flags & MSG_PEEK))) {
1281 if (unlikely(++port->conn_unacked >= TIPC_CONNACK_INTV)) 1277 if (unlikely(++tsk->rcv_unacked >= TIPC_CONNACK_INTV)) {
1282 tipc_acknowledge(port->ref, port->conn_unacked); 1278 tipc_acknowledge(port->ref, tsk->rcv_unacked);
1279 tsk->rcv_unacked = 0;
1280 }
1283 advance_rx_queue(sk); 1281 advance_rx_queue(sk);
1284 } 1282 }
1285 1283