Port ranges for PF rules: public port start should be equal to ending port 
start; the same applies to end ports


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/bbbccc0a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/bbbccc0a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/bbbccc0a

Branch: refs/heads/master
Commit: bbbccc0a7b912781be01272f9d9a526d49c28ed8
Parents: 2c2178c
Author: Alena Prokharchyk <[email protected]>
Authored: Fri Sep 14 11:38:07 2012 -0700
Committer: Alena Prokharchyk <[email protected]>
Committed: Thu Sep 27 10:50:04 2012 -0700

----------------------------------------------------------------------
 .../api/commands/CreatePortForwardingRuleCmd.java  |    1 -
 .../com/cloud/network/rules/RulesManagerImpl.java  |    9 +++++++++
 2 files changed, 9 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/bbbccc0a/api/src/com/cloud/api/commands/CreatePortForwardingRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreatePortForwardingRuleCmd.java 
b/api/src/com/cloud/api/commands/CreatePortForwardingRuleCmd.java
index 55f0b23..3f3915a 100644
--- a/api/src/com/cloud/api/commands/CreatePortForwardingRuleCmd.java
+++ b/api/src/com/cloud/api/commands/CreatePortForwardingRuleCmd.java
@@ -66,7 +66,6 @@ public class CreatePortForwardingRuleCmd extends 
BaseAsyncCreateCmd implements P
     @Parameter(name = ApiConstants.PRIVATE_END_PORT, type = 
CommandType.INTEGER, required = false, description = "the ending port of port 
forwarding rule's private port range")
     private Integer privateEndPort;
 
-
     @Parameter(name = ApiConstants.PUBLIC_START_PORT, type = 
CommandType.INTEGER, required = true, 
             description = "the starting port of port forwarding rule's public 
port range")
     private Integer publicStartPort;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/bbbccc0a/server/src/com/cloud/network/rules/RulesManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/RulesManagerImpl.java 
b/server/src/com/cloud/network/rules/RulesManagerImpl.java
index 6e57009..3a61db9 100755
--- a/server/src/com/cloud/network/rules/RulesManagerImpl.java
+++ b/server/src/com/cloud/network/rules/RulesManagerImpl.java
@@ -244,6 +244,15 @@ public class RulesManagerImpl implements RulesManager, 
RulesService, Manager {
             } else {
                 dstIp = new Ip(guestNic.getIp4Address());
             }
+            
+            //source start port and source dest port should be the same. The 
same applies to dest ports
+            if (rule.getSourcePortStart().intValue() != 
rule.getDestinationPortStart()) {
+                throw new InvalidParameterValueException("Private port start 
should be equal to public port start", null);
+            }
+            
+            if (rule.getSourcePortEnd().intValue() != 
rule.getDestinationPortEnd()) {
+                throw new InvalidParameterValueException("Private port end 
should be equal to public port end", null);
+            }
 
             Transaction txn = Transaction.currentTxn();
             txn.start();

Reply via email to