On 02/19/2011 05:45 AM, Mike Christie wrote: > On 02/18/2011 08:59 PM, Dr. Ed Morbius wrote: >> Trying to set up a number of initiators on CentOS 5.5 with a Dell >> MD32xxi target. >> >> I've successfully configured several other identical initiators with >> these targets. >> >> $ export DP=<dataport IP> >> $ sudo iscsiadm -m discoverydb -t sendtargets -p $DP:3260 >> iscsiadm: Discovery record [$DP,3260] not found. >> > >> I've got records in /var/lib/iscsi/ifaces, but no other /var/lib/iscsi/ >> subdirectories. > > Have you done discovery to that address,port or done a -o new to create > a db discovery record for it? If not then that is what you would expect. > > You can do > > > sudo iscsiadm -m discoverydb -t sendtargets -p $DP:3260 -D > > without the -D, then iscsiadm is just looking for the discovery record > for that discovery address,port. > > To have iscsiadm try to do discovery pass it the -D argument or do the > old style > > iscsiadm -m discovery -t st -p ip:port > (no db in the discovery mode name). > I have just stumbled upon this issue, too.
And found it pretty awkward to use; after all, to all intents and purposes the hostname and the IP-address can be used interchangeably. I (and our QA :-( ) don't see a reason why should draw a blank here. So after long hours of debugging I came up with this patch, which resolves the hostname into the IP address and uses this for lookup. Mike, comments? Cheers, Hannes -- Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Markus Rex, HRB 16746 (AG Nürnberg) -- You received this message because you are subscribed to the Google Groups "open-iscsi" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.
From: Hannes Reinecke <[email protected]> Date: Wed, 23 Feb 2011 10:06:50 +0100 Subject: [PATCH] iscsiadm: fixup discovery records display Sendtargets discovery is using the passed in address to lookup the existing records in the database. However, as this can either be the hostname or the IP address it is getting confused and won't find existing records when called with the other address. So we should be resolving the hostname into the IP address when looking up records in the database. Signed-off-by: Hannes Reinecke <[email protected]> diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c index 1478c7b..6fe4151 100644 --- a/usr/iscsiadm.c +++ b/usr/iscsiadm.c @@ -2371,7 +2371,8 @@ main(int argc, char **argv) memset(&drec, 0, sizeof(discovery_rec_t)); idbm_sendtargets_defaults(db, &drec.u.sendtargets); - strncpy(drec.address, ip, sizeof(drec.address)); + if (address_to_ip(ip, drec.address) < 0) + strncpy(drec.address, ip, sizeof(drec.address)); drec.port = port; if (do_sendtargets(db, &drec, &ifaces, info_level, diff --git a/usr/util.c b/usr/util.c index 8e74dfd..9f7aeed 100644 --- a/usr/util.c +++ b/usr/util.c @@ -7,6 +7,8 @@ #include <sys/un.h> #include <sys/time.h> #include <sys/resource.h> +#include <arpa/inet.h> +#include <netdb.h> #include "log.h" #include "actor.h" @@ -88,6 +90,34 @@ str_to_ipport(char *str, int *port, int *tpgt) return ip; } +int address_to_ip(char *address, char *ipaddr) +{ + int ret; + struct addrinfo *ai_list, *aip; + struct sockaddr_in *sinp; + const char *addrp = NULL; + + if ((ret = getaddrinfo (address, NULL, + NULL, &ai_list)) != 0) { + log_warning("getaddrinfo for %s failed: %s", + address, gai_strerror(ret)); + return -EINVAL; + } + for (aip = ai_list; aip != NULL; aip = aip->ai_next) { + if (aip->ai_family == AF_INET) { + sinp = (struct sockaddr_in *)aip->ai_addr; + addrp = inet_ntop(aip->ai_family, + &sinp->sin_addr, + ipaddr, INET_ADDRSTRLEN); + if (addrp) + return 0; + } + } + /* Fallback if we couldn't resolve the address */ + log_debug(5, "Couldn't resolve address %s", address); + return -EADDRNOTAVAIL; +} + #define ISCSI_MAX_FILES 16384 int increase_max_files(void) diff --git a/usr/util.h b/usr/util.h index 9176ca9..21d1279 100644 --- a/usr/util.h +++ b/usr/util.h @@ -20,6 +20,7 @@ extern int iscsid_response(int fd, int cmd, struct iscsiadm_rsp *rsp); extern char *str_to_ipport(char *str, int *port, int *tgpt); extern void idbm_node_setup_defaults(struct node_rec *rec); +extern int address_to_ip(char *address, char *ipaddr); extern int iscsi_match_session(void *data, struct session_info *info); extern int __iscsi_match_session(struct node_rec *rec, char *targetname,
