Skip to content

Commit c80498e

Browse files
NicolasDichteldavem330
authored andcommitted
vxlan: fix ovs support
The required changes in the function vxlan_dev_create() were missing in commit 8bcdc4f. The vxlan device is not registered anymore after this patch and the error path causes an stack dump: WARNING: CPU: 3 PID: 1498 at net/core/dev.c:6713 rollback_registered_many+0x9d/0x3f0 Fixes: 8bcdc4f ("vxlan: add changelink support") CC: Roopa Prabhu <[email protected]> Signed-off-by: Nicolas Dichtel <[email protected]> Acked-by: Roopa Prabhu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 91864f5 commit c80498e

File tree

1 file changed

+40
-33
lines changed

1 file changed

+40
-33
lines changed

drivers/net/vxlan.c

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2976,6 +2976,44 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
29762976
return 0;
29772977
}
29782978

2979+
static int __vxlan_dev_create(struct net *net, struct net_device *dev,
2980+
struct vxlan_config *conf)
2981+
{
2982+
struct vxlan_net *vn = net_generic(net, vxlan_net_id);
2983+
struct vxlan_dev *vxlan = netdev_priv(dev);
2984+
int err;
2985+
2986+
err = vxlan_dev_configure(net, dev, conf, false);
2987+
if (err)
2988+
return err;
2989+
2990+
dev->ethtool_ops = &vxlan_ethtool_ops;
2991+
2992+
/* create an fdb entry for a valid default destination */
2993+
if (!vxlan_addr_any(&vxlan->default_dst.remote_ip)) {
2994+
err = vxlan_fdb_create(vxlan, all_zeros_mac,
2995+
&vxlan->default_dst.remote_ip,
2996+
NUD_REACHABLE | NUD_PERMANENT,
2997+
NLM_F_EXCL | NLM_F_CREATE,
2998+
vxlan->cfg.dst_port,
2999+
vxlan->default_dst.remote_vni,
3000+
vxlan->default_dst.remote_vni,
3001+
vxlan->default_dst.remote_ifindex,
3002+
NTF_SELF);
3003+
if (err)
3004+
return err;
3005+
}
3006+
3007+
err = register_netdevice(dev);
3008+
if (err) {
3009+
vxlan_fdb_delete_default(vxlan, vxlan->default_dst.remote_vni);
3010+
return err;
3011+
}
3012+
3013+
list_add(&vxlan->next, &vn->vxlan_list);
3014+
return 0;
3015+
}
3016+
29793017
static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[],
29803018
struct net_device *dev, struct vxlan_config *conf,
29813019
bool changelink)
@@ -3172,45 +3210,14 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[],
31723210
static int vxlan_newlink(struct net *src_net, struct net_device *dev,
31733211
struct nlattr *tb[], struct nlattr *data[])
31743212
{
3175-
struct vxlan_net *vn = net_generic(src_net, vxlan_net_id);
3176-
struct vxlan_dev *vxlan = netdev_priv(dev);
31773213
struct vxlan_config conf;
31783214
int err;
31793215

31803216
err = vxlan_nl2conf(tb, data, dev, &conf, false);
31813217
if (err)
31823218
return err;
31833219

3184-
err = vxlan_dev_configure(src_net, dev, &conf, false);
3185-
if (err)
3186-
return err;
3187-
3188-
dev->ethtool_ops = &vxlan_ethtool_ops;
3189-
3190-
/* create an fdb entry for a valid default destination */
3191-
if (!vxlan_addr_any(&vxlan->default_dst.remote_ip)) {
3192-
err = vxlan_fdb_create(vxlan, all_zeros_mac,
3193-
&vxlan->default_dst.remote_ip,
3194-
NUD_REACHABLE | NUD_PERMANENT,
3195-
NLM_F_EXCL | NLM_F_CREATE,
3196-
vxlan->cfg.dst_port,
3197-
vxlan->default_dst.remote_vni,
3198-
vxlan->default_dst.remote_vni,
3199-
vxlan->default_dst.remote_ifindex,
3200-
NTF_SELF);
3201-
if (err)
3202-
return err;
3203-
}
3204-
3205-
err = register_netdevice(dev);
3206-
if (err) {
3207-
vxlan_fdb_delete_default(vxlan, vxlan->default_dst.remote_vni);
3208-
return err;
3209-
}
3210-
3211-
list_add(&vxlan->next, &vn->vxlan_list);
3212-
3213-
return 0;
3220+
return __vxlan_dev_create(src_net, dev, &conf);
32143221
}
32153222

32163223
static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
@@ -3440,7 +3447,7 @@ struct net_device *vxlan_dev_create(struct net *net, const char *name,
34403447
if (IS_ERR(dev))
34413448
return dev;
34423449

3443-
err = vxlan_dev_configure(net, dev, conf, false);
3450+
err = __vxlan_dev_create(net, dev, conf);
34443451
if (err < 0) {
34453452
free_netdev(dev);
34463453
return ERR_PTR(err);

0 commit comments

Comments
 (0)