mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 02:15:17 +00:00
infiniband: Reject the invalid pkey value
The pkey values 0x0000 and 0x8000 are not supported by kernel, raise an error when the user specifies such a pkey value. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/infiniband/ulp/ipoib/ipoib_main.c?id=c5eb0a61238dd6faf37f58c9ce61c9980aaffd7a#n2394 Signed-off-by: Wen Liang <liangwen12year@gmail.com>
This commit is contained in:
parent
6927dc39f7
commit
d0bce9ef62
2 changed files with 52 additions and 0 deletions
|
|
@ -2091,6 +2091,15 @@ class ArgValidator_DictConnection(ArgValidatorDict):
|
|||
if result["infiniband"]["transport_mode"] is None:
|
||||
result["infiniband"]["transport_mode"] = "datagram"
|
||||
if result["infiniband"]["p_key"] != -1:
|
||||
if (
|
||||
result["infiniband"]["p_key"] == 0x0000
|
||||
or result["infiniband"]["p_key"] == 0x8000
|
||||
):
|
||||
raise ValidationError(
|
||||
name,
|
||||
"the pkey value {0} is not allowed as such a pkey value is not "
|
||||
"supported by kernel".format(result["infiniband"]["p_key"]),
|
||||
)
|
||||
if "mac" not in result and "parent" not in result:
|
||||
raise ValidationError(
|
||||
name + ".infiniband.p_key",
|
||||
|
|
|
|||
|
|
@ -4986,6 +4986,49 @@ class TestValidatorDictBond(Python26CompatTestCase):
|
|||
self.validator.validate(self.test_connections)
|
||||
|
||||
|
||||
class TestValidatorDictInfiniband(Python26CompatTestCase):
|
||||
def setUp(self):
|
||||
self.validator = network_lsr.argument_validator.ArgValidator_ListConnections()
|
||||
self.test_connections = [
|
||||
{
|
||||
"name": "ib0",
|
||||
"type": "infiniband",
|
||||
"interface_name": "ib0",
|
||||
},
|
||||
{
|
||||
"name": "ib0-10",
|
||||
"type": "infiniband",
|
||||
"infiniband": {
|
||||
"p_key": 10,
|
||||
"transport_mode": "datagram",
|
||||
},
|
||||
"parent": "ib0",
|
||||
},
|
||||
]
|
||||
|
||||
def test_invalid_pkey_values(self):
|
||||
self.test_connections[1]["infiniband"]["p_key"] = 0x0000
|
||||
self.assertRaisesRegex(
|
||||
ValidationError,
|
||||
"the pkey value {0} is not allowed as such a pkey value is not "
|
||||
"supported by kernel".format(
|
||||
self.test_connections[1]["infiniband"]["p_key"]
|
||||
),
|
||||
self.validator.validate,
|
||||
self.test_connections,
|
||||
)
|
||||
self.test_connections[1]["infiniband"]["p_key"] = 0x8000
|
||||
self.assertRaisesRegex(
|
||||
ValidationError,
|
||||
"the pkey value {0} is not allowed as such a pkey value is not "
|
||||
"supported by kernel".format(
|
||||
self.test_connections[1]["infiniband"]["p_key"]
|
||||
),
|
||||
self.validator.validate,
|
||||
self.test_connections,
|
||||
)
|
||||
|
||||
|
||||
class TestSysUtils(unittest.TestCase):
|
||||
def test_link_read_permaddress(self):
|
||||
self.assertEqual(SysUtil._link_read_permaddress("lo"), "00:00:00:00:00:00")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue