Support 'route_metric4' for initscripts provider

The user want to change the metric for the default route, add support
for that.

https://bugzilla.redhat.com/show_bug.cgi?id=2134201

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
This commit is contained in:
Wen Liang 2022-10-11 18:20:18 -04:00 committed by Fernando Fernández Mancera
parent 5c9456a8a3
commit c913aa0b93
2 changed files with 5 additions and 3 deletions

View file

@ -526,7 +526,8 @@ The IP configuration supports the following options:
[`ipv6.route-metric`](https://developer.gnome.org/NetworkManager/stable/nm-settings.html#nm-settings.property.ipv6.route-metric)
properties, respectively. If specified, it determines the route metric for DHCP
assigned routes and the default route, and thus the priority for multiple
interfaces.
interfaces. For `initscripts`, `route_metric4` sets the metric for the default
route and `route_metric6` is not supported.
- `route`

View file

@ -323,8 +323,6 @@ class IfcfgUtil:
if ip["dhcp4_send_hostname"] is not None:
warn_fcn("ip.dhcp4_send_hostname is not supported by initscripts provider")
if ip["route_metric4"] is not None and ip["route_metric4"] >= 0:
warn_fcn("ip.route_metric4 is not supported by initscripts provider")
if ip["route_metric6"] is not None and ip["route_metric6"] >= 0:
warn_fcn("ip.route_metric6 is not supported by initscripts provider")
@ -516,6 +514,9 @@ class IfcfgUtil:
else:
ifcfg["DEFROUTE"] = "no"
if ip["route_metric4"] is not None and ip["route_metric4"] >= 0:
ifcfg["METRIC"] = str(ip["route_metric4"])
route4 = []
route6 = []
for r in ip["route"]: