On 04/06/2015 12:23 PM, Thomas Dwyer III wrote:
> I wasn't able to find any change you may have made earlier related to
It was a change to iscsid restart/boot. For the bind by netdev/mac you
do not have to have a record setup when restarting iscsid. For bind by
IP you currently do.
Could you run a quick test?
Could you login like normal, then kill iscsid
killall iscsid
then restart it by hand
/sbin/iscsid
and could you then check that we are still bound to the proper ip. The
iscsid restart will force a reconnecting of the socket/connection. I
want to double check that when we reconnect it is working like you
wanted. Code looks ok, but I want to make sure.
> this issue. I was surprised, however, to learn that discovery & login
> apparently use the same codepath (albeit in two different processes,
> iscsiadm & iscsid) for creating sockets. The call to
> setsockopt(SO_BINDTODEVICE) applies in both cases, contrary to the
> portion of the README (section 5.1.3) that says:
>
> "Be aware that iscsiadm will use the default route to do discovery. It
> will not use the iface specified."
Yeah, we added that support when we added offload discovery, but forgot
to update the README.
I attached what should hopefully be the final patch. I merged your
patch, added some documentation, cleaned up old info, and cleaned up
some related code.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.
diff --git a/README b/README
index 06d1b6f..8c42533 100644
--- a/README
+++ b/README
@@ -446,9 +446,9 @@ Usage: iscsiadm [OPTION]
=====================
The next sections describe how to setup iSCSI ifaces so you can bind
-a session to a NIC port when using software iscsi (section 5.1.1), and
-it describes how to setup ifaces for use with offload cards from Chelsio
-and Broadcm (section 5.1.2).
+a session to a NIC port or IP address when using software iSCSI, and it
+describes how to setup ifaces for use with offload cards from Chelsio, Emulex,
+Broadcom, and Qlogic (section 5.1.2).
5.1.1 How to setup iSCSI interfaces (iface) for binding
@@ -480,7 +480,8 @@ a scsi_host per HBA port).
To manage both types of initiator stacks, iscsiadm uses the interface (iface)
structure. For each HBA port or for software iscsi for each network
device (ethX) or NIC, that you wish to bind sessions to you must create
-a iface config /etc/iscsi/ifaces.
+a iface config. Running the iscsiadm iface commands in this section will
+create the required configuration file in /etc/iscsi/ifaces.
Prep:
@@ -527,26 +528,20 @@ For each network object you wish to bind a session to you must create
a seperate iface config in /etc/iscsi/ifaces and each iface config file
must have a unique name which is less than or equal to 64 characters.
-Example:
-
-If you have NIC1 with MAC address 00:0F:1F:92:6B:BF and NIC2 with
-MAC address 00:C0:DD:08:63:E7 and you wanted to do software iscsi over
-TCP/IP. Then in /etc/iscsi/ifaces/iface0 you would enter:
-
-iface.transport_name = tcp
-iface.hwaddress = 00:0F:1F:92:6B:BF
-
-and in /etc/iscsi/ifaces/iface1 you would enter:
-
-iface.transport_name = tcp
-iface.hwaddress = 00:C0:DD:08:63:E7
+iscsiadm setup examples:
+------------------------
Warning: Do not name a iface config file "default" or "iser".
They are special value/file that is used by the iscsi tools for
backward compatibility. If you name a iface default or iser, then
the behavior is not defined.
-To use iscsiadm to create iface0 above for you run:
+
+Bind by MAC example:
+--------------------
+If you have a NIC with MAC address 00:0F:1F:92:6B:BF and want to bind iSCSI
+sessions/connections to the network device with that MAC run the following
+commands:
(This will create a new empty iface config. If there was already a iface
with the name "iface0" this command will overwrite it.)
@@ -555,10 +550,51 @@ with the name "iface0" this command will overwrite it.)
(This will set the hwaddress.)
# iscsiadm -m iface -I iface0 --op=update -n iface.hwaddress -v 00:0F:1F:92:6B:BF
+
+Bind by network device name example:
+------------------------------------
+Instead of specifying the MAC address, the network deice name (eth0, eth1.1,
+enp0s25, etc) may be used. To do this, set the iface.net_ifacename with
+the following commands:
+
+(This will create a new empty iface config. If there was already a iface
+with the name "iface0" this command will overwrite it.)
+# iscsiadm -m iface -I iface0 --op=new
+
+(This will set the network device name.)
+# iscsiadm -m iface -I iface0 --op=update -n iface.net_ifacename -v eth1.1
+
+
+
+Bind by IP address example:
+---------------------------
+[This feature requires a 2.6.27 or newer kernel]
+
+If you have NIC with multiple IP addresses you may wish to bind a iSCSI
+session/connection to a specific IP on that NIC. To do this, set the
+iface.ipaddress with the following commands:
+
+(This will create a new empty iface config. If there was already a iface
+with the name "iface0" this command will overwrite it.)
+# iscsiadm -m iface -I iface0 --op=new
+
+(This will set the IP address.)
+# iscsiadm -m iface -I iface0 --op=update -n iface.ipaddress -v 192.168.56.110
+
+
+**************************
+
+If the iSCSI iface hwaddress/net_ifacename and IP address are both set then
+the initiator will bind the session to both the matching network device and
+the specified IP address on that device.
+
+
+********** NOTE **********
If you had sessions logged in iscsiadm will not update, overwrite
a iface. You must log out first. If you have a iface bound to a node/portal
but you have not logged in then, iscsiadm will update the config and
all existing bindings.
+**************************
You should now skip to 5.1.3 to see how to log in using the iface and for
@@ -569,11 +605,11 @@ some helpful management commands.
5.1.2 Setting up a iface for a iSCSI offload card
=================================================
-This section describes how to setup ifaces for use with Chelsio, Broadcom and
-QLogic cards.
+This section describes how to setup ifaces for use with Chelsio (cxgb3i/cxgb4i),
+Broadcom (now Qlogic) (bnx2i), Emulex (be2iscsi) and QLogic (qla2xxx) cards.
-By default, iscsiadm will create a iface for each Broadcom, QLogic and Chelsio
-port. The iface name will be of the form:
+By default, iscsiadm will create a iface for each Broadcom, QLogic, Emulex and
+Chelsio port. The iface name will be of the form:
$transport/driver_name.$MAC_ADDRESS
@@ -666,10 +702,9 @@ next section.
5.1.3 Discoverying iSCSI targets/portals
========================================
-Be aware that iscsiadm will use the default route to do discovery. It will
-not use the iface specified. So if you are using a offload card, you will
-need a seperate network connection to the target for discovery purposes.
-*This will be fixed in the next version of open-iscsi*
+By default, iscsiadm will use the default route when doing discovery.
+If a iface is passed in, then it will use that info to bind the discovery
+session to a network device, ip or offload card port.
For compatibility reasons, when you run iscsiadm to do discovery, it
will check for interfaces in /etc/iscsi/iscsi/ifaces that are using
diff --git a/usr/iface.c b/usr/iface.c
index 0a7f0bb..722ac8f 100644
--- a/usr/iface.c
+++ b/usr/iface.c
@@ -372,6 +372,11 @@ struct iface_search {
struct iface_rec *found;
};
+/*
+ * We do not match based on ip address binding because it was added
+ * after the ifacename kernel addition and is only supported with
+ * 2.6.27 and newer.
+ */
static int __iface_get_by_net_binding(void *data, struct iface_rec *iface)
{
struct iface_search *search = data;
@@ -398,15 +403,6 @@ static int __iface_get_by_net_binding(void *data, struct iface_rec *iface)
return 0;
}
-/*
- if (iface_is_bound_by_ipaddr(search->pattern)) {
- if (!strcmp(iface->ipaddress, search->pattern->ipaddress)) {
- iface_copy(search->found, iface);
- return 1;
- } else
- return 0;
- }
-*/
return 0;
}
@@ -414,7 +410,7 @@ static int __iface_get_by_net_binding(void *data, struct iface_rec *iface)
* Before 2.0.870, we only could bind by netdeivce or hwaddress,
* so we did a simple reverse lookup to go from sysfs info to
* the iface name. After 2.0.870 we added a lot of options to the
- * iface binding so we added the ifacename to the kernel.
+ * iface binding so we added the ifacename to the kernel in 2.6.27.
*
* This function is for older kernels that do not export the ifacename.
* If the user was doing iscsi_tcp session binding we will find
@@ -721,15 +717,7 @@ int iface_is_valid(struct iface_rec *iface)
if (!strlen(iface->transport_name))
return 0;
- if (iface_is_bound_by_hwaddr(iface))
- return 1;
-
- if (iface_is_bound_by_netdev(iface))
- return 1;
-// if (iface_is_bound_by_ipaddr(iface))
-// return 1;
-
- /* bound by transport name */
+ /* bound by transport name, hwaddr, netdev or ipaddr */
return 1;
}
diff --git a/usr/io.c b/usr/io.c
index f552e1e..42948da 100644
--- a/usr/io.c
+++ b/usr/io.c
@@ -159,21 +159,13 @@ free_ifap:
#endif
-#if 0
-
-This is not supported for now, because it is not exactly what we want.
-It also turns out that targets will send packets to other interfaces
-causing all types of weird things to happen.
-
-
static int bind_src_by_address(int sockfd, char *address)
{
int rc = 0;
- char port[NI_MAXSERV];
struct sockaddr_storage saddr;
memset(&saddr, 0, sizeof(struct sockaddr_storage));
- if (resolve_address(address, port, &saddr)) {
+ if (resolve_address(address, NULL, &saddr)) {
log_error("Could not bind %s to conn.", address);
return -1;
}
@@ -196,7 +188,6 @@ static int bind_src_by_address(int sockfd, char *address)
log_debug(4, "Bound %s to socket fd %d", address, sockfd);
return rc;
}
-#endif
static int bind_conn_to_iface(iscsi_conn_t *conn, struct iface_rec *iface)
{
@@ -215,17 +206,12 @@ static int bind_conn_to_iface(iscsi_conn_t *conn, struct iface_rec *iface)
}
} else if (iface_is_bound_by_netdev(iface)) {
strcpy(session->netdev, iface->netdev);
- } else if (iface_is_bound_by_ipaddr(iface)) {
- /*
- * we never supported this but now with offload having to
- * set the ip address in the iface, useris may forget to
- * set the offload's transport type and we end up here by
- * accident.
- */
- log_error("Cannot bind %s to net/scsi interface. This is not "
- "supported with software iSCSI (iscsi_tcp).",
- iface->ipaddress);
- return -1;
+ }
+
+ if (iface_is_bound_by_ipaddr(iface)) {
+ if (bind_src_by_address(conn->socket_fd, iface->ipaddress)) {
+ return -1;
+ }
}
if (strlen(session->netdev)) {
diff --git a/usr/iscsid.c b/usr/iscsid.c
index f8ffd23..f21a07d 100644
--- a/usr/iscsid.c
+++ b/usr/iscsid.c
@@ -225,8 +225,14 @@ static int sync_session(void *data, struct session_info *info)
memset(&rec, 0, sizeof(node_rec_t));
/*
- * We might get the local ip address for software. We do not
- * want to try and bind a session by ip though.
+ * We might get the local ip address for software because the
+ * kernel always export the ip being used. We do not want to try and
+ * bind a session by ip based on that. Will read in record and use
+ * that info.
+ *
+ * TODO: if a user was doing boot and bound the session by IP then
+ * this will not work. This is currently only supported if they
+ * are using our node/iface db though.
*/
if (!t->template->set_host_ip)
memset(info->iface.ipaddress, 0, sizeof(info->iface.ipaddress));