]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkd: route - support 'onlink' routes
authorTom Gundersen <teg@jklm.no>
Tue, 23 Feb 2016 12:27:50 +0000 (13:27 +0100)
committerTom Gundersen <teg@jklm.no>
Thu, 10 Mar 2016 13:51:14 +0000 (14:51 +0100)
By setting GatewayOnlink=yes, the kernel will assume that the gateway is onlink
even if there is no route to it.

Resolves issue #1283.

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

index c6bbb958337f0014ac8e1a79fa447de5f66eb005..94f732e5283fed936fbed2137bbcf6bce32c1bb8 100644 (file)
             <para>As in the <literal>[Network]</literal> section.</para>
           </listitem>
         </varlistentry>
+        <varlistentry>
+          <term><varname>GatewayOnlink=</varname></term>
+          <listitem>
+            <para>Explicitly consider the gateway to be onlink, even if there
+            is no route to it. A boolean, defaults to
+            <literal>no</literal>.</para>
+          </listitem>
+        </varlistentry>
         <varlistentry>
           <term><varname>Destination=</varname></term>
           <listitem>
index 7a9a136d5b33da5ef3f55019cccbd1d5fc4c62c0..4def6b8d493de8a477bfbfe47ea4d96dbee8ef95 100644 (file)
@@ -64,6 +64,7 @@ Address.Peer,                           config_parse_address,
 Address.Broadcast,                      config_parse_broadcast,                         0,                             0
 Address.Label,                          config_parse_label,                             0,                             0
 Route.Gateway,                          config_parse_gateway,                           0,                             0
+Route.GatewayOnlink,                    config_parse_gateway_onlink,                    0,                             0
 Route.Destination,                      config_parse_destination,                       0,                             0
 Route.Source,                           config_parse_destination,                       0,                             0
 Route.Metric,                           config_parse_route_priority,                    0,                             0
index e065a5a5a9ef94c28b352f7479faafe6f5822508..001452370f9877469d165080280cb55ddeb7474a 100644 (file)
@@ -581,6 +581,47 @@ int config_parse_gateway(const char *unit,
         return 0;
 }
 
+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) {
+        Network *network = userdata;
+        _cleanup_route_free_ Route *n = NULL;
+        bool onlink;
+        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;
+
+        r = config_parse_bool(unit, filename, line, section,
+                              section_line, lvalue, ltype,
+                              rvalue, &onlink, userdata);
+        if (r < 0)
+                return r;
+
+        if (onlink)
+                n->flags |= RTNH_F_ONLINK;
+        else
+                n->flags &= ~RTNH_F_ONLINK;
+
+        n = NULL;
+
+        return 0;
+}
+
 int config_parse_preferred_src(const char *unit,
                 const char *filename,
                 unsigned line,
index a4a4bf265377b9c822c986dcd4f6becb04a2fc0a..0341a909235ea919a6c3da0fc7e9969914951e76 100644 (file)
@@ -70,6 +70,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Route*, route_free);
 #define _cleanup_route_free_ _cleanup_(route_freep)
 
 int config_parse_gateway(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_preferred_src(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_destination(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_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);