aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorJon Paul Maloy <jon.maloy@ericsson.com>2014-02-13 17:29:15 -0500
committerDavid S. Miller <davem@davemloft.net>2014-02-13 17:57:06 -0500
commita5377831eb64c1b8a7b911dc79aec73a930e95da (patch)
tree6507569b5f737a03f58008933c5fff64e566e72f /net/tipc
parent02842f718d9d47950ec9045825679ec266ba532d (diff)
tipc: changes to general packet reception algorithm
We change the order of checking for destination users when processing incoming packets. By placing the checks for users that may potentially replace the processed buffer, i.e., CHANGEOVER_PROTOCOL and MSG_FRAGMENTER, in a separate step before we check for the true end users, we get rid of a label and a 'goto', at the same time making the code more comprehensible and easy to follow. This commit does not change any functionality, it is just a cosmetic code reshuffle. Signed-off-by: Jon Maloy <jon.maloy@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/link.c76
1 files changed, 40 insertions, 36 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c
index b678c2e0080a..663623c5896d 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1484,7 +1484,7 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr)
1484 if ((n_ptr->block_setup & WAIT_PEER_DOWN) && 1484 if ((n_ptr->block_setup & WAIT_PEER_DOWN) &&
1485 msg_user(msg) == LINK_PROTOCOL && 1485 msg_user(msg) == LINK_PROTOCOL &&
1486 (msg_type(msg) == RESET_MSG || 1486 (msg_type(msg) == RESET_MSG ||
1487 msg_type(msg) == ACTIVATE_MSG) && 1487 msg_type(msg) == ACTIVATE_MSG) &&
1488 !msg_redundant_link(msg)) 1488 !msg_redundant_link(msg))
1489 n_ptr->block_setup &= ~WAIT_PEER_DOWN; 1489 n_ptr->block_setup &= ~WAIT_PEER_DOWN;
1490 1490
@@ -1503,7 +1503,6 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr)
1503 while ((crs != l_ptr->next_out) && 1503 while ((crs != l_ptr->next_out) &&
1504 less_eq(buf_seqno(crs), ackd)) { 1504 less_eq(buf_seqno(crs), ackd)) {
1505 struct sk_buff *next = crs->next; 1505 struct sk_buff *next = crs->next;
1506
1507 kfree_skb(crs); 1506 kfree_skb(crs);
1508 crs = next; 1507 crs = next;
1509 released++; 1508 released++;
@@ -1516,14 +1515,17 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr)
1516 /* Try sending any messages link endpoint has pending */ 1515 /* Try sending any messages link endpoint has pending */
1517 if (unlikely(l_ptr->next_out)) 1516 if (unlikely(l_ptr->next_out))
1518 tipc_link_push_queue(l_ptr); 1517 tipc_link_push_queue(l_ptr);
1518
1519 if (unlikely(!list_empty(&l_ptr->waiting_ports))) 1519 if (unlikely(!list_empty(&l_ptr->waiting_ports)))
1520 tipc_link_wakeup_ports(l_ptr, 0); 1520 tipc_link_wakeup_ports(l_ptr, 0);
1521
1521 if (unlikely(++l_ptr->unacked_window >= TIPC_MIN_LINK_WIN)) { 1522 if (unlikely(++l_ptr->unacked_window >= TIPC_MIN_LINK_WIN)) {
1522 l_ptr->stats.sent_acks++; 1523 l_ptr->stats.sent_acks++;
1523 tipc_link_send_proto_msg(l_ptr, STATE_MSG, 0, 0, 0, 0, 0); 1524 tipc_link_send_proto_msg(l_ptr, STATE_MSG,
1525 0, 0, 0, 0, 0);
1524 } 1526 }
1525 1527
1526 /* Now (finally!) process the incoming message */ 1528 /* Process the incoming packet */
1527 if (unlikely(!link_working_working(l_ptr))) { 1529 if (unlikely(!link_working_working(l_ptr))) {
1528 if (msg_user(msg) == LINK_PROTOCOL) { 1530 if (msg_user(msg) == LINK_PROTOCOL) {
1529 link_recv_proto_msg(l_ptr, buf); 1531 link_recv_proto_msg(l_ptr, buf);
@@ -1555,14 +1557,40 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr)
1555 l_ptr->next_in_no++; 1557 l_ptr->next_in_no++;
1556 if (unlikely(l_ptr->oldest_deferred_in)) 1558 if (unlikely(l_ptr->oldest_deferred_in))
1557 head = link_insert_deferred_queue(l_ptr, head); 1559 head = link_insert_deferred_queue(l_ptr, head);
1558deliver: 1560
1559 if (likely(msg_isdata(msg))) { 1561 /* Deliver packet/message to correct user: */
1562 if (unlikely(msg_user(msg) == CHANGEOVER_PROTOCOL)) {
1563 if (!tipc_link_tunnel_rcv(n_ptr, &buf)) {
1564 tipc_node_unlock(n_ptr);
1565 continue;
1566 }
1567 msg = buf_msg(buf);
1568 } else if (msg_user(msg) == MSG_FRAGMENTER) {
1569 int rc;
1570
1571 l_ptr->stats.recv_fragments++;
1572 rc = tipc_link_frag_rcv(&l_ptr->reasm_head,
1573 &l_ptr->reasm_tail,
1574 &buf);
1575 if (rc == LINK_REASM_COMPLETE) {
1576 l_ptr->stats.recv_fragmented++;
1577 msg = buf_msg(buf);
1578 } else {
1579 if (rc == LINK_REASM_ERROR)
1580 tipc_link_reset(l_ptr);
1581 tipc_node_unlock(n_ptr);
1582 continue;
1583 }
1584 }
1585
1586 switch (msg_user(msg)) {
1587 case TIPC_LOW_IMPORTANCE:
1588 case TIPC_MEDIUM_IMPORTANCE:
1589 case TIPC_HIGH_IMPORTANCE:
1590 case TIPC_CRITICAL_IMPORTANCE:
1560 tipc_node_unlock(n_ptr); 1591 tipc_node_unlock(n_ptr);
1561 tipc_port_recv_msg(buf); 1592 tipc_port_recv_msg(buf);
1562 continue; 1593 continue;
1563 }
1564 switch (msg_user(msg)) {
1565 int ret;
1566 case MSG_BUNDLER: 1594 case MSG_BUNDLER:
1567 l_ptr->stats.recv_bundles++; 1595 l_ptr->stats.recv_bundles++;
1568 l_ptr->stats.recv_bundled += msg_msgcnt(msg); 1596 l_ptr->stats.recv_bundled += msg_msgcnt(msg);
@@ -1574,44 +1602,20 @@ deliver:
1574 tipc_node_unlock(n_ptr); 1602 tipc_node_unlock(n_ptr);
1575 tipc_named_recv(buf); 1603 tipc_named_recv(buf);
1576 continue; 1604 continue;
1577 case BCAST_PROTOCOL:
1578 tipc_link_recv_sync(n_ptr, buf);
1579 tipc_node_unlock(n_ptr);
1580 continue;
1581 case CONN_MANAGER: 1605 case CONN_MANAGER:
1582 tipc_node_unlock(n_ptr); 1606 tipc_node_unlock(n_ptr);
1583 tipc_port_recv_proto_msg(buf); 1607 tipc_port_recv_proto_msg(buf);
1584 continue; 1608 continue;
1585 case MSG_FRAGMENTER: 1609 case BCAST_PROTOCOL:
1586 l_ptr->stats.recv_fragments++; 1610 tipc_link_recv_sync(n_ptr, buf);
1587 ret = tipc_link_frag_rcv(&l_ptr->reasm_head, 1611 break;
1588 &l_ptr->reasm_tail,
1589 &buf);
1590 if (ret == LINK_REASM_COMPLETE) {
1591 l_ptr->stats.recv_fragmented++;
1592 msg = buf_msg(buf);
1593 goto deliver;
1594 }
1595 if (ret == LINK_REASM_ERROR)
1596 tipc_link_reset(l_ptr);
1597 tipc_node_unlock(n_ptr);
1598 continue;
1599 case CHANGEOVER_PROTOCOL:
1600 if (!tipc_link_tunnel_rcv(n_ptr, &buf))
1601 break;
1602 msg = buf_msg(buf);
1603 seq_no = msg_seqno(msg);
1604 goto deliver;
1605 default: 1612 default:
1606 kfree_skb(buf); 1613 kfree_skb(buf);
1607 buf = NULL;
1608 break; 1614 break;
1609 } 1615 }
1610 tipc_node_unlock(n_ptr); 1616 tipc_node_unlock(n_ptr);
1611 tipc_net_route_msg(buf);
1612 continue; 1617 continue;
1613unlock_discard: 1618unlock_discard:
1614
1615 tipc_node_unlock(n_ptr); 1619 tipc_node_unlock(n_ptr);
1616discard: 1620discard:
1617 kfree_skb(buf); 1621 kfree_skb(buf);