Skip to content

Commit

Permalink
datapath: backport: openvswitch: do not ignore netdev errors when cre…
Browse files Browse the repository at this point in the history
…ating tunnel vports

Upstream commit:
    commit 4b5b9ba553f9aa5f484ab972fc9b58061885ceca
    Author: Martynas Pumputis <[email protected]>
    Date:   Tue Aug 9 16:24:50 2016 +0100

    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: Martynas Pumputis <[email protected]>
    Acked-by: Pravin B Shelar <[email protected]>
    Signed-off-by: David S. Miller <[email protected]>

Signed-off-by: Pravin B Shelar <[email protected]>
Acked-by: Jesse Gross <[email protected]>
  • Loading branch information
pshelar committed Aug 15, 2016
1 parent d5a76da commit c59b72b
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 6 deletions.
1 change: 1 addition & 0 deletions datapath/linux/compat/dev-openvswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ int rpl_rtnl_delete_link(struct net_device *dev)

return 0;
}
EXPORT_SYMBOL_GPL(rpl_rtnl_delete_link);

#ifndef USE_UPSTREAM_TUNNEL
int ovs_dev_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
Expand Down
9 changes: 8 additions & 1 deletion datapath/vport-geneve.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 9 additions & 2 deletions datapath/vport-gre.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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;
}

Expand Down
8 changes: 7 additions & 1 deletion datapath/vport-lisp.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,14 @@ static struct vport *lisp_tnl_create(const struct vport_parms *parms)
ovs_vport_free(vport);
return ERR_CAST(dev);
}
err = dev_change_flags(dev, dev->flags | IFF_UP);
if (err < 0) {
rtnl_delete_link(dev);
rtnl_unlock();
ovs_vport_free(vport);
goto error;
}

dev_change_flags(dev, dev->flags | IFF_UP);
rtnl_unlock();
return vport;
error:
Expand Down
9 changes: 8 additions & 1 deletion datapath/vport-stt.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,14 @@ static struct vport *stt_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:
Expand Down
9 changes: 8 additions & 1 deletion datapath/vport-vxlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit c59b72b

Please sign in to comment.