BUG-5785 Support for dissemination of L3VPN flow spec III 84/38384/22
authorKevin Wang <kevixw@gmail.com>
Mon, 2 May 2016 23:48:25 +0000 (23:48 +0000)
committerMilos Fabian <milfabia@cisco.com>
Mon, 13 Jun 2016 12:11:18 +0000 (12:11 +0000)
- Add RIB Support
- Integration

Change-Id: Iecc0908ac55cf64414a472fe1dcc5e78034090c0
Signed-off-by: Kevin Wang <kevixw@gmail.com>
14 files changed:
bgp/controller-config/src/main/resources/initial/31-bgp.xml
bgp/controller-config/src/main/resources/initial/41-bgp-example.xml
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/AbstractFlowspecNlriParser.java
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/AbstractFlowspecRIBSupport.java
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/FlowspecIpv4RIBSupport.java
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/FlowspecIpv6RIBSupport.java
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/RIBActivator.java
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/SimpleFlowspecIpv4NlriParser.java
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/SimpleFlowspecIpv6NlriParser.java
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/AbstractFlowspecL3vpnRIBSupport.java [new file with mode: 0644]
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/ipv4/FlowspecL3vpnIpv4NlriParser.java
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/ipv4/FlowspecL3vpnIpv4RIBSupport.java [new file with mode: 0644]
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/ipv6/FlowspecL3vpnIpv6NlriParser.java
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/ipv6/FlowspecL3vpnIpv6RIBSupport.java [new file with mode: 0644]

index 790ec933c7cb5b3f0dfe4785ef357e77cfafe57b..f8001836ffa0ac0f2888843bcdbc01b6c251d9fa 100644 (file)
                     <afi xmlns:bgp="urn:opendaylight:params:xml:ns:yang:bgp-types">bgp:ipv6-address-family</afi>
                     <safi xmlns:flowspec="urn:opendaylight:params:xml:ns:yang:bgp-flowspec">flowspec:flowspec-subsequent-address-family</safi>
                 </module>
+                <module>
+                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:bgp-table-type-impl</type>
+                    <name>ipv4-flowspec-l3vpn</name>
+                    <afi xmlns:bgp="urn:opendaylight:params:xml:ns:yang:bgp-types">bgp:ipv4-address-family</afi>
+                    <safi xmlns:flowspec="urn:opendaylight:params:xml:ns:yang:bgp-flowspec">flowspec:flowspec-l3vpn-subsequent-address-family</safi>
+                </module>
+                <module>
+                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:bgp-table-type-impl</type>
+                    <name>ipv6-flowspec-l3vpn</name>
+                    <afi xmlns:bgp="urn:opendaylight:params:xml:ns:yang:bgp-types">bgp:ipv6-address-family</afi>
+                    <safi xmlns:flowspec="urn:opendaylight:params:xml:ns:yang:bgp-flowspec">flowspec:flowspec-l3vpn-subsequent-address-family</safi>
+                </module>
                 <module>
                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:bgp-table-type-impl</type>
                     <name>ipv4-labeled-unicast</name>
                         <name>ipv6-flowspec</name>
                         <provider>/modules/module[type='bgp-table-type-impl'][name='ipv6-flowspec']</provider>
                     </instance>
+                    <instance>
+                        <name>ipv4-flowspec-l3vpn</name>
+                        <provider>/modules/module[type='bgp-table-type-impl'][name='ipv4-flowspec-l3vpn']</provider>
+                    </instance>
+                    <instance>
+                        <name>ipv6-flowspec-l3vpn</name>
+                        <provider>/modules/module[type='bgp-table-type-impl'][name='ipv6-flowspec-l3vpn']</provider>
+                    </instance>
                     <instance>
                         <name>ipv4-labeled-unicast</name>
                         <provider>/modules/module[type='bgp-table-type-impl'][name='ipv4-labeled-unicast']</provider>
index 74d1b8c37d9bc8a96bdc5a40c7e329d8aa2381e0..e9906a49406dc5803537b9a5b6f7606c5456b9fb 100755 (executable)
                         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:bgp-table-type</type>
                         <name>ipv6-flowspec</name>
                     </advertized-table>
+                    <advertized-table>
+                        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:bgp-table-type</type>
+                        <name>ipv4-flowspec-l3vpn</name>
+                    </advertized-table>
+                    <advertized-table>
+                        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:bgp-table-type</type>
+                        <name>ipv6-flowspec-l3vpn</name>
+                    </advertized-table>
                     <advertized-table>
                         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:bgp-table-type</type>
                         <name>ipv4-labeled-unicast</name>
                         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:bgp-table-type</type>
                         <name>ipv6-flowspec</name>
                     </local-table>
+                    <local-table>
+                        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:bgp-table-type</type>
+                        <name>ipv4-flowspec-l3vpn</name>
+                    </local-table>
+                    <local-table>
+                        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:bgp-table-type</type>
+                        <name>ipv6-flowspec-l3vpn</name>
+                    </local-table>
                     <local-table>
                         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:bgp-table-type</type>
                         <name>ipv4-labeled-unicast</name>
index 541266784bad47de95140cad14b30a379da0c878..3e9eb0d8400e41789a88ffe0b98a5ce092032265 100644 (file)
@@ -171,7 +171,7 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
      * @param pathId     associated path id with given NLRI
      * @return created destination type
      */
-    protected abstract DestinationType createWithdrawnDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId);
+    public abstract DestinationType createWithdrawnDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId);
 
     /**
      * Create advertized destination type
@@ -180,7 +180,7 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
      * @param pathId     associated path id with given NLRI
      * @return created destination type
      */
-    protected abstract DestinationType createAdvertizedRoutesDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId);
+    public abstract DestinationType createAdvertizedRoutesDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId);
 
     @Override
     public final void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
index a7a244b6f3f3960ba29e62d18dd3d460fb9b2668..76d12e441ee6c0be9f726ffaa18bcd64e02dbda5 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.protocol.bgp.flowspec;
 
 import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableCollection;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
@@ -16,12 +17,12 @@ import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
 import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
 import org.opendaylight.protocol.bgp.rib.spi.MultiPathAbstractRIBSupport;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.FlowspecSubsequentAddressFamily;
 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.destination.DestinationType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.Route;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.tables.Routes;
 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;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -30,21 +31,36 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgum
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-public abstract class AbstractFlowspecRIBSupport extends MultiPathAbstractRIBSupport {
-    protected AbstractFlowspecRIBSupport(final Class<? extends Routes> cazeClass, final Class<? extends DataObject> containerClass,
-        final Class<? extends Route> listClass, final Class<? extends AddressFamily> afiClass, final QName destinationQname) {
-        super(cazeClass, containerClass, listClass, afiClass, FlowspecSubsequentAddressFamily.class, "route-key", destinationQname);
-    }
+public abstract class AbstractFlowspecRIBSupport<T extends AbstractFlowspecNlriParser> extends MultiPathAbstractRIBSupport {
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractFlowspecRIBSupport.class);
+
+    protected final T nlriParser;
+
+    protected AbstractFlowspecRIBSupport(
+        final Class<? extends Routes> cazeClass,
+        final Class<? extends DataObject> containerClass,
+        final Class<? extends Route> listClass,
+        final Class<? extends AddressFamily> afiClass,
+        final Class<? extends SubsequentAddressFamily> safiClass,
+        final QName dstContainerClassQName,
+        final T nlriParser
+    ) {
+        super(cazeClass, containerClass, listClass, afiClass, safiClass, "route-key", dstContainerClassQName);
 
-    protected abstract AbstractFlowspecNlriParser getParser();
+        this.nlriParser = Preconditions.checkNotNull(nlriParser);
+    }
 
     @Override
+    @Nonnull
     public final ImmutableCollection<Class<? extends DataObject>> cacheableAttributeObjects() {
         return ImmutableSet.of();
     }
 
     @Override
+    @Nonnull
     public final ImmutableCollection<Class<? extends DataObject>> cacheableNlriObjects() {
         return ImmutableSet.of();
     }
@@ -59,7 +75,10 @@ public abstract class AbstractFlowspecRIBSupport extends MultiPathAbstractRIBSup
     protected DestinationType buildDestination(@Nonnull final Collection<MapEntryNode> routes) {
         final MapEntryNode routesCont = Iterables.getOnlyElement(routes);
         final PathId pathId = PathIdUtil.buildPathId(routesCont, routePathIdNid());
-        return getParser().createAdvertizedRoutesDestinationType(new Object[] {getParser().extractFlowspec(routesCont)}, pathId);
+        return this.nlriParser.createAdvertizedRoutesDestinationType(
+            new Object[] {this.nlriParser.extractFlowspec(routesCont)},
+            pathId
+        );
     }
 
     @Nonnull
@@ -67,16 +86,24 @@ public abstract class AbstractFlowspecRIBSupport extends MultiPathAbstractRIBSup
     protected DestinationType buildWithdrawnDestination(@Nonnull final Collection<MapEntryNode> routes) {
         final MapEntryNode routesCont = Iterables.getOnlyElement(routes);
         final PathId pathId = PathIdUtil.buildPathId(routesCont, routePathIdNid());
-        return getParser().createWithdrawnDestinationType(new Object[] {getParser().extractFlowspec(Iterables.getOnlyElement(routes))}, pathId);
+        return this.nlriParser.createWithdrawnDestinationType(
+            new Object[] {this.nlriParser.extractFlowspec(Iterables.getOnlyElement(routes))},
+            pathId
+        );
     }
 
     @Override
-    protected final void processDestination(final DOMDataWriteTransaction tx, final YangInstanceIdentifier routesPath,
-        final ContainerNode destination, final ContainerNode attributes, final ApplyRoute function) {
+    protected final void processDestination(
+        final DOMDataWriteTransaction tx,
+        final YangInstanceIdentifier routesPath,
+        final ContainerNode destination,
+        final ContainerNode attributes,
+        final ApplyRoute function
+    ) {
         if (destination != null) {
             final YangInstanceIdentifier base = routesPath.node(routesContainerIdentifier()).node(routeQName());
             final Optional<DataContainerChild<? extends PathArgument, ?>> maybePathIdLeaf = destination.getChild(routePathIdNid());
-            final String routeKeyValue = getParser().stringNlri(destination);
+            final String routeKeyValue = this.nlriParser.stringNlri(destination);
             final NodeIdentifierWithPredicates routeKey = PathIdUtil.createNidKey(routeQName(), routeKeyQName(), pathIdQName(), routeKeyValue, maybePathIdLeaf);
             function.apply(tx, base, routeKey, destination, attributes);
         }
index 24e16ce2506f12768c889340d2253304c3a2fd6e..54d957dd92f10d021edfbefe30495fd5aa49151e 100644 (file)
@@ -7,27 +7,28 @@
  */
 package org.opendaylight.protocol.bgp.flowspec;
 
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.FlowspecSubsequentAddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.bgp.rib.rib.loc.rib.tables.routes.FlowspecRoutesCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.destination.ipv4.DestinationFlowspec;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.ipv4.route.FlowspecRoute;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.routes.FlowspecRoutes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
 
-final class FlowspecIpv4RIBSupport extends AbstractFlowspecRIBSupport {
-
-    private SimpleFlowspecIpv4NlriParser FS_PARSER;
+public final class FlowspecIpv4RIBSupport extends AbstractFlowspecRIBSupport<SimpleFlowspecIpv4NlriParser> {
 
     public FlowspecIpv4RIBSupport(SimpleFlowspecExtensionProviderContext context) {
-        super(FlowspecRoutesCase.class, FlowspecRoutes.class, FlowspecRoute.class, Ipv4AddressFamily.class, DestinationFlowspec.QNAME);
-        FS_PARSER = new SimpleFlowspecIpv4NlriParser(context.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4, SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC));
+        super(
+            FlowspecRoutesCase.class,
+            FlowspecRoutes.class,
+            FlowspecRoute.class,
+            Ipv4AddressFamily.class,
+            FlowspecSubsequentAddressFamily.class,
+            DestinationFlowspec.QNAME,
+            new SimpleFlowspecIpv4NlriParser(context.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4, SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC))
+        );
     }
 
     static FlowspecIpv4RIBSupport getInstance(SimpleFlowspecExtensionProviderContext context) {
         return new FlowspecIpv4RIBSupport(context);
     }
-
-    @Override
-    protected AbstractFlowspecNlriParser getParser() {
-        return FS_PARSER;
-    }
 }
index f99fabc6650fe096f917524a90bc2d1c12b3e235..1f094607018709f0eab06ed600a08ff8af7c7ebe 100644 (file)
@@ -7,27 +7,28 @@
  */
 package org.opendaylight.protocol.bgp.flowspec;
 
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.FlowspecSubsequentAddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.bgp.rib.rib.loc.rib.tables.routes.FlowspecIpv6RoutesCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.destination.ipv6.DestinationFlowspec;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.ipv6.route.FlowspecRoute;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.ipv6.routes.FlowspecIpv6Routes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
 
-public final class FlowspecIpv6RIBSupport extends AbstractFlowspecRIBSupport {
-
-    private SimpleFlowspecIpv6NlriParser FS_PARSER;
+public final class FlowspecIpv6RIBSupport extends AbstractFlowspecRIBSupport<SimpleFlowspecIpv6NlriParser> {
 
     public FlowspecIpv6RIBSupport(SimpleFlowspecExtensionProviderContext context) {
-        super(FlowspecIpv6RoutesCase.class, FlowspecIpv6Routes.class, FlowspecRoute.class, Ipv6AddressFamily.class, DestinationFlowspec.QNAME);
-        FS_PARSER = new SimpleFlowspecIpv6NlriParser(context.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV6, SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC));
+        super(
+            FlowspecIpv6RoutesCase.class,
+            FlowspecIpv6Routes.class,
+            FlowspecRoute.class,
+            Ipv6AddressFamily.class,
+            FlowspecSubsequentAddressFamily.class,
+            DestinationFlowspec.QNAME,
+            new SimpleFlowspecIpv6NlriParser(context.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV6, SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC))
+        );
     }
 
     static FlowspecIpv6RIBSupport getInstance(SimpleFlowspecExtensionProviderContext context) {
         return new FlowspecIpv6RIBSupport(context);
     }
-
-    @Override
-    protected AbstractFlowspecNlriParser getParser() {
-        return FS_PARSER;
-    }
 }
index 48d480da5216e66d141d5f6e4cb9d3e86199d76d..e9a89b11e5b84e3305a7a0d666f9937ef4b5d98b 100644 (file)
@@ -9,8 +9,11 @@ package org.opendaylight.protocol.bgp.flowspec;
 
 import java.util.ArrayList;
 import java.util.List;
+import org.opendaylight.protocol.bgp.flowspec.l3vpn.ipv4.FlowspecL3vpnIpv4RIBSupport;
+import org.opendaylight.protocol.bgp.flowspec.l3vpn.ipv6.FlowspecL3vpnIpv6RIBSupport;
 import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBExtensionProviderActivator;
 import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.FlowspecL3vpnSubsequentAddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.FlowspecSubsequentAddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
@@ -29,6 +32,8 @@ public final class RIBActivator extends AbstractRIBExtensionProviderActivator {
         final List<AutoCloseable> regs = new ArrayList<>();
         regs.add(context.registerRIBSupport(Ipv4AddressFamily.class, FlowspecSubsequentAddressFamily.class, FlowspecIpv4RIBSupport.getInstance(fs_context)));
         regs.add(context.registerRIBSupport(Ipv6AddressFamily.class, FlowspecSubsequentAddressFamily.class, FlowspecIpv6RIBSupport.getInstance(fs_context)));
+        regs.add(context.registerRIBSupport(Ipv4AddressFamily.class, FlowspecL3vpnSubsequentAddressFamily.class, FlowspecL3vpnIpv4RIBSupport.getInstance(fs_context)));
+        regs.add(context.registerRIBSupport(Ipv6AddressFamily.class, FlowspecL3vpnSubsequentAddressFamily.class, FlowspecL3vpnIpv6RIBSupport.getInstance(fs_context)));
         return regs;
     }
 }
index b6a08f8e6665b5b51d8b2e8b88fd9ddea3a33f50..0bbc92cd4cada06cc63a07cdb4c6c2fde662a545 100644 (file)
@@ -28,7 +28,7 @@ public final class SimpleFlowspecIpv4NlriParser extends AbstractFlowspecNlriPars
     }
 
     @Override
-    protected DestinationType createWithdrawnDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId) {
+    public DestinationType createWithdrawnDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId) {
         final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[0];
         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecCaseBuilder()
             .setDestinationFlowspec(
@@ -40,7 +40,7 @@ public final class SimpleFlowspecIpv4NlriParser extends AbstractFlowspecNlriPars
     }
 
     @Override
-    protected DestinationType createAdvertizedRoutesDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId) {
+    public DestinationType createAdvertizedRoutesDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId) {
         final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[0];
         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecCaseBuilder()
             .setDestinationFlowspec(
index 3acc478e95ab5363bf873934a8254ee597f14eec..9bfda428cd0752490412782d0c9338052574bbee 100644 (file)
@@ -28,7 +28,7 @@ public final class SimpleFlowspecIpv6NlriParser extends AbstractFlowspecNlriPars
     }
 
     @Override
-    protected DestinationType createWithdrawnDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId) {
+    public DestinationType createWithdrawnDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId) {
         final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[0];
         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecIpv6CaseBuilder()
             .setDestinationFlowspec(
@@ -40,7 +40,7 @@ public final class SimpleFlowspecIpv6NlriParser extends AbstractFlowspecNlriPars
     }
 
     @Override
-    protected DestinationType createAdvertizedRoutesDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId) {
+    public DestinationType createAdvertizedRoutesDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId) {
         final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[0];
         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecIpv6CaseBuilder()
             .setDestinationFlowspec(
diff --git a/bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/AbstractFlowspecL3vpnRIBSupport.java b/bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/AbstractFlowspecL3vpnRIBSupport.java
new file mode 100644 (file)
index 0000000..c9456b7
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.flowspec.l3vpn;
+
+import com.google.common.collect.Iterables;
+import java.util.Collection;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.opendaylight.bgp.concepts.RouteDistinguisherUtil;
+import org.opendaylight.protocol.bgp.flowspec.AbstractFlowspecRIBSupport;
+import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.FlowspecL3vpnSubsequentAddressFamily;
+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.destination.DestinationType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.Route;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.tables.Routes;
+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.RouteDistinguisher;
+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.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Kevin Wang
+ */
+public abstract class AbstractFlowspecL3vpnRIBSupport<T extends AbstractFlowspecL3vpnNlriParser> extends AbstractFlowspecRIBSupport<T> {
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractFlowspecL3vpnRIBSupport.class);
+
+    private final NodeIdentifier RD_NID;
+
+    protected AbstractFlowspecL3vpnRIBSupport(
+        final Class<? extends Routes> cazeClass,
+        final Class<? extends DataObject> containerClass,
+        final Class<? extends Route> listClass,
+        final QName dstContainerClassQName,
+        final Class<? extends AddressFamily> afiClass,
+        final T flowspecNlriParser
+    ) {
+        super(cazeClass, containerClass, listClass, afiClass, FlowspecL3vpnSubsequentAddressFamily.class, dstContainerClassQName, flowspecNlriParser);
+        final QName RD_QNAME = QName.create(routeQName(), "route-distinguisher").intern();
+        RD_NID = new NodeIdentifier(RD_QNAME);
+    }
+
+    @Nullable
+    private RouteDistinguisher buildRouteDistinguisher(final DataContainerNode<? extends PathArgument> data) {
+        final NormalizedNode<?, ?> rdNode = NormalizedNodes.findNode(data, RD_NID).orNull();
+        RouteDistinguisher rd = null;
+        if (rdNode != null) {
+            rd = RouteDistinguisherUtil.parseRouteDistinguisher(rdNode.getValue());
+        }
+        return rd;
+    }
+
+    @Nonnull
+    @Override
+    protected DestinationType buildDestination(@Nonnull final Collection<MapEntryNode> routes) {
+        final MapEntryNode routesCont = Iterables.getOnlyElement(routes);
+        final PathId pathId = PathIdUtil.buildPathId(routesCont, routePathIdNid());
+        final RouteDistinguisher rd = buildRouteDistinguisher(routesCont);
+        return this.nlriParser.createAdvertizedRoutesDestinationType(
+            new Object[] {rd, this.nlriParser.extractFlowspec(routesCont)},
+            pathId
+        );
+    }
+
+    @Nonnull
+    @Override
+    protected DestinationType buildWithdrawnDestination(@Nonnull final Collection<MapEntryNode> routes) {
+        final MapEntryNode routesCont = Iterables.getOnlyElement(routes);
+        final PathId pathId = PathIdUtil.buildPathId(routesCont, routePathIdNid());
+        final RouteDistinguisher rd = buildRouteDistinguisher(routesCont);
+        return this.nlriParser.createWithdrawnDestinationType(
+            new Object[] {rd, nlriParser.extractFlowspec(Iterables.getOnlyElement(routes))},
+            pathId
+        );
+    }
+}
index 8ad5b9be0d002b6d2b0b478eb8968108bdc2a2fe..5f4e2c60248f783c7b4bbc5e952f7285417477ff 100644 (file)
@@ -34,7 +34,7 @@ public final class FlowspecL3vpnIpv4NlriParser extends AbstractFlowspecL3vpnNlri
     }
 
     @Override
-    protected DestinationType createWithdrawnDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId) {
+    public DestinationType createWithdrawnDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId) {
         final RouteDistinguisher rd = (RouteDistinguisher) nlriFields[0];
         final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[1];
         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv4CaseBuilder()
@@ -48,7 +48,7 @@ public final class FlowspecL3vpnIpv4NlriParser extends AbstractFlowspecL3vpnNlri
     }
 
     @Override
-    protected DestinationType createAdvertizedRoutesDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId) {
+    public DestinationType createAdvertizedRoutesDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId) {
         final RouteDistinguisher rd = (RouteDistinguisher) nlriFields[0];
         final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[1];
         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecL3vpnIpv4CaseBuilder()
diff --git a/bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/ipv4/FlowspecL3vpnIpv4RIBSupport.java b/bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/ipv4/FlowspecL3vpnIpv4RIBSupport.java
new file mode 100644 (file)
index 0000000..a21afe5
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.flowspec.l3vpn.ipv4;
+
+import org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecExtensionProviderContext;
+import org.opendaylight.protocol.bgp.flowspec.l3vpn.AbstractFlowspecL3vpnRIBSupport;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv4RoutesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.ipv4.route.FlowspecRoute;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.l3vpn.destination.ipv4.DestinationFlowspecL3vpnIpv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.l3vpn.ipv4.routes.FlowspecL3vpnIpv4Routes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
+
+/**
+ * @author Kevin Wang
+ */
+public final class FlowspecL3vpnIpv4RIBSupport extends AbstractFlowspecL3vpnRIBSupport<FlowspecL3vpnIpv4NlriParser> {
+
+    public FlowspecL3vpnIpv4RIBSupport(SimpleFlowspecExtensionProviderContext context) {
+        super(
+            FlowspecL3vpnIpv4RoutesCase.class,
+            FlowspecL3vpnIpv4Routes.class,
+            FlowspecRoute.class,
+            DestinationFlowspecL3vpnIpv4.QNAME,
+            Ipv4AddressFamily.class,
+            new FlowspecL3vpnIpv4NlriParser(context.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4, SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC_VPN))
+        );
+    }
+
+    public static final FlowspecL3vpnIpv4RIBSupport getInstance(SimpleFlowspecExtensionProviderContext context) {
+        return new FlowspecL3vpnIpv4RIBSupport(context);
+    }
+}
index c5e3ad18ba89805f6b7852862aa82a4d1439686d..245ee4d8d1eac935c2d8114761574ea03502d87c 100644 (file)
@@ -34,7 +34,7 @@ public final class FlowspecL3vpnIpv6NlriParser extends AbstractFlowspecL3vpnNlri
     }
 
     @Override
-    protected DestinationType createWithdrawnDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId) {
+    public DestinationType createWithdrawnDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId) {
         final RouteDistinguisher rd = (RouteDistinguisher) nlriFields[0];
         final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[1];
         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv6CaseBuilder()
@@ -48,7 +48,7 @@ public final class FlowspecL3vpnIpv6NlriParser extends AbstractFlowspecL3vpnNlri
     }
 
     @Override
-    protected DestinationType createAdvertizedRoutesDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId) {
+    public DestinationType createAdvertizedRoutesDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId) {
         final RouteDistinguisher rd = (RouteDistinguisher) nlriFields[0];
         final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[1];
         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecL3vpnIpv6CaseBuilder()
diff --git a/bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/ipv6/FlowspecL3vpnIpv6RIBSupport.java b/bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/ipv6/FlowspecL3vpnIpv6RIBSupport.java
new file mode 100644 (file)
index 0000000..fe6a22d
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.flowspec.l3vpn.ipv6;
+
+import org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecExtensionProviderContext;
+import org.opendaylight.protocol.bgp.flowspec.l3vpn.AbstractFlowspecL3vpnRIBSupport;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv6RoutesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.ipv6.route.FlowspecRoute;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.l3vpn.ipv6.routes.FlowspecL3vpnIpv6Routes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
+
+/**
+ * @author Kevin Wang
+ */
+public final class FlowspecL3vpnIpv6RIBSupport extends AbstractFlowspecL3vpnRIBSupport<FlowspecL3vpnIpv6NlriParser> {
+
+    public FlowspecL3vpnIpv6RIBSupport(SimpleFlowspecExtensionProviderContext context) {
+        super(
+            FlowspecL3vpnIpv6RoutesCase.class,
+            FlowspecL3vpnIpv6Routes.class,
+            FlowspecRoute.class,
+            DestinationFlowspecL3vpnIpv6.QNAME,
+            Ipv6AddressFamily.class,
+            new FlowspecL3vpnIpv6NlriParser(context.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV6, SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC_VPN))
+        );
+    }
+
+    public static final FlowspecL3vpnIpv6RIBSupport getInstance(SimpleFlowspecExtensionProviderContext context) {
+        return new FlowspecL3vpnIpv6RIBSupport(context);
+    }
+}