Hello community,

here is the log from the commit of package target-isns for openSUSE:Factory 
checked in at 2018-06-19 12:04:13
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/target-isns (Old)
 and      /work/SRC/openSUSE:Factory/.target-isns.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "target-isns"

Tue Jun 19 12:04:13 2018 rev:7 rq:617250 version:0.6.4

Changes:
--------
--- /work/SRC/openSUSE:Factory/target-isns/target-isns.changes  2017-09-04 
12:33:36.674386250 +0200
+++ /work/SRC/openSUSE:Factory/.target-isns.new/target-isns.changes     
2018-06-19 12:04:17.056649089 +0200
@@ -1,0 +2,20 @@
+Sat Jun 16 00:44:32 UTC 2018 - [email protected]
+
+- Update to version 0.6.4:
+  * Update the GitHub URL to open-iscsi/target-isns
+  * Make configfs-iscsi-path configurable
+  * Generate multiple PDUs for large count target register message
+  * Update target-isns man page for configfs_iscsi_path
+  * Add Kyle Fortin to THANKS
+  * documentation: describe the registration period of Open-iSNS
+  * documentation: describe how to test target-isns with Open-iSNS
+  * Bump version to 0.6.4
+  * Add a changelog
+  - which replaces target-isns-0.6.3.tar.xz with
+    target-isns-0.6.4.tar.xz
+
+- Handle gcc8 compiler complaints by replacing pathname snprintf()
+  calls with asprintf(), adding patch:
+  * Replace-snprintf-with-asprintf-for-string-handling.patch
+
+-------------------------------------------------------------------

Old:
----
  target-isns-0.6.3.tar.xz

New:
----
  Replace-snprintf-with-asprintf-for-string-handling.patch
  target-isns-0.6.4.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ target-isns.spec ++++++
--- /var/tmp/diff_new_pack.I8j9sz/_old  2018-06-19 12:04:18.192606914 +0200
+++ /var/tmp/diff_new_pack.I8j9sz/_new  2018-06-19 12:04:18.196606766 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package target-isns
 #
-# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -20,9 +20,10 @@
 Summary:        Supplies iSNS support for Linux kernel target
 License:        GPL-2.0+
 Group:          System/Kernel
-Version:        0.6.3
+Version:        0.6.4
 Release:        0
 Source:         %{name}-%{version}.tar.xz
+Patch1:         Replace-snprintf-with-asprintf-for-string-handling.patch
 Url:            https://github.com/open-iscsi/target-isns
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 BuildRequires:  cmake
@@ -45,6 +46,7 @@
 
 %prep
 %setup -n %{name}-%{version}
+%patch1 -p1
 
 %build
 %cmake -DSUPPORT_SYSTEMD=ON

++++++ Replace-snprintf-with-asprintf-for-string-handling.patch ++++++
>From de826ee1bb14a2f48bf082017598e0816fffbbb8 Mon Sep 17 00:00:00 2001
From: Lee Duncan <[email protected]>
Date: Fri, 15 Jun 2018 17:29:30 -0700
Subject: [PATCH] Replace snprintf with asprintf for string handling

This also makes the gcc8 compiler happy, and avoids possible
problems with strings actually being truncated.
--- 
diff -aurp target-isns-0.6.4.orig/src/configfs.c 
target-isns-0.6.4/src/configfs.c
--- target-isns-0.6.4.orig/src/configfs.c       2018-01-20 12:23:46.000000000 
-0800
+++ target-isns-0.6.4/src/configfs.c    2018-06-15 18:07:26.541537030 -0700
@@ -31,6 +31,8 @@
  *   +-- $IQN N                         W   +-- target N
  */
 
+#define _GNU_SOURCE
+
 #include "configfs.h"
 
 #include <ccan/list/list.h>
@@ -115,12 +117,13 @@ static struct tpg *tpg_find_by_watch(con
 static struct target *configfs_target_init(const char *name)
 {
        struct target *tgt;
-       char path[512];
+       char *path;
 
        if ((tgt = malloc(sizeof(struct target))) == NULL)
                return NULL;
 
-       snprintf(path, sizeof(path), "%s/%s", config.configfs_iscsi_path, name);
+       if (asprintf(&path, "%s/%s", config.configfs_iscsi_path, name) < 0)
+               return NULL;
        strncpy(tgt->name, name, ISCSI_NAME_SIZE);
        tgt->name[ISCSI_NAME_SIZE - 1] = '\0';
        tgt->exists = false;
@@ -128,26 +131,33 @@ static struct target *configfs_target_in
        tgt->watch_fd = inotify_add_watch(inotify_fd, path, INOTIFY_MASK);
        list_head_init(&tgt->tpgs);
        list_add_tail(&targets, &tgt->node);
+       free(path);
 
        return tgt;
 }
 
 static bool configfs_tpg_enabled(const struct target *tgt, uint16_t tpg_tag)
 {
-       int fd;
+       int fd = -1;
        ssize_t nr;
-       char buf[8], path[512];
+       char buf[8];
+       char *path = NULL;
        bool enabled = false;
 
-       snprintf(path, sizeof(path),
-                "%s/%s/tpgt_%hu/enable",
-                config.configfs_iscsi_path, tgt->name, tpg_tag);
+       if (asprintf(&path, "%s/%s/tpgt_%hu/enable",
+                    config.configfs_iscsi_path, tgt->name, tpg_tag) < 0)
+               goto dun;
        if ((fd = open(path, O_RDONLY)) == -1)
-               return false;
+               goto dun;
        if ((nr = read(fd, buf, sizeof(buf))) != -1) {
                enabled = buf[0] == '1';
        }
-       close(fd);
+
+dun:
+       if (fd >= 0)
+               close(fd);
+       if (path)
+               free(path);
 
        return enabled;
 }
@@ -155,20 +165,32 @@ static bool configfs_tpg_enabled(const s
 static struct tpg *configfs_tpg_init(struct target *tgt, uint16_t tpg_tag)
 {
        struct tpg *tpg = malloc(sizeof(struct tpg));
-       char path[512];
-       char np_path[512];
+       char *path;
+       char *np_path;
 
-       snprintf(path, sizeof(path), "%s/%s/tpgt_%hu",
-                config.configfs_iscsi_path, tgt->name, tpg_tag);
-       snprintf(np_path, sizeof(np_path), "%s/np", path);
+       if (asprintf(&path, "%s/%s/tpgt_%hu",
+                    config.configfs_iscsi_path, tgt->name, tpg_tag) < 0)
+               goto err_out;
+       if (asprintf(&np_path, "%s/np", path) < 0)
+               goto err_out;
        tpg->watch_fd = inotify_add_watch(inotify_fd, path, INOTIFY_MASK);
        tpg->np_watch_fd = inotify_add_watch(inotify_fd, np_path, INOTIFY_MASK);
        tpg->tag = tpg_tag;
        tpg->enabled = configfs_tpg_enabled(tgt, tpg_tag);
        tpg->exists = false;
        list_add(&tgt->tpgs, &tpg->node);
+       free(path);
+       free(np_path);
 
        return tpg;
+
+err_out:
+       if (path)
+               free(path);
+       if (np_path)
+               free(np_path);
+       free(tpg);
+       return NULL;
 }
 
 static int get_portal(const char *str, int *af, char *ip_addr, uint16_t *port)
@@ -248,12 +270,14 @@ static int configfs_tpg_update(struct ta
 {
        DIR *np_dir;
        struct dirent *dirent;
-       char np_path[512];
+       char *np_path;
+
+       if (asprintf(&np_path, "%s/%s/tpgt_%hu/np",
+                    config.configfs_iscsi_path, tgt->name, tpg->tag) < 0)
+               return -ENOMEM;
 
-       snprintf(np_path, sizeof(np_path),
-                "%s/%s/tpgt_%hu/np",
-                config.configfs_iscsi_path, tgt->name, tpg->tag);
        np_dir = opendir(np_path);
+       free(np_path);
        if (!np_dir)
                return -ENOENT;
 
@@ -293,11 +317,13 @@ static int configfs_target_update(struct
        struct tpg *tpg, *tpg_next;
        struct tpg_portal *tpg_portal, *tpg_portal_next;
        uint16_t tpg_tag;
-       char tgt_path[512];
+       char *tgt_path;
 
-       snprintf(tgt_path, sizeof(tgt_path), "%s/%s",
-                config.configfs_iscsi_path, tgt->name);
+       if (asprintf(&tgt_path, "%s/%s",
+                   config.configfs_iscsi_path, tgt->name) < 0)
+               return -ENOMEM;
        tgt_dir = opendir(tgt_path);
+       free(tgt_path);
        if (!tgt_dir)
                return -ENOENT;
 
@@ -314,6 +340,8 @@ static int configfs_target_update(struct
 
                if (!tpg)
                        tpg = configfs_tpg_init(tgt, tpg_tag);
+               if (!tpg)
+                       return -ENOMEM;
                configfs_tpg_update(tgt, tpg);
                tpg->exists = true;
        }
@@ -366,6 +394,8 @@ int configfs_inotify_init(void)
                tgt = target_find(dirent->d_name);
                if (!tgt)
                        tgt = configfs_target_init(dirent->d_name);
+               if (!tgt)
+                       goto out;
                configfs_target_update(tgt);
        }
        closedir(iscsi_dir);
@@ -488,6 +518,8 @@ static void configfs_tpg_handle(const st
 
        if ((event->mask & IN_CREATE) && !tpg) {
                tpg = configfs_tpg_init(tgt, tpg_tag);
+               if (!tpg)
+                       return;
                configfs_tpg_update(tgt, tpg);
        } else if ((event->mask & IN_DELETE) && tpg) {
                list_del(&tpg->node);
++++++ _service ++++++
--- /var/tmp/diff_new_pack.I8j9sz/_old  2018-06-19 12:04:18.244604983 +0200
+++ /var/tmp/diff_new_pack.I8j9sz/_new  2018-06-19 12:04:18.248604835 +0200
@@ -4,8 +4,8 @@
     <param name="url">https://github.com/open-iscsi/target-isns.git</param>
     <param name="subdir"></param>
     <param name="filename">target-isns</param>
-    <param name="versionformat">0.6.3</param>
-    <param name="revision">v0.6.3</param>
+    <param name="versionformat">0.6.4</param>
+    <param name="revision">v0.6.4</param>
     <param name="changesgenerate">enable</param>
   </service>
   <service name="recompress" mode="disabled">

++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.I8j9sz/_old  2018-06-19 12:04:18.272603943 +0200
+++ /var/tmp/diff_new_pack.I8j9sz/_new  2018-06-19 12:04:18.272603943 +0200
@@ -1,4 +1,4 @@
 <servicedata>
 <service name="tar_scm">
             <param 
name="url">https://github.com/open-iscsi/target-isns.git</param>
-          <param 
name="changesrevision">4e8a1a761beb1e368a2bde47f5b9912800587170</param></service></servicedata>
+          <param 
name="changesrevision">498a8ffa4a0f584549fdf2175a2675a27fb9ce58</param></service></servicedata>
\ No newline at end of file

++++++ target-isns-0.6.3.tar.xz -> target-isns-0.6.4.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/target-isns-0.6.3/.gitignore 
new/target-isns-0.6.4/.gitignore
--- old/target-isns-0.6.3/.gitignore    2017-03-05 18:26:53.000000000 +0100
+++ new/target-isns-0.6.4/.gitignore    1970-01-01 01:00:00.000000000 +0100
@@ -1,6 +0,0 @@
-*.a
-*.c.o
-*.cmake
-*.make
-CMakeFiles/
-Makefile
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/target-isns-0.6.3/CHANGELOG.md 
new/target-isns-0.6.4/CHANGELOG.md
--- old/target-isns-0.6.3/CHANGELOG.md  1970-01-01 01:00:00.000000000 +0100
+++ new/target-isns-0.6.4/CHANGELOG.md  2018-01-20 21:23:46.000000000 +0100
@@ -0,0 +1,22 @@
+# Changelog
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
+and this project adheres to [Semantic 
Versioning](http://semver.org/spec/v2.0.0.html).
+
+## [Unreleased]
+
+## [0.6.4] - 2018-01-20
+### Fixed
+- Fix segfault caused by large PDUs by generating multiple PDUs for
+  large registration messages. Contributed by Kyle Fortin.
+
+### Added
+- Add the `--configfs-iscsi-path` option to exercise target-isns with
+  fake configfs hierarchies that emulate large iSCSI configurations.
+  Contributed by Kyle Fortin.
+- Add [how to test target-isns with Open-iSNS](documentation/testing.md)
+- Add a [changelog](CHANGELOG.md).
+
+
+## [0.6.3] - 2017-03-05
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/target-isns-0.6.3/CMakeLists.txt 
new/target-isns-0.6.4/CMakeLists.txt
--- old/target-isns-0.6.3/CMakeLists.txt        2017-03-05 18:26:53.000000000 
+0100
+++ new/target-isns-0.6.4/CMakeLists.txt        2018-01-20 21:23:46.000000000 
+0100
@@ -6,7 +6,7 @@
 #
 
 project(target-isns "C")
-set(TARGET_ISNS_VERSION "0.6.3")
+set(TARGET_ISNS_VERSION "0.6.4")
 
 cmake_minimum_required(VERSION 2.8)
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/target-isns-0.6.3/README.md 
new/target-isns-0.6.4/README.md
--- old/target-isns-0.6.3/README.md     2017-03-05 18:26:53.000000000 +0100
+++ new/target-isns-0.6.4/README.md     2018-01-20 21:23:46.000000000 +0100
@@ -60,6 +60,6 @@
 
 Contributions are welcomed!
 
- * Source repository: [GitHub](https://github.com/cvubrugier/target-isns)
- * Bug tracker: [GitHub](https://github.com/cvubrugier/target-isns/issues)
- * Tarballs: [GitHub](https://github.com/cvubrugier/target-isns/releases)
+ * Source repository: [GitHub](https://github.com/open-iscsi/target-isns)
+ * Bug tracker: [GitHub](https://github.com/open-iscsi/target-isns/issues)
+ * Tarballs: [GitHub](https://github.com/open-iscsi/target-isns/releases)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/target-isns-0.6.3/THANKS new/target-isns-0.6.4/THANKS
--- old/target-isns-0.6.3/THANKS        2017-03-05 18:26:53.000000000 +0100
+++ new/target-isns-0.6.4/THANKS        2018-01-20 21:23:46.000000000 +0100
@@ -2,6 +2,7 @@
 Andy Grover <agrover at redhat.com>
 Christophe Vu-Brugier <cvubrugier at fastmail.fm>
 Dan Walkes <danwalkes at trellis-logic.com>
+Kyle Fortin <kyle.fortin at oracle.com>
 Lee Duncan <lduncan at suse.com>
 Olaf Kirch <okir at suse.com>
 Victor Dodon <dodonvictor at gmail.com>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/target-isns-0.6.3/documentation/iSNS-servers.md 
new/target-isns-0.6.4/documentation/iSNS-servers.md
--- old/target-isns-0.6.3/documentation/iSNS-servers.md 2017-03-05 
18:26:53.000000000 +0100
+++ new/target-isns-0.6.4/documentation/iSNS-servers.md 2018-01-20 
21:23:46.000000000 +0100
@@ -3,8 +3,9 @@
 
 Target-isns is tested with the following iSNS servers:
 
- * Microsoft 2012 R2 iSNS server
- * OpenIndiana iSNS server
+* Open-iSNS
+* Microsoft 2012 R2 iSNS server
+* OpenIndiana iSNS server
 
 If you use another iSNS server, please tell us if target-isns works
 for you.
@@ -19,26 +20,30 @@
 For a description of the iSNS registration period please refer to
 section "6.2.6 Registration Period" of RFC 4171:
 
- * [RFC 4171, 6.2.6](http://tools.ietf.org/html/rfc4171#section-6.2.6)
+* [RFC 4171, 6.2.6](http://tools.ietf.org/html/rfc4171#section-6.2.6)
 
-The default registration period of the Microsoft iSNS server is 15
-minutes (900 seconds) whereas the default registration period of the
-OpenIndiana iSNS server is 1 day (86400 seconds).
+Default registration periods:
+
+* Open-iSNS: 10 minutes (set in isnsd.conf)
+* Microsoft iSNS server: 15 minutes
+* OpenIndiana iSNS server: 1 day
 
 Target-isns uses a registration period of 5 minutes (300 seconds). It
 sends this value to the iSNS server and it also queries the server
-registration period. We observe that the Microsoft iSNS server changes
-its registration period to use our value but it does not report its
-registration period to us. On the other hand, the OpenIndiana iSNS
-server changes its registration period only if it is greater than its
-default registration period. Moreover, the OpenIndiana iSNS server
-correctly reports the value of its registration period to target-isns.
-As a consequence, target-isns can update its registration period to
-use the same value as the server.
+registration period. We observe that Open-iSNS reports its
+registration period, allowing target-isns to use the same value. The
+Microsoft iSNS server changes its registration period to use our value
+but it does not report its registration period to us. On the other
+hand, the OpenIndiana iSNS server changes its registration period only
+if it is greater than its default registration period. Moreover, the
+OpenIndiana iSNS server correctly reports the value of its
+registration period to target-isns.  As a consequence, target-isns can
+update its registration period to use the same value as the server.
 
 Thus, target-isns uses the following registration periods depending on
 the iSNS server:
 
+* Open-iSNS: 10 minutes (Open-iSNS default value)
 * Microsoft iSNS server: 5 minutes (target-isns default value)
 * OpenIndiana iSNS server: 1 day (OpenIndiana default value)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/target-isns-0.6.3/documentation/testing.md 
new/target-isns-0.6.4/documentation/testing.md
--- old/target-isns-0.6.3/documentation/testing.md      1970-01-01 
01:00:00.000000000 +0100
+++ new/target-isns-0.6.4/documentation/testing.md      2018-01-20 
21:23:46.000000000 +0100
@@ -0,0 +1,53 @@
+Testing
+=======
+
+Testing target-isns with Open-iSNS
+----------------------------------
+
+The easiest way to test target-isns is to install Open-iSNS on the
+same machine.
+
+On a first terminal, start the iSNS daemon in foreground and enable
+all debugging facilities:
+
+    $ sudo /usr/sbin/isnsd --foreground --debug all
+
+Then, on a second terminal, start the iSNS client also in foreground
+and set the IP address of the iSNS server to localhost:
+
+    $ ./src/target-isns --isns-server 127.0.0.1 --debug
+    0.000000 I: target-isns version 0.6.3 started
+    0.000036 I: iSNS server is 127.0.0.1:3205
+
+The iSNS client should register your iSCSI targets to the iSNS server
+and keep them registered (i.e. refreshing their registration before
+the registration period expires). If you hit Ctrl + C, target-isns
+deregisters the iSCSI targets and exits.
+
+
+Testing with fake iSCSI configurations
+--------------------------------------
+
+By default, target-isns works by watching the iSCSI configfs directory
+that contains the configuration of the Linux kernel target's subsystem
+(also known as LIO). This configuration is visible under
+`/sys/kernel/config/target/iscsi`.
+
+For testing purposes, you can create a fake configfs hierarchy that
+look the same and ask target-isns to browse it. Below is a minimal
+fake configfs hierarchy that allows to register a single iSCSI target
+containing a single target portal group:
+
+    $ mkdir -p fake-iscsi-path/iqn.2018-01.org.example:disk1
+    $ mkdir -p fake-iscsi-path/iqn.2018-01.org.example:disk1/tpgt_1
+    $ mkdir -p fake-iscsi-path/iqn.2018-01.org.example:disk1/tpgt_1/np
+    $ mkdir -p 
fake-iscsi-path/iqn.2018-01.org.example:disk1/tpgt_1/np/0.0.0.0:3260
+    $ echo 1 > fake-iscsi-path/iqn.2018-01.org.example:disk1/tpgt_1/enable
+
+Then, you can start target-isns with the `--configfs-iscsi-path`
+option pointing to the fake configfs hierarchy:
+
+    $ ./src/target-isns --isns-server 127.0.0.1 --debug --configfs-iscsi-path 
fake-iscsi-path/
+
+With this method, you can emulate large iSCSI configurations with many
+iSCSI targets and target portal groups.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/target-isns-0.6.3/src/configfs.c 
new/target-isns-0.6.4/src/configfs.c
--- old/target-isns-0.6.3/src/configfs.c        2017-03-05 18:26:53.000000000 
+0100
+++ new/target-isns-0.6.4/src/configfs.c        2018-01-20 21:23:46.000000000 
+0100
@@ -47,8 +47,8 @@
 
 #include "isns.h"
 #include "log.h"
+#include "util.h"
 
-#define CONFIGFS_ISCSI_PATH    "/sys/kernel/config/target/iscsi"
 #define INOTIFY_MASK           (IN_CREATE | IN_DELETE | IN_MODIFY)
 #define INOTIFY_BUF_LEN                (16 * (sizeof(struct inotify_event) + 
NAME_MAX + 1))
 
@@ -69,7 +69,7 @@
 
 bool configfs_iscsi_path_exists(void)
 {
-       DIR *dir = opendir(CONFIGFS_ISCSI_PATH);
+       DIR *dir = opendir(config.configfs_iscsi_path);
 
        if (dir) {
                closedir(dir);
@@ -120,7 +120,7 @@
        if ((tgt = malloc(sizeof(struct target))) == NULL)
                return NULL;
 
-       snprintf(path, sizeof(path), CONFIGFS_ISCSI_PATH "/%s", name);
+       snprintf(path, sizeof(path), "%s/%s", config.configfs_iscsi_path, name);
        strncpy(tgt->name, name, ISCSI_NAME_SIZE);
        tgt->name[ISCSI_NAME_SIZE - 1] = '\0';
        tgt->exists = false;
@@ -140,8 +140,8 @@
        bool enabled = false;
 
        snprintf(path, sizeof(path),
-                CONFIGFS_ISCSI_PATH "/%s/tpgt_%hu/enable",
-                tgt->name, tpg_tag);
+                "%s/%s/tpgt_%hu/enable",
+                config.configfs_iscsi_path, tgt->name, tpg_tag);
        if ((fd = open(path, O_RDONLY)) == -1)
                return false;
        if ((nr = read(fd, buf, sizeof(buf))) != -1) {
@@ -158,8 +158,8 @@
        char path[512];
        char np_path[512];
 
-       snprintf(path, sizeof(path), CONFIGFS_ISCSI_PATH "/%s/tpgt_%hu",
-                tgt->name, tpg_tag);
+       snprintf(path, sizeof(path), "%s/%s/tpgt_%hu",
+                config.configfs_iscsi_path, tgt->name, tpg_tag);
        snprintf(np_path, sizeof(np_path), "%s/np", path);
        tpg->watch_fd = inotify_add_watch(inotify_fd, path, INOTIFY_MASK);
        tpg->np_watch_fd = inotify_add_watch(inotify_fd, np_path, INOTIFY_MASK);
@@ -251,8 +251,8 @@
        char np_path[512];
 
        snprintf(np_path, sizeof(np_path),
-                CONFIGFS_ISCSI_PATH "/%s/tpgt_%hu/np",
-                tgt->name, tpg->tag);
+                "%s/%s/tpgt_%hu/np",
+                config.configfs_iscsi_path, tgt->name, tpg->tag);
        np_dir = opendir(np_path);
        if (!np_dir)
                return -ENOENT;
@@ -295,7 +295,8 @@
        uint16_t tpg_tag;
        char tgt_path[512];
 
-       snprintf(tgt_path, sizeof(tgt_path), CONFIGFS_ISCSI_PATH "/%s", 
tgt->name);
+       snprintf(tgt_path, sizeof(tgt_path), "%s/%s",
+                config.configfs_iscsi_path, tgt->name);
        tgt_dir = opendir(tgt_path);
        if (!tgt_dir)
                return -ENOENT;
@@ -346,10 +347,11 @@
        if ((inotify_fd = inotify_init()) == -1)
                return -1;
 
-       if (inotify_add_watch(inotify_fd, CONFIGFS_ISCSI_PATH, INOTIFY_MASK) == 
-1)
+       if (inotify_add_watch(inotify_fd, config.configfs_iscsi_path,
+                             INOTIFY_MASK) == -1)
                goto out;
 
-       iscsi_dir = opendir(CONFIGFS_ISCSI_PATH);
+       iscsi_dir = opendir(config.configfs_iscsi_path);
        if (!iscsi_dir)
                goto out;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/target-isns-0.6.3/src/configfs.h 
new/target-isns-0.6.4/src/configfs.h
--- old/target-isns-0.6.3/src/configfs.h        2017-03-05 18:26:53.000000000 
+0100
+++ new/target-isns-0.6.4/src/configfs.h        2018-01-20 21:23:46.000000000 
+0100
@@ -41,6 +41,7 @@
 };
 
 #define ALL_TARGETS ((struct target*) 1)
+#define CONFIGFS_ISCSI_PATH    "/sys/kernel/config/target/iscsi"
 
 bool configfs_iscsi_path_exists(void);
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/target-isns-0.6.3/src/isns.c 
new/target-isns-0.6.4/src/isns.c
--- old/target-isns-0.6.3/src/isns.c    2017-03-05 18:26:53.000000000 +0100
+++ new/target-isns-0.6.4/src/isns.c    2018-01-20 21:23:46.000000000 +0100
@@ -151,13 +151,12 @@
        return query;
 }
 
-static struct isns_query *isns_query_pop(uint16_t transaction)
+static struct isns_query *isns_query_find(uint16_t transaction)
 {
        struct isns_query *query, *query_next;
 
        list_for_each_safe(&query_list, query, query_next, node) {
                if (query->transaction == transaction) {
-                       list_del(&query->node);
                        return query;
                }
        }
@@ -165,6 +164,19 @@
        return NULL;
 }
 
+static struct isns_query *isns_query_pop(uint16_t transaction)
+{
+       struct isns_query *query;
+
+       query = isns_query_find(transaction);
+       if (query != NULL) {
+               list_del(&query->node);
+               return query;
+       }
+
+       return NULL;
+}
+
 static int isns_connect(void)
 {
        int fd, err;
@@ -470,10 +482,59 @@
        }
 }
 
+#define TGT_REG_BUFSIZE                8192
+#define TGT_REG_BUFTHRESH      (TGT_REG_BUFSIZE - 256)
+/*
+ * isns_target_register_flush - flush PDU to isns server if necessary.
+ *
+ * Send target register PDU once buffer threshold exceeded and reset
+ * buffer to build the next continuation PDU.
+ *
+ * Returns length flushed or < 0 for error.
+ */
+static int isns_target_register_flush(struct isns_tlv **tlv, char *buf,
+               size_t bufsize, uint16_t *length, uint16_t *flags,
+               uint16_t *sequence)
+{
+       struct isns_hdr *hdr = (struct isns_hdr *) buf;
+       int err;
+
+       if (*length < TGT_REG_BUFTHRESH)
+               return 0;
+       isns_hdr_init(hdr, ISNS_FUNC_DEV_ATTR_REG, *length, *flags,
+                     transaction, *sequence);
+       log_print(LOG_DEBUG, "flushing seq %u, length %d", *sequence, *length);
+       err = write(isns_fd, buf, *length + sizeof(struct isns_hdr));
+       if (err < 0)
+               log_print(LOG_ERR, "%s %d: %s", __func__, __LINE__,
+                         strerror(errno));
+       *flags &= ~ISNS_FLAG_FIRST_PDU;
+       (*sequence)++;
+       memset(buf, 0, bufsize);
+       *tlv = (struct isns_tlv *) hdr->pdu;
+       *length = 0;
+       return err;
+}
+
+/*
+ * isns_target_register - build / send PDU(s) to register target(s).
+ *
+ * An unknown amount of target groups and portals could be sent for
+ * registration to the isns server.  The open-isns server can only
+ * handle messages of up to 8192 bytes.  Anything larger needs to be
+ * broken into multiple PDUs with proper use of ISNS_FLAG_FIRST_PDU
+ * and ISNS_FLAG_LAST_PDU flags, the same transaction id and an
+ * incrementing PDU sequence number.
+ *
+ * For each attribute appended to the message buffer, once a threshold
+ * is crossed, send it over the socket, clear the buffer, and build the
+ * continuation PDUs until completes.
+ */
 static int isns_target_register(const struct target *target)
 {
-       char buf[4096];
-       uint16_t flags = 0, length = 0;
+       char buf[TGT_REG_BUFSIZE];
+       uint16_t flags = ISNS_FLAG_CLIENT | ISNS_FLAG_FIRST_PDU, length = 0;
+       uint16_t sequence = 0;
        struct isns_hdr *hdr = (struct isns_hdr *) buf;
        struct isns_tlv *tlv;
        struct target *tgt;
@@ -528,8 +589,11 @@
                uint8_t ip_addr[16];
                isns_ip_addr_set(portal, ip_addr);
 
-               length += isns_tlv_set(&tlv, ISNS_ATTR_PORTAL_IP_ADDRESS, 16, 
ip_addr);
+               length += isns_tlv_set(&tlv, ISNS_ATTR_PORTAL_IP_ADDRESS, 16,
+                                      ip_addr);
                length += isns_tlv_set(&tlv, ISNS_ATTR_PORTAL_PORT, 4, &port);
+               isns_target_register_flush(&tlv, &buf[0], sizeof(buf),
+                                          &length, &flags, &sequence);
        }
 
        list_for_each(&targets, tgt, node) {
@@ -541,13 +605,17 @@
                                              tgt->name);
                length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NODE_TYPE,
                                       sizeof(node), &node);
+               isns_target_register_flush(&tlv, &buf[0], sizeof(buf),
+                                          &length, &flags, &sequence);
 
                /* Register the TPGs. */
                list_for_each(&tgt->tpgs, tpg, node) {
                        uint32_t tag = htonl(tpg->tag);
 
-                       length += isns_tlv_set_string(&tlv, 
ISNS_ATTR_PG_ISCSI_NAME,
-                                                     tgt->name);
+                       length += isns_tlv_set_string(&tlv,
+                                       ISNS_ATTR_PG_ISCSI_NAME, tgt->name);
+                       isns_target_register_flush(&tlv, &buf[0], sizeof(buf),
+                                       &length, &flags, &sequence);
 
                        list_for_each(&portals, portal, node) {
                                if (!tpg_has_portal(tpg, portal))
@@ -557,20 +625,29 @@
                                uint8_t ip_addr[16];
                                isns_ip_addr_set(portal, ip_addr);
 
-                               length += isns_tlv_set(&tlv, 
ISNS_ATTR_PG_PORTAL_IP_ADDRESS,
-                                                      sizeof(ip_addr), 
&ip_addr);
-                               length += isns_tlv_set(&tlv, 
ISNS_ATTR_PG_PORTAL_PORT,
-                                                      sizeof(port), &port);
+                               length += isns_tlv_set(&tlv,
+                                               ISNS_ATTR_PG_PORTAL_IP_ADDRESS,
+                                               sizeof(ip_addr), &ip_addr);
+                               length += isns_tlv_set(&tlv,
+                                               ISNS_ATTR_PG_PORTAL_PORT,
+                                               sizeof(port), &port);
+                               isns_target_register_flush(&tlv, &buf[0],
+                                       sizeof(buf), &length, &flags,
+                                       &sequence);
                        }
                        length += isns_tlv_set(&tlv, ISNS_ATTR_PG_TAG,
                                               sizeof(tag), &tag);
+                       isns_target_register_flush(&tlv, &buf[0], sizeof(buf),
+                                                  &length, &flags, &sequence);
                }
        }
 
-       flags |= ISNS_FLAG_CLIENT | ISNS_FLAG_LAST_PDU | ISNS_FLAG_FIRST_PDU;
+       flags |= ISNS_FLAG_LAST_PDU;
        isns_hdr_init(hdr, ISNS_FUNC_DEV_ATTR_REG, length, flags,
-                     transaction, 0);
+                     transaction, sequence);
 
+       log_print(LOG_DEBUG, "sending last PDU seq %u, length %d",
+                 sequence, length);
        err = write(isns_fd, buf, length + sizeof(struct isns_hdr));
        if (err < 0)
                log_print(LOG_ERR, "%s %d: %s", __func__, __LINE__, 
strerror(errno));
@@ -791,24 +868,33 @@
 {
        struct isns_tlv *tlv;
        uint16_t length = ntohs(hdr->length);
+       uint16_t flags = ntohs(hdr->flags);
        uint16_t transaction = ntohs(hdr->transaction);
-       uint32_t status = ntohl(hdr->pdu[0]);
+       uint32_t status;
        struct isns_query *query;
        char *name = NULL;
        uint8_t ip_addr[16];
        uint32_t port;
        uint32_t period;
 
-       query = isns_query_pop(transaction);
+       /* Only pop the query from the list if the last PDU is received. */
+       if (flags & ISNS_FLAG_LAST_PDU)
+               query = isns_query_pop(transaction);
+       else
+               query = isns_query_find(transaction);
        if (!query) {
                log_print(LOG_ERR, "unknown transaction %u", transaction);
                return;
        }
 
-       if (status) {
-               log_print(LOG_ERR, "error in response (status = %" PRIu32 ")",
-                         status);
-               goto free_query;
+       if (flags & ISNS_FLAG_FIRST_PDU) {
+               status = ntohl(hdr->pdu[0]);
+               if (status) {
+                       log_print(LOG_ERR,
+                               "error in response (status = %" PRIu32 ")",
+                               status);
+                       goto free_query;
+               }
        }
 
        if (query->name[0] == '\0') {
@@ -823,13 +909,17 @@
                goto free_query;
        }
 
-       /* skip status */
-       tlv = (struct isns_tlv *) ((char *) hdr->pdu + 4);
-
-       if (length < 4)
-               goto free_query;
-
-       length -= 4;
+       /* Skip status on the first PDU. */
+       if (flags & ISNS_FLAG_FIRST_PDU) {
+               tlv = (struct isns_tlv *) ((char *) hdr->pdu + 4);
+
+               if (length < 4)
+                       goto free_query;
+
+               length -= 4;
+       } else {
+               tlv = (struct isns_tlv *)hdr->pdu;
+       }
 
        while (length) {
                uint32_t tag = ntohl(tlv->tag);
@@ -898,7 +988,8 @@
        }
 
 free_query:
-       free(query);
+       if (flags & ISNS_FLAG_LAST_PDU)
+               free(query);
 }
 
 int isns_handle(void)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/target-isns-0.6.3/src/target-isns.c 
new/target-isns-0.6.4/src/target-isns.c
--- old/target-isns-0.6.3/src/target-isns.c     2017-03-05 18:26:53.000000000 
+0100
+++ new/target-isns-0.6.4/src/target-isns.c     2018-01-20 21:23:46.000000000 
+0100
@@ -44,12 +44,13 @@
 static void print_usage(void)
 {
        printf("Usage: " PROGNAME " [OPTIONS]\n"
-              "  -i, --isns-server  Set the IP address of the iSNS server.\n"
-              "  -p, --isns-port    Set the remote port for iSNS server.\n"
-              "  -d, --debug        Increase the debugging level (implies 
-f).\n"
-              "  -f, --foreground   Run in the foreground.\n"
-              "  -v, --version      Print version information.\n"
-              "  -h, --help         Print this message.\n");
+              "  -i, --isns-server          Set the IP address of the iSNS 
server.\n"
+              "  -p, --isns-port            Set the remote port for iSNS 
server.\n"
+              "  -d, --debug                Increase the debugging level 
(implies -f).\n"
+              "  -f, --foreground           Run in the foreground.\n"
+              "  -s, --configfs-iscsi-path  Use alternate sys configfs iscsi 
path.\n"
+              "  -v, --version              Print version information.\n"
+              "  -h, --help                 Print this message.\n");
 }
 
 static void epoll_init_fds(void)
@@ -113,15 +114,16 @@
 
 int main(int argc, char *argv[])
 {
-       char optstring[] = "i:p:dfvh";
+       char optstring[] = "i:p:dfs:vh";
        struct option longopts[] = {
-               {"isns-server", 1, NULL, 'i'},
-               {"isns-port",   1, NULL, 'p'},
-               {"debug",       0, NULL, 'd'},
-               {"foreground",  0, NULL, 'f'},
-               {"version",     0, NULL, 'v'},
-               {"help",        0, NULL, 'h'},
-               {NULL,          0, NULL, 0}
+               {"isns-server",         1, NULL, 'i'},
+               {"isns-port",           1, NULL, 'p'},
+               {"debug",               0, NULL, 'd'},
+               {"foreground",          0, NULL, 'f'},
+               {"configfs-iscsi-path", 1, NULL, 's'},
+               {"version",             0, NULL, 'v'},
+               {"help",                0, NULL, 'h'},
+               {NULL,                  0, NULL, 0}
         };
        int option;
        int longindex = 0;
@@ -130,6 +132,7 @@
        ssize_t nr_events;
        bool daemon = true;
        int ret = EXIT_FAILURE;
+       size_t configsz;
 
        conffile_read();
 
@@ -137,10 +140,9 @@
                                     &longindex)) != -1) {
                switch (option) {
                case 'i':
-                       ;
-                       const size_t sz = sizeof(config.isns_server);
-                       strncpy(config.isns_server, optarg, sz);
-                       config.isns_server[sz - 1] = '\0';
+                       configsz = sizeof(config.isns_server);
+                       strncpy(config.isns_server, optarg, configsz);
+                       config.isns_server[configsz - 1] = '\0';
                        break;
                case 'p':
                        sscanf(optarg, "%hu", &config.isns_port);
@@ -152,6 +154,11 @@
                case 'f':
                        daemon = false;
                        break;
+               case 's':
+                       configsz = sizeof(config.configfs_iscsi_path);
+                       strncpy(config.configfs_iscsi_path, optarg, configsz);
+                       config.configfs_iscsi_path[configsz - 1] = '\0';
+                       break;
                case 'v':
                        printf(PROGNAME " version " TARGET_ISNS_VERSION "\n");
                        exit(EXIT_SUCCESS);
@@ -171,6 +178,9 @@
                fprintf(stderr,
                        "Error: configfs is not mounted or the "
                        "target and iSCSI modules are not loaded.\n");
+               fprintf(stderr,
+                       "Error: %s missing.\n",
+                       config.configfs_iscsi_path);
                exit(EXIT_FAILURE);
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/target-isns-0.6.3/src/util.c 
new/target-isns-0.6.4/src/util.c
--- old/target-isns-0.6.3/src/util.c    2017-03-05 18:26:53.000000000 +0100
+++ new/target-isns-0.6.4/src/util.c    2018-01-20 21:23:46.000000000 +0100
@@ -13,6 +13,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include "configfs.h"
 
 #define PIDFILE                "/run/target-isns.pid"
 #define CONFFILE       "/etc/target-isns.conf"
@@ -42,6 +43,7 @@
        memset(&config, 0, sizeof(config));
        config.log_level = LOG_INFO;
        config.isns_port = ISNS_PORT;
+       strcpy(config.configfs_iscsi_path, CONFIGFS_ISCSI_PATH);
 
        if ((file = fopen(CONFFILE, "r")) == NULL) {
                log_print(LOG_ERR, "Could not read " CONFFILE);
@@ -98,6 +100,11 @@
                                config.log_level = LOG_INFO;
                        else if (streq(value, "debug"))
                                config.log_level = LOG_DEBUG;
+               } else if (streq(key, "configfs_iscsi_path")) {
+                       const size_t sz = sizeof(config.configfs_iscsi_path);
+
+                       strncpy(config.configfs_iscsi_path, value, sz);
+                       config.configfs_iscsi_path[sz - 1] = '\0';
                }
        }
        fclose(file);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/target-isns-0.6.3/src/util.h 
new/target-isns-0.6.4/src/util.h
--- old/target-isns-0.6.3/src/util.h    2017-03-05 18:26:53.000000000 +0100
+++ new/target-isns-0.6.4/src/util.h    2018-01-20 21:23:46.000000000 +0100
@@ -13,6 +13,7 @@
        char isns_server[64];
        uint16_t isns_port;
        int log_level;
+       char configfs_iscsi_path[256];
 } config;
 
 void pidfile_create(void);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/target-isns-0.6.3/target-isns.8 
new/target-isns-0.6.4/target-isns.8
--- old/target-isns-0.6.3/target-isns.8 2017-03-05 18:26:53.000000000 +0100
+++ new/target-isns-0.6.4/target-isns.8 2018-01-20 21:23:46.000000000 +0100
@@ -27,6 +27,9 @@
 \fB\-f\fR, \fB\-\-foreground\fR
 run in the foreground
 .TP
+\fB\-s\fR, \fB\-\-configfs-iscsi-path\fR=\fI\/PATH\/\fR
+use alternate sys configfs iscsi path
+.TP
 \fB\-v\fR, \fB\-\-version\fR
 print version information and exit
 .TP
@@ -46,11 +49,14 @@
 .TP
 \fB\/log_level\fR=[\fI\/info\fR\/|\fI\/debug\fR]
 set the log level (default is info)
+.TP
+\fB\/configfs_iscsi_path\fR=\fI\/PATH\fR
+set the configfs path for iscsi (default is /sys/kernel/config/target/iscsi)
 .SH
 BUGS
 .PP
 Please send bug reports to the upstream bug tracker at
-\fBhttps://github.com/cvubrugier/target-isns/issues\fR.
+\fBhttps://github.com/open-iscsi/target-isns/issues\fR.
 .SH
 SEE ALSO
 .PP
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/target-isns-0.6.3/target-isns.conf 
new/target-isns-0.6.4/target-isns.conf
--- old/target-isns-0.6.3/target-isns.conf      2017-03-05 18:26:53.000000000 
+0100
+++ new/target-isns-0.6.4/target-isns.conf      2018-01-20 21:23:46.000000000 
+0100
@@ -11,3 +11,6 @@
 # Log verbosity: info, debug.
 # This parameter is optional.
 # log_level = info
+
+# Configfs path for iscsi.
+# configfs_iscsi_path = /sys/kernel/config/target/iscsi
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/target-isns-0.6.3/target-isns.spec 
new/target-isns-0.6.4/target-isns.spec
--- old/target-isns-0.6.3/target-isns.spec      2017-03-05 18:26:53.000000000 
+0100
+++ new/target-isns-0.6.4/target-isns.spec      2018-01-20 21:23:46.000000000 
+0100
@@ -6,7 +6,7 @@
 License:    GPLv2+
 ExclusiveOS: linux
 Group:      System Environment/Kernel
-URL:        https://github.com/cvubrugier/target-isns
+URL:        https://github.com/open-iscsi/target-isns
 BuildRoot:  %{_tmppath}/%{name}-%{version}-build
 BuildRequires: gcc flex glibc-devel make
 BuildRequires: cmake


Reply via email to