BUG-2201 : fixed Ipv4/Ipv6 AdjRibsIn to use correct class 39/12039/1
authorDana Kutenicsova <dkutenic@cisco.com>
Thu, 16 Oct 2014 11:17:26 +0000 (13:17 +0200)
committerRobert Varga <rovarga@cisco.com>
Fri, 17 Oct 2014 07:12:40 +0000 (07:12 +0000)
Change-Id: Ic7b274857ee55aa7b46db0e2e114d271e33225d0
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
(cherry picked from commit 18abe5459dd86d4d402f9801f69109541a2ee7c3)

bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/BGPParserTest.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/Ipv4AdjRIBsIn.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/Ipv6AdjRIBsIn.java

index 79e200e3448a7915e6ac1f3183bd68a5e120934e..46add4dc18569f3bf770147b573e3c0d06c26e8f 100644 (file)
@@ -692,6 +692,37 @@ public class BGPParserTest {
         assertArrayEquals(inputBytes.get(6), ByteArray.readAllBytes(buffer));
     }
 
+    /*
+     * End of Rib for Ipv6 consists of empty MP_UNREACH_NLRI, with AFI 2 and SAFI 1
+     *
+     * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
+     * 00 1e <- length (29) - including header
+     * 02 <- message type
+     * 00 00 <- withdrawn routes length
+     * 00 07 <- total path attribute length
+     * 90 <- attribute flags
+     * 0f <- attribute type (15 - MP_UNREACH_NLRI)
+     * 00 03 <- attribute length
+     * 00 02 <- value (AFI 2: IPv6)
+     * 01 <- value (SAFI 1)
+     */
+    @Test
+    public void testEORIpv6exLength() throws Exception {
+        final byte[] body = ByteArray.cutBytes(inputBytes.get(6), MessageUtil.COMMON_HEADER_LENGTH);
+        final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(6), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
+        final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength);
+
+        final Class<? extends AddressFamily> afi = message.getPathAttributes().getAugmentation(PathAttributes2.class).getMpUnreachNlri().getAfi();
+        final Class<? extends SubsequentAddressFamily> safi = message.getPathAttributes().getAugmentation(PathAttributes2.class).getMpUnreachNlri().getSafi();
+
+        assertEquals(Ipv6AddressFamily.class, afi);
+        assertEquals(UnicastSubsequentAddressFamily.class, safi);
+
+        final ByteBuf buffer = Unpooled.buffer();
+        BGPParserTest.updateParser.serializeMessage(message, buffer);
+        assertArrayEquals(inputBytes.get(6), ByteArray.readAllBytes(buffer));
+    }
+
     /*
      * End of Rib for LS consists of empty MP_UNREACH_NLRI, with AFI 16388 and SAFI 71
      *
index 1fdfaba7af505cc47ccdd97cc7acd9d133020ce5..a0329ee94cdae28c33627eacca75965349941dcb 100644 (file)
@@ -14,7 +14,6 @@ import org.opendaylight.protocol.bgp.rib.spi.Peer;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.destination.destination.type.DestinationIpv4Case;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.destination.destination.type.DestinationIpv4CaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.destination.destination.type.destination.ipv4._case.DestinationIpv4;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.destination.destination.type.destination.ipv4._case.DestinationIpv4Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.path.attributes.MpReachNlri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.path.attributes.MpReachNlriBuilder;
@@ -79,7 +78,7 @@ final class Ipv4AdjRIBsIn extends AbstractAdjRIBs<Ipv4Prefix, Ipv4Route, Ipv4Rou
                 new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(
                     Lists.newArrayList(data.getPrefix())).build()).build()).build());
         } else {
-            ((DestinationIpv4) ar.getDestinationType()).getIpv4Prefixes().add(data.getPrefix());
+            ((DestinationIpv4Case) ar.getDestinationType()).getDestinationIpv4().getIpv4Prefixes().add(data.getPrefix());
         }
     }
 
index bc32ea243908248931292bf257b0b5d4436da7d1..8fe7a5c77cdb569fff55a47e599d10786c8b635e 100644 (file)
@@ -14,7 +14,6 @@ import org.opendaylight.protocol.bgp.rib.spi.Peer;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.destination.destination.type.DestinationIpv6Case;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.destination.destination.type.DestinationIpv6CaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.destination.destination.type.destination.ipv6._case.DestinationIpv6;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.destination.destination.type.destination.ipv6._case.DestinationIpv6Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.path.attributes.MpReachNlri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.path.attributes.MpReachNlriBuilder;
@@ -61,7 +60,7 @@ final class Ipv6AdjRIBsIn extends AbstractAdjRIBs<Ipv6Prefix, Ipv6Route, Ipv6Rou
 
     @Override
     public void removeRoutes(final AdjRIBsTransaction trans, final Peer peer, final MpUnreachNlri nlri) {
-        for (final Ipv6Prefix id : ((DestinationIpv6) nlri.getWithdrawnRoutes().getDestinationType()).getIpv6Prefixes()) {
+        for (final Ipv6Prefix id : ((DestinationIpv6Case) nlri.getWithdrawnRoutes().getDestinationType()).getDestinationIpv6().getIpv6Prefixes()) {
             super.remove(trans, peer, id);
         }
     }
@@ -78,7 +77,7 @@ final class Ipv6AdjRIBsIn extends AbstractAdjRIBs<Ipv6Prefix, Ipv6Route, Ipv6Rou
                 new DestinationIpv6CaseBuilder().setDestinationIpv6(new DestinationIpv6Builder().setIpv6Prefixes(
                     Lists.newArrayList(data.getPrefix())).build()).build()).build());
         } else {
-            ((DestinationIpv6) ar.getDestinationType()).getIpv6Prefixes().add(data.getPrefix());
+            ((DestinationIpv6Case) ar.getDestinationType()).getDestinationIpv6().getIpv6Prefixes().add(data.getPrefix());
         }
     }