Reject configuring ipv6 disabled if not supported in NM

In NM, the property `NM_SETTING_IP6_CONFIG_METHOD_DISABLED` is only
supported since NM 1.20, therefore, the role should reject configuring
`ipv6 disabled` if `NM_SETTING_IP6_CONFIG_METHOD_DISABLED` is not
supported by the running version of NM.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
This commit is contained in:
Wen Liang 2022-03-11 15:49:57 -05:00 committed by Fernando Fernández Mancera
parent da260c85cd
commit 59ee08ae02
5 changed files with 51 additions and 6 deletions

View file

@ -2216,6 +2216,17 @@ class ArgValidator_ListConnections(ArgValidatorList):
idx,
"ip.ipv6_disabled is not supported by initscripts.",
)
if not hasattr(Util.NM(), "SETTING_IP6_CONFIG_METHOD_DISABLED"):
raise ValidationError.from_connection(
idx,
"ip.ipv6_disabled is not supported by the running version of "
"NetworkManager, it requires at least version 1.20. But you can "
"disable IPv6 auto configuration by setting ip.auto6 to False. "
"Then NetworkManager will ignore IPv6 for this connection. This "
"will still leave the sysctl value 'disable_ipv6' unchanged, but "
"setting ip.ipv6_disabled to True in the role will set the sysctl "
"value 'disable_ipv6' to True ",
)
# Setting ip.dns is not allowed when corresponding IP method for that
# nameserver is disabled
for nameserver in connection["ip"]["dns"]: