diff options
author | Erik Hugne <erik.hugne@ericsson.com> | 2014-07-01 04:22:40 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-07-07 22:55:07 -0400 |
commit | 7ae934bebe289362e5b1f5ea50e4c347863ae202 (patch) | |
tree | 993584604fc4b6369dd095a195000955a41e0ed1 /net/tipc/link.c | |
parent | 86c6a2c75ab97fe31844985169e26aea335432f9 (diff) |
tipc: refactor message delivery out of tipc_rcv
This is a cosmetic change, separating message delivery from the
link state processing.
Signed-off-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/link.c')
-rw-r--r-- | net/tipc/link.c | 124 |
1 files changed, 80 insertions, 44 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c index a081e7d08d22..18b1524098c6 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -88,6 +88,8 @@ static void link_print(struct tipc_link *l_ptr, const char *str); | |||
88 | static int tipc_link_frag_xmit(struct tipc_link *l_ptr, struct sk_buff *buf); | 88 | static int tipc_link_frag_xmit(struct tipc_link *l_ptr, struct sk_buff *buf); |
89 | static void tipc_link_sync_xmit(struct tipc_link *l); | 89 | static void tipc_link_sync_xmit(struct tipc_link *l); |
90 | static void tipc_link_sync_rcv(struct tipc_node *n, struct sk_buff *buf); | 90 | static void tipc_link_sync_rcv(struct tipc_node *n, struct sk_buff *buf); |
91 | static int tipc_link_input(struct tipc_link *l, struct sk_buff *buf); | ||
92 | static int tipc_link_prepare_input(struct tipc_link *l, struct sk_buff **buf); | ||
91 | 93 | ||
92 | /* | 94 | /* |
93 | * Simple link routines | 95 | * Simple link routines |
@@ -1458,54 +1460,14 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr) | |||
1458 | if (unlikely(l_ptr->oldest_deferred_in)) | 1460 | if (unlikely(l_ptr->oldest_deferred_in)) |
1459 | head = link_insert_deferred_queue(l_ptr, head); | 1461 | head = link_insert_deferred_queue(l_ptr, head); |
1460 | 1462 | ||
1461 | /* Deliver packet/message to correct user: */ | 1463 | if (tipc_link_prepare_input(l_ptr, &buf)) { |
1462 | if (unlikely(msg_user(msg) == CHANGEOVER_PROTOCOL)) { | ||
1463 | if (!tipc_link_tunnel_rcv(n_ptr, &buf)) { | ||
1464 | tipc_node_unlock(n_ptr); | ||
1465 | continue; | ||
1466 | } | ||
1467 | msg = buf_msg(buf); | ||
1468 | } else if (msg_user(msg) == MSG_FRAGMENTER) { | ||
1469 | l_ptr->stats.recv_fragments++; | ||
1470 | if (tipc_buf_append(&l_ptr->reasm_buf, &buf)) { | ||
1471 | l_ptr->stats.recv_fragmented++; | ||
1472 | msg = buf_msg(buf); | ||
1473 | } else { | ||
1474 | if (!l_ptr->reasm_buf) | ||
1475 | tipc_link_reset(l_ptr); | ||
1476 | tipc_node_unlock(n_ptr); | ||
1477 | continue; | ||
1478 | } | ||
1479 | } | ||
1480 | |||
1481 | switch (msg_user(msg)) { | ||
1482 | case TIPC_LOW_IMPORTANCE: | ||
1483 | case TIPC_MEDIUM_IMPORTANCE: | ||
1484 | case TIPC_HIGH_IMPORTANCE: | ||
1485 | case TIPC_CRITICAL_IMPORTANCE: | ||
1486 | case CONN_MANAGER: | ||
1487 | tipc_node_unlock(n_ptr); | ||
1488 | tipc_sk_rcv(buf); | ||
1489 | continue; | ||
1490 | case MSG_BUNDLER: | ||
1491 | l_ptr->stats.recv_bundles++; | ||
1492 | l_ptr->stats.recv_bundled += msg_msgcnt(msg); | ||
1493 | tipc_node_unlock(n_ptr); | 1464 | tipc_node_unlock(n_ptr); |
1494 | tipc_link_bundle_rcv(buf); | ||
1495 | continue; | 1465 | continue; |
1496 | case NAME_DISTRIBUTOR: | ||
1497 | n_ptr->bclink.recv_permitted = true; | ||
1498 | tipc_node_unlock(n_ptr); | ||
1499 | tipc_named_rcv(buf); | ||
1500 | continue; | ||
1501 | case BCAST_PROTOCOL: | ||
1502 | tipc_link_sync_rcv(n_ptr, buf); | ||
1503 | break; | ||
1504 | default: | ||
1505 | kfree_skb(buf); | ||
1506 | break; | ||
1507 | } | 1466 | } |
1508 | tipc_node_unlock(n_ptr); | 1467 | tipc_node_unlock(n_ptr); |
1468 | msg = buf_msg(buf); | ||
1469 | if (tipc_link_input(l_ptr, buf) != 0) | ||
1470 | goto discard; | ||
1509 | continue; | 1471 | continue; |
1510 | unlock_discard: | 1472 | unlock_discard: |
1511 | tipc_node_unlock(n_ptr); | 1473 | tipc_node_unlock(n_ptr); |
@@ -1515,6 +1477,80 @@ discard: | |||
1515 | } | 1477 | } |
1516 | 1478 | ||
1517 | /** | 1479 | /** |
1480 | * tipc_link_prepare_input - process TIPC link messages | ||
1481 | * | ||
1482 | * returns nonzero if the message was consumed | ||
1483 | * | ||
1484 | * Node lock must be held | ||
1485 | */ | ||
1486 | static int tipc_link_prepare_input(struct tipc_link *l, struct sk_buff **buf) | ||
1487 | { | ||
1488 | struct tipc_node *n; | ||
1489 | struct tipc_msg *msg; | ||
1490 | int res = -EINVAL; | ||
1491 | |||
1492 | n = l->owner; | ||
1493 | msg = buf_msg(*buf); | ||
1494 | switch (msg_user(msg)) { | ||
1495 | case CHANGEOVER_PROTOCOL: | ||
1496 | if (tipc_link_tunnel_rcv(n, buf)) | ||
1497 | res = 0; | ||
1498 | break; | ||
1499 | case MSG_FRAGMENTER: | ||
1500 | l->stats.recv_fragments++; | ||
1501 | if (tipc_buf_append(&l->reasm_buf, buf)) { | ||
1502 | l->stats.recv_fragmented++; | ||
1503 | res = 0; | ||
1504 | } else if (!l->reasm_buf) { | ||
1505 | tipc_link_reset(l); | ||
1506 | } | ||
1507 | break; | ||
1508 | case MSG_BUNDLER: | ||
1509 | l->stats.recv_bundles++; | ||
1510 | l->stats.recv_bundled += msg_msgcnt(msg); | ||
1511 | res = 0; | ||
1512 | break; | ||
1513 | case NAME_DISTRIBUTOR: | ||
1514 | n->bclink.recv_permitted = true; | ||
1515 | res = 0; | ||
1516 | break; | ||
1517 | case BCAST_PROTOCOL: | ||
1518 | tipc_link_sync_rcv(n, *buf); | ||
1519 | break; | ||
1520 | default: | ||
1521 | res = 0; | ||
1522 | } | ||
1523 | return res; | ||
1524 | } | ||
1525 | /** | ||
1526 | * tipc_link_input - Deliver message too higher layers | ||
1527 | */ | ||
1528 | static int tipc_link_input(struct tipc_link *l, struct sk_buff *buf) | ||
1529 | { | ||
1530 | struct tipc_msg *msg = buf_msg(buf); | ||
1531 | int res = 0; | ||
1532 | |||
1533 | switch (msg_user(msg)) { | ||
1534 | case TIPC_LOW_IMPORTANCE: | ||
1535 | case TIPC_MEDIUM_IMPORTANCE: | ||
1536 | case TIPC_HIGH_IMPORTANCE: | ||
1537 | case TIPC_CRITICAL_IMPORTANCE: | ||
1538 | case CONN_MANAGER: | ||
1539 | tipc_sk_rcv(buf); | ||
1540 | break; | ||
1541 | case NAME_DISTRIBUTOR: | ||
1542 | tipc_named_rcv(buf); | ||
1543 | break; | ||
1544 | case MSG_BUNDLER: | ||
1545 | tipc_link_bundle_rcv(buf); | ||
1546 | break; | ||
1547 | default: | ||
1548 | res = -EINVAL; | ||
1549 | } | ||
1550 | return res; | ||
1551 | } | ||
1552 | |||
1553 | /** | ||
1518 | * tipc_link_defer_pkt - Add out-of-sequence message to deferred reception queue | 1554 | * tipc_link_defer_pkt - Add out-of-sequence message to deferred reception queue |
1519 | * | 1555 | * |
1520 | * Returns increase in queue length (i.e. 0 or 1) | 1556 | * Returns increase in queue length (i.e. 0 or 1) |