Commit 3af390e2 authored by Ying Xue's avatar Ying Xue Committed by David S. Miller

tipc: remove two indentation levels in tipc_recv_msg routine

The message dispatching part of tipc_recv_msg() is wrapped layers of
while/if/if/switch, causing out-of-control indentation and does not
look very good. We reduce two indentation levels by separating the
message dispatching from the blocks that checks link state and
sequence numbers, allowing longer function and arg names to be
consistently indented without wrapping. Additionally we also rename
"cont" label to "discard" and add one new label called "unlock_discard"
to make code clearer. In all, these are cosmetic changes that do not
alter the operation of TIPC in any way.
Signed-off-by: default avatarYing Xue <ying.xue@windriver.com>
Reviewed-by: default avatarErik Hugne <erik.hugne@ericsson.com>
Cc: David Laight <david.laight@aculab.com>
Cc: Andreas Bofjäll <andreas.bofjall@ericsson.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 99470819
...@@ -1507,15 +1507,15 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) ...@@ -1507,15 +1507,15 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr)
/* Ensure bearer is still enabled */ /* Ensure bearer is still enabled */
if (unlikely(!b_ptr->active)) if (unlikely(!b_ptr->active))
goto cont; goto discard;
/* Ensure message is well-formed */ /* Ensure message is well-formed */
if (unlikely(!link_recv_buf_validate(buf))) if (unlikely(!link_recv_buf_validate(buf)))
goto cont; goto discard;
/* Ensure message data is a single contiguous unit */ /* Ensure message data is a single contiguous unit */
if (unlikely(skb_linearize(buf))) if (unlikely(skb_linearize(buf)))
goto cont; goto discard;
/* Handle arrival of a non-unicast link message */ /* Handle arrival of a non-unicast link message */
msg = buf_msg(buf); msg = buf_msg(buf);
...@@ -1531,20 +1531,18 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) ...@@ -1531,20 +1531,18 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr)
/* Discard unicast link messages destined for another node */ /* Discard unicast link messages destined for another node */
if (unlikely(!msg_short(msg) && if (unlikely(!msg_short(msg) &&
(msg_destnode(msg) != tipc_own_addr))) (msg_destnode(msg) != tipc_own_addr)))
goto cont; goto discard;
/* Locate neighboring node that sent message */ /* Locate neighboring node that sent message */
n_ptr = tipc_node_find(msg_prevnode(msg)); n_ptr = tipc_node_find(msg_prevnode(msg));
if (unlikely(!n_ptr)) if (unlikely(!n_ptr))
goto cont; goto discard;
tipc_node_lock(n_ptr); tipc_node_lock(n_ptr);
/* Locate unicast link endpoint that should handle message */ /* Locate unicast link endpoint that should handle message */
l_ptr = n_ptr->links[b_ptr->identity]; l_ptr = n_ptr->links[b_ptr->identity];
if (unlikely(!l_ptr)) { if (unlikely(!l_ptr))
tipc_node_unlock(n_ptr); goto unlock_discard;
goto cont;
}
/* Verify that communication with node is currently allowed */ /* Verify that communication with node is currently allowed */
if ((n_ptr->block_setup & WAIT_PEER_DOWN) && if ((n_ptr->block_setup & WAIT_PEER_DOWN) &&
...@@ -1554,10 +1552,8 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) ...@@ -1554,10 +1552,8 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr)
!msg_redundant_link(msg)) !msg_redundant_link(msg))
n_ptr->block_setup &= ~WAIT_PEER_DOWN; n_ptr->block_setup &= ~WAIT_PEER_DOWN;
if (n_ptr->block_setup) { if (n_ptr->block_setup)
tipc_node_unlock(n_ptr); goto unlock_discard;
goto cont;
}
/* Validate message sequence number info */ /* Validate message sequence number info */
seq_no = msg_seqno(msg); seq_no = msg_seqno(msg);
...@@ -1593,98 +1589,97 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) ...@@ -1593,98 +1589,97 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr)
/* Now (finally!) process the incoming message */ /* Now (finally!) process the incoming message */
protocol_check: protocol_check:
if (likely(link_working_working(l_ptr))) { if (unlikely(!link_working_working(l_ptr))) {
if (likely(seq_no == mod(l_ptr->next_in_no))) { if (msg_user(msg) == LINK_PROTOCOL) {
l_ptr->next_in_no++; link_recv_proto_msg(l_ptr, buf);
if (unlikely(l_ptr->oldest_deferred_in)) head = link_insert_deferred_queue(l_ptr, head);
head = link_insert_deferred_queue(l_ptr, tipc_node_unlock(n_ptr);
head); continue;
deliver: }
if (likely(msg_isdata(msg))) {
tipc_node_unlock(n_ptr); /* Traffic message. Conditionally activate link */
tipc_port_recv_msg(buf); link_state_event(l_ptr, TRAFFIC_MSG_EVT);
continue;
} if (link_working_working(l_ptr)) {
switch (msg_user(msg)) { /* Re-insert buffer in front of queue */
int ret; buf->next = head;
case MSG_BUNDLER: head = buf;
l_ptr->stats.recv_bundles++;
l_ptr->stats.recv_bundled +=
msg_msgcnt(msg);
tipc_node_unlock(n_ptr);
tipc_link_recv_bundle(buf);
continue;
case NAME_DISTRIBUTOR:
n_ptr->bclink.recv_permitted = true;
tipc_node_unlock(n_ptr);
tipc_named_recv(buf);
continue;
case BCAST_PROTOCOL:
tipc_link_recv_sync(n_ptr, buf);
tipc_node_unlock(n_ptr);
continue;
case CONN_MANAGER:
tipc_node_unlock(n_ptr);
tipc_port_recv_proto_msg(buf);
continue;
case MSG_FRAGMENTER:
l_ptr->stats.recv_fragments++;
ret = tipc_link_recv_fragment(
&l_ptr->defragm_buf,
&buf, &msg);
if (ret == 1) {
l_ptr->stats.recv_fragmented++;
goto deliver;
}
if (ret == -1)
l_ptr->next_in_no--;
break;
case CHANGEOVER_PROTOCOL:
type = msg_type(msg);
if (link_recv_changeover_msg(&l_ptr,
&buf)) {
msg = buf_msg(buf);
seq_no = msg_seqno(msg);
if (type == ORIGINAL_MSG)
goto deliver;
goto protocol_check;
}
break;
default:
kfree_skb(buf);
buf = NULL;
break;
}
tipc_node_unlock(n_ptr); tipc_node_unlock(n_ptr);
tipc_net_route_msg(buf);
continue; continue;
} }
goto unlock_discard;
}
/* Link is now in state WORKING_WORKING */
if (unlikely(seq_no != mod(l_ptr->next_in_no))) {
link_handle_out_of_seq_msg(l_ptr, buf); link_handle_out_of_seq_msg(l_ptr, buf);
head = link_insert_deferred_queue(l_ptr, head); head = link_insert_deferred_queue(l_ptr, head);
tipc_node_unlock(n_ptr); tipc_node_unlock(n_ptr);
continue; continue;
} }
l_ptr->next_in_no++;
/* Link is not in state WORKING_WORKING */ if (unlikely(l_ptr->oldest_deferred_in))
if (msg_user(msg) == LINK_PROTOCOL) {
link_recv_proto_msg(l_ptr, buf);
head = link_insert_deferred_queue(l_ptr, head); head = link_insert_deferred_queue(l_ptr, head);
deliver:
if (likely(msg_isdata(msg))) {
tipc_node_unlock(n_ptr); tipc_node_unlock(n_ptr);
tipc_port_recv_msg(buf);
continue; continue;
} }
switch (msg_user(msg)) {
/* Traffic message. Conditionally activate link */ int ret;
link_state_event(l_ptr, TRAFFIC_MSG_EVT); case MSG_BUNDLER:
l_ptr->stats.recv_bundles++;
if (link_working_working(l_ptr)) { l_ptr->stats.recv_bundled += msg_msgcnt(msg);
/* Re-insert buffer in front of queue */ tipc_node_unlock(n_ptr);
buf->next = head; tipc_link_recv_bundle(buf);
head = buf; continue;
case NAME_DISTRIBUTOR:
n_ptr->bclink.recv_permitted = true;
tipc_node_unlock(n_ptr);
tipc_named_recv(buf);
continue;
case BCAST_PROTOCOL:
tipc_link_recv_sync(n_ptr, buf);
tipc_node_unlock(n_ptr); tipc_node_unlock(n_ptr);
continue; continue;
case CONN_MANAGER:
tipc_node_unlock(n_ptr);
tipc_port_recv_proto_msg(buf);
continue;
case MSG_FRAGMENTER:
l_ptr->stats.recv_fragments++;
ret = tipc_link_recv_fragment(&l_ptr->defragm_buf,
&buf, &msg);
if (ret == 1) {
l_ptr->stats.recv_fragmented++;
goto deliver;
}
if (ret == -1)
l_ptr->next_in_no--;
break;
case CHANGEOVER_PROTOCOL:
type = msg_type(msg);
if (link_recv_changeover_msg(&l_ptr, &buf)) {
msg = buf_msg(buf);
seq_no = msg_seqno(msg);
if (type == ORIGINAL_MSG)
goto deliver;
goto protocol_check;
}
break;
default:
kfree_skb(buf);
buf = NULL;
break;
} }
tipc_node_unlock(n_ptr); tipc_node_unlock(n_ptr);
cont: tipc_net_route_msg(buf);
continue;
unlock_discard:
tipc_node_unlock(n_ptr);
discard:
kfree_skb(buf); kfree_skb(buf);
} }
read_unlock_bh(&tipc_net_lock); read_unlock_bh(&tipc_net_lock);
......
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