chiark / gitweb /
networkd: logging - align messages
[elogind.git] / src / network / networkd-network.c
index a452096836bd6160e7da413ba0809a32b95acefc..76381c4f6c576b3d6807cca4252262751f26f702 100644 (file)
@@ -20,6 +20,7 @@
 ***/
 
 #include <ctype.h>
+#include <net/if.h>
 
 #include "networkd.h"
 #include "network-internal.h"
@@ -220,7 +221,7 @@ int network_get(Manager *manager, struct udev_device *device,
                                      udev_device_get_property_value(device, "ID_NET_DRIVER"),
                                      udev_device_get_devtype(device),
                                      ifname)) {
-                        log_debug("%s: found matching network '%s'", ifname,
+                        log_debug("%*s: found matching network '%s'", IFNAMSIZ, ifname,
                                   network->filename);
                         *ret = network;
                         return 0;
@@ -257,7 +258,8 @@ int config_parse_netdev(const char *unit,
                 void *data,
                 void *userdata) {
         Network *network = userdata;
-        char *kind_string, *p;
+        _cleanup_free_ char *kind_string = NULL;
+        char *p;
         NetDev *netdev;
         NetDevKind kind;
         int r;
@@ -314,7 +316,7 @@ int config_parse_netdev(const char *unit,
 
                 break;
         case NETDEV_KIND_MACVLAN:
-                r = hashmap_put(network->macvlans, netdev->name, netdev);
+                r = hashmap_put(network->macvlans, netdev->ifname, netdev);
                 if (r < 0) {
                         log_syntax(unit, LOG_ERR, filename, line, EINVAL,
                                    "Can not add MACVLAN to network: %s", rvalue);
@@ -330,3 +332,42 @@ int config_parse_netdev(const char *unit,
 
         return 0;
 }
+
+int config_parse_tunnel(const char *unit,
+                        const char *filename,
+                        unsigned line,
+                        const char *section,
+                        unsigned section_line,
+                        const char *lvalue,
+                        int ltype,
+                        const char *rvalue,
+                        void *data,
+                        void *userdata) {
+        Network *network = userdata;
+        NetDev *netdev;
+        int r;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        r = netdev_get(network->manager, rvalue, &netdev);
+        if (r < 0) {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+                           "Tunnel is invalid, ignoring assignment: %s", rvalue);
+                return 0;
+        }
+
+        if (netdev->kind != NETDEV_KIND_IPIP &&
+            netdev->kind != NETDEV_KIND_SIT &&
+            netdev->kind != NETDEV_KIND_GRE) {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+                           "NetDev is not a tunnel, ignoring assignment: %s", rvalue);
+                return 0;
+        }
+
+        network->tunnel = netdev;
+
+        return 0;
+}