aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/socket.c
diff options
context:
space:
mode:
authorJon Paul Maloy <jon.maloy@ericsson.com>2015-07-16 16:54:23 -0400
committerDavid S. Miller <davem@davemloft.net>2015-07-20 23:41:15 -0400
commit22d85c79428b8ca9a01623aa3e3a1fe29a30a119 (patch)
treebc72ee5256301d591616db2270c45929be2d58d6 /net/tipc/socket.c
parent36e78a463b26c9b8017a2e11dcd6c4b8e34b4161 (diff)
tipc: change sk_buffer handling in tipc_link_xmit()
When the function tipc_link_xmit() is given a buffer list for transmission, it currently consumes the list both when transmission is successful and when it fails, except for the special case when it encounters link congestion. This behavior is inconsistent, and needs to be corrected if we want to avoid problems in later commits in this series. In this commit, we change this to let the function consume the list only when transmission is successful, and leave the list with the sender in all other cases. We also modifiy the socket code so that it adapts to this change, i.e., purges the list when a non-congestion error code is returned. Reviewed-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/socket.c')
-rw-r--r--net/tipc/socket.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 3a7567f690f3..87fef25f6519 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -686,21 +686,22 @@ new_mtu:
686 686
687 do { 687 do {
688 rc = tipc_bclink_xmit(net, pktchain); 688 rc = tipc_bclink_xmit(net, pktchain);
689 if (likely(rc >= 0)) { 689 if (likely(!rc))
690 rc = dsz; 690 return dsz;
691 break; 691
692 if (rc == -ELINKCONG) {
693 tsk->link_cong = 1;
694 rc = tipc_wait_for_sndmsg(sock, &timeo);
695 if (!rc)
696 continue;
692 } 697 }
698 __skb_queue_purge(pktchain);
693 if (rc == -EMSGSIZE) { 699 if (rc == -EMSGSIZE) {
694 msg->msg_iter = save; 700 msg->msg_iter = save;
695 goto new_mtu; 701 goto new_mtu;
696 } 702 }
697 if (rc != -ELINKCONG) 703 break;
698 break; 704 } while (1);
699 tipc_sk(sk)->link_cong = 1;
700 rc = tipc_wait_for_sndmsg(sock, &timeo);
701 if (rc)
702 __skb_queue_purge(pktchain);
703 } while (!rc);
704 return rc; 705 return rc;
705} 706}
706 707
@@ -925,23 +926,24 @@ new_mtu:
925 skb = skb_peek(pktchain); 926 skb = skb_peek(pktchain);
926 TIPC_SKB_CB(skb)->wakeup_pending = tsk->link_cong; 927 TIPC_SKB_CB(skb)->wakeup_pending = tsk->link_cong;
927 rc = tipc_link_xmit(net, pktchain, dnode, tsk->portid); 928 rc = tipc_link_xmit(net, pktchain, dnode, tsk->portid);
928 if (likely(rc >= 0)) { 929 if (likely(!rc)) {
929 if (sock->state != SS_READY) 930 if (sock->state != SS_READY)
930 sock->state = SS_CONNECTING; 931 sock->state = SS_CONNECTING;
931 rc = dsz; 932 return dsz;
932 break;
933 } 933 }
934 if (rc == -ELINKCONG) {
935 tsk->link_cong = 1;
936 rc = tipc_wait_for_sndmsg(sock, &timeo);
937 if (!rc)
938 continue;
939 }
940 __skb_queue_purge(pktchain);
934 if (rc == -EMSGSIZE) { 941 if (rc == -EMSGSIZE) {
935 m->msg_iter = save; 942 m->msg_iter = save;
936 goto new_mtu; 943 goto new_mtu;
937 } 944 }
938 if (rc != -ELINKCONG) 945 break;
939 break; 946 } while (1);
940 tsk->link_cong = 1;
941 rc = tipc_wait_for_sndmsg(sock, &timeo);
942 if (rc)
943 __skb_queue_purge(pktchain);
944 } while (!rc);
945 947
946 return rc; 948 return rc;
947} 949}
@@ -1048,10 +1050,11 @@ next:
1048 tsk->sent_unacked++; 1050 tsk->sent_unacked++;
1049 sent += send; 1051 sent += send;
1050 if (sent == dsz) 1052 if (sent == dsz)
1051 break; 1053 return dsz;
1052 goto next; 1054 goto next;
1053 } 1055 }
1054 if (rc == -EMSGSIZE) { 1056 if (rc == -EMSGSIZE) {
1057 __skb_queue_purge(pktchain);
1055 tsk->max_pkt = tipc_node_get_mtu(net, dnode, 1058 tsk->max_pkt = tipc_node_get_mtu(net, dnode,
1056 portid); 1059 portid);
1057 m->msg_iter = save; 1060 m->msg_iter = save;
@@ -1059,13 +1062,13 @@ next:
1059 } 1062 }
1060 if (rc != -ELINKCONG) 1063 if (rc != -ELINKCONG)
1061 break; 1064 break;
1065
1062 tsk->link_cong = 1; 1066 tsk->link_cong = 1;
1063 } 1067 }
1064 rc = tipc_wait_for_sndpkt(sock, &timeo); 1068 rc = tipc_wait_for_sndpkt(sock, &timeo);
1065 if (rc)
1066 __skb_queue_purge(pktchain);
1067 } while (!rc); 1069 } while (!rc);
1068 1070
1071 __skb_queue_purge(pktchain);
1069 return sent ? sent : rc; 1072 return sent ? sent : rc;
1070} 1073}
1071 1074