Mike Christie wrote:
> Hey,
> 
> When the iscsi scripts run they assume the network is ready to go. This 
> may not be the case for lots of different reasons, and to get around 
> this we have the login retry param in iscsi.conf. What we really want is 
> the login retry param, combined with the ability to know that the 
> network is up. To do this, I have been looking at libdbus and netreport, 
> in the hope that when the network is up, we can just fire off "iscsiadm 
> -m node -L automatic".
> 
> Before I do this though, I wanted to see if anyone have any opinion on 
> dbus or netreport? Will one be a problem for any distro?
> 

Oh yeah, here is a really basic patch for netreport usage. Right now it 
is really dumb, since we do not konw if the network is going up or down, 
and all we do is try to login to the records marked autoatmic. We of 
course should only waste our time trying to log in when the network is 
up and should try to figure out if it is a interface we even care about.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to open-iscsi@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/open-iscsi
-~----------~----~----~----~------~----~------~--~---

diff --git a/kernel/iscsi_tcp.c b/kernel/iscsi_tcp.c
diff --git a/kernel/iscsi_tcp.h b/kernel/iscsi_tcp.h
diff --git a/kernel/libiscsi.h b/kernel/libiscsi.h
diff --git a/kernel/scsi_transport_iscsi.c b/kernel/scsi_transport_iscsi.c
diff --git a/usr/iscsid.c b/usr/iscsid.c
index 2959821..70cb230 100644
--- a/usr/iscsid.c
+++ b/usr/iscsid.c
@@ -257,6 +257,30 @@ static void sync_sessions(void)
 	idbm_terminate(db);
 }
 
+/*
+ * This is only for a test. We should figure out if the
+ * network is going up or down, and if it is interface we
+ * even care about and do the right thing.
+ */
+static void handle_network_event(void)
+{
+	pid_t pid;
+	int rc;
+
+	log_debug(3, "Handling network event.\n");
+
+	pid = fork();
+	if (pid == 0) {
+		rc = execlp("/sbin/iscsiadm", "iscsiadm", "-m", "node", "-L",
+			    "automatic", NULL);
+	if (rc)
+		log_error("iscsiadm execution failed err (%d).", rc);
+	} else if (pid < 0)
+		log_error("Could not run iscsiadm.");
+	else
+		need_reap();
+}
+
 static void iscsid_exit(void)
 {
 	isns_exit();
@@ -280,6 +304,22 @@ static void iscsid_shutdown(void)
 	exit(0);
 }
 
+static void setup_netreport(void)
+{
+	pid_t pid;
+	int rc;
+
+	pid = fork();
+	if (pid == 0) {
+		rc = execlp("/sbin/netreport", "netreport", NULL);
+		if (rc)
+			log_error("netreport execution failed err (%d).", rc);
+	} else if (pid < 0)
+		log_error("Could not set netreport.");
+	else
+		need_reap();
+}
+
 static void catch_signal(int signo)
 {
 	log_debug(1, "%d caught signal -%d...", signo, getpid());
@@ -288,6 +328,9 @@ static void catch_signal(int signo)
 	case SIGTERM:
 		iscsid_shutdown();
 		break;
+	case SIGIO:
+		handle_network_event();
+		break;
 	default:
 		break;
 	}
@@ -324,9 +367,10 @@ int main(int argc, char *argv[])
 	sa_new.sa_handler = catch_signal;
 	sigemptyset(&sa_new.sa_mask);
 	sa_new.sa_flags = 0;
-	sigaction(SIGINT, &sa_new, &sa_old );
-	sigaction(SIGPIPE, &sa_new, &sa_old );
-	sigaction(SIGTERM, &sa_new, &sa_old );
+	sigaction(SIGINT, &sa_new, &sa_old);
+	sigaction(SIGPIPE, &sa_new, &sa_old);
+	sigaction(SIGTERM, &sa_new, &sa_old);
+	sigaction(SIGIO, &sa_new, &sa_old);
 
 	while ((ch = getopt_long(argc, argv, "c:i:fd:u:g:p:vh", long_options,
 				 &longindex)) >= 0) {
@@ -488,6 +532,7 @@ int main(int argc, char *argv[])
 	increase_max_files();
 	actor_init();
 	isns_fd = isns_init();
+	setup_netreport();
 	event_loop(ipc, control_fd, mgmt_ipc_fd, isns_fd);
 	iscsid_shutdown();
 	return 0;

Reply via email to