mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 02:15:17 +00:00
fix: Allow address 0.0.0.0/0 or ::/0 for 'from'/'to' in routing rule validation
`from 0.0.0.0/0` means from all IPv4 addresses, `from ::/0` means from all IPv6 addresses. In NM, if `from` property is not specified in a routing rule, NM still appends `from 0.0.0.0/0` or `from ::/0` to the rule. NM also allows to specify `to 0.0.0.0/0` or `to ::/0` in a routing rule, but the connection profiles will only show the `from` setting for the rule. Signed-off-by: Wen Liang <liangwen12year@gmail.com>
This commit is contained in:
parent
815b5b0cc5
commit
c7a31e7079
4 changed files with 41 additions and 5 deletions
|
|
@ -779,15 +779,27 @@ class ArgValidatorIPRoutingRule(ArgValidatorDict):
|
|||
name,
|
||||
"missing 'table' for the routing rule",
|
||||
)
|
||||
|
||||
if result["from"] is not None:
|
||||
# `from 0.0.0.0/0` means from all IPv4 addresses
|
||||
# `from ::/0` means from all IPv6 addresses
|
||||
# In NM, if `from` property is not specified in a routing rule, NM
|
||||
# still appends `from 0.0.0.0/0` or `from ::/0` to the rule
|
||||
if result["from"] is not None and result["from"]["address"] not in [
|
||||
"0.0.0.0",
|
||||
"::",
|
||||
]:
|
||||
if result["from"]["prefix"] == 0:
|
||||
raise ValidationError(
|
||||
name,
|
||||
"the prefix length for 'from' cannot be zero",
|
||||
)
|
||||
|
||||
if result["to"] is not None:
|
||||
# NM also allows to specify `to 0.0.0.0/0` or `to ::/0` in a routing
|
||||
# rule, but the connection profiles will only show the `from` setting
|
||||
# for the rule
|
||||
if result["to"] is not None and result["to"]["address"] not in [
|
||||
"0.0.0.0",
|
||||
"::",
|
||||
]:
|
||||
if result["to"]["prefix"] == 0:
|
||||
raise ValidationError(
|
||||
name,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue