]> git.proxmox.com Git - mirror_lxc.git/commitdiff
network: send names for all non-trivial network types
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 3 Jul 2019 21:17:05 +0000 (23:17 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 3 Jul 2019 21:28:58 +0000 (23:28 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/network.c
src/lxc/network.h
src/lxc/start.c

index 38c7a75ba3218a0dffccb9f657b3d1752ccd6d19..ca74b1e62d30d2030925119f17c69e8648ba279c 100644 (file)
@@ -3174,6 +3174,17 @@ int lxc_network_move_created_netdev_priv(struct lxc_handler *handler)
        return 0;
 }
 
+static int network_requires_advanced_setup(int type)
+{
+       if (type == LXC_NET_EMPTY)
+               return false;
+
+       if (type == LXC_NET_NONE)
+               return false;
+
+       return true;
+}
+
 static int lxc_create_network_unpriv(struct lxc_handler *handler)
 {
        int hooks_version = handler->conf->hooks_version;
@@ -3186,10 +3197,7 @@ static int lxc_create_network_unpriv(struct lxc_handler *handler)
        lxc_list_for_each(iterator, network) {
                struct lxc_netdev *netdev = iterator->elem;
 
-               if (netdev->type == LXC_NET_EMPTY)
-                       continue;
-
-               if (netdev->type == LXC_NET_NONE)
+               if (!network_requires_advanced_setup(netdev->type))
                        continue;
 
                if (netdev->type != LXC_NET_VETH) {
@@ -3528,7 +3536,7 @@ static int lxc_setup_netdev_in_child_namespaces(struct lxc_netdev *netdev)
                netdev->ifindex = if_nametoindex(netdev->created_name);
                if (!netdev->ifindex)
                        SYSERROR("Failed to retrieve ifindex for network device with name %s",
-                                netdev->name ?: "(null)");
+                                netdev->created_name ?: "(null)");
        }
 
        /* get the new ifindex in case of physical netdev */
@@ -3763,7 +3771,7 @@ int lxc_setup_network_in_child_namespaces(const struct lxc_conf *conf,
        return 0;
 }
 
-int lxc_network_send_veth_names_to_child(struct lxc_handler *handler)
+int lxc_network_send_to_child(struct lxc_handler *handler)
 {
        struct lxc_list *iterator;
        struct lxc_list *network = &handler->conf->network;
@@ -3773,7 +3781,7 @@ int lxc_network_send_veth_names_to_child(struct lxc_handler *handler)
                int ret;
                struct lxc_netdev *netdev = iterator->elem;
 
-               if (netdev->type != LXC_NET_VETH)
+               if (!network_requires_advanced_setup(netdev->type))
                        continue;
 
                ret = lxc_send_nointr(data_sock, netdev->name, IFNAMSIZ, MSG_NOSIGNAL);
@@ -3790,7 +3798,7 @@ int lxc_network_send_veth_names_to_child(struct lxc_handler *handler)
        return 0;
 }
 
-int lxc_network_recv_veth_names_from_parent(struct lxc_handler *handler)
+int lxc_network_recv_from_parent(struct lxc_handler *handler)
 {
        struct lxc_list *iterator;
        struct lxc_list *network = &handler->conf->network;
@@ -3800,7 +3808,7 @@ int lxc_network_recv_veth_names_from_parent(struct lxc_handler *handler)
                int ret;
                struct lxc_netdev *netdev = iterator->elem;
 
-               if (netdev->type != LXC_NET_VETH)
+               if (!network_requires_advanced_setup(netdev->type))
                        continue;
 
                ret = lxc_recv_nointr(data_sock, netdev->name, IFNAMSIZ, 0);
index 9a79cb870b71d0c87d454242dc0fa4d86404a6a3..483fbb8cd430a1d14e8c14ce580760899c95bfd6 100644 (file)
@@ -278,8 +278,8 @@ extern int lxc_requests_empty_network(struct lxc_handler *handler);
 extern int lxc_restore_phys_nics_to_netns(struct lxc_handler *handler);
 extern int lxc_setup_network_in_child_namespaces(const struct lxc_conf *conf,
                                                 struct lxc_list *network);
-extern int lxc_network_send_veth_names_to_child(struct lxc_handler *handler);
-extern int lxc_network_recv_veth_names_from_parent(struct lxc_handler *handler);
+extern int lxc_network_send_to_child(struct lxc_handler *handler);
+extern int lxc_network_recv_from_parent(struct lxc_handler *handler);
 extern int lxc_network_send_name_and_ifindex_to_parent(struct lxc_handler *handler);
 extern int lxc_network_recv_name_and_ifindex_from_child(struct lxc_handler *handler);
 extern int lxc_netns_set_nsid(int netns_fd);
index 9e28d3dcdfd65df3abf8607e2a563c4cf6e2d697..1e559f887a8f865445207520c73fdb92d8678e65 100644 (file)
@@ -1194,7 +1194,7 @@ static int do_start(void *data)
                goto out_error;
 
        if (handler->ns_clone_flags & CLONE_NEWNET) {
-               ret = lxc_network_recv_veth_names_from_parent(handler);
+               ret = lxc_network_recv_from_parent(handler);
                if (ret < 0) {
                        ERROR("Failed to receive veth names from parent");
                        goto out_warn_father;
@@ -1252,12 +1252,12 @@ static int do_start(void *data)
         */
        if (handler->daemonize && !handler->conf->autodev) {
                char path[PATH_MAX];
-               
+
                ret = snprintf(path, sizeof(path), "%s/dev/null",
                               handler->conf->rootfs.mount);
                if (ret < 0 || ret >= sizeof(path))
                        goto out_warn_father;
-               
+
                ret = access(path, F_OK);
                if (ret != 0) {
                        devnull_fd = open_devnull();
@@ -1839,7 +1839,7 @@ static int lxc_spawn(struct lxc_handler *handler)
                        goto out_delete_net;
                }
 
-               ret = lxc_network_send_veth_names_to_child(handler);
+               ret = lxc_network_send_to_child(handler);
                if (ret < 0) {
                        ERROR("Failed to send veth names to child");
                        goto out_delete_net;