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;
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) {
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 */
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;
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);
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;
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);
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);
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;
*/
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();
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;