BUG-4827: BGP Add path Ipv6 ribSupport 69/37669/8
authorClaudio D. Gasparini <cgaspari@cisco.com>
Fri, 15 Apr 2016 10:55:35 +0000 (12:55 +0200)
committerMilos Fabian <milfabia@cisco.com>
Wed, 27 Apr 2016 09:09:37 +0000 (09:09 +0000)
BGP Add path support for Ipv6 extension

Change-Id: I913097608e4f9ea62aca0820b53bbd67dce64dd9
Signed-off-by: Claudio D. Gasparini <cgaspari@cisco.com>
bgp/inet/src/main/yang/bgp-inet.yang
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AdvertizedRoutesSerializer.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/Ipv6NlriParser.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/WithdrawnRoutesSerializer.java
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/PathIdUtil.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/IPv4RIBSupport.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/IPv6RIBSupport.java
bgp/topology-provider/src/test/java/org/opendaylight/bgpcep/bgp/topology/provider/Ipv4ReachabilityTopologyBuilderTest.java
bgp/topology-provider/src/test/java/org/opendaylight/bgpcep/bgp/topology/provider/Ipv6ReachabilityTopologyBuilderTest.java

index a6c1207e21c7ad841107caeb17ed08e2c9d9d463..a429ad379e4224dfb8107f146430bcf903551a8e 100644 (file)
@@ -39,6 +39,7 @@ module bgp-inet {
         leaf prefix {
             type inet:ipv6-prefix;
         }
+        uses bgp-msg:path-id-grouping;
     }
 
     grouping ipv4-prefixes {
@@ -84,7 +85,7 @@ module bgp-inet {
             list ipv6-route {
                 uses ipv6-prefix;
 
-                key prefix;
+                key "prefix path-id";
 
                 uses bgp-rib:route {
                     augment "attributes/bgp-prefix-sid/bgp-prefix-sid-tlvs/bgp-prefix-sid-tlv" {
index fad07e96732e7726d92a34182a3176f5cd89b90c..60b7f551c3ed3124c85d12f39bc747962b72e994 100644 (file)
@@ -45,6 +45,7 @@ public class AdvertizedRoutesSerializer implements NlriSerializer {
         } else if (routes.getDestinationType() instanceof DestinationIpv6Case) {
             final DestinationIpv6Case destinationIpv6Case = (DestinationIpv6Case) routes.getDestinationType();
             for (final Ipv6Prefixes ipv6Prefix : destinationIpv6Case.getDestinationIpv6().getIpv6Prefixes()) {
+                PathIdUtil.writePathId(ipv6Prefix.getPathId(), byteAggregator);
                 ByteBufWriteUtil.writeMinimalPrefix(ipv6Prefix.getPrefix(), byteAggregator);
             }
         }
index 858e1537f2921e21a65220fdd8d78ad6b5450eb0..6549a5219c3900f42727a0b91d1f0a2f6d2a27b5 100644 (file)
@@ -10,11 +10,15 @@ package org.opendaylight.protocol.bgp.parser.impl.message.update;
 import io.netty.buffer.ByteBuf;
 import java.util.ArrayList;
 import java.util.List;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
+import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
+import org.opendaylight.protocol.bgp.parser.spi.MultiPathSupportUtil;
 import org.opendaylight.protocol.bgp.parser.spi.NlriParser;
-import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
+import org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint;
 import org.opendaylight.protocol.util.Ipv6Util;
-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.inet.rev150305.ipv6.prefixes.DestinationIpv6;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv6.prefixes.DestinationIpv6Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv6.prefixes.destination.ipv6.Ipv6Prefixes;
@@ -24,26 +28,46 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mult
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpUnreachNlriBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily;
 
 public final class Ipv6NlriParser implements NlriParser {
 
-    private static DestinationIpv6 prefixes(final ByteBuf nlri) {
-        final List<Ipv6Prefix> prefs = Ipv6Util.prefixListForBytes(ByteArray.readAllBytes(nlri));
-        final List<Ipv6Prefixes> prefixes = new ArrayList<>(prefs.size());
-        for (final Ipv6Prefix p : prefs) {
-            prefixes.add(new Ipv6PrefixesBuilder().setPrefix(p).build());
+    private static DestinationIpv6 prefixes(final ByteBuf nlri, final PeerSpecificParserConstraint constraint,
+        final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi) {
+        final List<Ipv6Prefixes> prefixes = new ArrayList<>();
+        final boolean supported = MultiPathSupportUtil.isTableTypeSupported(constraint, new BgpTableTypeImpl(afi, safi));
+        while (nlri.isReadable()) {
+            final Ipv6PrefixesBuilder prefixesBuilder = new Ipv6PrefixesBuilder();
+            if (supported) {
+                prefixesBuilder.setPathId(PathIdUtil.readPathId(nlri));
+            }
+            prefixesBuilder.setPrefix(Ipv6Util.prefixForByteBuf(nlri));
+            prefixes.add(prefixesBuilder.build());
         }
         return new DestinationIpv6Builder().setIpv6Prefixes(prefixes).build();
     }
 
     @Override
-    public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder) {
-        builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6CaseBuilder().setDestinationIpv6(
-            prefixes(nlri)).build()).build());
+    public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder) throws BGPParsingException {
+        parseNlri(nlri, builder, null);
     }
 
     @Override
     public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder) throws BGPParsingException {
-        builder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv6CaseBuilder().setDestinationIpv6(prefixes(nlri)).build()).build());
+        parseNlri(nlri, builder, null);
+    }
+
+    @Override
+    public void parseNlri(@Nonnull final ByteBuf nlri, @Nonnull final MpReachNlriBuilder builder,
+        @Nullable final PeerSpecificParserConstraint constraint) throws BGPParsingException {
+        builder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv6CaseBuilder().
+            setDestinationIpv6(prefixes(nlri, constraint, builder.getAfi(), builder.getSafi())).build()).build());
+    }
+
+    @Override
+    public void parseNlri(@Nonnull final ByteBuf nlri, @Nonnull final MpUnreachNlriBuilder builder, @Nullable final PeerSpecificParserConstraint constraint) throws BGPParsingException {
+        builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6CaseBuilder().setDestinationIpv6(
+            prefixes(nlri, constraint, builder.getAfi(), builder.getSafi())).build()).build());
     }
 }
\ No newline at end of file
index bc9855f5151770e559bf96e51a5e3416cf49338d..706fc4c45c29829f87b05b9dd05c27c03982b36a 100644 (file)
@@ -54,6 +54,7 @@ public class WithdrawnRoutesSerializer implements NlriSerializer {
             final DestinationIpv6Case destinationIpv6Case = (DestinationIpv6Case) routes.getDestinationType();
             if (destinationIpv6Case.getDestinationIpv6().getIpv6Prefixes() != null) {
                 for (final Ipv6Prefixes ipv6Prefix : destinationIpv6Case.getDestinationIpv6().getIpv6Prefixes()) {
+                    PathIdUtil.writePathId(ipv6Prefix.getPathId(), byteAggregator);
                     ByteBufWriteUtil.writeMinimalPrefix(ipv6Prefix.getPrefix(), byteAggregator);
                 }
             }
index ae1c80f016c6ffdaf4ca1127b8bf95a7fb7ce1ff..76e4d61a6a3f067d6baab06283d730abd7a681e1 100644 (file)
@@ -9,11 +9,16 @@
 package org.opendaylight.protocol.bgp.parser.spi;
 
 import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableMap;
 import io.netty.buffer.ByteBuf;
 import javax.annotation.Nullable;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.PathId;
+import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
 
@@ -50,7 +55,7 @@ public final class PathIdUtil {
     /**
      * Extract PathId from route change received
      *
-     * @param data
+     * @param data Data containing the path Id
      * @param pathNii Path Id NodeIdentifier specific per each Rib support
      * @return The path identifier from data change, in case its not provided or supported return null
      */
@@ -62,4 +67,34 @@ public final class PathIdUtil {
         }
         return (Long) pathId.getValue();
     }
+
+    /**
+     * Create a Add Path PathArgument Key(prefix+pathId)
+     *
+     * @param pathId Path Id value
+     * @param routeId Route Id value
+     * @param routeQname route QName provided per each RibSupport
+     * @param pathidQname Path Id QName provided per each RibSupport
+     * @param prefixQname Prefix QName provided per each RibSupport
+     * @return
+     */
+    public static PathArgument createNiiKey(final long pathId, final PathArgument routeId, final QName routeQname, final QName pathidQname,
+        final QName prefixQname) {
+        final String prefix = (String) (((NodeIdentifierWithPredicates) routeId).getKeyValues()).get(prefixQname);
+        final ImmutableMap<QName, Object> keyValues = ImmutableMap.of(pathidQname, pathId, prefixQname, prefix);
+
+        return new NodeIdentifierWithPredicates(routeQname, keyValues);
+    }
+
+    /**
+     * Build Path Id
+     *
+     * @param routesCont route container
+     * @param pathIdNii path Id node Identifier
+     * @return PathId or null in case is not the container
+     */
+    public static PathId buildPathId(final DataContainerNode<? extends PathArgument> routesCont, final NodeIdentifier pathIdNii) {
+        final Long pathIdVal = PathIdUtil.extractPathId(routesCont, pathIdNii);
+        return pathIdVal == null ? null : new PathId(pathIdVal);
+    }
 }
index 6fa1f826fc73987d2df12799c48941ada0f7bc7d..777ad4d13ea17ce4b0143b8c2d48dbb952bdbf28 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.protocol.bgp.rib.impl;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableCollection;
-import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -25,7 +24,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.Ipv4Routes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.ipv4.routes.Ipv4Route;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4CaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.PathId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpReachNlri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpReachNlriBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpUnreachNlri;
@@ -39,7 +37,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
@@ -56,7 +53,7 @@ final class IPv4RIBSupport extends AbstractIPRIBSupport {
     private static final QName PATHID_QNAME = QName.create(Ipv4Route.QNAME, "path-id").intern();
     private static final IPv4RIBSupport SINGLETON = new IPv4RIBSupport();
     private static final ImmutableCollection<Class<? extends DataObject>> CACHEABLE_NLRI_OBJECTS =
-            ImmutableSet.<Class<? extends DataObject>>of(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.Ipv4Prefix.class);
+            ImmutableSet.of(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.Ipv4Prefix.class);
     private final ChoiceNode emptyRoutes = Builders.choiceBuilder()
             .withNodeIdentifier(new NodeIdentifier(Routes.QNAME))
             .addChild(Builders.containerBuilder()
@@ -119,10 +116,7 @@ final class IPv4RIBSupport extends AbstractIPRIBSupport {
     @Nonnull
     @Override
     public PathArgument getRouteIdAddPath(final long pathId, final PathArgument routeId) {
-        final String prefix = (String) (((NodeIdentifierWithPredicates) routeId).getKeyValues()).get(PREFIX_QNAME);
-        final ImmutableMap<QName, Object> keyValues = ImmutableMap.of(PATHID_QNAME, pathId, PREFIX_QNAME, prefix);
-
-        return new NodeIdentifierWithPredicates(Ipv4Route.QNAME, keyValues);
+        return PathIdUtil.createNiiKey(pathId, routeId, Ipv4Route.QNAME, PATHID_QNAME, PREFIX_QNAME);
     }
 
     @Override
@@ -135,7 +129,7 @@ final class IPv4RIBSupport extends AbstractIPRIBSupport {
         for (final MapEntryNode route : routes) {
             final String prefix = (String) route.getChild(this.routeKeyLeaf).get().getValue();
             final Ipv4PrefixesBuilder prefixBuilder = new Ipv4PrefixesBuilder().setPrefix(new Ipv4Prefix(prefix));
-            prefixBuilder.setPathId(new PathId(PathIdUtil.extractPathId(route, PATH_ID_LEAF)));
+            prefixBuilder.setPathId(PathIdUtil.buildPathId(route, PATH_ID_LEAF));
             prefs.add(prefixBuilder.build());
         }
         return prefs;
index 902eba570c7a714f5f4705bdc0817b6a97ca1b6a..a6f55642475515760ccfe7a04c4ef5f984c15eeb 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.collect.ImmutableSet;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
 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.inet.rev150305.bgp.rib.rib.loc.rib.tables.routes.Ipv6RoutesCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv6.prefixes.DestinationIpv6;
@@ -46,16 +47,14 @@ final class IPv6RIBSupport extends AbstractIPRIBSupport {
     private static final QName PREFIX_QNAME = QName.create(Ipv6Route.QNAME, "prefix").intern();
     private static final IPv6RIBSupport SINGLETON = new IPv6RIBSupport();
     private static final ImmutableCollection<Class<? extends DataObject>> CACHEABLE_NLRI_OBJECTS =
-            ImmutableSet.<Class<? extends DataObject>>of(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.Ipv6Prefix.class);
-    private final ChoiceNode emptyRoutes = Builders.choiceBuilder()
-            .withNodeIdentifier(new NodeIdentifier(Routes.QNAME))
-            .addChild(Builders.containerBuilder()
-                .withNodeIdentifier(new NodeIdentifier(Ipv6Routes.QNAME))
-                .withChild(ImmutableNodes.mapNodeBuilder(Ipv6Route.QNAME).build()).build()).build();
-    private final NodeIdentifier destination = new NodeIdentifier(DestinationIpv6.QNAME);
-    private final NodeIdentifier route = new NodeIdentifier(Ipv6Route.QNAME);
-    private final NodeIdentifier nlriRoutesList = new NodeIdentifier(Ipv6Prefixes.QNAME);
-    private final NodeIdentifier routeKeyLeaf = new NodeIdentifier(PREFIX_QNAME);
+        ImmutableSet.of(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.Ipv6Prefix.class);
+    private static final ChoiceNode EMPTY_ROUTES = Builders.choiceBuilder().withNodeIdentifier(new NodeIdentifier(Routes.QNAME))
+        .addChild(Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(Ipv6Routes.QNAME)).withChild(ImmutableNodes
+            .mapNodeBuilder(Ipv6Route.QNAME).build()).build()).build();
+    private static final NodeIdentifier DESTINATION = new NodeIdentifier(DestinationIpv6.QNAME);
+    private static final NodeIdentifier ROUTE = new NodeIdentifier(Ipv6Route.QNAME);
+    private static final NodeIdentifier NLRI_ROUTES_LIST = new NodeIdentifier(Ipv6Prefixes.QNAME);
+    private static final NodeIdentifier PATH_ID_LEAF = new NodeIdentifier(PREFIX_QNAME);
 
     private IPv6RIBSupport() {
         super(Ipv6RoutesCase.class, Ipv6Routes.class, Ipv6Route.class);
@@ -67,27 +66,55 @@ final class IPv6RIBSupport extends AbstractIPRIBSupport {
 
     @Override
     public ChoiceNode emptyRoutes() {
-        return this.emptyRoutes;
+        return EMPTY_ROUTES;
+    }
+
+    @Override
+    public ImmutableCollection<Class<? extends DataObject>> cacheableNlriObjects() {
+        return CACHEABLE_NLRI_OBJECTS;
     }
 
     @Override
     protected NodeIdentifier destinationContainerIdentifier() {
-        return this.destination;
+        return DESTINATION;
     }
 
     @Override
-    protected NodeIdentifier routeIdentifier() {
-        return this.route;
+    protected MpReachNlri buildReach(final Collection<MapEntryNode> routes, final CNextHop hop) {
+        final MpReachNlriBuilder mb = new MpReachNlriBuilder();
+        mb.setAfi(Ipv6AddressFamily.class);
+        mb.setSafi(UnicastSubsequentAddressFamily.class);
+        mb.setCNextHop(hop);
+        mb.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
+            new DestinationIpv6CaseBuilder().setDestinationIpv6(
+                new DestinationIpv6Builder().setIpv6Prefixes(extractPrefixes(routes)).build()).build()).build());
+        return mb.build();
     }
 
     @Override
-    protected NodeIdentifier routeKeyLeafIdentifier() {
-        return this.routeKeyLeaf;
+    protected MpUnreachNlri buildUnreach(final Collection<MapEntryNode> routes) {
+        final MpUnreachNlriBuilder mb = new MpUnreachNlriBuilder();
+        mb.setAfi(Ipv6AddressFamily.class);
+        mb.setSafi(UnicastSubsequentAddressFamily.class);
+        mb.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
+            new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6CaseBuilder().setDestinationIpv6(
+                new DestinationIpv6Builder().setIpv6Prefixes(extractPrefixes(routes)).build()).build()).build());
+        return mb.build();
+    }
+
+    @Override
+    protected NodeIdentifier routeIdentifier() {
+        return ROUTE;
     }
 
     @Override
     protected NodeIdentifier nlriRoutesListIdentifier() {
-        return this.nlriRoutesList;
+        return NLRI_ROUTES_LIST;
+    }
+
+    @Override
+    protected NodeIdentifier routeKeyLeafIdentifier() {
+        return PATH_ID_LEAF;
     }
 
     @Override
@@ -100,40 +127,12 @@ final class IPv6RIBSupport extends AbstractIPRIBSupport {
         return Ipv6Route.QNAME;
     }
 
-    @Override
-    public ImmutableCollection<Class<? extends DataObject>> cacheableNlriObjects() {
-        return CACHEABLE_NLRI_OBJECTS;
-    }
-
     private List<Ipv6Prefixes> extractPrefixes(final Collection<MapEntryNode> routes) {
         final List<Ipv6Prefixes> prefs = new ArrayList<>(routes.size());
         for (final MapEntryNode ipv6Route : routes) {
-            final String prefix = (String) ipv6Route.getChild(this.routeKeyLeaf).get().getValue();
-            prefs.add(new Ipv6PrefixesBuilder().setPrefix(new Ipv6Prefix(prefix)).build());
+            final String prefix = (String) ipv6Route.getChild(PATH_ID_LEAF).get().getValue();
+            prefs.add(new Ipv6PrefixesBuilder().setPathId(PathIdUtil.buildPathId(ipv6Route, PATH_ID_LEAF)).setPrefix(new Ipv6Prefix(prefix)).build());
         }
         return prefs;
     }
-
-    @Override
-    protected MpReachNlri buildReach(final Collection<MapEntryNode> routes, final CNextHop hop) {
-        final MpReachNlriBuilder mb = new MpReachNlriBuilder();
-        mb.setAfi(Ipv6AddressFamily.class);
-        mb.setSafi(UnicastSubsequentAddressFamily.class);
-        mb.setCNextHop(hop);
-        mb.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
-            new DestinationIpv6CaseBuilder().setDestinationIpv6(
-                new DestinationIpv6Builder().setIpv6Prefixes(extractPrefixes(routes)).build()).build()).build());
-        return mb.build();
-    }
-
-    @Override
-    protected MpUnreachNlri buildUnreach(final Collection<MapEntryNode> routes) {
-        final MpUnreachNlriBuilder mb = new MpUnreachNlriBuilder();
-        mb.setAfi(Ipv6AddressFamily.class);
-        mb.setSafi(UnicastSubsequentAddressFamily.class);
-        mb.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
-            new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6CaseBuilder().setDestinationIpv6(
-                new DestinationIpv6Builder().setIpv6Prefixes(extractPrefixes(routes)).build()).build()).build());
-        return mb.build();
-    }
 }
index 08acbe61b08910fbfac49b4cec52a1ee5cbcec8e..cb4ab8057ce5c0a3348fd64c741b9976b60d1a01 100644 (file)
@@ -39,8 +39,8 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public class Ipv4ReachabilityTopologyBuilderTest extends AbstractTopologyBuilderTest {
 
+    static final long PATH_ID = 1;
     private static final String ROUTE_IP4PREFIX = "127.1.0.0/32";
-    private static final long ROUTE_IP4PATH_ID = 1;
     private static final String NEXT_HOP = "127.1.0.1";
     private static final String NEW_NEXT_HOP = "127.1.0.2";
 
@@ -53,7 +53,7 @@ public class Ipv4ReachabilityTopologyBuilderTest extends AbstractTopologyBuilder
         this.ipv4TopoBuilder = new Ipv4ReachabilityTopologyBuilder(dataBroker, LOC_RIB_REF, TEST_TOPOLOGY_ID);
         this.ipv4TopoBuilder.start(dataBroker, Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
         final InstanceIdentifier<Tables> path = this.ipv4TopoBuilder.tableInstanceIdentifier(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
-        this.ipv4RouteIID = path.builder().child((Class)Ipv4Routes.class).child(Ipv4Route.class, new Ipv4RouteKey(new PathId(ROUTE_IP4PATH_ID),
+        this.ipv4RouteIID = path.builder().child((Class) Ipv4Routes.class).child(Ipv4Route.class, new Ipv4RouteKey(new PathId(PATH_ID),
             new Ipv4Prefix(ROUTE_IP4PREFIX))).build();
     }
 
@@ -98,7 +98,7 @@ public class Ipv4ReachabilityTopologyBuilderTest extends AbstractTopologyBuilder
         final Attributes attribute = new AttributesBuilder()
             .setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address(nextHop)).build()).build())
             .build();
-        return new Ipv4RouteBuilder().setKey(new Ipv4RouteKey(new PathId(ROUTE_IP4PATH_ID), new Ipv4Prefix(ROUTE_IP4PREFIX)))
+        return new Ipv4RouteBuilder().setKey(new Ipv4RouteKey(new PathId(PATH_ID), new Ipv4Prefix(ROUTE_IP4PREFIX)))
             .setPrefix(new Ipv4Prefix(ROUTE_IP4PREFIX)).setAttributes(attribute).build();
     }
 
index 3975fa7f0c08ced757a1ede0e7a2b61ca4a26a32..c1cd6e1f37ddc351cbaa583eea6c67406accb8b8 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.bgpcep.bgp.topology.provider;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.opendaylight.bgpcep.bgp.topology.provider.Ipv4ReachabilityTopologyBuilderTest.PATH_ID;
 
 import com.google.common.base.Optional;
 import org.junit.Test;
@@ -24,6 +25,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv6.routes.ipv6.routes.Ipv6Route;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv6.routes.ipv6.routes.Ipv6RouteBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv6.routes.ipv6.routes.Ipv6RouteKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.PathId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Attributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.AttributesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.Tables;
@@ -51,7 +53,8 @@ public class Ipv6ReachabilityTopologyBuilderTest extends AbstractTopologyBuilder
         this.ipv6TopoBuilder = new Ipv6ReachabilityTopologyBuilder(dataBroker, LOC_RIB_REF, TEST_TOPOLOGY_ID);
         this.ipv6TopoBuilder.start(dataBroker, Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class);
         final InstanceIdentifier<Tables> path = this.ipv6TopoBuilder.tableInstanceIdentifier(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class);
-        this.ipv6RouteIID = path.builder().child((Class)Ipv6Routes.class).child(Ipv6Route.class, new Ipv6RouteKey(new Ipv6Prefix(ROUTE_IP6PREFIX))).build();
+        this.ipv6RouteIID = path.builder().child((Class) Ipv6Routes.class).child(Ipv6Route.class, new Ipv6RouteKey(new PathId(PATH_ID),
+            new Ipv6Prefix(ROUTE_IP6PREFIX))).build();
     }
 
     @Test
@@ -95,6 +98,7 @@ public class Ipv6ReachabilityTopologyBuilderTest extends AbstractTopologyBuilder
         final Attributes attribute = new AttributesBuilder()
             .setCNextHop(new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder().setGlobal(new Ipv6Address(netxHop)).build()).build())
             .build();
-        return new Ipv6RouteBuilder().setKey(new Ipv6RouteKey(new Ipv6Prefix(ROUTE_IP6PREFIX))).setPrefix(new Ipv6Prefix(ROUTE_IP6PREFIX)).setAttributes(attribute).build();
+        return new Ipv6RouteBuilder().setKey(new Ipv6RouteKey(new PathId(PATH_ID), new Ipv6Prefix(ROUTE_IP6PREFIX)))
+            .setPrefix(new Ipv6Prefix(ROUTE_IP6PREFIX)).setAttributes(attribute).build();
     }
 }