Unverified Commit e360d52a by Christian Brauner Committed by Stéphane Graber

network: add lxc_log_configured_netdevs()

This logs the configured networks on the trace level to support debugging. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 9c8ca2a5
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
#include "caps.h" /* for lxc_caps_last_cap() */ #include "caps.h" /* for lxc_caps_last_cap() */
#include "cgroup.h" #include "cgroup.h"
#include "conf.h" #include "conf.h"
#include "confile_utils.h"
#include "error.h" #include "error.h"
#include "log.h" #include "log.h"
#include "lxcaufs.h" #include "lxcaufs.h"
...@@ -2944,6 +2945,8 @@ int lxc_create_network(struct lxc_handler *handler) ...@@ -2944,6 +2945,8 @@ int lxc_create_network(struct lxc_handler *handler)
if (!am_root) if (!am_root)
return 0; return 0;
lxc_log_configured_netdevs(handler->conf);
lxc_list_for_each(iterator, network) { lxc_list_for_each(iterator, network) {
netdev = iterator->elem; netdev = iterator->elem;
......
...@@ -235,3 +235,61 @@ struct lxc_netdev *lxc_get_netdev_by_idx(struct lxc_conf *conf, ...@@ -235,3 +235,61 @@ struct lxc_netdev *lxc_get_netdev_by_idx(struct lxc_conf *conf,
return netdev; return netdev;
} }
void lxc_log_configured_netdevs(const struct lxc_conf *conf)
{
struct lxc_netdev *netdev;
struct lxc_list *it = (struct lxc_list *)&conf->network;;
if ((conf->loglevel != LXC_LOG_LEVEL_TRACE) &&
(lxc_log_get_level() != LXC_LOG_LEVEL_TRACE))
return;
if (lxc_list_empty(it)) {
TRACE("container has no networks configured");
return;
}
lxc_list_for_each(it, &conf->network) {
netdev = it->elem;
TRACE("index: %d", netdev->idx);
switch (netdev->type) {
case LXC_NET_VETH:
TRACE("type: veth");
break;
case LXC_NET_MACVLAN:
TRACE("type: macvlan");
break;
case LXC_NET_VLAN:
TRACE("type: vlan");
break;
case LXC_NET_PHYS:
TRACE("type: phys");
break;
case LXC_NET_EMPTY:
TRACE("type: empty");
break;
case LXC_NET_NONE:
TRACE("type: none");
break;
default:
ERROR("invalid network type %d", netdev->type);
return;
}
TRACE("flags: %s", netdev->flags == IFF_UP ? "up" : "none");
if (netdev->link)
TRACE("link: %s", netdev->link);
if (netdev->name)
TRACE("name: %s", netdev->name);
if (netdev->hwaddr)
TRACE("hwaddr: %s", netdev->hwaddr);
if (netdev->mtu)
TRACE("mtu: %s", netdev->mtu);
if (netdev->upscript)
TRACE("upscript: %s", netdev->upscript);
if (netdev->downscript)
TRACE("downscript: %s", netdev->downscript);
}
}
...@@ -32,5 +32,6 @@ extern struct lxc_netdev *lxc_find_netdev_by_idx(struct lxc_conf *conf, ...@@ -32,5 +32,6 @@ extern struct lxc_netdev *lxc_find_netdev_by_idx(struct lxc_conf *conf,
unsigned int idx); unsigned int idx);
extern struct lxc_netdev *lxc_get_netdev_by_idx(struct lxc_conf *conf, extern struct lxc_netdev *lxc_get_netdev_by_idx(struct lxc_conf *conf,
unsigned int idx); unsigned int idx);
extern void lxc_log_configured_netdevs(const struct lxc_conf *conf);
#endif /* __LXC_CONFILE_UTILS_H */ #endif /* __LXC_CONFILE_UTILS_H */
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