aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/net.c
diff options
context:
space:
mode:
authorJon Maloy <jon.maloy@ericsson.com>2018-03-22 15:42:49 -0400
committerDavid S. Miller <davem@davemloft.net>2018-03-23 13:12:18 -0400
commit23fd3eace088ab1872ee59c19191a119ec779ac9 (patch)
tree9469f540f7bd0279b0359bff04362877bd28e27b /net/tipc/net.c
parentb89afb116ca2830cc982624f93e888860868a84b (diff)
tipc: remove direct accesses to own_addr field in struct tipc_net
As a preparation to changing the addressing structure of TIPC we replace all direct accesses to the tipc_net::own_addr field with the function dedicated for this, tipc_own_addr(). There are no changes to program logics in this commit. Acked-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/net.c')
-rw-r--r--net/tipc/net.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/net/tipc/net.c b/net/tipc/net.c
index eb0d7a352e3f..7f140a5308ee 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -106,7 +106,7 @@
106 106
107int tipc_net_start(struct net *net, u32 addr) 107int tipc_net_start(struct net *net, u32 addr)
108{ 108{
109 struct tipc_net *tn = net_generic(net, tipc_net_id); 109 struct tipc_net *tn = tipc_net(net);
110 char addr_string[16]; 110 char addr_string[16];
111 111
112 tn->own_addr = addr; 112 tn->own_addr = addr;
@@ -117,25 +117,24 @@ int tipc_net_start(struct net *net, u32 addr)
117 tipc_named_reinit(net); 117 tipc_named_reinit(net);
118 tipc_sk_reinit(net); 118 tipc_sk_reinit(net);
119 119
120 tipc_nametbl_publish(net, TIPC_CFG_SRV, tn->own_addr, tn->own_addr, 120 tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr,
121 TIPC_CLUSTER_SCOPE, 0, tn->own_addr); 121 TIPC_CLUSTER_SCOPE, 0, addr);
122 122
123 pr_info("Started in network mode\n"); 123 pr_info("Started in network mode\n");
124 pr_info("Own node address %s, cluster identity %u\n", 124 pr_info("Own node address %s, cluster identity %u\n",
125 tipc_addr_string_fill(addr_string, tn->own_addr), 125 tipc_addr_string_fill(addr_string, addr),
126 tn->net_id); 126 tn->net_id);
127 return 0; 127 return 0;
128} 128}
129 129
130void tipc_net_stop(struct net *net) 130void tipc_net_stop(struct net *net)
131{ 131{
132 struct tipc_net *tn = net_generic(net, tipc_net_id); 132 u32 self = tipc_own_addr(net);
133 133
134 if (!tn->own_addr) 134 if (!self)
135 return; 135 return;
136 136
137 tipc_nametbl_withdraw(net, TIPC_CFG_SRV, tn->own_addr, 0, 137 tipc_nametbl_withdraw(net, TIPC_CFG_SRV, self, 0, self);
138 tn->own_addr);
139 rtnl_lock(); 138 rtnl_lock();
140 tipc_bearer_stop(net); 139 tipc_bearer_stop(net);
141 tipc_node_stop(net); 140 tipc_node_stop(net);
@@ -202,9 +201,9 @@ out:
202 201
203int __tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info) 202int __tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info)
204{ 203{
205 struct net *net = sock_net(skb->sk);
206 struct tipc_net *tn = net_generic(net, tipc_net_id);
207 struct nlattr *attrs[TIPC_NLA_NET_MAX + 1]; 204 struct nlattr *attrs[TIPC_NLA_NET_MAX + 1];
205 struct net *net = sock_net(skb->sk);
206 struct tipc_net *tn = tipc_net(net);
208 int err; 207 int err;
209 208
210 if (!info->attrs[TIPC_NLA_NET]) 209 if (!info->attrs[TIPC_NLA_NET])
@@ -216,13 +215,13 @@ int __tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info)
216 if (err) 215 if (err)
217 return err; 216 return err;
218 217
218 /* Can't change net id once TIPC has joined a network */
219 if (tipc_own_addr(net))
220 return -EPERM;
221
219 if (attrs[TIPC_NLA_NET_ID]) { 222 if (attrs[TIPC_NLA_NET_ID]) {
220 u32 val; 223 u32 val;
221 224
222 /* Can't change net id once TIPC has joined a network */
223 if (tn->own_addr)
224 return -EPERM;
225
226 val = nla_get_u32(attrs[TIPC_NLA_NET_ID]); 225 val = nla_get_u32(attrs[TIPC_NLA_NET_ID]);
227 if (val < 1 || val > 9999) 226 if (val < 1 || val > 9999)
228 return -EINVAL; 227 return -EINVAL;
@@ -233,10 +232,6 @@ int __tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info)
233 if (attrs[TIPC_NLA_NET_ADDR]) { 232 if (attrs[TIPC_NLA_NET_ADDR]) {
234 u32 addr; 233 u32 addr;
235 234
236 /* Can't change net addr once TIPC has joined a network */
237 if (tn->own_addr)
238 return -EPERM;
239
240 addr = nla_get_u32(attrs[TIPC_NLA_NET_ADDR]); 235 addr = nla_get_u32(attrs[TIPC_NLA_NET_ADDR]);
241 if (!addr) 236 if (!addr)
242 return -EINVAL; 237 return -EINVAL;