@@ -1739,22 +1739,21 @@ static int tipc_sk_anc_data_recv(struct msghdr *m, struct sk_buff *skb,
1739
1739
return 0 ;
1740
1740
}
1741
1741
1742
- static void tipc_sk_send_ack (struct tipc_sock * tsk )
1742
+ static struct sk_buff * tipc_sk_build_ack (struct tipc_sock * tsk )
1743
1743
{
1744
1744
struct sock * sk = & tsk -> sk ;
1745
- struct net * net = sock_net (sk );
1746
1745
struct sk_buff * skb = NULL ;
1747
1746
struct tipc_msg * msg ;
1748
1747
u32 peer_port = tsk_peer_port (tsk );
1749
1748
u32 dnode = tsk_peer_node (tsk );
1750
1749
1751
1750
if (!tipc_sk_connected (sk ))
1752
- return ;
1751
+ return NULL ;
1753
1752
skb = tipc_msg_create (CONN_MANAGER , CONN_ACK , INT_H_SIZE , 0 ,
1754
1753
dnode , tsk_own_node (tsk ), peer_port ,
1755
1754
tsk -> portid , TIPC_OK );
1756
1755
if (!skb )
1757
- return ;
1756
+ return NULL ;
1758
1757
msg = buf_msg (skb );
1759
1758
msg_set_conn_ack (msg , tsk -> rcv_unacked );
1760
1759
tsk -> rcv_unacked = 0 ;
@@ -1764,7 +1763,19 @@ static void tipc_sk_send_ack(struct tipc_sock *tsk)
1764
1763
tsk -> rcv_win = tsk_adv_blocks (tsk -> sk .sk_rcvbuf );
1765
1764
msg_set_adv_win (msg , tsk -> rcv_win );
1766
1765
}
1767
- tipc_node_xmit_skb (net , skb , dnode , msg_link_selector (msg ));
1766
+ return skb ;
1767
+ }
1768
+
1769
+ static void tipc_sk_send_ack (struct tipc_sock * tsk )
1770
+ {
1771
+ struct sk_buff * skb ;
1772
+
1773
+ skb = tipc_sk_build_ack (tsk );
1774
+ if (!skb )
1775
+ return ;
1776
+
1777
+ tipc_node_xmit_skb (sock_net (& tsk -> sk ), skb , tsk_peer_node (tsk ),
1778
+ msg_link_selector (buf_msg (skb )));
1768
1779
}
1769
1780
1770
1781
static int tipc_wait_for_rcvmsg (struct socket * sock , long * timeop )
@@ -1938,7 +1949,6 @@ static int tipc_recvstream(struct socket *sock, struct msghdr *m,
1938
1949
bool peek = flags & MSG_PEEK ;
1939
1950
int offset , required , copy , copied = 0 ;
1940
1951
int hlen , dlen , err , rc ;
1941
- bool ack = false;
1942
1952
long timeout ;
1943
1953
1944
1954
/* Catch invalid receive attempts */
@@ -1983,7 +1993,6 @@ static int tipc_recvstream(struct socket *sock, struct msghdr *m,
1983
1993
1984
1994
/* Copy data if msg ok, otherwise return error/partial data */
1985
1995
if (likely (!err )) {
1986
- ack = msg_ack_required (hdr );
1987
1996
offset = skb_cb -> bytes_read ;
1988
1997
copy = min_t (int , dlen - offset , buflen - copied );
1989
1998
rc = skb_copy_datagram_msg (skb , hlen + offset , m , copy );
@@ -2011,7 +2020,7 @@ static int tipc_recvstream(struct socket *sock, struct msghdr *m,
2011
2020
2012
2021
/* Send connection flow control advertisement when applicable */
2013
2022
tsk -> rcv_unacked += tsk_inc (tsk , hlen + dlen );
2014
- if (ack || tsk -> rcv_unacked >= tsk -> rcv_win / TIPC_ACK_RATE )
2023
+ if (tsk -> rcv_unacked >= tsk -> rcv_win / TIPC_ACK_RATE )
2015
2024
tipc_sk_send_ack (tsk );
2016
2025
2017
2026
/* Exit if all requested data or FIN/error received */
@@ -2105,9 +2114,11 @@ static void tipc_sk_proto_rcv(struct sock *sk,
2105
2114
* tipc_sk_filter_connect - check incoming message for a connection-based socket
2106
2115
* @tsk: TIPC socket
2107
2116
* @skb: pointer to message buffer.
2117
+ * @xmitq: for Nagle ACK if any
2108
2118
* Returns true if message should be added to receive queue, false otherwise
2109
2119
*/
2110
- static bool tipc_sk_filter_connect (struct tipc_sock * tsk , struct sk_buff * skb )
2120
+ static bool tipc_sk_filter_connect (struct tipc_sock * tsk , struct sk_buff * skb ,
2121
+ struct sk_buff_head * xmitq )
2111
2122
{
2112
2123
struct sock * sk = & tsk -> sk ;
2113
2124
struct net * net = sock_net (sk );
@@ -2171,8 +2182,17 @@ static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb)
2171
2182
if (!skb_queue_empty (& sk -> sk_write_queue ))
2172
2183
tipc_sk_push_backlog (tsk );
2173
2184
/* Accept only connection-based messages sent by peer */
2174
- if (likely (con_msg && !err && pport == oport && pnode == onode ))
2185
+ if (likely (con_msg && !err && pport == oport &&
2186
+ pnode == onode )) {
2187
+ if (msg_ack_required (hdr )) {
2188
+ struct sk_buff * skb ;
2189
+
2190
+ skb = tipc_sk_build_ack (tsk );
2191
+ if (skb )
2192
+ __skb_queue_tail (xmitq , skb );
2193
+ }
2175
2194
return true;
2195
+ }
2176
2196
if (!tsk_peer_msg (tsk , hdr ))
2177
2197
return false;
2178
2198
if (!err )
@@ -2267,7 +2287,7 @@ static void tipc_sk_filter_rcv(struct sock *sk, struct sk_buff *skb,
2267
2287
while ((skb = __skb_dequeue (& inputq ))) {
2268
2288
hdr = buf_msg (skb );
2269
2289
limit = rcvbuf_limit (sk , skb );
2270
- if ((sk_conn && !tipc_sk_filter_connect (tsk , skb )) ||
2290
+ if ((sk_conn && !tipc_sk_filter_connect (tsk , skb , xmitq )) ||
2271
2291
(!sk_conn && msg_connected (hdr )) ||
2272
2292
(!grp && msg_in_group (hdr )))
2273
2293
err = TIPC_ERR_NO_PORT ;
0 commit comments