X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=kernel%2Fvserver%2Fnetwork.c;h=3a8eae14e3f9a60dc4eab13ebccd78676e8196e2;hb=9464c7cf61b9433057924c36e6e02f303a00e768;hp=6674c638c0a849e8c97798af3782262b9efb86b3;hpb=41689045f6a3cbe0550e1d34e9cc20d2e8c432ba;p=linux-2.6.git diff --git a/kernel/vserver/network.c b/kernel/vserver/network.c index 6674c638c..3a8eae14e 100644 --- a/kernel/vserver/network.c +++ b/kernel/vserver/network.c @@ -3,14 +3,13 @@ * * Virtual Server: Network Support * - * Copyright (C) 2003-2006 Herbert Pötzl + * Copyright (C) 2003-2005 Herbert Pötzl * * V0.01 broken out from vcontext V0.05 * V0.02 cleaned up implementation * V0.03 added equiv nx commands * V0.04 switch to RCU based hash * V0.05 and back to locking again - * V0.06 have __create claim() the nxi * */ @@ -140,16 +139,15 @@ static inline void __hash_nx_info(struct nx_info *nxi) static inline void __unhash_nx_info(struct nx_info *nxi) { + vxd_assert_lock(&nx_info_hash_lock); vxdprintk(VXD_CBIT(nid, 4), "__unhash_nx_info: %p[#%d]", nxi, nxi->nx_id); - spin_lock(&nx_info_hash_lock); /* context must be hashed */ BUG_ON(!nx_info_state(nxi, NXS_HASHED)); nxi->nx_state &= ~NXS_HASHED; hlist_del(&nxi->nx_hlist); - spin_unlock(&nx_info_hash_lock); } @@ -206,7 +204,7 @@ static inline nid_t __nx_dynamic_id(void) /* __create_nx_info() * create the requested context - * get(), claim() and hash it */ + * get() and hash it */ static struct nx_info * __create_nx_info(int id) { @@ -251,7 +249,6 @@ static struct nx_info * __create_nx_info(int id) /* new context */ vxdprintk(VXD_CBIT(nid, 0), "create_nx_info(%d) = %p (new)", id, new); - claim_nx_info(new, NULL); __hash_nx_info(get_nx_info(new)); nxi = new, new = NULL; @@ -270,7 +267,9 @@ out_unlock: void unhash_nx_info(struct nx_info *nxi) { __shutdown_nx_info(nxi); + spin_lock(&nx_info_hash_lock); __unhash_nx_info(nxi); + spin_unlock(&nx_info_hash_lock); } #ifdef CONFIG_VSERVER_LEGACYNET @@ -387,7 +386,6 @@ int nx_migrate_task(struct task_struct *p, struct nx_info *nxi) if (old_nxi) release_nx_info(old_nxi, p); - ret = 0; out: put_nx_info(old_nxi); return ret; @@ -490,11 +488,8 @@ int nx_addr_conflict(struct nx_info *nxi, uint32_t addr, struct sock *sk) void nx_set_persistent(struct nx_info *nxi) { - vxdprintk(VXD_CBIT(nid, 6), - "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id); - get_nx_info(nxi); - claim_nx_info(nxi, NULL); + claim_nx_info(nxi, current); } void nx_clear_persistent(struct nx_info *nxi) @@ -502,7 +497,7 @@ void nx_clear_persistent(struct nx_info *nxi) vxdprintk(VXD_CBIT(nid, 6), "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id); - release_nx_info(nxi, NULL); + release_nx_info(nxi, current); put_nx_info(nxi); } @@ -590,22 +585,26 @@ int vc_net_create(uint32_t nid, void __user *data) /* initial flags */ new_nxi->nx_flags = vc_data.flagword; + /* get a reference for persistent contexts */ + if ((vc_data.flagword & NXF_PERSISTENT)) + nx_set_persistent(new_nxi); + ret = -ENOEXEC; if (vs_net_change(new_nxi, VSC_NETUP)) - goto out; - + goto out_unhash; ret = nx_migrate_task(current, new_nxi); - if (ret) + if (!ret) { + /* return context id on success */ + ret = new_nxi->nx_id; goto out; - - /* return context id on success */ - ret = new_nxi->nx_id; - - /* get a reference for persistent contexts */ + } +out_unhash: + /* prepare for context disposal */ + new_nxi->nx_state |= NXS_SHUTDOWN; if ((vc_data.flagword & NXF_PERSISTENT)) - nx_set_persistent(new_nxi); + nx_clear_persistent(new_nxi); + __unhash_nx_info(new_nxi); out: - release_nx_info(new_nxi, NULL); put_nx_info(new_nxi); return ret; }