chiark / gitweb /
networkd: support route scopes
authorTom Gundersen <teg@jklm.no>
Mon, 9 Feb 2015 15:22:34 +0000 (16:22 +0100)
committerTom Gundersen <teg@jklm.no>
Mon, 9 Feb 2015 15:53:54 +0000 (16:53 +0100)
For now we only support the hardcoded values RT_SCOPE_{UNIVERSE,LOCAL,HOST},
and not numerical values or values from /etc/iproute2/rt_scopes.

This addresses https://bugs.freedesktop.org/show_bug.cgi?id=88508.

man/systemd.network.xml
src/network/networkd-network-gperf.gperf
src/network/networkd-route.c
src/network/networkd.h

index 6c137e16e994a897e63d0bcff0d85449cf9f4eb0..9b3a92d266e9b5e2ebb2ad6ce8c3d2f04fb0aef8 100644 (file)
             <para>The metric of the route. An unsigned integer</para>
           </listitem>
         </varlistentry>
+        <varlistentry>
+          <term><varname>Scope=</varname></term>
+          <listitem>
+            <para>The scope of the route. One of the values <literal>global</literal>,
+            <literal>link</literal> or <literal>host</literal>. Defaults to
+            <literal>global</literal>.</para>
+          </listitem>
+        </varlistentry>
       </variablelist>
   </refsect1>
 
index 6f295488bdda4ed3d652bacbfacb5d757dc36b96..1731e04228124e21f8e4910a7e584e56d892cd9a 100644 (file)
@@ -56,6 +56,7 @@ Route.Gateway,               config_parse_gateway,               0,
 Route.Destination,           config_parse_destination,           0,                             0
 Route.Source,                config_parse_destination,           0,                             0
 Route.Metric,                config_parse_route_priority,        0,                             0
+Route.Scope,                 config_parse_route_scope,           0,                             0
 DHCP.UseDNS,                 config_parse_bool,                  0,                             offsetof(Network, dhcp_dns)
 DHCP.UseMTU,                 config_parse_bool,                  0,                             offsetof(Network, dhcp_mtu)
 DHCP.UseHostname,            config_parse_bool,                  0,                             offsetof(Network, dhcp_hostname)
index 590dd49df91efed445a6936f9e0527e4e606afb7..c2d1ffca25444383ac1a42421406746673792de2 100644 (file)
@@ -427,3 +427,44 @@ int config_parse_route_priority(const char *unit,
 
         return 0;
 }
+
+int config_parse_route_scope(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;
+        _cleanup_route_free_ Route *n = NULL;
+        int r;
+
+        assert(filename);
+        assert(section);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        r = route_new_static(network, section_line, &n);
+        if (r < 0)
+                return r;
+
+        if (streq(rvalue, "host"))
+                n->scope = RT_SCOPE_HOST;
+        else if (streq(rvalue, "link"))
+                n->scope = RT_SCOPE_LINK;
+        else if (streq(rvalue, "global"))
+                n->scope = RT_SCOPE_UNIVERSE;
+        else {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+                           "Unknown route scope: %s", rvalue);
+                return 0;
+        }
+
+        n = NULL;
+
+        return 0;
+}
index 6fb920b1587b780897c0ac4562602b189aeea525..22cc51d93376780c293b416a9041acc4fda4cbd5 100644 (file)
@@ -352,6 +352,10 @@ int config_parse_destination(const char *unit, const char *filename, unsigned li
 int config_parse_route_priority(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);
+
+int config_parse_route_scope(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);
 /* Address */
 int address_new_static(Network *network, unsigned section, Address **ret);
 int address_new_dynamic(Address **ret);