Skip to content

Commit

Permalink
tipc: let port protocol senders use new link send function
Browse files Browse the repository at this point in the history
Several functions in port.c, related to the port protocol and
connection shutdown, need to send messages. We now convert them
to use the new link send function.

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>
  • Loading branch information
Jon Paul Maloy authored and David S. Miller committed Jun 27, 2014
1 parent 4ccfe5e commit b786e2b
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions net/tipc/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ u32 tipc_port_init(struct tipc_port *p_ptr,
void tipc_port_destroy(struct tipc_port *p_ptr)
{
struct sk_buff *buf = NULL;
struct tipc_msg *msg = NULL;
u32 peer;

tipc_withdraw(p_ptr, 0, NULL);

Expand All @@ -247,14 +249,15 @@ void tipc_port_destroy(struct tipc_port *p_ptr)
if (p_ptr->connected) {
buf = port_build_peer_abort_msg(p_ptr, TIPC_ERR_NO_PORT);
tipc_nodesub_unsubscribe(&p_ptr->subscription);
msg = buf_msg(buf);
peer = msg_destnode(msg);
tipc_link_xmit2(buf, peer, msg_link_selector(msg));
}

spin_lock_bh(&tipc_port_list_lock);
list_del(&p_ptr->port_list);
list_del(&p_ptr->wait_list);
spin_unlock_bh(&tipc_port_list_lock);
k_term_timer(&p_ptr->timer);
tipc_net_route_msg(buf);
}

/*
Expand All @@ -276,6 +279,7 @@ static struct sk_buff *port_build_proto_msg(struct tipc_port *p_ptr,
msg_set_destport(msg, tipc_port_peerport(p_ptr));
msg_set_origport(msg, p_ptr->ref);
msg_set_msgcnt(msg, ack);
buf->next = NULL;
}
return buf;
}
Expand All @@ -284,6 +288,7 @@ static void port_timeout(unsigned long ref)
{
struct tipc_port *p_ptr = tipc_port_lock(ref);
struct sk_buff *buf = NULL;
struct tipc_msg *msg = NULL;

if (!p_ptr)
return;
Expand All @@ -302,20 +307,23 @@ static void port_timeout(unsigned long ref)
k_start_timer(&p_ptr->timer, p_ptr->probing_interval);
}
tipc_port_unlock(p_ptr);
tipc_net_route_msg(buf);
msg = buf_msg(buf);
tipc_link_xmit2(buf, msg_destnode(msg), msg_link_selector(msg));
}


static void port_handle_node_down(unsigned long ref)
{
struct tipc_port *p_ptr = tipc_port_lock(ref);
struct sk_buff *buf = NULL;
struct tipc_msg *msg = NULL;

if (!p_ptr)
return;
buf = port_build_self_abort_msg(p_ptr, TIPC_ERR_NO_NODE);
tipc_port_unlock(p_ptr);
tipc_net_route_msg(buf);
msg = buf_msg(buf);
tipc_link_xmit2(buf, msg_destnode(msg), msg_link_selector(msg));
}


Expand All @@ -327,6 +335,7 @@ static struct sk_buff *port_build_self_abort_msg(struct tipc_port *p_ptr, u32 er
struct tipc_msg *msg = buf_msg(buf);
msg_swap_words(msg, 4, 5);
msg_swap_words(msg, 6, 7);
buf->next = NULL;
}
return buf;
}
Expand All @@ -351,6 +360,7 @@ static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *p_ptr, u32 er
if (imp < TIPC_CRITICAL_IMPORTANCE)
msg_set_importance(msg, ++imp);
msg_set_errcode(msg, err);
buf->next = NULL;
}
return buf;
}
Expand Down Expand Up @@ -401,7 +411,7 @@ void tipc_port_proto_rcv(struct sk_buff *buf)
p_ptr->probing_state = CONFIRMED;
tipc_port_unlock(p_ptr);
exit:
tipc_net_route_msg(r_buf);
tipc_link_xmit2(r_buf, msg_destnode(msg), msg_link_selector(msg));
kfree_skb(buf);
}

Expand Down Expand Up @@ -496,6 +506,7 @@ 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)
Expand All @@ -505,7 +516,10 @@ void tipc_acknowledge(u32 ref, u32 ack)
buf = port_build_proto_msg(p_ptr, CONN_ACK, ack);
}
tipc_port_unlock(p_ptr);
tipc_net_route_msg(buf);
if (!buf)
return;
msg = buf_msg(buf);
tipc_link_xmit2(buf, msg_destnode(msg), msg_link_selector(msg));
}

int tipc_publish(struct tipc_port *p_ptr, unsigned int scope,
Expand Down Expand Up @@ -656,6 +670,7 @@ int tipc_port_disconnect(u32 ref)
*/
int tipc_port_shutdown(u32 ref)
{
struct tipc_msg *msg;
struct tipc_port *p_ptr;
struct sk_buff *buf = NULL;

Expand All @@ -665,6 +680,7 @@ int tipc_port_shutdown(u32 ref)

buf = port_build_peer_abort_msg(p_ptr, TIPC_CONN_SHUTDOWN);
tipc_port_unlock(p_ptr);
tipc_net_route_msg(buf);
msg = buf_msg(buf);
tipc_link_xmit2(buf, msg_destnode(msg), msg_link_selector(msg));
return tipc_port_disconnect(ref);
}

0 comments on commit b786e2b

Please sign in to comment.