networkd: add support to configure route protocol. (#5890)
authorSusant Sahani <ssahani@users.noreply.github.com>
Tue, 9 May 2017 18:01:25 +0000 (18:01 +0000)
committerLennart Poettering <lennart@poettering.net>
Tue, 9 May 2017 18:01:25 +0000 (20:01 +0200)
Closes: #5889

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

index ad0e0cf..74ee8e5 100644 (file)
           </para>
           </listitem>
         </varlistentry>
+        <varlistentry>
+          <term><varname>Protocol=</varname></term>
+          <listitem>
+            <para>The Protocol identifier for the route. Takes a number between 0 and 255 or the special values
+            <literal>kernel</literal>, <literal>boot</literal> and <literal>static</literal>. Defaults to
+            <literal>static</literal>.
+            </para>
+          </listitem>
+        </varlistentry>
       </variablelist>
   </refsect1>
 
index ee8bd6f..ef53b52 100644 (file)
@@ -90,6 +90,7 @@ Route.PreferredSource,                  config_parse_preferred_src,
 Route.Table,                            config_parse_route_table,                       0,                             0
 Route.GatewayOnlink,                    config_parse_gateway_onlink,                    0,                             0
 Route.IPv6Preference,                   config_parse_ipv6_route_preference,             0,                             0
+Route.Protocol,                         config_parse_route_protocol,                    0,                             0
 DHCP.ClientIdentifier,                  config_parse_dhcp_client_identifier,            0,                             offsetof(Network, dhcp_client_identifier)
 DHCP.UseDNS,                            config_parse_bool,                              0,                             offsetof(Network, dhcp_use_dns)
 DHCP.UseNTP,                            config_parse_bool,                              0,                             offsetof(Network, dhcp_use_ntp)
index ff93fe4..c5ee08a 100644 (file)
@@ -1012,3 +1012,40 @@ int config_parse_ipv6_route_preference(const char *unit,
 
         return 0;
 }
+
+int config_parse_route_protocol(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;
+
+        r = route_new_static(network, filename, section_line, &n);
+        if (r < 0)
+                return r;
+
+        if (streq(rvalue, "kernel"))
+                n->protocol = RTPROT_KERNEL;
+        else if (streq(rvalue, "boot"))
+                n->protocol = RTPROT_BOOT;
+        else if (streq(rvalue, "static"))
+                n->protocol = RTPROT_STATIC;
+        else {
+                r = safe_atou8(rvalue , &n->protocol);
+                if (r < 0) {
+                        log_syntax(unit, LOG_ERR, filename, line, r, "Could not parse route protocol \"%s\", ignoring assignment: %m", rvalue);
+                        return 0;
+                }
+        }
+
+        n = NULL;
+
+        return 0;
+}
index 47ff6f2..efd1e53 100644 (file)
@@ -77,3 +77,4 @@ int config_parse_route_scope(const char *unit, const char *filename, unsigned li
 int config_parse_route_table(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_gateway_onlink(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_ipv6_route_preference(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_protocol(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);