diff options
author | Ying Xue <ying.xue@windriver.com> | 2015-01-09 02:27:10 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-01-12 16:24:33 -0500 |
commit | 347475395434abb2b61bf59c2952470f37072567 (patch) | |
tree | 71a5f63547edecee31f557d0bacbf993b953a099 | |
parent | 4ac1c8d0ee9faf3a4be185cc4db1381fa0d81280 (diff) |
tipc: make tipc node address support net namespace
If net namespace is supported in tipc, each namespace will be treated
as a separate tipc node. Therefore, every namespace must own its
private tipc node address. This means the "tipc_own_addr" global
variable of node address must be moved to tipc_net structure to
satisfy the requirement. It's turned out that users also can assign
node address for every namespace.
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Tested-by: Tero Aho <Tero.Aho@coriant.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/tipc/addr.c | 43 | ||||
-rw-r--r-- | net/tipc/addr.h | 44 | ||||
-rw-r--r-- | net/tipc/bcast.c | 6 | ||||
-rw-r--r-- | net/tipc/bearer.c | 13 | ||||
-rw-r--r-- | net/tipc/config.c | 9 | ||||
-rw-r--r-- | net/tipc/core.c | 4 | ||||
-rw-r--r-- | net/tipc/core.h | 5 | ||||
-rw-r--r-- | net/tipc/discover.c | 8 | ||||
-rw-r--r-- | net/tipc/link.c | 56 | ||||
-rw-r--r-- | net/tipc/msg.c | 40 | ||||
-rw-r--r-- | net/tipc/msg.h | 21 | ||||
-rw-r--r-- | net/tipc/name_distr.c | 21 | ||||
-rw-r--r-- | net/tipc/name_distr.h | 2 | ||||
-rw-r--r-- | net/tipc/name_table.c | 39 | ||||
-rw-r--r-- | net/tipc/net.c | 20 | ||||
-rw-r--r-- | net/tipc/node.c | 23 | ||||
-rw-r--r-- | net/tipc/socket.c | 86 |
17 files changed, 246 insertions, 194 deletions
diff --git a/net/tipc/addr.c b/net/tipc/addr.c index 9e6eeb450fe1..48fd3b5a73fb 100644 --- a/net/tipc/addr.c +++ b/net/tipc/addr.c | |||
@@ -36,6 +36,49 @@ | |||
36 | 36 | ||
37 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
38 | #include "addr.h" | 38 | #include "addr.h" |
39 | #include "core.h" | ||
40 | |||
41 | /** | ||
42 | * in_own_cluster - test for cluster inclusion; <0.0.0> always matches | ||
43 | */ | ||
44 | int in_own_cluster(struct net *net, u32 addr) | ||
45 | { | ||
46 | return in_own_cluster_exact(net, addr) || !addr; | ||
47 | } | ||
48 | |||
49 | int in_own_cluster_exact(struct net *net, u32 addr) | ||
50 | { | ||
51 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
52 | |||
53 | return !((addr ^ tn->own_addr) >> 12); | ||
54 | } | ||
55 | |||
56 | /** | ||
57 | * in_own_node - test for node inclusion; <0.0.0> always matches | ||
58 | */ | ||
59 | int in_own_node(struct net *net, u32 addr) | ||
60 | { | ||
61 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
62 | |||
63 | return (addr == tn->own_addr) || !addr; | ||
64 | } | ||
65 | |||
66 | /** | ||
67 | * addr_domain - convert 2-bit scope value to equivalent message lookup domain | ||
68 | * | ||
69 | * Needed when address of a named message must be looked up a second time | ||
70 | * after a network hop. | ||
71 | */ | ||
72 | u32 addr_domain(struct net *net, u32 sc) | ||
73 | { | ||
74 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
75 | |||
76 | if (likely(sc == TIPC_NODE_SCOPE)) | ||
77 | return tn->own_addr; | ||
78 | if (sc == TIPC_CLUSTER_SCOPE) | ||
79 | return tipc_cluster_mask(tn->own_addr); | ||
80 | return tipc_zone_mask(tn->own_addr); | ||
81 | } | ||
39 | 82 | ||
40 | /** | 83 | /** |
41 | * tipc_addr_domain_valid - validates a network domain address | 84 | * tipc_addr_domain_valid - validates a network domain address |
diff --git a/net/tipc/addr.h b/net/tipc/addr.h index 4e364c4f1359..c700c2d28e09 100644 --- a/net/tipc/addr.h +++ b/net/tipc/addr.h | |||
@@ -39,12 +39,12 @@ | |||
39 | 39 | ||
40 | #include <linux/types.h> | 40 | #include <linux/types.h> |
41 | #include <linux/tipc.h> | 41 | #include <linux/tipc.h> |
42 | #include <net/net_namespace.h> | ||
43 | #include <net/netns/generic.h> | ||
42 | 44 | ||
43 | #define TIPC_ZONE_MASK 0xff000000u | 45 | #define TIPC_ZONE_MASK 0xff000000u |
44 | #define TIPC_CLUSTER_MASK 0xfffff000u | 46 | #define TIPC_CLUSTER_MASK 0xfffff000u |
45 | 47 | ||
46 | extern u32 tipc_own_addr __read_mostly; | ||
47 | |||
48 | static inline u32 tipc_zone_mask(u32 addr) | 48 | static inline u32 tipc_zone_mask(u32 addr) |
49 | { | 49 | { |
50 | return addr & TIPC_ZONE_MASK; | 50 | return addr & TIPC_ZONE_MASK; |
@@ -55,42 +55,10 @@ static inline u32 tipc_cluster_mask(u32 addr) | |||
55 | return addr & TIPC_CLUSTER_MASK; | 55 | return addr & TIPC_CLUSTER_MASK; |
56 | } | 56 | } |
57 | 57 | ||
58 | static inline int in_own_cluster_exact(u32 addr) | 58 | int in_own_cluster(struct net *net, u32 addr); |
59 | { | 59 | int in_own_cluster_exact(struct net *net, u32 addr); |
60 | return !((addr ^ tipc_own_addr) >> 12); | 60 | int in_own_node(struct net *net, u32 addr); |
61 | } | 61 | u32 addr_domain(struct net *net, u32 sc); |
62 | |||
63 | /** | ||
64 | * in_own_node - test for node inclusion; <0.0.0> always matches | ||
65 | */ | ||
66 | static inline int in_own_node(u32 addr) | ||
67 | { | ||
68 | return (addr == tipc_own_addr) || !addr; | ||
69 | } | ||
70 | |||
71 | /** | ||
72 | * in_own_cluster - test for cluster inclusion; <0.0.0> always matches | ||
73 | */ | ||
74 | static inline int in_own_cluster(u32 addr) | ||
75 | { | ||
76 | return in_own_cluster_exact(addr) || !addr; | ||
77 | } | ||
78 | |||
79 | /** | ||
80 | * addr_domain - convert 2-bit scope value to equivalent message lookup domain | ||
81 | * | ||
82 | * Needed when address of a named message must be looked up a second time | ||
83 | * after a network hop. | ||
84 | */ | ||
85 | static inline u32 addr_domain(u32 sc) | ||
86 | { | ||
87 | if (likely(sc == TIPC_NODE_SCOPE)) | ||
88 | return tipc_own_addr; | ||
89 | if (sc == TIPC_CLUSTER_SCOPE) | ||
90 | return tipc_cluster_mask(tipc_own_addr); | ||
91 | return tipc_zone_mask(tipc_own_addr); | ||
92 | } | ||
93 | |||
94 | int tipc_addr_domain_valid(u32); | 62 | int tipc_addr_domain_valid(u32); |
95 | int tipc_addr_node_valid(u32 addr); | 63 | int tipc_addr_node_valid(u32 addr); |
96 | int tipc_in_scope(u32 domain, u32 addr); | 64 | int tipc_in_scope(u32 domain, u32 addr); |
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index bc58097ebad2..53f8bf059fec 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c | |||
@@ -317,7 +317,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); | 317 | struct sk_buff *skb = skb_peek(&n_ptr->bclink.deferred_queue); |
318 | u32 to = skb ? buf_seqno(skb) - 1 : n_ptr->bclink.last_sent; | 318 | u32 to = skb ? buf_seqno(skb) - 1 : n_ptr->bclink.last_sent; |
319 | 319 | ||
320 | tipc_msg_init(msg, BCAST_PROTOCOL, STATE_MSG, | 320 | tipc_msg_init(net, msg, BCAST_PROTOCOL, STATE_MSG, |
321 | INT_H_SIZE, n_ptr->addr); | 321 | INT_H_SIZE, n_ptr->addr); |
322 | msg_set_non_seq(msg, 1); | 322 | msg_set_non_seq(msg, 1); |
323 | msg_set_mc_netid(msg, tn->net_id); | 323 | msg_set_mc_netid(msg, tn->net_id); |
@@ -428,7 +428,7 @@ static void bclink_accept_pkt(struct tipc_node *node, u32 seqno) | |||
428 | * Unicast an ACK periodically, ensuring that | 428 | * Unicast an ACK periodically, ensuring that |
429 | * all nodes in the cluster don't ACK at the same time | 429 | * all nodes in the cluster don't ACK at the same time |
430 | */ | 430 | */ |
431 | if (((seqno - tipc_own_addr) % TIPC_MIN_LINK_WIN) == 0) { | 431 | if (((seqno - tn->own_addr) % TIPC_MIN_LINK_WIN) == 0) { |
432 | tipc_link_proto_xmit(node->active_links[node->addr & 1], | 432 | tipc_link_proto_xmit(node->active_links[node->addr & 1], |
433 | STATE_MSG, 0, 0, 0, 0, 0); | 433 | STATE_MSG, 0, 0, 0, 0, 0); |
434 | tn->bcl->stats.sent_acks++; | 434 | tn->bcl->stats.sent_acks++; |
@@ -466,7 +466,7 @@ void tipc_bclink_rcv(struct net *net, struct sk_buff *buf) | |||
466 | if (unlikely(msg_user(msg) == BCAST_PROTOCOL)) { | 466 | if (unlikely(msg_user(msg) == BCAST_PROTOCOL)) { |
467 | if (msg_type(msg) != STATE_MSG) | 467 | if (msg_type(msg) != STATE_MSG) |
468 | goto unlock; | 468 | goto unlock; |
469 | if (msg_destnode(msg) == tipc_own_addr) { | 469 | if (msg_destnode(msg) == tn->own_addr) { |
470 | tipc_bclink_acknowledge(node, msg_bcast_ack(msg)); | 470 | tipc_bclink_acknowledge(node, msg_bcast_ack(msg)); |
471 | tipc_node_unlock(node); | 471 | tipc_node_unlock(node); |
472 | tipc_bclink_lock(net); | 472 | tipc_bclink_lock(net); |
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 9a0d6ed5c96c..33dc3486d16c 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
@@ -278,7 +278,7 @@ int tipc_enable_bearer(struct net *net, const char *name, u32 disc_domain, | |||
278 | u32 i; | 278 | u32 i; |
279 | int res = -EINVAL; | 279 | int res = -EINVAL; |
280 | 280 | ||
281 | if (!tipc_own_addr) { | 281 | if (!tn->own_addr) { |
282 | pr_warn("Bearer <%s> rejected, not supported in standalone mode\n", | 282 | pr_warn("Bearer <%s> rejected, not supported in standalone mode\n", |
283 | name); | 283 | name); |
284 | return -ENOPROTOOPT; | 284 | return -ENOPROTOOPT; |
@@ -288,11 +288,11 @@ int tipc_enable_bearer(struct net *net, const char *name, u32 disc_domain, | |||
288 | return -EINVAL; | 288 | return -EINVAL; |
289 | } | 289 | } |
290 | if (tipc_addr_domain_valid(disc_domain) && | 290 | if (tipc_addr_domain_valid(disc_domain) && |
291 | (disc_domain != tipc_own_addr)) { | 291 | (disc_domain != tn->own_addr)) { |
292 | if (tipc_in_scope(disc_domain, tipc_own_addr)) { | 292 | if (tipc_in_scope(disc_domain, tn->own_addr)) { |
293 | disc_domain = tipc_own_addr & TIPC_CLUSTER_MASK; | 293 | disc_domain = tn->own_addr & TIPC_CLUSTER_MASK; |
294 | res = 0; /* accept any node in own cluster */ | 294 | res = 0; /* accept any node in own cluster */ |
295 | } else if (in_own_cluster_exact(disc_domain)) | 295 | } else if (in_own_cluster_exact(net, disc_domain)) |
296 | res = 0; /* accept specified node in own cluster */ | 296 | res = 0; /* accept specified node in own cluster */ |
297 | } | 297 | } |
298 | if (res) { | 298 | if (res) { |
@@ -817,6 +817,7 @@ int tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info) | |||
817 | int tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info) | 817 | int tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info) |
818 | { | 818 | { |
819 | struct net *net = genl_info_net(info); | 819 | struct net *net = genl_info_net(info); |
820 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
820 | int err; | 821 | int err; |
821 | char *bearer; | 822 | char *bearer; |
822 | struct nlattr *attrs[TIPC_NLA_BEARER_MAX + 1]; | 823 | struct nlattr *attrs[TIPC_NLA_BEARER_MAX + 1]; |
@@ -824,7 +825,7 @@ int tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info) | |||
824 | u32 prio; | 825 | u32 prio; |
825 | 826 | ||
826 | prio = TIPC_MEDIA_LINK_PRI; | 827 | prio = TIPC_MEDIA_LINK_PRI; |
827 | domain = tipc_own_addr & TIPC_CLUSTER_MASK; | 828 | domain = tn->own_addr & TIPC_CLUSTER_MASK; |
828 | 829 | ||
829 | if (!info->attrs[TIPC_NLA_BEARER]) | 830 | if (!info->attrs[TIPC_NLA_BEARER]) |
830 | return -EINVAL; | 831 | return -EINVAL; |
diff --git a/net/tipc/config.c b/net/tipc/config.c index 974723a1e32e..6873360cda53 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c | |||
@@ -163,18 +163,19 @@ static struct sk_buff *cfg_disable_bearer(struct net *net) | |||
163 | 163 | ||
164 | static struct sk_buff *cfg_set_own_addr(struct net *net) | 164 | static struct sk_buff *cfg_set_own_addr(struct net *net) |
165 | { | 165 | { |
166 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
166 | u32 addr; | 167 | u32 addr; |
167 | 168 | ||
168 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) | 169 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) |
169 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | 170 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); |
170 | 171 | ||
171 | addr = ntohl(*(__be32 *)TLV_DATA(req_tlv_area)); | 172 | addr = ntohl(*(__be32 *)TLV_DATA(req_tlv_area)); |
172 | if (addr == tipc_own_addr) | 173 | if (addr == tn->own_addr) |
173 | return tipc_cfg_reply_none(); | 174 | return tipc_cfg_reply_none(); |
174 | if (!tipc_addr_node_valid(addr)) | 175 | if (!tipc_addr_node_valid(addr)) |
175 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE | 176 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE |
176 | " (node address)"); | 177 | " (node address)"); |
177 | if (tipc_own_addr) | 178 | if (tn->own_addr) |
178 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 179 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED |
179 | " (cannot change node address once assigned)"); | 180 | " (cannot change node address once assigned)"); |
180 | if (!tipc_net_start(net, addr)) | 181 | if (!tipc_net_start(net, addr)) |
@@ -196,7 +197,7 @@ static struct sk_buff *cfg_set_netid(struct net *net) | |||
196 | if (value < 1 || value > 9999) | 197 | if (value < 1 || value > 9999) |
197 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE | 198 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE |
198 | " (network id must be 1-9999)"); | 199 | " (network id must be 1-9999)"); |
199 | if (tipc_own_addr) | 200 | if (tn->own_addr) |
200 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 201 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED |
201 | " (cannot change network id once TIPC has joined a network)"); | 202 | " (cannot change network id once TIPC has joined a network)"); |
202 | tn->net_id = value; | 203 | tn->net_id = value; |
@@ -218,7 +219,7 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd, | |||
218 | rep_headroom = reply_headroom; | 219 | rep_headroom = reply_headroom; |
219 | 220 | ||
220 | /* Check command authorization */ | 221 | /* Check command authorization */ |
221 | if (likely(in_own_node(orig_node))) { | 222 | if (likely(in_own_node(net, orig_node))) { |
222 | /* command is permitted */ | 223 | /* command is permitted */ |
223 | } else { | 224 | } else { |
224 | rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 225 | rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED |
diff --git a/net/tipc/core.c b/net/tipc/core.c index 63cde8148aaf..7c09670120eb 100644 --- a/net/tipc/core.c +++ b/net/tipc/core.c | |||
@@ -48,7 +48,6 @@ | |||
48 | int tipc_random __read_mostly; | 48 | int tipc_random __read_mostly; |
49 | 49 | ||
50 | /* configurable TIPC parameters */ | 50 | /* configurable TIPC parameters */ |
51 | u32 tipc_own_addr __read_mostly; | ||
52 | int tipc_net_id __read_mostly; | 51 | int tipc_net_id __read_mostly; |
53 | int sysctl_tipc_rmem[3] __read_mostly; /* min/default/max */ | 52 | int sysctl_tipc_rmem[3] __read_mostly; /* min/default/max */ |
54 | 53 | ||
@@ -58,6 +57,7 @@ static int __net_init tipc_init_net(struct net *net) | |||
58 | int err; | 57 | int err; |
59 | 58 | ||
60 | tn->net_id = 4711; | 59 | tn->net_id = 4711; |
60 | tn->own_addr = 0; | ||
61 | INIT_LIST_HEAD(&tn->node_list); | 61 | INIT_LIST_HEAD(&tn->node_list); |
62 | spin_lock_init(&tn->node_list_lock); | 62 | spin_lock_init(&tn->node_list_lock); |
63 | 63 | ||
@@ -96,8 +96,6 @@ static int __init tipc_init(void) | |||
96 | 96 | ||
97 | pr_info("Activated (version " TIPC_MOD_VER ")\n"); | 97 | pr_info("Activated (version " TIPC_MOD_VER ")\n"); |
98 | 98 | ||
99 | tipc_own_addr = 0; | ||
100 | |||
101 | sysctl_tipc_rmem[0] = TIPC_CONN_OVERLOAD_LIMIT >> 4 << | 99 | sysctl_tipc_rmem[0] = TIPC_CONN_OVERLOAD_LIMIT >> 4 << |
102 | TIPC_LOW_IMPORTANCE; | 100 | TIPC_LOW_IMPORTANCE; |
103 | sysctl_tipc_rmem[1] = TIPC_CONN_OVERLOAD_LIMIT >> 4 << | 101 | sysctl_tipc_rmem[1] = TIPC_CONN_OVERLOAD_LIMIT >> 4 << |
diff --git a/net/tipc/core.h b/net/tipc/core.h index 893992944570..afabf39e801c 100644 --- a/net/tipc/core.h +++ b/net/tipc/core.h | |||
@@ -72,10 +72,6 @@ | |||
72 | 72 | ||
73 | int tipc_snprintf(char *buf, int len, const char *fmt, ...); | 73 | int tipc_snprintf(char *buf, int len, const char *fmt, ...); |
74 | 74 | ||
75 | /* | ||
76 | * Global configuration variables | ||
77 | */ | ||
78 | extern u32 tipc_own_addr __read_mostly; | ||
79 | extern int tipc_net_id __read_mostly; | 75 | extern int tipc_net_id __read_mostly; |
80 | extern int sysctl_tipc_rmem[3] __read_mostly; | 76 | extern int sysctl_tipc_rmem[3] __read_mostly; |
81 | extern int sysctl_tipc_named_timeout __read_mostly; | 77 | extern int sysctl_tipc_named_timeout __read_mostly; |
@@ -86,6 +82,7 @@ extern int sysctl_tipc_named_timeout __read_mostly; | |||
86 | extern int tipc_random __read_mostly; | 82 | extern int tipc_random __read_mostly; |
87 | 83 | ||
88 | struct tipc_net { | 84 | struct tipc_net { |
85 | u32 own_addr; | ||
89 | int net_id; | 86 | int net_id; |
90 | 87 | ||
91 | /* Node table and node list */ | 88 | /* Node table and node list */ |
diff --git a/net/tipc/discover.c b/net/tipc/discover.c index f93dd3dd621b..786411dea61c 100644 --- a/net/tipc/discover.c +++ b/net/tipc/discover.c | |||
@@ -86,7 +86,7 @@ static void tipc_disc_init_msg(struct net *net, struct sk_buff *buf, u32 type, | |||
86 | u32 dest_domain = b_ptr->domain; | 86 | u32 dest_domain = b_ptr->domain; |
87 | 87 | ||
88 | msg = buf_msg(buf); | 88 | msg = buf_msg(buf); |
89 | tipc_msg_init(msg, LINK_CONFIG, type, INT_H_SIZE, dest_domain); | 89 | tipc_msg_init(net, msg, LINK_CONFIG, type, INT_H_SIZE, dest_domain); |
90 | msg_set_non_seq(msg, 1); | 90 | msg_set_non_seq(msg, 1); |
91 | msg_set_node_sig(msg, tipc_random); | 91 | msg_set_node_sig(msg, tipc_random); |
92 | msg_set_dest_domain(msg, dest_domain); | 92 | msg_set_dest_domain(msg, dest_domain); |
@@ -153,12 +153,12 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *buf, | |||
153 | if (!tipc_addr_node_valid(onode)) | 153 | if (!tipc_addr_node_valid(onode)) |
154 | return; | 154 | return; |
155 | 155 | ||
156 | if (in_own_node(onode)) { | 156 | if (in_own_node(net, onode)) { |
157 | if (memcmp(&maddr, &bearer->addr, sizeof(maddr))) | 157 | if (memcmp(&maddr, &bearer->addr, sizeof(maddr))) |
158 | disc_dupl_alert(bearer, tipc_own_addr, &maddr); | 158 | disc_dupl_alert(bearer, tn->own_addr, &maddr); |
159 | return; | 159 | return; |
160 | } | 160 | } |
161 | if (!tipc_in_scope(ddom, tipc_own_addr)) | 161 | if (!tipc_in_scope(ddom, tn->own_addr)) |
162 | return; | 162 | return; |
163 | if (!tipc_in_scope(bearer->domain, onode)) | 163 | if (!tipc_in_scope(bearer->domain, onode)) |
164 | return; | 164 | return; |
diff --git a/net/tipc/link.c b/net/tipc/link.c index a84d5c67997e..997256769065 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -241,6 +241,7 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, | |||
241 | struct tipc_bearer *b_ptr, | 241 | struct tipc_bearer *b_ptr, |
242 | const struct tipc_media_addr *media_addr) | 242 | const struct tipc_media_addr *media_addr) |
243 | { | 243 | { |
244 | struct tipc_net *tn = net_generic(n_ptr->net, tipc_net_id); | ||
244 | struct tipc_link *l_ptr; | 245 | struct tipc_link *l_ptr; |
245 | struct tipc_msg *msg; | 246 | struct tipc_msg *msg; |
246 | char *if_name; | 247 | char *if_name; |
@@ -270,8 +271,8 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, | |||
270 | l_ptr->addr = peer; | 271 | l_ptr->addr = peer; |
271 | if_name = strchr(b_ptr->name, ':') + 1; | 272 | if_name = strchr(b_ptr->name, ':') + 1; |
272 | sprintf(l_ptr->name, "%u.%u.%u:%s-%u.%u.%u:unknown", | 273 | sprintf(l_ptr->name, "%u.%u.%u:%s-%u.%u.%u:unknown", |
273 | tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr), | 274 | tipc_zone(tn->own_addr), tipc_cluster(tn->own_addr), |
274 | tipc_node(tipc_own_addr), | 275 | tipc_node(tn->own_addr), |
275 | if_name, | 276 | if_name, |
276 | tipc_zone(peer), tipc_cluster(peer), tipc_node(peer)); | 277 | tipc_zone(peer), tipc_cluster(peer), tipc_node(peer)); |
277 | /* note: peer i/f name is updated by reset/activate message */ | 278 | /* note: peer i/f name is updated by reset/activate message */ |
@@ -285,7 +286,8 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, | |||
285 | 286 | ||
286 | l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg; | 287 | l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg; |
287 | msg = l_ptr->pmsg; | 288 | msg = l_ptr->pmsg; |
288 | tipc_msg_init(msg, LINK_PROTOCOL, RESET_MSG, INT_H_SIZE, l_ptr->addr); | 289 | tipc_msg_init(n_ptr->net, msg, LINK_PROTOCOL, RESET_MSG, INT_H_SIZE, |
290 | l_ptr->addr); | ||
289 | msg_set_size(msg, sizeof(l_ptr->proto_msg)); | 291 | msg_set_size(msg, sizeof(l_ptr->proto_msg)); |
290 | msg_set_session(msg, (tipc_random & 0xffff)); | 292 | msg_set_session(msg, (tipc_random & 0xffff)); |
291 | msg_set_bearer_id(msg, b_ptr->identity); | 293 | msg_set_bearer_id(msg, b_ptr->identity); |
@@ -358,10 +360,12 @@ void tipc_link_delete_list(struct net *net, unsigned int bearer_id, | |||
358 | static bool link_schedule_user(struct tipc_link *link, u32 oport, | 360 | static bool link_schedule_user(struct tipc_link *link, u32 oport, |
359 | uint chain_sz, uint imp) | 361 | uint chain_sz, uint imp) |
360 | { | 362 | { |
363 | struct net *net = link->owner->net; | ||
364 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
361 | struct sk_buff *buf; | 365 | struct sk_buff *buf; |
362 | 366 | ||
363 | buf = tipc_msg_create(SOCK_WAKEUP, 0, INT_H_SIZE, 0, tipc_own_addr, | 367 | buf = tipc_msg_create(net, SOCK_WAKEUP, 0, INT_H_SIZE, 0, tn->own_addr, |
364 | tipc_own_addr, oport, 0, 0); | 368 | tn->own_addr, oport, 0, 0); |
365 | if (!buf) | 369 | if (!buf) |
366 | return false; | 370 | return false; |
367 | TIPC_SKB_CB(buf)->chain_sz = chain_sz; | 371 | TIPC_SKB_CB(buf)->chain_sz = chain_sz; |
@@ -753,7 +757,7 @@ int __tipc_link_xmit(struct net *net, struct tipc_link *link, | |||
753 | } else if (tipc_msg_bundle(outqueue, skb, mtu)) { | 757 | } else if (tipc_msg_bundle(outqueue, skb, mtu)) { |
754 | link->stats.sent_bundled++; | 758 | link->stats.sent_bundled++; |
755 | continue; | 759 | continue; |
756 | } else if (tipc_msg_make_bundle(outqueue, skb, mtu, | 760 | } else if (tipc_msg_make_bundle(net, outqueue, skb, mtu, |
757 | link->addr)) { | 761 | link->addr)) { |
758 | link->stats.sent_bundled++; | 762 | link->stats.sent_bundled++; |
759 | link->stats.sent_bundles++; | 763 | link->stats.sent_bundles++; |
@@ -822,7 +826,7 @@ int tipc_link_xmit(struct net *net, struct sk_buff_head *list, u32 dnode, | |||
822 | if (link) | 826 | if (link) |
823 | return rc; | 827 | return rc; |
824 | 828 | ||
825 | if (likely(in_own_node(dnode))) { | 829 | if (likely(in_own_node(net, dnode))) { |
826 | /* As a node local message chain never contains more than one | 830 | /* As a node local message chain never contains more than one |
827 | * buffer, we just need to dequeue one SKB buffer from the | 831 | * buffer, we just need to dequeue one SKB buffer from the |
828 | * head list. | 832 | * head list. |
@@ -852,7 +856,8 @@ static void tipc_link_sync_xmit(struct tipc_link *link) | |||
852 | return; | 856 | return; |
853 | 857 | ||
854 | msg = buf_msg(skb); | 858 | msg = buf_msg(skb); |
855 | tipc_msg_init(msg, BCAST_PROTOCOL, STATE_MSG, INT_H_SIZE, link->addr); | 859 | tipc_msg_init(link->owner->net, msg, BCAST_PROTOCOL, STATE_MSG, |
860 | INT_H_SIZE, link->addr); | ||
856 | msg_set_last_bcast(msg, link->owner->bclink.acked); | 861 | msg_set_last_bcast(msg, link->owner->bclink.acked); |
857 | __tipc_link_xmit_skb(link, skb); | 862 | __tipc_link_xmit_skb(link, skb); |
858 | } | 863 | } |
@@ -1092,6 +1097,7 @@ static int link_recv_buf_validate(struct sk_buff *buf) | |||
1092 | */ | 1097 | */ |
1093 | void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b_ptr) | 1098 | void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b_ptr) |
1094 | { | 1099 | { |
1100 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
1095 | struct sk_buff_head head; | 1101 | struct sk_buff_head head; |
1096 | struct tipc_node *n_ptr; | 1102 | struct tipc_node *n_ptr; |
1097 | struct tipc_link *l_ptr; | 1103 | struct tipc_link *l_ptr; |
@@ -1125,7 +1131,7 @@ void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b_ptr) | |||
1125 | 1131 | ||
1126 | /* Discard unicast link messages destined for another node */ | 1132 | /* Discard unicast link messages destined for another node */ |
1127 | if (unlikely(!msg_short(msg) && | 1133 | if (unlikely(!msg_short(msg) && |
1128 | (msg_destnode(msg) != tipc_own_addr))) | 1134 | (msg_destnode(msg) != tn->own_addr))) |
1129 | goto discard; | 1135 | goto discard; |
1130 | 1136 | ||
1131 | /* Locate neighboring node that sent message */ | 1137 | /* Locate neighboring node that sent message */ |
@@ -1483,6 +1489,7 @@ void tipc_link_proto_xmit(struct tipc_link *l_ptr, u32 msg_typ, int probe_msg, | |||
1483 | static void tipc_link_proto_rcv(struct net *net, struct tipc_link *l_ptr, | 1489 | static void tipc_link_proto_rcv(struct net *net, struct tipc_link *l_ptr, |
1484 | struct sk_buff *buf) | 1490 | struct sk_buff *buf) |
1485 | { | 1491 | { |
1492 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
1486 | u32 rec_gap = 0; | 1493 | u32 rec_gap = 0; |
1487 | u32 max_pkt_info; | 1494 | u32 max_pkt_info; |
1488 | u32 max_pkt_ack; | 1495 | u32 max_pkt_ack; |
@@ -1494,7 +1501,7 @@ static void tipc_link_proto_rcv(struct net *net, struct tipc_link *l_ptr, | |||
1494 | goto exit; | 1501 | goto exit; |
1495 | 1502 | ||
1496 | if (l_ptr->net_plane != msg_net_plane(msg)) | 1503 | if (l_ptr->net_plane != msg_net_plane(msg)) |
1497 | if (tipc_own_addr > msg_prevnode(msg)) | 1504 | if (tn->own_addr > msg_prevnode(msg)) |
1498 | l_ptr->net_plane = msg_net_plane(msg); | 1505 | l_ptr->net_plane = msg_net_plane(msg); |
1499 | 1506 | ||
1500 | switch (msg_type(msg)) { | 1507 | switch (msg_type(msg)) { |
@@ -1662,8 +1669,8 @@ void tipc_link_failover_send_queue(struct tipc_link *l_ptr) | |||
1662 | if (!tunnel) | 1669 | if (!tunnel) |
1663 | return; | 1670 | return; |
1664 | 1671 | ||
1665 | tipc_msg_init(&tunnel_hdr, CHANGEOVER_PROTOCOL, | 1672 | tipc_msg_init(l_ptr->owner->net, &tunnel_hdr, CHANGEOVER_PROTOCOL, |
1666 | ORIGINAL_MSG, INT_H_SIZE, l_ptr->addr); | 1673 | ORIGINAL_MSG, INT_H_SIZE, l_ptr->addr); |
1667 | msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); | 1674 | msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); |
1668 | msg_set_msgcnt(&tunnel_hdr, msgcount); | 1675 | msg_set_msgcnt(&tunnel_hdr, msgcount); |
1669 | 1676 | ||
@@ -1720,8 +1727,8 @@ void tipc_link_dup_queue_xmit(struct tipc_link *l_ptr, | |||
1720 | struct sk_buff *skb; | 1727 | struct sk_buff *skb; |
1721 | struct tipc_msg tunnel_hdr; | 1728 | struct tipc_msg tunnel_hdr; |
1722 | 1729 | ||
1723 | tipc_msg_init(&tunnel_hdr, CHANGEOVER_PROTOCOL, | 1730 | tipc_msg_init(l_ptr->owner->net, &tunnel_hdr, CHANGEOVER_PROTOCOL, |
1724 | DUPLICATE_MSG, INT_H_SIZE, l_ptr->addr); | 1731 | DUPLICATE_MSG, INT_H_SIZE, l_ptr->addr); |
1725 | msg_set_msgcnt(&tunnel_hdr, skb_queue_len(&l_ptr->outqueue)); | 1732 | msg_set_msgcnt(&tunnel_hdr, skb_queue_len(&l_ptr->outqueue)); |
1726 | msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); | 1733 | msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); |
1727 | skb_queue_walk(&l_ptr->outqueue, skb) { | 1734 | skb_queue_walk(&l_ptr->outqueue, skb) { |
@@ -2506,12 +2513,14 @@ msg_full: | |||
2506 | } | 2513 | } |
2507 | 2514 | ||
2508 | /* Caller should hold appropriate locks to protect the link */ | 2515 | /* Caller should hold appropriate locks to protect the link */ |
2509 | static int __tipc_nl_add_link(struct tipc_nl_msg *msg, struct tipc_link *link) | 2516 | static int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg, |
2517 | struct tipc_link *link) | ||
2510 | { | 2518 | { |
2511 | int err; | 2519 | int err; |
2512 | void *hdr; | 2520 | void *hdr; |
2513 | struct nlattr *attrs; | 2521 | struct nlattr *attrs; |
2514 | struct nlattr *prop; | 2522 | struct nlattr *prop; |
2523 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
2515 | 2524 | ||
2516 | hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_v2_family, | 2525 | hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_v2_family, |
2517 | NLM_F_MULTI, TIPC_NL_LINK_GET); | 2526 | NLM_F_MULTI, TIPC_NL_LINK_GET); |
@@ -2525,7 +2534,7 @@ static int __tipc_nl_add_link(struct tipc_nl_msg *msg, struct tipc_link *link) | |||
2525 | if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, link->name)) | 2534 | if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, link->name)) |
2526 | goto attr_msg_full; | 2535 | goto attr_msg_full; |
2527 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_DEST, | 2536 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_DEST, |
2528 | tipc_cluster_mask(tipc_own_addr))) | 2537 | tipc_cluster_mask(tn->own_addr))) |
2529 | goto attr_msg_full; | 2538 | goto attr_msg_full; |
2530 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->max_pkt)) | 2539 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->max_pkt)) |
2531 | goto attr_msg_full; | 2540 | goto attr_msg_full; |
@@ -2575,9 +2584,8 @@ msg_full: | |||
2575 | } | 2584 | } |
2576 | 2585 | ||
2577 | /* Caller should hold node lock */ | 2586 | /* Caller should hold node lock */ |
2578 | static int __tipc_nl_add_node_links(struct tipc_nl_msg *msg, | 2587 | static int __tipc_nl_add_node_links(struct net *net, struct tipc_nl_msg *msg, |
2579 | struct tipc_node *node, | 2588 | struct tipc_node *node, u32 *prev_link) |
2580 | u32 *prev_link) | ||
2581 | { | 2589 | { |
2582 | u32 i; | 2590 | u32 i; |
2583 | int err; | 2591 | int err; |
@@ -2588,7 +2596,7 @@ static int __tipc_nl_add_node_links(struct tipc_nl_msg *msg, | |||
2588 | if (!node->links[i]) | 2596 | if (!node->links[i]) |
2589 | continue; | 2597 | continue; |
2590 | 2598 | ||
2591 | err = __tipc_nl_add_link(msg, node->links[i]); | 2599 | err = __tipc_nl_add_link(net, msg, node->links[i]); |
2592 | if (err) | 2600 | if (err) |
2593 | return err; | 2601 | return err; |
2594 | } | 2602 | } |
@@ -2633,7 +2641,8 @@ int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
2633 | list_for_each_entry_continue_rcu(node, &tn->node_list, | 2641 | list_for_each_entry_continue_rcu(node, &tn->node_list, |
2634 | list) { | 2642 | list) { |
2635 | tipc_node_lock(node); | 2643 | tipc_node_lock(node); |
2636 | err = __tipc_nl_add_node_links(&msg, node, &prev_link); | 2644 | err = __tipc_nl_add_node_links(net, &msg, node, |
2645 | &prev_link); | ||
2637 | tipc_node_unlock(node); | 2646 | tipc_node_unlock(node); |
2638 | if (err) | 2647 | if (err) |
2639 | goto out; | 2648 | goto out; |
@@ -2647,7 +2656,8 @@ int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
2647 | 2656 | ||
2648 | list_for_each_entry_rcu(node, &tn->node_list, list) { | 2657 | list_for_each_entry_rcu(node, &tn->node_list, list) { |
2649 | tipc_node_lock(node); | 2658 | tipc_node_lock(node); |
2650 | err = __tipc_nl_add_node_links(&msg, node, &prev_link); | 2659 | err = __tipc_nl_add_node_links(net, &msg, node, |
2660 | &prev_link); | ||
2651 | tipc_node_unlock(node); | 2661 | tipc_node_unlock(node); |
2652 | if (err) | 2662 | if (err) |
2653 | goto out; | 2663 | goto out; |
@@ -2700,7 +2710,7 @@ int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info) | |||
2700 | goto err_out; | 2710 | goto err_out; |
2701 | } | 2711 | } |
2702 | 2712 | ||
2703 | err = __tipc_nl_add_link(&msg, link); | 2713 | err = __tipc_nl_add_link(net, &msg, link); |
2704 | if (err) | 2714 | if (err) |
2705 | goto err_out; | 2715 | goto err_out; |
2706 | 2716 | ||
diff --git a/net/tipc/msg.c b/net/tipc/msg.c index 642fb137463c..18aba9e99345 100644 --- a/net/tipc/msg.c +++ b/net/tipc/msg.c | |||
@@ -70,25 +70,27 @@ struct sk_buff *tipc_buf_acquire(u32 size) | |||
70 | return skb; | 70 | return skb; |
71 | } | 71 | } |
72 | 72 | ||
73 | void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, u32 hsize, | 73 | void tipc_msg_init(struct net *net, struct tipc_msg *m, u32 user, u32 type, |
74 | u32 destnode) | 74 | u32 hsize, u32 destnode) |
75 | { | 75 | { |
76 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
77 | |||
76 | memset(m, 0, hsize); | 78 | memset(m, 0, hsize); |
77 | msg_set_version(m); | 79 | msg_set_version(m); |
78 | msg_set_user(m, user); | 80 | msg_set_user(m, user); |
79 | msg_set_hdr_sz(m, hsize); | 81 | msg_set_hdr_sz(m, hsize); |
80 | msg_set_size(m, hsize); | 82 | msg_set_size(m, hsize); |
81 | msg_set_prevnode(m, tipc_own_addr); | 83 | msg_set_prevnode(m, tn->own_addr); |
82 | msg_set_type(m, type); | 84 | msg_set_type(m, type); |
83 | if (hsize > SHORT_H_SIZE) { | 85 | if (hsize > SHORT_H_SIZE) { |
84 | msg_set_orignode(m, tipc_own_addr); | 86 | msg_set_orignode(m, tn->own_addr); |
85 | msg_set_destnode(m, destnode); | 87 | msg_set_destnode(m, destnode); |
86 | } | 88 | } |
87 | } | 89 | } |
88 | 90 | ||
89 | struct sk_buff *tipc_msg_create(uint user, uint type, uint hdr_sz, | 91 | struct sk_buff *tipc_msg_create(struct net *net, uint user, uint type, |
90 | uint data_sz, u32 dnode, u32 onode, | 92 | uint hdr_sz, uint data_sz, u32 dnode, |
91 | u32 dport, u32 oport, int errcode) | 93 | u32 onode, u32 dport, u32 oport, int errcode) |
92 | { | 94 | { |
93 | struct tipc_msg *msg; | 95 | struct tipc_msg *msg; |
94 | struct sk_buff *buf; | 96 | struct sk_buff *buf; |
@@ -98,7 +100,7 @@ struct sk_buff *tipc_msg_create(uint user, uint type, uint hdr_sz, | |||
98 | return NULL; | 100 | return NULL; |
99 | 101 | ||
100 | msg = buf_msg(buf); | 102 | msg = buf_msg(buf); |
101 | tipc_msg_init(msg, user, type, hdr_sz, dnode); | 103 | tipc_msg_init(net, msg, user, type, hdr_sz, dnode); |
102 | msg_set_size(msg, hdr_sz + data_sz); | 104 | msg_set_size(msg, hdr_sz + data_sz); |
103 | msg_set_prevnode(msg, onode); | 105 | msg_set_prevnode(msg, onode); |
104 | msg_set_origport(msg, oport); | 106 | msg_set_origport(msg, oport); |
@@ -194,8 +196,8 @@ err: | |||
194 | * | 196 | * |
195 | * Returns message data size or errno: -ENOMEM, -EFAULT | 197 | * Returns message data size or errno: -ENOMEM, -EFAULT |
196 | */ | 198 | */ |
197 | int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m, int offset, | 199 | int tipc_msg_build(struct net *net, struct tipc_msg *mhdr, struct msghdr *m, |
198 | int dsz, int pktmax, struct sk_buff_head *list) | 200 | int offset, int dsz, int pktmax, struct sk_buff_head *list) |
199 | { | 201 | { |
200 | int mhsz = msg_hdr_sz(mhdr); | 202 | int mhsz = msg_hdr_sz(mhdr); |
201 | int msz = mhsz + dsz; | 203 | int msz = mhsz + dsz; |
@@ -227,8 +229,8 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m, int offset, | |||
227 | } | 229 | } |
228 | 230 | ||
229 | /* Prepare reusable fragment header */ | 231 | /* Prepare reusable fragment header */ |
230 | tipc_msg_init(&pkthdr, MSG_FRAGMENTER, FIRST_FRAGMENT, | 232 | tipc_msg_init(net, &pkthdr, MSG_FRAGMENTER, FIRST_FRAGMENT, INT_H_SIZE, |
231 | INT_H_SIZE, msg_destnode(mhdr)); | 233 | msg_destnode(mhdr)); |
232 | msg_set_size(&pkthdr, pktmax); | 234 | msg_set_size(&pkthdr, pktmax); |
233 | msg_set_fragm_no(&pkthdr, pktno); | 235 | msg_set_fragm_no(&pkthdr, pktno); |
234 | 236 | ||
@@ -339,8 +341,8 @@ bool tipc_msg_bundle(struct sk_buff_head *list, struct sk_buff *skb, u32 mtu) | |||
339 | * Replaces buffer if successful | 341 | * Replaces buffer if successful |
340 | * Returns true if success, otherwise false | 342 | * Returns true if success, otherwise false |
341 | */ | 343 | */ |
342 | bool tipc_msg_make_bundle(struct sk_buff_head *list, struct sk_buff *skb, | 344 | bool tipc_msg_make_bundle(struct net *net, struct sk_buff_head *list, |
343 | u32 mtu, u32 dnode) | 345 | struct sk_buff *skb, u32 mtu, u32 dnode) |
344 | { | 346 | { |
345 | struct sk_buff *bskb; | 347 | struct sk_buff *bskb; |
346 | struct tipc_msg *bmsg; | 348 | struct tipc_msg *bmsg; |
@@ -363,7 +365,7 @@ bool tipc_msg_make_bundle(struct sk_buff_head *list, struct sk_buff *skb, | |||
363 | 365 | ||
364 | skb_trim(bskb, INT_H_SIZE); | 366 | skb_trim(bskb, INT_H_SIZE); |
365 | bmsg = buf_msg(bskb); | 367 | bmsg = buf_msg(bskb); |
366 | tipc_msg_init(bmsg, MSG_BUNDLER, 0, INT_H_SIZE, dnode); | 368 | tipc_msg_init(net, bmsg, MSG_BUNDLER, 0, INT_H_SIZE, dnode); |
367 | msg_set_seqno(bmsg, msg_seqno(msg)); | 369 | msg_set_seqno(bmsg, msg_seqno(msg)); |
368 | msg_set_ack(bmsg, msg_ack(msg)); | 370 | msg_set_ack(bmsg, msg_ack(msg)); |
369 | msg_set_bcast_ack(bmsg, msg_bcast_ack(msg)); | 371 | msg_set_bcast_ack(bmsg, msg_bcast_ack(msg)); |
@@ -380,8 +382,10 @@ bool tipc_msg_make_bundle(struct sk_buff_head *list, struct sk_buff *skb, | |||
380 | * Consumes buffer if failure | 382 | * Consumes buffer if failure |
381 | * Returns true if success, otherwise false | 383 | * Returns true if success, otherwise false |
382 | */ | 384 | */ |
383 | bool tipc_msg_reverse(struct sk_buff *buf, u32 *dnode, int err) | 385 | bool tipc_msg_reverse(struct net *net, struct sk_buff *buf, u32 *dnode, |
386 | int err) | ||
384 | { | 387 | { |
388 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
385 | struct tipc_msg *msg = buf_msg(buf); | 389 | struct tipc_msg *msg = buf_msg(buf); |
386 | uint imp = msg_importance(msg); | 390 | uint imp = msg_importance(msg); |
387 | struct tipc_msg ohdr; | 391 | struct tipc_msg ohdr; |
@@ -401,7 +405,7 @@ bool tipc_msg_reverse(struct sk_buff *buf, u32 *dnode, int err) | |||
401 | msg_set_errcode(msg, err); | 405 | msg_set_errcode(msg, err); |
402 | msg_set_origport(msg, msg_destport(&ohdr)); | 406 | msg_set_origport(msg, msg_destport(&ohdr)); |
403 | msg_set_destport(msg, msg_origport(&ohdr)); | 407 | msg_set_destport(msg, msg_origport(&ohdr)); |
404 | msg_set_prevnode(msg, tipc_own_addr); | 408 | msg_set_prevnode(msg, tn->own_addr); |
405 | if (!msg_short(msg)) { | 409 | if (!msg_short(msg)) { |
406 | msg_set_orignode(msg, msg_destnode(&ohdr)); | 410 | msg_set_orignode(msg, msg_destnode(&ohdr)); |
407 | msg_set_destnode(msg, msg_orignode(&ohdr)); | 411 | msg_set_destnode(msg, msg_orignode(&ohdr)); |
@@ -440,7 +444,7 @@ int tipc_msg_eval(struct net *net, struct sk_buff *buf, u32 *dnode) | |||
440 | if (msg_reroute_cnt(msg) > 0) | 444 | if (msg_reroute_cnt(msg) > 0) |
441 | return -TIPC_ERR_NO_NAME; | 445 | return -TIPC_ERR_NO_NAME; |
442 | 446 | ||
443 | *dnode = addr_domain(msg_lookup_scope(msg)); | 447 | *dnode = addr_domain(net, msg_lookup_scope(msg)); |
444 | dport = tipc_nametbl_translate(net, msg_nametype(msg), | 448 | dport = tipc_nametbl_translate(net, msg_nametype(msg), |
445 | msg_nameinst(msg), | 449 | msg_nameinst(msg), |
446 | dnode); | 450 | dnode); |
diff --git a/net/tipc/msg.h b/net/tipc/msg.h index 69f37e652a8e..526ef345b70e 100644 --- a/net/tipc/msg.h +++ b/net/tipc/msg.h | |||
@@ -748,19 +748,20 @@ static inline u32 msg_tot_origport(struct tipc_msg *m) | |||
748 | } | 748 | } |
749 | 749 | ||
750 | struct sk_buff *tipc_buf_acquire(u32 size); | 750 | struct sk_buff *tipc_buf_acquire(u32 size); |
751 | bool tipc_msg_reverse(struct sk_buff *buf, u32 *dnode, int err); | 751 | bool tipc_msg_reverse(struct net *net, struct sk_buff *buf, u32 *dnode, |
752 | int err); | ||
752 | int tipc_msg_eval(struct net *net, struct sk_buff *buf, u32 *dnode); | 753 | int tipc_msg_eval(struct net *net, struct sk_buff *buf, u32 *dnode); |
753 | void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, u32 hsize, | 754 | void tipc_msg_init(struct net *net, struct tipc_msg *m, u32 user, u32 type, |
754 | u32 destnode); | 755 | u32 hsize, u32 destnode); |
755 | struct sk_buff *tipc_msg_create(uint user, uint type, uint hdr_sz, | 756 | struct sk_buff *tipc_msg_create(struct net *net, uint user, uint type, |
756 | uint data_sz, u32 dnode, u32 onode, | 757 | uint hdr_sz, uint data_sz, u32 dnode, |
757 | u32 dport, u32 oport, int errcode); | 758 | u32 onode, u32 dport, u32 oport, int errcode); |
758 | int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf); | 759 | int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf); |
759 | bool tipc_msg_bundle(struct sk_buff_head *list, struct sk_buff *skb, u32 mtu); | 760 | bool tipc_msg_bundle(struct sk_buff_head *list, struct sk_buff *skb, u32 mtu); |
760 | bool tipc_msg_make_bundle(struct sk_buff_head *list, struct sk_buff *skb, | 761 | bool tipc_msg_make_bundle(struct net *net, struct sk_buff_head *list, |
761 | u32 mtu, u32 dnode); | 762 | struct sk_buff *skb, u32 mtu, u32 dnode); |
762 | int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m, int offset, | 763 | int tipc_msg_build(struct net *net, struct tipc_msg *mhdr, struct msghdr *m, |
763 | int dsz, int mtu, struct sk_buff_head *list); | 764 | int offset, int dsz, int mtu, struct sk_buff_head *list); |
764 | struct sk_buff *tipc_msg_reassemble(struct sk_buff_head *list); | 765 | struct sk_buff *tipc_msg_reassemble(struct sk_buff_head *list); |
765 | 766 | ||
766 | #endif | 767 | #endif |
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c index ba421321d15d..7f31cd4badc4 100644 --- a/net/tipc/name_distr.c +++ b/net/tipc/name_distr.c | |||
@@ -68,14 +68,16 @@ static void publ_to_item(struct distr_item *i, struct publication *p) | |||
68 | /** | 68 | /** |
69 | * named_prepare_buf - allocate & initialize a publication message | 69 | * named_prepare_buf - allocate & initialize a publication message |
70 | */ | 70 | */ |
71 | static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest) | 71 | static struct sk_buff *named_prepare_buf(struct net *net, u32 type, u32 size, |
72 | u32 dest) | ||
72 | { | 73 | { |
73 | struct sk_buff *buf = tipc_buf_acquire(INT_H_SIZE + size); | 74 | struct sk_buff *buf = tipc_buf_acquire(INT_H_SIZE + size); |
74 | struct tipc_msg *msg; | 75 | struct tipc_msg *msg; |
75 | 76 | ||
76 | if (buf != NULL) { | 77 | if (buf != NULL) { |
77 | msg = buf_msg(buf); | 78 | msg = buf_msg(buf); |
78 | tipc_msg_init(msg, NAME_DISTRIBUTOR, type, INT_H_SIZE, dest); | 79 | tipc_msg_init(net, msg, NAME_DISTRIBUTOR, type, INT_H_SIZE, |
80 | dest); | ||
79 | msg_set_size(msg, INT_H_SIZE + size); | 81 | msg_set_size(msg, INT_H_SIZE + size); |
80 | } | 82 | } |
81 | return buf; | 83 | return buf; |
@@ -91,7 +93,7 @@ void named_cluster_distribute(struct net *net, struct sk_buff *skb) | |||
91 | rcu_read_lock(); | 93 | rcu_read_lock(); |
92 | list_for_each_entry_rcu(node, &tn->node_list, list) { | 94 | list_for_each_entry_rcu(node, &tn->node_list, list) { |
93 | dnode = node->addr; | 95 | dnode = node->addr; |
94 | if (in_own_node(dnode)) | 96 | if (in_own_node(net, dnode)) |
95 | continue; | 97 | continue; |
96 | if (!tipc_node_active_links(node)) | 98 | if (!tipc_node_active_links(node)) |
97 | continue; | 99 | continue; |
@@ -121,7 +123,7 @@ struct sk_buff *tipc_named_publish(struct net *net, struct publication *publ) | |||
121 | if (publ->scope == TIPC_NODE_SCOPE) | 123 | if (publ->scope == TIPC_NODE_SCOPE) |
122 | return NULL; | 124 | return NULL; |
123 | 125 | ||
124 | buf = named_prepare_buf(PUBLICATION, ITEM_SIZE, 0); | 126 | buf = named_prepare_buf(net, PUBLICATION, ITEM_SIZE, 0); |
125 | if (!buf) { | 127 | if (!buf) { |
126 | pr_warn("Publication distribution failure\n"); | 128 | pr_warn("Publication distribution failure\n"); |
127 | return NULL; | 129 | return NULL; |
@@ -135,7 +137,7 @@ struct sk_buff *tipc_named_publish(struct net *net, struct publication *publ) | |||
135 | /** | 137 | /** |
136 | * tipc_named_withdraw - tell other nodes about a withdrawn publication by this node | 138 | * tipc_named_withdraw - tell other nodes about a withdrawn publication by this node |
137 | */ | 139 | */ |
138 | struct sk_buff *tipc_named_withdraw(struct publication *publ) | 140 | struct sk_buff *tipc_named_withdraw(struct net *net, struct publication *publ) |
139 | { | 141 | { |
140 | struct sk_buff *buf; | 142 | struct sk_buff *buf; |
141 | struct distr_item *item; | 143 | struct distr_item *item; |
@@ -145,7 +147,7 @@ struct sk_buff *tipc_named_withdraw(struct publication *publ) | |||
145 | if (publ->scope == TIPC_NODE_SCOPE) | 147 | if (publ->scope == TIPC_NODE_SCOPE) |
146 | return NULL; | 148 | return NULL; |
147 | 149 | ||
148 | buf = named_prepare_buf(WITHDRAWAL, ITEM_SIZE, 0); | 150 | buf = named_prepare_buf(net, WITHDRAWAL, ITEM_SIZE, 0); |
149 | if (!buf) { | 151 | if (!buf) { |
150 | pr_warn("Withdrawal distribution failure\n"); | 152 | pr_warn("Withdrawal distribution failure\n"); |
151 | return NULL; | 153 | return NULL; |
@@ -175,7 +177,8 @@ static void named_distribute(struct net *net, struct sk_buff_head *list, | |||
175 | list_for_each_entry(publ, pls, local_list) { | 177 | list_for_each_entry(publ, pls, local_list) { |
176 | /* Prepare next buffer: */ | 178 | /* Prepare next buffer: */ |
177 | if (!skb) { | 179 | if (!skb) { |
178 | skb = named_prepare_buf(PUBLICATION, msg_rem, dnode); | 180 | skb = named_prepare_buf(net, PUBLICATION, msg_rem, |
181 | dnode); | ||
179 | if (!skb) { | 182 | if (!skb) { |
180 | pr_warn("Bulk publication failure\n"); | 183 | pr_warn("Bulk publication failure\n"); |
181 | return; | 184 | return; |
@@ -227,7 +230,7 @@ static void tipc_publ_subscribe(struct net *net, struct publication *publ, | |||
227 | { | 230 | { |
228 | struct tipc_node *node; | 231 | struct tipc_node *node; |
229 | 232 | ||
230 | if (in_own_node(addr)) | 233 | if (in_own_node(net, addr)) |
231 | return; | 234 | return; |
232 | 235 | ||
233 | node = tipc_node_find(net, addr); | 236 | node = tipc_node_find(net, addr); |
@@ -416,7 +419,7 @@ void tipc_named_reinit(struct net *net) | |||
416 | for (scope = TIPC_ZONE_SCOPE; scope <= TIPC_NODE_SCOPE; scope++) | 419 | for (scope = TIPC_ZONE_SCOPE; scope <= TIPC_NODE_SCOPE; scope++) |
417 | list_for_each_entry_rcu(publ, &tn->nametbl->publ_list[scope], | 420 | list_for_each_entry_rcu(publ, &tn->nametbl->publ_list[scope], |
418 | local_list) | 421 | local_list) |
419 | publ->node = tipc_own_addr; | 422 | publ->node = tn->own_addr; |
420 | 423 | ||
421 | spin_unlock_bh(&tn->nametbl_lock); | 424 | spin_unlock_bh(&tn->nametbl_lock); |
422 | } | 425 | } |
diff --git a/net/tipc/name_distr.h b/net/tipc/name_distr.h index 1ed2d7e48290..5ec10b59527b 100644 --- a/net/tipc/name_distr.h +++ b/net/tipc/name_distr.h | |||
@@ -68,7 +68,7 @@ struct distr_item { | |||
68 | }; | 68 | }; |
69 | 69 | ||
70 | struct sk_buff *tipc_named_publish(struct net *net, struct publication *publ); | 70 | struct sk_buff *tipc_named_publish(struct net *net, struct publication *publ); |
71 | struct sk_buff *tipc_named_withdraw(struct publication *publ); | 71 | struct sk_buff *tipc_named_withdraw(struct net *net, struct publication *publ); |
72 | void named_cluster_distribute(struct net *net, struct sk_buff *buf); | 72 | void named_cluster_distribute(struct net *net, struct sk_buff *buf); |
73 | void tipc_named_node_up(struct net *net, u32 dnode); | 73 | void tipc_named_node_up(struct net *net, u32 dnode); |
74 | void tipc_named_rcv(struct net *net, struct sk_buff *buf); | 74 | void tipc_named_rcv(struct net *net, struct sk_buff *buf); |
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index 57e39c16a8c3..ce09b863528c 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c | |||
@@ -227,9 +227,11 @@ static u32 nameseq_locate_subseq(struct name_seq *nseq, u32 instance) | |||
227 | /** | 227 | /** |
228 | * tipc_nameseq_insert_publ | 228 | * tipc_nameseq_insert_publ |
229 | */ | 229 | */ |
230 | static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | 230 | static struct publication *tipc_nameseq_insert_publ(struct net *net, |
231 | u32 type, u32 lower, u32 upper, | 231 | struct name_seq *nseq, |
232 | u32 scope, u32 node, u32 port, u32 key) | 232 | u32 type, u32 lower, |
233 | u32 upper, u32 scope, | ||
234 | u32 node, u32 port, u32 key) | ||
233 | { | 235 | { |
234 | struct tipc_subscription *s; | 236 | struct tipc_subscription *s; |
235 | struct tipc_subscription *st; | 237 | struct tipc_subscription *st; |
@@ -314,12 +316,12 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
314 | list_add(&publ->zone_list, &info->zone_list); | 316 | list_add(&publ->zone_list, &info->zone_list); |
315 | info->zone_list_size++; | 317 | info->zone_list_size++; |
316 | 318 | ||
317 | if (in_own_cluster(node)) { | 319 | if (in_own_cluster(net, node)) { |
318 | list_add(&publ->cluster_list, &info->cluster_list); | 320 | list_add(&publ->cluster_list, &info->cluster_list); |
319 | info->cluster_list_size++; | 321 | info->cluster_list_size++; |
320 | } | 322 | } |
321 | 323 | ||
322 | if (in_own_node(node)) { | 324 | if (in_own_node(net, node)) { |
323 | list_add(&publ->node_list, &info->node_list); | 325 | list_add(&publ->node_list, &info->node_list); |
324 | info->node_list_size++; | 326 | info->node_list_size++; |
325 | } | 327 | } |
@@ -348,8 +350,10 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, | |||
348 | * A failed withdraw request simply returns a failure indication and lets the | 350 | * A failed withdraw request simply returns a failure indication and lets the |
349 | * caller issue any error or warning messages associated with such a problem. | 351 | * caller issue any error or warning messages associated with such a problem. |
350 | */ | 352 | */ |
351 | static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 inst, | 353 | static struct publication *tipc_nameseq_remove_publ(struct net *net, |
352 | u32 node, u32 ref, u32 key) | 354 | struct name_seq *nseq, |
355 | u32 inst, u32 node, | ||
356 | u32 ref, u32 key) | ||
353 | { | 357 | { |
354 | struct publication *publ; | 358 | struct publication *publ; |
355 | struct sub_seq *sseq = nameseq_find_subseq(nseq, inst); | 359 | struct sub_seq *sseq = nameseq_find_subseq(nseq, inst); |
@@ -377,13 +381,13 @@ found: | |||
377 | info->zone_list_size--; | 381 | info->zone_list_size--; |
378 | 382 | ||
379 | /* Remove publication from cluster scope list, if present */ | 383 | /* Remove publication from cluster scope list, if present */ |
380 | if (in_own_cluster(node)) { | 384 | if (in_own_cluster(net, node)) { |
381 | list_del(&publ->cluster_list); | 385 | list_del(&publ->cluster_list); |
382 | info->cluster_list_size--; | 386 | info->cluster_list_size--; |
383 | } | 387 | } |
384 | 388 | ||
385 | /* Remove publication from node scope list, if present */ | 389 | /* Remove publication from node scope list, if present */ |
386 | if (in_own_node(node)) { | 390 | if (in_own_node(net, node)) { |
387 | list_del(&publ->node_list); | 391 | list_del(&publ->node_list); |
388 | info->node_list_size--; | 392 | info->node_list_size--; |
389 | } | 393 | } |
@@ -483,7 +487,7 @@ struct publication *tipc_nametbl_insert_publ(struct net *net, u32 type, | |||
483 | return NULL; | 487 | return NULL; |
484 | 488 | ||
485 | spin_lock_bh(&seq->lock); | 489 | spin_lock_bh(&seq->lock); |
486 | publ = tipc_nameseq_insert_publ(seq, type, lower, upper, | 490 | publ = tipc_nameseq_insert_publ(net, seq, type, lower, upper, |
487 | scope, node, port, key); | 491 | scope, node, port, key); |
488 | spin_unlock_bh(&seq->lock); | 492 | spin_unlock_bh(&seq->lock); |
489 | return publ; | 493 | return publ; |
@@ -500,7 +504,7 @@ struct publication *tipc_nametbl_remove_publ(struct net *net, u32 type, | |||
500 | return NULL; | 504 | return NULL; |
501 | 505 | ||
502 | spin_lock_bh(&seq->lock); | 506 | spin_lock_bh(&seq->lock); |
503 | publ = tipc_nameseq_remove_publ(seq, lower, node, ref, key); | 507 | publ = tipc_nameseq_remove_publ(net, seq, lower, node, ref, key); |
504 | if (!seq->first_free && list_empty(&seq->subscriptions)) { | 508 | if (!seq->first_free && list_empty(&seq->subscriptions)) { |
505 | hlist_del_init_rcu(&seq->ns_list); | 509 | hlist_del_init_rcu(&seq->ns_list); |
506 | kfree(seq->sseqs); | 510 | kfree(seq->sseqs); |
@@ -528,6 +532,7 @@ struct publication *tipc_nametbl_remove_publ(struct net *net, u32 type, | |||
528 | u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance, | 532 | u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance, |
529 | u32 *destnode) | 533 | u32 *destnode) |
530 | { | 534 | { |
535 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
531 | struct sub_seq *sseq; | 536 | struct sub_seq *sseq; |
532 | struct name_info *info; | 537 | struct name_info *info; |
533 | struct publication *publ; | 538 | struct publication *publ; |
@@ -535,7 +540,7 @@ u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance, | |||
535 | u32 ref = 0; | 540 | u32 ref = 0; |
536 | u32 node = 0; | 541 | u32 node = 0; |
537 | 542 | ||
538 | if (!tipc_in_scope(*destnode, tipc_own_addr)) | 543 | if (!tipc_in_scope(*destnode, tn->own_addr)) |
539 | return 0; | 544 | return 0; |
540 | 545 | ||
541 | rcu_read_lock(); | 546 | rcu_read_lock(); |
@@ -572,13 +577,13 @@ u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance, | |||
572 | } | 577 | } |
573 | 578 | ||
574 | /* Round-Robin Algorithm */ | 579 | /* Round-Robin Algorithm */ |
575 | else if (*destnode == tipc_own_addr) { | 580 | else if (*destnode == tn->own_addr) { |
576 | if (list_empty(&info->node_list)) | 581 | if (list_empty(&info->node_list)) |
577 | goto no_match; | 582 | goto no_match; |
578 | publ = list_first_entry(&info->node_list, struct publication, | 583 | publ = list_first_entry(&info->node_list, struct publication, |
579 | node_list); | 584 | node_list); |
580 | list_move_tail(&publ->node_list, &info->node_list); | 585 | list_move_tail(&publ->node_list, &info->node_list); |
581 | } else if (in_own_cluster_exact(*destnode)) { | 586 | } else if (in_own_cluster_exact(net, *destnode)) { |
582 | if (list_empty(&info->cluster_list)) | 587 | if (list_empty(&info->cluster_list)) |
583 | goto no_match; | 588 | goto no_match; |
584 | publ = list_first_entry(&info->cluster_list, struct publication, | 589 | publ = list_first_entry(&info->cluster_list, struct publication, |
@@ -670,7 +675,7 @@ struct publication *tipc_nametbl_publish(struct net *net, u32 type, u32 lower, | |||
670 | } | 675 | } |
671 | 676 | ||
672 | publ = tipc_nametbl_insert_publ(net, type, lower, upper, scope, | 677 | publ = tipc_nametbl_insert_publ(net, type, lower, upper, scope, |
673 | tipc_own_addr, port_ref, key); | 678 | tn->own_addr, port_ref, key); |
674 | if (likely(publ)) { | 679 | if (likely(publ)) { |
675 | tn->nametbl->local_publ_count++; | 680 | tn->nametbl->local_publ_count++; |
676 | buf = tipc_named_publish(net, publ); | 681 | buf = tipc_named_publish(net, publ); |
@@ -695,11 +700,11 @@ int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref, | |||
695 | struct tipc_net *tn = net_generic(net, tipc_net_id); | 700 | struct tipc_net *tn = net_generic(net, tipc_net_id); |
696 | 701 | ||
697 | spin_lock_bh(&tn->nametbl_lock); | 702 | spin_lock_bh(&tn->nametbl_lock); |
698 | publ = tipc_nametbl_remove_publ(net, type, lower, tipc_own_addr, | 703 | publ = tipc_nametbl_remove_publ(net, type, lower, tn->own_addr, |
699 | ref, key); | 704 | ref, key); |
700 | if (likely(publ)) { | 705 | if (likely(publ)) { |
701 | tn->nametbl->local_publ_count--; | 706 | tn->nametbl->local_publ_count--; |
702 | skb = tipc_named_withdraw(publ); | 707 | skb = tipc_named_withdraw(net, publ); |
703 | /* Any pending external events? */ | 708 | /* Any pending external events? */ |
704 | tipc_named_process_backlog(net); | 709 | tipc_named_process_backlog(net); |
705 | list_del_init(&publ->pport_list); | 710 | list_del_init(&publ->pport_list); |
diff --git a/net/tipc/net.c b/net/tipc/net.c index 04445d210e45..263267e0e7fe 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c | |||
@@ -115,30 +115,32 @@ int tipc_net_start(struct net *net, u32 addr) | |||
115 | char addr_string[16]; | 115 | char addr_string[16]; |
116 | int res; | 116 | int res; |
117 | 117 | ||
118 | tipc_own_addr = addr; | 118 | tn->own_addr = addr; |
119 | tipc_named_reinit(net); | 119 | tipc_named_reinit(net); |
120 | tipc_sk_reinit(net); | 120 | tipc_sk_reinit(net); |
121 | res = tipc_bclink_init(net); | 121 | res = tipc_bclink_init(net); |
122 | if (res) | 122 | if (res) |
123 | return res; | 123 | return res; |
124 | 124 | ||
125 | tipc_nametbl_publish(net, TIPC_CFG_SRV, tipc_own_addr, tipc_own_addr, | 125 | tipc_nametbl_publish(net, TIPC_CFG_SRV, tn->own_addr, tn->own_addr, |
126 | TIPC_ZONE_SCOPE, 0, tipc_own_addr); | 126 | TIPC_ZONE_SCOPE, 0, tn->own_addr); |
127 | 127 | ||
128 | pr_info("Started in network mode\n"); | 128 | pr_info("Started in network mode\n"); |
129 | pr_info("Own node address %s, network identity %u\n", | 129 | pr_info("Own node address %s, network identity %u\n", |
130 | tipc_addr_string_fill(addr_string, tipc_own_addr), | 130 | tipc_addr_string_fill(addr_string, tn->own_addr), |
131 | tn->net_id); | 131 | tn->net_id); |
132 | return 0; | 132 | return 0; |
133 | } | 133 | } |
134 | 134 | ||
135 | void tipc_net_stop(struct net *net) | 135 | void tipc_net_stop(struct net *net) |
136 | { | 136 | { |
137 | if (!tipc_own_addr) | 137 | struct tipc_net *tn = net_generic(net, tipc_net_id); |
138 | |||
139 | if (!tn->own_addr) | ||
138 | return; | 140 | return; |
139 | 141 | ||
140 | tipc_nametbl_withdraw(net, TIPC_CFG_SRV, tipc_own_addr, 0, | 142 | tipc_nametbl_withdraw(net, TIPC_CFG_SRV, tn->own_addr, 0, |
141 | tipc_own_addr); | 143 | tn->own_addr); |
142 | rtnl_lock(); | 144 | rtnl_lock(); |
143 | tipc_bearer_stop(net); | 145 | tipc_bearer_stop(net); |
144 | tipc_bclink_stop(net); | 146 | tipc_bclink_stop(net); |
@@ -224,7 +226,7 @@ int tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info) | |||
224 | u32 val; | 226 | u32 val; |
225 | 227 | ||
226 | /* Can't change net id once TIPC has joined a network */ | 228 | /* Can't change net id once TIPC has joined a network */ |
227 | if (tipc_own_addr) | 229 | if (tn->own_addr) |
228 | return -EPERM; | 230 | return -EPERM; |
229 | 231 | ||
230 | val = nla_get_u32(attrs[TIPC_NLA_NET_ID]); | 232 | val = nla_get_u32(attrs[TIPC_NLA_NET_ID]); |
@@ -238,7 +240,7 @@ int tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info) | |||
238 | u32 addr; | 240 | u32 addr; |
239 | 241 | ||
240 | /* Can't change net addr once TIPC has joined a network */ | 242 | /* Can't change net addr once TIPC has joined a network */ |
241 | if (tipc_own_addr) | 243 | if (tn->own_addr) |
242 | return -EPERM; | 244 | return -EPERM; |
243 | 245 | ||
244 | addr = nla_get_u32(attrs[TIPC_NLA_NET_ADDR]); | 246 | addr = nla_get_u32(attrs[TIPC_NLA_NET_ADDR]); |
diff --git a/net/tipc/node.c b/net/tipc/node.c index 3db501260de1..b1eb0927bac8 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
@@ -75,7 +75,7 @@ struct tipc_node *tipc_node_find(struct net *net, u32 addr) | |||
75 | struct tipc_net *tn = net_generic(net, tipc_net_id); | 75 | struct tipc_net *tn = net_generic(net, tipc_net_id); |
76 | struct tipc_node *node; | 76 | struct tipc_node *node; |
77 | 77 | ||
78 | if (unlikely(!in_own_cluster_exact(addr))) | 78 | if (unlikely(!in_own_cluster_exact(net, addr))) |
79 | return NULL; | 79 | return NULL; |
80 | 80 | ||
81 | rcu_read_lock(); | 81 | rcu_read_lock(); |
@@ -155,7 +155,7 @@ int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port) | |||
155 | struct tipc_node *node; | 155 | struct tipc_node *node; |
156 | struct tipc_sock_conn *conn; | 156 | struct tipc_sock_conn *conn; |
157 | 157 | ||
158 | if (in_own_node(dnode)) | 158 | if (in_own_node(net, dnode)) |
159 | return 0; | 159 | return 0; |
160 | 160 | ||
161 | node = tipc_node_find(net, dnode); | 161 | node = tipc_node_find(net, dnode); |
@@ -181,7 +181,7 @@ void tipc_node_remove_conn(struct net *net, u32 dnode, u32 port) | |||
181 | struct tipc_node *node; | 181 | struct tipc_node *node; |
182 | struct tipc_sock_conn *conn, *safe; | 182 | struct tipc_sock_conn *conn, *safe; |
183 | 183 | ||
184 | if (in_own_node(dnode)) | 184 | if (in_own_node(net, dnode)) |
185 | return; | 185 | return; |
186 | 186 | ||
187 | node = tipc_node_find(net, dnode); | 187 | node = tipc_node_find(net, dnode); |
@@ -200,14 +200,16 @@ void tipc_node_remove_conn(struct net *net, u32 dnode, u32 port) | |||
200 | 200 | ||
201 | void tipc_node_abort_sock_conns(struct net *net, struct list_head *conns) | 201 | void tipc_node_abort_sock_conns(struct net *net, struct list_head *conns) |
202 | { | 202 | { |
203 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
203 | struct tipc_sock_conn *conn, *safe; | 204 | struct tipc_sock_conn *conn, *safe; |
204 | struct sk_buff *buf; | 205 | struct sk_buff *buf; |
205 | 206 | ||
206 | list_for_each_entry_safe(conn, safe, conns, list) { | 207 | list_for_each_entry_safe(conn, safe, conns, list) { |
207 | buf = tipc_msg_create(TIPC_CRITICAL_IMPORTANCE, TIPC_CONN_MSG, | 208 | buf = tipc_msg_create(net, TIPC_CRITICAL_IMPORTANCE, |
208 | SHORT_H_SIZE, 0, tipc_own_addr, | 209 | TIPC_CONN_MSG, SHORT_H_SIZE, 0, |
209 | conn->peer_node, conn->port, | 210 | tn->own_addr, conn->peer_node, |
210 | conn->peer_port, TIPC_ERR_NO_NODE); | 211 | conn->port, conn->peer_port, |
212 | TIPC_ERR_NO_NODE); | ||
211 | if (likely(buf)) | 213 | if (likely(buf)) |
212 | tipc_sk_rcv(net, buf); | 214 | tipc_sk_rcv(net, buf); |
213 | list_del(&conn->list); | 215 | list_del(&conn->list); |
@@ -287,6 +289,7 @@ static void node_select_active_links(struct tipc_node *n_ptr) | |||
287 | */ | 289 | */ |
288 | void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr) | 290 | void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr) |
289 | { | 291 | { |
292 | struct tipc_net *tn = net_generic(n_ptr->net, tipc_net_id); | ||
290 | struct tipc_link **active; | 293 | struct tipc_link **active; |
291 | 294 | ||
292 | n_ptr->working_links--; | 295 | n_ptr->working_links--; |
@@ -321,7 +324,7 @@ void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr) | |||
321 | } | 324 | } |
322 | 325 | ||
323 | /* Loopback link went down? No fragmentation needed from now on. */ | 326 | /* Loopback link went down? No fragmentation needed from now on. */ |
324 | if (n_ptr->addr == tipc_own_addr) { | 327 | if (n_ptr->addr == tn->own_addr) { |
325 | n_ptr->act_mtus[0] = MAX_MSG_SIZE; | 328 | n_ptr->act_mtus[0] = MAX_MSG_SIZE; |
326 | n_ptr->act_mtus[1] = MAX_MSG_SIZE; | 329 | n_ptr->act_mtus[1] = MAX_MSG_SIZE; |
327 | } | 330 | } |
@@ -483,7 +486,7 @@ struct sk_buff *tipc_node_get_links(struct net *net, const void *req_tlv_area, | |||
483 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE | 486 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE |
484 | " (network address)"); | 487 | " (network address)"); |
485 | 488 | ||
486 | if (!tipc_own_addr) | 489 | if (!tn->own_addr) |
487 | return tipc_cfg_reply_none(); | 490 | return tipc_cfg_reply_none(); |
488 | 491 | ||
489 | spin_lock_bh(&tn->node_list_lock); | 492 | spin_lock_bh(&tn->node_list_lock); |
@@ -501,7 +504,7 @@ struct sk_buff *tipc_node_get_links(struct net *net, const void *req_tlv_area, | |||
501 | return NULL; | 504 | return NULL; |
502 | 505 | ||
503 | /* Add TLV for broadcast link */ | 506 | /* Add TLV for broadcast link */ |
504 | link_info.dest = htonl(tipc_cluster_mask(tipc_own_addr)); | 507 | link_info.dest = htonl(tipc_cluster_mask(tn->own_addr)); |
505 | link_info.up = htonl(1); | 508 | link_info.up = htonl(1); |
506 | strlcpy(link_info.str, tipc_bclink_name, TIPC_MAX_LINK_NAME); | 509 | strlcpy(link_info.str, tipc_bclink_name, TIPC_MAX_LINK_NAME); |
507 | tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info)); | 510 | tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info)); |
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 4670e1e46c89..9b8470edc783 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -251,10 +251,11 @@ static void tsk_rej_rx_queue(struct sock *sk) | |||
251 | { | 251 | { |
252 | struct sk_buff *skb; | 252 | struct sk_buff *skb; |
253 | u32 dnode; | 253 | u32 dnode; |
254 | struct net *net = sock_net(sk); | ||
254 | 255 | ||
255 | while ((skb = __skb_dequeue(&sk->sk_receive_queue))) { | 256 | while ((skb = __skb_dequeue(&sk->sk_receive_queue))) { |
256 | if (tipc_msg_reverse(skb, &dnode, TIPC_ERR_NO_PORT)) | 257 | if (tipc_msg_reverse(net, skb, &dnode, TIPC_ERR_NO_PORT)) |
257 | tipc_link_xmit_skb(sock_net(sk), skb, dnode, 0); | 258 | tipc_link_xmit_skb(net, skb, dnode, 0); |
258 | } | 259 | } |
259 | } | 260 | } |
260 | 261 | ||
@@ -265,6 +266,7 @@ static void tsk_rej_rx_queue(struct sock *sk) | |||
265 | */ | 266 | */ |
266 | static bool tsk_peer_msg(struct tipc_sock *tsk, struct tipc_msg *msg) | 267 | static bool tsk_peer_msg(struct tipc_sock *tsk, struct tipc_msg *msg) |
267 | { | 268 | { |
269 | struct tipc_net *tn = net_generic(sock_net(&tsk->sk), tipc_net_id); | ||
268 | u32 peer_port = tsk_peer_port(tsk); | 270 | u32 peer_port = tsk_peer_port(tsk); |
269 | u32 orig_node; | 271 | u32 orig_node; |
270 | u32 peer_node; | 272 | u32 peer_node; |
@@ -281,10 +283,10 @@ static bool tsk_peer_msg(struct tipc_sock *tsk, struct tipc_msg *msg) | |||
281 | if (likely(orig_node == peer_node)) | 283 | if (likely(orig_node == peer_node)) |
282 | return true; | 284 | return true; |
283 | 285 | ||
284 | if (!orig_node && (peer_node == tipc_own_addr)) | 286 | if (!orig_node && (peer_node == tn->own_addr)) |
285 | return true; | 287 | return true; |
286 | 288 | ||
287 | if (!peer_node && (orig_node == tipc_own_addr)) | 289 | if (!peer_node && (orig_node == tn->own_addr)) |
288 | return true; | 290 | return true; |
289 | 291 | ||
290 | return false; | 292 | return false; |
@@ -346,7 +348,7 @@ static int tipc_sk_create(struct net *net, struct socket *sock, | |||
346 | tsk->max_pkt = MAX_PKT_DEFAULT; | 348 | tsk->max_pkt = MAX_PKT_DEFAULT; |
347 | INIT_LIST_HEAD(&tsk->publications); | 349 | INIT_LIST_HEAD(&tsk->publications); |
348 | msg = &tsk->phdr; | 350 | msg = &tsk->phdr; |
349 | tipc_msg_init(msg, TIPC_LOW_IMPORTANCE, TIPC_NAMED_MSG, | 351 | tipc_msg_init(net, msg, TIPC_LOW_IMPORTANCE, TIPC_NAMED_MSG, |
350 | NAMED_H_SIZE, 0); | 352 | NAMED_H_SIZE, 0); |
351 | 353 | ||
352 | /* Finish initializing socket data structures */ | 354 | /* Finish initializing socket data structures */ |
@@ -471,6 +473,7 @@ static int tipc_release(struct socket *sock) | |||
471 | { | 473 | { |
472 | struct sock *sk = sock->sk; | 474 | struct sock *sk = sock->sk; |
473 | struct net *net = sock_net(sk); | 475 | struct net *net = sock_net(sk); |
476 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
474 | struct tipc_sock *tsk; | 477 | struct tipc_sock *tsk; |
475 | struct sk_buff *skb; | 478 | struct sk_buff *skb; |
476 | u32 dnode, probing_state; | 479 | u32 dnode, probing_state; |
@@ -503,7 +506,8 @@ static int tipc_release(struct socket *sock) | |||
503 | tsk->connected = 0; | 506 | tsk->connected = 0; |
504 | tipc_node_remove_conn(net, dnode, tsk->portid); | 507 | tipc_node_remove_conn(net, dnode, tsk->portid); |
505 | } | 508 | } |
506 | if (tipc_msg_reverse(skb, &dnode, TIPC_ERR_NO_PORT)) | 509 | if (tipc_msg_reverse(net, skb, &dnode, |
510 | TIPC_ERR_NO_PORT)) | ||
507 | tipc_link_xmit_skb(net, skb, dnode, 0); | 511 | tipc_link_xmit_skb(net, skb, dnode, 0); |
508 | } | 512 | } |
509 | } | 513 | } |
@@ -514,9 +518,9 @@ static int tipc_release(struct socket *sock) | |||
514 | sock_put(sk); | 518 | sock_put(sk); |
515 | tipc_sk_remove(tsk); | 519 | tipc_sk_remove(tsk); |
516 | if (tsk->connected) { | 520 | if (tsk->connected) { |
517 | skb = tipc_msg_create(TIPC_CRITICAL_IMPORTANCE, TIPC_CONN_MSG, | 521 | skb = tipc_msg_create(net, TIPC_CRITICAL_IMPORTANCE, |
518 | SHORT_H_SIZE, 0, dnode, tipc_own_addr, | 522 | TIPC_CONN_MSG, SHORT_H_SIZE, 0, dnode, |
519 | tsk_peer_port(tsk), | 523 | tn->own_addr, tsk_peer_port(tsk), |
520 | tsk->portid, TIPC_ERR_NO_PORT); | 524 | tsk->portid, TIPC_ERR_NO_PORT); |
521 | if (skb) | 525 | if (skb) |
522 | tipc_link_xmit_skb(net, skb, dnode, tsk->portid); | 526 | tipc_link_xmit_skb(net, skb, dnode, tsk->portid); |
@@ -614,6 +618,7 @@ static int tipc_getname(struct socket *sock, struct sockaddr *uaddr, | |||
614 | { | 618 | { |
615 | struct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr; | 619 | struct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr; |
616 | struct tipc_sock *tsk = tipc_sk(sock->sk); | 620 | struct tipc_sock *tsk = tipc_sk(sock->sk); |
621 | struct tipc_net *tn = net_generic(sock_net(sock->sk), tipc_net_id); | ||
617 | 622 | ||
618 | memset(addr, 0, sizeof(*addr)); | 623 | memset(addr, 0, sizeof(*addr)); |
619 | if (peer) { | 624 | if (peer) { |
@@ -624,7 +629,7 @@ static int tipc_getname(struct socket *sock, struct sockaddr *uaddr, | |||
624 | addr->addr.id.node = tsk_peer_node(tsk); | 629 | addr->addr.id.node = tsk_peer_node(tsk); |
625 | } else { | 630 | } else { |
626 | addr->addr.id.ref = tsk->portid; | 631 | addr->addr.id.ref = tsk->portid; |
627 | addr->addr.id.node = tipc_own_addr; | 632 | addr->addr.id.node = tn->own_addr; |
628 | } | 633 | } |
629 | 634 | ||
630 | *uaddr_len = sizeof(*addr); | 635 | *uaddr_len = sizeof(*addr); |
@@ -741,7 +746,7 @@ static int tipc_sendmcast(struct socket *sock, struct tipc_name_seq *seq, | |||
741 | new_mtu: | 746 | new_mtu: |
742 | mtu = tipc_bclink_get_mtu(); | 747 | mtu = tipc_bclink_get_mtu(); |
743 | __skb_queue_head_init(&head); | 748 | __skb_queue_head_init(&head); |
744 | rc = tipc_msg_build(mhdr, msg, 0, dsz, mtu, &head); | 749 | rc = tipc_msg_build(net, mhdr, msg, 0, dsz, mtu, &head); |
745 | if (unlikely(rc < 0)) | 750 | if (unlikely(rc < 0)) |
746 | return rc; | 751 | return rc; |
747 | 752 | ||
@@ -774,7 +779,7 @@ void tipc_sk_mcast_rcv(struct net *net, struct sk_buff *buf) | |||
774 | uint i, last, dst = 0; | 779 | uint i, last, dst = 0; |
775 | u32 scope = TIPC_CLUSTER_SCOPE; | 780 | u32 scope = TIPC_CLUSTER_SCOPE; |
776 | 781 | ||
777 | if (in_own_node(msg_orignode(msg))) | 782 | if (in_own_node(net, msg_orignode(msg))) |
778 | scope = TIPC_NODE_SCOPE; | 783 | scope = TIPC_NODE_SCOPE; |
779 | 784 | ||
780 | /* Create destination port list: */ | 785 | /* Create destination port list: */ |
@@ -826,7 +831,7 @@ static int tipc_sk_proto_rcv(struct tipc_sock *tsk, u32 *dnode, | |||
826 | if (conn_cong) | 831 | if (conn_cong) |
827 | tsk->sk.sk_write_space(&tsk->sk); | 832 | tsk->sk.sk_write_space(&tsk->sk); |
828 | } else if (msg_type(msg) == CONN_PROBE) { | 833 | } else if (msg_type(msg) == CONN_PROBE) { |
829 | if (!tipc_msg_reverse(buf, dnode, TIPC_OK)) | 834 | if (!tipc_msg_reverse(sock_net(&tsk->sk), buf, dnode, TIPC_OK)) |
830 | return TIPC_OK; | 835 | return TIPC_OK; |
831 | msg_set_type(msg, CONN_PROBE_REPLY); | 836 | msg_set_type(msg, CONN_PROBE_REPLY); |
832 | return TIPC_FWD_MSG; | 837 | return TIPC_FWD_MSG; |
@@ -959,7 +964,7 @@ static int tipc_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
959 | new_mtu: | 964 | new_mtu: |
960 | mtu = tipc_node_get_mtu(net, dnode, tsk->portid); | 965 | mtu = tipc_node_get_mtu(net, dnode, tsk->portid); |
961 | __skb_queue_head_init(&head); | 966 | __skb_queue_head_init(&head); |
962 | rc = tipc_msg_build(mhdr, m, 0, dsz, mtu, &head); | 967 | rc = tipc_msg_build(net, mhdr, m, 0, dsz, mtu, &head); |
963 | if (rc < 0) | 968 | if (rc < 0) |
964 | goto exit; | 969 | goto exit; |
965 | 970 | ||
@@ -1074,7 +1079,7 @@ next: | |||
1074 | mtu = tsk->max_pkt; | 1079 | mtu = tsk->max_pkt; |
1075 | send = min_t(uint, dsz - sent, TIPC_MAX_USER_MSG_SIZE); | 1080 | send = min_t(uint, dsz - sent, TIPC_MAX_USER_MSG_SIZE); |
1076 | __skb_queue_head_init(&head); | 1081 | __skb_queue_head_init(&head); |
1077 | rc = tipc_msg_build(mhdr, m, sent, send, mtu, &head); | 1082 | rc = tipc_msg_build(net, mhdr, m, sent, send, mtu, &head); |
1078 | if (unlikely(rc < 0)) | 1083 | if (unlikely(rc < 0)) |
1079 | goto exit; | 1084 | goto exit; |
1080 | do { | 1085 | do { |
@@ -1246,6 +1251,7 @@ static int tipc_sk_anc_data_recv(struct msghdr *m, struct tipc_msg *msg, | |||
1246 | static void tipc_sk_send_ack(struct tipc_sock *tsk, uint ack) | 1251 | static void tipc_sk_send_ack(struct tipc_sock *tsk, uint ack) |
1247 | { | 1252 | { |
1248 | struct net *net = sock_net(&tsk->sk); | 1253 | struct net *net = sock_net(&tsk->sk); |
1254 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
1249 | struct sk_buff *skb = NULL; | 1255 | struct sk_buff *skb = NULL; |
1250 | struct tipc_msg *msg; | 1256 | struct tipc_msg *msg; |
1251 | u32 peer_port = tsk_peer_port(tsk); | 1257 | u32 peer_port = tsk_peer_port(tsk); |
@@ -1253,8 +1259,9 @@ static void tipc_sk_send_ack(struct tipc_sock *tsk, uint ack) | |||
1253 | 1259 | ||
1254 | if (!tsk->connected) | 1260 | if (!tsk->connected) |
1255 | return; | 1261 | return; |
1256 | skb = tipc_msg_create(CONN_MANAGER, CONN_ACK, INT_H_SIZE, 0, dnode, | 1262 | skb = tipc_msg_create(net, CONN_MANAGER, CONN_ACK, INT_H_SIZE, 0, |
1257 | tipc_own_addr, peer_port, tsk->portid, TIPC_OK); | 1263 | dnode, tn->own_addr, peer_port, tsk->portid, |
1264 | TIPC_OK); | ||
1258 | if (!skb) | 1265 | if (!skb) |
1259 | return; | 1266 | return; |
1260 | msg = buf_msg(skb); | 1267 | msg = buf_msg(skb); |
@@ -1726,6 +1733,7 @@ static int tipc_backlog_rcv(struct sock *sk, struct sk_buff *skb) | |||
1726 | int rc; | 1733 | int rc; |
1727 | u32 onode; | 1734 | u32 onode; |
1728 | struct tipc_sock *tsk = tipc_sk(sk); | 1735 | struct tipc_sock *tsk = tipc_sk(sk); |
1736 | struct net *net = sock_net(sk); | ||
1729 | uint truesize = skb->truesize; | 1737 | uint truesize = skb->truesize; |
1730 | 1738 | ||
1731 | rc = filter_rcv(sk, skb); | 1739 | rc = filter_rcv(sk, skb); |
@@ -1736,10 +1744,10 @@ static int tipc_backlog_rcv(struct sock *sk, struct sk_buff *skb) | |||
1736 | return 0; | 1744 | return 0; |
1737 | } | 1745 | } |
1738 | 1746 | ||
1739 | if ((rc < 0) && !tipc_msg_reverse(skb, &onode, -rc)) | 1747 | if ((rc < 0) && !tipc_msg_reverse(net, skb, &onode, -rc)) |
1740 | return 0; | 1748 | return 0; |
1741 | 1749 | ||
1742 | tipc_link_xmit_skb(sock_net(sk), skb, onode, 0); | 1750 | tipc_link_xmit_skb(net, skb, onode, 0); |
1743 | 1751 | ||
1744 | return 0; | 1752 | return 0; |
1745 | } | 1753 | } |
@@ -1784,7 +1792,7 @@ int tipc_sk_rcv(struct net *net, struct sk_buff *skb) | |||
1784 | if (likely(!rc)) | 1792 | if (likely(!rc)) |
1785 | return 0; | 1793 | return 0; |
1786 | exit: | 1794 | exit: |
1787 | if ((rc < 0) && !tipc_msg_reverse(skb, &dnode, -rc)) | 1795 | if ((rc < 0) && !tipc_msg_reverse(net, skb, &dnode, -rc)) |
1788 | return -EHOSTUNREACH; | 1796 | return -EHOSTUNREACH; |
1789 | 1797 | ||
1790 | tipc_link_xmit_skb(net, skb, dnode, 0); | 1798 | tipc_link_xmit_skb(net, skb, dnode, 0); |
@@ -2045,6 +2053,7 @@ static int tipc_shutdown(struct socket *sock, int how) | |||
2045 | { | 2053 | { |
2046 | struct sock *sk = sock->sk; | 2054 | struct sock *sk = sock->sk; |
2047 | struct net *net = sock_net(sk); | 2055 | struct net *net = sock_net(sk); |
2056 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
2048 | struct tipc_sock *tsk = tipc_sk(sk); | 2057 | struct tipc_sock *tsk = tipc_sk(sk); |
2049 | struct sk_buff *skb; | 2058 | struct sk_buff *skb; |
2050 | u32 dnode; | 2059 | u32 dnode; |
@@ -2067,15 +2076,16 @@ restart: | |||
2067 | kfree_skb(skb); | 2076 | kfree_skb(skb); |
2068 | goto restart; | 2077 | goto restart; |
2069 | } | 2078 | } |
2070 | if (tipc_msg_reverse(skb, &dnode, TIPC_CONN_SHUTDOWN)) | 2079 | if (tipc_msg_reverse(net, skb, &dnode, |
2080 | TIPC_CONN_SHUTDOWN)) | ||
2071 | tipc_link_xmit_skb(net, skb, dnode, | 2081 | tipc_link_xmit_skb(net, skb, dnode, |
2072 | tsk->portid); | 2082 | tsk->portid); |
2073 | tipc_node_remove_conn(net, dnode, tsk->portid); | 2083 | tipc_node_remove_conn(net, dnode, tsk->portid); |
2074 | } else { | 2084 | } else { |
2075 | dnode = tsk_peer_node(tsk); | 2085 | dnode = tsk_peer_node(tsk); |
2076 | skb = tipc_msg_create(TIPC_CRITICAL_IMPORTANCE, | 2086 | skb = tipc_msg_create(net, TIPC_CRITICAL_IMPORTANCE, |
2077 | TIPC_CONN_MSG, SHORT_H_SIZE, | 2087 | TIPC_CONN_MSG, SHORT_H_SIZE, |
2078 | 0, dnode, tipc_own_addr, | 2088 | 0, dnode, tn->own_addr, |
2079 | tsk_peer_port(tsk), | 2089 | tsk_peer_port(tsk), |
2080 | tsk->portid, TIPC_CONN_SHUTDOWN); | 2090 | tsk->portid, TIPC_CONN_SHUTDOWN); |
2081 | tipc_link_xmit_skb(net, skb, dnode, tsk->portid); | 2091 | tipc_link_xmit_skb(net, skb, dnode, tsk->portid); |
@@ -2107,6 +2117,8 @@ static void tipc_sk_timeout(unsigned long data) | |||
2107 | { | 2117 | { |
2108 | struct tipc_sock *tsk = (struct tipc_sock *)data; | 2118 | struct tipc_sock *tsk = (struct tipc_sock *)data; |
2109 | struct sock *sk = &tsk->sk; | 2119 | struct sock *sk = &tsk->sk; |
2120 | struct net *net = sock_net(sk); | ||
2121 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
2110 | struct sk_buff *skb = NULL; | 2122 | struct sk_buff *skb = NULL; |
2111 | u32 peer_port, peer_node; | 2123 | u32 peer_port, peer_node; |
2112 | 2124 | ||
@@ -2120,13 +2132,13 @@ static void tipc_sk_timeout(unsigned long data) | |||
2120 | 2132 | ||
2121 | if (tsk->probing_state == TIPC_CONN_PROBING) { | 2133 | if (tsk->probing_state == TIPC_CONN_PROBING) { |
2122 | /* Previous probe not answered -> self abort */ | 2134 | /* Previous probe not answered -> self abort */ |
2123 | skb = tipc_msg_create(TIPC_CRITICAL_IMPORTANCE, TIPC_CONN_MSG, | 2135 | skb = tipc_msg_create(net, TIPC_CRITICAL_IMPORTANCE, |
2124 | SHORT_H_SIZE, 0, tipc_own_addr, | 2136 | TIPC_CONN_MSG, SHORT_H_SIZE, 0, |
2125 | peer_node, tsk->portid, peer_port, | 2137 | tn->own_addr, peer_node, tsk->portid, |
2126 | TIPC_ERR_NO_PORT); | 2138 | peer_port, TIPC_ERR_NO_PORT); |
2127 | } else { | 2139 | } else { |
2128 | skb = tipc_msg_create(CONN_MANAGER, CONN_PROBE, INT_H_SIZE, | 2140 | skb = tipc_msg_create(net, CONN_MANAGER, CONN_PROBE, INT_H_SIZE, |
2129 | 0, peer_node, tipc_own_addr, | 2141 | 0, peer_node, tn->own_addr, |
2130 | peer_port, tsk->portid, TIPC_OK); | 2142 | peer_port, tsk->portid, TIPC_OK); |
2131 | tsk->probing_state = TIPC_CONN_PROBING; | 2143 | tsk->probing_state = TIPC_CONN_PROBING; |
2132 | if (!mod_timer(&tsk->timer, jiffies + tsk->probing_intv)) | 2144 | if (!mod_timer(&tsk->timer, jiffies + tsk->probing_intv)) |
@@ -2198,14 +2210,16 @@ static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope, | |||
2198 | static int tipc_sk_show(struct tipc_sock *tsk, char *buf, | 2210 | static int tipc_sk_show(struct tipc_sock *tsk, char *buf, |
2199 | int len, int full_id) | 2211 | int len, int full_id) |
2200 | { | 2212 | { |
2213 | struct net *net = sock_net(&tsk->sk); | ||
2214 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
2201 | struct publication *publ; | 2215 | struct publication *publ; |
2202 | int ret; | 2216 | int ret; |
2203 | 2217 | ||
2204 | if (full_id) | 2218 | if (full_id) |
2205 | ret = tipc_snprintf(buf, len, "<%u.%u.%u:%u>:", | 2219 | ret = tipc_snprintf(buf, len, "<%u.%u.%u:%u>:", |
2206 | tipc_zone(tipc_own_addr), | 2220 | tipc_zone(tn->own_addr), |
2207 | tipc_cluster(tipc_own_addr), | 2221 | tipc_cluster(tn->own_addr), |
2208 | tipc_node(tipc_own_addr), tsk->portid); | 2222 | tipc_node(tn->own_addr), tsk->portid); |
2209 | else | 2223 | else |
2210 | ret = tipc_snprintf(buf, len, "%-10u:", tsk->portid); | 2224 | ret = tipc_snprintf(buf, len, "%-10u:", tsk->portid); |
2211 | 2225 | ||
@@ -2296,8 +2310,8 @@ void tipc_sk_reinit(struct net *net) | |||
2296 | rht_for_each_entry_rcu(tsk, pos, tbl, i, node) { | 2310 | rht_for_each_entry_rcu(tsk, pos, tbl, i, node) { |
2297 | spin_lock_bh(&tsk->sk.sk_lock.slock); | 2311 | spin_lock_bh(&tsk->sk.sk_lock.slock); |
2298 | msg = &tsk->phdr; | 2312 | msg = &tsk->phdr; |
2299 | msg_set_prevnode(msg, tipc_own_addr); | 2313 | msg_set_prevnode(msg, tn->own_addr); |
2300 | msg_set_orignode(msg, tipc_own_addr); | 2314 | msg_set_orignode(msg, tn->own_addr); |
2301 | spin_unlock_bh(&tsk->sk.sk_lock.slock); | 2315 | spin_unlock_bh(&tsk->sk.sk_lock.slock); |
2302 | } | 2316 | } |
2303 | } | 2317 | } |
@@ -2691,6 +2705,8 @@ static int __tipc_nl_add_sk(struct sk_buff *skb, struct netlink_callback *cb, | |||
2691 | int err; | 2705 | int err; |
2692 | void *hdr; | 2706 | void *hdr; |
2693 | struct nlattr *attrs; | 2707 | struct nlattr *attrs; |
2708 | struct net *net = sock_net(skb->sk); | ||
2709 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
2694 | 2710 | ||
2695 | hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, | 2711 | hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, |
2696 | &tipc_genl_v2_family, NLM_F_MULTI, TIPC_NL_SOCK_GET); | 2712 | &tipc_genl_v2_family, NLM_F_MULTI, TIPC_NL_SOCK_GET); |
@@ -2702,7 +2718,7 @@ static int __tipc_nl_add_sk(struct sk_buff *skb, struct netlink_callback *cb, | |||
2702 | goto genlmsg_cancel; | 2718 | goto genlmsg_cancel; |
2703 | if (nla_put_u32(skb, TIPC_NLA_SOCK_REF, tsk->portid)) | 2719 | if (nla_put_u32(skb, TIPC_NLA_SOCK_REF, tsk->portid)) |
2704 | goto attr_msg_cancel; | 2720 | goto attr_msg_cancel; |
2705 | if (nla_put_u32(skb, TIPC_NLA_SOCK_ADDR, tipc_own_addr)) | 2721 | if (nla_put_u32(skb, TIPC_NLA_SOCK_ADDR, tn->own_addr)) |
2706 | goto attr_msg_cancel; | 2722 | goto attr_msg_cancel; |
2707 | 2723 | ||
2708 | if (tsk->connected) { | 2724 | if (tsk->connected) { |