network: send names for all non-trivial network types

parent 61302ef7
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment