chiark / gitweb /
networkd: generalize IPv4LL to LinkLocal
authorTom Gundersen <teg@jklm.no>
Sun, 8 Feb 2015 21:27:15 +0000 (22:27 +0100)
committerTom Gundersen <teg@jklm.no>
Mon, 9 Feb 2015 11:20:10 +0000 (12:20 +0100)
This allows both IPv4 and IPv6 link-local addresses to be enabled or disabled. By default
we still enable IPv6LL and disable IPv4LL. The old config option is kept for backwards
compatibility, but removed from the documentation.

man/systemd.network.xml
network/80-container-host0.network
network/80-container-ve.network
src/network/networkd-ipv4ll.c
src/network/networkd-link.c
src/network/networkd-link.h
src/network/networkd-network-gperf.gperf
src/network/networkd-network.c
src/network/networkd.h

index b8facdc0af99debad22342866c7c2ee8f18fd039..6c137e16e994a897e63d0bcff0d85449cf9f4eb0 100644 (file)
           </listitem>
         </varlistentry>
         <varlistentry>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><varname>IPv4LL=</varname></term>
+          <term><varname>LinkLocal=</varname></term>
           <listitem>
           <listitem>
-            <para>A boolean. When true, enables IPv4 link-local support.
-            </para>
+            <para>Enables link-local address autoconfiguration. Accepts
+            <literal>yes</literal>, <literal>no</literal>,
+            <literal>ipv4</literal>, or <literal>ipv6</literal>. Defaults to
+            <literal>ipv6</literal>.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
           </listitem>
         </varlistentry>
         <varlistentry>
index 8d9293f23958bac3db4903d4db5048acded663d1..4e68c3d549db1d60a54dc3fd60225fde56ddffc0 100644 (file)
@@ -11,4 +11,4 @@ Name=host0
 
 [Network]
 DHCP=yes
 
 [Network]
 DHCP=yes
-IPv4LL=yes
+LinkLocal=yes
index 7bde1d49340df8110aa02750eaa4389fb3a1a1b7..cac436d81d5a4dde3342451e3888ec7d336d093c 100644 (file)
@@ -12,6 +12,6 @@ Driver=veth
 [Network]
 # Default to using a /28 prefix, giving up to 13 addresses per container.
 Address=0.0.0.0/28
 [Network]
 # Default to using a /28 prefix, giving up to 13 addresses per container.
 Address=0.0.0.0/28
-IPv4LL=yes
+LinkLocal=yes
 DHCPServer=yes
 IPMasquerade=yes
 DHCPServer=yes
 IPMasquerade=yes
index 339bf4d190f9b4a286875e2442cdb20032107e69..8050801e1959d69cedf0638721d79ed44d744b51 100644 (file)
@@ -209,7 +209,7 @@ int ipv4ll_configure(Link *link) {
 
         assert(link);
         assert(link->network);
 
         assert(link);
         assert(link->network);
-        assert(link->network->ipv4ll);
+        assert(IN_SET(link->network->link_local, ADDRESS_FAMILY_IPV4, ADDRESS_FAMILY_YES));
 
         r = sd_ipv4ll_new(&link->ipv4ll);
         if (r < 0)
 
         r = sd_ipv4ll_new(&link->ipv4ll);
         if (r < 0)
index eff1ce94be9bb5273bfd2ec67dc63e598dd4ce95..3b9881d71e57c88825f580e11596f1c225d5a060 100644 (file)
@@ -72,7 +72,17 @@ bool link_ipv4ll_enabled(Link *link) {
         if (!link->network)
                 return false;
 
         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) {
 }
 
 bool link_lldp_enabled(Link *link) {
@@ -1087,6 +1097,38 @@ static int link_up(Link *link) {
                 }
         }
 
                 }
         }
 
+        if (!link_ipv6ll_enabled(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;
+                }
+
+                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;
+                }
+
+                r = sd_rtnl_message_close_container(req);
+                if (r < 0) {
+                        log_link_error(link, "Could not close AF_INET6 contaire: %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 contaire: %s", strerror(-r));
+                        return r;
+                }
+        }
+
         r = sd_rtnl_call_async(link->manager->rtnl, req, link_up_handler, link,
                                0, NULL);
         if (r < 0) {
         r = sd_rtnl_call_async(link->manager->rtnl, req, link_up_handler, link,
                                0, NULL);
         if (r < 0) {
@@ -1391,8 +1433,8 @@ static int link_initialized_and_synced(sd_rtnl *rtnl, sd_rtnl_message *m,
                 return r;
 
         if (link->flags & IFF_LOOPBACK) {
                 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");
 
                 if (network->dhcp != ADDRESS_FAMILY_NO)
                         log_link_debug(link, "ignoring DHCP clients for loopback link");
index ce83f24da3d0406584d38c2d52e66c3d522bc198..449dbc8846f2922215bd16d07e043838ad60ac0f 100644 (file)
@@ -116,6 +116,7 @@ int icmp6_configure(Link *link);
 
 bool link_lldp_enabled(Link *link);
 bool link_ipv4ll_enabled(Link *link);
 
 bool link_lldp_enabled(Link *link);
 bool link_ipv4ll_enabled(Link *link);
+bool link_ipv6ll_enabled(Link *link);
 bool link_dhcp4_server_enabled(Link *link);
 bool link_dhcp4_enabled(Link *link);
 bool link_dhcp6_enabled(Link *link);
 bool link_dhcp4_server_enabled(Link *link);
 bool link_dhcp4_enabled(Link *link);
 bool link_dhcp6_enabled(Link *link);
index 26fce97b6aeb15bc3ac8d59b885e283d5dca94fe..525f2ba799ad2ce99ea47a0784322e6ab475e49f 100644 (file)
@@ -36,7 +36,7 @@ Network.VXLAN,               config_parse_netdev,                0,
 Network.Tunnel,              config_parse_tunnel,                0,                             0
 Network.DHCP,                config_parse_dhcp,                  0,                             offsetof(Network, dhcp)
 Network.DHCPServer,          config_parse_bool,                  0,                             offsetof(Network, dhcp_server)
 Network.Tunnel,              config_parse_tunnel,                0,                             0
 Network.DHCP,                config_parse_dhcp,                  0,                             offsetof(Network, dhcp)
 Network.DHCPServer,          config_parse_bool,                  0,                             offsetof(Network, dhcp_server)
-Network.IPv4LL,              config_parse_bool,                  0,                             offsetof(Network, ipv4ll)
+Network.LinkLocal,           config_parse_address_family_boolean,0,                             offsetof(Network, link_local)
 Network.IPv4LLRoute,         config_parse_bool,                  0,                             offsetof(Network, ipv4ll_route)
 Network.LLDP,                config_parse_bool,                  0,                             offsetof(Network, lldp)
 Network.Address,             config_parse_address,               0,                             0
 Network.IPv4LLRoute,         config_parse_bool,                  0,                             offsetof(Network, ipv4ll_route)
 Network.LLDP,                config_parse_bool,                  0,                             offsetof(Network, lldp)
 Network.Address,             config_parse_address,               0,                             0
@@ -69,6 +69,7 @@ Bridge.Cost,                 config_parse_unsigned,              0,
 BridgeFDB.MACAddress,        config_parse_fdb_hwaddr,            0,                             0
 BridgeFDB.VLANId,            config_parse_fdb_vlan_id,           0,                             0
 /* backwards compatibility: do not add new entries to this section */
 BridgeFDB.MACAddress,        config_parse_fdb_hwaddr,            0,                             0
 BridgeFDB.VLANId,            config_parse_fdb_vlan_id,           0,                             0
 /* backwards compatibility: do not add new entries to this section */
+Network.IPv4LL,              config_parse_ipv4ll,                0,                             offsetof(Network, link_local)
 DHCPv4.UseDNS,               config_parse_bool,                  0,                             offsetof(Network, dhcp_dns)
 DHCPv4.UseMTU,               config_parse_bool,                  0,                             offsetof(Network, dhcp_mtu)
 DHCPv4.UseHostname,          config_parse_bool,                  0,                             offsetof(Network, dhcp_hostname)
 DHCPv4.UseDNS,               config_parse_bool,                  0,                             offsetof(Network, dhcp_dns)
 DHCPv4.UseMTU,               config_parse_bool,                  0,                             offsetof(Network, dhcp_mtu)
 DHCPv4.UseHostname,          config_parse_bool,                  0,                             offsetof(Network, dhcp_hostname)
index 504419cdb0ef4f215fc4e024d9ccfac18770a893..c39ba6dfa25fdcf7ce7e685b11b5b9e2f7042701 100644 (file)
@@ -107,6 +107,8 @@ static int network_load_one(Manager *manager, const char *filename) {
 
         network->llmnr = LLMNR_SUPPORT_YES;
 
 
         network->llmnr = LLMNR_SUPPORT_YES;
 
+        network->link_local = ADDRESS_FAMILY_IPV6;
+
         r = config_parse(NULL, filename, file,
                          "Match\0"
                          "Link\0"
         r = config_parse(NULL, filename, file,
                          "Match\0"
                          "Link\0"
@@ -520,6 +522,37 @@ int config_parse_tunnel(const char *unit,
         return 0;
 }
 
         return 0;
 }
 
+int config_parse_ipv4ll(
+                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) {
+
+        AddressFamilyBoolean *link_local = data;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        /* Note that this is mostly like
+         * config_parse_address_family_boolean(), except that it
+         * applies only to IPv4 */
+
+        if (parse_boolean(rvalue))
+                *link_local |= ADDRESS_FAMILY_IPV4;
+        else
+                *link_local &= ~ADDRESS_FAMILY_IPV4;
+
+        return 0;
+}
+
 int config_parse_dhcp(
                 const char* unit,
                 const char *filename,
 int config_parse_dhcp(
                 const char* unit,
                 const char *filename,
index 147b21acdc9c096012cf8c1335ed49c1228544af..4f3bcf36f9d2c6cd3c165b6d37dd2f9b77c2638b 100644 (file)
@@ -126,7 +126,7 @@ struct Network {
         bool dhcp_critical;
         bool dhcp_routes;
         unsigned dhcp_route_metric;
         bool dhcp_critical;
         bool dhcp_routes;
         unsigned dhcp_route_metric;
-        bool ipv4ll;
+        AddressFamilyBoolean link_local;
         bool ipv4ll_route;
 
         bool dhcp_server;
         bool ipv4ll_route;
 
         bool dhcp_server;
@@ -399,6 +399,12 @@ int config_parse_dhcp(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);
 
                       const char *section, unsigned section_line, const char *lvalue,
                       int ltype, const char *rvalue, void *data, void *userdata);
 
+/* IPv4LL support (legacy) */
+
+int config_parse_ipv4ll(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);
+
 /* LLMNR support */
 
 const char* llmnr_support_to_string(LLMNRSupport i) _const_;
 /* LLMNR support */
 
 const char* llmnr_support_to_string(LLMNRSupport i) _const_;