Skip to content

[2024.1] Various bug fixes #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions networking_mlnx/eswitchd/eswitch_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,13 @@ def _parse_physical_mapping(self):
def _init_connections(self):
context = zmq.Context()
self.socket_os = context.socket(zmq.REP)
self.socket.setsockopt(zmq.LINGER, 0)
os_transport = constants.SOCKET_OS_TRANSPORT
os_port = constants.SOCKET_OS_PORT
os_addr = constants.SOCKET_OS_ADDR
self.conn_os_url = set_conn_url(os_transport, os_addr, os_port)

self.socket_os.bind(self.conn_os_url)
self.poller = zmq.Poller()
self.poller.register(self.socket_os, zmq.POLLIN)

def _handle_msg(self):
data = None
Expand All @@ -81,15 +80,20 @@ def _handle_msg(self):
if msg:
data = jsonutils.loads(msg)

msg = None
result = {
"status": "FAIL",
"action": data.get("action", "UNKNOWN"),
"reason": "UNKNOWN"
}
if data:
try:
result = self.dispatcher.handle_msg(data)
msg = jsonutils.dumps(result)
except Exception as e:
LOG.exception("Exception during message handling - %s", e)
msg = jsonutils.dumps(str(e))
sender.send_string(msg)
result["reason"] = str(e)

msg = jsonutils.dumps(result)
sender.send_string(msg)

def daemon_loop(self):
LOG.info("Daemon Started!")
Expand Down
4 changes: 2 additions & 2 deletions networking_mlnx/eswitchd/utils/pci_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def get_vfs_info(self, pf):

def get_dev_attr(self, attr_path):
try:
fd = open(attr_path)
return fd.readline().strip()
with open(attr_path) as fd:
return fd.readline().strip()
except IOError:
return

Expand Down
74 changes: 37 additions & 37 deletions networking_mlnx/internal/netdev_ops/impl_pyroute2.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ def set_vf_admin_state(self, pf_ifname, vf_idx, state):
:param state: desired admin state as defined in
networking_mlnx.internal.netdev_ops.constants
"""
try:
ip = pyroute2.IPRoute()
link_idx = ip.link_lookup(ifname=pf_ifname)[0]
ip.link(
'set', index=link_idx, vf={'vf': int(vf_idx),
'link_state': state})
except IndexError:
raise exceptions.NetworkInterfaceNotFound(pf_ifname)
except pyroute2.NetlinkError as e:
raise exceptions.NetlinkRuntimeError(e)
with pyroute2.IPRoute() as ip:
try:
link_idx = ip.link_lookup(ifname=pf_ifname)[0]
ip.link(
'set', index=link_idx, vf={'vf': int(vf_idx),
'link_state': state})
except IndexError:
raise exceptions.NetworkInterfaceNotFound(pf_ifname)
except pyroute2.NetlinkError as e:
raise exceptions.NetlinkRuntimeError(e)

def set_link_state(self, ifname, state):
"""Set net device link state
Expand All @@ -51,14 +51,14 @@ def set_link_state(self, ifname, state):
:param state: desired link state as defined in
networking_mlnx.internal.netdev_ops.constants
"""
try:
ip = pyroute2.IPRoute()
link_idx = ip.link_lookup(ifname=ifname)[0]
ip.link('set', index=link_idx, state=state)
except IndexError:
raise exceptions.NetworkInterfaceNotFound(ifname)
except pyroute2.NetlinkError as e:
raise exceptions.NetlinkRuntimeError(e)
with pyroute2.IPRoute() as ip:
try:
link_idx = ip.link_lookup(ifname=ifname)[0]
ip.link('set', index=link_idx, state=state)
except IndexError:
raise exceptions.NetworkInterfaceNotFound(ifname)
except pyroute2.NetlinkError as e:
raise exceptions.NetlinkRuntimeError(e)

def set_vf_guid(self, pf_ifname, vf_idx, guid):
"""Set vf administrative port and node GUID
Expand All @@ -68,17 +68,17 @@ def set_vf_guid(self, pf_ifname, vf_idx, guid):
:param guid: 64bit guid str in xx:xx:xx:xx:xx:xx:xx:xx format
where x is a hexadecimal digit.
"""
try:
ip = pyroute2.IPRoute()
link_idx = ip.link_lookup(ifname=pf_ifname)[0]
ip.link('set', index=link_idx, vf={'vf': int(vf_idx),
'ib_port_guid': guid})
ip.link('set', index=link_idx,
vf={'vf': int(vf_idx), 'ib_node_guid': guid})
except IndexError:
raise exceptions.NetworkInterfaceNotFound(pf_ifname)
except pyroute2.NetlinkError as e:
raise exceptions.NetlinkRuntimeError(e)
with pyroute2.IPRoute() as ip:
try:
link_idx = ip.link_lookup(ifname=pf_ifname)[0]
ip.link('set', index=link_idx, vf={'vf': int(vf_idx),
'ib_port_guid': guid})
ip.link('set', index=link_idx,
vf={'vf': int(vf_idx), 'ib_node_guid': guid})
except IndexError:
raise exceptions.NetworkInterfaceNotFound(pf_ifname)
except pyroute2.NetlinkError as e:
raise exceptions.NetlinkRuntimeError(e)

def get_vf_guid(self, pf_ifname, vf_idx):
"""Get vf administrative GUID
Expand All @@ -91,14 +91,14 @@ def get_vf_guid(self, pf_ifname, vf_idx):
NOTE: while there are two GUIDs assigned per VF (port and node GUID)
we assume they are the same and return just one value.
"""
try:
ip = pyroute2.IPRoute()
link_idx = ip.link_lookup(ifname=pf_ifname)[0]
attrs = ip.link('get', index=link_idx, ext_mask=1)[0]
except IndexError:
raise exceptions.NetworkInterfaceNotFound(pf_ifname)
except pyroute2.NetlinkError as e:
raise exceptions.NetlinkRuntimeError(e)
with pyroute2.IPRoute() as ip:
try:
link_idx = ip.link_lookup(ifname=pf_ifname)[0]
attrs = ip.link('get', index=link_idx, ext_mask=1)[0]
except IndexError:
raise exceptions.NetworkInterfaceNotFound(pf_ifname)
except pyroute2.NetlinkError as e:
raise exceptions.NetlinkRuntimeError(e)

vf_attr = (attrs.get_attr('IFLA_VFINFO_LIST').
get_attrs("IFLA_VF_INFO"))[int(vf_idx)]
Expand Down
3 changes: 2 additions & 1 deletion networking_mlnx/plugins/ml2/drivers/mlnx/mech_mlnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ def _gen_client_id_with_prefix(self, port, prefix):
def _gen_client_id_opt(self, port):
client_id = self._gen_client_id(port)
return [{"opt_name": edo_ext.DHCP_OPT_CLIENT_ID,
"opt_value": client_id}]
"opt_value": client_id,
"ip_version": 4}]

def _gen_none_client_id_opt(self, port):
updated_extra_dhcp_opts = []
Expand Down