Skip to content

Commit

Permalink
udev: FC/Loop - use case-insensitive comparison for traddr
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Belanger <[email protected]>
  • Loading branch information
Martin Belanger committed Aug 3, 2023
1 parent f5eb169 commit 4741895
Show file tree
Hide file tree
Showing 10 changed files with 450 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/meson-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
run: |
python3 -m pip install pytest
python3 -m pip install pytest-cov
PYTHONPATH=.build:.build/subprojects/libnvme:/usr/lib/python3/dist-packages/ pytest --cov=./staslib --cov-report=xml test/test-*.py
PYTHONPATH=.build:.build/subprojects/libnvme:/usr/lib/python3/dist-packages/ pytest --cov=.build/staslib --cov-report=xml test/test-*.py
- uses: codecov/codecov-action@v3
with:
Expand Down
8 changes: 4 additions & 4 deletions doc/readthedocs/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ components = [
'environment.txt',
'installation.rst',
'nvme-stas.rst',
'org.nvmexpress.stac.debug.rst',
'org.nvmexpress.stac.rst',
'org.nvmexpress.staf.debug.rst',
'org.nvmexpress.staf.rst',
conf.get('STACD_DBUS_NAME') + '.debug.rst',
conf.get('STACD_DBUS_NAME') + '.rst',
conf.get('STAFD_DBUS_NAME') + '.debug.rst',
conf.get('STAFD_DBUS_NAME') + '.rst',
'stacctl.rst',
'stacd-index.rst',
'stacd.conf.rst',
Expand Down
8 changes: 4 additions & 4 deletions etc/dbus-1/system.d/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
dbus_conf_dir = datadir / 'dbus-1' / 'system.d'

configure_file(
input: 'org.nvmexpress.staf.in.conf',
output: 'org.nvmexpress.staf.conf',
input: conf.get('STAFD_DBUS_NAME') + '.in.conf',
output: conf.get('STAFD_DBUS_NAME') + '.conf',
configuration: conf,
install_dir: dbus_conf_dir,
)

configure_file(
input: 'org.nvmexpress.stac.in.conf',
output: 'org.nvmexpress.stac.conf',
input: conf.get('STACD_DBUS_NAME') + '.in.conf',
output: conf.get('STACD_DBUS_NAME') + '.conf',
configuration: conf,
install_dir: dbus_conf_dir,
)
3 changes: 2 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
project(
'nvme-stas',
meson_version: '>= 0.53.0',
version: '2.3-rc3',
version: '2.3-rc4',
license: 'Apache-2.0',
default_options: [
'buildtype=release',
Expand Down Expand Up @@ -78,6 +78,7 @@ conf.set('STAFD_DBUS_NAME', 'org.nvmexpress.staf')
conf.set('STAFD_DBUS_PATH', '/org/nvmexpress/staf')
conf.set('STACD_DBUS_NAME', 'org.nvmexpress.stac')
conf.set('STACD_DBUS_PATH', '/org/nvmexpress/stac')
conf.set('ETC', etcdir)

#===============================================================================
stafd = configure_file(
Expand Down
12 changes: 6 additions & 6 deletions staslib/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@

PROG_NAME = os.path.basename(sys.argv[0])

NVME_HOSTID = '/etc/nvme/hostid'
NVME_HOSTNQN = '/etc/nvme/hostnqn'
NVME_HOSTKEY = '/etc/nvme/hostkey'
NVME_HOSTID = '@ETC@/nvme/hostid'
NVME_HOSTNQN = '@ETC@/nvme/hostnqn'
NVME_HOSTKEY = '@ETC@/nvme/hostkey'

SYS_CONF_FILE = '/etc/stas/sys.conf'
STAFD_CONF_FILE = '/etc/stas/stafd.conf'
STACD_CONF_FILE = '/etc/stas/stacd.conf'
SYS_CONF_FILE = '@ETC@/stas/sys.conf'
STAFD_CONF_FILE = '@ETC@/stas/stafd.conf'
STACD_CONF_FILE = '@ETC@/stas/stacd.conf'

HAS_NBFT_SUPPORT = hasattr(nvme, 'nbft_get')
NBFT_SYSFS_PATH = "/sys/firmware/acpi/tables"
Expand Down
6 changes: 3 additions & 3 deletions staslib/gutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#
# Authors: Martin Belanger <[email protected]>
#
'''This module provides utility functions/classes to provide easier to use
access to GLib/Gio/Gobject resources.
'''This module provides utility functions (or classes) that simplify
the use of certain GLib/Gio/Gobject functions/resources.
'''

import logging
Expand Down Expand Up @@ -443,7 +443,7 @@ def connect(self):
# the GLib context.
family = socket.AF_INET if self._traddr.version == 4 else socket.AF_INET6
self._native_sock = socket.socket(family, socket.SOCK_STREAM | socket.SOCK_NONBLOCK, socket.IPPROTO_TCP)
if isinstance(self._host_iface, str):
if self._host_iface and isinstance(self._host_iface, str):
self._native_sock.setsockopt(socket.SOL_SOCKET, socket.SO_BINDTODEVICE, self._host_iface.encode('utf-8'))

# Convert socket.socket() to a Gio.Socket() object
Expand Down
11 changes: 6 additions & 5 deletions staslib/udev.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ def _cid_matches_tid(tid, cid): # pylint: disable=too-many-return-statements,t
be re-used for the candidate controller (specified by tid).
We do not have a match if the candidate's tid.transport, tid.traddr,
tid.trsvcid, and tid.subsysnqn are not identical to those of the cid.
These 4 parameters are mandatory for a match.
tid.trsvcid, tid.subsysnqn, and tid.host_nqn are not identical to those
of the cid. These 5 parameters are mandatory for a match.
The tid.host_traddr and tid.host_iface depend on the transport type.
These parameters may not apply or have a different syntax/meaning
Expand Down Expand Up @@ -274,8 +274,9 @@ def _cid_matches_tid(tid, cid): # pylint: disable=too-many-return-statements,t
tid_traddr = iputil.get_ipaddress_obj(tid.traddr, ipv4_mapped_convert=True)
cid_traddr = iputil.get_ipaddress_obj(cid['traddr'], ipv4_mapped_convert=True)
else:
cid_traddr = cid['traddr']
tid_traddr = tid.traddr
# For FC and loop we can do a case-insensitive comparison
tid_traddr = tid.traddr.lower()
cid_traddr = cid['traddr'].lower()

if cid_traddr != tid_traddr:
return False
Expand Down Expand Up @@ -308,7 +309,7 @@ def _cid_matches_tid(tid, cid): # pylint: disable=too-many-return-statements,t

elif tid.transport == 'fc':
# host-traddr is mandatory for FC.
if tid.host_traddr != cid['host-traddr']:
if tid.host_traddr.lower() != cid['host-traddr'].lower():
return False

elif tid.transport == 'rdma':
Expand Down
2 changes: 1 addition & 1 deletion usr/lib/systemd/system/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ configure_file(
input: '[email protected]',
output: '[email protected]',
install_dir: sd_unit_dir,
copy: true,
configuration: conf,
)

configure_file(
Expand Down
6 changes: 3 additions & 3 deletions usr/lib/systemd/system/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
# This file is part of NVMe STorage Appliance Services (nvme-stas).
#
[Unit]
Description=nvme-stas /etc/nvme/%i auto-generation
Description=nvme-stas @ETC@/nvme/%i auto-generation
Documentation=man:[email protected](8)
ConditionFileNotEmpty=|!/etc/nvme/%i
ConditionFileNotEmpty=|!@ETC@/nvme/%i

[Service]
Type=oneshot
ExecStart=/usr/bin/stasadm %i -f /etc/nvme/%i
ExecStart=/usr/bin/stasadm %i -f @ETC@/nvme/%i

[Install]
WantedBy=stas-config.target
Loading

0 comments on commit 4741895

Please sign in to comment.