Skip to content

Commit 8e6e85e

Browse files
committed
Merge branch 'tipc-next'
Erik Hugne says: ==================== tipc: link state processing improvements Message delivery is separated from the link state processing, and we fix a bug in receive-path triggered acks. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 86c6a2c + 3f53bd8 commit 8e6e85e

File tree

1 file changed

+83
-47
lines changed

1 file changed

+83
-47
lines changed

net/tipc/link.c

Lines changed: 83 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ static void link_print(struct tipc_link *l_ptr, const char *str);
8888
static int tipc_link_frag_xmit(struct tipc_link *l_ptr, struct sk_buff *buf);
8989
static void tipc_link_sync_xmit(struct tipc_link *l);
9090
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);
9193

9294
/*
9395
* Simple link routines
@@ -1420,11 +1422,6 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr)
14201422
if (unlikely(!list_empty(&l_ptr->waiting_ports)))
14211423
tipc_link_wakeup_ports(l_ptr, 0);
14221424

1423-
if (unlikely(++l_ptr->unacked_window >= TIPC_MIN_LINK_WIN)) {
1424-
l_ptr->stats.sent_acks++;
1425-
tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, 0, 0, 0);
1426-
}
1427-
14281425
/* Process the incoming packet */
14291426
if (unlikely(!link_working_working(l_ptr))) {
14301427
if (msg_user(msg) == LINK_PROTOCOL) {
@@ -1458,54 +1455,19 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr)
14581455
if (unlikely(l_ptr->oldest_deferred_in))
14591456
head = link_insert_deferred_queue(l_ptr, head);
14601457

1461-
/* Deliver packet/message to correct user: */
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-
}
1458+
if (unlikely(++l_ptr->unacked_window >= TIPC_MIN_LINK_WIN)) {
1459+
l_ptr->stats.sent_acks++;
1460+
tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, 0, 0, 0);
14791461
}
14801462

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);
1463+
if (tipc_link_prepare_input(l_ptr, &buf)) {
14931464
tipc_node_unlock(n_ptr);
1494-
tipc_link_bundle_rcv(buf);
14951465
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;
15071466
}
15081467
tipc_node_unlock(n_ptr);
1468+
msg = buf_msg(buf);
1469+
if (tipc_link_input(l_ptr, buf) != 0)
1470+
goto discard;
15091471
continue;
15101472
unlock_discard:
15111473
tipc_node_unlock(n_ptr);
@@ -1514,6 +1476,80 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr)
15141476
}
15151477
}
15161478

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+
15171553
/**
15181554
* tipc_link_defer_pkt - Add out-of-sequence message to deferred reception queue
15191555
*

0 commit comments

Comments
 (0)