Joris van Lieshout created CLOUDSTACK-6020:
----------------------------------------------

             Summary: createPortForwardingRule failes for vmguestip above 
127.255.255.255
                 Key: CLOUDSTACK-6020
                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-6020
             Project: CloudStack
          Issue Type: Bug
      Security Level: Public (Anyone can view this level - this is the default.)
          Components: API
    Affects Versions: 4.2.0, 4.1.0, 4.0.2, 4.0.1, 4.0.0, pre-4.0.0, 4.1.1, 
Future, 4.2.1, 4.1.2, 4.3.0, 4.4.0
            Reporter: Joris van Lieshout


command=createPortForwardingRule&response=json&sessionkey=FmHQb9oGmgKlM4ihB%2Fb2ik7p35E%3D&ipaddressid=d29bebfe-edc1-406f-b4ed-7a49c6e7ee1f&privateport=80&privateendport=80&publicport=80&publicendport=80&protocol=tcp&virtualmachineid=cc5c9dc4-3eeb-4533-994a-0e2636a48a60&openfirewall=false&vmguestip=192.168.1.30&networkid=5e56227c-83c0-4b85-8a27-53343e806d12&_=1391510423905

vmguestip=192.168.1.30

api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java
@Parameter(name = ApiConstants.VM_GUEST_IP, type = CommandType.STRING, required 
= false,
    description = "VM guest nic Secondary ip address for the port forwarding 
rule")
    private String vmSecondaryIp;

@Override
    public void create() {
        // cidr list parameter is deprecated
        if (cidrlist != null) {
            throw new InvalidParameterValueException("Parameter cidrList is 
deprecated; if you need to open firewall rule for the specific cidr, please 
refer to createFirewallRule command");
        }

        Ip privateIp = getVmSecondaryIp();
        if (privateIp != null) {
            if ( !privateIp.isIp4()) {
                throw new InvalidParameterValueException("Invalid vm ip 
address");
            }
        }

        try {
            PortForwardingRule result = 
_rulesService.createPortForwardingRule(this, virtualMachineId, privateIp, 
getOpenFirewall());
            setEntityId(result.getId());
            setEntityUuid(result.getUuid());
        } catch (NetworkRuleConflictException ex) {
            s_logger.info("Network rule conflict: " , ex);
            s_logger.trace("Network Rule Conflict: ", ex);
            throw new 
ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, ex.getMessage());
        }
    }

utils/src/com/cloud/utils/net/Ip.java
public boolean isIp4() {
        return ip < Integer.MAX_VALUE;
    }

public Ip(String ip) {
        this.ip = NetUtils.ip2Long(ip);
    }

=== ip2long for 192.168.1.30 => 3232235806

=== Integer.MAX_VALUE => 231-1 = 2147483647

3232235806 (192.168.1.30) is therefore bigger then MAX_VALUE making isIp4() 
return FALSE and throwing a InvalidParameterValueException…



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to