Commit 739f5e4e authored by Jon Paul Maloy's avatar Jon Paul Maloy Committed by David S. Miller

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: default avatarJon Maloy <jon.maloy@ericsson.com>
Reviewed-by: default avatarErik Hugne <erik.hugne@ericsson.com>
Reviewed-by: default avatarYing Xue <ying.xue@windriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dadebc00
...@@ -221,28 +221,6 @@ void tipc_port_reinit(void) ...@@ -221,28 +221,6 @@ void tipc_port_reinit(void)
spin_unlock_bh(&tipc_port_list_lock); spin_unlock_bh(&tipc_port_list_lock);
} }
void tipc_acknowledge(u32 ref, u32 ack)
{
struct tipc_port *p_ptr;
struct sk_buff *buf = NULL;
struct tipc_msg *msg;
p_ptr = tipc_port_lock(ref);
if (!p_ptr)
return;
if (p_ptr->connected)
buf = tipc_msg_create(CONN_MANAGER, CONN_ACK, INT_H_SIZE,
0, tipc_port_peernode(p_ptr),
tipc_own_addr, tipc_port_peerport(p_ptr),
p_ptr->ref, TIPC_OK);
tipc_port_unlock(p_ptr);
if (!buf)
return;
msg = buf_msg(buf);
msg_set_msgcnt(msg, ack);
tipc_link_xmit(buf, msg_destnode(msg), msg_link_selector(msg));
}
int tipc_publish(struct tipc_port *p_ptr, unsigned int scope, int tipc_publish(struct tipc_port *p_ptr, unsigned int scope,
struct tipc_name_seq const *seq) struct tipc_name_seq const *seq)
{ {
......
...@@ -92,8 +92,6 @@ struct tipc_port_list; ...@@ -92,8 +92,6 @@ struct tipc_port_list;
u32 tipc_port_init(struct tipc_port *p_ptr, u32 tipc_port_init(struct tipc_port *p_ptr,
const unsigned int importance); const unsigned int importance);
void tipc_acknowledge(u32 port_ref, u32 ack);
void tipc_port_destroy(struct tipc_port *p_ptr); void tipc_port_destroy(struct tipc_port *p_ptr);
int tipc_publish(struct tipc_port *p_ptr, unsigned int scope, int tipc_publish(struct tipc_port *p_ptr, unsigned int scope,
......
...@@ -1106,6 +1106,24 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg, ...@@ -1106,6 +1106,24 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg,
return 0; return 0;
} }
static void tipc_sk_send_ack(struct tipc_port *port, uint ack)
{
struct sk_buff *buf = NULL;
struct tipc_msg *msg;
u32 peer_port = tipc_port_peerport(port);
u32 dnode = tipc_port_peernode(port);
if (!port->connected)
return;
buf = tipc_msg_create(CONN_MANAGER, CONN_ACK, INT_H_SIZE, 0, dnode,
tipc_own_addr, peer_port, port->ref, TIPC_OK);
if (!buf)
return;
msg = buf_msg(buf);
msg_set_msgcnt(msg, ack);
tipc_link_xmit(buf, dnode, msg_link_selector(msg));
}
static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop) static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
...@@ -1226,7 +1244,7 @@ static int tipc_recvmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1226,7 +1244,7 @@ static int tipc_recvmsg(struct kiocb *iocb, struct socket *sock,
if (likely(!(flags & MSG_PEEK))) { if (likely(!(flags & MSG_PEEK))) {
if ((sock->state != SS_READY) && if ((sock->state != SS_READY) &&
(++tsk->rcv_unacked >= TIPC_CONNACK_INTV)) { (++tsk->rcv_unacked >= TIPC_CONNACK_INTV)) {
tipc_acknowledge(port->ref, tsk->rcv_unacked); tipc_sk_send_ack(port, tsk->rcv_unacked);
tsk->rcv_unacked = 0; tsk->rcv_unacked = 0;
} }
advance_rx_queue(sk); advance_rx_queue(sk);
...@@ -1337,7 +1355,7 @@ static int tipc_recv_stream(struct kiocb *iocb, struct socket *sock, ...@@ -1337,7 +1355,7 @@ static int tipc_recv_stream(struct kiocb *iocb, struct socket *sock,
/* Consume received message (optional) */ /* Consume received message (optional) */
if (likely(!(flags & MSG_PEEK))) { if (likely(!(flags & MSG_PEEK))) {
if (unlikely(++tsk->rcv_unacked >= TIPC_CONNACK_INTV)) { if (unlikely(++tsk->rcv_unacked >= TIPC_CONNACK_INTV)) {
tipc_acknowledge(port->ref, tsk->rcv_unacked); tipc_sk_send_ack(port, tsk->rcv_unacked);
tsk->rcv_unacked = 0; tsk->rcv_unacked = 0;
} }
advance_rx_queue(sk); advance_rx_queue(sk);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment