Match AfiSafi Policy implementation 15/72515/2
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Wed, 30 May 2018 15:02:03 +0000 (17:02 +0200)
committerClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Thu, 31 May 2018 17:31:08 +0000 (19:31 +0200)
Change-Id: Iaea1cd7d6933a015282e1cb2f3e24a61f299d305
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
47 files changed:
bgp/openconfig-rp-impl/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/impl/BGPRibPolicyImpl.java
bgp/openconfig-rp-spi/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/spi/registry/BgpAttributeConditionsUtil.java [new file with mode: 0644]
bgp/openconfig-rp-spi/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/spi/registry/BgpConditionsRegistry.java
bgp/openconfig-rp-spi/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/spi/registry/ConditionsRegistryImpl.java
bgp/openconfig-rp-spi/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/spi/registry/StatementRegistry.java
bgp/openconfig-rp-spi/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/spi/registry/StatementRegistryConsumer.java
bgp/openconfig-rp-spi/src/main/resources/org/opendaylight/blueprint/bgp-openconfig-routing-policy-spi.xml
bgp/openconfig-rp-spi/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/spi/AbstractStatementRegistryTest.java
bgp/openconfig-rp-spi/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/spi/AppendActionTest.java
bgp/openconfig-rp-spi/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/spi/AsPathLengthTest.java
bgp/openconfig-rp-spi/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/spi/AttributesEqualTests.java
bgp/openconfig-rp-spi/src/test/resources/initial/routing-policy-config.xml
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/AbstractStatementRegistryConsumerTest.java
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/ExportDefaultStatementTest.java
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/ImportDefaultStatementTest.java
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/MatchAsPathSetTest.java
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/MatchBgpNeighborSetTest.java
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/MatchCommunityTest.java
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/MatchExtComTest.java
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/SetCommunityTest.java
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/SetExtCommunityTest.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/AddPathAbstractRouteEntry.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/base/BaseRouteEntry.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/ApplicationPeer.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/EffectiveRibInWriter.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/LocRibWriter.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RouteEntryDependenciesContainerImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/AppPeer.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/BgpPeer.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/RibImpl.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AbstractAddPathTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AbstractRIBTestSetup.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathAllPathsTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathBasePathsTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathNPathsTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/DefaultRibPoliciesMockTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/ParserToSalTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/PeerTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SynchronizationAndExceptionTest.java
bgp/rib-spi/pom.xml
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AbstractRIBSupport.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AddPathRibSupport.java [deleted file]
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/RIBSupport.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/entry/RouteEntryDependenciesContainer.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/policy/BGPRibRoutingPolicy.java

index fd60eb90733cd03db09184889c04cae9def150fd..20c8eaf36622702156cee0f6154a647b10967dac 100644 (file)
@@ -27,6 +27,7 @@ import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.Stat
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.DefaultPolicyType;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.apply.policy.group.apply.policy.Config;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.RoutingPolicy;
@@ -97,12 +98,13 @@ final class BGPRibPolicyImpl implements BGPRibRoutingPolicy {
 
     @Override
     public Optional<Attributes> applyImportPolicies(final BGPRouteEntryImportParameters policyParameters,
-            final Attributes attributes) {
+            final Attributes attributes, final Class<? extends AfiSafiType> afiSafi) {
         RouteAttributeContainer currentAttributes = routeAttributeContainerFalse(attributes);
         for (final String policyName : this.importPolicy) {
             for (final Statement statement : this.statements.getUnchecked(policyName)) {
                 currentAttributes = this.policyRegistry
-                        .applyImportStatement(this.ribBaseParameters, policyParameters, currentAttributes, statement);
+                        .applyImportStatement(this.ribBaseParameters, afiSafi, policyParameters, currentAttributes,
+                                statement);
             }
         }
         if (!currentAttributes.anyConditionSatisfied()) {
@@ -115,12 +117,12 @@ final class BGPRibPolicyImpl implements BGPRibRoutingPolicy {
 
     @Override
     public Optional<Attributes> applyExportPolicies(final BGPRouteEntryExportParameters policyParameters,
-            final Attributes attributes) {
+            final Attributes attributes, final Class<? extends AfiSafiType> afiSafi) {
         RouteAttributeContainer currentAttributes = routeAttributeContainerFalse(attributes);
         for (final String policyName : this.exportPolicy) {
             for (final Statement statement : this.statements.getUnchecked(policyName)) {
                 currentAttributes = this.policyRegistry.applyExportStatement(
-                        this.ribBaseParameters, policyParameters, currentAttributes, statement);
+                        this.ribBaseParameters, afiSafi, policyParameters, currentAttributes, statement);
             }
         }
         if (!currentAttributes.anyConditionSatisfied()) {
diff --git a/bgp/openconfig-rp-spi/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/spi/registry/BgpAttributeConditionsUtil.java b/bgp/openconfig-rp-spi/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/spi/registry/BgpAttributeConditionsUtil.java
new file mode 100644 (file)
index 0000000..42ba6b9
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.openconfig.routing.policy.spi.registry;
+
+import java.util.List;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.attribute.conditions.AsPathLength;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.conditions.BgpConditions;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.BgpOriginAttrType;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.AttributeComparison;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.AttributeEq;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.AttributeGe;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.AttributeLe;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.AsPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.LocalPref;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.MultiExitDisc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.Origin;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.as.path.Segments;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.AsPathSegment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.CNextHop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.EmptyNextHopCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv4NextHopCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv6NextHopCase;
+
+/**
+ * Bgp Attribute Conditions Util per check conditions matchs.
+ *
+ * @author Claudio D. Gasparini
+ */
+final class BgpAttributeConditionsUtil {
+    private BgpAttributeConditionsUtil() {
+        throw new UnsupportedOperationException();
+    }
+
+    static boolean matchConditions(
+            final Class<? extends AfiSafiType> afiSafi,
+            final Attributes attributes,
+            final BgpConditions conditions) {
+        if (!matchAfiSafi(afiSafi, conditions.getAfiSafiIn())) {
+            return false;
+        }
+
+        if (!matchAsPathLength(attributes.getAsPath(), conditions.getAsPathLength())) {
+            return false;
+        }
+
+        if (!matchMED(attributes.getMultiExitDisc(), conditions.getMedEq())) {
+            return false;
+        }
+
+        if (!matchOrigin(attributes.getOrigin(), conditions.getOriginEq())) {
+            return false;
+        }
+
+        if (!matchNextHopIn(attributes.getCNextHop(), conditions.getNextHopIn())) {
+            return false;
+        }
+
+        if (!matchLocalPref(attributes.getLocalPref(), conditions.getLocalPrefEq())) {
+            return false;
+        }
+        return true;
+    }
+
+    private static boolean matchAfiSafi(
+            final Class<? extends AfiSafiType> afiSafi,
+            final List<Class<? extends AfiSafiType>> afiSafiIn) {
+        if (afiSafiIn == null) {
+            return true;
+        }
+        return afiSafiIn.contains(afiSafi);
+    }
+
+    private static boolean matchMED(final MultiExitDisc multiExitDisc, final Long med) {
+        if (multiExitDisc == null || med == null) {
+            return true;
+        }
+
+        return multiExitDisc.getMed().equals(med);
+    }
+
+    private static boolean matchOrigin(final Origin origin, final BgpOriginAttrType originEq) {
+        if (origin == null || originEq == null) {
+            return true;
+        }
+        return origin.getValue().getIntValue() == originEq.getIntValue();
+    }
+
+    private static boolean matchAsPathLength(final AsPath asPath, final AsPathLength asPathLength) {
+        if (asPath == null || asPathLength == null) {
+            return true;
+        }
+
+        final List<Segments> segments = asPath.getSegments();
+        int total = segments.stream().map(AsPathSegment::getAsSequence)
+                .filter(Objects::nonNull).mapToInt(List::size).sum();
+
+        if (total == 0) {
+            total = segments.stream().map(AsPathSegment::getAsSet)
+                    .filter(Objects::nonNull).mapToInt(List::size).sum();
+        }
+
+        final Class<? extends AttributeComparison> comp = asPathLength.getOperator();
+        final long asPathLenght = asPathLength.getValue();
+        if (comp == AttributeEq.class) {
+            return total == asPathLenght;
+        } else if (comp == AttributeGe.class) {
+            return total >= asPathLenght;
+        } else if (comp == AttributeLe.class) {
+            return total <= asPathLenght;
+        }
+        return false;
+    }
+
+
+    private static boolean matchNextHopIn(final CNextHop nextHop, final List<IpAddress> nextHopIn) {
+        if (nextHop == null || nextHopIn == null || nextHop instanceof EmptyNextHopCase) {
+            return true;
+        }
+
+        IpAddress global;
+        if (nextHop instanceof Ipv4NextHopCase) {
+            global = new IpAddress(((Ipv4NextHopCase) nextHop).getIpv4NextHop().getGlobal());
+        } else {
+            global = new IpAddress(((Ipv6NextHopCase) nextHop).getIpv6NextHop().getGlobal());
+        }
+        return nextHopIn.contains(global);
+    }
+
+    private static boolean matchLocalPref(final LocalPref localPref, final Long localPrefEq) {
+        if (localPref == null || localPrefEq == null) {
+            return true;
+        }
+        return localPref.getPref().equals(localPrefEq);
+    }
+}
index 6d6430db6969de42cf4146f7913d52ccd4e0f3e1..561bc625aabc4c80590ab92e43e8dbec4c304ddc 100644 (file)
@@ -9,9 +9,7 @@ package org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry;
 
 import com.google.common.base.Preconditions;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
-import java.util.Objects;
 import javax.annotation.concurrent.GuardedBy;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.RouteEntryBaseAttributes;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.condition.BgpConditionsAugmentationPolicy;
@@ -20,35 +18,19 @@ import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameter
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.BgpMatchConditions;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.Conditions1;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.attribute.conditions.AsPathLength;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.match.conditions.MatchAsPathSet;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.match.conditions.MatchCommunitySet;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.match.conditions.MatchExtCommunitySet;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.conditions.BgpConditions;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.BgpOriginAttrType;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.AttributeComparison;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.AttributeEq;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.AttributeGe;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.AttributeLe;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Conditions;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.AsPath;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.LocalPref;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.MultiExitDisc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.Origin;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.as.path.Segments;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.AsPathSegment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.CNextHop;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.EmptyNextHopCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv4NextHopCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv6NextHopCase;
 import org.opendaylight.yangtools.concepts.AbstractRegistration;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 import org.opendaylight.yangtools.yang.binding.ChildOf;
 import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
 
-public final class BgpConditionsRegistry {
+final class BgpConditionsRegistry {
     @GuardedBy("this")
     private final Map<Class<? extends Augmentation<BgpConditions>>,
             BgpConditionsAugmentationPolicy> bgpConditionsAugRegistry = new HashMap<>();
@@ -56,7 +38,7 @@ public final class BgpConditionsRegistry {
     private final Map<Class<? extends ChildOf<BgpMatchConditions>>,
             BgpConditionsPolicy> bgpConditionsRegistry = new HashMap<>();
 
-    public AbstractRegistration registerBgpConditionsAugmentationPolicy(
+    AbstractRegistration registerBgpConditionsAugmentationPolicy(
             final Class<? extends Augmentation<BgpConditions>> conditionPolicyClass,
             final BgpConditionsAugmentationPolicy conditionPolicy) {
         synchronized (this.bgpConditionsAugRegistry) {
@@ -75,7 +57,7 @@ public final class BgpConditionsRegistry {
         }
     }
 
-    public <T extends ChildOf<BgpMatchConditions>, N> AbstractRegistration registerBgpConditionsPolicy(
+    <T extends ChildOf<BgpMatchConditions>, N> AbstractRegistration registerBgpConditionsPolicy(
             final Class<T> conditionPolicyClass,
             final BgpConditionsPolicy<T, N> conditionPolicy) {
         synchronized (this.bgpConditionsRegistry) {
@@ -95,7 +77,8 @@ public final class BgpConditionsRegistry {
     }
 
     @SuppressWarnings("unchecked")
-    public boolean matchExportConditions(
+    boolean matchExportConditions(
+            final Class<? extends AfiSafiType> afiSafi,
             final RouteEntryBaseAttributes entryInfo,
             final BGPRouteEntryExportParameters routeEntryExportParameters,
             final Attributes attributes,
@@ -104,7 +87,7 @@ public final class BgpConditionsRegistry {
         if (bgpConditionsAug != null) {
 
             final BgpConditions bgpConditions = bgpConditionsAug.getBgpConditions();
-            if (!matchExportCondition(entryInfo, routeEntryExportParameters, attributes,
+            if (!matchExportCondition(afiSafi, entryInfo, routeEntryExportParameters, attributes,
                     bgpConditions)) {
                 return false;
             }
@@ -125,7 +108,8 @@ public final class BgpConditionsRegistry {
     }
 
 
-    public boolean matchImportConditions(
+    boolean matchImportConditions(
+            final Class<? extends AfiSafiType> afiSafi,
             final RouteEntryBaseAttributes entryInfo,
             final BGPRouteEntryImportParameters routeEntryImportParameters,
             final Attributes attributes,
@@ -135,7 +119,7 @@ public final class BgpConditionsRegistry {
         if (bgpConditionsAug != null) {
             final BgpConditions bgpConditions = bgpConditionsAug.getBgpConditions();
             synchronized (this) {
-                if (!matchImportCondition(entryInfo, routeEntryImportParameters, attributes,
+                if (!matchImportCondition(afiSafi, entryInfo, routeEntryImportParameters, attributes,
                         bgpConditions)) {
                     return false;
                 }
@@ -158,28 +142,13 @@ public final class BgpConditionsRegistry {
 
     @SuppressWarnings("unchecked")
     private boolean matchImportCondition(
+            final Class<? extends AfiSafiType> afiSafi,
             final RouteEntryBaseAttributes routeEntryInfo,
             final BGPRouteEntryImportParameters routeEntryImportParameters,
             final Attributes attributes,
             final BgpConditions conditions) {
 
-        if (!matchAsPathLength(attributes.getAsPath(), conditions.getAsPathLength())) {
-            return false;
-        }
-
-        if (!matchMED(attributes.getMultiExitDisc(), conditions.getMedEq())) {
-            return false;
-        }
-
-        if (!matchOrigin(attributes.getOrigin(), conditions.getOriginEq())) {
-            return false;
-        }
-
-        if (!matchNextHopIn(attributes.getCNextHop(), conditions.getNextHopIn())) {
-            return false;
-        }
-
-        if (!matchLocalPref(attributes.getLocalPref(), conditions.getLocalPrefEq())) {
+        if (!BgpAttributeConditionsUtil.matchConditions(afiSafi, attributes, conditions)) {
             return false;
         }
 
@@ -215,27 +184,12 @@ public final class BgpConditionsRegistry {
 
     @SuppressWarnings("unchecked")
     private boolean matchExportCondition(
+            final Class<? extends AfiSafiType> afiSafi,
             final RouteEntryBaseAttributes routeEntryInfo,
             final BGPRouteEntryExportParameters routeEntryExportParameters,
             final Attributes attributes,
             final BgpConditions conditions) {
-        if (!matchAsPathLength(attributes.getAsPath(), conditions.getAsPathLength())) {
-            return false;
-        }
-
-        if (!matchMED(attributes.getMultiExitDisc(), conditions.getMedEq())) {
-            return false;
-        }
-
-        if (!matchOrigin(attributes.getOrigin(), conditions.getOriginEq())) {
-            return false;
-        }
-
-        if (!matchNextHopIn(attributes.getCNextHop(), conditions.getNextHopIn())) {
-            return false;
-        }
-
-        if (!matchLocalPref(attributes.getLocalPref(), conditions.getLocalPrefEq())) {
+        if (!BgpAttributeConditionsUtil.matchConditions(afiSafi, attributes, conditions)) {
             return false;
         }
 
@@ -268,67 +222,4 @@ public final class BgpConditionsRegistry {
 
         return true;
     }
-
-    private boolean matchMED(final MultiExitDisc multiExitDisc, final Long med) {
-        if (multiExitDisc == null || med == null) {
-            return true;
-        }
-
-        return multiExitDisc.getMed().equals(med);
-    }
-
-    private boolean matchOrigin(final Origin origin, final BgpOriginAttrType originEq) {
-        if (origin == null || originEq == null) {
-            return true;
-        }
-        return origin.getValue().getIntValue() == originEq.getIntValue();
-    }
-
-    private boolean matchAsPathLength(final AsPath asPath, final AsPathLength asPathLength) {
-        if (asPath == null || asPathLength == null) {
-            return true;
-        }
-
-        final List<Segments> segments = asPath.getSegments();
-        int total = segments.stream().map(AsPathSegment::getAsSequence)
-                .filter(Objects::nonNull).mapToInt(List::size).sum();
-
-        if (total == 0) {
-            total = segments.stream().map(AsPathSegment::getAsSet)
-                    .filter(Objects::nonNull).mapToInt(List::size).sum();
-        }
-
-        final Class<? extends AttributeComparison> comp = asPathLength.getOperator();
-        final long asPathLenght = asPathLength.getValue();
-        if (comp == AttributeEq.class) {
-            return total == asPathLenght;
-        } else if (comp == AttributeGe.class) {
-            return total >= asPathLenght;
-        } else if (comp == AttributeLe.class) {
-            return total <= asPathLenght;
-        }
-        return false;
-    }
-
-
-    private boolean matchNextHopIn(final CNextHop nextHop, final List<IpAddress> nextHopIn) {
-        if (nextHop == null || nextHopIn == null || nextHop instanceof EmptyNextHopCase) {
-            return true;
-        }
-
-        IpAddress global;
-        if (nextHop instanceof Ipv4NextHopCase) {
-            global = new IpAddress(((Ipv4NextHopCase) nextHop).getIpv4NextHop().getGlobal());
-        } else {
-            global = new IpAddress(((Ipv6NextHopCase) nextHop).getIpv6NextHop().getGlobal());
-        }
-        return nextHopIn.contains(global);
-    }
-
-    private boolean matchLocalPref(final LocalPref localPref, final Long localPrefEq) {
-        if (localPref == null || localPrefEq == null) {
-            return true;
-        }
-        return localPref.getPref().equals(localPrefEq);
-    }
 }
index d22a05200adbbab06202c0f87abfb2483b568a28..7e96d1d2e3a1b8ae56077b94e0a73c7f0cb4114c 100644 (file)
@@ -13,7 +13,6 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.HashMap;
 import java.util.Map;
 import javax.annotation.concurrent.GuardedBy;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.RouteEntryBaseAttributes;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.condition.BgpConditionsAugmentationPolicy;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.condition.BgpConditionsPolicy;
@@ -22,6 +21,7 @@ import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameter
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.BgpMatchConditions;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.conditions.BgpConditions;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Conditions;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
 import org.opendaylight.yangtools.concepts.AbstractRegistration;
@@ -34,12 +34,9 @@ final class ConditionsRegistryImpl {
     @GuardedBy("this")
     private final Map<Class<? extends Augmentation<Conditions>>, ConditionsAugPolicy> conditionsRegistry
             = new HashMap<>();
-    //TODO Implement match prefix
-    //private final GenericConditionPolicyHandler genericConditionHandler;
     private final BgpConditionsRegistry bgpConditionsRegistry = new BgpConditionsRegistry();
 
-    ConditionsRegistryImpl(final DataBroker databroker) {
-    //    this.genericConditionHandler = new GenericConditionPolicyHandler(databroker);
+    ConditionsRegistryImpl() {
     }
 
     AbstractRegistration registerConditionPolicy(final Class<? extends Augmentation<Conditions>> conditionPolicyClass,
@@ -75,13 +72,14 @@ final class ConditionsRegistryImpl {
 
     @SuppressWarnings("unchecked")
     boolean matchExportConditions(
+            final Class<? extends AfiSafiType> afiSafi,
             final RouteEntryBaseAttributes entryInfo,
             final BGPRouteEntryExportParameters routeEntryExportParameters,
             final Attributes attributes,
             final Conditions conditions) {
 
         if (!this.bgpConditionsRegistry
-                .matchExportConditions(entryInfo, routeEntryExportParameters, attributes, conditions)) {
+                .matchExportConditions(afiSafi, entryInfo, routeEntryExportParameters, attributes, conditions)) {
             return false;
         }
 
@@ -106,17 +104,12 @@ final class ConditionsRegistryImpl {
 
     @SuppressWarnings("unchecked")
     boolean matchImportConditions(
-            final RouteEntryBaseAttributes entryInfo,
+            final Class<? extends AfiSafiType> afiSafi, final RouteEntryBaseAttributes entryInfo,
             final BGPRouteEntryImportParameters routeEntryImportParameters,
             final Attributes attributes,
             final Conditions conditions) {
-        /*if (!this.genericConditionHandler
-                .matchImportCondition(routeEntryImportParameters, conditions)) {
-            return false;
-        }*/
-
         if (!this.bgpConditionsRegistry
-                .matchImportConditions(entryInfo, routeEntryImportParameters, attributes, conditions)) {
+                .matchImportConditions(afiSafi, entryInfo, routeEntryImportParameters, attributes, conditions)) {
             return false;
         }
 
index ed5a922912b393cf845512ce2964e7a276cc3955..e0f79caf013483b3c05a821dc1eee67c14e86546 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry;
 
 import static org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer.routeAttributeContainerTrue;
 
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.RouteEntryBaseAttributes;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.action.ActionsAugPolicy;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.action.BgpActionAugPolicy;
@@ -23,6 +22,7 @@ import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameter
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.BgpMatchConditions;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.BgpActions;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.conditions.BgpConditions;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Actions;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Conditions;
@@ -35,19 +35,21 @@ public final class StatementRegistry implements StatementRegistryConsumer, State
     private final ConditionsRegistryImpl conditionsRegistry;
     private final ActionsRegistryImpl actionsRegistry;
 
-    public StatementRegistry(final DataBroker databroker) {
-        this.conditionsRegistry = new ConditionsRegistryImpl(databroker);
+    public StatementRegistry() {
+        this.conditionsRegistry = new ConditionsRegistryImpl();
         this.actionsRegistry = new ActionsRegistryImpl();
     }
 
     @Override
     public RouteAttributeContainer applyExportStatement(
             final RouteEntryBaseAttributes routeEntryInfo,
+            final Class<? extends AfiSafiType> afiSafi,
             final BGPRouteEntryExportParameters routeEntryExportParameters,
             final RouteAttributeContainer attributes,
             final Statement statement) {
         final Attributes att = attributes.getAttributes();
         if (att == null || !this.conditionsRegistry.matchExportConditions(
+                afiSafi,
                 routeEntryInfo,
                 routeEntryExportParameters,
                 att,
@@ -64,11 +66,13 @@ public final class StatementRegistry implements StatementRegistryConsumer, State
     @Override
     public RouteAttributeContainer applyImportStatement(
             final RouteEntryBaseAttributes routeEntryInfo,
+            final Class<? extends AfiSafiType> afiSafi,
             final BGPRouteEntryImportParameters routeEntryImportParameters,
             final RouteAttributeContainer attributes,
             final Statement statement) {
         final Attributes att = attributes.getAttributes();
         if (att == null || !this.conditionsRegistry.matchImportConditions(
+                afiSafi,
                 routeEntryInfo,
                 routeEntryImportParameters,
                 attributes.getAttributes(),
index e2eda0ea5a257ab4722e55f3f157946dc24389e5..8c566a6e470d195f502ec90649e4c4b0e9bd284e 100644 (file)
@@ -12,6 +12,7 @@ import javax.annotation.Nonnull;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.RouteEntryBaseAttributes;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
 
 /**
@@ -22,6 +23,7 @@ public interface StatementRegistryConsumer {
      * Apply statement to BGP Route Attributes (Export Policy).
      *
      * @param routeEntryInfo       contains route Entry Info(AS, ClusterId, OriginatorId)
+     * @param afiSafi              Afi Safi Type
      * @param baseExportParameters export Parameters
      * @param attributes           route attributes
      * @param statement            Statement containing Conditions/Actions
@@ -30,6 +32,7 @@ public interface StatementRegistryConsumer {
     @Nonnull
     RouteAttributeContainer applyExportStatement(
             @Nonnull RouteEntryBaseAttributes routeEntryInfo,
+            @Nonnull Class<? extends AfiSafiType> afiSafi,
             @Nonnull BGPRouteEntryExportParameters baseExportParameters,
             @Nonnull RouteAttributeContainer attributes,
             @Nonnull Statement statement);
@@ -38,6 +41,7 @@ public interface StatementRegistryConsumer {
      * Apply statement to BGP Route Attributes (Import Policy).
      *
      * @param routeEntryInfo      contains route Entry Info(AS, ClusterId, OriginatorId)
+     * @param afiSafi             Afi Safi Type
      * @param routeBaseParameters route base parameters
      * @param attributes          route attributes
      * @param statement           Statement containing Conditions/Actions
@@ -46,6 +50,7 @@ public interface StatementRegistryConsumer {
     @Nonnull
     RouteAttributeContainer applyImportStatement(
             @Nonnull RouteEntryBaseAttributes routeEntryInfo,
+            @Nonnull Class<? extends AfiSafiType> afiSafi,
             @Nonnull BGPRouteEntryImportParameters routeBaseParameters,
             @Nonnull RouteAttributeContainer attributes,
             @Nonnull Statement statement);
index 10883a9b15a8cacddd6233f3c6559581eaff2267..cd1ea22619969111a82a4cf40ddd3a88697b9c27 100644 (file)
@@ -1,14 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
            xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
-    <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" odl:type="pingpong"/>
-
     <odl:specific-reference-list id="statementActivatorList"
                                  interface="org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.StatementProviderActivator"/>
 
     <bean id="statementRegistry"
           class="org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.StatementRegistry">
-        <argument ref="dataBroker"/>
     </bean>
 
     <bean id="statementProviderActivator"
index 8b2771c45552dbc89c436537fdc05c460ebed996..27663de6ecacdadd932ef20ebcad1ba605c0a6a7 100644 (file)
@@ -33,7 +33,7 @@ public class AbstractStatementRegistryTest extends AbstractOpenconfigRoutingPoli
     @Override
     public void setUp() throws Exception {
         super.setUp();
-        this.statementRegistry = new StatementRegistry(getDataBroker());
+        this.statementRegistry = new StatementRegistry();
     }
 
     protected List<Statement> loadStatement(final String policyName) throws ExecutionException, InterruptedException {
index decc1fa1db8166eef1d1c631f0c4979d66eaa44d..888e7dcb368716fd037d0ae795d33210679119be 100644 (file)
@@ -17,6 +17,7 @@ import org.junit.Test;
 import org.mockito.Mock;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
@@ -54,6 +55,7 @@ public class AppendActionTest extends AbstractStatementRegistryTest {
                 = routeAttributeContainerFalse(new AttributesBuilder().build());
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
index 896bd0dd4ba6988169e1fa5609394485358e84dd..33aaae62dbf00c2157d90d23290ff01fdfa1eddb 100644 (file)
@@ -20,6 +20,7 @@ import org.junit.Test;
 import org.mockito.Mock;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
@@ -61,6 +62,7 @@ public class AsPathLengthTest extends AbstractStatementRegistryTest {
 
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -75,6 +77,7 @@ public class AsPathLengthTest extends AbstractStatementRegistryTest {
         attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().setAsPath(asPath.build()).build());
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -99,6 +102,7 @@ public class AsPathLengthTest extends AbstractStatementRegistryTest {
 
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -112,6 +116,7 @@ public class AsPathLengthTest extends AbstractStatementRegistryTest {
         attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().setAsPath(asPath.build()).build());
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -136,6 +141,7 @@ public class AsPathLengthTest extends AbstractStatementRegistryTest {
 
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -147,6 +153,7 @@ public class AsPathLengthTest extends AbstractStatementRegistryTest {
         attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().setAsPath(asPath.build()).build());
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
index f8215930e11c14edd13e23569681f5db91533935..871613056e9036858c2b672e50c9fba8498bc787 100644 (file)
@@ -18,6 +18,8 @@ import org.junit.Test;
 import org.mockito.Mock;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV6UNICAST;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
@@ -58,6 +60,7 @@ public class AttributesEqualTests extends AbstractStatementRegistryTest {
 
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -69,6 +72,7 @@ public class AttributesEqualTests extends AbstractStatementRegistryTest {
                 .build());
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -85,6 +89,7 @@ public class AttributesEqualTests extends AbstractStatementRegistryTest {
 
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -96,6 +101,7 @@ public class AttributesEqualTests extends AbstractStatementRegistryTest {
                 .build());
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -113,6 +119,7 @@ public class AttributesEqualTests extends AbstractStatementRegistryTest {
 
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -125,6 +132,7 @@ public class AttributesEqualTests extends AbstractStatementRegistryTest {
                 .build());
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -141,6 +149,7 @@ public class AttributesEqualTests extends AbstractStatementRegistryTest {
 
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -152,6 +161,36 @@ public class AttributesEqualTests extends AbstractStatementRegistryTest {
                 .build());
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
+                this.exportParameters,
+                attributeContainer,
+                statement);
+        assertNull(result.getAttributes());
+    }
+
+    @Test
+    public void testAfiSafiIn() {
+        Statement statement = this.basicStatements.stream()
+                .filter(st -> st.getName().equals("afi-safi-in-test")).findFirst().get();
+        RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder()
+                .setLocalPref(new LocalPrefBuilder().setPref(350L).build())
+                .build());
+
+        RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
+                this.baseAttributes,
+                IPV6UNICAST.class,
+                this.exportParameters,
+                attributeContainer,
+                statement);
+        assertNotNull(result.getAttributes());
+
+
+        attributeContainer = routeAttributeContainerFalse(new AttributesBuilder()
+                .setLocalPref(new LocalPrefBuilder().setPref(100L).build())
+                .build());
+        result = this.statementRegistry.applyExportStatement(
+                this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
index 2c768f2c9c1cb99dcfca485abb379ba106f26f2a..6587d55b5995ad4f91e65cae587057352474b3b0 100644 (file)
                         <reject-route/>
                     </actions>
                 </statement>
+                <statement>
+                    <name>afi-safi-in-test</name>
+                    <conditions>
+                        <bgp-conditions xmlns="http://openconfig.net/yang/bgp-policy">
+                            <afi-safi-in xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV4-UNICAST</afi-safi-in>
+                        </bgp-conditions>
+                    </conditions>
+                    <actions>
+                        <reject-route/>
+                    </actions>
+                </statement>
                 <statement>
                     <name>multiple-append-test</name>
                     <conditions>
index 8ca584a25c28a044a6ddd9d90d84255e39f28861..8701de32d432e6ac2d25a607794e93842daa285e 100644 (file)
@@ -28,7 +28,7 @@ public class AbstractStatementRegistryConsumerTest extends AbstractStatementRegi
     @Override
     public void setUp() throws Exception {
         super.setUp();
-        this.statementRegistry = new StatementRegistry(getDataBroker());
+        this.statementRegistry = new StatementRegistry();
         final StatementActivator activator = new StatementActivator(getDataBroker());
         activator.start(this.statementRegistry);
     }
index 4c2684aa7d89f0188c73e89382e345ad8cc6cfeb..87736f29206960b0956de8324eb06227353384f5 100644 (file)
@@ -24,6 +24,7 @@ import org.mockito.Mock;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.impl.PolicyRIBBaseParametersImpl;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerRole;
@@ -137,6 +138,7 @@ public class ExportDefaultStatementTest extends AbstractStatementRegistryConsume
 
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attInput,
                 statement);
index 38d726eef220095d444c53bcdf572d99c495d2e4..e5cda8d8278c64ed995286e9902f3daaa71d053a 100644 (file)
@@ -19,6 +19,7 @@ import org.mockito.Mock;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.impl.PolicyRIBBaseParametersImpl;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerRole;
@@ -77,6 +78,7 @@ public class ImportDefaultStatementTest extends AbstractStatementRegistryConsume
 
         RouteAttributeContainer result = this.statementRegistry.applyImportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.importParameters,
                 attInput,
                 statement);
index 81770adaf9df3faf61698251cf3429a9e92c0016..4e2a732132a2840c2a31359c4fb17315d4ec933f 100644 (file)
@@ -21,6 +21,7 @@ import org.mockito.Mock;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.impl.PolicyRIBBaseParametersImpl;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
@@ -50,6 +51,7 @@ public class MatchAsPathSetTest extends AbstractStatementRegistryConsumerTest {
                 new AttributesBuilder().build());
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -63,6 +65,7 @@ public class MatchAsPathSetTest extends AbstractStatementRegistryConsumerTest {
                                         AsNumber.getDefaultInstance("65"))).build())).build()).build());
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -79,6 +82,7 @@ public class MatchAsPathSetTest extends AbstractStatementRegistryConsumerTest {
                                 AsNumber.getDefaultInstance("65"))).build())).build()).build());
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -98,6 +102,7 @@ public class MatchAsPathSetTest extends AbstractStatementRegistryConsumerTest {
                         )).build()).build());
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -115,6 +120,7 @@ public class MatchAsPathSetTest extends AbstractStatementRegistryConsumerTest {
                                         AsNumber.getDefaultInstance("65"))).build())).build()).build());
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -128,6 +134,7 @@ public class MatchAsPathSetTest extends AbstractStatementRegistryConsumerTest {
                                         AsNumber.getDefaultInstance("200"))).build())).build()).build());
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
index 4b95f08cd6eaadb96e6a4497520ff120e562d417..fed7cbcf5ca56d28009f67b97679bb47e228dae5 100644 (file)
@@ -20,6 +20,7 @@ import org.mockito.Mock;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.impl.PolicyRIBBaseParametersImpl;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId;
@@ -50,6 +51,7 @@ public class MatchBgpNeighborSetTest extends AbstractStatementRegistryConsumerTe
 
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -59,6 +61,7 @@ public class MatchBgpNeighborSetTest extends AbstractStatementRegistryConsumerTe
         doReturn(new PeerId("bgp://127.0.0.1")).when(this.exportParameters).getFromPeerId();
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -76,6 +79,7 @@ public class MatchBgpNeighborSetTest extends AbstractStatementRegistryConsumerTe
 
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -84,6 +88,7 @@ public class MatchBgpNeighborSetTest extends AbstractStatementRegistryConsumerTe
         doReturn(new PeerId("bgp://127.0.0.1")).when(this.exportParameters).getFromPeerId();
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -102,6 +107,7 @@ public class MatchBgpNeighborSetTest extends AbstractStatementRegistryConsumerTe
 
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -111,6 +117,7 @@ public class MatchBgpNeighborSetTest extends AbstractStatementRegistryConsumerTe
         doReturn(new PeerId("bgp://127.0.0.1")).when(this.exportParameters).getToPeerId();
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -129,6 +136,7 @@ public class MatchBgpNeighborSetTest extends AbstractStatementRegistryConsumerTe
 
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -137,6 +145,7 @@ public class MatchBgpNeighborSetTest extends AbstractStatementRegistryConsumerTe
         doReturn(new PeerId("bgp://127.0.0.1")).when(this.exportParameters).getToPeerId();
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
index 4f236397ebb64feca6997e24d44521b0122fdbd8..b624dd9c59ce24fcbdf7f527756f1d1e9a5dfb73 100644 (file)
@@ -20,6 +20,7 @@ import org.mockito.Mock;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.impl.PolicyRIBBaseParametersImpl;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
@@ -47,6 +48,7 @@ public class MatchCommunityTest extends AbstractStatementRegistryConsumerTest {
                 new AttributesBuilder().build());
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -60,6 +62,7 @@ public class MatchCommunityTest extends AbstractStatementRegistryConsumerTest {
 
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -74,6 +77,7 @@ public class MatchCommunityTest extends AbstractStatementRegistryConsumerTest {
                 new AttributesBuilder().build());
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -87,6 +91,7 @@ public class MatchCommunityTest extends AbstractStatementRegistryConsumerTest {
 
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -101,6 +106,7 @@ public class MatchCommunityTest extends AbstractStatementRegistryConsumerTest {
                 new AttributesBuilder().build());
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -114,6 +120,7 @@ public class MatchCommunityTest extends AbstractStatementRegistryConsumerTest {
 
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
index 82c8329fd02cb930d3b3ce44d61684e175d75561..15418dab9d78db2d595ee6633fa09f78e680a2e5 100644 (file)
@@ -22,6 +22,7 @@ import org.mockito.Mock;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.impl.PolicyRIBBaseParametersImpl;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
@@ -54,6 +55,7 @@ public class MatchExtComTest extends AbstractStatementRegistryConsumerTest {
                 new AttributesBuilder().build());
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -71,6 +73,7 @@ public class MatchExtComTest extends AbstractStatementRegistryConsumerTest {
 
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -85,6 +88,7 @@ public class MatchExtComTest extends AbstractStatementRegistryConsumerTest {
                 new AttributesBuilder().build());
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -105,6 +109,7 @@ public class MatchExtComTest extends AbstractStatementRegistryConsumerTest {
 
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -119,6 +124,7 @@ public class MatchExtComTest extends AbstractStatementRegistryConsumerTest {
                 new AttributesBuilder().build());
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -135,6 +141,7 @@ public class MatchExtComTest extends AbstractStatementRegistryConsumerTest {
 
         result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
index 450c688c97d947756b7ab122575bc84d3bb6c15d..e3d0fd1aa6e82ecf3d2ab291aa308a5314c12566 100644 (file)
@@ -21,6 +21,7 @@ import org.mockito.Mock;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.impl.PolicyRIBBaseParametersImpl;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
@@ -56,6 +57,7 @@ public class SetCommunityTest extends AbstractStatementRegistryConsumerTest {
                 new AttributesBuilder().build());
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -71,6 +73,7 @@ public class SetCommunityTest extends AbstractStatementRegistryConsumerTest {
                 new AttributesBuilder().build());
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -86,6 +89,7 @@ public class SetCommunityTest extends AbstractStatementRegistryConsumerTest {
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(this.multipleCom);
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -101,6 +105,7 @@ public class SetCommunityTest extends AbstractStatementRegistryConsumerTest {
                 new AttributesBuilder().build());
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -116,6 +121,7 @@ public class SetCommunityTest extends AbstractStatementRegistryConsumerTest {
                 new AttributesBuilder().build());
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -131,6 +137,7 @@ public class SetCommunityTest extends AbstractStatementRegistryConsumerTest {
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(this.multipleCom);
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
index 3b9d3de7d366f39443aaf1c95948f1da200ea45a..b51d1fc2f19acf2f5f458345b151f168e7fc736d 100644 (file)
@@ -21,6 +21,7 @@ import org.mockito.Mock;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.impl.PolicyRIBBaseParametersImpl;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
@@ -68,6 +69,7 @@ public class SetExtCommunityTest extends AbstractStatementRegistryConsumerTest {
                 new AttributesBuilder().build());
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -83,6 +85,7 @@ public class SetExtCommunityTest extends AbstractStatementRegistryConsumerTest {
                 new AttributesBuilder().build());
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -98,6 +101,7 @@ public class SetExtCommunityTest extends AbstractStatementRegistryConsumerTest {
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(this.multipleExtCom);
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -113,6 +117,7 @@ public class SetExtCommunityTest extends AbstractStatementRegistryConsumerTest {
                 new AttributesBuilder().build());
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -128,6 +133,7 @@ public class SetExtCommunityTest extends AbstractStatementRegistryConsumerTest {
                 new AttributesBuilder().build());
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
@@ -143,6 +149,7 @@ public class SetExtCommunityTest extends AbstractStatementRegistryConsumerTest {
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(this.multipleExtCom);
         RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
                 this.baseAttributes,
+                IPV4UNICAST.class,
                 this.exportParameters,
                 attributeContainer,
                 statement);
index 9ec15c9387aa4fe31fe1ba2327fe125503cd454a..7670536dbd28d08e5d2f1651ea36ef853bc4f41c 100644 (file)
@@ -177,7 +177,7 @@ public abstract class AddPathAbstractRouteEntry extends AbstractRouteEntry<AddPa
                 final BGPRouteEntryExportParameters baseExp = new BGPRouteEntryExportParametersImpl(
                         this.peerTracker.getPeer(path.getPeerId()), toPeer);
                 final Optional<Attributes> effAttrib = routeEntryDep.getRoutingPolicies()
-                        .applyExportPolicies(baseExp, path.getAttributes());
+                        .applyExportPolicies(baseExp, path.getAttributes(), routeEntryDep.getAfiSafType());
                 if (effAttrib.isPresent()) {
                     Identifier routeIdentifier = ribSupport.createRouteListKey(destPeerSupAddPath
                             ? path.getPathId() : NON_PATH_ID_VALUE, routeKey);
@@ -255,7 +255,7 @@ public abstract class AddPathAbstractRouteEntry extends AbstractRouteEntry<AddPa
                     final BGPRouteEntryExportParameters baseExp
                             = new BGPRouteEntryExportParametersImpl(fromPeer, toPeer);
                     effAttrib = routeEntryDep.getRoutingPolicies()
-                            .applyExportPolicies(baseExp, attributes);
+                            .applyExportPolicies(baseExp, attributes, routeEntryDep.getAfiSafType());
                 }
                 Route newRoute = null;
                 InstanceIdentifier ribOutRoute = null;
index d5d28eb90cf3dddd1dadc9670af17960b83b23fd..95acceb707b29353aa1a79010693c819b76c79c0 100644 (file)
@@ -138,7 +138,7 @@ final class BaseRouteEntry extends AbstractRouteEntry<BaseBestPath> {
         final BGPRouteEntryExportParameters routeEntry = new BGPRouteEntryExportParametersImpl(
                 this.peerTracker.getPeer(this.bestPath.getPeerId()), toPeer);
         final Optional<Attributes> effAttrib = entryDep.getRoutingPolicies()
-                .applyExportPolicies(routeEntry, this.bestPath.getAttributes());
+                .applyExportPolicies(routeEntry, this.bestPath.getAttributes(), entryDep.getAfiSafType());
         if (effAttrib.isPresent()) {
             final Route route = createRoute(ribSupport,
                     entryInfo.getRouteKey(), this.bestPath.getPathId(), this.bestPath);
@@ -185,7 +185,8 @@ final class BaseRouteEntry extends AbstractRouteEntry<BaseBestPath> {
     private void fillAdjRibsOut(
             @Nullable final Attributes attributes,
             @Nullable final Route route,
-            final Identifier routeKey, final PeerId fromPeerId,
+            final Identifier routeKey,
+            final PeerId fromPeerId,
             final RouteEntryDependenciesContainer routeEntryDep,
             final WriteTransaction tx) {
         /*
@@ -209,7 +210,7 @@ final class BaseRouteEntry extends AbstractRouteEntry<BaseBestPath> {
             if (fromPeer != null && attributes != null) {
                 final BGPRouteEntryExportParameters routeEntry
                         = new BGPRouteEntryExportParametersImpl(fromPeer, toPeer);
-                effAttr = routingPolicies.applyExportPolicies(routeEntry, attributes);
+                effAttr = routingPolicies.applyExportPolicies(routeEntry, attributes, routeEntryDep.getAfiSafType());
             }
             final InstanceIdentifier ribOutTarget
                     = ribSupport.createRouteIdentifier(toPeer.getRibOutIId(localTK), routeKey);
index cb3bdf5cbf855af9cd1a9a4c9eb4bb1f8d5ca1bb..d32058a831ad625764473931627d5300182e8bfc 100644 (file)
@@ -30,6 +30,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
 import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
 import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
 import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
 import org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContextRegistry;
 import org.opendaylight.protocol.bgp.rib.impl.state.BGPSessionStateImpl;
@@ -84,6 +85,7 @@ public class ApplicationPeer extends AbstractPeer implements ClusteredDOMDataTre
     private final YangInstanceIdentifier adjRibsInId;
     private final InstanceIdentifier<AdjRibOut> peerRibOutIId;
     private final KeyedInstanceIdentifier<Peer, PeerKey> peerIId;
+    private final BGPTableTypeRegistryConsumer tableTypeRegistry;
     private DOMTransactionChain chain;
     private DOMTransactionChain writerChain;
     private EffectiveRibInWriter effectiveRibInWriter;
@@ -110,9 +112,12 @@ public class ApplicationPeer extends AbstractPeer implements ClusteredDOMDataTre
         void register();
     }
 
-    public ApplicationPeer(final ApplicationRibId applicationRibId, final Ipv4Address ipAddress, final RIB rib) {
+    public ApplicationPeer(
+            final BGPTableTypeRegistryConsumer tableTypeRegistry,
+            final ApplicationRibId applicationRibId, final Ipv4Address ipAddress, final RIB rib) {
         super(rib, applicationRibId.getValue(), APP_PEER_GROUP, PeerRole.Internal,
                 new IpAddress(ipAddress), Collections.emptySet());
+        this.tableTypeRegistry = requireNonNull(tableTypeRegistry);
         final RIB targetRib = requireNonNull(rib);
         this.rawIdentifier = InetAddresses.forString(ipAddress.getValue()).getAddress();
         this.adjRibsInId = targetRib.getYangRibId().node(Peer.QNAME)
@@ -147,7 +152,8 @@ public class ApplicationPeer extends AbstractPeer implements ClusteredDOMDataTre
         this.adjRibInWriter = this.adjRibInWriter.transform(this.peerId, this.peerPath, context, localTables,
                 Collections.emptyMap(), registerAppPeerListener);
         this.effectiveRibInWriter = new EffectiveRibInWriter(this, this.rib,
-                this.rib.createPeerChain(this), this.peerIId, localTables);
+                this.rib.createPeerChain(this), this.peerIId, localTables, this.tableTypeRegistry
+        );
         this.effectiveRibInWriter.init();
         this.bgpSessionState.registerMessagesCounter(this);
         this.trackerRegistration = this.rib.getPeerTracker().registerPeer(this);
index eda7ecaf8cb772c04cf92de061274e2318015d54..109b42fb4da6eac1f6416f6be09617d5119aaa35 100644 (file)
@@ -36,6 +36,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.parser.BGPError;
 import org.opendaylight.protocol.bgp.parser.impl.message.update.LocalPreferenceAttributeParser;
@@ -103,6 +104,7 @@ public class BGPPeer extends AbstractPeer implements BGPSessionListener {
     private final RIB rib;
     private final Map<TablesKey, AdjRibOutListener> adjRibOutListenerSet = new HashMap<>();
     private final RpcProviderRegistry rpcRegistry;
+    private final BGPTableTypeRegistryConsumer tableTypeRegistry;
     private InstanceIdentifier<AdjRibOut> peerRibOutIId;
     @GuardedBy("this")
     private AbstractRegistration trackerRegistration;
@@ -129,6 +131,7 @@ public class BGPPeer extends AbstractPeer implements BGPSessionListener {
     private boolean sessionUp;
 
     public BGPPeer(
+            final BGPTableTypeRegistryConsumer tableTypeRegistry,
             final IpAddress neighborAddress,
             final String peerGroupName,
             final RIB rib,
@@ -140,20 +143,22 @@ public class BGPPeer extends AbstractPeer implements BGPSessionListener {
             final Set<TablesKey> afiSafisGracefulAdvertized) {
         super(rib, Ipv4Util.toStringIP(neighborAddress), peerGroupName, role, clusterId,
                 localAs, neighborAddress, afiSafisAdvertized, afiSafisGracefulAdvertized);
+        this.tableTypeRegistry = requireNonNull(tableTypeRegistry);
         this.rib = requireNonNull(rib);
         this.rpcRegistry = rpcRegistry;
         this.chain = rib.createPeerDOMChain(this);
     }
 
     BGPPeer(
+            final BGPTableTypeRegistryConsumer tableTypeRegistry,
             final IpAddress neighborAddress,
             final RIB rib,
             final PeerRole role,
             final RpcProviderRegistry rpcRegistry,
             final Set<TablesKey> afiSafisAdvertized,
             final Set<TablesKey> afiSafisGracefulAdvertized) {
-        this(neighborAddress, null, rib, role, null, null, rpcRegistry, afiSafisAdvertized,
-                afiSafisGracefulAdvertized);
+        this(tableTypeRegistry, neighborAddress, null, rib, role, null, null, rpcRegistry,
+                afiSafisAdvertized, afiSafisGracefulAdvertized);
     }
 
 
@@ -331,8 +336,9 @@ public class BGPPeer extends AbstractPeer implements BGPSessionListener {
         final Set<TablesKey> setTables = advertizedTableTypes.stream().map(t -> new TablesKey(t.getAfi(), t.getSafi()))
                 .collect(Collectors.toSet());
         this.tables = ImmutableSet.copyOf(setTables);
-        this.effRibInWriter = new EffectiveRibInWriter(this, this.rib, this.rib.createPeerChain(this),
-                peerIId, this.tables);
+        this.effRibInWriter = new EffectiveRibInWriter(this, this.rib,
+                this.rib.createPeerChain(this),
+                peerIId, this.tables, this.tableTypeRegistry);
         registerPrefixesCounters(this.effRibInWriter, this.effRibInWriter);
         this.peerRibOutIId = peerIId.child(AdjRibOut.class);
         this.effRibInWriter.init();
index fcbfd0409fd2b721b8210f5581517c83e6c9c222..7da3f6f3357baa8fa0e95730f6aab6df17ed0eac 100644 (file)
@@ -29,6 +29,7 @@ import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
 import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
 import org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContextRegistry;
 import org.opendaylight.protocol.bgp.rib.impl.state.peer.PrefixesInstalledCounters;
@@ -83,11 +84,16 @@ final class EffectiveRibInWriter implements PrefixesReceivedCounters, PrefixesIn
     private final Map<TablesKey, LongAdder> prefixesInstalled;
     private final BGPRibRoutingPolicy ribPolicies;
     private final BGPRouteEntryImportParameters peerImportParameters;
+    private final BGPTableTypeRegistryConsumer tableTypeRegistry;
 
-    EffectiveRibInWriter(final BGPRouteEntryImportParameters peer, final RIB rib,
+    EffectiveRibInWriter(
+            final BGPRouteEntryImportParameters peer,
+            final RIB rib,
             final BindingTransactionChain chain,
             final KeyedInstanceIdentifier<Peer, PeerKey> peerIId,
-            @Nonnull final Set<TablesKey> tables) {
+            final Set<TablesKey> tables,
+            final BGPTableTypeRegistryConsumer tableTypeRegistry
+    ) {
         this.registry = requireNonNull(rib.getRibSupportContext());
         this.chain = requireNonNull(chain);
         this.peerIId = requireNonNull(peerIId);
@@ -96,6 +102,7 @@ final class EffectiveRibInWriter implements PrefixesReceivedCounters, PrefixesIn
         this.prefixesReceived = buildPrefixesTables(tables);
         this.ribPolicies = requireNonNull(rib.getRibPolicies());
         this.databroker = requireNonNull(rib.getDataBroker());
+        this.tableTypeRegistry = requireNonNull(tableTypeRegistry);
         this.peerImportParameters = peer;
     }
 
@@ -216,7 +223,8 @@ final class EffectiveRibInWriter implements PrefixesReceivedCounters, PrefixesIn
         final InstanceIdentifier routeIID = ribSupport.createRouteIdentifier(tablePath, routeKey);
         CountersUtil.increment(this.prefixesReceived.get(tk), tk);
         final Optional<Attributes> effAtt = this.ribPolicies
-                .applyImportPolicies(this.peerImportParameters, route.getAttributes());
+                .applyImportPolicies(this.peerImportParameters, route.getAttributes(),
+                        tableTypeRegistry.getAfiSafiType(ribSupport.getTablesKey()).get());
         if (effAtt.isPresent()) {
             CountersUtil.increment(this.prefixesInstalled.get(tk), tk);
             tx.put(LogicalDatastoreType.OPERATIONAL, routeIID, route);
index 17784090ca8a40dc6fd4fd4b1d2ebda8e153fd5a..eb513690bd1f87668a8e84315454c04baf942f66 100644 (file)
@@ -37,6 +37,7 @@ import org.opendaylight.protocol.bgp.rib.spi.BGPPeerTracker;
 import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
 import org.opendaylight.protocol.bgp.rib.spi.RouterIds;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.Rib;
@@ -86,6 +87,7 @@ final class LocRibWriter implements AutoCloseable, TotalPrefixesCounter, TotalPa
             final BGPRibRoutingPolicy ribPolicies,
             final BGPPeerTracker peerTracker,
             final TablesKey tablesKey,
+            final Class<? extends AfiSafiType> afiSafiType,
             final PathSelectionMode pathSelectionMode) {
         this.chain = requireNonNull(chain);
         this.ribIId = requireNonNull(ribIId);
@@ -98,12 +100,14 @@ final class LocRibWriter implements AutoCloseable, TotalPrefixesCounter, TotalPa
         this.pathSelectionMode = pathSelectionMode;
 
         this.entryDep = new RouteEntryDependenciesContainerImpl(this.ribSupport, ribPolicies,
-                tablesKey, this.locRibTableIID);
+                tablesKey, afiSafiType, this.locRibTableIID);
         init();
     }
 
-    public static LocRibWriter create(@Nonnull final RIBSupport ribSupport,
+    public static LocRibWriter create(
+            @Nonnull final RIBSupport ribSupport,
             @Nonnull final TablesKey tablesKey,
+            @Nonnull final Class<? extends AfiSafiType> afiSafiType,
             @Nonnull final BindingTransactionChain chain,
             @Nonnull final KeyedInstanceIdentifier<Rib, RibKey> ribIId,
             @Nonnull final AsNumber ourAs,
@@ -112,7 +116,7 @@ final class LocRibWriter implements AutoCloseable, TotalPrefixesCounter, TotalPa
             @Nonnull final BGPPeerTracker peerTracker,
             @Nonnull final PathSelectionMode pathSelectionStrategy) {
         return new LocRibWriter(ribSupport, chain, ribIId, ourAs.getValue(), dataBroker, ribPolicies,
-                peerTracker, tablesKey, pathSelectionStrategy);
+                peerTracker, tablesKey, afiSafiType, pathSelectionStrategy);
     }
 
     @SuppressWarnings("unchecked")
index e0cdddab91ba3a3a423dcdbe37296831c18e9343..1ee8a83c4060c740d639f474afac2ae8c00b680e 100755 (executable)
@@ -40,6 +40,7 @@ import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
 import org.opendaylight.protocol.bgp.mode.api.PathSelectionMode;
 import org.opendaylight.protocol.bgp.mode.impl.base.BasePathSelectionModeFactory;
+import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
 import org.opendaylight.protocol.bgp.rib.impl.spi.CodecsRegistry;
 import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
@@ -98,6 +99,7 @@ public final class RIBImpl extends BGPRIBStateImpl implements RIB, TransactionCh
     private final YangInstanceIdentifier yangRibId;
     private final RIBSupportContextRegistryImpl ribContextRegistry;
     private final CodecsRegistryImpl codecsRegistry;
+    private final BGPTableTypeRegistryConsumer tableTypeRegistry;
     @GuardedBy("this")
     private ClusterSingletonServiceRegistration registration;
     private final DOMDataBrokerExtension domService;
@@ -112,7 +114,9 @@ public final class RIBImpl extends BGPRIBStateImpl implements RIB, TransactionCh
     @GuardedBy("this")
     private boolean isServiceInstantiated;
 
-    public RIBImpl(final RibId ribId,
+    public RIBImpl(
+            final BGPTableTypeRegistryConsumer tableTypeRegistry,
+            final RibId ribId,
             final AsNumber localAs,
             final BgpId localBgpId,
             final RIBExtensionConsumerContext extensions,
@@ -127,6 +131,7 @@ public final class RIBImpl extends BGPRIBStateImpl implements RIB, TransactionCh
     ) {
         super(InstanceIdentifier.create(BgpRib.class).child(Rib.class, new RibKey(requireNonNull(ribId))),
                 localBgpId, localAs);
+        this.tableTypeRegistry = requireNonNull(tableTypeRegistry);
         this.localAs = requireNonNull(localAs);
         this.bgpIdentifier = requireNonNull(localBgpId);
         this.dispatcher = requireNonNull(dispatcher);
@@ -199,6 +204,7 @@ public final class RIBImpl extends BGPRIBStateImpl implements RIB, TransactionCh
         final LocRibWriter locRibWriter = LocRibWriter.create(
                 ribSupport,
                 key,
+                this.tableTypeRegistry.getAfiSafiType(key).get(),
                 txChain,
                 getInstanceIdentifier(),
                 this.localAs,
index a7c7a39df71300005d33bfb97d4dec7503ca0727..014035ad6ff3d97c57060948b61bf1f884044f4a 100644 (file)
@@ -9,9 +9,11 @@ package org.opendaylight.protocol.bgp.rib.impl;
 
 import static java.util.Objects.requireNonNull;
 
+import javax.annotation.Nonnull;
 import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
 import org.opendaylight.protocol.bgp.rib.spi.entry.RouteEntryDependenciesContainer;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
@@ -21,14 +23,17 @@ public final class RouteEntryDependenciesContainerImpl implements RouteEntryDepe
     private final TablesKey tablesKey;
     private final KeyedInstanceIdentifier<Tables, TablesKey> locRibTarget;
     private final BGPRibRoutingPolicy routingPolicies;
+    private final Class<? extends AfiSafiType> afiSafiType;
 
     public RouteEntryDependenciesContainerImpl(
             final RIBSupport ribSupport,
             final BGPRibRoutingPolicy routingPolicies,
             final TablesKey tablesKey,
+            final Class<? extends AfiSafiType> afiSafiType,
             final KeyedInstanceIdentifier<Tables, TablesKey> locRibTarget) {
         this.ribSupport = requireNonNull(ribSupport);
         this.tablesKey = requireNonNull(tablesKey);
+        this.afiSafiType = requireNonNull(afiSafiType);
         this.routingPolicies = requireNonNull(routingPolicies);
         this.locRibTarget = requireNonNull(locRibTarget);
     }
@@ -43,6 +48,11 @@ public final class RouteEntryDependenciesContainerImpl implements RouteEntryDepe
         return this.tablesKey;
     }
 
+    @Override
+    public Class<? extends AfiSafiType> getAfiSafType() {
+        return this.afiSafiType;
+    }
+
     @Override
     public KeyedInstanceIdentifier<Tables, TablesKey> getLocRibTableTarget() {
         return this.locRibTarget;
index d3ca61416eefbc3fa7cba1fc20b1de795c0b7bef..a125f3788fb1e5949e03187a2e2f92033906ab1d 100644 (file)
@@ -61,7 +61,7 @@ public final class AppPeer implements PeerBean, BGPPeerStateConsumer {
                 "Previous peer instance was not closed.");
         this.currentConfiguration = neighbor;
         this.bgpAppPeerSingletonService = new BgpAppPeerSingletonService(rib, createAppRibId(neighbor),
-                neighbor.getNeighborAddress().getIpv4Address());
+                neighbor.getNeighborAddress().getIpv4Address(), tableTypeRegistry);
     }
 
     @Override
@@ -120,8 +120,9 @@ public final class AppPeer implements PeerBean, BGPPeerStateConsumer {
         @GuardedBy("this")
         private boolean isServiceInstantiated;
 
-        BgpAppPeerSingletonService(final RIB rib, final ApplicationRibId appRibId, final Ipv4Address neighborAddress) {
-            this.applicationPeer = new ApplicationPeer(appRibId, neighborAddress, rib);
+        BgpAppPeerSingletonService(final RIB rib, final ApplicationRibId appRibId, final Ipv4Address neighborAddress,
+                final BGPTableTypeRegistryConsumer tableTypeRegistry) {
+            this.applicationPeer = new ApplicationPeer(tableTypeRegistry, appRibId, neighborAddress, rib);
             this.appRibId = appRibId;
             this.dataTreeChangeService = rib.getService();
         }
index e3547f881c640900b6dd221c62dfa9313e6a7f5a..efe7cab0003975ff317fe97f809a8095fa17241d 100644 (file)
@@ -268,8 +268,8 @@ public final class BgpPeer implements PeerBean, BGPPeerStateConsumer {
                 neighborLocalAs = globalAs;
             }
 
-            this.bgpPeer = new BGPPeer(this.neighborAddress, peerGroupName, rib, role, clusterId, neighborLocalAs,
-                    BgpPeer.this.rpcRegistry, afiSafisAdvertized, Collections.emptySet());
+            this.bgpPeer = new BGPPeer(tableTypeRegistry, this.neighborAddress, peerGroupName, rib, role, clusterId,
+                    neighborLocalAs, BgpPeer.this.rpcRegistry, afiSafisAdvertized, Collections.emptySet());
             this.prefs = new BGPSessionPreferences(neighborLocalAs, hold, rib.getBgpIdentifier(),
                     neighborRemoteAs, bgpParameters, getPassword(keyMapping));
             this.activeConnection = OpenConfigMappingUtil.isActive(neighbor, peerGroup);
index 2a96ad886aaeaf977fd4c94a984fff606ff9d188..8f7125b63b19386277b917adafef0927434f0427 100644 (file)
@@ -266,6 +266,7 @@ public final class RibImpl implements RIB, BGPRibStateConsumer, AutoCloseable {
                 this.extensions.getClassLoadingStrategy());
 
         return new RIBImpl(
+                tableTypeRegistry,
                 new RibId(bgpInstanceName),
                 this.asNumber,
                 new BgpId(this.routerId),
index e3f8b1f1da6fb2821b6008921bff52bbe5709e96..7a3751f0f0066d2187b9f1adcb2f24c32a65595a 100644 (file)
@@ -32,6 +32,7 @@ import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
 import org.opendaylight.protocol.bgp.inet.RIBActivator;
+import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
 import org.opendaylight.protocol.bgp.parser.BGPError;
 import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
 import org.opendaylight.protocol.bgp.parser.impl.BGPActivator;
@@ -232,11 +233,11 @@ public abstract class AbstractAddPathTest extends DefaultRibPoliciesMockTest {
         return connectPeer(peer, clientDispatcher);
     }
 
-    protected static BGPPeer configurePeer(final Ipv4Address peerAddress, final RIBImpl ribImpl,
-        final BgpParameters bgpParameters, final PeerRole peerRole, final BGPPeerRegistry bgpPeerRegistry) {
+    protected static BGPPeer configurePeer(final BGPTableTypeRegistryConsumer tableRegistry, final Ipv4Address peerAddress, final RIBImpl ribImpl,
+            final BgpParameters bgpParameters, final PeerRole peerRole, final BGPPeerRegistry bgpPeerRegistry) {
         final IpAddress ipAddress = new IpAddress(peerAddress);
 
-        final BGPPeer bgpPeer = new BGPPeer(new IpAddress(peerAddress), ribImpl, peerRole, null,
+        final BGPPeer bgpPeer = new BGPPeer(tableRegistry, new IpAddress(peerAddress), ribImpl, peerRole, null,
             AFI_SAFIS_ADVERTIZED, Collections.emptySet());
         final List<BgpParameters> tlvs = Lists.newArrayList(bgpParameters);
         bgpPeerRegistry.addPeer(ipAddress, bgpPeer,
index 86f3ce7f0227282938e8494a1969ade9d249aab9..97d487df915dfcfde51134b062143673e679326d 100644 (file)
@@ -181,7 +181,7 @@ public class AbstractRIBTestSetup extends DefaultRibPoliciesMockTest {
         mockedMethods();
         doReturn(mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider)
                 .registerClusterSingletonService(any(ClusterSingletonService.class));
-        this.rib = new RIBImpl(new RibId("test"), new AsNumber(5L), RIB_ID, context,
+        this.rib = new RIBImpl(this.tableRegistry, new RibId("test"), new AsNumber(5L), RIB_ID, context,
                 this.dispatcher, codecsRegistry, this.dom, getDataBroker(), this.policies, this.peerTracker,
                 localTables, Collections.singletonMap(new TablesKey(AFI, SAFI),
                 BasePathSelectionModeFactory.createBestPathSelectionStrategy(this.peerTracker)));
index dde75a677f00263238aaf97997f55916cbcc6bfc..ff5a2612027e87a9965a399966185254bdbf2eb7 100644 (file)
@@ -55,7 +55,7 @@ public class AddPathAllPathsTest extends AbstractAddPathTest {
         final Map<TablesKey, PathSelectionMode> pathTables
                 = ImmutableMap.of(TABLES_KEY, new AllPathSelection(this.peerTracker));
 
-        this.ribImpl = new RIBImpl(new RibId("test-rib"), AS_NUMBER, BGP_ID,
+        this.ribImpl = new RIBImpl(this.tableRegistry, new RibId("test-rib"), AS_NUMBER, BGP_ID,
                 this.ribExtension, this.serverDispatcher, this.codecsRegistry,
             getDomBroker(), getDataBroker(), this.policies, this.peerTracker, TABLES_TYPE, pathTables);
 
@@ -86,17 +86,17 @@ public class AddPathAllPathsTest extends AbstractAddPathTest {
         final BgpParameters nonAddPathParams = createParameter(false);
         final BgpParameters addPathParams = createParameter(true);
 
-        final BGPPeer peer1 = configurePeer(PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+        final BGPPeer peer1 = configurePeer(this.tableRegistry, PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
         final BGPSessionImpl session1 = createPeerSession(PEER1, nonAddPathParams, new SimpleSessionListener());
 
-        configurePeer(PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
         final BGPSessionImpl session2 = createPeerSession(PEER2, nonAddPathParams, new SimpleSessionListener());
 
-        configurePeer(PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
         final BGPSessionImpl session3 = createPeerSession(PEER3, nonAddPathParams, new SimpleSessionListener());
 
         final SimpleSessionListener listener4 = new SimpleSessionListener();
-        final BGPPeer peer4 = configurePeer(PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
+        final BGPPeer peer4 = configurePeer(this.tableRegistry, PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
 
         BGPPeerState peer4State = peer4.getPeerState();
         assertNull(peer4State.getGroupId());
@@ -132,7 +132,7 @@ public class AddPathAllPathsTest extends AbstractAddPathTest {
         final BGPSessionImpl session4 = createPeerSession(PEER4, nonAddPathParams, listener4);
 
         final SimpleSessionListener listener5 = new SimpleSessionListener();
-        configurePeer(PEER5, this.ribImpl, addPathParams, PeerRole.RrClient, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER5, this.ribImpl, addPathParams, PeerRole.RrClient, this.serverRegistry);
         final BGPSessionImpl session5 = createPeerSession(PEER5, addPathParams, listener5);
         checkPeersPresentOnDataStore(5);
 
@@ -191,7 +191,7 @@ public class AddPathAllPathsTest extends AbstractAddPathTest {
         assertEquals(1L, ribState.getTotalPrefixesCount());
 
         final SimpleSessionListener listener6 = new SimpleSessionListener();
-        final BGPPeer peer6 = configurePeer(PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
+        final BGPPeer peer6 = configurePeer(this.tableRegistry, PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
         final BGPSessionImpl session6 = createPeerSession(PEER6, nonAddPathParams, listener6);
         checkPeersPresentOnDataStore(6);
         checkReceivedMessages(listener6, 1);
index d8a3cb4331ecb0faa957e1a0b8411deaf2dd9a80..34f428df36bb81b89cf21bbae71685964f9fa1dc 100644 (file)
@@ -42,7 +42,8 @@ public class AddPathBasePathsTest extends AbstractAddPathTest {
         final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(tk,
             BasePathSelectionModeFactory.createBestPathSelectionStrategy(this.peerTracker));
 
-        this.ribImpl = new RIBImpl(new RibId("test-rib"), AS_NUMBER, new BgpId(RIB_ID), this.ribExtension,
+        this.ribImpl = new RIBImpl(this.tableRegistry, new RibId("test-rib"), AS_NUMBER, new BgpId(RIB_ID),
+                this.ribExtension,
                 this.serverDispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies,
                 this.peerTracker, TABLES_TYPE, pathTables);
         this.ribImpl.instantiateServiceInstance();
@@ -71,21 +72,21 @@ public class AddPathBasePathsTest extends AbstractAddPathTest {
     public void testUseCase1() throws Exception {
         final BgpParameters nonAddPathParams = createParameter(false);
 
-        configurePeer(PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
         final BGPSessionImpl session1 = createPeerSession(PEER1, nonAddPathParams, new SimpleSessionListener());
 
-        configurePeer(PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
         final BGPSessionImpl session2 = createPeerSession(PEER2, nonAddPathParams, new SimpleSessionListener());
 
-        configurePeer(PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
         final BGPSessionImpl session3 = createPeerSession(PEER3,nonAddPathParams, new SimpleSessionListener());
 
         final SimpleSessionListener listener4 = new SimpleSessionListener();
-        configurePeer(PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
         final BGPSessionImpl session4 = createPeerSession(PEER4, nonAddPathParams, listener4);
 
         final SimpleSessionListener listener5 = new SimpleSessionListener();
-        configurePeer(PEER5, this.ribImpl, nonAddPathParams, PeerRole.Ebgp, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER5, this.ribImpl, nonAddPathParams, PeerRole.Ebgp, this.serverRegistry);
         final BGPSessionImpl session5 = createPeerSession(PEER5, nonAddPathParams, listener5);
         checkPeersPresentOnDataStore(5);
 
@@ -109,7 +110,7 @@ public class AddPathBasePathsTest extends AbstractAddPathTest {
         assertEquals(UPD_NA_200_EBGP, listener5.getListMsg().get(1));
 
         final SimpleSessionListener listener6 = new SimpleSessionListener();
-        configurePeer(PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
         final BGPSessionImpl session6 = createPeerSession(PEER6, nonAddPathParams, listener6);
 
         checkPeersPresentOnDataStore(6);
index 9b70c277d052c4ab4317ffd79defb7c87972df0a..28ebdcb764a40b560f111a4ca4243c43c5b6d863 100644 (file)
@@ -42,7 +42,8 @@ public class AddPathNPathsTest extends AbstractAddPathTest {
         final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(tk,
                 new AddPathBestNPathSelection(2L, this.peerTracker));
 
-        this.ribImpl = new RIBImpl(new RibId("test-rib"), AS_NUMBER, new BgpId(RIB_ID), this.ribExtension,
+        this.ribImpl = new RIBImpl(this.tableRegistry, new RibId("test-rib"), AS_NUMBER, new BgpId(RIB_ID),
+                this.ribExtension,
                 this.serverDispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies,
                 this.peerTracker, TABLES_TYPE,  pathTables);
 
@@ -73,21 +74,21 @@ public class AddPathNPathsTest extends AbstractAddPathTest {
         final BgpParameters nonAddPathParams = createParameter(false);
         final BgpParameters addPathParams = createParameter(true);
 
-        configurePeer(PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
         final BGPSessionImpl session1 = createPeerSession(PEER1, nonAddPathParams, new SimpleSessionListener());
 
-        configurePeer(PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
        final BGPSessionImpl session2 = createPeerSession(PEER2, nonAddPathParams, new SimpleSessionListener());
 
-        configurePeer(PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
         final BGPSessionImpl session3 = createPeerSession(PEER3, nonAddPathParams, new SimpleSessionListener());
 
         final SimpleSessionListener listener4 = new SimpleSessionListener();
-        configurePeer(PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
         final BGPSessionImpl session4 = createPeerSession(PEER4, nonAddPathParams, listener4);
 
         final SimpleSessionListener listener5 = new SimpleSessionListener();
-        configurePeer(PEER5, this.ribImpl, addPathParams, PeerRole.RrClient, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER5, this.ribImpl, addPathParams, PeerRole.RrClient, this.serverRegistry);
         final BGPSessionImpl session5 = createPeerSession(PEER5, addPathParams, listener5);
         checkPeersPresentOnDataStore(5);
 
@@ -98,7 +99,7 @@ public class AddPathNPathsTest extends AbstractAddPathTest {
         assertEquals(UPD_100, listener5.getListMsg().get(0));
 
         final SimpleSessionListener listener6 = new SimpleSessionListener();
-        configurePeer(PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
         final BGPSessionImpl session6 = createPeerSession(PEER6, nonAddPathParams, listener6);
         checkPeersPresentOnDataStore(6);
         checkReceivedMessages(listener6, 1);
index 43aa5beef5ce0636b376380de5e6296ee497b952..9c682fec0fd6530b894a8d09b4455d1115c58d82 100644 (file)
@@ -7,18 +7,23 @@
  */
 package org.opendaylight.protocol.bgp.rib.impl;
 
+import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doReturn;
 
 import java.util.Collections;
+import java.util.Optional;
 import org.junit.Before;
 import org.mockito.Mock;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.impl.BGPRibRoutingPolicyFactoryImpl;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.BGPRibRoutingPolicyFactory;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.statement.AbstractStatementRegistryConsumerTest;
+import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.DefaultPolicyType;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.apply.policy.group.apply.policy.Config;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.BgpId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.ClusterIdentifier;
 
@@ -29,6 +34,8 @@ public class DefaultRibPoliciesMockTest extends AbstractStatementRegistryConsume
     protected BGPRibRoutingPolicy policies;
     protected BGPRibRoutingPolicyFactory policyProvider;
     @Mock
+    protected BGPTableTypeRegistryConsumer tableRegistry;
+    @Mock
     private Config config;
 
     @Before
@@ -38,6 +45,7 @@ public class DefaultRibPoliciesMockTest extends AbstractStatementRegistryConsume
         doReturn(DefaultPolicyType.REJECTROUTE).when(this.config).getDefaultExportPolicy();
         doReturn(Collections.singletonList("default-odl-import-policy")).when(this.config).getImportPolicy();
         doReturn(Collections.singletonList("default-odl-export-policy")).when(this.config).getExportPolicy();
+        doReturn(Optional.of(IPV4UNICAST.class)).when(this.tableRegistry).getAfiSafiType(any(TablesKey.class));
 
         this.policyProvider = new BGPRibRoutingPolicyFactoryImpl(getDataBroker(), this.statementRegistry);
         this.policies = this.policyProvider.buildBGPRibPolicy(AS, this.bgpID, this.ci, this.config);
index 4b1e0859b48a2598c02ea228e6b62f47e0e666a8..e3148da2437fb2632bcb7c4381968faf2e822609 100755 (executable)
@@ -112,15 +112,15 @@ public class ParserToSalTest extends DefaultRibPoliciesMockTest {
         final List<BgpTableType> tables = ImmutableList.of(new BgpTableTypeImpl(LinkstateAddressFamily.class,
                 LinkstateSubsequentAddressFamily.class));
 
-        final RIBImpl rib = new RIBImpl(new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext2, this.dispatcher,
-                this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies, this.peerTracker, tables,
-                Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory
+        final RIBImpl rib = new RIBImpl(this.tableRegistry, new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext2,
+                this.dispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies, this.peerTracker,
+                tables, Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory
                         .createBestPathSelectionStrategy(this.peerTracker)));
         rib.instantiateServiceInstance();
         assertTablesExists(tables);
         rib.onGlobalContextUpdated(this.schemaService.getGlobalContext());
-        final BGPPeer peer = new BGPPeer(this.localAddress, rib, PeerRole.Ibgp, null, Collections.emptySet(),
-                Collections.emptySet());
+        final BGPPeer peer = new BGPPeer(this.tableRegistry, this.localAddress, rib, PeerRole.Ibgp, null,
+                Collections.emptySet(), Collections.emptySet());
         peer.instantiateServiceInstance();
         final ListenerRegistration<?> reg = this.mock.registerUpdateListener(peer);
         reg.close();
@@ -130,15 +130,15 @@ public class ParserToSalTest extends DefaultRibPoliciesMockTest {
     public void testWithoutLinkstate() throws ReadFailedException {
         final List<BgpTableType> tables = ImmutableList.of(new BgpTableTypeImpl(Ipv4AddressFamily.class,
                 UnicastSubsequentAddressFamily.class));
-        final RIBImpl rib = new RIBImpl(new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext1, this.dispatcher,
-                this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies, this.peerTracker, tables,
-                Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory
-                        .createBestPathSelectionStrategy(this.peerTracker)));
+        final RIBImpl rib = new RIBImpl(this.tableRegistry, new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext1,
+                this.dispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies, this.peerTracker,
+                tables, Collections.singletonMap(TABLE_KEY,
+                BasePathSelectionModeFactory.createBestPathSelectionStrategy(this.peerTracker)));
         rib.instantiateServiceInstance();
         rib.onGlobalContextUpdated(this.schemaService.getGlobalContext());
         assertTablesExists(tables);
-        final BGPPeer peer = new BGPPeer(this.localAddress, rib, PeerRole.Ibgp, null, Collections.emptySet(),
-                Collections.emptySet());
+        final BGPPeer peer = new BGPPeer(this.tableRegistry, this.localAddress, rib, PeerRole.Ibgp, null,
+                Collections.emptySet(), Collections.emptySet());
         peer.instantiateServiceInstance();
         final ListenerRegistration<?> reg = this.mock.registerUpdateListener(peer);
         reg.close();
index b96956927302b56b27e87b9bbad2121ab379bf4c..3925ff3f827335de880ab51f7e7d9a2b64e9388d 100644 (file)
@@ -122,7 +122,8 @@ public class PeerTest extends AbstractRIBTestSetup {
         final Ipv4Prefix first = new Ipv4Prefix("127.0.0.2/32");
         final Ipv4Prefix second = new Ipv4Prefix("127.0.0.1/32");
         final Ipv4Prefix third = new Ipv4Prefix("127.0.0.3/32");
-        this.peer = new ApplicationPeer(new ApplicationRibId(this.neighborAddress.getIpv4Address().getValue()),
+        this.peer = new ApplicationPeer(this.tableRegistry,
+                new ApplicationRibId(this.neighborAddress.getIpv4Address().getValue()),
                 this.neighborAddress.getIpv4Address(), getRib());
         this.peer.instantiateServiceInstance(null, null);
         final YangInstanceIdentifier base = getRib().getYangRibId().node(LocRib.QNAME)
@@ -136,7 +137,7 @@ public class PeerTest extends AbstractRIBTestSetup {
 
     @Test
     public void testClassicPeer() throws Exception {
-        this.classic = new BGPPeer(this.neighborAddress, getRib(), PeerRole.Ibgp, null,
+        this.classic = new BGPPeer(this.tableRegistry, this.neighborAddress, getRib(), PeerRole.Ibgp, null,
                 Collections.emptySet(), Collections.emptySet());
         this.classic.instantiateServiceInstance();
         this.mockSession();
@@ -178,7 +179,7 @@ public class PeerTest extends AbstractRIBTestSetup {
         assertEquals(3, this.routes.size());
 
         //create new peer so that it gets advertized routes from RIB
-        final BGPPeer testingPeer = new BGPPeer(this.neighborAddress, getRib(), PeerRole.Ibgp, null,
+        final BGPPeer testingPeer = new BGPPeer(this.tableRegistry, this.neighborAddress, getRib(), PeerRole.Ibgp, null,
                 Collections.emptySet(), Collections.emptySet());
         testingPeer.instantiateServiceInstance();
         testingPeer.onSessionUp(this.session);
index 8b861a1be37c8029ac97bf4bd073beb224ec3b48..4dd744b4c196e03f209422897356721ea7d3616a 100644 (file)
@@ -208,14 +208,15 @@ public class SynchronizationAndExceptionTest extends AbstractAddPathTest {
     public void testHandleMessageAfterException() {
         final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(TABLES_KEY,
             BasePathSelectionModeFactory.createBestPathSelectionStrategy(this.peerTracker));
-        final RIBImpl ribImpl = new RIBImpl( new RibId(RIB_ID), AS_NUMBER,  new BgpId(RIB_ID), this.ribExtension,
+        final RIBImpl ribImpl = new RIBImpl(this.tableRegistry, new RibId(RIB_ID), AS_NUMBER,  new BgpId(RIB_ID),
+                this.ribExtension,
                 this.serverDispatcher, this.codecsRegistry, this.domBroker, getDataBroker(), this.policies,
                 this.peerTracker, ImmutableList.of(this.ipv4tt), pathTables);
         ribImpl.instantiateServiceInstance();
         ribImpl.onGlobalContextUpdated(this.schemaService.getGlobalContext());
 
-        final BGPPeer bgpPeer = new BGPPeer(neighbor, ribImpl, PeerRole.Ibgp, null, AFI_SAFIS_ADVERTIZED,
-                Collections.emptySet());
+        final BGPPeer bgpPeer = new BGPPeer(this.tableRegistry, neighbor, ribImpl, PeerRole.Ibgp, null,
+                AFI_SAFIS_ADVERTIZED, Collections.emptySet());
         bgpPeer.instantiateServiceInstance();
         final BGPSessionImpl bgpSession = new BGPSessionImpl(bgpPeer, this.speakerListener, this.classicOpen,
                 this.classicOpen.getHoldTimer(), null);
@@ -256,14 +257,15 @@ public class SynchronizationAndExceptionTest extends AbstractAddPathTest {
     public void testUseCase1() {
         final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(TABLES_KEY,
                 BasePathSelectionModeFactory.createBestPathSelectionStrategy(this.peerTracker));
-        final RIBImpl ribImpl = new RIBImpl(new RibId(RIB_ID), AS_NUMBER, new BgpId(RIB_ID), this.ribExtension,
+        final RIBImpl ribImpl = new RIBImpl(this.tableRegistry, new RibId(RIB_ID), AS_NUMBER, new BgpId(RIB_ID),
+                this.ribExtension,
                 this.serverDispatcher, this.codecsRegistry, this.domBroker, getDataBroker(), this.policies,
                 this.peerTracker, ImmutableList.of(this.ipv4tt), pathTables);
         ribImpl.instantiateServiceInstance();
         ribImpl.onGlobalContextUpdated(this.schemaService.getGlobalContext());
 
-        final BGPPeer bgpPeer = new BGPPeer(neighbor, ribImpl, PeerRole.Ibgp, null, AFI_SAFIS_ADVERTIZED,
-                Collections.emptySet());
+        final BGPPeer bgpPeer = new BGPPeer(this.tableRegistry, neighbor, ribImpl, PeerRole.Ibgp, null,
+                AFI_SAFIS_ADVERTIZED, Collections.emptySet());
         bgpPeer.instantiateServiceInstance();
         final BGPSessionImpl bgpSession = new BGPSessionImpl(bgpPeer, this.speakerListener, this.classicOpen,
                 this.classicOpen.getHoldTimer(), null);
index a9d151bb3d165b6edb1615d6d6fdfe0bdde8a39d..bc3e8fc8a9e0b6b3aa92d50454b747aaa6625b14 100644 (file)
             <groupId>${project.groupId}</groupId>
             <artifactId>bgp-rib-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.bgpcep</groupId>
+            <artifactId>bgp-openconfig-api</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal.model</groupId>
             <artifactId>ietf-inet-types-2013-07-15</artifactId>
index fcf04912cad70f8d5e561d3bd0b1dd22bf984a06..5a499d3ea3882fd903f961de97913e572a4a7dd0 100644 (file)
@@ -105,6 +105,7 @@ public abstract class AbstractRIBSupport<
     private final NodeIdentifier rdNid;
     protected final BindingNormalizedNodeSerializer mappingService;
     protected final YangInstanceIdentifier routeDefaultYii;
+    private final TablesKey tk;
 
     /**
      * Default constructor. Requires the QName of the container augmented under the routes choice
@@ -138,7 +139,7 @@ public abstract class AbstractRIBSupport<
         this.listClass = requireNonNull(listClass);
         this.routeQname = BindingReflections.findQName(listClass).withModule(module);
         this.routesListIdentifier = new NodeIdentifier(this.routeQname);
-        final TablesKey tk = new TablesKey(afiClass, safiClass);
+        this.tk = new TablesKey(afiClass, safiClass);
         //FIXME Use Route Case IId instead of Tables IId.
         this.emptyRoutes = (ChoiceNode) ((MapEntryNode) this.mappingService
                 .toNormalizedNode(TABLES_II, new TablesBuilder().setKey(tk)
@@ -166,6 +167,11 @@ public abstract class AbstractRIBSupport<
                         .node(this.routeQname).build();
     }
 
+    @Override
+    public final TablesKey getTablesKey() {
+        return this.tk;
+    }
+
     @Override
     public final Class<C> routesCaseClass() {
         return this.cazeClass;
diff --git a/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AddPathRibSupport.java b/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AddPathRibSupport.java
deleted file mode 100644 (file)
index b1e7cb7..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco 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.rib.spi;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-
-/**
- * Interface implemented to be extended by RibSupport.
- * This interface exposes methods to access to Add Path information
- * By default we implement non supported Multiple Path therefore
- * 0 Path Id is returned and null PathArgument
- * Deprecated: All families should support additional path
- */
-@Deprecated
-interface AddPathRibSupport {
-    /**
-     * Construct a PathArgument to an AddPathRoute.
-     *
-     * @param pathId  The path identifier
-     * @param routeId PathArgument leaf path
-     * @return routeId PathArgument + pathId or Null in case Add-path is not supported
-     */
-    @Deprecated
-    @Nullable
-    default PathArgument getRouteIdAddPath(long pathId, @Nonnull PathArgument routeId) {
-        return null;
-    }
-
-    /**
-     * Create a new Path Argument for route Key removing remove Path Id from key.
-     * For extension which do not support Multiple Path this step is not required.
-     *
-     * @param routeKey routeKey Path Argument
-     * @return new route Key
-     */
-    @Deprecated
-    default NodeIdentifierWithPredicates createRouteKeyPathArgument(@Nonnull NodeIdentifierWithPredicates routeKey) {
-        return null;
-    }
-}
index 7b39b1eacf0bd790d80c68c8f0df21257f176849..e792a4dc33eb60c918fda622346c0231f5585892 100644 (file)
@@ -236,6 +236,13 @@ public interface RIBSupport<
     @Nonnull
     R createRoute(@Nullable R route, String routeKey, @Nullable long pathId, @Nonnull Attributes attributes);
 
+    /**
+     * Returns TablesKey which we are providing support.
+     *
+     * @return TablesKey
+     */
+    TablesKey getTablesKey();
+
     interface ApplyRoute {
         void apply(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier base,
                 @Nonnull NodeIdentifierWithPredicates routeKey,
index e24d439398373a7ebc9fdd86ae9837f420b224d1..a94f4f9753ccbe7b7d060b364e9b86534279e5ca 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.protocol.bgp.rib.spi.entry;
 import javax.annotation.Nonnull;
 import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
@@ -35,6 +36,14 @@ public interface RouteEntryDependenciesContainer {
     @Nonnull
     TablesKey getLocalTablesKey();
 
+    /**
+     * Returns the AfiSafiType(AFI/SAFI) corresponding to the Route Entry.
+     *
+     * @return TablesKey
+     */
+    @Nonnull
+    Class<? extends AfiSafiType> getAfiSafType();
+
 
     /**
      * Returns the loc-rib table to be updated and to which  corresponds this Route Entry.
index 21dfccf682f39831f78b6c91c8efb822d2b8543d..f60580d9b9fe242e30b919e28c105b65f4f67bdc 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.protocol.bgp.rib.spi.policy;
 
 import java.util.Optional;
 import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
 
 /**
@@ -20,12 +21,14 @@ public interface BGPRibRoutingPolicy {
      *
      * @param policyParameters containing attributes and sender peer information
      * @param attributes       Route attributes
+     * @param afiSafType       Afi Safi Type
      * @return modified route attributes after apply policies
      */
     @Nonnull
     Optional<Attributes> applyImportPolicies(
             @Nonnull BGPRouteEntryImportParameters policyParameters,
-            @Nonnull Attributes attributes
+            @Nonnull Attributes attributes,
+            @Nonnull Class<? extends AfiSafiType> afiSafType
     );
 
     /**
@@ -33,11 +36,13 @@ public interface BGPRibRoutingPolicy {
      *
      * @param policyParameters containing attributes and sender/receiver peer information
      * @param attributes       Route attributes
+     * @param afiSafType       Afi Safi Type
      * @return modified route attributes after apply policies
      */
     @Nonnull
     Optional<Attributes> applyExportPolicies(
             @Nonnull BGPRouteEntryExportParameters policyParameters,
-            @Nonnull Attributes attributes
+            @Nonnull Attributes attributes,
+            @Nonnull Class<? extends AfiSafiType> afiSafType
     );
 }