You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by wilderrodrigues <gi...@git.apache.org> on 2015/05/23 09:24:11 UTC

[GitHub] cloudstack pull request: CLOUDSTACK-8506 - Make ACS compliant with...

GitHub user wilderrodrigues opened a pull request:

    https://github.com/apache/cloudstack/pull/292

    CLOUDSTACK-8506 - Make ACS compliant with the RFC 3021

    Hi @bhaisaab and @DaanHoogland
    
    Could you please have a look at this PR and also at the RFC 3021?
    
    It allows us to have something like this:
    
            // RFC 3021 - 31-Bit Prefixes on IPv4 Point-to-Point Links
            //     GW              Netmask         Stat IP        End IP
            // 192.168.24.0 - 255.255.255.254 - 192.168.24.0 - 192.168.24.1
            // https://tools.ietf.org/html/rfc3021
    
    Email thread: https://www.mail-archive.com/dev@cloudstack.apache.org/msg45035.html
    
    Manual tests:
    
    I created the following public networks successfully:
    
    GW                 - Netmask             - Start IP          - End IP
    192.168.24.0 - 255.255.255.254 - 192.168.24.0 - 192.168.24.1
    192.168.10.0 - 255.255.255.254 - 192.168.10.0 - 192.168.10.1
    
    ![image](https://cloud.githubusercontent.com/assets/5129209/7782894/6510f674-012d-11e5-9476-7fb61cc427a7.png)
    
    Automated tests:
    
    Environments:
    
    Centos7 + KVM + Qemu
    MySQL/MariaDB 5.5.41
    Management Server running CentOS 7
    Component/Smoke tests: https://github.com/apache/cloudstack (test/integration/component and smoke)
    Storage type: NFS shared
    Isolation method: VLAN
    Agent: 4.6.0
    
    XenServer 62
    MySQL/MariaDB 5.5.41
    Management Server running CentOS 7
    Component/Smoke tests: https://github.com/apache/cloudstack (test/integration/component and smoke)
    Storage type: NFS shared
    Isolation method: VLAN
    
    ================== KVM tests ==================
    
    Test advanced zone virtual router ... === TestName: test_advZoneVirtualRouter | Status : SUCCESS ===
    ok
    Test Deploy Virtual Machine ... === TestName: test_deploy_vm | Status : SUCCESS ===
    ok
    Test Multiple Deploy Virtual Machine ... === TestName: test_deploy_vm_multiple | Status : SUCCESS ===
    ok
    Test Stop Virtual Machine ... === TestName: test_01_stop_vm | Status : SUCCESS ===
    ok
    Test Start Virtual Machine ... === TestName: test_02_start_vm | Status : SUCCESS ===
    ok
    Test Reboot Virtual Machine ... === TestName: test_03_reboot_vm | Status : SUCCESS ===
    ok
    Test destroy Virtual Machine ... === TestName: test_06_destroy_vm | Status : SUCCESS ===
    ok
    Test recover Virtual Machine ... === TestName: test_07_restore_vm | Status : SUCCESS ===
    ok
    Test migrate VM ... SKIP: At least two hosts should be present in the zone for migration
    Test destroy(expunge) Virtual Machine ... === TestName: test_09_expunge_vm | Status : SUCCESS ===
    ok
    
    ----------------------------------------------------------------------
    Ran 10 tests in 2672.003s
    
    OK (SKIP=1)
    /tmp//MarvinLogs/test_vm_life_cycle_CBBMBX/results.txt (END)
    
    
    Test router internal advanced zone ... === TestName: test_02_router_internal_adv | Status : SUCCESS ===
    ok
    Test restart network ... === TestName: test_03_restart_network_cleanup | Status : SUCCESS ===
    ok
    Test router basic setup ... === TestName: test_05_router_basic | Status : SUCCESS ===
    ok
    Test router advanced setup ... === TestName: test_06_router_advanced | Status : SUCCESS ===
    ok
    Test stop router ... === TestName: test_07_stop_router | Status : SUCCESS ===
    ok
    Test start router ... === TestName: test_08_start_router | Status : SUCCESS ===
    ok
    Test reboot router ... === TestName: test_09_reboot_router | Status : SUCCESS ===
    ok
    
    ----------------------------------------------------------------------
    Ran 7 tests in 1738.326s
    
    
    OK
    /tmp//MarvinLogs/test_routers_E9IXI8/results.txt (END)
    
    
    Test to create service offering ... === TestName: test_01_create_service_offering | Status : SUCCESS ===
    ok
    Test to update existing service offering ... === TestName: test_02_edit_service_offering | Status : SUCCESS ===
    ok
    Test to delete service offering ... === TestName: test_03_delete_service_offering | Status : SUCCESS ===
    ok
    
    ----------------------------------------------------------------------
    Ran 3 tests in 716.298s
    
    OK
    /tmp//MarvinLogs/test_service_offerings_TGBROS/results.txt (END)
    
    
    Test reset virtual machine on reboot ... === TestName: test_01_reset_vm_on_reboot | Status : SUCCESS ===
    ok
    
    ----------------------------------------------------------------------
    Ran 1 test in 842.055s
    
    OK
    /tmp//MarvinLogs/test_reset_vm_on_reboot_P8SXD8/results.txt (END)
    
    
    ================== XenServer 6.2 tests ==================
    
    
    Test advanced zone router services ... === TestName: test_01_AdvancedZoneRouterServices | Status : SUCCESS ===
    ok
    Test network garbage collection ... === TestName: test_02_NetworkGarbageCollection | Status : SUCCESS ===
    ok
    Test router start on VM deploy ... === TestName: test_03_RouterStartOnVmDeploy | Status : SUCCESS ===
    ok
    
    ----------------------------------------------------------------------
    Ran 3 tests in 584.831s
    
    OK
    /tmp//MarvinLogs/test_routers_6N0F4X/results.txt (END)
    
    
    Test reset virtual machine on reboot ... === TestName: test_01_reset_vm_on_reboot | Status : SUCCESS ===
    ok
    
    ----------------------------------------------------------------------
    Ran 1 test in 193.477s
    
    OK
    /tmp//MarvinLogs/test_reset_vm_on_reboot_QP4HWN/results.txt (END)
    
    
    Test to create service offering ... === TestName: test_01_create_service_offering | Status : SUCCESS ===
    ok
    Test to update existing service offering ... === TestName: test_02_edit_service_offering | Status : SUCCESS ===
    ok
    Test to delete service offering ... === TestName: test_03_delete_service_offering | Status : SUCCESS ===
    ok
    
    ----------------------------------------------------------------------
    Ran 3 tests in 208.381s
    
    OK
    /tmp//MarvinLogs/test_service_offerings_TN84C8/results.txt (END)
    
    
    Test advanced zone virtual router ... === TestName: test_advZoneVirtualRouter | Status : SUCCESS ===
    ok
    Test Deploy Virtual Machine ... === TestName: test_deploy_vm | Status : SUCCESS ===
    ok
    Test Multiple Deploy Virtual Machine ... === TestName: test_deploy_vm_multiple | Status : SUCCESS ===
    ok
    Test Stop Virtual Machine ... === TestName: test_01_stop_vm | Status : SUCCESS ===
    ok
    Test Start Virtual Machine ... === TestName: test_02_start_vm | Status : SUCCESS ===
    ok
    Test Reboot Virtual Machine ... === TestName: test_03_reboot_vm | Status : SUCCESS ===
    ok
    Test destroy Virtual Machine ... === TestName: test_06_destroy_vm | Status : SUCCESS ===
    ok
    Test recover Virtual Machine ... === TestName: test_07_restore_vm | Status : SUCCESS ===
    ok
    Test migrate VM ... SKIP: At least two hosts should be present in the zone for migration
    Test destroy(expunge) Virtual Machine ... === TestName: test_09_expunge_vm | Status : SUCCESS ===
    ok
    
    ----------------------------------------------------------------------
    Ran 10 tests in 836.488s
    
    OK (SKIP=1)
    /tmp//MarvinLogs/test_vm_life_cycle_AI4BME/results.txt (END)

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/schubergphilis/cloudstack improvement/RFC_3021_31_Bit_Prefixes

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cloudstack/pull/292.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #292
    
----
commit 14863bbaffda55bf99bb96915f240db1605ce79c
Author: wilderrodrigues <wr...@schubergphilis.com>
Date:   2015-05-22T16:17:16Z

    CLOUDSTACK-8506
      - Added subnetUtils.setInclusiveHostCount(true) to NetUtils.isIpWithtInCidrRange() method. It makes the 31-bit prefixes work just fine
      - Added 3 unit tests to test valid and invalid ranges.

commit a83f74d83e4d0699ad631d2efa4cd674bc53076b
Author: wilderrodrigues <wr...@schubergphilis.com>
Date:   2015-05-22T18:08:09Z

    CLOUDSTACK-8506
    
      - Changing the implementation of the NetUtils.ipRangesOverlap() a little bit in order to be compliant with RFC 3021
      - 2 unit tests added
      - ranges from 0 to 255 covered by the tests, which also test the negative cases.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-8506 - Make ACS compliant with...

Posted by wilderrodrigues <gi...@git.apache.org>.
Github user wilderrodrigues commented on the pull request:

    https://github.com/apache/cloudstack/pull/292#issuecomment-104871245
  
    @DaanHoogland , I also commented on your comments.
    
    Which bit is hard to review? Put a lot of test results and also did the manual tests for the public networks, followed by new unit tests.
    
    Can we merge it? If so, I would also suggest to get it on 4.4.4 and 4.5.
    
    Cheers,
    Wilder


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Re: [GitHub] cloudstack pull request: CLOUDSTACK-8506 - Make ACS compliant with...

Posted by Daan Hoogland <da...@gmail.com>.
This code is a bug. To split in two conditions range 1 is a /31 or range 1
is not a /31;

precondition: endIp1Long == startIp1Long + 1

1: startIp2Long - startIp1Long == startIp2Long - (endIp1Long -
ip31bitPrefixOffSet)    # - startip2Long
2: - startIp1Long == - (endIp1Long - ip31bitPrefixOffSet)
        # * -1
3: startIp1Long == endIp1Long - ip31bitPrefixOffSet
    # + ip31bitPrefixOffSet
4: startip1Long + 1 == endIp1Long
    # precondition
5: true  ==>> return false

precondition: endIp1Long != startIp1Long + 1 # no /31 network

1 through 4 the same
5: false ==>> do further checking

the conditional block comes down to
if(endIp1Long == startIp1Long + 1)
{
    return false; // no further overlap is tested for!!!
}

This means that if range 1 is a slash thirty one no further overlap
checking is done, irrespective of range 2. I don't know if this is right,
but the code is not clear in this perspect for sure.

Op za 23 mei 2015 om 12:00 schreef wilderrodrigues <gi...@git.apache.org>:

> Github user wilderrodrigues commented on a diff in the pull request:
>
>     https://github.com/apache/cloudstack/pull/292#discussion_r30943691
>
>     --- Diff: utils/src/com/cloud/utils/net/NetUtils.java ---
>     @@ -329,35 +329,46 @@ public static String getMacAddress(InetAddress
> address) {
>              return sb.toString();
>          }
>
>     -    public static long getMacAddressAsLong(InetAddress address) {
>     +    public static long getMacAddressAsLong(final InetAddress address)
> {
>              long macAddressAsLong = 0;
>              try {
>     -            NetworkInterface ni =
> NetworkInterface.getByInetAddress(address);
>     -            byte[] mac = ni.getHardwareAddress();
>     +            final NetworkInterface ni =
> NetworkInterface.getByInetAddress(address);
>     +            final byte[] mac = ni.getHardwareAddress();
>
>                  for (int i = 0; i < mac.length; i++) {
>     -                macAddressAsLong |= ((long)(mac[i] & 0xff) <<
> (mac.length - i - 1) * 8);
>     +                macAddressAsLong |= (long)(mac[i] & 0xff) <<
> (mac.length - i - 1) * 8;
>                  }
>
>     -        } catch (SocketException e) {
>     +        } catch (final SocketException e) {
>                  s_logger.error("SocketException when trying to retrieve
> MAC address", e);
>              }
>
>              return macAddressAsLong;
>          }
>
>     -    public static boolean ipRangesOverlap(String startIp1, String
> endIp1, String startIp2, String endIp2) {
>     -        long startIp1Long = ip2Long(startIp1);
>     +    public static boolean ipRangesOverlap(final String startIp1,
> final String endIp1, final String startIp2, final String endIp2) {
>     +        final long startIp1Long = ip2Long(startIp1);
>              long endIp1Long = startIp1Long;
>              if (endIp1 != null) {
>                  endIp1Long = ip2Long(endIp1);
>              }
>     -        long startIp2Long = ip2Long(startIp2);
>     +        final long startIp2Long = ip2Long(startIp2);
>              long endIp2Long = startIp2Long;
>              if (endIp2 != null) {
>                  endIp2Long = ip2Long(endIp2);
>              }
>
>     +        // check if the gatewayip is the part of the ip range being
> added.
>     +        // RFC 3021 - 31-Bit Prefixes on IPv4 Point-to-Point Links
>     +        //     GW              Netmask         Stat IP        End IP
>     +        // 192.168.24.0 - 255.255.255.254 - 192.168.24.0 -
> 192.168.24.1
>     +        // https://tools.ietf.org/html/rfc3021
>     +        // Added by Wilder Rodrigues
>     +        final int ip31bitPrefixOffSet = 1;
>     +        if (startIp2Long - startIp1Long == startIp2Long - (endIp1Long
> - ip31bitPrefixOffSet)) {
>     --- End diff --
>
>     Nope, it's not. You should check the configurationImpl and see how the
> checks are done separately
>
>     Or then look at the chat last night. The iPOverlaps method doens't
> check cidr, as I said before. It checks that there are only 2 ips in the
> range
>
>     Why that? Because the conditions and all the ConfigurationImpl are
> doing the job in many steps
>
>     We can discuss it further on Tuesday.
>
>     Sent from my iPhone
>
>     On 23 May 2015, at 11:09, Daan Hoogland <notifications@github.com
> <ma...@github.com>> wrote:
>
>
>     In utils/src/com/cloud/utils/net/NetUtils.java<
> https://github.com/apache/cloudstack/pull/292#discussion_r30943403>:
>
>     >          long endIp2Long = startIp2Long;
>     >          if (endIp2 != null) {
>     >              endIp2Long = ip2Long(endIp2);
>     >          }
>     >
>     > +        // check if the gatewayip is the part of the ip range being
> added.
>     > +        // RFC 3021 - 31-Bit Prefixes on IPv4 Point-to-Point Links
>     > +        //     GW              Netmask         Stat IP        End IP
>     > +        // 192.168.24.0 - 255.255.255.254 - 192.168.24.0 -
> 192.168.24.1
>     > +        // https://tools.ietf.org/html/rfc3021
>     > +        // Added by Wilder Rodrigues
>     > +        final int ip31bitPrefixOffSet = 1;
>     > +        if (startIp2Long - startIp1Long == startIp2Long -
> (endIp1Long - ip31bitPrefixOffSet)) {
>
>
>     for any endIp1Long == startIp1Long +1 this condition is true, no
> matter what startIp2Long is let alone endIp2Long. So is it the intention to
> check (startIp1Long == endIp1Long - ip31bitPrefixOffSet) and return false
> if it is? This comes down to a check if this is indeed a /31 range and
> makes no sense to me.
>
>     —
>     Reply to this email directly or view it on GitHub<
> https://github.com/apache/cloudstack/pull/292/files#r30943403>.
>
>
>
> ---
> If your project is set up for it, you can reply to this email and have your
> reply appear on GitHub as well. If your project does not have this feature
> enabled and wishes so, or if the feature is enabled but not working, please
> contact infrastructure at infrastructure@apache.org or file a JIRA ticket
> with INFRA.
> ---
>

[GitHub] cloudstack pull request: CLOUDSTACK-8506 - Make ACS compliant with...

Posted by wilderrodrigues <gi...@git.apache.org>.
Github user wilderrodrigues commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/292#discussion_r30943691
  
    --- Diff: utils/src/com/cloud/utils/net/NetUtils.java ---
    @@ -329,35 +329,46 @@ public static String getMacAddress(InetAddress address) {
             return sb.toString();
         }
     
    -    public static long getMacAddressAsLong(InetAddress address) {
    +    public static long getMacAddressAsLong(final InetAddress address) {
             long macAddressAsLong = 0;
             try {
    -            NetworkInterface ni = NetworkInterface.getByInetAddress(address);
    -            byte[] mac = ni.getHardwareAddress();
    +            final NetworkInterface ni = NetworkInterface.getByInetAddress(address);
    +            final byte[] mac = ni.getHardwareAddress();
     
                 for (int i = 0; i < mac.length; i++) {
    -                macAddressAsLong |= ((long)(mac[i] & 0xff) << (mac.length - i - 1) * 8);
    +                macAddressAsLong |= (long)(mac[i] & 0xff) << (mac.length - i - 1) * 8;
                 }
     
    -        } catch (SocketException e) {
    +        } catch (final SocketException e) {
                 s_logger.error("SocketException when trying to retrieve MAC address", e);
             }
     
             return macAddressAsLong;
         }
     
    -    public static boolean ipRangesOverlap(String startIp1, String endIp1, String startIp2, String endIp2) {
    -        long startIp1Long = ip2Long(startIp1);
    +    public static boolean ipRangesOverlap(final String startIp1, final String endIp1, final String startIp2, final String endIp2) {
    +        final long startIp1Long = ip2Long(startIp1);
             long endIp1Long = startIp1Long;
             if (endIp1 != null) {
                 endIp1Long = ip2Long(endIp1);
             }
    -        long startIp2Long = ip2Long(startIp2);
    +        final long startIp2Long = ip2Long(startIp2);
             long endIp2Long = startIp2Long;
             if (endIp2 != null) {
                 endIp2Long = ip2Long(endIp2);
             }
     
    +        // check if the gatewayip is the part of the ip range being added.
    +        // RFC 3021 - 31-Bit Prefixes on IPv4 Point-to-Point Links
    +        //     GW              Netmask         Stat IP        End IP
    +        // 192.168.24.0 - 255.255.255.254 - 192.168.24.0 - 192.168.24.1
    +        // https://tools.ietf.org/html/rfc3021
    +        // Added by Wilder Rodrigues
    +        final int ip31bitPrefixOffSet = 1;
    +        if (startIp2Long - startIp1Long == startIp2Long - (endIp1Long - ip31bitPrefixOffSet)) {
    --- End diff --
    
    Nope, it's not. You should check the configurationImpl and see how the checks are done separately
    
    Or then look at the chat last night. The iPOverlaps method doens't check cidr, as I said before. It checks that there are only 2 ips in the range
    
    Why that? Because the conditions and all the ConfigurationImpl are doing the job in many steps
    
    We can discuss it further on Tuesday.
    
    Sent from my iPhone
    
    On 23 May 2015, at 11:09, Daan Hoogland <no...@github.com>> wrote:
    
    
    In utils/src/com/cloud/utils/net/NetUtils.java<https://github.com/apache/cloudstack/pull/292#discussion_r30943403>:
    
    >          long endIp2Long = startIp2Long;
    >          if (endIp2 != null) {
    >              endIp2Long = ip2Long(endIp2);
    >          }
    >
    > +        // check if the gatewayip is the part of the ip range being added.
    > +        // RFC 3021 - 31-Bit Prefixes on IPv4 Point-to-Point Links
    > +        //     GW              Netmask         Stat IP        End IP
    > +        // 192.168.24.0 - 255.255.255.254 - 192.168.24.0 - 192.168.24.1
    > +        // https://tools.ietf.org/html/rfc3021
    > +        // Added by Wilder Rodrigues
    > +        final int ip31bitPrefixOffSet = 1;
    > +        if (startIp2Long - startIp1Long == startIp2Long - (endIp1Long - ip31bitPrefixOffSet)) {
    
    
    for any endIp1Long == startIp1Long +1 this condition is true, no matter what startIp2Long is let alone endIp2Long. So is it the intention to check (startIp1Long == endIp1Long - ip31bitPrefixOffSet) and return false if it is? This comes down to a check if this is indeed a /31 range and makes no sense to me.
    
    —
    Reply to this email directly or view it on GitHub<https://github.com/apache/cloudstack/pull/292/files#r30943403>.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-8506 - Make ACS compliant with...

Posted by DaanHoogland <gi...@git.apache.org>.
Github user DaanHoogland commented on the pull request:

    https://github.com/apache/cloudstack/pull/292#issuecomment-104865612
  
    hard to review this, @wilderrodrigues I made one comment on the logic.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-8506 - Make ACS compliant with...

Posted by wilderrodrigues <gi...@git.apache.org>.
Github user wilderrodrigues commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/292#discussion_r30943304
  
    --- Diff: utils/src/com/cloud/utils/net/NetUtils.java ---
    @@ -329,35 +329,46 @@ public static String getMacAddress(InetAddress address) {
             return sb.toString();
         }
     
    -    public static long getMacAddressAsLong(InetAddress address) {
    +    public static long getMacAddressAsLong(final InetAddress address) {
             long macAddressAsLong = 0;
             try {
    -            NetworkInterface ni = NetworkInterface.getByInetAddress(address);
    -            byte[] mac = ni.getHardwareAddress();
    +            final NetworkInterface ni = NetworkInterface.getByInetAddress(address);
    +            final byte[] mac = ni.getHardwareAddress();
     
                 for (int i = 0; i < mac.length; i++) {
    -                macAddressAsLong |= ((long)(mac[i] & 0xff) << (mac.length - i - 1) * 8);
    +                macAddressAsLong |= (long)(mac[i] & 0xff) << (mac.length - i - 1) * 8;
                 }
     
    -        } catch (SocketException e) {
    +        } catch (final SocketException e) {
                 s_logger.error("SocketException when trying to retrieve MAC address", e);
             }
     
             return macAddressAsLong;
         }
     
    -    public static boolean ipRangesOverlap(String startIp1, String endIp1, String startIp2, String endIp2) {
    -        long startIp1Long = ip2Long(startIp1);
    +    public static boolean ipRangesOverlap(final String startIp1, final String endIp1, final String startIp2, final String endIp2) {
    +        final long startIp1Long = ip2Long(startIp1);
             long endIp1Long = startIp1Long;
             if (endIp1 != null) {
                 endIp1Long = ip2Long(endIp1);
             }
    -        long startIp2Long = ip2Long(startIp2);
    +        final long startIp2Long = ip2Long(startIp2);
             long endIp2Long = startIp2Long;
             if (endIp2 != null) {
                 endIp2Long = ip2Long(endIp2);
             }
     
    +        // check if the gatewayip is the part of the ip range being added.
    +        // RFC 3021 - 31-Bit Prefixes on IPv4 Point-to-Point Links
    +        //     GW              Netmask         Stat IP        End IP
    +        // 192.168.24.0 - 255.255.255.254 - 192.168.24.0 - 192.168.24.1
    +        // https://tools.ietf.org/html/rfc3021
    +        // Added by Wilder Rodrigues
    +        final int ip31bitPrefixOffSet = 1;
    +        if (startIp2Long - startIp1Long == startIp2Long - (endIp1Long - ip31bitPrefixOffSet)) {
    --- End diff --
    
    No. It doesn't because the isIpWithtInCidrRange() is checked before, in the ConfigurationManagerImpl.
    
    As you can see, the method you commented on doesn't check the CIDR.
    



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-8506 - Make ACS compliant with...

Posted by wilderrodrigues <gi...@git.apache.org>.
Github user wilderrodrigues commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/292#discussion_r30943291
  
    --- Diff: server/src/com/cloud/configuration/ConfigurationManagerImpl.java ---
    @@ -3556,6 +3556,11 @@ private void checkPublicIpRangeErrors(long zoneId, String vlanId, String vlanGat
                 throw new InvalidParameterValueException("Please ensure that your end IP is in the same subnet as your IP range's gateway, as per the IP range's netmask.");
             }
             // check if the gatewayip is the part of the ip range being added.
    +        // RFC 3021 - 31-Bit Prefixes on IPv4 Point-to-Point Links
    --- End diff --
    
    I talked to Remi yesterday and we agreed that would be nice to comment on the code so people don't remove the functionality by mistake or at least will make sure it still works if changes are made.
    
    By fixing the bug CLOUDSTACK-4811 on October 2013, it made the /31 not work anymore.
    
    The comment causes no harm.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-8506 - Make ACS compliant with...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/cloudstack/pull/292


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-8506 - Make ACS compliant with...

Posted by DaanHoogland <gi...@git.apache.org>.
Github user DaanHoogland commented on the pull request:

    https://github.com/apache/cloudstack/pull/292#issuecomment-104871936
  
    the pr contains a lot of added final keywords, more then actual code.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-8506 - Make ACS compliant with...

Posted by wilderrodrigues <gi...@git.apache.org>.
Github user wilderrodrigues commented on the pull request:

    https://github.com/apache/cloudstack/pull/292#issuecomment-104872293
  
    Ah, indeed.
    
    There is the logic you mentioned in the previous comment and 1 added call to NetUtils.isIpWithtInCidrRange() line 1509 which is:
    
    subnetUtils.setInclusiveHostCount(true);
    
    I discussed with Remi yesterday on Slack.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-8506 - Make ACS compliant with...

Posted by DaanHoogland <gi...@git.apache.org>.
Github user DaanHoogland commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/292#discussion_r30943403
  
    --- Diff: utils/src/com/cloud/utils/net/NetUtils.java ---
    @@ -329,35 +329,46 @@ public static String getMacAddress(InetAddress address) {
             return sb.toString();
         }
     
    -    public static long getMacAddressAsLong(InetAddress address) {
    +    public static long getMacAddressAsLong(final InetAddress address) {
             long macAddressAsLong = 0;
             try {
    -            NetworkInterface ni = NetworkInterface.getByInetAddress(address);
    -            byte[] mac = ni.getHardwareAddress();
    +            final NetworkInterface ni = NetworkInterface.getByInetAddress(address);
    +            final byte[] mac = ni.getHardwareAddress();
     
                 for (int i = 0; i < mac.length; i++) {
    -                macAddressAsLong |= ((long)(mac[i] & 0xff) << (mac.length - i - 1) * 8);
    +                macAddressAsLong |= (long)(mac[i] & 0xff) << (mac.length - i - 1) * 8;
                 }
     
    -        } catch (SocketException e) {
    +        } catch (final SocketException e) {
                 s_logger.error("SocketException when trying to retrieve MAC address", e);
             }
     
             return macAddressAsLong;
         }
     
    -    public static boolean ipRangesOverlap(String startIp1, String endIp1, String startIp2, String endIp2) {
    -        long startIp1Long = ip2Long(startIp1);
    +    public static boolean ipRangesOverlap(final String startIp1, final String endIp1, final String startIp2, final String endIp2) {
    +        final long startIp1Long = ip2Long(startIp1);
             long endIp1Long = startIp1Long;
             if (endIp1 != null) {
                 endIp1Long = ip2Long(endIp1);
             }
    -        long startIp2Long = ip2Long(startIp2);
    +        final long startIp2Long = ip2Long(startIp2);
             long endIp2Long = startIp2Long;
             if (endIp2 != null) {
                 endIp2Long = ip2Long(endIp2);
             }
     
    +        // check if the gatewayip is the part of the ip range being added.
    +        // RFC 3021 - 31-Bit Prefixes on IPv4 Point-to-Point Links
    +        //     GW              Netmask         Stat IP        End IP
    +        // 192.168.24.0 - 255.255.255.254 - 192.168.24.0 - 192.168.24.1
    +        // https://tools.ietf.org/html/rfc3021
    +        // Added by Wilder Rodrigues
    +        final int ip31bitPrefixOffSet = 1;
    +        if (startIp2Long - startIp1Long == startIp2Long - (endIp1Long - ip31bitPrefixOffSet)) {
    --- End diff --
    
    for any endIp1Long == startIp1Long +1 this condition is true, no matter what startIp2Long is let alone endIp2Long. So is it the intention to check (startIp1Long == endIp1Long - ip31bitPrefixOffSet) and return false if it is? This comes down to a check if this is indeed a /31 range and makes no sense to me.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-8506 - Make ACS compliant with...

Posted by DaanHoogland <gi...@git.apache.org>.
Github user DaanHoogland commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/292#discussion_r30943135
  
    --- Diff: utils/src/com/cloud/utils/net/NetUtils.java ---
    @@ -329,35 +329,46 @@ public static String getMacAddress(InetAddress address) {
             return sb.toString();
         }
     
    -    public static long getMacAddressAsLong(InetAddress address) {
    +    public static long getMacAddressAsLong(final InetAddress address) {
             long macAddressAsLong = 0;
             try {
    -            NetworkInterface ni = NetworkInterface.getByInetAddress(address);
    -            byte[] mac = ni.getHardwareAddress();
    +            final NetworkInterface ni = NetworkInterface.getByInetAddress(address);
    +            final byte[] mac = ni.getHardwareAddress();
     
                 for (int i = 0; i < mac.length; i++) {
    -                macAddressAsLong |= ((long)(mac[i] & 0xff) << (mac.length - i - 1) * 8);
    +                macAddressAsLong |= (long)(mac[i] & 0xff) << (mac.length - i - 1) * 8;
                 }
     
    -        } catch (SocketException e) {
    +        } catch (final SocketException e) {
                 s_logger.error("SocketException when trying to retrieve MAC address", e);
             }
     
             return macAddressAsLong;
         }
     
    -    public static boolean ipRangesOverlap(String startIp1, String endIp1, String startIp2, String endIp2) {
    -        long startIp1Long = ip2Long(startIp1);
    +    public static boolean ipRangesOverlap(final String startIp1, final String endIp1, final String startIp2, final String endIp2) {
    +        final long startIp1Long = ip2Long(startIp1);
             long endIp1Long = startIp1Long;
             if (endIp1 != null) {
                 endIp1Long = ip2Long(endIp1);
             }
    -        long startIp2Long = ip2Long(startIp2);
    +        final long startIp2Long = ip2Long(startIp2);
             long endIp2Long = startIp2Long;
             if (endIp2 != null) {
                 endIp2Long = ip2Long(endIp2);
             }
     
    +        // check if the gatewayip is the part of the ip range being added.
    +        // RFC 3021 - 31-Bit Prefixes on IPv4 Point-to-Point Links
    +        //     GW              Netmask         Stat IP        End IP
    +        // 192.168.24.0 - 255.255.255.254 - 192.168.24.0 - 192.168.24.1
    +        // https://tools.ietf.org/html/rfc3021
    +        // Added by Wilder Rodrigues
    +        final int ip31bitPrefixOffSet = 1;
    +        if (startIp2Long - startIp1Long == startIp2Long - (endIp1Long - ip31bitPrefixOffSet)) {
    --- End diff --
    
    isn't this condition true for all range2 with any /31 range1?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: CLOUDSTACK-8506 - Make ACS compliant with...

Posted by DaanHoogland <gi...@git.apache.org>.
Github user DaanHoogland commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/292#discussion_r30943140
  
    --- Diff: server/src/com/cloud/configuration/ConfigurationManagerImpl.java ---
    @@ -3556,6 +3556,11 @@ private void checkPublicIpRangeErrors(long zoneId, String vlanId, String vlanGat
                 throw new InvalidParameterValueException("Please ensure that your end IP is in the same subnet as your IP range's gateway, as per the IP range's netmask.");
             }
             // check if the gatewayip is the part of the ip range being added.
    +        // RFC 3021 - 31-Bit Prefixes on IPv4 Point-to-Point Links
    --- End diff --
    
    why is this comment added here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---