aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYing Xue <ying.xue@windriver.com>2013-10-29 23:26:57 -0400
committerDavid S. Miller <davem@davemloft.net>2013-10-30 16:54:54 -0400
commit3af390e2c5fd8a8cab6d123c18fcd3e1a65b43c6 (patch)
tree44d308df8a93a55387f7df8112ba36e1e3a29e6f
parent99470819b1a89f77c1eb44f6b3328c1aeb2c87d0 (diff)
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: Ying Xue <ying.xue@windriver.com> Reviewed-by: Erik Hugne <erik.hugne@ericsson.com> Cc: David Laight <david.laight@aculab.com> Cc: Andreas Bofjäll <andreas.bofjall@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/tipc/link.c173
1 files changed, 84 insertions, 89 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c
index e8153f64d2d6..54163f91b8ae 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1507,15 +1507,15 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr)
1507 1507
1508 /* Ensure bearer is still enabled */ 1508 /* Ensure bearer is still enabled */
1509 if (unlikely(!b_ptr->active)) 1509 if (unlikely(!b_ptr->active))
1510 goto cont; 1510 goto discard;
1511 1511
1512 /* Ensure message is well-formed */ 1512 /* Ensure message is well-formed */
1513 if (unlikely(!link_recv_buf_validate(buf))) 1513 if (unlikely(!link_recv_buf_validate(buf)))
1514 goto cont; 1514 goto discard;
1515 1515
1516 /* Ensure message data is a single contiguous unit */ 1516 /* Ensure message data is a single contiguous unit */
1517 if (unlikely(skb_linearize(buf))) 1517 if (unlikely(skb_linearize(buf)))
1518 goto cont; 1518 goto discard;
1519 1519
1520 /* Handle arrival of a non-unicast link message */ 1520 /* Handle arrival of a non-unicast link message */
1521 msg = buf_msg(buf); 1521 msg = buf_msg(buf);
@@ -1531,20 +1531,18 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr)
1531 /* Discard unicast link messages destined for another node */ 1531 /* Discard unicast link messages destined for another node */
1532 if (unlikely(!msg_short(msg) && 1532 if (unlikely(!msg_short(msg) &&
1533 (msg_destnode(msg) != tipc_own_addr))) 1533 (msg_destnode(msg) != tipc_own_addr)))
1534 goto cont; 1534 goto discard;
1535 1535
1536 /* Locate neighboring node that sent message */ 1536 /* Locate neighboring node that sent message */
1537 n_ptr = tipc_node_find(msg_prevnode(msg)); 1537 n_ptr = tipc_node_find(msg_prevnode(msg));
1538 if (unlikely(!n_ptr)) 1538 if (unlikely(!n_ptr))
1539 goto cont; 1539 goto discard;
1540 tipc_node_lock(n_ptr); 1540 tipc_node_lock(n_ptr);
1541 1541
1542 /* Locate unicast link endpoint that should handle message */ 1542 /* Locate unicast link endpoint that should handle message */
1543 l_ptr = n_ptr->links[b_ptr->identity]; 1543 l_ptr = n_ptr->links[b_ptr->identity];
1544 if (unlikely(!l_ptr)) { 1544 if (unlikely(!l_ptr))
1545 tipc_node_unlock(n_ptr); 1545 goto unlock_discard;
1546 goto cont;
1547 }
1548 1546
1549 /* Verify that communication with node is currently allowed */ 1547 /* Verify that communication with node is currently allowed */
1550 if ((n_ptr->block_setup & WAIT_PEER_DOWN) && 1548 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 !msg_redundant_link(msg)) 1552 !msg_redundant_link(msg))
1555 n_ptr->block_setup &= ~WAIT_PEER_DOWN; 1553 n_ptr->block_setup &= ~WAIT_PEER_DOWN;
1556 1554
1557 if (n_ptr->block_setup) { 1555 if (n_ptr->block_setup)
1558 tipc_node_unlock(n_ptr); 1556 goto unlock_discard;
1559 goto cont;
1560 }
1561 1557
1562 /* Validate message sequence number info */ 1558 /* Validate message sequence number info */
1563 seq_no = msg_seqno(msg); 1559 seq_no = msg_seqno(msg);
@@ -1593,98 +1589,97 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr)
1593 1589
1594 /* Now (finally!) process the incoming message */ 1590 /* Now (finally!) process the incoming message */
1595protocol_check: 1591protocol_check:
1596 if (likely(link_working_working(l_ptr))) { 1592 if (unlikely(!link_working_working(l_ptr))) {
1597 if (likely(seq_no == mod(l_ptr->next_in_no))) { 1593 if (msg_user(msg) == LINK_PROTOCOL) {
1598 l_ptr->next_in_no++; 1594 link_recv_proto_msg(l_ptr, buf);
1599 if (unlikely(l_ptr->oldest_deferred_in)) 1595 head = link_insert_deferred_queue(l_ptr, head);
1600 head = link_insert_deferred_queue(l_ptr, 1596 tipc_node_unlock(n_ptr);
1601 head); 1597 continue;
1602deliver: 1598 }
1603 if (likely(msg_isdata(msg))) { 1599
1604 tipc_node_unlock(n_ptr); 1600 /* Traffic message. Conditionally activate link */
1605 tipc_port_recv_msg(buf); 1601 link_state_event(l_ptr, TRAFFIC_MSG_EVT);
1606 continue; 1602
1607 } 1603 if (link_working_working(l_ptr)) {
1608 switch (msg_user(msg)) { 1604 /* Re-insert buffer in front of queue */
1609 int ret; 1605 buf->next = head;
1610 case MSG_BUNDLER: 1606 head = buf;
1611 l_ptr->stats.recv_bundles++;
1612 l_ptr->stats.recv_bundled +=
1613 msg_msgcnt(msg);
1614 tipc_node_unlock(n_ptr);
1615 tipc_link_recv_bundle(buf);
1616 continue;
1617 case NAME_DISTRIBUTOR:
1618 n_ptr->bclink.recv_permitted = true;
1619 tipc_node_unlock(n_ptr);
1620 tipc_named_recv(buf);
1621 continue;
1622 case BCAST_PROTOCOL:
1623 tipc_link_recv_sync(n_ptr, buf);
1624 tipc_node_unlock(n_ptr);
1625 continue;
1626 case CONN_MANAGER:
1627 tipc_node_unlock(n_ptr);
1628 tipc_port_recv_proto_msg(buf);
1629 continue;
1630 case MSG_FRAGMENTER:
1631 l_ptr->stats.recv_fragments++;
1632 ret = tipc_link_recv_fragment(
1633 &l_ptr->defragm_buf,
1634 &buf, &msg);
1635 if (ret == 1) {
1636 l_ptr->stats.recv_fragmented++;
1637 goto deliver;
1638 }
1639 if (ret == -1)
1640 l_ptr->next_in_no--;
1641 break;
1642 case CHANGEOVER_PROTOCOL:
1643 type = msg_type(msg);
1644 if (link_recv_changeover_msg(&l_ptr,
1645 &buf)) {
1646 msg = buf_msg(buf);
1647 seq_no = msg_seqno(msg);
1648 if (type == ORIGINAL_MSG)
1649 goto deliver;
1650 goto protocol_check;
1651 }
1652 break;
1653 default:
1654 kfree_skb(buf);
1655 buf = NULL;
1656 break;
1657 }
1658 tipc_node_unlock(n_ptr); 1607 tipc_node_unlock(n_ptr);
1659 tipc_net_route_msg(buf);
1660 continue; 1608 continue;
1661 } 1609 }
1610 goto unlock_discard;
1611 }
1612
1613 /* Link is now in state WORKING_WORKING */
1614 if (unlikely(seq_no != mod(l_ptr->next_in_no))) {
1662 link_handle_out_of_seq_msg(l_ptr, buf); 1615 link_handle_out_of_seq_msg(l_ptr, buf);
1663 head = link_insert_deferred_queue(l_ptr, head); 1616 head = link_insert_deferred_queue(l_ptr, head);
1664 tipc_node_unlock(n_ptr); 1617 tipc_node_unlock(n_ptr);
1665 continue; 1618 continue;
1666 } 1619 }
1667 1620 l_ptr->next_in_no++;
1668 /* Link is not in state WORKING_WORKING */ 1621 if (unlikely(l_ptr->oldest_deferred_in))
1669 if (msg_user(msg) == LINK_PROTOCOL) {
1670 link_recv_proto_msg(l_ptr, buf);
1671 head = link_insert_deferred_queue(l_ptr, head); 1622 head = link_insert_deferred_queue(l_ptr, head);
1623deliver:
1624 if (likely(msg_isdata(msg))) {
1672 tipc_node_unlock(n_ptr); 1625 tipc_node_unlock(n_ptr);
1626 tipc_port_recv_msg(buf);
1673 continue; 1627 continue;
1674 } 1628 }
1675 1629 switch (msg_user(msg)) {
1676 /* Traffic message. Conditionally activate link */ 1630 int ret;
1677 link_state_event(l_ptr, TRAFFIC_MSG_EVT); 1631 case MSG_BUNDLER:
1678 1632 l_ptr->stats.recv_bundles++;
1679 if (link_working_working(l_ptr)) { 1633 l_ptr->stats.recv_bundled += msg_msgcnt(msg);
1680 /* Re-insert buffer in front of queue */ 1634 tipc_node_unlock(n_ptr);
1681 buf->next = head; 1635 tipc_link_recv_bundle(buf);
1682 head = buf; 1636 continue;
1637 case NAME_DISTRIBUTOR:
1638 n_ptr->bclink.recv_permitted = true;
1639 tipc_node_unlock(n_ptr);
1640 tipc_named_recv(buf);
1641 continue;
1642 case BCAST_PROTOCOL:
1643 tipc_link_recv_sync(n_ptr, buf);
1683 tipc_node_unlock(n_ptr); 1644 tipc_node_unlock(n_ptr);
1684 continue; 1645 continue;
1646 case CONN_MANAGER:
1647 tipc_node_unlock(n_ptr);
1648 tipc_port_recv_proto_msg(buf);
1649 continue;
1650 case MSG_FRAGMENTER:
1651 l_ptr->stats.recv_fragments++;
1652 ret = tipc_link_recv_fragment(&l_ptr->defragm_buf,
1653 &buf, &msg);
1654 if (ret == 1) {
1655 l_ptr->stats.recv_fragmented++;
1656 goto deliver;
1657 }
1658 if (ret == -1)
1659 l_ptr->next_in_no--;
1660 break;
1661 case CHANGEOVER_PROTOCOL:
1662 type = msg_type(msg);
1663 if (link_recv_changeover_msg(&l_ptr, &buf)) {
1664 msg = buf_msg(buf);
1665 seq_no = msg_seqno(msg);
1666 if (type == ORIGINAL_MSG)
1667 goto deliver;
1668 goto protocol_check;
1669 }
1670 break;
1671 default:
1672 kfree_skb(buf);
1673 buf = NULL;
1674 break;
1685 } 1675 }
1686 tipc_node_unlock(n_ptr); 1676 tipc_node_unlock(n_ptr);
1687cont: 1677 tipc_net_route_msg(buf);
1678 continue;
1679unlock_discard:
1680
1681 tipc_node_unlock(n_ptr);
1682discard:
1688 kfree_skb(buf); 1683 kfree_skb(buf);
1689 } 1684 }
1690 read_unlock_bh(&tipc_net_lock); 1685 read_unlock_bh(&tipc_net_lock);