mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-27 16:18:16 +00:00
network: add lxc_log_configured_netdevs()
This logs the configured networks on the trace level to support debugging. Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
parent
bbc079cf87
commit
1ed6ba91b5
@ -77,6 +77,7 @@
|
||||
#include "caps.h" /* for lxc_caps_last_cap() */
|
||||
#include "cgroup.h"
|
||||
#include "conf.h"
|
||||
#include "confile_utils.h"
|
||||
#include "error.h"
|
||||
#include "log.h"
|
||||
#include "lxcaufs.h"
|
||||
@ -3043,6 +3044,8 @@ int lxc_create_network(struct lxc_handler *handler)
|
||||
if (!am_root)
|
||||
return 0;
|
||||
|
||||
lxc_log_configured_netdevs(handler->conf);
|
||||
|
||||
lxc_list_for_each(iterator, network) {
|
||||
|
||||
netdev = iterator->elem;
|
||||
|
@ -235,3 +235,61 @@ struct lxc_netdev *lxc_get_netdev_by_idx(struct lxc_conf *conf,
|
||||
|
||||
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,
|
||||
unsigned int idx);
|
||||
extern struct lxc_netdev *lxc_get_netdev_by_idx(struct lxc_conf *conf,
|
||||
unsigned int idx);
|
||||
extern void lxc_log_configured_netdevs(const struct lxc_conf *conf);
|
||||
|
||||
#endif /* __LXC_CONFILE_UTILS_H */
|
||||
|
Loading…
Reference in New Issue
Block a user