mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 02:15:17 +00:00
infiniband: Change the default value of p_key into None
The current default `p_key` value is `-1`, which is only useful for the recognizability with NetworkManager API. NetworkManager chooses the `-1` as the default pkey value only because the connection should be created on the physical infiniband interface by default and the positive pkey value would make the connection created on the virtual infiniband partition. But NetworkManager should also have represented the default value as not specifying the pkey property initially. Therefore, change the default value of `p_key` into `None`. Signed-off-by: Wen Liang <liangwen12year@gmail.com>
This commit is contained in:
parent
be2d0e847c
commit
e8cdb2bc58
3 changed files with 18 additions and 10 deletions
|
|
@ -348,7 +348,7 @@ class IfcfgUtil:
|
|||
if (connection["infiniband"]["transport_mode"] == "connected")
|
||||
else "no"
|
||||
)
|
||||
if connection["infiniband"]["p_key"] != -1:
|
||||
if connection["infiniband"]["p_key"] is not None:
|
||||
ifcfg["PKEY"] = "yes"
|
||||
ifcfg["PKEY_ID"] = str(connection["infiniband"]["p_key"])
|
||||
if connection["parent"]:
|
||||
|
|
@ -846,7 +846,7 @@ class NMUtil:
|
|||
NM.SETTING_INFINIBAND_TRANSPORT_MODE,
|
||||
connection["infiniband"]["transport_mode"],
|
||||
)
|
||||
if connection["infiniband"]["p_key"] != -1:
|
||||
if connection["infiniband"]["p_key"] is not None:
|
||||
s_infiniband.set_property(
|
||||
NM.SETTING_INFINIBAND_P_KEY, connection["infiniband"]["p_key"]
|
||||
)
|
||||
|
|
@ -2012,7 +2012,7 @@ class Cmd(object):
|
|||
"interface exists" % (connection["interface_name"]),
|
||||
)
|
||||
elif connection["type"] == "infiniband":
|
||||
if connection["infiniband"]["p_key"] == -1:
|
||||
if connection["infiniband"]["p_key"] is None:
|
||||
self.log_fatal(
|
||||
idx,
|
||||
"profile specifies interface_name '%s' but no such "
|
||||
|
|
|
|||
|
|
@ -1561,13 +1561,15 @@ class ArgValidator_DictInfiniband(ArgValidatorDict):
|
|||
ArgValidatorStr(
|
||||
"transport_mode", enum_values=["datagram", "connected"]
|
||||
),
|
||||
ArgValidatorNum("p_key", val_min=-1, val_max=0xFFFF, default_value=-1),
|
||||
ArgValidatorNum(
|
||||
"p_key", val_min=-1, val_max=0xFFFF, default_value=None
|
||||
),
|
||||
],
|
||||
default_value=ArgValidator.MISSING,
|
||||
)
|
||||
|
||||
def get_default_infiniband(self):
|
||||
return {"transport_mode": "datagram", "p_key": -1}
|
||||
return {"transport_mode": "datagram", "p_key": None}
|
||||
|
||||
|
||||
class ArgValidator_DictVlan(ArgValidatorDict):
|
||||
|
|
@ -2090,7 +2092,13 @@ class ArgValidator_DictConnection(ArgValidatorDict):
|
|||
)
|
||||
if result["infiniband"]["transport_mode"] is None:
|
||||
result["infiniband"]["transport_mode"] = "datagram"
|
||||
if result["infiniband"]["p_key"] != -1:
|
||||
# For the compatibility with NetworkManager API and the initial
|
||||
# infiniband support in the role (the user may get used to set the
|
||||
# `p_key` into `-1` to make the connection created on the physical
|
||||
# infiniband interface), normalize the `p_key` setting as follows
|
||||
if result["infiniband"]["p_key"] == -1:
|
||||
result["infiniband"]["p_key"] = None
|
||||
if result["infiniband"]["p_key"] is not None:
|
||||
if (
|
||||
result["infiniband"]["p_key"] == 0x0000
|
||||
or result["infiniband"]["p_key"] == 0x8000
|
||||
|
|
@ -2148,7 +2156,7 @@ class ArgValidator_DictConnection(ArgValidatorDict):
|
|||
and (not result.get("match") or not result["match"].get("path"))
|
||||
and not (
|
||||
result["type"] == "infiniband"
|
||||
and result["infiniband"]["p_key"] != -1
|
||||
and result["infiniband"]["p_key"] is not None
|
||||
)
|
||||
):
|
||||
if not Util.ifname_valid(result["name"]):
|
||||
|
|
@ -2370,7 +2378,7 @@ class ArgValidator_ListConnections(ArgValidatorList):
|
|||
)
|
||||
or (
|
||||
(connection["type"] == "infiniband")
|
||||
and (connection["infiniband"]["p_key"] != -1)
|
||||
and (connection["infiniband"]["p_key"] is not None)
|
||||
)
|
||||
):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -2199,7 +2199,7 @@ class TestValidator(Python26CompatTestCase):
|
|||
"ethtool": ETHTOOL_DEFAULTS,
|
||||
"force_state_change": None,
|
||||
"ignore_errors": None,
|
||||
"infiniband": {"p_key": -1, "transport_mode": "datagram"},
|
||||
"infiniband": {"p_key": None, "transport_mode": "datagram"},
|
||||
"interface_name": None,
|
||||
"ip": {
|
||||
"address": [],
|
||||
|
|
@ -2357,7 +2357,7 @@ class TestValidator(Python26CompatTestCase):
|
|||
"check_iface_exists": True,
|
||||
"ethtool": ETHTOOL_DEFAULTS,
|
||||
"ignore_errors": None,
|
||||
"infiniband": {"p_key": -1, "transport_mode": "datagram"},
|
||||
"infiniband": {"p_key": None, "transport_mode": "datagram"},
|
||||
"interface_name": "ib0",
|
||||
"ip": {
|
||||
"address": [],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue