1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-03-08 20:58:20 +03:00

network: wireguard: also accept negative boolean values to disable adding routes

RouteTable=off was introduced to provide consistency with wg-quick
command. This makes the RouteTable= settings accepts other negative
boolean values.
This commit is contained in:
Yu Watanabe 2022-01-16 15:59:45 +09:00
parent cfe1237f38
commit e135559d80
2 changed files with 10 additions and 10 deletions

View File

@ -1575,14 +1575,14 @@
<term><varname>RouteTable=</varname></term> <term><varname>RouteTable=</varname></term>
<listitem> <listitem>
<para>The table identifier for the routes to the addresses specified in the <para>The table identifier for the routes to the addresses specified in the
<varname>AllowedIPs=</varname>. Takes the special value <literal>off</literal>, one of the <varname>AllowedIPs=</varname>. Takes a negative boolean value, one of the predefined names
predefined names <literal>default</literal>, <literal>main</literal>, and <literal>default</literal>, <literal>main</literal>, and <literal>local</literal>, names
<literal>local</literal>, names defined in <varname>RouteTable=</varname> in defined in <varname>RouteTable=</varname> in
<citerefentry><refentrytitle>networkd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>, <citerefentry><refentrytitle>networkd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
or a number in the range 1…4294967295. When <literal>off</literal> the routes to the or a number in the range 1…4294967295. When <literal>off</literal> the routes to the
addresses specified in the <varname>AllowedIPs=</varname> setting will not be configured. addresses specified in the <varname>AllowedIPs=</varname> setting will not be configured.
Defaults to <literal>off</literal>. This setting will be ignored when the same setting is Defaults to false. This setting will be ignored when the same setting is specified in the
specified in the [WireGuardPeer] section.</para> [WireGuardPeer] section.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
@ -1682,9 +1682,9 @@
<term><varname>RouteTable=</varname></term> <term><varname>RouteTable=</varname></term>
<listitem> <listitem>
<para>The table identifier for the routes to the addresses specified in the <para>The table identifier for the routes to the addresses specified in the
<varname>AllowedIPs=</varname>. Takes the special value <literal>off</literal>, one of the <varname>AllowedIPs=</varname>. Takes a negative boolean value, one of the predefined names
predefined names <literal>default</literal>, <literal>main</literal>, and <literal>default</literal>, <literal>main</literal>, and <literal>local</literal>, names
<literal>local</literal>, names defined in <varname>RouteTable=</varname> in defined in <varname>RouteTable=</varname> in
<citerefentry><refentrytitle>networkd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>, <citerefentry><refentrytitle>networkd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
or a number in the range 1…4294967295. Defaults to unset, and the value specified in the or a number in the range 1…4294967295. Defaults to unset, and the value specified in the
same setting in the [WireGuard] section will be used.</para> same setting in the [WireGuard] section will be used.</para>

View File

@ -895,7 +895,7 @@ int config_parse_wireguard_route_table(
assert(data); assert(data);
assert(userdata); assert(userdata);
if (isempty(rvalue) || streq(rvalue, "off")) { if (isempty(rvalue) || parse_boolean(rvalue) == 0) {
*table = 0; /* Disabled. */ *table = 0; /* Disabled. */
return 0; return 0;
} }
@ -947,7 +947,7 @@ int config_parse_wireguard_peer_route_table(
return 0; return 0;
} }
if (streq(rvalue, "off")) { if (parse_boolean(rvalue) == 0) {
peer->route_table = 0; /* Disabled. */ peer->route_table = 0; /* Disabled. */
peer->route_table_set = true; peer->route_table_set = true;
TAKE_PTR(peer); TAKE_PTR(peer);