]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
network: add lxc_log_configured_netdevs()
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 14 Jun 2017 14:32:27 +0000 (16:32 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 18 Jun 2017 09:53:59 +0000 (11:53 +0200)
This logs the configured networks on the trace level to support debugging.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c
src/lxc/confile_utils.c
src/lxc/confile_utils.h

index 255318781611637e9659cd645ae5bb29f35421af..93ef05c634ae45c8c2bce3e70de68a0d03abe43a 100644 (file)
@@ -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;
index 6118762e1f17d9fa4cac228c058bf7ffafc81045..895f9cd25bf9279acc016337059500067b5f2bea 100644 (file)
@@ -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);
+       }
+}
index 7b41af156f3c4e5c7d1a35f9400053373db7e168..01cd0510b4bd666d2153d4bc0b20c4ceba97f7df 100644 (file)
@@ -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 */