Browse Source

Add explicit casting to int for vf index

Mainly to avoid possible issues when vf index
is extracted from the system and is not converted
to int. while current code does not suffer from this
symptom, the same approach is already used in netdev API.
here we do the same.

Change-Id: I4e657173a2f44e834af211a8dc39df62da2aadf1
changes/81/707381/1
Adrian Chiris 1 week ago
parent
commit
daba7c2acc
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      networking_mlnx/eswitchd/utils/ib_utils.py

+ 3
- 3
networking_mlnx/eswitchd/utils/ib_utils.py View File

@@ -173,7 +173,7 @@ class IbUtils(object):
for vf_idx in vf_idxs:
guid_path = (
constants.MLNX5_GUID_NODE_PATH % {'module': pf_mlx_name,
'vf_num': vf_idx})
'vf_num': int(vf_idx)})
with open(guid_path) as f:
guid = f.readline().strip()
mac = self._get_mac_from_guid(guid)
@@ -215,9 +215,9 @@ class IbUtils(object):

def _set_vf_guid_sysfs_mlnx5(self, guid, pf_mlx_dev, vf_idx):
guid_node = constants.MLNX5_GUID_NODE_PATH % {'module': pf_mlx_dev,
'vf_num': vf_idx}
'vf_num': int(vf_idx)}
guid_port = constants.MLNX5_GUID_PORT_PATH % {'module': pf_mlx_dev,
'vf_num': vf_idx}
'vf_num': int(vf_idx)}
for path in (guid_node, guid_port):
sys_api.sys_write(path, guid)



Loading…
Cancel
Save