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
%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)
*m = (Manager) {
.speed_meter_interval_usec = SPEED_METER_DEFAULT_TIME_INTERVAL,
.manage_foreign_routes = true,
+ .manage_foreign_rules = true,
.ethtool_fd = -1,
};
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;
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));