add check for null IP address when serializing MAC/IP advertisment route 19/41119/1
authorGiles Heron <giheron@cisco.com>
Thu, 30 Jun 2016 08:03:21 +0000 (18:03 +1000)
committerGiles Heron <giheron@cisco.com>
Thu, 30 Jun 2016 08:21:25 +0000 (18:21 +1000)
Change-Id: I4562587fd32a6d6576d7f2f59f180068d1d86282
Signed-off-by: Giles Heron <giheron@cisco.com>
bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/MACIpAdvRParser.java

index 4295769a2e3b2d9d73bdef99f8db7b037ed1ddc9..e132f58ca8afb83d6ac087eee32f60f5cf999f8c 100644 (file)
@@ -125,12 +125,16 @@ final class MACIpAdvRParser extends AbstractEvpnNlri {
 
     private static ByteBuf serializeIp(final IpAddress ipAddress) {
         final ByteBuf body = Unpooled.buffer();
-        if (ipAddress.getIpv4Address() != null) {
-            body.writeByte(Ipv4Util.IP4_BITS_LENGTH);
-            body.writeBytes(Ipv4Util.bytesForAddress(ipAddress.getIpv4Address()));
-        } else if (ipAddress.getIpv6Address() != null) {
-            body.writeByte(Ipv6Util.IPV6_BITS_LENGTH);
-            body.writeBytes(Ipv6Util.bytesForAddress(ipAddress.getIpv6Address()));
+        if (ipAddress != null) {
+            if (ipAddress.getIpv4Address() != null) {
+                body.writeByte(Ipv4Util.IP4_BITS_LENGTH);
+                body.writeBytes(Ipv4Util.bytesForAddress(ipAddress.getIpv4Address()));
+            } else if (ipAddress.getIpv6Address() != null) {
+                body.writeByte(Ipv6Util.IPV6_BITS_LENGTH);
+                body.writeBytes(Ipv6Util.bytesForAddress(ipAddress.getIpv6Address()));
+            } else {
+                body.writeZero(ZERO_BYTE);
+            }
         } else {
             body.writeZero(ZERO_BYTE);
         }