X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=datapath%2Ftunnel.c;h=e42e0e361fbf562a36ac0149dfc037cd8dccfe7e;hb=46c6a11da0409a4f52fd6ea5f72154c73af0ba47;hp=ce1d8eb524663afd93f741fc5a550783feca99a0;hpb=f827d749920e1bcc275660695144d25c7adbbd4b;p=openvswitch diff --git a/datapath/tunnel.c b/datapath/tunnel.c index ce1d8eb5..e42e0e36 100644 --- a/datapath/tunnel.c +++ b/datapath/tunnel.c @@ -1372,6 +1372,7 @@ struct vport *tnl_create(const struct vport_parms *parms, { struct vport *vport; struct tnl_vport *tnl_vport; + struct tnl_mutable_config *mutable; int initial_frag_id; int err; @@ -1386,19 +1387,19 @@ struct vport *tnl_create(const struct vport_parms *parms, strcpy(tnl_vport->name, parms->name); tnl_vport->tnl_ops = tnl_ops; - tnl_vport->mutable = kzalloc(sizeof(struct tnl_mutable_config), GFP_KERNEL); - if (!tnl_vport->mutable) { + mutable = kzalloc(sizeof(struct tnl_mutable_config), GFP_KERNEL); + if (!mutable) { err = -ENOMEM; goto error_free_vport; } - vport_gen_rand_ether_addr(tnl_vport->mutable->eth_addr); - tnl_vport->mutable->mtu = ETH_DATA_LEN; + vport_gen_rand_ether_addr(mutable->eth_addr); + mutable->mtu = ETH_DATA_LEN; get_random_bytes(&initial_frag_id, sizeof(int)); atomic_set(&tnl_vport->frag_id, initial_frag_id); - err = set_config(parms->config, tnl_ops, NULL, tnl_vport->mutable); + err = set_config(parms->config, tnl_ops, NULL, mutable); if (err) goto error_free_mutable; @@ -1406,9 +1407,11 @@ struct vport *tnl_create(const struct vport_parms *parms, #ifdef NEED_CACHE_TIMEOUT tnl_vport->cache_exp_interval = MAX_CACHE_EXP - - (net_random() % (MAX_CACHE_EXP / 2)); + (net_random() % (MAX_CACHE_EXP / 2)); #endif + rcu_assign_pointer(tnl_vport->mutable, mutable); + err = add_port(vport); if (err) goto error_free_mutable; @@ -1416,7 +1419,7 @@ struct vport *tnl_create(const struct vport_parms *parms, return vport; error_free_mutable: - kfree(tnl_vport->mutable); + kfree(mutable); error_free_vport: vport_free(vport); error: @@ -1456,13 +1459,11 @@ error: static void free_port_rcu(struct rcu_head *rcu) { - struct tnl_vport *tnl_vport = container_of(rcu, struct tnl_vport, rcu); - - spin_lock_bh(&tnl_vport->cache_lock); - free_cache(tnl_vport->cache); - spin_unlock_bh(&tnl_vport->cache_lock); + struct tnl_vport *tnl_vport = container_of(rcu, + struct tnl_vport, rcu); - kfree(tnl_vport->mutable); + free_cache((struct tnl_cache __force *)tnl_vport->cache); + kfree((struct tnl_mutable __force *)tnl_vport->mutable); vport_free(tnl_vport_to_vport(tnl_vport)); }