]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
network: Adds check for bridge link interface existence in instantiate_veth
authorThomas Parrott <thomas.parrott@canonical.com>
Wed, 3 Jun 2020 10:26:35 +0000 (11:26 +0100)
committerThomas Parrott <thomas.parrott@canonical.com>
Mon, 8 Jun 2020 12:27:07 +0000 (13:27 +0100)
To avoid misleading errors about openvswitch when non-existent bridge link interface specified.

Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
src/lxc/network.c

index da09141dd6d2506ee8d09020443cc0cd1aa0c7a4..15c362fb69a25248e2fb32998950d9c89b39c97e 100644 (file)
@@ -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);