From 26da53c3acc51d5a93476c47836508e1661c6505 Mon Sep 17 00:00:00 2001 From: Thomas Parrott Date: Wed, 3 Jun 2020 11:26:35 +0100 Subject: [PATCH] network: Adds check for bridge link interface existence in instantiate_veth To avoid misleading errors about openvswitch when non-existent bridge link interface specified. Signed-off-by: Thomas Parrott --- src/lxc/network.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lxc/network.c b/src/lxc/network.c index da09141dd..15c362fb6 100644 --- a/src/lxc/network.c +++ b/src/lxc/network.c @@ -324,11 +324,15 @@ static int instantiate_veth(struct lxc_handler *handler, struct lxc_netdev *netd } if (!is_empty_string(netdev->link) && netdev->priv.veth_attr.mode == VETH_MODE_BRIDGE) { + if (!lxc_nic_exists(netdev->link)) { + SYSERROR("Failed to attach \"%s\" to bridge \"%s\", bridge interface doesn't exist", veth1, netdev->link); + goto out_delete; + } + err = lxc_bridge_attach(netdev->link, veth1); if (err) { errno = -err; - SYSERROR("Failed to attach \"%s\" to bridge \"%s\"", - veth1, netdev->link); + SYSERROR("Failed to attach \"%s\" to bridge \"%s\"", veth1, netdev->link); goto out_delete; } INFO("Attached \"%s\" to bridge \"%s\"", veth1, netdev->link); -- 2.47.2