From fd14dd8316b1317d3ee2ff28b9d013198be40d70 Mon Sep 17 00:00:00 2001 From: Lee Duncan Date: Sun, 20 Mar 2022 16:12:40 -0700 Subject: Clean up Makefile build system. A major overdue overhaul of the Make layout, including moving lots of lower-level things out of the top-level Makefile into the Makefiles for the appropriate subdirectory, renaming the template files (where @SBINDIR@ gets translated) so that their purpose is more obvious, making the build more idempotent (no need to install a file if it's not newer). Should be no functional change, as no script or C file changed. Main difference from before: now the udev rules gets made and installed by default (as part of "make"/"make install"), and the iscsiuio daemon is now installed for "make install". One should now be able to go into any subdirectory and type "make"/"make install" to build and install the targets from that directory, at least for the etc, utils, and usr subdirectories. This change is in preparation for more template translations coming. --- Makefile | 118 +++----- etc/Makefile | 81 ++++++ etc/systemd/.gitignore | 4 + etc/systemd/iscsi-init.service | 19 -- etc/systemd/iscsi-init.service.template | 19 ++ etc/systemd/iscsi.service | 18 -- etc/systemd/iscsi.service.template | 18 ++ etc/systemd/iscsid.service | 19 -- etc/systemd/iscsid.service.template | 19 ++ etc/systemd/iscsiuio.service | 20 -- etc/systemd/iscsiuio.service.template | 20 ++ usr/Makefile | 18 +- utils/.gitignore | 3 + utils/50-iscsi-firmware-login.rules | 15 -- utils/50-iscsi-firmware-login.rules.template | 15 ++ utils/Makefile | 66 ++++- utils/iscsi-gen-initiatorname | 102 ------- utils/iscsi-gen-initiatorname.sh.template | 102 +++++++ utils/iscsi_discovery | 195 -------------- utils/iscsi_discovery.sh | 195 ++++++++++++++ utils/iscsi_fw_login | 12 - utils/iscsi_fw_login.sh.template | 12 + utils/iscsi_offload | 384 --------------------------- utils/iscsi_offload.sh | 384 +++++++++++++++++++++++++++ 24 files changed, 984 insertions(+), 874 deletions(-) create mode 100644 etc/Makefile create mode 100644 etc/systemd/.gitignore delete mode 100644 etc/systemd/iscsi-init.service create mode 100644 etc/systemd/iscsi-init.service.template delete mode 100644 etc/systemd/iscsi.service create mode 100644 etc/systemd/iscsi.service.template delete mode 100644 etc/systemd/iscsid.service create mode 100644 etc/systemd/iscsid.service.template delete mode 100644 etc/systemd/iscsiuio.service create mode 100644 etc/systemd/iscsiuio.service.template delete mode 100644 utils/50-iscsi-firmware-login.rules create mode 100644 utils/50-iscsi-firmware-login.rules.template delete mode 100755 utils/iscsi-gen-initiatorname create mode 100644 utils/iscsi-gen-initiatorname.sh.template delete mode 100755 utils/iscsi_discovery create mode 100755 utils/iscsi_discovery.sh delete mode 100644 utils/iscsi_fw_login create mode 100644 utils/iscsi_fw_login.sh.template delete mode 100755 utils/iscsi_offload create mode 100755 utils/iscsi_offload.sh diff --git a/Makefile b/Makefile index 5f513de..2e2627d 100644 --- a/Makefile +++ b/Makefile @@ -6,33 +6,15 @@ # that you want everything installed into. DESTDIR ?= -SED = /usr/bin/sed - prefix = /usr exec_prefix = -sbindir = $(exec_prefix)/sbin -bindir = $(exec_prefix)/bin +sbindir ?= $(exec_prefix)/sbin mandir = $(prefix)/share/man -etcdir = /etc -initddir = $(etcdir)/init.d -rulesdir = $(etcdir)/udev/rules.d -systemddir = $(prefix)/lib/systemd MANPAGES = doc/iscsid.8 doc/iscsiadm.8 doc/iscsi_discovery.8 \ iscsiuio/docs/iscsiuio.8 doc/iscsi_fw_login.8 doc/iscsi-iname.8 \ doc/iscsistart.8 doc/iscsi-gen-initiatorname.8 -PROGRAMS = usr/iscsid usr/iscsiadm utils/iscsi-iname iscsiuio/src/unix/iscsiuio \ - usr/iscsistart -SCRIPTS = utils/iscsi_discovery utils/iscsi_fw_login utils/iscsi_offload \ - utils/iscsi-gen-initiatorname INSTALL = install -CONFIGFILE = etc/iscsid.conf -IFACEFILES = etc/iface.example -RULESFILES = utils/50-iscsi-firmware-login.rules -SYSTEMDFILES = etc/systemd/iscsi.service \ - etc/systemd/iscsi-init.service \ - etc/systemd/iscsid.service etc/systemd/iscsid.socket \ - etc/systemd/iscsiuio.service etc/systemd/iscsiuio.socket export DESTDIR prefix INSTALL @@ -62,12 +44,13 @@ endif all: user user: iscsiuio/Makefile - $(MAKE) -C libopeniscsiusr SBINDIR=$(sbindir) - $(MAKE) -C utils/sysdeps - $(MAKE) -C utils/fwparam_ibft - $(MAKE) -C usr - $(MAKE) -C utils - $(MAKE) -C iscsiuio + $(MAKE) $(MFLAGS) -C libopeniscsiusr SBINDIR=$(sbindir) + $(MAKE) $(MFLAGS) -C utils/sysdeps + $(MAKE) $(MFLAGS) -C utils/fwparam_ibft + $(MAKE) $(MFLAGS) -C usr SBINDIR=$(sbindir) + $(MAKE) $(MFLAGS) -C utils SBINDIR=$(sbindir) + $(MAKE) $(MFLAGS) -C etc SBINDIR=$(sbindir) + $(MAKE) $(MFLAGS) -C iscsiuio @echo @echo "Compilation complete Output file" @echo "----------------------------------- ----------------" @@ -88,13 +71,14 @@ iscsiuio/configure iscsiuio/Makefile.in: iscsiuio/configure.ac iscsiuio/Makefile force: ; clean: - $(MAKE) -C utils/sysdeps clean - $(MAKE) -C utils/fwparam_ibft clean - $(MAKE) -C utils clean - $(MAKE) -C usr clean - $(MAKE) -C libopeniscsiusr clean - [ ! -f iscsiuio/Makefile ] || $(MAKE) -C iscsiuio clean - [ ! -f iscsiuio/Makefile ] || $(MAKE) -C iscsiuio distclean + $(MAKE) $(MFLAGS) -C utils/sysdeps clean + $(MAKE) $(MFLAGS) -C utils/fwparam_ibft clean + $(MAKE) $(MFLAGS) -C utils clean + $(MAKE) $(MFLAGS) -C usr clean + $(MAKE) $(MFLAGS) -C etc clean + $(MAKE) $(MFLAGS) -C libopeniscsiusr clean + [ ! -f iscsiuio/Makefile ] || $(MAKE) $(MFLAGS) -C iscsiuio clean + [ ! -f iscsiuio/Makefile ] || $(MAKE) $(MFLAGS) -C iscsiuio distclean # this is for safety # now -jXXX will still be safe @@ -104,64 +88,24 @@ clean: install_etc install_iface install_doc install_iname install: install_programs install_doc install_etc \ - install_systemd install_iname install_iface install_libopeniscsiusr + install_systemd install_iname install_iface install_libopeniscsiusr \ + install_iscsiuio + +install_iscsiuio: + $(MAKE) $(MFLAGS) -C iscsiuio install install_user: install_programs install_doc install_etc \ install_systemd install_iname install_iface install_udev_rules: - $(INSTALL) -d $(DESTDIR)$(rulesdir) - $(INSTALL) -m 644 $(RULESFILES) $(DESTDIR)$(rulesdir) - for f in $(RULESFILES); do \ - p=$(DESTDIR)$(rulesdir)/$${f##*/}; \ - $(SED) -i -e 's:@SBINDIR@:$(sbindir):' $$p; \ - done - -install_systemd: - $(INSTALL) -d $(DESTDIR)$(systemddir)/system - $(INSTALL) -m 644 $(SYSTEMDFILES) $(DESTDIR)$(systemddir)/system - for f in $(SYSTEMDFILES); do \ - p=$(DESTDIR)$(systemddir)/system/$${f##*/}; \ - $(SED) -i -e 's:@SBINDIR@:$(sbindir):' $$p; \ - done + $(MAKE) $(MFLAGS) -C utils $@ -install_programs: $(PROGRAMS) $(SCRIPTS) - $(INSTALL) -d $(DESTDIR)$(sbindir) - $(INSTALL) -m 755 $^ $(DESTDIR)$(sbindir) - for f in $(SCRIPTS); do \ - p=$(DESTDIR)$(sbindir)/$${f##*/}; \ - $(SED) -i -e 's:@SBINDIR@:$(sbindir):' $$p; \ - done +install_programs: + $(MAKE) $(MFLAGS) -C utils install + $(MAKE) $(MFLAGS) -C usr install -# ugh, auto-detection is evil -# Gentoo maintains their own init.d stuff -install_initd: - if [ -f /etc/debian_version ]; then \ - $(MAKE) install_initd_debian ; \ - elif [ -f /etc/redhat-release ]; then \ - $(MAKE) install_initd_redhat ; \ - fi - -# these are external targets to allow bypassing distribution detection -install_initd_redhat: - $(INSTALL) -d $(DESTDIR)$(initddir) - $(INSTALL) -m 755 etc/initd/initd.redhat \ - $(DESTDIR)$(initddir)/open-iscsi - -install_initd_debian: - $(INSTALL) -d $(DESTDIR)$(initddir) - $(INSTALL) -m 755 etc/initd/initd.debian \ - $(DESTDIR)$(initddir)/open-iscsi - -install_iface: $(IFACEFILES) - $(INSTALL) -d $(DESTDIR)$(etcdir)/iscsi/ifaces - $(INSTALL) -m 644 $^ $(DESTDIR)$(etcdir)/iscsi/ifaces - -install_etc: $(CONFIGFILE) - if [ ! -f $(DESTDIR)/etc/iscsi/iscsid.conf ]; then \ - $(INSTALL) -d $(DESTDIR)$(etcdir)/iscsi ; \ - $(INSTALL) -m 644 $^ $(DESTDIR)$(etcdir)/iscsi ; \ - fi +install_initd install_initd_redhat install_initd_debian install_ifae install_etc install_systemd install_iface: + $(MAKE) $(MFLAGS) -C etc $@ install_doc: $(MANPAGES) $(INSTALL) -d $(DESTDIR)$(mandir)/man8 @@ -177,11 +121,15 @@ install_iname: fi install_libopeniscsiusr: - $(MAKE) -C libopeniscsiusr install + $(MAKE) $(MFLAGS) -C libopeniscsiusr install depend: for dir in usr utils utils/fwparam_ibft; do \ - $(MAKE) -C $$dir $@; \ + $(MAKE) $(MFLAGS) -C $$dir $@; \ done +.PHONY: all user install force clean install_user install_udev_rules install_systemd \ + install_programs install_initrd install_initrd_redhat install_initrd_debian \ + install_etc install_doc install_iname install_libopeniscsiusr + # vim: ft=make tw=72 sw=4 ts=4: diff --git a/etc/Makefile b/etc/Makefile new file mode 100644 index 0000000..8a7d7c0 --- /dev/null +++ b/etc/Makefile @@ -0,0 +1,81 @@ +# +# gnu Makefile for the etc subdirectory, including +# initd and systemd subdirectories +# + +prefix = /usr +DESTDIR ?= +SBINDIR ?= $(DESTDIR)/sbin + +systemddir ?= $(DESTDIR)$(prefix)/lib/systemd +etcdir = $(DESTDIR)/etc +initddir ?= $(etcdir)/init.d + +HOMEDIR ?= $(etcdir)/iscsi + +SED = /usr/bin/sed +INSTALL = install + +SYSTEMD_SOURCE_FILES = iscsid.socket iscsiuio.socket +SYSTEMD_SOURCES = $(addprefix systemd/,$(SYSTEMD_SOURCE_FILES)) +SYSTEMD_TEMPLATE_FILES = iscsi-init.service.template \ + iscsid.service.template \ + iscsi.service.template \ + iscsiuio.service.template +SYSTEMD_TEMPLATES = $(addprefix systemd/,$(SYSTEMD_TEMPLATE_FILES)) +SYSTEMD_GENERATED_SERVICE_FILES = $(SYSTEMD_TEMPLATES:.template=) +SYSTEMD_DEST_FILES = $(addprefix $(systemddir)/system/,$(notdir $(SYSTEMD_SOURCES))) \ + $(addprefix $(systemddir)/system/,$(notdir $(SYSTEMD_GENERATED_SERVICE_FILES))) +IFACE_FILES = iface.example +IFACE_DEST_FILES = $(addprefix $(HOMEDIR)/ifaces/,$(IFACE_FILES)) +ETC_FILES = iscsid.conf +ETC_DEST_FILES = $(addprefix $(HOMEDIR)/,$(ETC_FILES)) + +all: $(SYSTEMD_SOURCES) $(SYSTEMD_GENERATED_SERVICE_FILES) + +$(SYSTEMD_GENERATED_SERVICE_FILES): systemd/%.service: systemd/%.service.template + $(SED) -e 's:@SBINDIR@:$(SBINDIR):' $? > $@ + +install: install_systemd install_iface install_etc + +install_iface: $(IFACE_DEST_FILES) + +$(IFACE_DEST_FILES): $(HOMEDIR)/ifaces/%: % + $(INSTALL) -m 644 $? $@ + +install_etc: $(ETC_DEST_FILES) + +$(ETC_DEST_FILES): $(HOMEDIR)/%: % + $(INSTALL) -m 644 $? $@ + +install_initd_distro = $(INSTALL) -m 755 $(1) $(initddir)/open-iscsi/ + +install_initd: $(initddir)/open-iscsi + @if [ -f /etc/debian_version ]; then \ + $(call install_initd_distro,initd/initd.redhat) ; \ + elif [ -f /etc/redhat-release ]; then \ + $(call install_initd_distro,initd/initd.debian) ; \ + fi + +$(initddir)/open-iscsi: + [ -d $@ ] || $(INSTALL) -d $@ + +install_initd_redhat: $(initddir)/open-iscsi + $(call install_initd_distro,initd/initd.redhat) + +install_initd_debian: $(initddir)/open-iscsi + $(call install_initd_distro,initd/initd.debian) + +install_systemd: $(systemddir)/system $(SYSTEMD_DEST_FILES) + +$(systemddir)/system: + [ -d $@ ] || $(INSTALL) -d -m 775 $@ + +$(SYSTEMD_DEST_FILES): $(systemddir)/system/%: systemd/% + $(INSTALL) $? $@ + +clean: + $(RM) $(SYSTEMD_GENERATED_SERVICE_FILES) + +.PHONY: all clean install install_iface install_initd install_initd_redhat \ + install_initd_debian install_systemd diff --git a/etc/systemd/.gitignore b/etc/systemd/.gitignore new file mode 100644 index 0000000..2b3a64e --- /dev/null +++ b/etc/systemd/.gitignore @@ -0,0 +1,4 @@ +iscsi-init.service +iscsi.service +iscsid.service +iscsiuio.service diff --git a/etc/systemd/iscsi-init.service b/etc/systemd/iscsi-init.service deleted file mode 100644 index 8f9a8aa..0000000 --- a/etc/systemd/iscsi-init.service +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description=One time configuration for iscsi.service -ConditionPathExists=!/etc/iscsi/initiatorname.iscsi -DefaultDependencies=no -RequiresMountsFor=/etc/iscsi -# systemd-remount-fs.service is optionally pulled in by -# local-fs.target, don't start it here (no Wants=) but if -# it's running wait for it to finish -After=systemd-remount-fs.service - -[Install] -# this ensures we are in the same transaction with -# systemd-remount-fs.service -WantedBy=systemd-remount-fs.service - -[Service] -Type=oneshot -RemainAfterExit=no -ExecStart=/usr/bin/sh -c 'echo "InitiatorName=`@SBINDIR@/iscsi-iname`" > /etc/iscsi/initiatorname.iscsi' diff --git a/etc/systemd/iscsi-init.service.template b/etc/systemd/iscsi-init.service.template new file mode 100644 index 0000000..8f9a8aa --- /dev/null +++ b/etc/systemd/iscsi-init.service.template @@ -0,0 +1,19 @@ +[Unit] +Description=One time configuration for iscsi.service +ConditionPathExists=!/etc/iscsi/initiatorname.iscsi +DefaultDependencies=no +RequiresMountsFor=/etc/iscsi +# systemd-remount-fs.service is optionally pulled in by +# local-fs.target, don't start it here (no Wants=) but if +# it's running wait for it to finish +After=systemd-remount-fs.service + +[Install] +# this ensures we are in the same transaction with +# systemd-remount-fs.service +WantedBy=systemd-remount-fs.service + +[Service] +Type=oneshot +RemainAfterExit=no +ExecStart=/usr/bin/sh -c 'echo "InitiatorName=`@SBINDIR@/iscsi-iname`" > /etc/iscsi/initiatorname.iscsi' diff --git a/etc/systemd/iscsi.service b/etc/systemd/iscsi.service deleted file mode 100644 index 6becab4..0000000 --- a/etc/systemd/iscsi.service +++ /dev/null @@ -1,18 +0,0 @@ -[Unit] -Description=Login and scanning of iSCSI devices -Documentation=man:iscsiadm(8) man:iscsid(8) -Before=remote-fs.target -After=network-online.target iscsid.service -Requires=iscsid.socket iscsi-init.service -Wants=network-online.target - -[Service] -Type=oneshot -ExecStart=@SBINDIR@/iscsiadm -m node --loginall=automatic -W -ExecStop=@SBINDIR@/iscsiadm -m node --logoutall=automatic -ExecStop=@SBINDIR@/iscsiadm -m node --logoutall=manual -SuccessExitStatus=21 15 -RemainAfterExit=true - -[Install] -WantedBy=remote-fs.target diff --git a/etc/systemd/iscsi.service.template b/etc/systemd/iscsi.service.template new file mode 100644 index 0000000..6becab4 --- /dev/null +++ b/etc/systemd/iscsi.service.template @@ -0,0 +1,18 @@ +[Unit] +Description=Login and scanning of iSCSI devices +Documentation=man:iscsiadm(8) man:iscsid(8) +Before=remote-fs.target +After=network-online.target iscsid.service +Requires=iscsid.socket iscsi-init.service +Wants=network-online.target + +[Service] +Type=oneshot +ExecStart=@SBINDIR@/iscsiadm -m node --loginall=automatic -W +ExecStop=@SBINDIR@/iscsiadm -m node --logoutall=automatic +ExecStop=@SBINDIR@/iscsiadm -m node --logoutall=manual +SuccessExitStatus=21 15 +RemainAfterExit=true + +[Install] +WantedBy=remote-fs.target diff --git a/etc/systemd/iscsid.service b/etc/systemd/iscsid.service deleted file mode 100644 index e2a50d3..0000000 --- a/etc/systemd/iscsid.service +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description=Open-iSCSI -Documentation=man:iscsid(8) man:iscsiuio(8) man:iscsiadm(8) -DefaultDependencies=no -After=network-online.target iscsiuio.service iscsi-init.service -Before=remote-fs-pre.target -Wants=remote-fs-pre.target -Requires=iscsi-init.service - -[Service] -Type=notify -NotifyAccess=main -ExecStart=@SBINDIR@/iscsid -f -KillMode=mixed -Restart=on-failure - -[Install] -WantedBy=multi-user.target -Also=iscsid.socket diff --git a/etc/systemd/iscsid.service.template b/etc/systemd/iscsid.service.template new file mode 100644 index 0000000..e2a50d3 --- /dev/null +++ b/etc/systemd/iscsid.service.template @@ -0,0 +1,19 @@ +[Unit] +Description=Open-iSCSI +Documentation=man:iscsid(8) man:iscsiuio(8) man:iscsiadm(8) +DefaultDependencies=no +After=network-online.target iscsiuio.service iscsi-init.service +Before=remote-fs-pre.target +Wants=remote-fs-pre.target +Requires=iscsi-init.service + +[Service] +Type=notify +NotifyAccess=main +ExecStart=@SBINDIR@/iscsid -f +KillMode=mixed +Restart=on-failure + +[Install] +WantedBy=multi-user.target +Also=iscsid.socket diff --git a/etc/systemd/iscsiuio.service b/etc/systemd/iscsiuio.service deleted file mode 100644 index 2e721fe..0000000 --- a/etc/systemd/iscsiuio.service +++ /dev/null @@ -1,20 +0,0 @@ -[Unit] -Description=iSCSI UserSpace I/O driver -Documentation=man:iscsiuio(8) -DefaultDependencies=no -Conflicts=shutdown.target -Requires=iscsid.service -BindTo=iscsid.service -After=network.target -Before=remote-fs-pre.target iscsid.service -Wants=remote-fs-pre.target - -[Service] -Type=notify -NotifyAccess=main -ExecStart=@SBINDIR@/iscsiuio -f -KillMode=mixed -Restart=on-failure - -[Install] -WantedBy=multi-user.target diff --git a/etc/systemd/iscsiuio.service.template b/etc/systemd/iscsiuio.service.template new file mode 100644 index 0000000..2e721fe --- /dev/null +++ b/etc/systemd/iscsiuio.service.template @@ -0,0 +1,20 @@ +[Unit] +Description=iSCSI UserSpace I/O driver +Documentation=man:iscsiuio(8) +DefaultDependencies=no +Conflicts=shutdown.target +Requires=iscsid.service +BindTo=iscsid.service +After=network.target +Before=remote-fs-pre.target iscsid.service +Wants=remote-fs-pre.target + +[Service] +Type=notify +NotifyAccess=main +ExecStart=@SBINDIR@/iscsiuio -f +KillMode=mixed +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/usr/Makefile b/usr/Makefile index fe7430a..e7ba803 100644 --- a/usr/Makefile +++ b/usr/Makefile @@ -4,6 +4,11 @@ ifeq ($(TOPDIR),) TOPDIR = .. endif +INSTALL = install + +DESTDR ?= +SBINDIR ?= $(DESTDIR)/sbin + OSNAME=$(shell uname -s) # allow users to override these @@ -46,7 +51,9 @@ LDFLAGS += $(shell $(PKG_CONFIG) --libs libsystemd) else CFLAGS += -DNO_SYSTEMD endif -PROGRAMS = iscsid iscsiadm iscsistart + +PROGRAMS = iscsid iscsiadm iscsistart +PROGRAMS_DEST = $(addprefix $(SBINDIR)/,$(PROGRAMS)) # libc compat files SYSDEPS_SRCS = $(sort $(wildcard ../utils/sysdeps/*.o)) @@ -77,6 +84,15 @@ iscsiadm: $(ISCSI_LIB_SRCS) $(DISCOVERY_SRCS) iscsiadm.o session_mgmt.o mntcheck iscsistart: $(ISCSI_LIB_SRCS) $(INITIATOR_SRCS) $(FW_BOOT_SRCS) \ iscsistart.o statics.o $(CC) $(CFLAGS) $^ -o $@ -lcrypto -lrt $(LDFLAGS) $(ISCSI_LIB) + +install: $(SBINDIR) $(PROGRAMS_DEST) + +$(SBINDIR): + [ -d $@ ] || $(INSTALL) -d $@ + +$(PROGRAMS_DEST): $(SBINDIR)/%: % + $(INSTALL) -m 755 $? $@ + clean: rm -f *.o $(PROGRAMS) .depend $(LIBSYS) diff --git a/utils/.gitignore b/utils/.gitignore index 7efe3fd..7b4beea 100644 --- a/utils/.gitignore +++ b/utils/.gitignore @@ -1 +1,4 @@ iscsi-iname +50-iscsi-firmware-login.rules +iscsi-gen-initiatorname.sh +iscsi_fw_login.sh diff --git a/utils/50-iscsi-firmware-login.rules b/utils/50-iscsi-firmware-login.rules deleted file mode 100644 index 9fa1e7d..0000000 --- a/utils/50-iscsi-firmware-login.rules +++ /dev/null @@ -1,15 +0,0 @@ -# This file contains the rules to handle iscsi firmware changes - -# DO NOT WRAP THIS LINE -# -# old udev does not understand some of it, -# and would end up skipping only some lines, not the full rule. -# which can cause all sort of trouble with strange-named device nodes -# for completely unrelated devices, -# resulting in unusable network lookback, etc. -# -# in case this is "accidentally" installed on a system with old udev, -# having it as one single line avoids those problems. -# -# DO NOT WRAP THIS LINE -SUBSYSTEM=="iscsi_boot*", ACTION=="add", DEVPATH=="*/target*", RUN+="@SBINDIR@/iscsi_fw_login" diff --git a/utils/50-iscsi-firmware-login.rules.template b/utils/50-iscsi-firmware-login.rules.template new file mode 100644 index 0000000..9fa1e7d --- /dev/null +++ b/utils/50-iscsi-firmware-login.rules.template @@ -0,0 +1,15 @@ +# This file contains the rules to handle iscsi firmware changes + +# DO NOT WRAP THIS LINE +# +# old udev does not understand some of it, +# and would end up skipping only some lines, not the full rule. +# which can cause all sort of trouble with strange-named device nodes +# for completely unrelated devices, +# resulting in unusable network lookback, etc. +# +# in case this is "accidentally" installed on a system with old udev, +# having it as one single line avoids those problems. +# +# DO NOT WRAP THIS LINE +SUBSYSTEM=="iscsi_boot*", ACTION=="add", DEVPATH=="*/target*", RUN+="@SBINDIR@/iscsi_fw_login" diff --git a/utils/Makefile b/utils/Makefile index aed3bb0..92af01e 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -1,16 +1,74 @@ # This Makefile will work only with GNU make. +# +# Make file for the util sub-directory +# +# This make file does not control the fwparam_ibft +# or sysdeps subdirectories. Those are still controlled +# from the top-level make file. +# + +SED = /usr/bin/sed +INSTALL = install +CHMOD = chmod + +DESTDIR ?= +SBINDIR ?= $(DESTDIR)/sbin + +ETCDIR = $(DESTDIR)/etc +RULESDIR = $(ETCDIR)/udev/rules.d CFLAGS ?= -O2 -fno-inline -g CFLAGS += -Wall -Wextra -Wstrict-prototypes -PROGRAMS = iscsi-iname -all: $(PROGRAMS) +PROGRAMS = iscsi-iname +PROGRAMS_DEST = $(addprefix $(SBINDIR)/,$(PROGRAMS)) + +SCRIPTS_SOURCES = iscsi_discovery.sh iscsi_offload.sh +SCRIPTS_TEMPLATES = iscsi_fw_login.sh.template iscsi-gen-initiatorname.sh.template +SCRIPTS_GENERATED = $(SCRIPTS_TEMPLATES:.template=) +SCRIPTS_DEST = $(addprefix $(SBINDIR)/,$(basename $(SCRIPTS_GENERATED))) \ + $(addprefix $(SBINDIR)/,$(basename $(SCRIPTS_SOURCES))) + +RULESFILES_TEMPLATES = 50-iscsi-firmware-login.rules.template +RULESFILES_GENERATED = $(RULESFILES_TEMPLATES:.template=) +RULESFILES_DEST = $(addprefix $(RULESDIR)/,$(RULESFILES_GENERATED)) + +OBJS = iscsi-iname.o md5.o + +all: $(PROGRAMS) $(SCRIPTS_GENERATED) $(RULESFILES_GENERATED) + +$(SCRIPTS_GENERATED): %.sh: %.sh.template + $(SED) -e 's:@SBINDIR@:$(SBINDIR):' $? > $@ + $(CHMOD) 755 $@ -iscsi-iname: md5.o iscsi-iname.o +$(RULESFILES_GENERATED): %.rules: %.rules.template + $(SED) -e 's:@SBINDIR@:$(SBINDIR):' $? > $@ + +iscsi-iname: $(OBJS) $(CC) $(CFLAGS) $(LDFLAGS) $^ $(DBM_LIB) -o $@ +install: $(SBINDIR) $(RULESDIR) $(PROGRAMS_DEST) $(SCRIPTS_DEST) $(RULESFILES_DEST) + +$(PROGRAMS_DEST): $(SBINDIR)/%: % + $(INSTALL) -m 755 $? $@ + +$(SCRIPTS_DEST): $(SBINDIR)/%: %.sh + $(INSTALL) -m 755 $? $@ + +install_udev_rules: $(RULESFILES_DEST) + +$(RULESFILES_DEST): $(RULESDIR)/%: % + $(INSTALL) -m 644 $? $@ + +$(SBINDIR) $(RULESDIR): + [ -d $@ ] || $(INSTALL) -d $@ + clean: - rm -f *.o $(PROGRAMS) .depend + $(RM) $(OBJS) + $(RM) $(PROGRAMS) + $(RM) $(SCRIPTS_GENERATED) + $(RM) $(RULESFILES_GENERATED) + $(RM) .depend depend: gcc $(CFLAGS) -M `ls *.c` > .depend diff --git a/utils/iscsi-gen-initiatorname b/utils/iscsi-gen-initiatorname deleted file mode 100755 index 70ad8bf..0000000 --- a/utils/iscsi-gen-initiatorname +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/bash -# -# iscsi-gen-initiatorname -# -# Generate a default iSCSI Initiatorname for SUSE installations. -# -# Copyright (c) 2022 Hannes Reinecke, SUSE Labs -# This script is licensed under the GPL. -# - -NAME="$0" -INAME_FILE="/etc/iscsi/initiatorname.iscsi" -IQN_PREFIX="iqn.1996-04.de.suse:01" - -IBFT_COMMENTS="\ -## -## iSCSI Initiatorname taken from iBFT BIOS tables. -## -## DO NOT EDIT OR REMOVE THIS FILE! -## If you remove this file, the iSCSI daemon will not start. -## Any change here will not be reflected to the iBFT BIOS tables. -## If a different initiatorname is required please change the -## initiatorname in the BIOS setup and call -## @SBINDIR@/iscsi-gen-initiatorname -f -## to recreate an updated version of this file. -##" - -NORMAL_COMMENTS="\ -## -## Default iSCSI Initiatorname. -## -## DO NOT EDIT OR REMOVE THIS FILE! -## If you remove this file, the iSCSI daemon will not start. -## If you change the InitiatorName, existing access control lists -## may reject this initiator. The InitiatorName must be unique -## for each iSCSI initiator. Do NOT duplicate iSCSI InitiatorNames." - -usage_and_exit() -{ - xit_val=$1 - - echo "Usage: $NAME [OPTIONS] -- generate an iSCSI initiatorname" - echo "Where OPTIONS are from:" - echo " -h print usage and exit" - echo " -f overwrite existing initiator name, if any" - echo " -p IQN-PRE set the prefix for the IQN generated (default $IQN_PREFIX)" - exit $xit_val -} - -while getopts "hfp:" o ; do - case "${o}" in - h) usage_and_exit 0 ;; - f) FORCE=1 ;; - p) IQN_PREFIX=${OPTARG} ;; - ?) usage_and_exit 1 ;; - esac -done -shift $(($OPTIND-1)) - -if [ "$#" -gt 0 ] ; then - echo "Invalid argument(s): $*" - usage_and_exit -fi - -# use the iBFT initiator name, if present -if [ -d /sys/firmware/ibft/initiator ] ; then - read iSCSI_INITIATOR_NAME < /sys/firmware/ibft/initiator/initiator-name -fi - -# if we have an iBFT initiator name and an initiator name -# file, they had better match, unless "force" is set -if [ -f $INAME_FILE -a -z "$FORCE" ] ; then - if [ "$iSCSI_INITIATOR_NAME" ] ; then - eval $(cat $INAME_FILE | sed -e '/^#/d') - if [ "$iSCSI_INITIATOR_NAME" != "$InitiatorName" ] ; then - echo "iSCSI Initiatorname from iBFT is different from the current setting." - echo "Please call '@SBINDIR@/iscsi-gen-initiatorname -f' to update the iSCSI Initiatorname." - exit 1 - fi - fi -fi - -# if we have an initiator name from iBFT or from -# an existing initiator name file, use it -if [ "$iSCSI_INITIATOR_NAME" ] ; then - echo "##" > $INAME_FILE || exit 1 - echo "## $INAME_FILE" >> $INAME_FILE - echo "$IBFT_COMMENTS" >> $INAME_FILE - echo "InitiatorName=$iSCSI_INITIATOR_NAME" >> $INAME_FILE - chmod 0600 $INAME_FILE -fi - -# if we still do not have an initiator name, create one -if [ ! -f $INAME_FILE ] ; then - echo "##" > $INAME_FILE || exit 1 - echo "## $INAME_FILE" >> $INAME_FILE - echo "$NORMAL_COMMENTS" >> $INAME_FILE - # create a unique initiator name using iscsi-iname - INAME=$(@SBINDIR@/iscsi-iname -p "$IQN_PREFIX") - echo "InitiatorName=$INAME" >> $INAME_FILE - chmod 0600 $INAME_FILE -fi diff --git a/utils/iscsi-gen-initiatorname.sh.template b/utils/iscsi-gen-initiatorname.sh.template new file mode 100644 index 0000000..70ad8bf --- /dev/null +++ b/utils/iscsi-gen-initiatorname.sh.template @@ -0,0 +1,102 @@ +#!/bin/bash +# +# iscsi-gen-initiatorname +# +# Generate a default iSCSI Initiatorname for SUSE installations. +# +# Copyright (c) 2022 Hannes Reinecke, SUSE Labs +# This script is licensed under the GPL. +# + +NAME="$0" +INAME_FILE="/etc/iscsi/initiatorname.iscsi" +IQN_PREFIX="iqn.1996-04.de.suse:01" + +IBFT_COMMENTS="\ +## +## iSCSI Initiatorname taken from iBFT BIOS tables. +## +## DO NOT EDIT OR REMOVE THIS FILE! +## If you remove this file, the iSCSI daemon will not start. +## Any change here will not be reflected to the iBFT BIOS tables. +## If a different initiatorname is required please change the +## initiatorname in the BIOS setup and call +## @SBINDIR@/iscsi-gen-initiatorname -f +## to recreate an updated version of this file. +##" + +NORMAL_COMMENTS="\ +## +## Default iSCSI Initiatorname. +## +## DO NOT EDIT OR REMOVE THIS FILE! +## If you remove this file, the iSCSI daemon will not start. +## If you change the InitiatorName, existing access control lists +## may reject this initiator. The InitiatorName must be unique +## for each iSCSI initiator. Do NOT duplicate iSCSI InitiatorNames." + +usage_and_exit() +{ + xit_val=$1 + + echo "Usage: $NAME [OPTIONS] -- generate an iSCSI initiatorname" + echo "Where OPTIONS are from:" + echo " -h print usage and exit" + echo " -f overwrite existing initiator name, if any" + echo " -p IQN-PRE set the prefix for the IQN generated (default $IQN_PREFIX)" + exit $xit_val +} + +while getopts "hfp:" o ; do + case "${o}" in + h) usage_and_exit 0 ;; + f) FORCE=1 ;; + p) IQN_PREFIX=${OPTARG} ;; + ?) usage_and_exit 1 ;; + esac +done +shift $(($OPTIND-1)) + +if [ "$#" -gt 0 ] ; then + echo "Invalid argument(s): $*" + usage_and_exit +fi + +# use the iBFT initiator name, if present +if [ -d /sys/firmware/ibft/initiator ] ; then + read iSCSI_INITIATOR_NAME < /sys/firmware/ibft/initiator/initiator-name +fi + +# if we have an iBFT initiator name and an initiator name +# file, they had better match, unless "force" is set +if [ -f $INAME_FILE -a -z "$FORCE" ] ; then + if [ "$iSCSI_INITIATOR_NAME" ] ; then + eval $(cat $INAME_FILE | sed -e '/^#/d') + if [ "$iSCSI_INITIATOR_NAME" != "$InitiatorName" ] ; then + echo "iSCSI Initiatorname from iBFT is different from the current setting." + echo "Please call '@SBINDIR@/iscsi-gen-initiatorname -f' to update the iSCSI Initiatorname." + exit 1 + fi + fi +fi + +# if we have an initiator name from iBFT or from +# an existing initiator name file, use it +if [ "$iSCSI_INITIATOR_NAME" ] ; then + echo "##" > $INAME_FILE || exit 1 + echo "## $INAME_FILE" >> $INAME_FILE + echo "$IBFT_COMMENTS" >> $INAME_FILE + echo "InitiatorName=$iSCSI_INITIATOR_NAME" >> $INAME_FILE + chmod 0600 $INAME_FILE +fi + +# if we still do not have an initiator name, create one +if [ ! -f $INAME_FILE ] ; then + echo "##" > $INAME_FILE || exit 1 + echo "## $INAME_FILE" >> $INAME_FILE + echo "$NORMAL_COMMENTS" >> $INAME_FILE + # create a unique initiator name using iscsi-iname + INAME=$(@SBINDIR@/iscsi-iname -p "$IQN_PREFIX") + echo "InitiatorName=$INAME" >> $INAME_FILE + chmod 0600 $INAME_FILE +fi diff --git a/utils/iscsi_discovery b/utils/iscsi_discovery deleted file mode 100755 index be2f390..0000000 --- a/utils/iscsi_discovery +++ /dev/null @@ -1,195 +0,0 @@ -#!/bin/bash -# -# Copyright (C) Voltaire Ltd. 2006. ALL RIGHTS RESERVED. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# Author: Dan Bar Dov - -# iscsi_discovery: -# * does a send-targets discovery to the given IP -# * set the transport type to the preferred transport (or tcp is -t flag is not used) -# * tries to login -# * if succeeds, -# o logout, -# o mark record autmatic (unless -m flag is used) -# * else -# o reset transport type to TCP -# o try to login -# o if succeeded -# + logout -# + mark record automatic (unless -m flag is used) -# - -usage() -{ - echo "Usage: $0 [-p ] [-d] [-t [-f]] [-m] [-l]" - echo "Options:" - echo "-p set the port number (default is 3260)." - echo "-d print debugging information" - echo "-t set transport (default is tcp)." - echo "-f force specific transport -disable the fallback to tcp (default is fallback enabled)." - echo " force the transport specified by the argument of the -t flag." - echo "-m manual startup - will set manual startup (default is automatic startup)." - echo "-l login to the new discovered nodes (default is false)." -} - -dbg() -{ - $debug && echo $@ -} - -initialize() -{ - trap "exit" 2 - debug=false - force="0" - log_out="1" - startup_manual="0" - #set default transport to tcp - transport=tcp - #set default port to 3260 - port=3260; -} - -parse_cmdline() -{ - if [ $# -lt 1 ]; then - usage - exit 1 - fi - - # check if the IP address is valid - ip=`echo $1 | awk -F'.' '$1 != "" && $1 <=255 && $2 != "" && $2 <= 255 && $3 != "" && $3 <= 255 && $4 != "" && $4 <= 255 {print $0}'` - if [ -z "$ip" ]; then - echo "$1 is not a vaild IP address!" - exit 1 - fi - shift - while getopts "dfmlt:p:" options; do - case $options in - d ) debug=true;; - f ) force="1";; - t ) transport=$OPTARG;; - p ) port=$OPTARG;; - m ) startup_manual="1";; - l ) log_out=0;; - \? ) usage - exit 1;; - * ) usage - exit 1;; - esac - done -} - -discover() -{ - # If open-iscsi is already logged in to the portal, exit - if [ $(iscsiadm -m session | grep -c ${ip}:${port}) -ne 0 ]; then - echo "Please logout from all targets on ${ip}:${port} before trying to run discovery on that portal" - exit 2 - fi - - connected=0 - discovered=0 - - dbg "starting discovery to $ip" - disc="$(iscsiadm -m discovery --type sendtargets --portal ${ip}:${port})" - echo "${disc}" | while read portal target - do - portal=${portal%,*} - select_transport - done - - discovered=$(echo "${disc}" | wc -l) - if [ ${discovered} = 0 ]; then - echo "failed to discover targets at ${ip}" - exit 2 - else - echo "discovered ${discovered} targets at ${ip}" - fi -} - -try_login() -{ - if [ "$startup_manual" != "1" ]; then - iscsiadm -m node --targetname ${target} --portal ${portal} --op update -n node.conn[0].startup -v automatic - fi - iscsiadm -m node --targetname ${target} --portal ${portal} --login >/dev/null 2>&1 - ret=$? - if [ ${ret} = 0 ]; then - echo "Set target ${target} to automatic login over ${transport} to portal ${portal}" - ((connected++)) - if [ "$log_out" = "1" ]; then - iscsiadm -m node --targetname ${target} --portal ${portal} --logout - fi - else - echo "Cannot login over ${transport} to portal ${portal}" - iscsiadm -m node --targetname ${target} --portal ${portal} --op update -n node.conn[0].startup -v manual - fi - return ${ret} -} - -set_transport() -{ - transport=$1 - case "$transport" in - iser) - # iSER does not use digest - iscsiadm -m node --targetname ${target} --portal ${portal} \ - --op update -n node.conn[0].iscsi.HeaderDigest -v None - iscsiadm -m node --targetname ${target} --portal ${portal} \ - --op update -n node.conn[0].iscsi.DataDigest -v None - ;; - cxgb3i) - # cxgb3i supports <= 16K packet (BHS + AHS + pdu payload + digests) - iscsiadm -m node --targetname ${target} --portal ${portal} \ - --op update -n node.conn[0].iscsi.MaxRecvDataSegmentLength \ - -v 8192 - ;; - esac - transport_name=`iscsiadm -m node -p ${portal} -T ${target} |awk '/transport_name/ {print $1}'` - iscsiadm -m node --targetname ${target} --portal ${portal} \ - --op update -n ${transport_name} -v ${transport} -} - -select_transport() -{ - set_transport $transport - dbg "Testing $transport-login to target ${target} portal ${portal}" - try_login; - if [ $? != 0 -a "$force" = "0" ]; then - set_transport tcp - dbg "starting to test tcp-login to target ${target} portal ${portal}" - try_login; - fi -} - -check_iscsid() -{ - #check if iscsid is running - pidof iscsid &>/dev/null - ret=$? - if [ $ret -ne 0 ]; then - echo "iscsid is not running" - echo "Exiting..." - exit 1 - fi -} - -check_iscsid -initialize -parse_cmdline "$@" -discover diff --git a/utils/iscsi_discovery.sh b/utils/iscsi_discovery.sh new file mode 100755 index 0000000..be2f390 --- /dev/null +++ b/utils/iscsi_discovery.sh @@ -0,0 +1,195 @@ +#!/bin/bash +# +# Copyright (C) Voltaire Ltd. 2006. ALL RIGHTS RESERVED. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Author: Dan Bar Dov + +# iscsi_discovery: +# * does a send-targets discovery to the given IP +# * set the transport type to the preferred transport (or tcp is -t flag is not used) +# * tries to login +# * if succeeds, +# o logout, +# o mark record autmatic (unless -m flag is used) +# * else +# o reset transport type to TCP +# o try to login +# o if succeeded +# + logout +# + mark record automatic (unless -m flag is used) +# + +usage() +{ + echo "Usage: $0 [-p ] [-d] [-t [-f]] [-m] [-l]" + echo "Options:" + echo "-p set the port number (default is 3260)." + echo "-d print debugging information" + echo "-t set transport (default is tcp)." + echo "-f force specific transport -disable the fallback to tcp (default is fallback enabled)." + echo " force the transport specified by the argument of the -t flag." + echo "-m manual startup - will set manual startup (default is automatic startup)." + echo "-l login to the new discovered nodes (default is false)." +} + +dbg() +{ + $debug && echo $@ +} + +initialize() +{ + trap "exit" 2 + debug=false + force="0" + log_out="1" + startup_manual="0" + #set default transport to tcp + transport=tcp + #set default port to 3260 + port=3260; +} + +parse_cmdline() +{ + if [ $# -lt 1 ]; then + usage + exit 1 + fi + + # check if the IP address is valid + ip=`echo $1 | awk -F'.' '$1 != "" && $1 <=255 && $2 != "" && $2 <= 255 && $3 != "" && $3 <= 255 && $4 != "" && $4 <= 255 {print $0}'` + if [ -z "$ip" ]; then + echo "$1 is not a vaild IP address!" + exit 1 + fi + shift + while getopts "dfmlt:p:" options; do + case $options in + d ) debug=true;; + f ) force="1";; + t ) transport=$OPTARG;; + p ) port=$OPTARG;; + m ) startup_manual="1";; + l ) log_out=0;; + \? ) usage + exit 1;; + * ) usage + exit 1;; + esac + done +} + +discover() +{ + # If open-iscsi is already logged in to the portal, exit + if [ $(iscsiadm -m session | grep -c ${ip}:${port}) -ne 0 ]; then + echo "Please logout from all targets on ${ip}:${port} before trying to run discovery on that portal" + exit 2 + fi + + connected=0 + discovered=0 + + dbg "starting discovery to $ip" + disc="$(iscsiadm -m discovery --type sendtargets --portal ${ip}:${port})" + echo "${disc}" | while read portal target + do + portal=${portal%,*} + select_transport + done + + discovered=$(echo "${disc}" | wc -l) + if [ ${discovered} = 0 ]; then + echo "failed to discover targets at ${ip}" + exit 2 + else + echo "discovered ${discovered} targets at ${ip}" + fi +} + +try_login() +{ + if [ "$startup_manual" != "1" ]; then + iscsiadm -m node --targetname ${target} --portal ${portal} --op update -n node.conn[0].startup -v automatic + fi + iscsiadm -m node --targetname ${target} --portal ${portal} --login >/dev/null 2>&1 + ret=$? + if [ ${ret} = 0 ]; then + echo "Set target ${target} to automatic login over ${transport} to portal ${portal}" + ((connected++)) + if [ "$log_out" = "1" ]; then + iscsiadm -m node --targetname ${target} --portal ${portal} --logout + fi + else + echo "Cannot login over ${transport} to portal ${portal}" + iscsiadm -m node --targetname ${target} --portal ${portal} --op update -n node.conn[0].startup -v manual + fi + return ${ret} +} + +set_transport() +{ + transport=$1 + case "$transport" in + iser) + # iSER does not use digest + iscsiadm -m node --targetname ${target} --portal ${portal} \ + --op update -n node.conn[0].iscsi.HeaderDigest -v None + iscsiadm -m node --targetname ${target} --portal ${portal} \ + --op update -n node.conn[0].iscsi.DataDigest -v None + ;; + cxgb3i) + # cxgb3i supports <= 16K packet (BHS + AHS + pdu payload + digests) + iscsiadm -m node --targetname ${target} --portal ${portal} \ + --op update -n node.conn[0].iscsi.MaxRecvDataSegmentLength \ + -v 8192 + ;; + esac + transport_name=`iscsiadm -m node -p ${portal} -T ${target} |awk '/transport_name/ {print $1}'` + iscsiadm -m node --targetname ${target} --portal ${portal} \ + --op update -n ${transport_name} -v ${transport} +} + +select_transport() +{ + set_transport $transport + dbg "Testing $transport-login to target ${target} portal ${portal}" + try_login; + if [ $? != 0 -a "$force" = "0" ]; then + set_transport tcp + dbg "starting to test tcp-login to target ${target} portal ${portal}" + try_login; + fi +} + +check_iscsid() +{ + #check if iscsid is running + pidof iscsid &>/dev/null + ret=$? + if [ $ret -ne 0 ]; then + echo "iscsid is not running" + echo "Exiting..." + exit 1 + fi +} + +check_iscsid +initialize +parse_cmdline "$@" +discover diff --git a/utils/iscsi_fw_login b/utils/iscsi_fw_login deleted file mode 100644 index aae9e4c..0000000 --- a/utils/iscsi_fw_login +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# -# iscsi_fw_login -- login to iscsi firmware targets, if any -# -# This script is called when udev discovers a new iscsi -# firmware target -# - -ARGS="-m fw -l" -ISCSIADM="@SBINDIR@/iscsiadm" - -$ISCSIADM $ARGS diff --git a/utils/iscsi_fw_login.sh.template b/utils/iscsi_fw_login.sh.template new file mode 100644 index 0000000..aae9e4c --- /dev/null +++ b/utils/iscsi_fw_login.sh.template @@ -0,0 +1,12 @@ +#!/bin/bash +# +# iscsi_fw_login -- login to iscsi firmware targets, if any +# +# This script is called when udev discovers a new iscsi +# firmware target +# + +ARGS="-m fw -l" +ISCSIADM="@SBINDIR@/iscsiadm" + +$ISCSIADM $ARGS diff --git a/utils/iscsi_offload b/utils/iscsi_offload deleted file mode 100755 index 1869fe1..0000000 --- a/utils/iscsi_offload +++ /dev/null @@ -1,384 +0,0 @@ -#!/bin/bash -# -# iscsi_offload -# -# Configure iSCSI offload engines for use with open-iscsi -# Usage: -# iscsi_offload [-d | -f | -i | -t ] -# -# Copyright (c) 2011 Hannes Reinecke, SUSE Labs -# This script is licensed under the GPL. -# -# The script creates an open-iscsi interface definition -# in the style -, where matches the -# network interface passed on the commandline. -# If '-t' (test mode) is passed as an option, the script -# will not create nor modify any setting but just print -# the currently active ones. -# -# Currently the script works with Broadcom (bnx2i) and -# Chelsio T3 (cxgbi) iSCSI offload engines. -# Should work with Chelsio T4, but has not been tested. -# ServerEngines (be2iscsi) and QLogic (qla4xxx) can only -# be configured via BIOS, open-iscsi support is still in -# development. -# - -# -# Return codes: -# 0: Success -# 1: Invalid command line parameter -# 2: iSCSI offloading not supported -# 3: Error during module loading -# 4: Cannot configure interface via iscsiadm, use BIOS setup -# 5: internal error running iscsiadm -# -# Output: -# [none|dhcp|ip |ibft] -# where -# : MAC Address of the iSCSI offload engine -# none: No IP configuration set for the iSCSI offload engine -# dhcp: iSCSI offload engine configured for DHCP -# ip: iSCSI offload engine configured with static IP address -# ibft: iSCSI offload engine configured from iBFT values -# - -# -# Figure out the MAC address of the iSCSI offload engine -# corresponding to a NIC from a given PCI device. -# bnx2 is using one PCI device per port for both network and iSCSI offloading -# cxgb3 is using one PCI device for everything. -# -iscsi_macaddress_from_pcidevice() -{ - local path=$1 - local if=$2 - local h - local host - - for h in $path/host* ; do - if [ -d "$h" ] ; then - host=${h##*/} - read netdev < /sys/class/iscsi_host/$host/netdev - if [ "$netdev" = "$IFNAME" ] ; then - read mac < /sys/class/iscsi_host/$host/hwaddress - if [ "$mac" != "00:00:00:00:00:00" ] ; then - echo "$mac" - fi - break; - fi - fi - done -} - -# -# Figure out the MAC address of the iSCSI offload engine -# corresponding to a NIC from a given PCI function. -# It is assumed that the MAC address of the iSCSI offload -# engine is equal of the MAC address of the NIC plus one. -# Suitable for be2iscsi and qla4xxx -# -iscsi_macaddress_from_pcifn() -{ - local path=$1 - local if=$2 - local h - local host - local ifmac - local olemacoffset=$3 - - ifmac=$(ip addr show dev $if | sed -n 's/ *link\/ether \(.*\) brd.*/\1/p') - m5=$(( 0x${ifmac##*:} )) - m5=$(( $m5 + $olemacoffset )) - ifmac=$(printf "%s:%02x" ${ifmac%:*} $m5) - for host in /sys/class/iscsi_host/host* ; do - if [ -L "$host" ] ; then - read mac < $host/hwaddress - if [ "$mac" = "$ifmac" ] ; then - echo "$mac" - break; - fi - fi - done -} - -update_iface_setting() { - local iface="$1" - local name="$2" - local value="$3" - - iface_value=$(iscsiadm -m iface -I $iface | sed -n "s/$name = \(.*\)/\1/p") - if [ "$iface_value" = "" ] ; then - iface_value= - fi - if [ "$iface_value" != "$value" ] ; then - if ! iscsiadm -m iface -I $iface -o update -n "$name" -v "$value" ; then - return 1 - fi - fi - return 0 -} - -while getopts di:t options ; do - case $options in - d ) mode=dhcp;; - i ) mode=static - optaddr=$OPTARG - ;; - f ) mode=firmware;; - t ) dry_run=1;; - ?) printf "Usage: %s [-d|-t|-i ipaddr|-f] ifname\n" $0 - exit 1;; - esac -done -shift $(($OPTIND - 1)) - -IFNAME=$1 -ibft_mode="none" - -if [ -z "$IFNAME" ] ; then - echo "No interface specified" - exit 1 -fi - -if [ "$dry_run" ] ; then - if [ "$mode" = "dhcp" ] ; then - echo "'-t' specified, ignoring '-d'" - mode= - elif [ "$mode" = "static" ] ; then - echo "'-t' specified, ignoring '-s'" - mode= - fi -fi - -if [ ! -L /sys/class/net/$IFNAME ] ; then - echo "Interface $IFNAME not found" - exit 1 -fi - -if [ "$optaddr" ] && ! ip route get $optaddr ; then - echo "Invalid IP address $optaddr" - exit 1 -fi -if [ "$dry_run" ] ; then - mode= -fi - - -ifpath=$(cd -P /sys/class/net/$IFNAME; echo $PWD) -pcipath=$(cd -P $ifpath/device; echo $PWD) - -if [ -d $pcipath ] ; then - drvlink=$(readlink $pcipath/driver) - driver=${drvlink##*/} -fi - -if [ -z "$driver" ] ; then - echo "No driver found for interface $IFNAME" - exit 1 -fi - -case "$driver" in - bnx2*) - mod=bnx2i - ;; - cxgb*) - mod=cxgb3i - ;; - be2*) - mod=be2iscsi - ;; - qla*) - mod=qla4xxx - ;; - qed*) - mod=qedi - ;; -esac - -if [ -z "$mod" ] ; then - echo "iSCSI offloading not supported on interface $IFNAME" - exit 2 -fi - -# Check if the required modules are already loaded -loaded=$(sed -n "/^$mod/p" /proc/modules) -if [ -z "$loaded" ] ; then - modprobe $mod -fi - -loaded=$(sed -n "/^$mod/p" /proc/modules) -if [ -z "$loaded" ] ; then - echo "Loading of $mod.ko failed, please check dmesg" - exit 3 -fi - -# Get the correct MAC address for the various devices -if [ "$mod" = "bnx2i" ] ; then - mac=$(iscsi_macaddress_from_pcidevice $pcipath $IFNAME) -elif [ "$mod" = "cxgb3i" ] ; then - mac=$(iscsi_macaddress_from_pcidevice $pcipath $IFNAME) -elif [ "$mod" = "be2iscsi" ] ; then - mac=$(iscsi_macaddress_from_pcifn $pcipath $IFNAME 1) -elif [ "$mod" = "qla4xxx" ] ; then - mac=$(iscsi_macaddress_from_pcifn $pcipath $IFNAME 1) -elif [ "$mod" = "qede" -o "$mod" = "qedi" ] ; then - mac=$(iscsi_macaddress_from_pcifn $pcipath $IFNAME 4) -fi - -if [ -z "$mac" ] ; then - echo "iSCSI offloading not supported on interface $IFNAME" - exit 2 -fi - -gen_iface="$mod.$mac" -ioe_iface="${IFNAME}-${mod}" - -# Get existing settings -if iscsiadm -m iface -I $ioe_iface > /dev/null 2>&1 ; then - ioe_mac=$(iscsiadm -m iface -I $ioe_iface 2> /dev/null| sed -n "s/iface\.hwaddress = \(.*\)/\1/p") - ioe_mod=$(iscsiadm -m iface -I $ioe_iface 2> /dev/null| sed -n "s/iface\.transport_name = \(.*\)/\1/p") - ipaddr=$(iscsiadm -m iface -I $ioe_iface 2> /dev/null| sed -n "s/iface\.ipaddress = \(.*\)/\1/p") - if [ "$ipaddr" == "" ] ; then - ipaddr= - fi -elif [ "$mod" = "be2iscsi" ] ; then - ioe_mac=$mac - ioe_mod=$mod -else - # Create new interface - iscsiadm -m iface -I $ioe_iface --op=new 2> /dev/null - ioe_mac= - ioe_mod= - ipaddr= -fi - -if [ -z "$dry_run" ] ; then - if [ "$ioe_mac" != "$mac" ] ; then - if [ -n "$ioe_mac" ] ; then - echo "Warning: Updating MAC address on iface $ioe_iface" - fi - update_iface_setting $ioe_iface iface.hwaddress "$mac" - fi - - if [ "$ioe_mod" != "$mod" ] ; then - if [ -n "$ioe_mod" ] ; then - echo "Warning: Update transport on iface $ioe_iface" - fi - update_iface_setting $ioe_iface iface.transport_name "$mod" - fi -elif [ -z "$ipaddr" ] ; then - ipaddr=$(iscsiadm -m iface -I $gen_iface 2> /dev/null| sed -n "s/iface\.ipaddress = \(.*\)/\1/p") - if [ "$ipaddr" = "" ] ; then - ipaddr= - fi -elif [ "$ioe_mod" != "$mod" ] ; then - echo "Warning: Transport mismatch on iface $ioe_iface: $ioe_mod should be $mod" -fi - -# Check iBFT setting -for d in /sys/firmware/* ; do - [ -d $d ] || continue - [ -d $d/ethernet0 ] || continue - iboot_dir=$d -done -if [ -n "$iboot_dir" ] && [ -d "$iboot_dir" ] ; then - for if in ${iboot_dir}/ethernet* ; do - read ibft_mac < $if/mac - [ "$ibft_mac" = "$mac" ] || continue - ibft_origin=0 - [ -f ${if}/origin ] && read ibft_origin < $if/origin - if [ "$ibft_origin" -eq 1 ] ; then - ibft_mode="static" - elif [ "$ibft_origin" -eq 3 ] ; then - ibft_mode="dhcp" - fi - [ -f $if/dhcp ] && read ibft_dhcp < $if/dhcp - if [ -n "$ibft_dhcp" -a "$ibft_mode" != "dhcp" ] ; then - ibft_mode=dhcp - fi - if [ "$ibft_mode" = "dhcp" ] ; then - ibft_ipaddr="0.0.0.0" - ibft_gateway= - ibft_mask= - break - fi - [ -f $if/ip-addr ] && read ibft_ipaddr < $if/ip-addr - [ -f $if/gateway ] && read ibft_gateway < $if/gateway - [ -f $if/subnet-mask ] && read ibft_mask < $if/subnet-mask - break - done -fi - -if [ -z "$optaddr" ] && [ "$ibft_ipaddr" ] ; then - optaddr=$ibft_ipaddr -fi - -# Check if the interface needs to be configured -if [ -z "$mode" ] ; then - if [ "$ibft_mode" != "none" ] ; then - echo "$mac ibft" - mode="ibft" - elif [ -z "$ipaddr" ] ; then - echo "$mac none" - mode="none" - elif [ "$ipaddr" = "0.0.0.0" ] ; then - echo "$mac dhcp" - ipaddr= - mode="dhcp" - else - echo "$mac ip $ipaddr" - mode="static" - fi - [ "$dry_run" ] && exit 0 -elif [ "$mode" = "dhcp" ] ; then - if [ "$ipaddr" = "0.0.0.0" ] ; then - echo "$mac dhcp" - exit 0 - fi - optaddr="0.0.0.0" -elif [ "$mode" = "static" ] && [ "$ipaddr" = "$optaddr" ] ; then - echo "$mac ip $ipaddr" - exit 0 -fi - -if [ "$mod" = "be2iscsi" ] ; then - exit 4 -fi - -if ! update_iface_setting $ioe_iface iface.ipaddress "$optaddr" ; then - echo "Failed to set IP address: $?" - exit 1 -fi -if ! update_iface_setting $gen_iface iface.ipaddress "$optaddr" ; then - echo "Failed to set IP address for generic interface: $?" - exit 1 -fi - -if ! update_iface_setting $ioe_iface iface.gateway "$ibft_gateway" ; then - echo "Failed to set gateway address: $?" - exit 1 -fi - -if ! update_iface_setting $gen_iface iface.gateway "$ibft_gateway" ; then - echo "Failed to set gateway address for generic interface: $?" - exit 1 -fi - -if ! update_iface_setting $ioe_iface iface.subnet_mask "$ibft_mask" ; then - echo "Failed to set subnet mask: $?" - exit 1 -fi - -if ! update_iface_setting $gen_iface iface.subnet_mask "$ibft_mask" ; then - echo "Failed to set subnet mask for generic interface: $?" - exit 1 -fi - -if [ "$mod" = "qla4xxx" ] ; then - iscsiadm -m iface -H $mac -o applyall -fi -ip link set dev $IFNAME up - -exit 0 - diff --git a/utils/iscsi_offload.sh b/utils/iscsi_offload.sh new file mode 100755 index 0000000..1869fe1 --- /dev/null +++ b/utils/iscsi_offload.sh @@ -0,0 +1,384 @@ +#!/bin/bash +# +# iscsi_offload +# +# Configure iSCSI offload engines for use with open-iscsi +# Usage: +# iscsi_offload [-d | -f | -i | -t ] +# +# Copyright (c) 2011 Hannes Reinecke, SUSE Labs +# This script is licensed under the GPL. +# +# The script creates an open-iscsi interface definition +# in the style -, where matches the +# network interface passed on the commandline. +# If '-t' (test mode) is passed as an option, the script +# will not create nor modify any setting but just print +# the currently active ones. +# +# Currently the script works with Broadcom (bnx2i) and +# Chelsio T3 (cxgbi) iSCSI offload engines. +# Should work with Chelsio T4, but has not been tested. +# ServerEngines (be2iscsi) and QLogic (qla4xxx) can only +# be configured via BIOS, open-iscsi support is still in +# development. +# + +# +# Return codes: +# 0: Success +# 1: Invalid command line parameter +# 2: iSCSI offloading not supported +# 3: Error during module loading +# 4: Cannot configure interface via iscsiadm, use BIOS setup +# 5: internal error running iscsiadm +# +# Output: +# [none|dhcp|ip |ibft] +# where +# : MAC Address of the iSCSI offload engine +# none: No IP configuration set for the iSCSI offload engine +# dhcp: iSCSI offload engine configured for DHCP +# ip: iSCSI offload engine configured with static IP address +# ibft: iSCSI offload engine configured from iBFT values +# + +# +# Figure out the MAC address of the iSCSI offload engine +# corresponding to a NIC from a given PCI device. +# bnx2 is using one PCI device per port for both network and iSCSI offloading +# cxgb3 is using one PCI device for everything. +# +iscsi_macaddress_from_pcidevice() +{ + local path=$1 + local if=$2 + local h + local host + + for h in $path/host* ; do + if [ -d "$h" ] ; then + host=${h##*/} + read netdev < /sys/class/iscsi_host/$host/netdev + if [ "$netdev" = "$IFNAME" ] ; then + read mac < /sys/class/iscsi_host/$host/hwaddress + if [ "$mac" != "00:00:00:00:00:00" ] ; then + echo "$mac" + fi + break; + fi + fi + done +} + +# +# Figure out the MAC address of the iSCSI offload engine +# corresponding to a NIC from a given PCI function. +# It is assumed that the MAC address of the iSCSI offload +# engine is equal of the MAC address of the NIC plus one. +# Suitable for be2iscsi and qla4xxx +# +iscsi_macaddress_from_pcifn() +{ + local path=$1 + local if=$2 + local h + local host + local ifmac + local olemacoffset=$3 + + ifmac=$(ip addr show dev $if | sed -n 's/ *link\/ether \(.*\) brd.*/\1/p') + m5=$(( 0x${ifmac##*:} )) + m5=$(( $m5 + $olemacoffset )) + ifmac=$(printf "%s:%02x" ${ifmac%:*} $m5) + for host in /sys/class/iscsi_host/host* ; do + if [ -L "$host" ] ; then + read mac < $host/hwaddress + if [ "$mac" = "$ifmac" ] ; then + echo "$mac" + break; + fi + fi + done +} + +update_iface_setting() { + local iface="$1" + local name="$2" + local value="$3" + + iface_value=$(iscsiadm -m iface -I $iface | sed -n "s/$name = \(.*\)/\1/p") + if [ "$iface_value" = "" ] ; then + iface_value= + fi + if [ "$iface_value" != "$value" ] ; then + if ! iscsiadm -m iface -I $iface -o update -n "$name" -v "$value" ; then + return 1 + fi + fi + return 0 +} + +while getopts di:t options ; do + case $options in + d ) mode=dhcp;; + i ) mode=static + optaddr=$OPTARG + ;; + f ) mode=firmware;; + t ) dry_run=1;; + ?) printf "Usage: %s [-d|-t|-i ipaddr|-f] ifname\n" $0 + exit 1;; + esac +done +shift $(($OPTIND - 1)) + +IFNAME=$1 +ibft_mode="none" + +if [ -z "$IFNAME" ] ; then + echo "No interface specified" + exit 1 +fi + +if [ "$dry_run" ] ; then + if [ "$mode" = "dhcp" ] ; then + echo "'-t' specified, ignoring '-d'" + mode= + elif [ "$mode" = "static" ] ; then + echo "'-t' specified, ignoring '-s'" + mode= + fi +fi + +if [ ! -L /sys/class/net/$IFNAME ] ; then + echo "Interface $IFNAME not found" + exit 1 +fi + +if [ "$optaddr" ] && ! ip route get $optaddr ; then + echo "Invalid IP address $optaddr" + exit 1 +fi +if [ "$dry_run" ] ; then + mode= +fi + + +ifpath=$(cd -P /sys/class/net/$IFNAME; echo $PWD) +pcipath=$(cd -P $ifpath/device; echo $PWD) + +if [ -d $pcipath ] ; then + drvlink=$(readlink $pcipath/driver) + driver=${drvlink##*/} +fi + +if [ -z "$driver" ] ; then + echo "No driver found for interface $IFNAME" + exit 1 +fi + +case "$driver" in + bnx2*) + mod=bnx2i + ;; + cxgb*) + mod=cxgb3i + ;; + be2*) + mod=be2iscsi + ;; + qla*) + mod=qla4xxx + ;; + qed*) + mod=qedi + ;; +esac + +if [ -z "$mod" ] ; then + echo "iSCSI offloading not supported on interface $IFNAME" + exit 2 +fi + +# Check if the required modules are already loaded +loaded=$(sed -n "/^$mod/p" /proc/modules) +if [ -z "$loaded" ] ; then + modprobe $mod +fi + +loaded=$(sed -n "/^$mod/p" /proc/modules) +if [ -z "$loaded" ] ; then + echo "Loading of $mod.ko failed, please check dmesg" + exit 3 +fi + +# Get the correct MAC address for the various devices +if [ "$mod" = "bnx2i" ] ; then + mac=$(iscsi_macaddress_from_pcidevice $pcipath $IFNAME) +elif [ "$mod" = "cxgb3i" ] ; then + mac=$(iscsi_macaddress_from_pcidevice $pcipath $IFNAME) +elif [ "$mod" = "be2iscsi" ] ; then + mac=$(iscsi_macaddress_from_pcifn $pcipath $IFNAME 1) +elif [ "$mod" = "qla4xxx" ] ; then + mac=$(iscsi_macaddress_from_pcifn $pcipath $IFNAME 1) +elif [ "$mod" = "qede" -o "$mod" = "qedi" ] ; then + mac=$(iscsi_macaddress_from_pcifn $pcipath $IFNAME 4) +fi + +if [ -z "$mac" ] ; then + echo "iSCSI offloading not supported on interface $IFNAME" + exit 2 +fi + +gen_iface="$mod.$mac" +ioe_iface="${IFNAME}-${mod}" + +# Get existing settings +if iscsiadm -m iface -I $ioe_iface > /dev/null 2>&1 ; then + ioe_mac=$(iscsiadm -m iface -I $ioe_iface 2> /dev/null| sed -n "s/iface\.hwaddress = \(.*\)/\1/p") + ioe_mod=$(iscsiadm -m iface -I $ioe_iface 2> /dev/null| sed -n "s/iface\.transport_name = \(.*\)/\1/p") + ipaddr=$(iscsiadm -m iface -I $ioe_iface 2> /dev/null| sed -n "s/iface\.ipaddress = \(.*\)/\1/p") + if [ "$ipaddr" == "" ] ; then + ipaddr= + fi +elif [ "$mod" = "be2iscsi" ] ; then + ioe_mac=$mac + ioe_mod=$mod +else + # Create new interface + iscsiadm -m iface -I $ioe_iface --op=new 2> /dev/null + ioe_mac= + ioe_mod= + ipaddr= +fi + +if [ -z "$dry_run" ] ; then + if [ "$ioe_mac" != "$mac" ] ; then + if [ -n "$ioe_mac" ] ; then + echo "Warning: Updating MAC address on iface $ioe_iface" + fi + update_iface_setting $ioe_iface iface.hwaddress "$mac" + fi + + if [ "$ioe_mod" != "$mod" ] ; then + if [ -n "$ioe_mod" ] ; then + echo "Warning: Update transport on iface $ioe_iface" + fi + update_iface_setting $ioe_iface iface.transport_name "$mod" + fi +elif [ -z "$ipaddr" ] ; then + ipaddr=$(iscsiadm -m iface -I $gen_iface 2> /dev/null| sed -n "s/iface\.ipaddress = \(.*\)/\1/p") + if [ "$ipaddr" = "" ] ; then + ipaddr= + fi +elif [ "$ioe_mod" != "$mod" ] ; then + echo "Warning: Transport mismatch on iface $ioe_iface: $ioe_mod should be $mod" +fi + +# Check iBFT setting +for d in /sys/firmware/* ; do + [ -d $d ] || continue + [ -d $d/ethernet0 ] || continue + iboot_dir=$d +done +if [ -n "$iboot_dir" ] && [ -d "$iboot_dir" ] ; then + for if in ${iboot_dir}/ethernet* ; do + read ibft_mac < $if/mac + [ "$ibft_mac" = "$mac" ] || continue + ibft_origin=0 + [ -f ${if}/origin ] && read ibft_origin < $if/origin + if [ "$ibft_origin" -eq 1 ] ; then + ibft_mode="static" + elif [ "$ibft_origin" -eq 3 ] ; then + ibft_mode="dhcp" + fi + [ -f $if/dhcp ] && read ibft_dhcp < $if/dhcp + if [ -n "$ibft_dhcp" -a "$ibft_mode" != "dhcp" ] ; then + ibft_mode=dhcp + fi + if [ "$ibft_mode" = "dhcp" ] ; then + ibft_ipaddr="0.0.0.0" + ibft_gateway= + ibft_mask= + break + fi + [ -f $if/ip-addr ] && read ibft_ipaddr < $if/ip-addr + [ -f $if/gateway ] && read ibft_gateway < $if/gateway + [ -f $if/subnet-mask ] && read ibft_mask < $if/subnet-mask + break + done +fi + +if [ -z "$optaddr" ] && [ "$ibft_ipaddr" ] ; then + optaddr=$ibft_ipaddr +fi + +# Check if the interface needs to be configured +if [ -z "$mode" ] ; then + if [ "$ibft_mode" != "none" ] ; then + echo "$mac ibft" + mode="ibft" + elif [ -z "$ipaddr" ] ; then + echo "$mac none" + mode="none" + elif [ "$ipaddr" = "0.0.0.0" ] ; then + echo "$mac dhcp" + ipaddr= + mode="dhcp" + else + echo "$mac ip $ipaddr" + mode="static" + fi + [ "$dry_run" ] && exit 0 +elif [ "$mode" = "dhcp" ] ; then + if [ "$ipaddr" = "0.0.0.0" ] ; then + echo "$mac dhcp" + exit 0 + fi + optaddr="0.0.0.0" +elif [ "$mode" = "static" ] && [ "$ipaddr" = "$optaddr" ] ; then + echo "$mac ip $ipaddr" + exit 0 +fi + +if [ "$mod" = "be2iscsi" ] ; then + exit 4 +fi + +if ! update_iface_setting $ioe_iface iface.ipaddress "$optaddr" ; then + echo "Failed to set IP address: $?" + exit 1 +fi +if ! update_iface_setting $gen_iface iface.ipaddress "$optaddr" ; then + echo "Failed to set IP address for generic interface: $?" + exit 1 +fi + +if ! update_iface_setting $ioe_iface iface.gateway "$ibft_gateway" ; then + echo "Failed to set gateway address: $?" + exit 1 +fi + +if ! update_iface_setting $gen_iface iface.gateway "$ibft_gateway" ; then + echo "Failed to set gateway address for generic interface: $?" + exit 1 +fi + +if ! update_iface_setting $ioe_iface iface.subnet_mask "$ibft_mask" ; then + echo "Failed to set subnet mask: $?" + exit 1 +fi + +if ! update_iface_setting $gen_iface iface.subnet_mask "$ibft_mask" ; then + echo "Failed to set subnet mask for generic interface: $?" + exit 1 +fi + +if [ "$mod" = "qla4xxx" ] ; then + iscsiadm -m iface -H $mac -o applyall +fi +ip link set dev $IFNAME up + +exit 0 + -- cgit v1.2.1