Commit 4b5b9ba5 authored by Martynas Pumputis's avatar Martynas Pumputis Committed by David S. Miller

openvswitch: do not ignore netdev errors when creating tunnel vports

The creation of a tunnel vport (geneve, gre, vxlan) brings up a
corresponding netdev, a multi-step operation which can fail.

For example, changing a vxlan vport's netdev state to 'up' binds the
vport's socket to a UDP port - if the binding fails (e.g. due to the
port being in use), the error is currently ignored giving the
appearance that the tunnel vport creation completed successfully.
Signed-off-by: default avatarMartynas Pumputis <martynas@weave.works>
Acked-by: default avatarPravin B Shelar <pshelar@ovn.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dafa6b0d
...@@ -93,7 +93,14 @@ static struct vport *geneve_tnl_create(const struct vport_parms *parms) ...@@ -93,7 +93,14 @@ static struct vport *geneve_tnl_create(const struct vport_parms *parms)
return ERR_CAST(dev); return ERR_CAST(dev);
} }
dev_change_flags(dev, dev->flags | IFF_UP); err = dev_change_flags(dev, dev->flags | IFF_UP);
if (err < 0) {
rtnl_delete_link(dev);
rtnl_unlock();
ovs_vport_free(vport);
goto error;
}
rtnl_unlock(); rtnl_unlock();
return vport; return vport;
error: error:
......
...@@ -54,6 +54,7 @@ static struct vport *gre_tnl_create(const struct vport_parms *parms) ...@@ -54,6 +54,7 @@ static struct vport *gre_tnl_create(const struct vport_parms *parms)
struct net *net = ovs_dp_get_net(parms->dp); struct net *net = ovs_dp_get_net(parms->dp);
struct net_device *dev; struct net_device *dev;
struct vport *vport; struct vport *vport;
int err;
vport = ovs_vport_alloc(0, &ovs_gre_vport_ops, parms); vport = ovs_vport_alloc(0, &ovs_gre_vport_ops, parms);
if (IS_ERR(vport)) if (IS_ERR(vport))
...@@ -67,9 +68,15 @@ static struct vport *gre_tnl_create(const struct vport_parms *parms) ...@@ -67,9 +68,15 @@ static struct vport *gre_tnl_create(const struct vport_parms *parms)
return ERR_CAST(dev); return ERR_CAST(dev);
} }
dev_change_flags(dev, dev->flags | IFF_UP); err = dev_change_flags(dev, dev->flags | IFF_UP);
rtnl_unlock(); if (err < 0) {
rtnl_delete_link(dev);
rtnl_unlock();
ovs_vport_free(vport);
return ERR_PTR(err);
}
rtnl_unlock();
return vport; return vport;
} }
......
...@@ -130,7 +130,14 @@ static struct vport *vxlan_tnl_create(const struct vport_parms *parms) ...@@ -130,7 +130,14 @@ static struct vport *vxlan_tnl_create(const struct vport_parms *parms)
return ERR_CAST(dev); return ERR_CAST(dev);
} }
dev_change_flags(dev, dev->flags | IFF_UP); err = dev_change_flags(dev, dev->flags | IFF_UP);
if (err < 0) {
rtnl_delete_link(dev);
rtnl_unlock();
ovs_vport_free(vport);
goto error;
}
rtnl_unlock(); rtnl_unlock();
return vport; return vport;
error: error:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment