summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2021-11-30 16:29:23 +0700
committerGitHub <noreply@github.com>2021-11-30 16:29:23 +0700
commitac518f1494fd1f014c90d3354eabbb7e33a22f30 (patch)
treefa9f2f1b669050f03d9baf01e8c344c5bfec7b42 /src
parente796b6a9dbf8eaa66b746a75c3211d9ea7ac458b (diff)
parent69a6a8a153b8c53de66bfb9c72a113bd42afa989 (diff)
downloadvyatta-wanloadbalance-lithium.tar.gz
vyatta-wanloadbalance-lithium.zip
Merge pull request #6 from EwaldvanGeffen/lithiumlithium
Bug 590 & 363
Diffstat (limited to 'src')
-rw-r--r--src/lbdata.hh1
-rw-r--r--src/lbdatafactory.cc11
-rw-r--r--src/lbdatafactory.hh3
-rw-r--r--src/lbdecision.cc19
4 files changed, 34 insertions, 0 deletions
diff --git a/src/lbdata.hh b/src/lbdata.hh
index 0b4175c..aaaa896 100644
--- a/src/lbdata.hh
+++ b/src/lbdata.hh
@@ -227,6 +227,7 @@ class LBData {
bool _flush_conntrack;
bool _sticky_inbound_connections;
string _hook;
+ string _post_hook;
};
#endif //__LBDATA_HH__
diff --git a/src/lbdatafactory.cc b/src/lbdatafactory.cc
index 9729e62..682b0b4 100644
--- a/src/lbdatafactory.cc
+++ b/src/lbdatafactory.cc
@@ -157,6 +157,9 @@ LBDataFactory::process(const vector<string> &path, int depth, const string &key,
else if (path[0] == "hook") {
process_hook(l_key,l_value);
}
+ else if (path[0] == "post-hook") {
+ process_post_hook(l_key,l_value);
+ }
else if (path[0] == "health") {
if (depth == 2 && key == "interface") {
process_health(l_key,l_value);
@@ -250,6 +253,14 @@ LBDataFactory::process_hook(const string &key, const string &value)
}
void
+LBDataFactory::process_post_hook(const string &key, const string &value)
+{
+ if (value.empty() == false) {
+ _lb_data._post_hook = value;
+ }
+}
+
+void
LBDataFactory::process_health(const string &key, const string &value)
{
if (value.empty() == false) {
diff --git a/src/lbdatafactory.hh b/src/lbdatafactory.hh
index 9178e00..f213993 100644
--- a/src/lbdatafactory.hh
+++ b/src/lbdatafactory.hh
@@ -59,6 +59,9 @@ private:
process_hook(const string &key, const string &value);
void
+ process_post_hook(const string &key, const string &value);
+
+ void
process_health_interface(const string &key, const string &value);
void
diff --git a/src/lbdecision.cc b/src/lbdecision.cc
index 665b2a2..fd5fd62 100644
--- a/src/lbdecision.cc
+++ b/src/lbdecision.cc
@@ -434,6 +434,25 @@ LBDecision::run(LBData &lb_data)
}
++iter;
}
+
+ map<string,string>::iterator post_iter = state_changed_coll.begin();
+ while (post_iter != state_changed_coll.end()) {
+ //set state
+ //set interface
+ if (lb_data._post_hook.empty() == false) {
+ setenv("WLB_INTERFACE_NAME",post_iter->first.c_str(),1);
+ setenv("WLB_INTERFACE_STATE",post_iter->second.c_str(),1);
+
+ syslog(LOG_WARNING, "executing script: %s",lb_data._post_hook.c_str());
+
+ execute(lb_data._post_hook, stdout);
+ //unset state
+ //unset interface
+ unsetenv("WLB_INTERFACE_NAME");
+ unsetenv("WLB_INTERFACE_STATE");
+ }
+ ++post_iter;
+ }
}
/**