aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/link.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/link.c')
-rw-r--r--net/tipc/link.c56
1 files changed, 26 insertions, 30 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 77c7ccd492b5..41cb09aa41de 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -101,13 +101,12 @@ static const struct nla_policy tipc_nl_prop_policy[TIPC_NLA_PROP_MAX + 1] = {
101 */ 101 */
102#define START_CHANGEOVER 100000u 102#define START_CHANGEOVER 100000u
103 103
104static void link_handle_out_of_seq_msg(struct net *net, 104static void link_handle_out_of_seq_msg(struct tipc_link *link,
105 struct tipc_link *l_ptr, 105 struct sk_buff *skb);
106 struct sk_buff *buf); 106static void tipc_link_proto_rcv(struct tipc_link *link,
107static void tipc_link_proto_rcv(struct net *net, struct tipc_link *l_ptr, 107 struct sk_buff *skb);
108 struct sk_buff *buf); 108static int tipc_link_tunnel_rcv(struct tipc_node *node,
109static int tipc_link_tunnel_rcv(struct net *net, struct tipc_node *n_ptr, 109 struct sk_buff **skb);
110 struct sk_buff **buf);
111static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tol); 110static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tol);
112static void link_state_event(struct tipc_link *l_ptr, u32 event); 111static void link_state_event(struct tipc_link *l_ptr, u32 event);
113static void link_reset_statistics(struct tipc_link *l_ptr); 112static void link_reset_statistics(struct tipc_link *l_ptr);
@@ -303,7 +302,7 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr,
303 302
304 l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg; 303 l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg;
305 msg = l_ptr->pmsg; 304 msg = l_ptr->pmsg;
306 tipc_msg_init(n_ptr->net, msg, LINK_PROTOCOL, RESET_MSG, INT_H_SIZE, 305 tipc_msg_init(tn->own_addr, msg, LINK_PROTOCOL, RESET_MSG, INT_H_SIZE,
307 l_ptr->addr); 306 l_ptr->addr);
308 msg_set_size(msg, sizeof(l_ptr->proto_msg)); 307 msg_set_size(msg, sizeof(l_ptr->proto_msg));
309 msg_set_session(msg, (tn->random & 0xffff)); 308 msg_set_session(msg, (tn->random & 0xffff));
@@ -379,12 +378,11 @@ void tipc_link_delete_list(struct net *net, unsigned int bearer_id,
379static bool link_schedule_user(struct tipc_link *link, u32 oport, 378static bool link_schedule_user(struct tipc_link *link, u32 oport,
380 uint chain_sz, uint imp) 379 uint chain_sz, uint imp)
381{ 380{
382 struct net *net = link->owner->net;
383 struct tipc_net *tn = net_generic(net, tipc_net_id);
384 struct sk_buff *buf; 381 struct sk_buff *buf;
385 382
386 buf = tipc_msg_create(net, SOCK_WAKEUP, 0, INT_H_SIZE, 0, tn->own_addr, 383 buf = tipc_msg_create(SOCK_WAKEUP, 0, INT_H_SIZE, 0,
387 tn->own_addr, oport, 0, 0); 384 link_own_addr(link), link_own_addr(link),
385 oport, 0, 0);
388 if (!buf) 386 if (!buf)
389 return false; 387 return false;
390 TIPC_SKB_CB(buf)->chain_sz = chain_sz; 388 TIPC_SKB_CB(buf)->chain_sz = chain_sz;
@@ -778,7 +776,7 @@ int __tipc_link_xmit(struct net *net, struct tipc_link *link,
778 } else if (tipc_msg_bundle(outqueue, skb, mtu)) { 776 } else if (tipc_msg_bundle(outqueue, skb, mtu)) {
779 link->stats.sent_bundled++; 777 link->stats.sent_bundled++;
780 continue; 778 continue;
781 } else if (tipc_msg_make_bundle(net, outqueue, skb, mtu, 779 } else if (tipc_msg_make_bundle(outqueue, skb, mtu,
782 link->addr)) { 780 link->addr)) {
783 link->stats.sent_bundled++; 781 link->stats.sent_bundled++;
784 link->stats.sent_bundles++; 782 link->stats.sent_bundles++;
@@ -877,7 +875,7 @@ static void tipc_link_sync_xmit(struct tipc_link *link)
877 return; 875 return;
878 876
879 msg = buf_msg(skb); 877 msg = buf_msg(skb);
880 tipc_msg_init(link->owner->net, msg, BCAST_PROTOCOL, STATE_MSG, 878 tipc_msg_init(link_own_addr(link), msg, BCAST_PROTOCOL, STATE_MSG,
881 INT_H_SIZE, link->addr); 879 INT_H_SIZE, link->addr);
882 msg_set_last_bcast(msg, link->owner->bclink.acked); 880 msg_set_last_bcast(msg, link->owner->bclink.acked);
883 __tipc_link_xmit_skb(link, skb); 881 __tipc_link_xmit_skb(link, skb);
@@ -1207,7 +1205,7 @@ void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b_ptr)
1207 /* Process the incoming packet */ 1205 /* Process the incoming packet */
1208 if (unlikely(!link_working_working(l_ptr))) { 1206 if (unlikely(!link_working_working(l_ptr))) {
1209 if (msg_user(msg) == LINK_PROTOCOL) { 1207 if (msg_user(msg) == LINK_PROTOCOL) {
1210 tipc_link_proto_rcv(net, l_ptr, skb); 1208 tipc_link_proto_rcv(l_ptr, skb);
1211 link_retrieve_defq(l_ptr, &head); 1209 link_retrieve_defq(l_ptr, &head);
1212 tipc_node_unlock(n_ptr); 1210 tipc_node_unlock(n_ptr);
1213 continue; 1211 continue;
@@ -1227,7 +1225,7 @@ void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b_ptr)
1227 1225
1228 /* Link is now in state WORKING_WORKING */ 1226 /* Link is now in state WORKING_WORKING */
1229 if (unlikely(seq_no != mod(l_ptr->next_in_no))) { 1227 if (unlikely(seq_no != mod(l_ptr->next_in_no))) {
1230 link_handle_out_of_seq_msg(net, l_ptr, skb); 1228 link_handle_out_of_seq_msg(l_ptr, skb);
1231 link_retrieve_defq(l_ptr, &head); 1229 link_retrieve_defq(l_ptr, &head);
1232 tipc_node_unlock(n_ptr); 1230 tipc_node_unlock(n_ptr);
1233 continue; 1231 continue;
@@ -1275,7 +1273,7 @@ static int tipc_link_prepare_input(struct net *net, struct tipc_link *l,
1275 msg = buf_msg(*buf); 1273 msg = buf_msg(*buf);
1276 switch (msg_user(msg)) { 1274 switch (msg_user(msg)) {
1277 case CHANGEOVER_PROTOCOL: 1275 case CHANGEOVER_PROTOCOL:
1278 if (tipc_link_tunnel_rcv(net, n, buf)) 1276 if (tipc_link_tunnel_rcv(n, buf))
1279 res = 0; 1277 res = 0;
1280 break; 1278 break;
1281 case MSG_FRAGMENTER: 1279 case MSG_FRAGMENTER:
@@ -1375,14 +1373,13 @@ u32 tipc_link_defer_pkt(struct sk_buff_head *list, struct sk_buff *skb)
1375/* 1373/*
1376 * link_handle_out_of_seq_msg - handle arrival of out-of-sequence packet 1374 * link_handle_out_of_seq_msg - handle arrival of out-of-sequence packet
1377 */ 1375 */
1378static void link_handle_out_of_seq_msg(struct net *net, 1376static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr,
1379 struct tipc_link *l_ptr,
1380 struct sk_buff *buf) 1377 struct sk_buff *buf)
1381{ 1378{
1382 u32 seq_no = buf_seqno(buf); 1379 u32 seq_no = buf_seqno(buf);
1383 1380
1384 if (likely(msg_user(buf_msg(buf)) == LINK_PROTOCOL)) { 1381 if (likely(msg_user(buf_msg(buf)) == LINK_PROTOCOL)) {
1385 tipc_link_proto_rcv(net, l_ptr, buf); 1382 tipc_link_proto_rcv(l_ptr, buf);
1386 return; 1383 return;
1387 } 1384 }
1388 1385
@@ -1507,10 +1504,9 @@ void tipc_link_proto_xmit(struct tipc_link *l_ptr, u32 msg_typ, int probe_msg,
1507 * Note that network plane id propagates through the network, and may 1504 * Note that network plane id propagates through the network, and may
1508 * change at any time. The node with lowest address rules 1505 * change at any time. The node with lowest address rules
1509 */ 1506 */
1510static void tipc_link_proto_rcv(struct net *net, struct tipc_link *l_ptr, 1507static void tipc_link_proto_rcv(struct tipc_link *l_ptr,
1511 struct sk_buff *buf) 1508 struct sk_buff *buf)
1512{ 1509{
1513 struct tipc_net *tn = net_generic(net, tipc_net_id);
1514 u32 rec_gap = 0; 1510 u32 rec_gap = 0;
1515 u32 max_pkt_info; 1511 u32 max_pkt_info;
1516 u32 max_pkt_ack; 1512 u32 max_pkt_ack;
@@ -1522,7 +1518,7 @@ static void tipc_link_proto_rcv(struct net *net, struct tipc_link *l_ptr,
1522 goto exit; 1518 goto exit;
1523 1519
1524 if (l_ptr->net_plane != msg_net_plane(msg)) 1520 if (l_ptr->net_plane != msg_net_plane(msg))
1525 if (tn->own_addr > msg_prevnode(msg)) 1521 if (link_own_addr(l_ptr) > msg_prevnode(msg))
1526 l_ptr->net_plane = msg_net_plane(msg); 1522 l_ptr->net_plane = msg_net_plane(msg);
1527 1523
1528 switch (msg_type(msg)) { 1524 switch (msg_type(msg)) {
@@ -1625,7 +1621,7 @@ static void tipc_link_proto_rcv(struct net *net, struct tipc_link *l_ptr,
1625 1621
1626 /* Protocol message before retransmits, reduce loss risk */ 1622 /* Protocol message before retransmits, reduce loss risk */
1627 if (l_ptr->owner->bclink.recv_permitted) 1623 if (l_ptr->owner->bclink.recv_permitted)
1628 tipc_bclink_update_link_state(net, l_ptr->owner, 1624 tipc_bclink_update_link_state(l_ptr->owner,
1629 msg_last_bcast(msg)); 1625 msg_last_bcast(msg));
1630 1626
1631 if (rec_gap || (msg_probe(msg))) { 1627 if (rec_gap || (msg_probe(msg))) {
@@ -1690,7 +1686,7 @@ void tipc_link_failover_send_queue(struct tipc_link *l_ptr)
1690 if (!tunnel) 1686 if (!tunnel)
1691 return; 1687 return;
1692 1688
1693 tipc_msg_init(l_ptr->owner->net, &tunnel_hdr, CHANGEOVER_PROTOCOL, 1689 tipc_msg_init(link_own_addr(l_ptr), &tunnel_hdr, CHANGEOVER_PROTOCOL,
1694 ORIGINAL_MSG, INT_H_SIZE, l_ptr->addr); 1690 ORIGINAL_MSG, INT_H_SIZE, l_ptr->addr);
1695 msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); 1691 msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id);
1696 msg_set_msgcnt(&tunnel_hdr, msgcount); 1692 msg_set_msgcnt(&tunnel_hdr, msgcount);
@@ -1748,7 +1744,7 @@ void tipc_link_dup_queue_xmit(struct tipc_link *l_ptr,
1748 struct sk_buff *skb; 1744 struct sk_buff *skb;
1749 struct tipc_msg tunnel_hdr; 1745 struct tipc_msg tunnel_hdr;
1750 1746
1751 tipc_msg_init(l_ptr->owner->net, &tunnel_hdr, CHANGEOVER_PROTOCOL, 1747 tipc_msg_init(link_own_addr(l_ptr), &tunnel_hdr, CHANGEOVER_PROTOCOL,
1752 DUPLICATE_MSG, INT_H_SIZE, l_ptr->addr); 1748 DUPLICATE_MSG, INT_H_SIZE, l_ptr->addr);
1753 msg_set_msgcnt(&tunnel_hdr, skb_queue_len(&l_ptr->outqueue)); 1749 msg_set_msgcnt(&tunnel_hdr, skb_queue_len(&l_ptr->outqueue));
1754 msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); 1750 msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id);
@@ -1802,7 +1798,7 @@ static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos)
1802/* tipc_link_dup_rcv(): Receive a tunnelled DUPLICATE_MSG packet. 1798/* tipc_link_dup_rcv(): Receive a tunnelled DUPLICATE_MSG packet.
1803 * Owner node is locked. 1799 * Owner node is locked.
1804 */ 1800 */
1805static void tipc_link_dup_rcv(struct net *net, struct tipc_link *l_ptr, 1801static void tipc_link_dup_rcv(struct tipc_link *l_ptr,
1806 struct sk_buff *t_buf) 1802 struct sk_buff *t_buf)
1807{ 1803{
1808 struct sk_buff *buf; 1804 struct sk_buff *buf;
@@ -1817,7 +1813,7 @@ static void tipc_link_dup_rcv(struct net *net, struct tipc_link *l_ptr,
1817 } 1813 }
1818 1814
1819 /* Add buffer to deferred queue, if applicable: */ 1815 /* Add buffer to deferred queue, if applicable: */
1820 link_handle_out_of_seq_msg(net, l_ptr, buf); 1816 link_handle_out_of_seq_msg(l_ptr, buf);
1821} 1817}
1822 1818
1823/* tipc_link_failover_rcv(): Receive a tunnelled ORIGINAL_MSG packet 1819/* tipc_link_failover_rcv(): Receive a tunnelled ORIGINAL_MSG packet
@@ -1869,7 +1865,7 @@ exit:
1869 * returned to the active link for delivery upwards. 1865 * returned to the active link for delivery upwards.
1870 * Owner node is locked. 1866 * Owner node is locked.
1871 */ 1867 */
1872static int tipc_link_tunnel_rcv(struct net *net, struct tipc_node *n_ptr, 1868static int tipc_link_tunnel_rcv(struct tipc_node *n_ptr,
1873 struct sk_buff **buf) 1869 struct sk_buff **buf)
1874{ 1870{
1875 struct sk_buff *t_buf = *buf; 1871 struct sk_buff *t_buf = *buf;
@@ -1887,7 +1883,7 @@ static int tipc_link_tunnel_rcv(struct net *net, struct tipc_node *n_ptr,
1887 goto exit; 1883 goto exit;
1888 1884
1889 if (msg_type(t_msg) == DUPLICATE_MSG) 1885 if (msg_type(t_msg) == DUPLICATE_MSG)
1890 tipc_link_dup_rcv(net, l_ptr, t_buf); 1886 tipc_link_dup_rcv(l_ptr, t_buf);
1891 else if (msg_type(t_msg) == ORIGINAL_MSG) 1887 else if (msg_type(t_msg) == ORIGINAL_MSG)
1892 *buf = tipc_link_failover_rcv(l_ptr, t_buf); 1888 *buf = tipc_link_failover_rcv(l_ptr, t_buf);
1893 else 1889 else