[Pkg-iscsi-maintainers] [SCM] Debian Open-iSCSI Packaging branch, upstream-mnc, updated. 2.0-872-193-gde2c0e7

Mike Christie michaelc at cs.wisc.edu
Sat Apr 7 15:44:18 UTC 2012


The following commit has been merged in the upstream-mnc branch:
commit 04b4a6699f63c4f0bab9523aae3efb8c909d6587
Author: Mike Christie <michaelc at cs.wisc.edu>
Date:   Thu Mar 22 04:09:01 2012 -0400

    iscsi tools: have iscsi tools bring up offload net iface
    
    bnx2i and cxgb*i need the network interface that the offload
    engine attaches to brought up before we can connect. This patch
    has the iscsi tools do this before trying to create a tcp/ip
    connection.

diff --git a/include/iscsi_net_util.h b/include/iscsi_net_util.h
index 222634d..31b80ad 100644
--- a/include/iscsi_net_util.h
+++ b/include/iscsi_net_util.h
@@ -7,5 +7,6 @@ extern int net_get_transport_name_from_netdev(char *netdev, char *transport);
 extern int net_get_netdev_from_hwaddress(char *hwaddress, char *netdev);
 extern int net_setup_netdev(char *netdev, char *local_ip, char *mask,
 			    char *gateway, char *remote_ip, int needs_bringup);
+extern int net_ifup_netdev(char *netdev);
 
 #endif
diff --git a/usr/initiator_common.c b/usr/initiator_common.c
index fa8846d..ef6820c 100644
--- a/usr/initiator_common.c
+++ b/usr/initiator_common.c
@@ -35,6 +35,7 @@
 #include "host.h"
 #include "sysdeps.h"
 #include "iscsi_err.h"
+#include "iscsi_net_util.h"
 
 struct iscsi_session *session_find_by_sid(uint32_t sid)
 {
@@ -566,6 +567,8 @@ int iscsi_host_set_net_params(struct iface_rec *iface,
 {
 	struct iscsi_transport *t = session->t;
 	int rc = 0;
+	char *netdev;
+	struct host_info hinfo;
 
 	log_debug(3, "setting iface %s, dev %s, set ip %s, hw %s, "
 		  "transport %s.\n",
@@ -582,6 +585,21 @@ int iscsi_host_set_net_params(struct iface_rec *iface,
 		return EINVAL;
 	}
 
+	/* these type of drivers need the netdev upd */
+	if (strlen(iface->netdev))
+		netdev = iface->netdev;
+	else {
+		memset(&hinfo, 0, sizeof(hinfo));
+		hinfo.host_no = session->hostno;
+		iscsi_sysfs_get_hostinfo_by_host_no(&hinfo);
+
+		netdev = hinfo.iface.netdev;
+	}
+
+	if (net_ifup_netdev(netdev))
+		log_warning("Could not brining up netdev %s. Try running "
+			    "'ifup %s' first if login fails.", netdev, netdev);
+
 	rc = host_set_param(t, session->hostno,
 			    ISCSI_HOST_PARAM_IPADDRESS,
 			    iface->ipaddress, ISCSI_STRING);
diff --git a/usr/iscsi_net_util.c b/usr/iscsi_net_util.c
index 7edc0b9..212cc59 100644
--- a/usr/iscsi_net_util.c
+++ b/usr/iscsi_net_util.c
@@ -306,4 +306,57 @@ done:
 	return ret;
 }
 
+/**
+ * net_ifup_netdev - bring up network interface
+ * @netdev: netdevice to bring up.
+ */
+int net_ifup_netdev(char *netdev)
+{
+	struct ifreq ifr;
+	int sock;
+	int ret = 0;
+
+	if (!strlen(netdev)) {
+		log_error("No netdev name in fw entry.\n");
+		return EINVAL;
+	}		
+
+	/* Create socket for making networking changes */
+	if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
+		log_error("Could not open socket to manage network "
+			  "(err %d - %s)", errno, strerror(errno));
+		return errno;
+	}
+
+	memset(&ifr, 0, sizeof(ifr));
+	strncpy(ifr.ifr_name, netdev, IFNAMSIZ);
+	if (ioctl(sock, SIOCSIFFLAGS, &ifr) < 0) {
+		log_error("Could not bring up netdev %s (err %d - %s)",
+			  netdev, errno, strerror(errno));
+		ret = errno;
+		goto done;
+	}
+
+	if (ifr.ifr_flags & IFF_UP) {
+		log_debug(3, "%s up\n", netdev);
+		goto done;
+	}
+
+	log_debug(3, "bringing %s up\n", netdev);
+
+	/* Bring up interface */
+	memset(&ifr, 0, sizeof(ifr));
+	strncpy(ifr.ifr_name, netdev, IFNAMSIZ);
+	ifr.ifr_flags = IFF_UP;
+	if (ioctl(sock, SIOCSIFFLAGS, &ifr) < 0) {
+		log_error("Could not bring up netdev %s (err %d - %s)",
+			  netdev, errno, strerror(errno));
+		ret = errno;
+		goto done;
+	}
+done:
+	close(sock);
+	return ret;
+}
+
 

-- 
Debian Open-iSCSI Packaging



More information about the Pkg-iscsi-maintainers mailing list