Skip to content

Commit aa8048a

Browse files
Alena Prokharchyksudison
authored andcommitted
Port ranges for PF rules: public port start should be equal to ending port start; the same applies to end ports
1 parent 2392f65 commit aa8048a

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

api/src/com/cloud/api/commands/CreatePortForwardingRuleCmd.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
6666
@Parameter(name = ApiConstants.PRIVATE_END_PORT, type = CommandType.INTEGER, required = false, description = "the ending port of port forwarding rule's private port range")
6767
private Integer privateEndPort;
6868

69-
7069
@Parameter(name = ApiConstants.PUBLIC_START_PORT, type = CommandType.INTEGER, required = true,
7170
description = "the starting port of port forwarding rule's public port range")
7271
private Integer publicStartPort;

server/src/com/cloud/network/rules/RulesManagerImpl.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,15 @@ public PortForwardingRule createPortForwardingRule(PortForwardingRule rule, Long
244244
} else {
245245
dstIp = new Ip(guestNic.getIp4Address());
246246
}
247+
248+
//source start port and source dest port should be the same. The same applies to dest ports
249+
if (rule.getSourcePortStart().intValue() != rule.getDestinationPortStart()) {
250+
throw new InvalidParameterValueException("Private port start should be equal to public port start", null);
251+
}
252+
253+
if (rule.getSourcePortEnd().intValue() != rule.getDestinationPortEnd()) {
254+
throw new InvalidParameterValueException("Private port end should be equal to public port end", null);
255+
}
247256

248257
Transaction txn = Transaction.currentTxn();
249258
txn.start();

0 commit comments

Comments
 (0)