From 6705a5345a93abb17a2ff4756e118f1209567da8 Mon Sep 17 00:00:00 2001 From: Dana Kutenicsova Date: Thu, 16 Oct 2014 13:17:26 +0200 Subject: [PATCH] BUG-2201 : fixed Ipv4/Ipv6 AdjRibsIn to use correct class Change-Id: Ic7b274857ee55aa7b46db0e2e114d271e33225d0 Signed-off-by: Dana Kutenicsova (cherry picked from commit 18abe5459dd86d4d402f9801f69109541a2ee7c3) --- .../bgp/parser/impl/BGPParserTest.java | 31 +++++++++++++++++++ .../protocol/bgp/rib/impl/Ipv4AdjRIBsIn.java | 3 +- .../protocol/bgp/rib/impl/Ipv6AdjRIBsIn.java | 5 ++- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/BGPParserTest.java b/bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/BGPParserTest.java index 79e200e344..46add4dc18 100644 --- a/bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/BGPParserTest.java +++ b/bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/BGPParserTest.java @@ -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 afi = message.getPathAttributes().getAugmentation(PathAttributes2.class).getMpUnreachNlri().getAfi(); + final Class 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 * diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/Ipv4AdjRIBsIn.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/Ipv4AdjRIBsIn.java index 1fdfaba7af..a0329ee94c 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/Ipv4AdjRIBsIn.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/Ipv4AdjRIBsIn.java @@ -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