Fix IpConversionUtil.extractIpv4AddressMask() 46/80546/11
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 22 Feb 2019 14:08:04 +0000 (15:08 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 7 Mar 2019 10:41:30 +0000 (11:41 +0100)
commite4269dfdfcc658a6ce660cd74694af2fd2791161
tree1d332a0028c275311b8ed432dbfa33a0c441a1ef
parent3b880c044da3757f1d0c581754cfaf7803fc352a
Fix IpConversionUtil.extractIpv4AddressMask()

The algorithm here is wrong when prefix length is 0, as it
returns 255.255.255.255, where it should be returning 0.0.0.0.
This turns out to be an error coming from the fact we use a long
bitmask and incorrect masks to mask out the topmost long bits.

Use an int bitmask and switch to non-sign-extending shifts, which
fixes the problem.

JIRA: OPNFLWPLUG-1063
Change-Id: Idd42ba510a3a9d2032646f07b0bde8061ecd2637
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/AddressNormalizationUtilTest.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/IpConversionUtil.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/IpConversionUtilTest.java