{
struct vport *vport;
struct tnl_vport *tnl_vport;
+ struct tnl_mutable_config *mutable;
int initial_frag_id;
int err;
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;
#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;
return vport;
error_free_mutable:
- kfree(tnl_vport->mutable);
+ kfree(mutable);
error_free_vport:
vport_free(vport);
error:
struct vport *vport;
struct patch_vport *patch_vport;
const char *peer_name;
+ struct device_config *devconf;
int err;
vport = vport_alloc(sizeof(struct patch_vport), &patch_vport_ops, parms);
strcpy(patch_vport->name, parms->name);
- patch_vport->devconf = kmalloc(sizeof(struct device_config), GFP_KERNEL);
- if (!patch_vport->devconf) {
+ devconf = kmalloc(sizeof(struct device_config), GFP_KERNEL);
+ if (!devconf) {
err = -ENOMEM;
goto error_free_vport;
}
- err = set_config(vport, parms->config, patch_vport->devconf);
+ err = set_config(vport, parms->config, devconf);
if (err)
goto error_free_devconf;
- vport_gen_rand_ether_addr(patch_vport->devconf->eth_addr);
+ vport_gen_rand_ether_addr(devconf->eth_addr);
/* Make the default MTU fairly large so that it doesn't become the
* bottleneck on systems using jumbo frames. */
- patch_vport->devconf->mtu = 65535;
+ devconf->mtu = 65535;
- peer_name = patch_vport->devconf->peer_name;
- hlist_add_head(&patch_vport->hash_node, hash_bucket(peer_name));
+ rcu_assign_pointer(patch_vport->devconf, devconf);
+ peer_name = devconf->peer_name;
+ hlist_add_head(&patch_vport->hash_node, hash_bucket(peer_name));
rcu_assign_pointer(patch_vport->peer, vport_locate(peer_name));
update_peers(patch_vport->name, vport);
return vport;
error_free_devconf:
- kfree(patch_vport->devconf);
+ kfree(devconf);
error_free_vport:
vport_free(vport);
error: