chiark / gitweb /
networkd: fdb - fix const warning
[elogind.git] / src / network / networkd-link.c
index eff1ce94be9bb5273bfd2ec67dc63e598dd4ce95..7b488162f98d12ca60b4e6ed0db5194da4757b83 100644 (file)
@@ -72,7 +72,17 @@ bool link_ipv4ll_enabled(Link *link) {
         if (!link->network)
                 return false;
 
-        return link->network->ipv4ll;
+        return IN_SET(link->network->link_local, ADDRESS_FAMILY_IPV4, ADDRESS_FAMILY_YES);
+}
+
+bool link_ipv6ll_enabled(Link *link) {
+        if (link->flags & IFF_LOOPBACK)
+                return false;
+
+        if (!link->network)
+                return false;
+
+        return IN_SET(link->network->link_local, ADDRESS_FAMILY_IPV6, ADDRESS_FAMILY_YES);
 }
 
 bool link_lldp_enabled(Link *link) {
@@ -718,12 +728,12 @@ int link_address_drop_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata)
         return 1;
 }
 
-static int link_set_bridge_fdb(const Link *const link) {
+static int link_set_bridge_fdb(Link *const link) {
         FdbEntry *fdb_entry;
         int r = 0;
 
         LIST_FOREACH(static_fdb_entries, fdb_entry, link->network->static_fdb_entries) {
-                r = fdb_entry_configure(link->manager->rtnl, fdb_entry, link->ifindex);
+                r = fdb_entry_configure(link, fdb_entry);
                 if(r < 0) {
                         log_link_error(link, "Failed to add MAC entry to static MAC table: %s", strerror(-r));
                         break;
@@ -1087,6 +1097,46 @@ static int link_up(Link *link) {
                 }
         }
 
+        r = sd_rtnl_message_open_container(req, IFLA_AF_SPEC);
+        if (r < 0) {
+                log_link_error(link, "Could not open IFLA_AF_SPEC container: %s", strerror(-r));
+                return r;
+        }
+
+        r = sd_rtnl_message_open_container(req, AF_INET6);
+        if (r < 0) {
+                log_link_error(link, "Could not open AF_INET6 container: %s", strerror(-r));
+                return r;
+        }
+
+        if (!link_ipv6ll_enabled(link)) {
+                r = sd_rtnl_message_append_u8(req, IFLA_INET6_ADDR_GEN_MODE, IN6_ADDR_GEN_MODE_NONE);
+                if (r < 0) {
+                        log_link_error(link, "Could not append IFLA_INET6_ADDR_GEN_MODE: %s", strerror(-r));
+                        return r;
+                }
+        }
+
+        if (!in_addr_is_null(AF_INET6, &link->network->ipv6_token)) {
+                r = sd_rtnl_message_append_in6_addr(req, IFLA_INET6_TOKEN, &link->network->ipv6_token.in6);
+                if (r < 0) {
+                        log_link_error(link, "Could not append IFLA_INET6_TOKEN: %s", strerror(-r));
+                        return r;
+                }
+        }
+
+        r = sd_rtnl_message_close_container(req);
+        if (r < 0) {
+                log_link_error(link, "Could not close AF_INET6 container: %s", strerror(-r));
+                return r;
+        }
+
+        r = sd_rtnl_message_close_container(req);
+        if (r < 0) {
+                log_link_error(link, "Could not close IFLA_AF_SPEC container: %s", strerror(-r));
+                return r;
+        }
+
         r = sd_rtnl_call_async(link->manager->rtnl, req, link_up_handler, link,
                                0, NULL);
         if (r < 0) {
@@ -1391,8 +1441,8 @@ static int link_initialized_and_synced(sd_rtnl *rtnl, sd_rtnl_message *m,
                 return r;
 
         if (link->flags & IFF_LOOPBACK) {
-                if (network->ipv4ll)
-                        log_link_debug(link, "ignoring IPv4LL for loopback link");
+                if (network->link_local != ADDRESS_FAMILY_NO)
+                        log_link_debug(link, "ignoring link-local autoconfiguration for loopback link");
 
                 if (network->dhcp != ADDRESS_FAMILY_NO)
                         log_link_debug(link, "ignoring DHCP clients for loopback link");