Bug-5922: inbound IPv6 connection fails if address has zero groups in it 38/44638/1
authorAjay <ajayl.bro@gmail.com>
Thu, 25 Aug 2016 03:10:34 +0000 (03:10 +0000)
committerAjay <ajayl.bro@gmail.com>
Thu, 25 Aug 2016 03:14:08 +0000 (03:14 +0000)
- Convert the remote IPv6 address to normalized notation (full-form and leading 0s removed)
  so that comparision with configured BGP Peer address works
- BGP Peer address is converted to this form in BGPPeerModule#getNormalizedHost

Change-Id: I9ce0b5a925a0599e7cca52adf2ec2f2a331026c5
Signed-off-by: Ajay <ajayl.bro@gmail.com>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractBGPSessionNegotiator.java

index 4f00c9af2ef3b2747af82e77eae545884998e540..9ba191ac136616d44faf62d6f5426ecb4d82baea 100644 (file)
@@ -24,6 +24,7 @@ import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
 import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
 import org.opendaylight.protocol.bgp.rib.spi.SessionNegotiator;
+import org.opendaylight.protocol.util.Ipv6Util;
 import org.opendaylight.protocol.util.Values;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
@@ -127,7 +128,11 @@ public abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandler
     }
 
     private IpAddress getRemoteIp() {
-        return StrictBGPPeerRegistry.getIpAddress(this.channel.remoteAddress());
+        final IpAddress remoteIp = StrictBGPPeerRegistry.getIpAddress(this.channel.remoteAddress());
+        if (remoteIp.getIpv6Address() != null) {
+            return new IpAddress(Ipv6Util.getFullForm(remoteIp.getIpv6Address()));
+        }
+        return remoteIp;
     }
 
     protected synchronized void handleMessage(final Notification msg) {