blob: 179275008a774946acd719c8dc30e8f287cec38c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
/*
* Module: lbpathtest.cc
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*/
#include <syslog.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/sysinfo.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/udp.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <errno.h>
#include <string.h>
#include <memory>
#include <time.h>
#include <sys/timeb.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include "lbdata.hh"
#include "lbpathtest.hh"
using namespace std;
/**
*
*
**/
LBPathTest::LBPathTest(bool debug) :
_debug(debug)
{
}
/**
*
*
**/
LBPathTest::~LBPathTest()
{
}
/**
*
*
**/
void
LBPathTest::start(LBData &lb_data)
{
//iterate through the tests until success per interface or complete
if (_debug) {
cout << "LBPathTest::start(): init" << endl;
}
set<LBHealth*> coll;
//iterate over the health interfaces, until success or test cases exhausted per interface
LBData::InterfaceHealthIter iter = lb_data._iface_health_coll.begin();
while (iter != lb_data._iface_health_coll.end()) {
coll.insert(&(iter->second));
iter->second.start_new_test_cycle();
++iter;
}
while (!coll.empty()) {
set<LBHealth*>::iterator i = coll.begin();
while (i != coll.end()) {
(*i)->start_new_test();
++i;
}
if (_debug) {
cout << "LBPathTest::start(): sending " << coll.size() << " tests" << endl;
}
//send all interface tests together
i = coll.begin();
while (i != coll.end()) {
(*i)->send_test();
++i;
}
if (_debug) {
cout << "LBPathTest::start(): waiting on recv" << endl;
}
//wait on responses
i = coll.begin();
while (i != coll.end()) {
int resp = (*i)->recv_test();
if (_debug) {
cout << "LBPathTest::start() interface: " << (*i)->_interface << " response value: " << (*i)->_hresults.get_last_resp() << endl;
}
if (resp == 0) { //means this interface has either exhausted its test cases or success
coll.erase(i++);
}
else {
++i;
}
}
}
}
|