aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2007-11-01 03:42:43 -0400
committerDavid S. Miller <davem@davemloft.net>2007-11-01 03:42:43 -0400
commit1dba323b3f92cf4a475236763b0373cb7d49395d (patch)
tree3f5463199c8957d3a94710d01380fc2f94d551a1
parent6257ff2177ff02d7f260a7a501876aa41cb9a9f6 (diff)
[NETNS]: Make the init/exit hooks checks outside the loop
When the new pernet something (subsys, device or operations) is being registered, the init callback is to be called for each namespace, that currently exitst in the system. During the unregister, the same is to be done with the exit callback. However, not every pernet something has both calls, but the check for the appropriate pointer to be not NULL is performed inside the for_each_net() loop. This is (at least) strange, so tune this. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/core/net_namespace.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 662e6ea1cecf..4e52921ade09 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -187,29 +187,28 @@ static int register_pernet_operations(struct list_head *list,
187 struct net *net, *undo_net; 187 struct net *net, *undo_net;
188 int error; 188 int error;
189 189
190 error = 0;
191 list_add_tail(&ops->list, list); 190 list_add_tail(&ops->list, list);
192 for_each_net(net) { 191 if (ops->init) {
193 if (ops->init) { 192 for_each_net(net) {
194 error = ops->init(net); 193 error = ops->init(net);
195 if (error) 194 if (error)
196 goto out_undo; 195 goto out_undo;
197 } 196 }
198 } 197 }
199out: 198 return 0;
200 return error;
201 199
202out_undo: 200out_undo:
203 /* If I have an error cleanup all namespaces I initialized */ 201 /* If I have an error cleanup all namespaces I initialized */
204 list_del(&ops->list); 202 list_del(&ops->list);
205 for_each_net(undo_net) { 203 if (ops->exit) {
206 if (undo_net == net) 204 for_each_net(undo_net) {
207 goto undone; 205 if (undo_net == net)
208 if (ops->exit) 206 goto undone;
209 ops->exit(undo_net); 207 ops->exit(undo_net);
208 }
210 } 209 }
211undone: 210undone:
212 goto out; 211 return error;
213} 212}
214 213
215static void unregister_pernet_operations(struct pernet_operations *ops) 214static void unregister_pernet_operations(struct pernet_operations *ops)
@@ -217,8 +216,8 @@ static void unregister_pernet_operations(struct pernet_operations *ops)
217 struct net *net; 216 struct net *net;
218 217
219 list_del(&ops->list); 218 list_del(&ops->list);
220 for_each_net(net) 219 if (ops->exit)
221 if (ops->exit) 220 for_each_net(net)
222 ops->exit(net); 221 ops->exit(net);
223} 222}
224 223