chiark / gitweb /
install: improve paths we show the user when enabling/disabling
[elogind.git] / src / network / networkd-tunnel.c
index e3ceb8b52b788ba6820b5294cd734102c8f701c8..202c089c4330713de2fab64e3084b5869c5aa285 100644 (file)
@@ -24,7 +24,6 @@
 #include <net/if.h>
 #include <linux/ip.h>
 #include <linux/if_tunnel.h>
-#include <libkmod.h>
 
 #include "sd-rtnl.h"
 #include "networkd.h"
@@ -61,6 +60,16 @@ static int netdev_fill_ipip_rtnl_message(Link *link, sd_rtnl_message *m) {
                 }
         }
 
+        if (netdev->mac) {
+                r = sd_rtnl_message_append_ether_addr(m, IFLA_ADDRESS, netdev->mac);
+                if (r < 0) {
+                        log_error_netdev(netdev,
+                                         "Colud not append IFLA_ADDRESS attribute: %s",
+                                         strerror(-r));
+                    return r;
+                }
+        }
+
         r = sd_rtnl_message_open_container(m, IFLA_LINKINFO);
         if (r < 0) {
                 log_error_netdev(netdev,
@@ -86,7 +95,7 @@ static int netdev_fill_ipip_rtnl_message(Link *link, sd_rtnl_message *m) {
                 return r;
         }
 
-        r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_LOCAL, &netdev->tunnel_local);
+        r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_LOCAL, &netdev->local);
         if (r < 0) {
                 log_error_netdev(netdev,
                                  "Could not append IFLA_IPTUN_LOCAL attribute: %s",
@@ -94,7 +103,7 @@ static int netdev_fill_ipip_rtnl_message(Link *link, sd_rtnl_message *m) {
                 return r;
         }
 
-        r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_REMOTE, &netdev->tunnel_remote);
+        r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_REMOTE, &netdev->remote);
         if (r < 0) {
                 log_error_netdev(netdev,
                                  "Could not append IFLA_IPTUN_REMOTE attribute: %s",
@@ -102,7 +111,7 @@ static int netdev_fill_ipip_rtnl_message(Link *link, sd_rtnl_message *m) {
                 return r;
         }
 
-        r = sd_rtnl_message_append_u8(m, IFLA_IPTUN_TTL, netdev->tunnel_ttl);
+        r = sd_rtnl_message_append_u8(m, IFLA_IPTUN_TTL, netdev->ttl);
         if (r < 0) {
                 log_error_netdev(netdev,
                                  "Could not append IFLA_IPTUN_TTL  attribute: %s",
@@ -158,6 +167,16 @@ static int netdev_fill_sit_rtnl_message(Link *link, sd_rtnl_message *m) {
                 }
         }
 
+        if (netdev->mac) {
+                r = sd_rtnl_message_append_ether_addr(m, IFLA_ADDRESS, netdev->mac);
+                if (r < 0) {
+                        log_error_netdev(netdev,
+                                         "Colud not append IFLA_ADDRESS attribute: %s",
+                                         strerror(-r));
+                    return r;
+                }
+        }
+
         r = sd_rtnl_message_open_container(m, IFLA_LINKINFO);
         if (r < 0) {
                 log_error_netdev(netdev,
@@ -183,7 +202,7 @@ static int netdev_fill_sit_rtnl_message(Link *link, sd_rtnl_message *m) {
                 return r;
         }
 
-        r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_LOCAL, &netdev->tunnel_local);
+        r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_LOCAL, &netdev->local);
         if (r < 0) {
                 log_error_netdev(netdev,
                                  "Could not append IFLA_IPTUN_LOCAL attribute: %s",
@@ -191,7 +210,7 @@ static int netdev_fill_sit_rtnl_message(Link *link, sd_rtnl_message *m) {
                 return r;
         }
 
-        r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_REMOTE, &netdev->tunnel_remote);
+        r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_REMOTE, &netdev->remote);
         if (r < 0) {
                 log_error_netdev(netdev,
                                  "Could not append IFLA_IPTUN_REMOTE attribute: %s",
@@ -199,7 +218,7 @@ static int netdev_fill_sit_rtnl_message(Link *link, sd_rtnl_message *m) {
                 return r;
         }
 
-        r = sd_rtnl_message_append_u8(m, IFLA_IPTUN_TOS, netdev->tunnel_tos);
+        r = sd_rtnl_message_append_u8(m, IFLA_IPTUN_TOS, netdev->tos);
         if (r < 0) {
                 log_error_netdev(netdev,
                                  "Could not append IFLA_IPTUN_TOS attribute: %s",
@@ -263,6 +282,16 @@ static int netdev_fill_ipgre_rtnl_message(Link *link, sd_rtnl_message *m) {
                 }
         }
 
+        if (netdev->mac) {
+                r = sd_rtnl_message_append_ether_addr(m, IFLA_ADDRESS, netdev->mac);
+                if (r < 0) {
+                        log_error_netdev(netdev,
+                                         "Colud not append IFLA_ADDRESS attribute: %s",
+                                         strerror(-r));
+                    return r;
+                }
+        }
+
         r = sd_rtnl_message_open_container(m, IFLA_LINKINFO);
         if (r < 0) {
                 log_error_netdev(netdev,
@@ -288,7 +317,7 @@ static int netdev_fill_ipgre_rtnl_message(Link *link, sd_rtnl_message *m) {
                 return r;
         }
 
-        r = sd_rtnl_message_append_in_addr(m, IFLA_GRE_LOCAL, &netdev->tunnel_local);
+        r = sd_rtnl_message_append_in_addr(m, IFLA_GRE_LOCAL, &netdev->local);
         if (r < 0) {
                 log_error_netdev(netdev,
                                  "Could not append IFLA_GRE_LOCAL attribute: %s",
@@ -296,7 +325,7 @@ static int netdev_fill_ipgre_rtnl_message(Link *link, sd_rtnl_message *m) {
                 return r;
         }
 
-        r = sd_rtnl_message_append_in_addr(m, IFLA_GRE_REMOTE, &netdev->tunnel_remote);
+        r = sd_rtnl_message_append_in_addr(m, IFLA_GRE_REMOTE, &netdev->remote);
         if (r < 0) {
                 log_error_netdev(netdev,
                                  "Could not append IFLA_GRE_REMOTE attribute: %s",
@@ -304,7 +333,7 @@ static int netdev_fill_ipgre_rtnl_message(Link *link, sd_rtnl_message *m) {
                 return r;
         }
 
-        r = sd_rtnl_message_append_u8(m, IFLA_GRE_TTL, netdev->tunnel_ttl);
+        r = sd_rtnl_message_append_u8(m, IFLA_GRE_TTL, netdev->ttl);
         if (r < 0) {
                 log_error_netdev(netdev,
                                  "Could not append IFLA_GRE_TTL attribute: %s",
@@ -312,7 +341,7 @@ static int netdev_fill_ipgre_rtnl_message(Link *link, sd_rtnl_message *m) {
                 return r;
         }
 
-        r = sd_rtnl_message_append_u8(m, IFLA_GRE_TOS, netdev->tunnel_tos);
+        r = sd_rtnl_message_append_u8(m, IFLA_GRE_TOS, netdev->tos);
         if (r < 0) {
                 log_error_netdev(netdev,
                                  "Could not append IFLA_GRE_TOS attribute: %s",
@@ -368,6 +397,16 @@ static int netdev_fill_vti_rtnl_message(Link *link, sd_rtnl_message *m) {
                 }
         }
 
+        if (netdev->mac) {
+                r = sd_rtnl_message_append_ether_addr(m, IFLA_ADDRESS, netdev->mac);
+                if (r < 0) {
+                        log_error_netdev(netdev,
+                                         "Colud not append IFLA_ADDRESS attribute: %s",
+                                         strerror(-r));
+                    return r;
+                }
+        }
+
         r = sd_rtnl_message_open_container(m, IFLA_LINKINFO);
         if (r < 0) {
                 log_error_netdev(netdev,
@@ -393,7 +432,7 @@ static int netdev_fill_vti_rtnl_message(Link *link, sd_rtnl_message *m) {
                 return r;
         }
 
-        r = sd_rtnl_message_append_in_addr(m, IFLA_VTI_LOCAL, &netdev->tunnel_local);
+        r = sd_rtnl_message_append_in_addr(m, IFLA_VTI_LOCAL, &netdev->local);
         if (r < 0) {
                 log_error_netdev(netdev,
                                  "Could not append IFLA_IPTUN_LOCAL attribute: %s",
@@ -401,7 +440,7 @@ static int netdev_fill_vti_rtnl_message(Link *link, sd_rtnl_message *m) {
                 return r;
         }
 
-        r = sd_rtnl_message_append_in_addr(m, IFLA_VTI_REMOTE, &netdev->tunnel_remote);
+        r = sd_rtnl_message_append_in_addr(m, IFLA_VTI_REMOTE, &netdev->remote);
         if (r < 0) {
                 log_error_netdev(netdev,
                                  "Could not append IFLA_IPTUN_REMOTE attribute: %s",
@@ -443,27 +482,6 @@ int netdev_create_tunnel(Link *link, sd_rtnl_message_handler_t callback) {
         assert(netdev->ifname);
         assert(netdev->manager);
         assert(netdev->manager->rtnl);
-        assert(netdev->manager->kmod_ctx);
-
-        /* Load kernel module first */
-        switch(netdev->kind) {
-        case NETDEV_KIND_IPIP:
-        case NETDEV_KIND_GRE:
-        case NETDEV_KIND_SIT:
-                r = load_module(netdev->manager->kmod_ctx,
-                                netdev_kind_to_string(netdev->kind));
-                if (r < 0) {
-                        log_error_netdev(netdev,
-                                         "Could not load Kernel module: %s . Ignoring",
-                                         netdev_kind_to_string(netdev->kind));
-                        return r;
-                }
-                break;
-        case NETDEV_KIND_VTI:
-                break;
-        default:
-                return -ENOTSUP;
-        }
 
         r = sd_rtnl_message_new_link(netdev->manager->rtnl, &m, RTM_NEWLINK, 0);
         if (r < 0) {