@@ -88,6 +88,8 @@ static void link_print(struct tipc_link *l_ptr, const char *str);
88
88
static int tipc_link_frag_xmit (struct tipc_link * l_ptr , struct sk_buff * buf );
89
89
static void tipc_link_sync_xmit (struct tipc_link * l );
90
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
95
* Simple link routines
@@ -1458,54 +1460,14 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr)
1458
1460
if (unlikely (l_ptr -> oldest_deferred_in ))
1459
1461
head = link_insert_deferred_queue (l_ptr , head );
1460
1462
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
- }
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 );
1463
+ if (tipc_link_prepare_input (l_ptr , & buf )) {
1493
1464
tipc_node_unlock (n_ptr );
1494
- tipc_link_bundle_rcv (buf );
1495
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
1467
tipc_node_unlock (n_ptr );
1468
+ msg = buf_msg (buf );
1469
+ if (tipc_link_input (l_ptr , buf ) != 0 )
1470
+ goto discard ;
1509
1471
continue ;
1510
1472
unlock_discard :
1511
1473
tipc_node_unlock (n_ptr );
@@ -1514,6 +1476,80 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr)
1514
1476
}
1515
1477
}
1516
1478
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
+
1517
1553
/**
1518
1554
* tipc_link_defer_pkt - Add out-of-sequence message to deferred reception queue
1519
1555
*
0 commit comments