Skip to content

Commit

Permalink
network: don't delete net devs we didn't create
Browse files Browse the repository at this point in the history
When we didn't create a net dev we should make sure that we don't delete it.  We
can simply check whether we have index for it. If not, we didn't create it.

Closes lxc#1600.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed May 30, 2017
1 parent f6104df commit b316d20
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lxc/conf.c
Expand Up @@ -2873,7 +2873,8 @@ static int instantiate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
return 0;

out_delete:
lxc_netdev_delete_by_name(veth1);
if (netdev->ifindex != 0)
lxc_netdev_delete_by_name(veth1);
if (!netdev->priv.veth_attr.pair)
free(veth1);
free(veth2);
Expand Down Expand Up @@ -3201,7 +3202,7 @@ bool lxc_delete_network(struct lxc_handler *handler)
/* Explicitly delete host veth device to prevent lingering
* devices. We had issues in LXD around this.
*/
if (netdev->type == LXC_NET_VETH && !am_unpriv()) {
if (netdev->ifindex != 0 && netdev->type == LXC_NET_VETH && !am_unpriv()) {
char *hostveth;
if (netdev->priv.veth_attr.pair) {
hostveth = netdev->priv.veth_attr.pair;
Expand Down

0 comments on commit b316d20

Please sign in to comment.