summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaurav Sinha <gaurav.sinha@vyatta.com>2012-09-07 14:10:29 -0700
committerGaurav Sinha <gaurav.sinha@vyatta.com>2012-09-07 17:19:20 -0700
commit3247c2cd893b868abd3516e9f7ef1b7e77c24169 (patch)
tree672c8b7442450fc3912ed20f9930eb3ad6b8d3ab
parent40cc6d8630e637d5ae7aeb130e7ceae8142f8cd4 (diff)
downloadvyatta-cfg-firewall-3247c2cd893b868abd3516e9f7ef1b7e77c24169.tar.gz
vyatta-cfg-firewall-3247c2cd893b868abd3516e9f7ef1b7e77c24169.zip
Fixing 3167, mandate multiport values after single port, remove misleading error message
(cherry picked from commit 94381cfb92ead6d5f32ab37bace5a1cf46efbb9e)
-rwxr-xr-xlib/Vyatta/IpTables/Rule.pm14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/Vyatta/IpTables/Rule.pm b/lib/Vyatta/IpTables/Rule.pm
index b78c2c2..ee4f4e8 100755
--- a/lib/Vyatta/IpTables/Rule.pm
+++ b/lib/Vyatta/IpTables/Rule.pm
@@ -428,13 +428,15 @@ sub rule {
return ($err_str, ) if (!defined($srcrule));
($dstrule, $err_str) = $dst->rule();
return ($err_str, ) if (!defined($dstrule));
- if ((grep /multiport/, $srcrule) ^ (grep /multiport/, $dstrule)) {
- if ((grep /sport/, $srcrule) && (grep /dport/, $dstrule)) {
- return ('Cannot specify multiple ports when both '
- . 'source and destination ports are specified', );
- }
+
+ # make sure multiport is always behind single port option
+ if ((grep /multiport/, $srcrule)) {
+ $rule .= " $dstrule $srcrule ";
+ } elsif ((grep /multiport/, $dstrule)) {
+ $rule .= " $srcrule $dstrule ";
+ } else {
+ $rule .= " $srcrule $dstrule ";
}
- $rule .= " $srcrule $dstrule ";
return ('Cannot specify both "match-frag" and "match-non-frag"', )
if (defined($self->{_frag}) && defined($self->{_non_frag}));