Search in sources :

Example 51 with Bgp

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp in project bgpcep by opendaylight.

the class BgpTopologyDeployerImpl method onDataTreeChanged.

@Override
public synchronized void onDataTreeChanged(final Collection<DataTreeModification<Topology>> changes) {
    if (this.closed) {
        LOG.trace("BGP Topology Provider Deployer was already closed, skipping changes.");
        return;
    }
    for (final DataTreeModification<Topology> change : changes) {
        final DataObjectModification<Topology> rootNode = change.getRootNode();
        final Topology dataBefore = rootNode.getDataBefore();
        final Topology dataAfter = rootNode.getDataAfter();
        LOG.trace("BGP topology deployer configuration changed: modification type: [{}]," + " data before:[{}], data after: [{}]", rootNode.getModificationType(), dataBefore, dataAfter);
        switch(rootNode.getModificationType()) {
            case DELETE:
                filterTopologyBuilders(dataBefore).forEach(provider -> provider.onTopologyBuilderRemoved(dataBefore));
                break;
            case SUBTREE_MODIFIED:
                filterTopologyBuilders(dataBefore).forEach(provider -> provider.onTopologyBuilderRemoved(dataBefore));
                filterTopologyBuilders(dataAfter).forEach(provider -> provider.onTopologyBuilderCreated(dataAfter));
                break;
            case WRITE:
                filterTopologyBuilders(dataAfter).forEach(provider -> provider.onTopologyBuilderCreated(dataAfter));
                break;
            default:
                break;
        }
    }
}
Also used : NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)

Example 52 with Bgp

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp in project bgpcep by opendaylight.

the class AddPathBasePathsTest method testUseCase1.

/*
    * Base-Paths
    *                                            ___________________
    *                                           | ODL BGP 127.0.0.1 |
    * [peer://127.0.0.2; p1, lp100] --(iBGP)--> |                   | --(RR-client, non add-path) --> [Peer://127.0.0.5; (p1, lp100), (p1, lp1200)]
    * [peer://127.0.0.3; p1, lp200] --(iBGP)--> |                   |
    * [peer://127.0.0.4; p1, lp50] --(iBGP)-->  |                   | --(eBgp, non add-path) --> [Peer://127.0.0.6; (p1, path-id1, lp100), (p1, path-id2, pl50), (p1, path-id3, pl200)]
    * [peer://127.0.0.2; p1, lp20] --(iBGP)-->  |___________________|
    * p1 = 1.1.1.1/32
    */
@Test
public void testUseCase1() throws Exception {
    final BgpParameters nonAddPathParams = createParameter(false);
    configurePeer(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);
    final BGPSessionImpl session2 = createPeerSession(PEER2, nonAddPathParams, new SimpleSessionListener());
    configurePeer(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);
    final BGPSessionImpl session4 = createPeerSession(PEER4, nonAddPathParams, listener4);
    final SimpleSessionListener listener5 = new SimpleSessionListener();
    configurePeer(PEER5, this.ribImpl, nonAddPathParams, PeerRole.Ebgp, this.serverRegistry);
    final BGPSessionImpl session5 = createPeerSession(PEER5, nonAddPathParams, listener5);
    checkPeersPresentOnDataStore(5);
    // new best route so far
    sendRouteAndCheckIsOnLocRib(session1, PREFIX1, 100, 1);
    checkReceivedMessages(listener4, 1);
    checkReceivedMessages(listener5, 1);
    assertEquals(UPD_NA_100, listener4.getListMsg().get(0));
    assertEquals(UPD_NA_100_EBGP, listener5.getListMsg().get(0));
    // the second best route
    sendRouteAndCheckIsOnLocRib(session2, PREFIX1, 50, 1);
    checkReceivedMessages(listener4, 1);
    checkReceivedMessages(listener5, 1);
    // new best route
    sendRouteAndCheckIsOnLocRib(session3, PREFIX1, 200, 1);
    checkReceivedMessages(listener4, 2);
    checkReceivedMessages(listener5, 2);
    assertEquals(UPD_NA_200, listener4.getListMsg().get(1));
    assertEquals(UPD_NA_200_EBGP, listener5.getListMsg().get(1));
    final SimpleSessionListener listener6 = new SimpleSessionListener();
    configurePeer(PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
    final BGPSessionImpl session6 = createPeerSession(PEER6, nonAddPathParams, listener6);
    checkPeersPresentOnDataStore(6);
    checkReceivedMessages(listener6, 1);
    assertEquals(UPD_NA_200, listener6.getListMsg().get(0));
    session6.close();
    checkPeersPresentOnDataStore(5);
    // best route updated to be the worse one
    sendRouteAndCheckIsOnLocRib(session3, PREFIX1, 20, 1);
    checkReceivedMessages(listener4, 3);
    checkReceivedMessages(listener5, 3);
    assertEquals(UPD_NA_100, listener4.getListMsg().get(2));
    assertEquals(UPD_NA_100_EBGP, listener5.getListMsg().get(2));
    // Remove second best, no advertisement should be done
    sendWithdrawalRouteAndCheckIsOnLocRib(session2, PREFIX1, 50, 1);
    checkReceivedMessages(listener4, 3);
    checkReceivedMessages(listener5, 3);
    // Remove best, 1 advertisement
    sendWithdrawalRouteAndCheckIsOnLocRib(session1, PREFIX1, 100, 1);
    checkReceivedMessages(listener4, 4);
    checkReceivedMessages(listener5, 4);
    // Remove best, 1 withdrawal
    sendWithdrawalRouteAndCheckIsOnLocRib(session3, PREFIX1, 20, 0);
    checkReceivedMessages(listener4, 5);
    checkReceivedMessages(listener5, 5);
    session1.close();
    session2.close();
    session3.close();
    session4.close();
    session5.close();
}
Also used : BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters) Test(org.junit.Test)

Example 53 with Bgp

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp in project bgpcep by opendaylight.

the class BGPOperationalStateUtilsTest method createDefaultProtocol.

private void createDefaultProtocol() throws ExecutionException, InterruptedException {
    final WriteTransaction wt = getDataBroker().newWriteOnlyTransaction();
    final Bgp bgp = new BgpBuilder().setGlobal(GlobalStateCliUtilsTest.buildGlobal(true).build()).setNeighbors(new NeighborsBuilder().setNeighbor(Collections.singletonList(NeighborStateCliUtilsTest.createBasicNeighbor())).build()).build();
    GlobalStateCliUtilsTest.buildGlobal(true);
    final InstanceIdentifier<Bgp> bgpIID = PROTOCOLS_IID.child(Protocol.class, new ProtocolKey(BGP.class, RIB_ID)).augmentation(NetworkInstanceProtocol.class).child(Bgp.class);
    wt.put(LogicalDatastoreType.OPERATIONAL, bgpIID, bgp, true);
    wt.submit().get();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) NeighborsBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.NeighborsBuilder) ProtocolKey(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.network.instance.protocols.ProtocolKey) BgpBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.BgpBuilder) Bgp(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.Bgp) BGP(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.BGP) NetworkInstanceProtocol(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NetworkInstanceProtocol)

Example 54 with Bgp

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp in project bgpcep by opendaylight.

the class BGPPeer method addBgp4Support.

// try to add a support for old-school BGP-4, if peer did not advertise IPv4-Unicast MP capability
private synchronized void addBgp4Support() {
    final TablesKey key = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
    if (!this.tables.contains(key)) {
        final HashSet<TablesKey> newSet = new HashSet<>(this.tables);
        newSet.add(key);
        this.tables = ImmutableSet.copyOf(newSet);
        createAdjRibOutListener(key, false);
    }
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) HashSet(java.util.HashSet)

Example 55 with Bgp

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp in project bgpcep by opendaylight.

the class BGPSessionImpl method terminate.

/**
 * Closes BGP session from the parent with given reason. A message needs to be sent, but parent doesn't have to be
 * modified, because he initiated the closing. (To prevent concurrent modification exception).
 *
 * @param e BGPDocumentedException
 */
@VisibleForTesting
synchronized void terminate(final BGPDocumentedException e) {
    final BGPError error = e.getError();
    final byte[] data = e.getData();
    final NotifyBuilder builder = new NotifyBuilder().setErrorCode(error.getCode()).setErrorSubcode(error.getSubcode());
    if (data != null && data.length != 0) {
        builder.setData(data);
    }
    this.writeAndFlush(builder.build());
    notifyTerminationReasonAndCloseWithoutMessage(error.getCode(), error.getSubcode());
}
Also used : BGPError(org.opendaylight.protocol.bgp.parser.BGPError) NotifyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.NotifyBuilder) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

BigInteger (java.math.BigInteger)18 Test (org.junit.Test)17 ByteBuf (io.netty.buffer.ByteBuf)16 ArrayList (java.util.ArrayList)16 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)16 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)11 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)10 ExecutionException (java.util.concurrent.ExecutionException)9 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)9 BGPDocumentedException (org.opendaylight.protocol.bgp.parser.BGPDocumentedException)9 Bgp (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp)7 BgpParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters)7 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)7 List (java.util.List)6 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)6 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)6 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)5 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)5 Neighbors (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Neighbors)5 Collections (java.util.Collections)4