summaryrefslogtreecommitdiff
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
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.
-rw-r--r--src/lbdecision.cc21
-rw-r--r--templates/show/wan-load-balance/status/node.def2
2 files changed, 15 insertions, 8 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("");
diff --git a/templates/show/wan-load-balance/status/node.def b/templates/show/wan-load-balance/status/node.def
index 87b47f6..6cd58ec 100644
--- a/templates/show/wan-load-balance/status/node.def
+++ b/templates/show/wan-load-balance/status/node.def
@@ -1,6 +1,6 @@
help: Show WAN load-balancing statistics
run: if [ -f /var/load-balance/wlb.out ] ; then
- sudo /sbin/iptables -L PREROUTING -t mangle -vv
+ sudo /sbin/iptables -L PREROUTING -t mangle -v
else
echo WAN load balancing is not configured
fi