Implement Set Next Hop Type Self 02/73602/5
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Fri, 29 Jun 2018 09:19:02 +0000 (11:19 +0200)
committerClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Mon, 2 Jul 2018 09:54:36 +0000 (11:54 +0200)
remove duplicated route policy, using
openconfig one.

Change-Id: I04fc6167956134bb2769cedbc04df48fb3d4c943
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
bgp/openconfig-api/src/main/yang/odl-bgp-default-policy.yang
bgp/openconfig-rp-spi/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/spi/registry/ActionsRegistryImpl.java
bgp/openconfig-rp-spi/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/spi/AppendActionTest.java
bgp/openconfig-rp-spi/src/test/resources/initial/routing-policy-config.xml
bgp/openconfig-rp-statement/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/SetLocalAddressAsNextHopHandler.java [deleted file]
bgp/openconfig-rp-statement/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/StatementActivator.java
bgp/openconfig-rp-statement/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/actions/SetOriginatorIdToAdvertizerRouterIdHandler.java [deleted file]
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/SetLocalAddressAsNextHopHandlerTest.java [deleted file]
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/SetOriginatorIdToAdvertizerRouterIdHandlerTest.java [deleted file]
bgp/openconfig-rp-statement/src/test/resources/initial/routing-policy-config.xml
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBImpl.java

index e2c57e38bd49f3d4046b26bb88beed570e752732..30accef2d364556d11a32179066ccbeeeb27876b 100644 (file)
@@ -297,24 +297,6 @@ module odl-bgp-policy {
         }
     }
 
-    augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:actions/bgp-pol:bgp-actions {
-        ext:augment-identifier set-originator-id-to-advertizer-router-id;
-        container set-originator-id-to-advertizer-router-id {
-
-        presence "node is present in the config data to apply the set-originator-id-to-advertizer-router-id action";
-        description "action to set router-id of the advertiser as Originator attribute";
-        }
-    }
-
-    augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:actions/bgp-pol:bgp-actions {
-        ext:augment-identifier set-local-address-as-next-hop;
-        container set-local-address-as-next-hop {
-
-        presence "node is present in the config data to apply set-local-address-as-next-hop action";
-        description "action to set local address as next hop";
-        }
-    }
-
     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:actions/bgp-pol:bgp-actions {
         ext:augment-identifier set-originator-id-prepend;
         container set-originator-id-prepend {
index 7f69af6a3c2b32eaa3246e0497e89919fa7fae01..f6dbd9545fbf0a205a0c60436afba7e93cdb0620 100644 (file)
@@ -185,8 +185,8 @@ final class ActionsRegistryImpl {
 
                 if (nhAction != null) {
                     final IpAddress address = nhAction.getIpAddress();
+                    CNextHop nhNew;
                     if (address != null) {
-                        CNextHop nhNew;
                         if (address.getIpv4Address() != null) {
                             nhNew = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder()
                                     .setGlobal(address.getIpv4Address()).build()).build();
@@ -196,6 +196,11 @@ final class ActionsRegistryImpl {
                         }
 
                         attributesUpdatedBuilder.setCNextHop(nhNew);
+                    } else if (nhAction.getEnumeration() != null
+                            && BgpNextHopType.Enumeration.SELF == nhAction.getEnumeration()) {
+                        nhNew = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder()
+                                .setGlobal(routeEntryInfo.getOriginatorId()).build()).build();
+                        attributesUpdatedBuilder.setCNextHop(nhNew);
                     }
                 }
                 attributesUpdated = attributesUpdatedBuilder.build();
index 888e7dcb368716fd037d0ae795d33210679119be..83ea2f000eb9b32337a403c058f8a94a5bf86a6a 100644 (file)
@@ -48,7 +48,7 @@ public class AppendActionTest extends AbstractStatementRegistryTest {
 
 
     @Test
-    public void testAppend() {
+    public void testMultipleAppend() {
         Statement statement = this.basicStatements.stream()
                 .filter(st -> st.getName().equals("multiple-append-test")).findFirst().get();
         final RouteAttributeContainer attributeContainer
@@ -69,4 +69,24 @@ public class AppendActionTest extends AbstractStatementRegistryTest {
                 .build();
         assertEquals(expected, result.getAttributes());
     }
+
+    @Test
+    public void testNextHopSelf() {
+        Statement statement = this.basicStatements.stream()
+                .filter(st -> st.getName().equals("next-hop-self-append-test")).findFirst().get();
+        final RouteAttributeContainer attributeContainer
+                = routeAttributeContainerFalse(new AttributesBuilder().build());
+        RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
+                this.baseAttributes,
+                IPV4UNICAST.class,
+                this.exportParameters,
+                attributeContainer,
+                statement);
+
+        final Attributes expected = new AttributesBuilder()
+                .setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder()
+                        .setGlobal(IPV4).build()).build())
+                .build();
+        assertEquals(expected, result.getAttributes());
+    }
 }
index 6587d55b5995ad4f91e65cae587057352474b3b0..818d3e355e607b8a56b139de4293a364949d4732 100644 (file)
                         </bgp-actions>
                     </actions>
                 </statement>
+                <statement>
+                    <name>next-hop-self-append-test</name>
+                    <conditions>
+                        <bgp-conditions xmlns="http://openconfig.net/yang/bgp-policy">
+                            <match-role-set xmlns="urn:opendaylight:params:xml:ns:yang:odl:bgp:default:policy">
+                                <from-role>
+                                    <role-set>/rpol:routing-policy/rpol:defined-sets/bgppol:bgp-defined-sets/role-sets/role-set[role-set-name="all"]</role-set>
+                                </from-role>
+                            </match-role-set>
+                        </bgp-conditions>
+                    </conditions>
+                    <actions>
+                        <bgp-actions xmlns="http://openconfig.net/yang/bgp-policy">
+                            <set-next-hop>SELF</set-next-hop>
+                        </bgp-actions>
+                    </actions>
+                </statement>
             </statements>
         </policy-definition>
     </policy-definitions>
diff --git a/bgp/openconfig-rp-statement/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/SetLocalAddressAsNextHopHandler.java b/bgp/openconfig-rp-statement/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/SetLocalAddressAsNextHopHandler.java
deleted file mode 100644 (file)
index a5768b5..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.statement;
-
-import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.RouteEntryBaseAttributes;
-import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.action.BgpActionAugPolicy;
-import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
-import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters;
-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;
-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.types.rev180329.next.hop.c.next.hop.Ipv4NextHopCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180329.SetLocalAddressAsNextHop;
-
-/**
- * Local Address shall be set as next Hop.
- * https://tools.ietf.org/html/rfc4684
- *
- * @author Claudio D. Gasparini
- */
-public final class SetLocalAddressAsNextHopHandler implements BgpActionAugPolicy<SetLocalAddressAsNextHop> {
-    private static final SetLocalAddressAsNextHopHandler INSTANCE = new SetLocalAddressAsNextHopHandler();
-
-    private SetLocalAddressAsNextHopHandler() {
-
-    }
-
-    public static SetLocalAddressAsNextHopHandler getInstance() {
-        return INSTANCE;
-    }
-
-    @Override
-    public Attributes applyImportAction(
-            final RouteEntryBaseAttributes routeEntryInfo,
-            final BGPRouteEntryImportParameters routeBaseParameters,
-            final Attributes attributes,
-            final SetLocalAddressAsNextHop actions) {
-        return setNextHop(attributes, routeEntryInfo.getOriginatorId());
-    }
-
-    private Attributes setNextHop(final Attributes attributes, final Ipv4Address localAddress) {
-        return new AttributesBuilder(attributes)
-                .setCNextHop(new Ipv4NextHopCaseBuilder()
-                        .setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(localAddress).build())
-                        .build()).build();
-    }
-
-    @Override
-    public Attributes applyExportAction(
-            final RouteEntryBaseAttributes routeEntryInfo,
-            final BGPRouteEntryExportParameters exportParameters,
-            final Attributes attributes,
-            final SetLocalAddressAsNextHop actions) {
-        return setNextHop(attributes, routeEntryInfo.getOriginatorId());
-    }
-}
index c1e3f29a6ab2af84b996687aed15093e94c8aaa4..00f9946095d442fe615a19c2b2ec0a5217e568a6 100644 (file)
@@ -22,7 +22,6 @@ import org.opendaylight.protocol.bgp.openconfig.routing.policy.statement.actions
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.statement.actions.SetCommunityHandler;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.statement.actions.SetExtCommunityHandler;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.statement.actions.SetOriginatorIdPrependHandler;
-import org.opendaylight.protocol.bgp.openconfig.routing.policy.statement.actions.SetOriginatorIdToAdvertizerRouterIdHandler;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.statement.conditions.MatchAfiSafiNotInHandler;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.statement.conditions.MatchAsPathSetHandler;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.statement.conditions.MatchBgpNeighborSetHandler;
@@ -46,9 +45,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180329.MatchRoleSetCondition;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180329.NonTransitiveAttributesFilter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180329.SetClusterIdPrepend;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180329.SetLocalAddressAsNextHop;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180329.SetOriginatorIdPrepend;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180329.SetOriginatorIdToAdvertizerRouterId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180329.VpnNonMemberCondition;
 
 public final class StatementActivator extends AbstractBGPStatementProviderActivator {
@@ -115,11 +112,5 @@ public final class StatementActivator extends AbstractBGPStatementProviderActiva
 
         registration.add(provider.registerBgpActionAugmentationPolicy(SetClusterIdPrepend.class,
                 new SetClusterIdPrependHandler()));
-
-        registration.add(provider.registerBgpActionAugmentationPolicy(SetOriginatorIdToAdvertizerRouterId.class,
-                SetOriginatorIdToAdvertizerRouterIdHandler.getInstance()));
-
-        registration.add(provider.registerBgpActionAugmentationPolicy(SetLocalAddressAsNextHop.class,
-                SetLocalAddressAsNextHopHandler.getInstance()));
     }
 }
diff --git a/bgp/openconfig-rp-statement/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/actions/SetOriginatorIdToAdvertizerRouterIdHandler.java b/bgp/openconfig-rp-statement/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/actions/SetOriginatorIdToAdvertizerRouterIdHandler.java
deleted file mode 100644 (file)
index e757a2b..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.statement.actions;
-
-import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.RouteEntryBaseAttributes;
-import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.action.BgpActionAugPolicy;
-import org.opendaylight.protocol.bgp.rib.spi.RouterIds;
-import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
-import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters;
-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.AttributesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.OriginatorIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180329.SetOriginatorIdToAdvertizerRouterId;
-
-/**
- * Originator attribute shall be set to the router-id of the advertiser.
- * https://tools.ietf.org/html/rfc4684
- *
- * @author Claudio D. Gasparini
- */
-public final class SetOriginatorIdToAdvertizerRouterIdHandler
-        implements BgpActionAugPolicy<SetOriginatorIdToAdvertizerRouterId> {
-    private static SetOriginatorIdToAdvertizerRouterIdHandler INSTANCE
-            = new SetOriginatorIdToAdvertizerRouterIdHandler();
-
-    private SetOriginatorIdToAdvertizerRouterIdHandler() {
-
-    }
-
-    public static SetOriginatorIdToAdvertizerRouterIdHandler getInstance() {
-        return INSTANCE;
-    }
-
-    @Override
-    public Attributes applyImportAction(
-            final RouteEntryBaseAttributes routeEntryInfo,
-            final BGPRouteEntryImportParameters routeBaseParameters,
-            final Attributes attributes,
-            final SetOriginatorIdToAdvertizerRouterId actions) {
-        return setOriginatorId(attributes, routeBaseParameters.getFromPeerId());
-    }
-
-    private Attributes setOriginatorId(final Attributes attributes, final PeerId peerId) {
-        if (attributes.getOriginatorId() != null) {
-            return attributes;
-        }
-        return new AttributesBuilder(attributes)
-                .setOriginatorId(new OriginatorIdBuilder()
-                        .setOriginator(RouterIds.inetFromPeerId(peerId)).build()).build();
-    }
-
-    @Override
-    public Attributes applyExportAction(
-            final RouteEntryBaseAttributes routeEntryInfo,
-            final BGPRouteEntryExportParameters routeBaseParameters,
-            final Attributes attributes,
-            final SetOriginatorIdToAdvertizerRouterId actions) {
-        return setOriginatorId(attributes, routeBaseParameters.getFromPeerId());
-    }
-}
diff --git a/bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/SetLocalAddressAsNextHopHandlerTest.java b/bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/SetLocalAddressAsNextHopHandlerTest.java
deleted file mode 100644 (file)
index fe71d7d..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.statement;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.doReturn;
-import static org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer.routeAttributeContainerFalse;
-
-import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-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.Ipv4Address;
-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.AttributesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerRole;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv4NextHopCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder;
-
-public class SetLocalAddressAsNextHopHandlerTest extends AbstractStatementRegistryConsumerTest {
-    private final Attributes multipleCom = new AttributesBuilder()
-            .setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder()
-                    .setGlobal(new Ipv4Address("1.2.3.4")).build()).build())
-            .build();
-    @Mock
-    private BGPRouteEntryExportParameters exportParameters;
-    private List<Statement> basicStatements;
-    private PolicyRIBBaseParametersImpl baseAttributes;
-
-    @Before
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        this.basicStatements = loadStatement("set-local-address-as-next-hop");
-        this.baseAttributes = new PolicyRIBBaseParametersImpl(LOCAL_AS, IPV4, CLUSTER);
-        doReturn(PeerRole.Ibgp).when(this.exportParameters).getFromPeerRole();
-    }
-
-    @Test
-    public void testInlineAdd() {
-        Statement statement = this.basicStatements.stream()
-                .filter(st -> st.getName().equals("set-local-address-as-next-hop")).findFirst().get();
-        RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
-                new AttributesBuilder().build());
-        RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
-                this.baseAttributes,
-                IPV4UNICAST.class,
-                this.exportParameters,
-                attributeContainer,
-                statement);
-
-        assertEquals(this.multipleCom, result.getAttributes());
-    }
-}
\ No newline at end of file
diff --git a/bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/SetOriginatorIdToAdvertizerRouterIdHandlerTest.java b/bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/SetOriginatorIdToAdvertizerRouterIdHandlerTest.java
deleted file mode 100644 (file)
index 919e3d0..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.statement;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.doReturn;
-import static org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer.routeAttributeContainerFalse;
-
-import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-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.RouterIds;
-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;
-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.message.rev180329.path.attributes.attributes.OriginatorIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerRole;
-
-public class SetOriginatorIdToAdvertizerRouterIdHandlerTest extends AbstractStatementRegistryConsumerTest {
-    private Ipv4Address ipv4 = Ipv4Address.getDefaultInstance("42.42.42.42");
-    private final Attributes multipleCom = new AttributesBuilder()
-            .setOriginatorId(new OriginatorIdBuilder().setOriginator(ipv4).build())
-            .build();
-    @Mock
-    private BGPRouteEntryExportParameters exportParameters;
-    private List<Statement> basicStatements;
-    private PolicyRIBBaseParametersImpl baseAttributes;
-
-    @Before
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        this.basicStatements = loadStatement("set-originator-id-to-advertizer-router-id");
-        this.baseAttributes = new PolicyRIBBaseParametersImpl(LOCAL_AS, IPV4, CLUSTER);
-        doReturn(PeerRole.Ibgp).when(this.exportParameters).getFromPeerRole();
-        doReturn(RouterIds.createPeerId(ipv4)).when(this.exportParameters).getFromPeerId();
-    }
-
-    @Test
-    public void testInlineAdd() {
-        Statement statement = this.basicStatements.stream()
-                .filter(st -> st.getName().equals("set-originator-id-to-advertizer-router-id")).findFirst().get();
-        RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
-                new AttributesBuilder().build());
-        RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
-                this.baseAttributes,
-                IPV4UNICAST.class,
-                this.exportParameters,
-                attributeContainer,
-                statement);
-
-        assertEquals(this.multipleCom, result.getAttributes());
-    }
-}
\ No newline at end of file
index cca95b1394fcf28872849f2097f5191fc76b969b..10dbae00e5560424ffa73e0fe65f27f5b14e7b03 100644 (file)
                 </statement>
             </statements>
         </policy-definition>
-        <policy-definition>
-            <name>set-originator-id-to-advertizer-router-id</name>
-            <statements>
-                <statement>
-                    <name>set-originator-id-to-advertizer-router-id</name>
-                    <conditions>
-                        <bgp-conditions xmlns="http://openconfig.net/yang/bgp-policy">
-                            <match-role-set xmlns="urn:opendaylight:params:xml:ns:yang:odl:bgp:default:policy">
-                                <from-role>
-                                    <role-set>
-                                        /rpol:routing-policy/rpol:defined-sets/bgppol:bgp-defined-sets/role-sets/role-set[role-set-name="all"]
-                                    </role-set>
-                                </from-role>
-                            </match-role-set>
-                        </bgp-conditions>
-                    </conditions>
-                    <actions>
-                        <bgp-actions xmlns="http://openconfig.net/yang/bgp-policy">
-                            <set-originator-id-to-advertizer-router-id xmlns="urn:opendaylight:params:xml:ns:yang:odl:bgp:default:policy"/>
-                        </bgp-actions>
-                    </actions>
-                </statement>
-            </statements>
-        </policy-definition>
-        <policy-definition>
-            <name>set-local-address-as-next-hop</name>
-            <statements>
-                <statement>
-                    <name>set-local-address-as-next-hop</name>
-                    <conditions>
-                        <bgp-conditions xmlns="http://openconfig.net/yang/bgp-policy">
-                            <match-role-set xmlns="urn:opendaylight:params:xml:ns:yang:odl:bgp:default:policy">
-                                <from-role>
-                                    <role-set>
-                                        /rpol:routing-policy/rpol:defined-sets/bgppol:bgp-defined-sets/role-sets/role-set[role-set-name="all"]
-                                    </role-set>
-                                </from-role>
-                            </match-role-set>
-                        </bgp-conditions>
-                    </conditions>
-                    <actions>
-                        <bgp-actions xmlns="http://openconfig.net/yang/bgp-policy">
-                            <set-local-address-as-next-hop xmlns="urn:opendaylight:params:xml:ns:yang:odl:bgp:default:policy"/>
-                        </bgp-actions>
-                    </actions>
-                </statement>
-            </statements>
-        </policy-definition>
         <policy-definition>
             <name>vpn-non-member-test</name>
             <statements>
index 2c967744ab7a021b304ee35f9af0adaac46e24e9..15d14adbadd2bf7bed7a27e2bc643b28b3e2221f 100755 (executable)
@@ -275,7 +275,10 @@ public final class RIBImpl extends BGPRIBStateImpl implements RIB, TransactionCh
 
     @Override
     public void refreshTable(final TablesKey tk, final PeerId peerId) {
-        this.vpnTableRefresher.get(tk).refreshTable(tk, peerId);
+        final RibOutRefresh table = this.vpnTableRefresher.get(tk);
+        if (table != null) {
+            table.refreshTable(tk, peerId);
+        }
     }
 
     @Override