Original patch for the BZ was incomplete - anaconda did set the
timeout for NM but didn't use it when waiting for device activation.
Related: rhbz#769145
---
isys/iface.c | 10 +++++-----
isys/iface.h | 2 +-
loader/loader.c | 4 ++--
loader/net.c | 13 +++++++------
loader/net.h | 4 +++-
5 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/isys/iface.c b/isys/iface.c
index db3027f..64a7663 100644
--- a/isys/iface.c
+++ b/isys/iface.c
@@ -474,11 +474,11 @@ gboolean is_iface_activated(char * ifname) {
/*
* Wait for NetworkManager to appear on the system bus
*/
-int wait_for_nm(void) {
+int wait_for_nm(int seconds) {
int count = 0;
/* send message and block until a reply or error comes back */
- while (count < 45) {
+ while (count < seconds) {
if (is_nm_running())
return 0;
@@ -491,9 +491,9 @@ int wait_for_nm(void) {
/*
* Start NetworkManager -- requires that you have already written out the
- * control files in /etc/sysconfig for the interface.
+ * control files in /etc/sysconfig for the interface. Timeout in seconds.
*/
-int iface_start_NetworkManager(void) {
+int iface_start_NetworkManager(int timeout) {
pid_t pid;
if (is_nm_running())
@@ -520,7 +520,7 @@ int iface_start_NetworkManager(void) {
} else if (pid == -1) {
return 1;
} else {
- return wait_for_nm();
+ return wait_for_nm(timeout);
}
return 0;
diff --git a/isys/iface.h b/isys/iface.h
index 567f5ee..933ac84 100644
--- a/isys/iface.h
+++ b/isys/iface.h
@@ -157,7 +157,7 @@ gboolean is_iface_activated(char * ifname);
/*
* Start NetworkManager
*/
-int iface_start_NetworkManager(void);
+int iface_start_NetworkManager(int timeout);
/*
* Set Maximum Transfer Unit (MTU) on specified interface
diff --git a/loader/loader.c b/loader/loader.c
index 0e6be44..3143449 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -2073,7 +2073,7 @@ int main(int argc, char ** argv) {
loaderData.method = -1;
loaderData.fw_loader_pid = -1;
loaderData.fw_search_pathz_len = -1;
- loaderData.dhcpTimeout = 0;
+ loaderData.dhcpTimeout = NM_DHCP_TIMEOUT;
extraArgs[0] = NULL;
parseCmdLineFlags(&loaderData, cmdLine);
@@ -2254,7 +2254,7 @@ int main(int argc, char ** argv) {
#endif
/* Start NetworkManager now so it's always available to talk to. */
- if (iface_start_NetworkManager())
+ if (iface_start_NetworkManager(loaderData.dhcpTimeout))
logMessage(INFO, "failed to start NetworkManager");
if (!FL_CMDLINE(flags))
diff --git a/loader/net.c b/loader/net.c
index af6c90c..14efbf0 100644
--- a/loader/net.c
+++ b/loader/net.c
@@ -487,7 +487,7 @@ int readNetConfig(char * device, iface_t * iface,
return LOADER_BACK;
}
- i = wait_for_iface_activation(iface->device);
+ i = wait_for_iface_activation(iface->device, iface->dhcptimeout);
newtPopWindow();
if (i > 0) {
@@ -548,7 +548,7 @@ int readNetConfig(char * device, iface_t * iface,
return LOADER_BACK;
}
- i = wait_for_iface_activation(iface->device);
+ i = wait_for_iface_activation(iface->device, iface->dhcptimeout);
newtPopWindow();
if (i > 0) {
@@ -1585,7 +1585,7 @@ void setKickstartNetwork(struct loaderData_s * loaderData, int argc,
iface_t iface;
gchar *bootProto = NULL, *device = NULL, *class = NULL, *ethtool = NULL;
gchar *essid = NULL, *wepkey = NULL, *onboot = NULL, *gateway = NULL;
- gint mtu = 1500, dhcpTimeout = 0;
+ gint mtu = 1500;
gboolean noipv4 = FALSE, noipv6 = FALSE, noDns = FALSE, noksdev = FALSE, activate = FALSE, nodefroute=FALSE, firstnetdev=FALSE;
GOptionContext *optCon = g_option_context_new(NULL);
GError *optErr = NULL;
@@ -1622,7 +1622,7 @@ void setKickstartNetwork(struct loaderData_s * loaderData, int argc,
{ "activate", 0, 0, G_OPTION_ARG_NONE, &activate, NULL, NULL },
{ "firstnetdev", 0, 0, G_OPTION_ARG_NONE, &firstnetdev, NULL, NULL },
{ "nodefroute", 0, 0, G_OPTION_ARG_NONE, &nodefroute, NULL, NULL },
- { "dhcptimeout", 0, 0, G_OPTION_ARG_INT, &dhcpTimeout, NULL, NULL },
+ { "dhcptimeout", 0, 0, G_OPTION_ARG_INT, &loaderData->dhcpTimeout, NULL, NULL },
{ NULL },
};
@@ -1650,6 +1650,7 @@ void setKickstartNetwork(struct loaderData_s * loaderData, int argc,
free(loaderData->wepkey);
loaderData->wepkey = NULL;
loaderData->mtu = 0;
+ loaderData->dhcpTimeout = NM_DHCP_TIMEOUT;
#ifdef ENABLE_IPV6
free(loaderData->ipv6);
@@ -2237,7 +2238,7 @@ void splitHostname (char *str, char **host, char **port)
/*
* Wait for activation of iface by NetworkManager, return non-zero on error.
*/
-int wait_for_iface_activation(char *ifname) {
+int wait_for_iface_activation(char *ifname, int timeout) {
int count = 0, i;
NMClient *client = NULL;
NMState state;
@@ -2297,7 +2298,7 @@ int wait_for_iface_activation(char *ifname) {
}
/* send message and block until a reply or error comes back */
- while (count < 45) {
+ while (count < timeout) {
/* pump the loop again to clear the messages */
while (g_main_context_pending (ctx)) {
g_main_context_iteration (ctx, FALSE);
diff --git a/loader/net.h b/loader/net.h
index e23582a..a35dd5b 100644
--- a/loader/net.h
+++ b/loader/net.h
@@ -34,6 +34,8 @@
#define SYSCONFIG_PATH "/etc/sysconfig"
#define NETWORK_SCRIPTS_PATH "/etc/sysconfig/network-scripts"
+#define NM_DHCP_TIMEOUT 45
+
struct intfconfig_s {
newtComponent ipv4Entry, cidr4Entry;
newtComponent gwEntry, nsEntry;
@@ -80,7 +82,7 @@ int activateDevice(struct loaderData_s * loaderData,
iface_t * iface);
int disconnectDevice(char *device);
void splitHostname (char *str, char **host, char **port);
-int wait_for_iface_activation(char * ifname);
+int wait_for_iface_activation(char * ifname, int timeout);
int wait_for_iface_disconnection(char *ifname);
int isURLRemote(char *url);
int split_ipv6addr_prefix_length(char *str, char **address, char **prefix);
--
1.7.4