From: Hannes Reinecke <h...@suse.de>

Instead of having the IQN prefix hardcoded in the program
we should provide for a configuration setting 'IQNPrefix'.

Signed-off-by: Hannes Reinecke <h...@suse.de>
---
 utils/open-isns/config.c          |  4 ++++
 utils/open-isns/doc/isns_config.5 | 14 +++++++++++++-
 utils/open-isns/isns.h            |  1 +
 utils/open-isns/message.c         |  6 +++++-
 4 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/utils/open-isns/config.c b/utils/open-isns/config.c
index cc470a4779a7..731858854650 100644
--- a/utils/open-isns/config.c
+++ b/utils/open-isns/config.c
@@ -156,6 +156,10 @@ isns_config_set(const char *name, char *pos)
                if (!value)
                        goto no_value;
                isns_assign_string(&isns_config.ic_auth_name, value);
+       } else if (!strcasecmp(name, "IQNPrefix")) {
+               if (!value)
+                       goto no_value;
+               isns_assign_string(&isns_config.ic_iqn_prefix, value);
        } else if (!strcasecmp(name, "Database")) {
                if (!value)
                        goto no_value;
diff --git a/utils/open-isns/doc/isns_config.5 
b/utils/open-isns/doc/isns_config.5
index 5fbd26e8db38..c04b97ec3599 100644
--- a/utils/open-isns/doc/isns_config.5
+++ b/utils/open-isns/doc/isns_config.5
@@ -62,7 +62,19 @@ When using DSA authentication, Open-iSNS currently requires 
the source
 name to match the key identifier (SPI) of the client's public
 key.
 .IP
-If left empty, the source name is derived from the client's hostname.
+If left empty, the source name is derived from either from
+the client's hostname using the
+.BR IQNPrefix
+option to generate an iSCSI qualified name.
+.TP
+.BR IQNPrefix
+Specifies the iSCSI qualified name prefix; must be of the form
+.BR iqn.YYYY-MM
+with
+.BR YYYY
+being the year and
+.BR MM
+the month.
 .TP
 .BR ServerAddress " (client):
 This options specifies the host name or address of
diff --git a/utils/open-isns/isns.h b/utils/open-isns/isns.h
index 53c22d5c4089..7adc57e56ecb 100644
--- a/utils/open-isns/isns.h
+++ b/utils/open-isns/isns.h
@@ -556,6 +556,7 @@ struct isns_config {
        char *          ic_source_name;
        char *          ic_source_suffix;
        char *          ic_entity_name;
+       char *          ic_iqn_prefix;
 
        char *          ic_server_name;
        char *          ic_bind_address;
diff --git a/utils/open-isns/message.c b/utils/open-isns/message.c
index db67a2cc1e15..5fa09d57cc22 100644
--- a/utils/open-isns/message.c
+++ b/utils/open-isns/message.c
@@ -362,6 +362,9 @@ out:        isns_free(fqdn);
 int
 isns_init_names(void)
 {
+       if (isns_config.ic_iqn_prefix == NULL) {
+               isns_config.ic_iqn_prefix = DUMMY_IQN_PREFIX;
+       }
        if (isns_config.ic_host_name == NULL) {
                char    namebuf[1024], *fqdn;
 
@@ -391,7 +394,8 @@ isns_init_names(void)
        }
 
        if (isns_config.ic_source_name == NULL) {
-               isns_config.ic_source_name = __revert_fqdn(DUMMY_IQN_PREFIX,
+               isns_config.ic_source_name = __revert_fqdn(
+                               isns_config.ic_iqn_prefix,
                                isns_config.ic_host_name,
                                isns_config.ic_source_suffix);
                if (isns_config.ic_source_name == NULL) {
-- 
2.1.2

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to