1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

Merge pull request #19287 from yuwata/network-manage-foreign-routing-policy-rule-19106

network: add ManageForeignRoutingPolicyRules= boolean setting
This commit is contained in:
Yu Watanabe 2021-04-14 19:01:41 +09:00 committed by GitHub
commit a2b1572ce4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 10 deletions

View File

@ -62,12 +62,24 @@
If <varname>SpeedMeter=no</varname>, the value is ignored. Defaults to 10sec.</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>ManageForeignRoutingPolicyRules=</varname></term>
<listitem><para>A boolean. When true, <command>systemd-networkd</command> will remove rules
that are not configured in .network files (except for rules with protocol
<literal>kernel</literal>). When false, it will not remove any foreign rules, keeping them even
if they are not configured in a .network file. Defaults to yes.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>ManageForeignRoutes=</varname></term>
<listitem><para>A boolean. When true, <command>systemd-networkd</command> will store any routes
configured by other tools in its memory. When false, <command>systemd-networkd</command> will
not manage the foreign routes, thus they are kept even if <varname>KeepConfiguration=</varname>
is false. Defaults to yes.</para></listitem>
<listitem><para>A boolean. When true, <command>systemd-networkd</command> will remove routes
that are not configured in .network files (except for routes with protocol
<literal>kernel</literal>, <literal>dhcp</literal> when <varname>KeepConfiguration=</varname>
is true or <literal>dhcp</literal>, and <literal>static</literal> when
<varname>KeepConfiguration=</varname> is true or <literal>static</literal>). When false, it will
not remove any foreign routes, keeping them even if they are not configured in a .network file.
Defaults to yes.</para></listitem>
</varlistentry>
<varlistentry>

View File

@ -20,9 +20,10 @@ struct ConfigPerfItem;
%struct-type
%includes
%%
Network.SpeedMeter, config_parse_bool, 0, offsetof(Manager, use_speed_meter)
Network.SpeedMeterIntervalSec, config_parse_sec, 0, offsetof(Manager, speed_meter_interval_usec)
Network.ManageForeignRoutes, config_parse_bool, 0, offsetof(Manager, manage_foreign_routes)
Network.RouteTable, config_parse_route_table_names, 0, 0
DHCP.DUIDType, config_parse_duid_type, 0, offsetof(Manager, duid)
DHCP.DUIDRawData, config_parse_duid_rawdata, 0, offsetof(Manager, duid)
Network.SpeedMeter, config_parse_bool, 0, offsetof(Manager, use_speed_meter)
Network.SpeedMeterIntervalSec, config_parse_sec, 0, offsetof(Manager, speed_meter_interval_usec)
Network.ManageForeignRoutingPolicyRules, config_parse_bool, 0, offsetof(Manager, manage_foreign_rules)
Network.ManageForeignRoutes, config_parse_bool, 0, offsetof(Manager, manage_foreign_routes)
Network.RouteTable, config_parse_route_table_names, 0, 0
DHCP.DUIDType, config_parse_duid_type, 0, offsetof(Manager, duid)
DHCP.DUIDRawData, config_parse_duid_rawdata, 0, offsetof(Manager, duid)

View File

@ -380,6 +380,7 @@ int manager_new(Manager **ret) {
*m = (Manager) {
.speed_meter_interval_usec = SPEED_METER_DEFAULT_TIME_INTERVAL,
.manage_foreign_routes = true,
.manage_foreign_rules = true,
.ethtool_fd = -1,
};
@ -655,6 +656,9 @@ static int manager_enumerate_rules(Manager *m) {
assert(m);
assert(m->rtnl);
if (!m->manage_foreign_rules)
return 0;
r = sd_rtnl_message_new_routing_policy_rule(m->rtnl, &req, RTM_GETRULE, 0);
if (r < 0)
return r;

View File

@ -32,6 +32,7 @@ struct Manager {
bool dirty;
bool restarting;
bool manage_foreign_routes;
bool manage_foreign_rules;
Set *dirty_links;

View File

@ -977,6 +977,8 @@ int manager_rtnl_process_rule(sd_netlink *rtnl, sd_netlink_message *message, Man
case RTM_NEWRULE:
if (rule)
log_routing_policy_rule_debug(tmp, tmp->family, "Received remembered", NULL, m);
else if (!m->manage_foreign_routes)
log_routing_policy_rule_debug(tmp, tmp->family, "Ignoring received foreign", NULL, m);
else {
log_routing_policy_rule_debug(tmp, tmp->family, "Remembering foreign", NULL, m);
r = routing_policy_rule_consume_foreign(m, TAKE_PTR(tmp));

View File

@ -15,7 +15,9 @@
[Network]
#SpeedMeter=no
#SpeedMeterIntervalSec=10sec
#ManageForeignRoutingPolicyRules=yes
#ManageForeignRoutes=yes
#RouteTable=
[DHCP]
#DUIDType=vendor