]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
network: netdev_configure_server_veth: reduce scope of disable_ipv6_fd/path vars 4432/head
authorAlexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Mon, 8 Apr 2024 10:29:08 +0000 (12:29 +0200)
committerAlexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Mon, 8 Apr 2024 10:29:08 +0000 (12:29 +0200)
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
src/lxc/network.c

index 2a6ba6cb44e3cf869643c1416f374e29f96863c7..0a99d32a0af7030b066779105b5a61179eca80b1 100644 (file)
@@ -615,10 +615,10 @@ static int setup_veth_ovs_bridge_vlan(char *veth1, struct lxc_netdev *netdev)
 
 static int netdev_configure_server_veth(struct lxc_handler *handler, struct lxc_netdev *netdev)
 {
-       int err, disable_ipv6_fd;
+       int err;
        unsigned int mtu = 1500;
        char *veth1, *veth2;
-       char veth1buf[IFNAMSIZ], veth2buf[IFNAMSIZ], path[PATH_MAX];
+       char veth1buf[IFNAMSIZ], veth2buf[IFNAMSIZ];
 
        err = validate_veth(netdev);
        if (err)
@@ -714,6 +714,9 @@ static int netdev_configure_server_veth(struct lxc_handler *handler, struct lxc_
        }
 
        if (!is_empty_string(netdev->link) && netdev->priv.veth_attr.mode == VETH_MODE_BRIDGE) {
+               char path[PATH_MAX];
+               __do_close int disable_ipv6_fd = -EBADF;
+
                /* Disable link-local IPv6 addresses for the host's end of the veth. */
                snprintf(path, PATH_MAX, "/proc/sys/net/ipv6/conf/%s/disable_ipv6", veth1);
                disable_ipv6_fd = open(path, O_RDWR);