]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
network: non-functional changes
authorChristian Brauner <christian.brauner@ubuntu.com>
Sun, 18 Jun 2017 10:22:46 +0000 (12:22 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 18 Jun 2017 10:22:46 +0000 (12:22 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c
src/lxc/conf.h
src/lxc/start.c

index b8b81fd902e4baf683a4e66287ab4e58f287a67b..52ce92a30f234934d727f77aeb7c1e4337d45db1 100644 (file)
@@ -2326,7 +2326,7 @@ static int setup_ipv6_addr(struct lxc_list *ip, int ifindex)
        return 0;
 }
 
-static int setup_netdev(struct lxc_netdev *netdev)
+static int lxc_setup_netdev_in_child_namespaces(struct lxc_netdev *netdev)
 {
        char ifname[IFNAMSIZ];
        char *current_ifname = ifname;
@@ -2508,7 +2508,8 @@ static int setup_netdev(struct lxc_netdev *netdev)
        return 0;
 }
 
-static int setup_network(const struct lxc_conf *conf, struct lxc_list *network)
+static int lxc_setup_networks_in_child_namespaces(const struct lxc_conf *conf,
+                                                 struct lxc_list *network)
 {
        struct lxc_list *iterator;
        struct lxc_netdev *netdev;
@@ -2516,10 +2517,9 @@ static int setup_network(const struct lxc_conf *conf, struct lxc_list *network)
        lxc_log_configured_netdevs(conf);
 
        lxc_list_for_each(iterator, network) {
-
                netdev = iterator->elem;
 
-               if (setup_netdev(netdev)) {
+               if (lxc_setup_netdev_in_child_namespaces(netdev)) {
                        ERROR("failed to setup netdev");
                        return -1;
                }
@@ -3036,38 +3036,42 @@ int lxc_requests_empty_network(struct lxc_handler *handler)
        return 0;
 }
 
-int lxc_create_network(struct lxc_handler *handler)
+int lxc_setup_networks_in_parent_namespaces(struct lxc_handler *handler)
 {
-       struct lxc_list *network = &handler->conf->network;
-       struct lxc_list *iterator;
+       bool am_root;
        struct lxc_netdev *netdev;
-       int am_root = (getuid() == 0);
+       struct lxc_list *iterator;
+       struct lxc_list *network = &handler->conf->network;
 
+       /* We need to be root. */
+       am_root = (getuid() == 0);
        if (!am_root)
                return 0;
 
        lxc_list_for_each(iterator, network) {
-
                netdev = iterator->elem;
 
-               if (netdev->type != LXC_NET_MACVLAN && netdev->priv.macvlan_attr.mode) {
-                       ERROR("Invalid macvlan.mode for a non-macvlan netdev");
+               if (netdev->type < 0 || netdev->type > LXC_NET_MAXCONFTYPE) {
+                       ERROR("invalid network configuration type '%d'",
+                             netdev->type);
                        return -1;
                }
 
-               if (netdev->type != LXC_NET_VETH && netdev->priv.veth_attr.pair) {
-                       ERROR("Invalid veth pair for a non-veth netdev");
+               if (netdev->type != LXC_NET_MACVLAN &&
+                   netdev->priv.macvlan_attr.mode) {
+                       ERROR("Invalid macvlan.mode for a non-macvlan netdev");
                        return -1;
                }
 
-               if (netdev->type != LXC_NET_VLAN && netdev->priv.vlan_attr.vid > 0) {
-                       ERROR("Invalid vlan.id for a non-macvlan netdev");
+               if (netdev->type != LXC_NET_VETH &&
+                   netdev->priv.veth_attr.pair) {
+                       ERROR("Invalid veth pair for a non-veth netdev");
                        return -1;
                }
 
-               if (netdev->type < 0 || netdev->type > LXC_NET_MAXCONFTYPE) {
-                       ERROR("invalid network configuration type '%d'",
-                             netdev->type);
+               if (netdev->type != LXC_NET_VLAN &&
+                   netdev->priv.vlan_attr.vid > 0) {
+                       ERROR("Invalid vlan.id for a non-macvlan netdev");
                        return -1;
                }
 
@@ -3285,9 +3289,11 @@ int lxc_assign_network(const char *lxcpath, char *lxcname,
                                INFO("mtu ignored due to insufficient privilege");
                        if (unpriv_assign_nic(lxcpath, lxcname, netdev, pid))
                                return -1;
-                       // lxc-user-nic has moved the nic to the new ns.
-                       // unpriv_assign_nic() fills in netdev->name.
-                       // netdev->ifindex will be filed in at setup_netdev.
+                       /* lxc-user-nic has moved the nic to the new ns.
+                        * unpriv_assign_nic() fills in netdev->name.
+                        * netdev->ifindex will be filed in at
+                        * lxc_setup_netdev_in_child_namespaces.
+                        */
                        continue;
                }
 
@@ -4110,7 +4116,8 @@ int lxc_setup(struct lxc_handler *handler)
                }
        }
 
-       if (setup_network(lxc_conf, &lxc_conf->network)) {
+       if (lxc_setup_networks_in_child_namespaces(lxc_conf,
+                                                  &lxc_conf->network)) {
                ERROR("failed to setup the network for '%s'", name);
                return -1;
        }
index e2a90cac52a827280a33f75c8493475e56e52d33..495d6486faa485e12262f3dbc27214af5ff46110 100644 (file)
@@ -432,7 +432,7 @@ extern void lxc_conf_free(struct lxc_conf *conf);
 extern int pin_rootfs(const char *rootfs);
 
 extern int lxc_requests_empty_network(struct lxc_handler *handler);
-extern int lxc_create_network(struct lxc_handler *handler);
+extern int lxc_setup_networks_in_parent_namespaces(struct lxc_handler *handler);
 extern bool lxc_delete_network(struct lxc_handler *handler);
 extern int lxc_assign_network(const char *lxcpath, char *lxcname,
                              struct lxc_list *networks, pid_t pid);
index 83c8151447b1371b8ab2da89648ada4c0281fedf..11854f905a0a80dfa4a47b6fe17fed2e0f88c4ce 100644 (file)
@@ -1239,7 +1239,7 @@ static int lxc_spawn(struct lxc_handler *handler)
                        /* That should be done before the clone because we will
                         * fill the netdev index and use them in the child.
                         */
-                       if (lxc_create_network(handler)) {
+                       if (lxc_setup_networks_in_parent_namespaces(handler)) {
                                ERROR("Failed to create the network.");
                                lxc_sync_fini(handler);
                                return -1;