mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 02:15:17 +00:00
feat: Support blackhole, prohibit and unreachable route types
It is useful and common practice to configure the routes with blackhole, prohibit, and unreachable route types when users have BGP routing setups. Notice that this feature is only for nm provider using `network_connections` variable. Configuring blackhole, prohibit, and unreachable route types is also supported by using `network_state` since nmstate version 2.2.20 (the setting name is `route-type`). Resolves: https://issues.redhat.com/browse/RHEL-19579 Signed-off-by: Wen Liang <liangwen12year@gmail.com>
This commit is contained in:
parent
735d4befa7
commit
b7492a27ba
8 changed files with 391 additions and 7 deletions
|
|
@ -674,6 +674,11 @@ class ArgValidatorIPRoute(ArgValidatorDict):
|
|||
ArgValidatorNum(
|
||||
"metric", default_value=-1, val_min=-1, val_max=UINT32_MAX
|
||||
),
|
||||
ArgValidatorStr(
|
||||
"type",
|
||||
default_value=None,
|
||||
enum_values=["blackhole", "prohibit", "unreachable"],
|
||||
),
|
||||
ArgValidatorRouteTable("table"),
|
||||
],
|
||||
default_value=None,
|
||||
|
|
@ -688,6 +693,7 @@ class ArgValidatorIPRoute(ArgValidatorDict):
|
|||
result["family"] = family
|
||||
|
||||
gateway = result["gateway"]
|
||||
route_type = result["type"]
|
||||
if gateway is not None:
|
||||
if family != gateway["family"]:
|
||||
raise ValidationError(
|
||||
|
|
@ -695,6 +701,12 @@ class ArgValidatorIPRoute(ArgValidatorDict):
|
|||
"conflicting address family between network and gateway '%s'"
|
||||
% (gateway["address"]),
|
||||
)
|
||||
if route_type is not None:
|
||||
raise ValidationError(
|
||||
name,
|
||||
"a %s route can not have a gateway '%s'"
|
||||
% (route_type, gateway["address"]),
|
||||
)
|
||||
result["gateway"] = gateway["address"]
|
||||
|
||||
prefix = result["prefix"]
|
||||
|
|
@ -2607,6 +2619,14 @@ class ArgValidator_ListConnections(ArgValidatorList):
|
|||
"NetworkManger until NM 1.30",
|
||||
)
|
||||
|
||||
if connection["ip"]["route"]:
|
||||
if mode == self.VALIDATE_ONE_MODE_INITSCRIPTS:
|
||||
for route in connection["ip"]["route"]:
|
||||
if route["type"] is not None:
|
||||
raise ValidationError.from_connection(
|
||||
idx,
|
||||
"type is not supported by initscripts",
|
||||
)
|
||||
if connection["ip"]["routing_rule"]:
|
||||
if mode == self.VALIDATE_ONE_MODE_INITSCRIPTS:
|
||||
raise ValidationError.from_connection(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue