diff options
author | Michael Larson <slioch@eng-140.vyatta.com> | 2008-02-05 16:13:28 -0800 |
---|---|---|
committer | Michael Larson <slioch@eng-140.vyatta.com> | 2008-02-05 16:13:28 -0800 |
commit | feaee77ba7c7003bac53c4858eab26ac339e6aa8 (patch) | |
tree | e138ef78aa6423976739084db89f68b67f6ecf35 | |
parent | f350c6bdc9d1fba54fc695039341c87eb50b573a (diff) | |
download | vyatta-wanloadbalance-feaee77ba7c7003bac53c4858eab26ac339e6aa8.tar.gz vyatta-wanloadbalance-feaee77ba7c7003bac53c4858eab26ac339e6aa8.zip |
changed port definition to be consistent with fw/nat (i.e. single port line allow multi-port configuration). init script fix
-rw-r--r-- | debian/vyatta-wanloadbalance.postinst | 9 | ||||
-rw-r--r-- | scripts/vyatta-wanloadbalance.pl | 36 | ||||
-rw-r--r-- | src/lbdata.cc | 6 | ||||
-rw-r--r-- | src/lbdata.hh | 6 | ||||
-rw-r--r-- | src/lbdatafactory.cc | 14 | ||||
-rw-r--r-- | src/lbdecision.cc | 14 | ||||
-rw-r--r-- | templates/load-balancing/wan/rule/node.tag/destination/port-name/node.def | 3 | ||||
-rw-r--r-- | templates/load-balancing/wan/rule/node.tag/destination/port-number/node.def | 7 | ||||
-rw-r--r-- | templates/load-balancing/wan/rule/node.tag/destination/port/node.def | 3 | ||||
-rw-r--r-- | templates/load-balancing/wan/rule/node.tag/source/port-number/node.def | 6 | ||||
-rw-r--r-- | templates/load-balancing/wan/rule/node.tag/source/port/node.def (renamed from templates/load-balancing/wan/rule/node.tag/source/port-name/node.def) | 1 |
11 files changed, 24 insertions, 81 deletions
diff --git a/debian/vyatta-wanloadbalance.postinst b/debian/vyatta-wanloadbalance.postinst index 0595d44..917b54c 100644 --- a/debian/vyatta-wanloadbalance.postinst +++ b/debian/vyatta-wanloadbalance.postinst @@ -9,13 +9,6 @@ sysconfdir=${prefix}/etc mkdir -p $LOADBALANCE_DIR chmod 0755 $LOADBALANCE_DIR -rm -f /etc/init.d/vyatta-wanloadbalance 2>/dev/null -ln -s /opt/vyatta/sbin/vyatta-wanloadbalance.init /etc/init.d/vyatta-wanloadbalance 2>/dev/null - -#because I'm lazy and don't want to have to create an extra pkg for the show cmd -mkdir -p /opt/vyatta/share/vyatta-op/templates/show/wan-load-balance/status/ -mv /opt/vyatta/share/vyatta-cfg/templates/show/wan-load-balance/node.def /opt/vyatta/share/vyatta-op/templates/show/wan-load-balance/. -mv /opt/vyatta/share/vyatta-cfg/templates/show/wan-load-balance/status/node.def /opt/vyatta/share/vyatta-op/templates/show/wan-load-balance/status/. - +ln -sf /opt/vyatta/sbin/vyatta-wanloadbalance.init /etc/init.d/vyatta-wanloadbalance #nothing diff --git a/scripts/vyatta-wanloadbalance.pl b/scripts/vyatta-wanloadbalance.pl index b41bab2..16fce02 100644 --- a/scripts/vyatta-wanloadbalance.pl +++ b/scripts/vyatta-wanloadbalance.pl @@ -103,26 +103,17 @@ sub write_rules { print FILE_LCK "\t\tnetwork " . $option . "\n"; } - $config->setLevel("load-balancing wan rule $rule destination port-number"); - my @dport_nums = $config->listNodes(); - foreach my $dport_num (@dport_nums) { + $config->setLevel("load-balancing wan rule $rule destination port"); + my @dport = $config->listNodes(); + foreach my $dp (@dport) { if ($protocol ne "tcp" && $protocol ne "udp") { print "Please specify protocol tcp or udp when configuring ports\n"; exit 2; } - print FILE_LCK "\t\tport-number " . $dport_num . "\n"; + print FILE_LCK "\t\tport " . $dp . "\n"; } - $config->setLevel("load-balancing wan rule $rule destination port-name"); - my @dport_names = $config->listNodes(); - foreach my $dport_name (@dport_names) { - if ($protocol ne "tcp" && $protocol ne "udp") { - print "Please specify protocol tcp or udp when configuring ports\n"; - exit 2; - } - print FILE_LCK "\t\tport-name " . $dport_name . "\n"; - } print FILE_LCK "\t}\n"; #source @@ -137,26 +128,15 @@ sub write_rules { print FILE_LCK "\t\tnetwork " . $option . "\n"; } - $config->setLevel("load-balancing wan rule $rule source port-number"); - my @sport_nums = $config->listNodes(); - foreach my $sport_num (@sport_nums) { - if ($protocol ne "tcp" && $protocol ne "udp") { - print "Please specify protocol tcp or udp when configuring ports\n"; - exit 2; - } - print FILE_LCK "\t\tport-number " . $sport_num . "\n"; - } - - $config->setLevel("load-balancing wan rule $rule source port-name"); - my @sport_names = $config->listNodes(); - foreach my $sport_name (@sport_names) { + $config->setLevel("load-balancing wan rule $rule source port"); + my @sports = $config->listNodes(); + foreach my $sp (@sports) { if ($protocol ne "tcp" && $protocol ne "udp") { print "Please specify protocol tcp or udp when configuring ports\n"; exit 2; } - print FILE_LCK "\t\tport-name " . $sport_name . "\n"; + print FILE_LCK "\t\tports " . $sp . "\n"; } - print FILE_LCK "\t}\n"; #interface $config->setLevel("load-balancing wan rule $rule interface"); diff --git a/src/lbdata.cc b/src/lbdata.cc index 57050d2..70d1f50 100644 --- a/src/lbdata.cc +++ b/src/lbdata.cc @@ -165,13 +165,11 @@ LBData::dump() cout << " " << r_iter->second._proto << endl; cout << " " << r_iter->second._s_addr << endl; cout << " " << r_iter->second._s_net << endl; - cout << " " << r_iter->second._s_port_num << endl; - cout << " " << r_iter->second._s_port_name << endl; + cout << " " << r_iter->second._s_port << endl; cout << " " << r_iter->second._d_addr << endl; cout << " " << r_iter->second._d_net << endl; - cout << " " << r_iter->second._d_port_num << endl; - cout << " " << r_iter->second._d_port_name << endl; + cout << " " << r_iter->second._d_port << endl; LBRule::InterfaceDistIter ri_iter = r_iter->second._iface_dist_coll.begin(); while (ri_iter != r_iter->second._iface_dist_coll.end()) { diff --git a/src/lbdata.hh b/src/lbdata.hh index d05bf2d..c466e20 100644 --- a/src/lbdata.hh +++ b/src/lbdata.hh @@ -50,13 +50,11 @@ class LBRule { string _proto; string _s_addr; string _s_net; - string _s_port_num; - string _s_port_name; + string _s_port; string _d_addr; string _d_net; - string _d_port_num; - string _d_port_name; + string _d_port; InterfaceDistColl _iface_dist_coll; }; diff --git a/src/lbdatafactory.cc b/src/lbdatafactory.cc index d422c95..15322a9 100644 --- a/src/lbdatafactory.cc +++ b/src/lbdatafactory.cc @@ -290,11 +290,8 @@ LBDataFactory::process_rule_source(const string &key, const string &value) else if (key == "network") { _rule_iter->second._s_net = value; } - else if (key == "port-name") { - _rule_iter->second._s_port_name = value; - } - else if (key == "port-number") { - _rule_iter->second._s_port_num = value; + else if (key == "port") { + _rule_iter->second._s_port = value; } } @@ -314,11 +311,8 @@ LBDataFactory::process_rule_destination(const string &key, const string &value) else if (key == "network") { _rule_iter->second._d_net = value; } - else if (key == "port-name") { - _rule_iter->second._d_port_name = value; - } - else if (key == "port-number") { - _rule_iter->second._d_port_num = value; + else if (key == "port") { + _rule_iter->second._d_port = value; } } diff --git a/src/lbdecision.cc b/src/lbdecision.cc index 64bc600..4893a64 100644 --- a/src/lbdecision.cc +++ b/src/lbdecision.cc @@ -314,18 +314,12 @@ LBDecision::get_application_cmd(LBRule &rule) filter += "--destination " + rule._d_net + " "; } - if (rule._s_port_name.empty() == false) { - filter += "--source-port " + rule._s_port_name + " "; - } - else if (rule._s_port_num.empty() == false) { - filter += "--source-port " + rule._s_port_num + " "; + if (rule._s_port.empty() == false) { + filter += "-m multiport --source-port " + rule._s_port + " "; } - if (rule._d_port_name.empty() == false) { - filter += "--destination-port " + rule._d_port_name + " "; - } - else if (rule._d_port_num.empty() == false) { - filter += "--destination-port " + rule._d_port_num + " "; + if (rule._d_port.empty() == false) { + filter += "-m multiport --destination-port " + rule._d_port + " "; } } diff --git a/templates/load-balancing/wan/rule/node.tag/destination/port-name/node.def b/templates/load-balancing/wan/rule/node.tag/destination/port-name/node.def deleted file mode 100644 index fbc6446..0000000 --- a/templates/load-balancing/wan/rule/node.tag/destination/port-name/node.def +++ /dev/null @@ -1,3 +0,0 @@ -tag: -type: txt -help: Port name diff --git a/templates/load-balancing/wan/rule/node.tag/destination/port-number/node.def b/templates/load-balancing/wan/rule/node.tag/destination/port-number/node.def deleted file mode 100644 index 72cb512..0000000 --- a/templates/load-balancing/wan/rule/node.tag/destination/port-number/node.def +++ /dev/null @@ -1,7 +0,0 @@ -tag: -type: u32 -syntax:expression: $VAR(@) >= 0 && $VAR(@) <= 65535; "port number must be between 1 and 65535" -help: Port number -comp_help: possible completions: -<1-65535> Port number - diff --git a/templates/load-balancing/wan/rule/node.tag/destination/port/node.def b/templates/load-balancing/wan/rule/node.tag/destination/port/node.def new file mode 100644 index 0000000..1e43c40 --- /dev/null +++ b/templates/load-balancing/wan/rule/node.tag/destination/port/node.def @@ -0,0 +1,3 @@ +type: txt +help: Ports + diff --git a/templates/load-balancing/wan/rule/node.tag/source/port-number/node.def b/templates/load-balancing/wan/rule/node.tag/source/port-number/node.def deleted file mode 100644 index 599a4c6..0000000 --- a/templates/load-balancing/wan/rule/node.tag/source/port-number/node.def +++ /dev/null @@ -1,6 +0,0 @@ -tag: -type: u32 -syntax:expression: $VAR(@) >= 0 && $VAR(@) <= 65535; "port number must be between 1 and 65535" -help: port number -comp_help: possible completions: -<1-65535> Port number diff --git a/templates/load-balancing/wan/rule/node.tag/source/port-name/node.def b/templates/load-balancing/wan/rule/node.tag/source/port/node.def index 6f8bcf5..db26231 100644 --- a/templates/load-balancing/wan/rule/node.tag/source/port-name/node.def +++ b/templates/load-balancing/wan/rule/node.tag/source/port/node.def @@ -1,3 +1,2 @@ -tag: type: txt help: port name |