diff mbox

openvswitch: do not ignore netdev errors when creating tunnel vports

Message ID 20160809152450.6626-1-martynas@weave.works
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Martynas Pumputis Aug. 9, 2016, 3:24 p.m. UTC
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 <martynas@weave.works>
---
 net/openvswitch/vport-geneve.c |  9 ++++++++-
 net/openvswitch/vport-gre.c    | 11 +++++++++--
 net/openvswitch/vport-vxlan.c  |  9 ++++++++-
 3 files changed, 25 insertions(+), 4 deletions(-)

Comments

Pravin Shelar Aug. 10, 2016, 5:26 p.m. UTC | #1
On Tue, Aug 9, 2016 at 8:24 AM, Martynas Pumputis <martynas@weave.works> wrote:
> 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 <martynas@weave.works>

Thanks.

Acked-by: Pravin B Shelar <pshelar@ovn.org>
David Miller Aug. 11, 2016, 6:14 a.m. UTC | #2
From: Martynas Pumputis <martynas@weave.works>
Date: Tue,  9 Aug 2016 16:24:50 +0100

> 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 <martynas@weave.works>

Applied.
diff mbox

Patch

diff --git a/net/openvswitch/vport-geneve.c b/net/openvswitch/vport-geneve.c
index 1a1fcec..5aaf3ba 100644
--- a/net/openvswitch/vport-geneve.c
+++ b/net/openvswitch/vport-geneve.c
@@ -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:
diff --git a/net/openvswitch/vport-gre.c b/net/openvswitch/vport-gre.c
index 7f8897f..0e72d95 100644
--- a/net/openvswitch/vport-gre.c
+++ b/net/openvswitch/vport-gre.c
@@ -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;
 }
 
diff --git a/net/openvswitch/vport-vxlan.c b/net/openvswitch/vport-vxlan.c
index 5eb7694..7eb955e 100644
--- a/net/openvswitch/vport-vxlan.c
+++ b/net/openvswitch/vport-vxlan.c
@@ -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: