Skip to content

Commit

Permalink
openvswitch: do not ignore netdev errors when creating tunnel vports
Browse files Browse the repository at this point in the history
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: Martynas Pumputis <[email protected]>
Acked-by: Pravin B Shelar <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Martynas Pumputis authored and davem330 committed Aug 11, 2016
1 parent dafa6b0 commit 4b5b9ba
Showing 3 changed files with 25 additions and 4 deletions.
9 changes: 8 additions & 1 deletion net/openvswitch/vport-geneve.c
Original file line number Diff line number Diff line change
@@ -93,7 +93,14 @@ static struct vport *geneve_tnl_create(const struct vport_parms *parms)
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();
return vport;
error:
11 changes: 9 additions & 2 deletions net/openvswitch/vport-gre.c
Original file line number Diff line number Diff line change
@@ -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_device *dev;
struct vport *vport;
int err;

vport = ovs_vport_alloc(0, &ovs_gre_vport_ops, parms);
if (IS_ERR(vport))
@@ -67,9 +68,15 @@ static struct vport *gre_tnl_create(const struct vport_parms *parms)
return ERR_CAST(dev);
}

dev_change_flags(dev, dev->flags | IFF_UP);
rtnl_unlock();
err = dev_change_flags(dev, dev->flags | IFF_UP);
if (err < 0) {
rtnl_delete_link(dev);
rtnl_unlock();
ovs_vport_free(vport);
return ERR_PTR(err);
}

rtnl_unlock();
return vport;
}

9 changes: 8 additions & 1 deletion net/openvswitch/vport-vxlan.c
Original file line number Diff line number Diff line change
@@ -130,7 +130,14 @@ static struct vport *vxlan_tnl_create(const struct vport_parms *parms)
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();
return vport;
error:

0 comments on commit 4b5b9ba

Please sign in to comment.