aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorJon Paul Maloy <jon.maloy@ericsson.com>2014-08-22 18:09:12 -0400
committerDavid S. Miller <davem@davemloft.net>2014-08-23 14:18:34 -0400
commit739f5e4efc82c4cb6b5201cbed337b6ff663bf19 (patch)
tree8364fc3cd87910c2aa34b4f6b49ea25e3cf1f720 /net/tipc
parentdadebc00299a19dc4639ba7192db937e31b81eb2 (diff)
tipc: redefine message acknowledge function
The function tipc_acknowledge() is a remnant from the obsolete native API. Currently, it grabs port_lock, before building an acknowledge message and sending it to the peer. Since all access to socket members now is protected by the socket lock, it has become unnecessary to grab port_lock here. In this commit, we remove the usage of port_lock, simplify the function, and move it to socket.c, renaming it to tipc_sk_send_ack(). Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Reviewed-by: Erik Hugne <erik.hugne@ericsson.com> Reviewed-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/port.c22
-rw-r--r--net/tipc/port.h2
-rw-r--r--net/tipc/socket.c22
3 files changed, 20 insertions, 26 deletions
diff --git a/net/tipc/port.c b/net/tipc/port.c
index 2f96719a3514..1074ccb0c76f 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -221,28 +221,6 @@ void tipc_port_reinit(void)
221 spin_unlock_bh(&tipc_port_list_lock); 221 spin_unlock_bh(&tipc_port_list_lock);
222} 222}
223 223
224void tipc_acknowledge(u32 ref, u32 ack)
225{
226 struct tipc_port *p_ptr;
227 struct sk_buff *buf = NULL;
228 struct tipc_msg *msg;
229
230 p_ptr = tipc_port_lock(ref);
231 if (!p_ptr)
232 return;
233 if (p_ptr->connected)
234 buf = tipc_msg_create(CONN_MANAGER, CONN_ACK, INT_H_SIZE,
235 0, tipc_port_peernode(p_ptr),
236 tipc_own_addr, tipc_port_peerport(p_ptr),
237 p_ptr->ref, TIPC_OK);
238 tipc_port_unlock(p_ptr);
239 if (!buf)
240 return;
241 msg = buf_msg(buf);
242 msg_set_msgcnt(msg, ack);
243 tipc_link_xmit(buf, msg_destnode(msg), msg_link_selector(msg));
244}
245
246int tipc_publish(struct tipc_port *p_ptr, unsigned int scope, 224int tipc_publish(struct tipc_port *p_ptr, unsigned int scope,
247 struct tipc_name_seq const *seq) 225 struct tipc_name_seq const *seq)
248{ 226{
diff --git a/net/tipc/port.h b/net/tipc/port.h
index b356cb8340d9..c92e1721f672 100644
--- a/net/tipc/port.h
+++ b/net/tipc/port.h
@@ -92,8 +92,6 @@ struct tipc_port_list;
92u32 tipc_port_init(struct tipc_port *p_ptr, 92u32 tipc_port_init(struct tipc_port *p_ptr,
93 const unsigned int importance); 93 const unsigned int importance);
94 94
95void tipc_acknowledge(u32 port_ref, u32 ack);
96
97void tipc_port_destroy(struct tipc_port *p_ptr); 95void tipc_port_destroy(struct tipc_port *p_ptr);
98 96
99int tipc_publish(struct tipc_port *p_ptr, unsigned int scope, 97int tipc_publish(struct tipc_port *p_ptr, unsigned int scope,
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index a65105818fe5..686a11be5c58 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -1106,6 +1106,24 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg,
1106 return 0; 1106 return 0;
1107} 1107}
1108 1108
1109static void tipc_sk_send_ack(struct tipc_port *port, uint ack)
1110{
1111 struct sk_buff *buf = NULL;
1112 struct tipc_msg *msg;
1113 u32 peer_port = tipc_port_peerport(port);
1114 u32 dnode = tipc_port_peernode(port);
1115
1116 if (!port->connected)
1117 return;
1118 buf = tipc_msg_create(CONN_MANAGER, CONN_ACK, INT_H_SIZE, 0, dnode,
1119 tipc_own_addr, peer_port, port->ref, TIPC_OK);
1120 if (!buf)
1121 return;
1122 msg = buf_msg(buf);
1123 msg_set_msgcnt(msg, ack);
1124 tipc_link_xmit(buf, dnode, msg_link_selector(msg));
1125}
1126
1109static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop) 1127static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop)
1110{ 1128{
1111 struct sock *sk = sock->sk; 1129 struct sock *sk = sock->sk;
@@ -1226,7 +1244,7 @@ restart:
1226 if (likely(!(flags & MSG_PEEK))) { 1244 if (likely(!(flags & MSG_PEEK))) {
1227 if ((sock->state != SS_READY) && 1245 if ((sock->state != SS_READY) &&
1228 (++tsk->rcv_unacked >= TIPC_CONNACK_INTV)) { 1246 (++tsk->rcv_unacked >= TIPC_CONNACK_INTV)) {
1229 tipc_acknowledge(port->ref, tsk->rcv_unacked); 1247 tipc_sk_send_ack(port, tsk->rcv_unacked);
1230 tsk->rcv_unacked = 0; 1248 tsk->rcv_unacked = 0;
1231 } 1249 }
1232 advance_rx_queue(sk); 1250 advance_rx_queue(sk);
@@ -1337,7 +1355,7 @@ restart:
1337 /* Consume received message (optional) */ 1355 /* Consume received message (optional) */
1338 if (likely(!(flags & MSG_PEEK))) { 1356 if (likely(!(flags & MSG_PEEK))) {
1339 if (unlikely(++tsk->rcv_unacked >= TIPC_CONNACK_INTV)) { 1357 if (unlikely(++tsk->rcv_unacked >= TIPC_CONNACK_INTV)) {
1340 tipc_acknowledge(port->ref, tsk->rcv_unacked); 1358 tipc_sk_send_ack(port, tsk->rcv_unacked);
1341 tsk->rcv_unacked = 0; 1359 tsk->rcv_unacked = 0;
1342 } 1360 }
1343 advance_rx_queue(sk); 1361 advance_rx_queue(sk);