aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorJon Paul Maloy <jon.maloy@ericsson.com>2015-02-05 08:36:36 -0500
committerDavid S. Miller <davem@davemloft.net>2015-02-05 19:00:01 -0500
commitc5898636c440da91d58f10beac00f073e68378df (patch)
tree67e7148b03414171b1d2012bd8f27ea63433c3ed /net/tipc
parent4134069f3ea6cd96903e426bd3dfb9bb44165357 (diff)
tipc: reduce usage of context info in socket and link
The most common usage of namespace information is when we fetch the own node addess from the net structure. This leads to a lot of passing around of a parameter of type 'struct net *' between functions just to make them able to obtain this address. However, in many cases this is unnecessary. The own node address is readily available as a member of both struct tipc_sock and tipc_link, and can be fetched from there instead. The fact that the vast majority of functions in socket.c and link.c anyway are maintaining a pointer to their respective base structures makes this option even more compelling. In this commit, we introduce the inline functions tsk_own_node() and link_own_node() to make it easy for functions to fetch the node address from those structs instead of having to pass along and dereference the namespace struct. In particular, we make calls to the msg_xx() functions in msg.{h,c} context independent by directly passing them the own node address as parameter when needed. Those functions should be regarded as leaves in the code dependency tree, and it is hence desirable to keep them namspace unaware. Apart from a potential positive effect on cache behavior, these changes make it easier to introduce the changes that will follow later in this series. Reviewed-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/bcast.c7
-rw-r--r--net/tipc/bcast.h2
-rw-r--r--net/tipc/discover.c3
-rw-r--r--net/tipc/link.c56
-rw-r--r--net/tipc/link.h4
-rw-r--r--net/tipc/msg.c33
-rw-r--r--net/tipc/msg.h10
-rw-r--r--net/tipc/name_distr.c5
-rw-r--r--net/tipc/node.c2
-rw-r--r--net/tipc/socket.c67
10 files changed, 98 insertions, 91 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 53f8bf059fec..3b886eb35c87 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -283,10 +283,11 @@ exit:
283 * 283 *
284 * RCU and node lock set 284 * RCU and node lock set
285 */ 285 */
286void tipc_bclink_update_link_state(struct net *net, struct tipc_node *n_ptr, 286void tipc_bclink_update_link_state(struct tipc_node *n_ptr,
287 u32 last_sent) 287 u32 last_sent)
288{ 288{
289 struct sk_buff *buf; 289 struct sk_buff *buf;
290 struct net *net = n_ptr->net;
290 struct tipc_net *tn = net_generic(net, tipc_net_id); 291 struct tipc_net *tn = net_generic(net, tipc_net_id);
291 292
292 /* Ignore "stale" link state info */ 293 /* Ignore "stale" link state info */
@@ -317,7 +318,7 @@ void tipc_bclink_update_link_state(struct net *net, struct tipc_node *n_ptr,
317 struct sk_buff *skb = skb_peek(&n_ptr->bclink.deferred_queue); 318 struct sk_buff *skb = skb_peek(&n_ptr->bclink.deferred_queue);
318 u32 to = skb ? buf_seqno(skb) - 1 : n_ptr->bclink.last_sent; 319 u32 to = skb ? buf_seqno(skb) - 1 : n_ptr->bclink.last_sent;
319 320
320 tipc_msg_init(net, msg, BCAST_PROTOCOL, STATE_MSG, 321 tipc_msg_init(tn->own_addr, msg, BCAST_PROTOCOL, STATE_MSG,
321 INT_H_SIZE, n_ptr->addr); 322 INT_H_SIZE, n_ptr->addr);
322 msg_set_non_seq(msg, 1); 323 msg_set_non_seq(msg, 1);
323 msg_set_mc_netid(msg, tn->net_id); 324 msg_set_mc_netid(msg, tn->net_id);
@@ -954,6 +955,8 @@ int tipc_bclink_init(struct net *net)
954 bcl->bearer_id = MAX_BEARERS; 955 bcl->bearer_id = MAX_BEARERS;
955 rcu_assign_pointer(tn->bearer_list[MAX_BEARERS], &bcbearer->bearer); 956 rcu_assign_pointer(tn->bearer_list[MAX_BEARERS], &bcbearer->bearer);
956 bcl->state = WORKING_WORKING; 957 bcl->state = WORKING_WORKING;
958 bcl->pmsg = (struct tipc_msg *)&bcl->proto_msg;
959 msg_set_prevnode(bcl->pmsg, tn->own_addr);
957 strlcpy(bcl->name, tipc_bclink_name, TIPC_MAX_LINK_NAME); 960 strlcpy(bcl->name, tipc_bclink_name, TIPC_MAX_LINK_NAME);
958 tn->bcbearer = bcbearer; 961 tn->bcbearer = bcbearer;
959 tn->bclink = bclink; 962 tn->bclink = bclink;
diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h
index a4583a109486..6ea190dccfe1 100644
--- a/net/tipc/bcast.h
+++ b/net/tipc/bcast.h
@@ -139,7 +139,7 @@ void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked);
139void tipc_bclink_rcv(struct net *net, struct sk_buff *buf); 139void tipc_bclink_rcv(struct net *net, struct sk_buff *buf);
140u32 tipc_bclink_get_last_sent(struct net *net); 140u32 tipc_bclink_get_last_sent(struct net *net);
141u32 tipc_bclink_acks_missing(struct tipc_node *n_ptr); 141u32 tipc_bclink_acks_missing(struct tipc_node *n_ptr);
142void tipc_bclink_update_link_state(struct net *net, struct tipc_node *n_ptr, 142void tipc_bclink_update_link_state(struct tipc_node *node,
143 u32 last_sent); 143 u32 last_sent);
144int tipc_bclink_stats(struct net *net, char *stats_buf, const u32 buf_size); 144int tipc_bclink_stats(struct net *net, char *stats_buf, const u32 buf_size);
145int tipc_bclink_reset_stats(struct net *net); 145int tipc_bclink_reset_stats(struct net *net);
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index a580a40d0208..feef3753615d 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -85,7 +85,8 @@ static void tipc_disc_init_msg(struct net *net, struct sk_buff *buf, u32 type,
85 u32 dest_domain = b_ptr->domain; 85 u32 dest_domain = b_ptr->domain;
86 86
87 msg = buf_msg(buf); 87 msg = buf_msg(buf);
88 tipc_msg_init(net, msg, LINK_CONFIG, type, INT_H_SIZE, dest_domain); 88 tipc_msg_init(tn->own_addr, msg, LINK_CONFIG, type,
89 INT_H_SIZE, dest_domain);
89 msg_set_non_seq(msg, 1); 90 msg_set_non_seq(msg, 1);
90 msg_set_node_sig(msg, tn->random); 91 msg_set_node_sig(msg, tn->random);
91 msg_set_dest_domain(msg, dest_domain); 92 msg_set_dest_domain(msg, dest_domain);
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
diff --git a/net/tipc/link.h b/net/tipc/link.h
index 3e3432b3044e..5b9a17f26280 100644
--- a/net/tipc/link.h
+++ b/net/tipc/link.h
@@ -278,6 +278,10 @@ static inline u32 lesser(u32 left, u32 right)
278 return less_eq(left, right) ? left : right; 278 return less_eq(left, right) ? left : right;
279} 279}
280 280
281static inline u32 link_own_addr(struct tipc_link *l)
282{
283 return msg_prevnode(l->pmsg);
284}
281 285
282/* 286/*
283 * Link status checking routines 287 * Link status checking routines
diff --git a/net/tipc/msg.c b/net/tipc/msg.c
index da67c8d3edc6..940d74197b8c 100644
--- a/net/tipc/msg.c
+++ b/net/tipc/msg.c
@@ -70,25 +70,23 @@ struct sk_buff *tipc_buf_acquire(u32 size)
70 return skb; 70 return skb;
71} 71}
72 72
73void tipc_msg_init(struct net *net, struct tipc_msg *m, u32 user, u32 type, 73void tipc_msg_init(u32 own_node, struct tipc_msg *m, u32 user, u32 type,
74 u32 hsize, u32 destnode) 74 u32 hsize, u32 dnode)
75{ 75{
76 struct tipc_net *tn = net_generic(net, tipc_net_id);
77
78 memset(m, 0, hsize); 76 memset(m, 0, hsize);
79 msg_set_version(m); 77 msg_set_version(m);
80 msg_set_user(m, user); 78 msg_set_user(m, user);
81 msg_set_hdr_sz(m, hsize); 79 msg_set_hdr_sz(m, hsize);
82 msg_set_size(m, hsize); 80 msg_set_size(m, hsize);
83 msg_set_prevnode(m, tn->own_addr); 81 msg_set_prevnode(m, own_node);
84 msg_set_type(m, type); 82 msg_set_type(m, type);
85 if (hsize > SHORT_H_SIZE) { 83 if (hsize > SHORT_H_SIZE) {
86 msg_set_orignode(m, tn->own_addr); 84 msg_set_orignode(m, own_node);
87 msg_set_destnode(m, destnode); 85 msg_set_destnode(m, dnode);
88 } 86 }
89} 87}
90 88
91struct sk_buff *tipc_msg_create(struct net *net, uint user, uint type, 89struct sk_buff *tipc_msg_create(uint user, uint type,
92 uint hdr_sz, uint data_sz, u32 dnode, 90 uint hdr_sz, uint data_sz, u32 dnode,
93 u32 onode, u32 dport, u32 oport, int errcode) 91 u32 onode, u32 dport, u32 oport, int errcode)
94{ 92{
@@ -100,9 +98,8 @@ struct sk_buff *tipc_msg_create(struct net *net, uint user, uint type,
100 return NULL; 98 return NULL;
101 99
102 msg = buf_msg(buf); 100 msg = buf_msg(buf);
103 tipc_msg_init(net, msg, user, type, hdr_sz, dnode); 101 tipc_msg_init(onode, msg, user, type, hdr_sz, dnode);
104 msg_set_size(msg, hdr_sz + data_sz); 102 msg_set_size(msg, hdr_sz + data_sz);
105 msg_set_prevnode(msg, onode);
106 msg_set_origport(msg, oport); 103 msg_set_origport(msg, oport);
107 msg_set_destport(msg, dport); 104 msg_set_destport(msg, dport);
108 msg_set_errcode(msg, errcode); 105 msg_set_errcode(msg, errcode);
@@ -195,7 +192,7 @@ err:
195 * 192 *
196 * Returns message data size or errno: -ENOMEM, -EFAULT 193 * Returns message data size or errno: -ENOMEM, -EFAULT
197 */ 194 */
198int tipc_msg_build(struct net *net, struct tipc_msg *mhdr, struct msghdr *m, 195int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m,
199 int offset, int dsz, int pktmax, struct sk_buff_head *list) 196 int offset, int dsz, int pktmax, struct sk_buff_head *list)
200{ 197{
201 int mhsz = msg_hdr_sz(mhdr); 198 int mhsz = msg_hdr_sz(mhdr);
@@ -227,8 +224,8 @@ int tipc_msg_build(struct net *net, struct tipc_msg *mhdr, struct msghdr *m,
227 } 224 }
228 225
229 /* Prepare reusable fragment header */ 226 /* Prepare reusable fragment header */
230 tipc_msg_init(net, &pkthdr, MSG_FRAGMENTER, FIRST_FRAGMENT, INT_H_SIZE, 227 tipc_msg_init(msg_prevnode(mhdr), &pkthdr, MSG_FRAGMENTER,
231 msg_destnode(mhdr)); 228 FIRST_FRAGMENT, INT_H_SIZE, msg_destnode(mhdr));
232 msg_set_size(&pkthdr, pktmax); 229 msg_set_size(&pkthdr, pktmax);
233 msg_set_fragm_no(&pkthdr, pktno); 230 msg_set_fragm_no(&pkthdr, pktno);
234 231
@@ -338,7 +335,7 @@ bool tipc_msg_bundle(struct sk_buff_head *list, struct sk_buff *skb, u32 mtu)
338 * Replaces buffer if successful 335 * Replaces buffer if successful
339 * Returns true if success, otherwise false 336 * Returns true if success, otherwise false
340 */ 337 */
341bool tipc_msg_make_bundle(struct net *net, struct sk_buff_head *list, 338bool tipc_msg_make_bundle(struct sk_buff_head *list,
342 struct sk_buff *skb, u32 mtu, u32 dnode) 339 struct sk_buff *skb, u32 mtu, u32 dnode)
343{ 340{
344 struct sk_buff *bskb; 341 struct sk_buff *bskb;
@@ -362,7 +359,8 @@ bool tipc_msg_make_bundle(struct net *net, struct sk_buff_head *list,
362 359
363 skb_trim(bskb, INT_H_SIZE); 360 skb_trim(bskb, INT_H_SIZE);
364 bmsg = buf_msg(bskb); 361 bmsg = buf_msg(bskb);
365 tipc_msg_init(net, bmsg, MSG_BUNDLER, 0, INT_H_SIZE, dnode); 362 tipc_msg_init(msg_prevnode(msg), bmsg, MSG_BUNDLER, 0,
363 INT_H_SIZE, dnode);
366 msg_set_seqno(bmsg, msg_seqno(msg)); 364 msg_set_seqno(bmsg, msg_seqno(msg));
367 msg_set_ack(bmsg, msg_ack(msg)); 365 msg_set_ack(bmsg, msg_ack(msg));
368 msg_set_bcast_ack(bmsg, msg_bcast_ack(msg)); 366 msg_set_bcast_ack(bmsg, msg_bcast_ack(msg));
@@ -379,10 +377,9 @@ bool tipc_msg_make_bundle(struct net *net, struct sk_buff_head *list,
379 * Consumes buffer if failure 377 * Consumes buffer if failure
380 * Returns true if success, otherwise false 378 * Returns true if success, otherwise false
381 */ 379 */
382bool tipc_msg_reverse(struct net *net, struct sk_buff *buf, u32 *dnode, 380bool tipc_msg_reverse(u32 own_addr, struct sk_buff *buf, u32 *dnode,
383 int err) 381 int err)
384{ 382{
385 struct tipc_net *tn = net_generic(net, tipc_net_id);
386 struct tipc_msg *msg = buf_msg(buf); 383 struct tipc_msg *msg = buf_msg(buf);
387 uint imp = msg_importance(msg); 384 uint imp = msg_importance(msg);
388 struct tipc_msg ohdr; 385 struct tipc_msg ohdr;
@@ -402,7 +399,7 @@ bool tipc_msg_reverse(struct net *net, struct sk_buff *buf, u32 *dnode,
402 msg_set_errcode(msg, err); 399 msg_set_errcode(msg, err);
403 msg_set_origport(msg, msg_destport(&ohdr)); 400 msg_set_origport(msg, msg_destport(&ohdr));
404 msg_set_destport(msg, msg_origport(&ohdr)); 401 msg_set_destport(msg, msg_origport(&ohdr));
405 msg_set_prevnode(msg, tn->own_addr); 402 msg_set_prevnode(msg, own_addr);
406 if (!msg_short(msg)) { 403 if (!msg_short(msg)) {
407 msg_set_orignode(msg, msg_destnode(&ohdr)); 404 msg_set_orignode(msg, msg_destnode(&ohdr));
408 msg_set_destnode(msg, msg_orignode(&ohdr)); 405 msg_set_destnode(msg, msg_orignode(&ohdr));
diff --git a/net/tipc/msg.h b/net/tipc/msg.h
index 526ef345b70e..f7ea95458c6f 100644
--- a/net/tipc/msg.h
+++ b/net/tipc/msg.h
@@ -748,19 +748,19 @@ static inline u32 msg_tot_origport(struct tipc_msg *m)
748} 748}
749 749
750struct sk_buff *tipc_buf_acquire(u32 size); 750struct sk_buff *tipc_buf_acquire(u32 size);
751bool tipc_msg_reverse(struct net *net, struct sk_buff *buf, u32 *dnode, 751bool tipc_msg_reverse(u32 own_addr, struct sk_buff *buf, u32 *dnode,
752 int err); 752 int err);
753int tipc_msg_eval(struct net *net, struct sk_buff *buf, u32 *dnode); 753int tipc_msg_eval(struct net *net, struct sk_buff *buf, u32 *dnode);
754void tipc_msg_init(struct net *net, struct tipc_msg *m, u32 user, u32 type, 754void tipc_msg_init(u32 own_addr, struct tipc_msg *m, u32 user, u32 type,
755 u32 hsize, u32 destnode); 755 u32 hsize, u32 destnode);
756struct sk_buff *tipc_msg_create(struct net *net, uint user, uint type, 756struct sk_buff *tipc_msg_create(uint user, uint type,
757 uint hdr_sz, uint data_sz, u32 dnode, 757 uint hdr_sz, uint data_sz, u32 dnode,
758 u32 onode, u32 dport, u32 oport, int errcode); 758 u32 onode, u32 dport, u32 oport, int errcode);
759int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf); 759int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf);
760bool tipc_msg_bundle(struct sk_buff_head *list, struct sk_buff *skb, u32 mtu); 760bool tipc_msg_bundle(struct sk_buff_head *list, struct sk_buff *skb, u32 mtu);
761bool tipc_msg_make_bundle(struct net *net, struct sk_buff_head *list, 761bool tipc_msg_make_bundle(struct sk_buff_head *list,
762 struct sk_buff *skb, u32 mtu, u32 dnode); 762 struct sk_buff *skb, u32 mtu, u32 dnode);
763int tipc_msg_build(struct net *net, struct tipc_msg *mhdr, struct msghdr *m, 763int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m,
764 int offset, int dsz, int mtu, struct sk_buff_head *list); 764 int offset, int dsz, int mtu, struct sk_buff_head *list);
765struct sk_buff *tipc_msg_reassemble(struct sk_buff_head *list); 765struct sk_buff *tipc_msg_reassemble(struct sk_buff_head *list);
766 766
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index 7f31cd4badc4..dd8564cd9dbb 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -71,13 +71,14 @@ static void publ_to_item(struct distr_item *i, struct publication *p)
71static struct sk_buff *named_prepare_buf(struct net *net, u32 type, u32 size, 71static struct sk_buff *named_prepare_buf(struct net *net, u32 type, u32 size,
72 u32 dest) 72 u32 dest)
73{ 73{
74 struct tipc_net *tn = net_generic(net, tipc_net_id);
74 struct sk_buff *buf = tipc_buf_acquire(INT_H_SIZE + size); 75 struct sk_buff *buf = tipc_buf_acquire(INT_H_SIZE + size);
75 struct tipc_msg *msg; 76 struct tipc_msg *msg;
76 77
77 if (buf != NULL) { 78 if (buf != NULL) {
78 msg = buf_msg(buf); 79 msg = buf_msg(buf);
79 tipc_msg_init(net, msg, NAME_DISTRIBUTOR, type, INT_H_SIZE, 80 tipc_msg_init(tn->own_addr, msg, NAME_DISTRIBUTOR, type,
80 dest); 81 INT_H_SIZE, dest);
81 msg_set_size(msg, INT_H_SIZE + size); 82 msg_set_size(msg, INT_H_SIZE + size);
82 } 83 }
83 return buf; 84 return buf;
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 842bd7ad4b17..1c409c45f0fe 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -204,7 +204,7 @@ void tipc_node_abort_sock_conns(struct net *net, struct list_head *conns)
204 struct sk_buff *buf; 204 struct sk_buff *buf;
205 205
206 list_for_each_entry_safe(conn, safe, conns, list) { 206 list_for_each_entry_safe(conn, safe, conns, list) {
207 buf = tipc_msg_create(net, TIPC_CRITICAL_IMPORTANCE, 207 buf = tipc_msg_create(TIPC_CRITICAL_IMPORTANCE,
208 TIPC_CONN_MSG, SHORT_H_SIZE, 0, 208 TIPC_CONN_MSG, SHORT_H_SIZE, 0,
209 tn->own_addr, conn->peer_node, 209 tn->own_addr, conn->peer_node,
210 conn->port, conn->peer_port, 210 conn->port, conn->peer_port,
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index caa4d663fd90..b384e658dfeb 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -177,6 +177,11 @@ static const struct nla_policy tipc_nl_sock_policy[TIPC_NLA_SOCK_MAX + 1] = {
177 * - port reference 177 * - port reference
178 */ 178 */
179 179
180static u32 tsk_own_node(struct tipc_sock *tsk)
181{
182 return msg_prevnode(&tsk->phdr);
183}
184
180static u32 tsk_peer_node(struct tipc_sock *tsk) 185static u32 tsk_peer_node(struct tipc_sock *tsk)
181{ 186{
182 return msg_destnode(&tsk->phdr); 187 return msg_destnode(&tsk->phdr);
@@ -249,11 +254,11 @@ static void tsk_rej_rx_queue(struct sock *sk)
249{ 254{
250 struct sk_buff *skb; 255 struct sk_buff *skb;
251 u32 dnode; 256 u32 dnode;
252 struct net *net = sock_net(sk); 257 u32 own_node = tsk_own_node(tipc_sk(sk));
253 258
254 while ((skb = __skb_dequeue(&sk->sk_receive_queue))) { 259 while ((skb = __skb_dequeue(&sk->sk_receive_queue))) {
255 if (tipc_msg_reverse(net, skb, &dnode, TIPC_ERR_NO_PORT)) 260 if (tipc_msg_reverse(own_node, skb, &dnode, TIPC_ERR_NO_PORT))
256 tipc_link_xmit_skb(net, skb, dnode, 0); 261 tipc_link_xmit_skb(sock_net(sk), skb, dnode, 0);
257 } 262 }
258} 263}
259 264
@@ -305,6 +310,7 @@ static bool tsk_peer_msg(struct tipc_sock *tsk, struct tipc_msg *msg)
305static int tipc_sk_create(struct net *net, struct socket *sock, 310static int tipc_sk_create(struct net *net, struct socket *sock,
306 int protocol, int kern) 311 int protocol, int kern)
307{ 312{
313 struct tipc_net *tn;
308 const struct proto_ops *ops; 314 const struct proto_ops *ops;
309 socket_state state; 315 socket_state state;
310 struct sock *sk; 316 struct sock *sk;
@@ -346,7 +352,8 @@ static int tipc_sk_create(struct net *net, struct socket *sock,
346 tsk->max_pkt = MAX_PKT_DEFAULT; 352 tsk->max_pkt = MAX_PKT_DEFAULT;
347 INIT_LIST_HEAD(&tsk->publications); 353 INIT_LIST_HEAD(&tsk->publications);
348 msg = &tsk->phdr; 354 msg = &tsk->phdr;
349 tipc_msg_init(net, msg, TIPC_LOW_IMPORTANCE, TIPC_NAMED_MSG, 355 tn = net_generic(sock_net(sk), tipc_net_id);
356 tipc_msg_init(tn->own_addr, msg, TIPC_LOW_IMPORTANCE, TIPC_NAMED_MSG,
350 NAMED_H_SIZE, 0); 357 NAMED_H_SIZE, 0);
351 358
352 /* Finish initializing socket data structures */ 359 /* Finish initializing socket data structures */
@@ -471,7 +478,6 @@ static int tipc_release(struct socket *sock)
471{ 478{
472 struct sock *sk = sock->sk; 479 struct sock *sk = sock->sk;
473 struct net *net; 480 struct net *net;
474 struct tipc_net *tn;
475 struct tipc_sock *tsk; 481 struct tipc_sock *tsk;
476 struct sk_buff *skb; 482 struct sk_buff *skb;
477 u32 dnode, probing_state; 483 u32 dnode, probing_state;
@@ -484,8 +490,6 @@ static int tipc_release(struct socket *sock)
484 return 0; 490 return 0;
485 491
486 net = sock_net(sk); 492 net = sock_net(sk);
487 tn = net_generic(net, tipc_net_id);
488
489 tsk = tipc_sk(sk); 493 tsk = tipc_sk(sk);
490 lock_sock(sk); 494 lock_sock(sk);
491 495
@@ -507,7 +511,7 @@ static int tipc_release(struct socket *sock)
507 tsk->connected = 0; 511 tsk->connected = 0;
508 tipc_node_remove_conn(net, dnode, tsk->portid); 512 tipc_node_remove_conn(net, dnode, tsk->portid);
509 } 513 }
510 if (tipc_msg_reverse(net, skb, &dnode, 514 if (tipc_msg_reverse(tsk_own_node(tsk), skb, &dnode,
511 TIPC_ERR_NO_PORT)) 515 TIPC_ERR_NO_PORT))
512 tipc_link_xmit_skb(net, skb, dnode, 0); 516 tipc_link_xmit_skb(net, skb, dnode, 0);
513 } 517 }
@@ -520,9 +524,9 @@ static int tipc_release(struct socket *sock)
520 sock_put(sk); 524 sock_put(sk);
521 tipc_sk_remove(tsk); 525 tipc_sk_remove(tsk);
522 if (tsk->connected) { 526 if (tsk->connected) {
523 skb = tipc_msg_create(net, TIPC_CRITICAL_IMPORTANCE, 527 skb = tipc_msg_create(TIPC_CRITICAL_IMPORTANCE,
524 TIPC_CONN_MSG, SHORT_H_SIZE, 0, dnode, 528 TIPC_CONN_MSG, SHORT_H_SIZE, 0, dnode,
525 tn->own_addr, tsk_peer_port(tsk), 529 tsk_own_node(tsk), tsk_peer_port(tsk),
526 tsk->portid, TIPC_ERR_NO_PORT); 530 tsk->portid, TIPC_ERR_NO_PORT);
527 if (skb) 531 if (skb)
528 tipc_link_xmit_skb(net, skb, dnode, tsk->portid); 532 tipc_link_xmit_skb(net, skb, dnode, tsk->portid);
@@ -730,8 +734,9 @@ static int tipc_sendmcast(struct socket *sock, struct tipc_name_seq *seq,
730 struct msghdr *msg, size_t dsz, long timeo) 734 struct msghdr *msg, size_t dsz, long timeo)
731{ 735{
732 struct sock *sk = sock->sk; 736 struct sock *sk = sock->sk;
737 struct tipc_sock *tsk = tipc_sk(sk);
733 struct net *net = sock_net(sk); 738 struct net *net = sock_net(sk);
734 struct tipc_msg *mhdr = &tipc_sk(sk)->phdr; 739 struct tipc_msg *mhdr = &tsk->phdr;
735 struct sk_buff_head head; 740 struct sk_buff_head head;
736 struct iov_iter save = msg->msg_iter; 741 struct iov_iter save = msg->msg_iter;
737 uint mtu; 742 uint mtu;
@@ -749,7 +754,7 @@ static int tipc_sendmcast(struct socket *sock, struct tipc_name_seq *seq,
749new_mtu: 754new_mtu:
750 mtu = tipc_bclink_get_mtu(); 755 mtu = tipc_bclink_get_mtu();
751 __skb_queue_head_init(&head); 756 __skb_queue_head_init(&head);
752 rc = tipc_msg_build(net, mhdr, msg, 0, dsz, mtu, &head); 757 rc = tipc_msg_build(mhdr, msg, 0, dsz, mtu, &head);
753 if (unlikely(rc < 0)) 758 if (unlikely(rc < 0))
754 return rc; 759 return rc;
755 760
@@ -836,7 +841,7 @@ static int tipc_sk_proto_rcv(struct tipc_sock *tsk, u32 *dnode,
836 if (conn_cong) 841 if (conn_cong)
837 tsk->sk.sk_write_space(&tsk->sk); 842 tsk->sk.sk_write_space(&tsk->sk);
838 } else if (msg_type(msg) == CONN_PROBE) { 843 } else if (msg_type(msg) == CONN_PROBE) {
839 if (!tipc_msg_reverse(sock_net(&tsk->sk), buf, dnode, TIPC_OK)) 844 if (!tipc_msg_reverse(tsk_own_node(tsk), buf, dnode, TIPC_OK))
840 return TIPC_OK; 845 return TIPC_OK;
841 msg_set_type(msg, CONN_PROBE_REPLY); 846 msg_set_type(msg, CONN_PROBE_REPLY);
842 return TIPC_FWD_MSG; 847 return TIPC_FWD_MSG;
@@ -971,7 +976,7 @@ static int tipc_sendmsg(struct kiocb *iocb, struct socket *sock,
971new_mtu: 976new_mtu:
972 mtu = tipc_node_get_mtu(net, dnode, tsk->portid); 977 mtu = tipc_node_get_mtu(net, dnode, tsk->portid);
973 __skb_queue_head_init(&head); 978 __skb_queue_head_init(&head);
974 rc = tipc_msg_build(net, mhdr, m, 0, dsz, mtu, &head); 979 rc = tipc_msg_build(mhdr, m, 0, dsz, mtu, &head);
975 if (rc < 0) 980 if (rc < 0)
976 goto exit; 981 goto exit;
977 982
@@ -1090,7 +1095,7 @@ next:
1090 mtu = tsk->max_pkt; 1095 mtu = tsk->max_pkt;
1091 send = min_t(uint, dsz - sent, TIPC_MAX_USER_MSG_SIZE); 1096 send = min_t(uint, dsz - sent, TIPC_MAX_USER_MSG_SIZE);
1092 __skb_queue_head_init(&head); 1097 __skb_queue_head_init(&head);
1093 rc = tipc_msg_build(net, mhdr, m, sent, send, mtu, &head); 1098 rc = tipc_msg_build(mhdr, m, sent, send, mtu, &head);
1094 if (unlikely(rc < 0)) 1099 if (unlikely(rc < 0))
1095 goto exit; 1100 goto exit;
1096 do { 1101 do {
@@ -1263,7 +1268,6 @@ static int tipc_sk_anc_data_recv(struct msghdr *m, struct tipc_msg *msg,
1263static void tipc_sk_send_ack(struct tipc_sock *tsk, uint ack) 1268static void tipc_sk_send_ack(struct tipc_sock *tsk, uint ack)
1264{ 1269{
1265 struct net *net = sock_net(&tsk->sk); 1270 struct net *net = sock_net(&tsk->sk);
1266 struct tipc_net *tn = net_generic(net, tipc_net_id);
1267 struct sk_buff *skb = NULL; 1271 struct sk_buff *skb = NULL;
1268 struct tipc_msg *msg; 1272 struct tipc_msg *msg;
1269 u32 peer_port = tsk_peer_port(tsk); 1273 u32 peer_port = tsk_peer_port(tsk);
@@ -1271,9 +1275,9 @@ static void tipc_sk_send_ack(struct tipc_sock *tsk, uint ack)
1271 1275
1272 if (!tsk->connected) 1276 if (!tsk->connected)
1273 return; 1277 return;
1274 skb = tipc_msg_create(net, CONN_MANAGER, CONN_ACK, INT_H_SIZE, 0, 1278 skb = tipc_msg_create(CONN_MANAGER, CONN_ACK, INT_H_SIZE, 0,
1275 dnode, tn->own_addr, peer_port, tsk->portid, 1279 dnode, tsk_own_node(tsk), peer_port,
1276 TIPC_OK); 1280 tsk->portid, TIPC_OK);
1277 if (!skb) 1281 if (!skb)
1278 return; 1282 return;
1279 msg = buf_msg(skb); 1283 msg = buf_msg(skb);
@@ -1756,7 +1760,7 @@ static int tipc_backlog_rcv(struct sock *sk, struct sk_buff *skb)
1756 return 0; 1760 return 0;
1757 } 1761 }
1758 1762
1759 if ((rc < 0) && !tipc_msg_reverse(net, skb, &onode, -rc)) 1763 if ((rc < 0) && !tipc_msg_reverse(tsk_own_node(tsk), skb, &onode, -rc))
1760 return 0; 1764 return 0;
1761 1765
1762 tipc_link_xmit_skb(net, skb, onode, 0); 1766 tipc_link_xmit_skb(net, skb, onode, 0);
@@ -1773,6 +1777,7 @@ static int tipc_backlog_rcv(struct sock *sk, struct sk_buff *skb)
1773int tipc_sk_rcv(struct net *net, struct sk_buff *skb) 1777int tipc_sk_rcv(struct net *net, struct sk_buff *skb)
1774{ 1778{
1775 struct tipc_sock *tsk; 1779 struct tipc_sock *tsk;
1780 struct tipc_net *tn;
1776 struct sock *sk; 1781 struct sock *sk;
1777 u32 dport = msg_destport(buf_msg(skb)); 1782 u32 dport = msg_destport(buf_msg(skb));
1778 int rc = TIPC_OK; 1783 int rc = TIPC_OK;
@@ -1804,7 +1809,8 @@ int tipc_sk_rcv(struct net *net, struct sk_buff *skb)
1804 if (likely(!rc)) 1809 if (likely(!rc))
1805 return 0; 1810 return 0;
1806exit: 1811exit:
1807 if ((rc < 0) && !tipc_msg_reverse(net, skb, &dnode, -rc)) 1812 tn = net_generic(net, tipc_net_id);
1813 if ((rc < 0) && !tipc_msg_reverse(tn->own_addr, skb, &dnode, -rc))
1808 return -EHOSTUNREACH; 1814 return -EHOSTUNREACH;
1809 1815
1810 tipc_link_xmit_skb(net, skb, dnode, 0); 1816 tipc_link_xmit_skb(net, skb, dnode, 0);
@@ -2065,7 +2071,6 @@ static int tipc_shutdown(struct socket *sock, int how)
2065{ 2071{
2066 struct sock *sk = sock->sk; 2072 struct sock *sk = sock->sk;
2067 struct net *net = sock_net(sk); 2073 struct net *net = sock_net(sk);
2068 struct tipc_net *tn = net_generic(net, tipc_net_id);
2069 struct tipc_sock *tsk = tipc_sk(sk); 2074 struct tipc_sock *tsk = tipc_sk(sk);
2070 struct sk_buff *skb; 2075 struct sk_buff *skb;
2071 u32 dnode; 2076 u32 dnode;
@@ -2088,16 +2093,17 @@ restart:
2088 kfree_skb(skb); 2093 kfree_skb(skb);
2089 goto restart; 2094 goto restart;
2090 } 2095 }
2091 if (tipc_msg_reverse(net, skb, &dnode, 2096 if (tipc_msg_reverse(tsk_own_node(tsk), skb, &dnode,
2092 TIPC_CONN_SHUTDOWN)) 2097 TIPC_CONN_SHUTDOWN))
2093 tipc_link_xmit_skb(net, skb, dnode, 2098 tipc_link_xmit_skb(net, skb, dnode,
2094 tsk->portid); 2099 tsk->portid);
2095 tipc_node_remove_conn(net, dnode, tsk->portid); 2100 tipc_node_remove_conn(net, dnode, tsk->portid);
2096 } else { 2101 } else {
2097 dnode = tsk_peer_node(tsk); 2102 dnode = tsk_peer_node(tsk);
2098 skb = tipc_msg_create(net, TIPC_CRITICAL_IMPORTANCE, 2103
2104 skb = tipc_msg_create(TIPC_CRITICAL_IMPORTANCE,
2099 TIPC_CONN_MSG, SHORT_H_SIZE, 2105 TIPC_CONN_MSG, SHORT_H_SIZE,
2100 0, dnode, tn->own_addr, 2106 0, dnode, tsk_own_node(tsk),
2101 tsk_peer_port(tsk), 2107 tsk_peer_port(tsk),
2102 tsk->portid, TIPC_CONN_SHUTDOWN); 2108 tsk->portid, TIPC_CONN_SHUTDOWN);
2103 tipc_link_xmit_skb(net, skb, dnode, tsk->portid); 2109 tipc_link_xmit_skb(net, skb, dnode, tsk->portid);
@@ -2129,10 +2135,9 @@ static void tipc_sk_timeout(unsigned long data)
2129{ 2135{
2130 struct tipc_sock *tsk = (struct tipc_sock *)data; 2136 struct tipc_sock *tsk = (struct tipc_sock *)data;
2131 struct sock *sk = &tsk->sk; 2137 struct sock *sk = &tsk->sk;
2132 struct net *net = sock_net(sk);
2133 struct tipc_net *tn = net_generic(net, tipc_net_id);
2134 struct sk_buff *skb = NULL; 2138 struct sk_buff *skb = NULL;
2135 u32 peer_port, peer_node; 2139 u32 peer_port, peer_node;
2140 u32 own_node = tsk_own_node(tsk);
2136 2141
2137 bh_lock_sock(sk); 2142 bh_lock_sock(sk);
2138 if (!tsk->connected) { 2143 if (!tsk->connected) {
@@ -2144,13 +2149,13 @@ static void tipc_sk_timeout(unsigned long data)
2144 2149
2145 if (tsk->probing_state == TIPC_CONN_PROBING) { 2150 if (tsk->probing_state == TIPC_CONN_PROBING) {
2146 /* Previous probe not answered -> self abort */ 2151 /* Previous probe not answered -> self abort */
2147 skb = tipc_msg_create(net, TIPC_CRITICAL_IMPORTANCE, 2152 skb = tipc_msg_create(TIPC_CRITICAL_IMPORTANCE,
2148 TIPC_CONN_MSG, SHORT_H_SIZE, 0, 2153 TIPC_CONN_MSG, SHORT_H_SIZE, 0,
2149 tn->own_addr, peer_node, tsk->portid, 2154 own_node, peer_node, tsk->portid,
2150 peer_port, TIPC_ERR_NO_PORT); 2155 peer_port, TIPC_ERR_NO_PORT);
2151 } else { 2156 } else {
2152 skb = tipc_msg_create(net, CONN_MANAGER, CONN_PROBE, INT_H_SIZE, 2157 skb = tipc_msg_create(CONN_MANAGER, CONN_PROBE,
2153 0, peer_node, tn->own_addr, 2158 INT_H_SIZE, 0, peer_node, own_node,
2154 peer_port, tsk->portid, TIPC_OK); 2159 peer_port, tsk->portid, TIPC_OK);
2155 tsk->probing_state = TIPC_CONN_PROBING; 2160 tsk->probing_state = TIPC_CONN_PROBING;
2156 sk_reset_timer(sk, &sk->sk_timer, jiffies + tsk->probing_intv); 2161 sk_reset_timer(sk, &sk->sk_timer, jiffies + tsk->probing_intv);