diff options
author | Ying Xue <ying.xue@windriver.com> | 2015-01-09 02:27:04 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-01-12 16:24:32 -0500 |
commit | c93d3baa24095887005647984cff5de8c63d3611 (patch) | |
tree | 1c7917d92605991696960243fe97dfef9d14913a /net/tipc/net.c | |
parent | 54fef04ad05f15984082c225fe47ce6af8ea1c5c (diff) |
tipc: involve namespace infrastructure
Involve namespace infrastructure, make the "tipc_net_id" global
variable aware of per namespace, and rename it to "net_id". In
order that the conversion can be successfully done, an instance
of networking namespace must be passed to relevant functions,
allowing them to access the "net_id" variable of per 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>
Diffstat (limited to 'net/tipc/net.c')
-rw-r--r-- | net/tipc/net.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/net/tipc/net.c b/net/tipc/net.c index cf13df3cde8f..5ce9d628f2d0 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c | |||
@@ -108,8 +108,9 @@ static const struct nla_policy tipc_nl_net_policy[TIPC_NLA_NET_MAX + 1] = { | |||
108 | * - A local spin_lock protecting the queue of subscriber events. | 108 | * - A local spin_lock protecting the queue of subscriber events. |
109 | */ | 109 | */ |
110 | 110 | ||
111 | int tipc_net_start(u32 addr) | 111 | int tipc_net_start(struct net *net, u32 addr) |
112 | { | 112 | { |
113 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
113 | char addr_string[16]; | 114 | char addr_string[16]; |
114 | int res; | 115 | int res; |
115 | 116 | ||
@@ -125,7 +126,8 @@ int tipc_net_start(u32 addr) | |||
125 | 126 | ||
126 | pr_info("Started in network mode\n"); | 127 | pr_info("Started in network mode\n"); |
127 | pr_info("Own node address %s, network identity %u\n", | 128 | pr_info("Own node address %s, network identity %u\n", |
128 | tipc_addr_string_fill(addr_string, tipc_own_addr), tipc_net_id); | 129 | tipc_addr_string_fill(addr_string, tipc_own_addr), |
130 | tn->net_id); | ||
129 | return 0; | 131 | return 0; |
130 | } | 132 | } |
131 | 133 | ||
@@ -144,8 +146,9 @@ void tipc_net_stop(void) | |||
144 | pr_info("Left network mode\n"); | 146 | pr_info("Left network mode\n"); |
145 | } | 147 | } |
146 | 148 | ||
147 | static int __tipc_nl_add_net(struct tipc_nl_msg *msg) | 149 | static int __tipc_nl_add_net(struct net *net, struct tipc_nl_msg *msg) |
148 | { | 150 | { |
151 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
149 | void *hdr; | 152 | void *hdr; |
150 | struct nlattr *attrs; | 153 | struct nlattr *attrs; |
151 | 154 | ||
@@ -158,7 +161,7 @@ static int __tipc_nl_add_net(struct tipc_nl_msg *msg) | |||
158 | if (!attrs) | 161 | if (!attrs) |
159 | goto msg_full; | 162 | goto msg_full; |
160 | 163 | ||
161 | if (nla_put_u32(msg->skb, TIPC_NLA_NET_ID, tipc_net_id)) | 164 | if (nla_put_u32(msg->skb, TIPC_NLA_NET_ID, tn->net_id)) |
162 | goto attr_msg_full; | 165 | goto attr_msg_full; |
163 | 166 | ||
164 | nla_nest_end(msg->skb, attrs); | 167 | nla_nest_end(msg->skb, attrs); |
@@ -176,6 +179,7 @@ msg_full: | |||
176 | 179 | ||
177 | int tipc_nl_net_dump(struct sk_buff *skb, struct netlink_callback *cb) | 180 | int tipc_nl_net_dump(struct sk_buff *skb, struct netlink_callback *cb) |
178 | { | 181 | { |
182 | struct net *net = sock_net(skb->sk); | ||
179 | int err; | 183 | int err; |
180 | int done = cb->args[0]; | 184 | int done = cb->args[0]; |
181 | struct tipc_nl_msg msg; | 185 | struct tipc_nl_msg msg; |
@@ -187,7 +191,7 @@ int tipc_nl_net_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
187 | msg.portid = NETLINK_CB(cb->skb).portid; | 191 | msg.portid = NETLINK_CB(cb->skb).portid; |
188 | msg.seq = cb->nlh->nlmsg_seq; | 192 | msg.seq = cb->nlh->nlmsg_seq; |
189 | 193 | ||
190 | err = __tipc_nl_add_net(&msg); | 194 | err = __tipc_nl_add_net(net, &msg); |
191 | if (err) | 195 | if (err) |
192 | goto out; | 196 | goto out; |
193 | 197 | ||
@@ -200,8 +204,10 @@ out: | |||
200 | 204 | ||
201 | int tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info) | 205 | int tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info) |
202 | { | 206 | { |
203 | int err; | 207 | struct net *net = genl_info_net(info); |
208 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
204 | struct nlattr *attrs[TIPC_NLA_NET_MAX + 1]; | 209 | struct nlattr *attrs[TIPC_NLA_NET_MAX + 1]; |
210 | int err; | ||
205 | 211 | ||
206 | if (!info->attrs[TIPC_NLA_NET]) | 212 | if (!info->attrs[TIPC_NLA_NET]) |
207 | return -EINVAL; | 213 | return -EINVAL; |
@@ -223,7 +229,7 @@ int tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info) | |||
223 | if (val < 1 || val > 9999) | 229 | if (val < 1 || val > 9999) |
224 | return -EINVAL; | 230 | return -EINVAL; |
225 | 231 | ||
226 | tipc_net_id = val; | 232 | tn->net_id = val; |
227 | } | 233 | } |
228 | 234 | ||
229 | if (attrs[TIPC_NLA_NET_ADDR]) { | 235 | if (attrs[TIPC_NLA_NET_ADDR]) { |
@@ -238,7 +244,7 @@ int tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info) | |||
238 | return -EINVAL; | 244 | return -EINVAL; |
239 | 245 | ||
240 | rtnl_lock(); | 246 | rtnl_lock(); |
241 | tipc_net_start(addr); | 247 | tipc_net_start(net, addr); |
242 | rtnl_unlock(); | 248 | rtnl_unlock(); |
243 | } | 249 | } |
244 | 250 | ||