summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Larson <slioch@eng-140.vyatta.com>2008-06-26 16:28:34 -0700
committerMichael Larson <slioch@eng-140.vyatta.com>2008-06-26 16:28:34 -0700
commit7c15d60e3c1c14a4192a2818338b2ead7119a8ff (patch)
treef6653d5efd63567af67ce3a5068c552b97dfc19b /src
parent690b13abef1e0abc986c25208a8ce36d88a3e523 (diff)
downloadvyatta-wanloadbalance-7c15d60e3c1c14a4192a2818338b2ead7119a8ff.tar.gz
vyatta-wanloadbalance-7c15d60e3c1c14a4192a2818338b2ead7119a8ff.zip
fixed up status command output and add wait for interface address check on wlb boot
with interface configuration.
Diffstat (limited to 'src')
-rw-r--r--src/lbdecision.cc21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/lbdecision.cc b/src/lbdecision.cc
index e9f56f4..87b30e1 100644
--- a/src/lbdecision.cc
+++ b/src/lbdecision.cc
@@ -420,13 +420,20 @@ LBDecision::fetch_iface_addr(const string &iface)
if (fd < 0) {
exit(1);
}
- strncpy(ifr.ifr_name, iface.c_str(), IFNAMSIZ);
- if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) {
- struct sockaddr_in *sin = (struct sockaddr_in *)&ifr.ifr_addr;
- struct in_addr in;
- in.s_addr = sin->sin_addr.s_addr;
- char *tmp_buf = inet_ntoa(in);
- return string(tmp_buf);
+
+ int ct = 2;
+ //try twice to retrieve this before failing
+ while (ct > 0) {
+ strncpy(ifr.ifr_name, iface.c_str(), IFNAMSIZ);
+ if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) {
+ struct sockaddr_in *sin = (struct sockaddr_in *)&ifr.ifr_addr;
+ struct in_addr in;
+ in.s_addr = sin->sin_addr.s_addr;
+ char *tmp_buf = inet_ntoa(in);
+ return string(tmp_buf);
+ }
+ usleep(500 * 1000); //.5 second sleep
+ --ct;
}
close(fd);
return string("");