Search in sources :

Example 51 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables in project bgpcep by opendaylight.

the class AbstractPeer method installRouteRibOut.

private <C extends Routes & DataObject & ChoiceIn<Tables>, S extends ChildOf<? super C>> void installRouteRibOut(final RouteEntryDependenciesContainer entryDep, final List<AdvertizedRoute<C, S>> routes, final DOMDataTreeWriteOperations tx) {
    final RIBSupport<C, S> ribSupport = entryDep.getRIBSupport();
    final TablesKey tk = ribSupport.getTablesKey();
    final BGPPeerTracker peerTracker = entryDep.getPeerTracker();
    final boolean addPathSupported = supportsAddPathSupported(tk);
    final YangInstanceIdentifier tableRibout = getRibOutIId(ribSupport.tablesKey());
    for (final AdvertizedRoute<C, S> advRoute : routes) {
        final PeerId fromPeerId = advRoute.getFromPeerId();
        if (!filterRoutes(fromPeerId, tk) || !advRoute.isFirstBestPath() && !addPathSupported) {
            continue;
        }
        if (!supportsLLGR() && advRoute.isDepreferenced()) {
            // https://tools.ietf.org/html/draft-uttaro-idr-bgp-persistence-04#section-4.3
            // o  The route SHOULD NOT be advertised to any neighbor from which the
            // Long-lived Graceful Restart Capability has not been received.  The
            // exception is described in the Optional Partial Deployment
            // Procedure section (Section 4.7).  Note that this requirement
            // implies that such routes should be withdrawn from any such
            // neighbor.
            deleteRoute(ribSupport, addPathSupported, tableRibout, advRoute, tx);
            continue;
        }
        final Peer fromPeer = peerTracker.getPeer(fromPeerId);
        final ContainerNode attributes = advRoute.getAttributes();
        if (fromPeer != null && attributes != null) {
            final YangInstanceIdentifier routePath = createRoutePath(ribSupport, tableRibout, advRoute, addPathSupported);
            final MapEntryNode route = advRoute.getRoute();
            applyExportPolicy(entryDep, fromPeerId, route, routePath, attributes).ifPresent(attrs -> storeRoute(ribSupport, advRoute, route, routePath, attrs, tx));
        }
    }
}
Also used : BGPPeerTracker(org.opendaylight.protocol.bgp.rib.spi.BGPPeerTracker) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) Peer(org.opendaylight.protocol.bgp.rib.spi.Peer) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) PeerId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId)

Example 52 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables in project bgpcep by opendaylight.

the class ParserToSalTest method assertTablesExists.

private void assertTablesExists(final List<BgpTableType> expectedTables) throws InterruptedException, ExecutionException {
    readDataOperational(getDataBroker(), BGP_IID, bgpRib -> {
        final var tables = bgpRib.nonnullRib().values().iterator().next().getLocRib().getTables();
        assertNotNull(tables);
        for (final BgpTableType tableType : expectedTables) {
            boolean found = false;
            for (final Tables table : tables.values()) {
                if (table.getAfi().equals(tableType.getAfi()) && table.getSafi().equals(tableType.getSafi())) {
                    found = true;
                    assertEquals(Boolean.TRUE, table.getAttributes().getUptodate());
                }
            }
            assertTrue(found);
        }
        return bgpRib;
    });
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables)

Example 53 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables in project bgpcep by opendaylight.

the class ParserToSalTest method testWithLinkstate.

@Test
public void testWithLinkstate() throws InterruptedException, ExecutionException {
    final List<BgpTableType> tables = ImmutableList.of(new BgpTableTypeImpl(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class));
    final RIBImpl rib = new RIBImpl(this.tableRegistry, new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext2, this.dispatcher, this.codecsRegistry, getDomBroker(), this.policies, tables, Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory.createBestPathSelectionStrategy()));
    rib.instantiateServiceInstance();
    assertTablesExists(tables);
    final BGPPeer peer = AbstractAddPathTest.configurePeer(this.tableRegistry, this.localAddress.getIpv4AddressNoZone(), rib, null, PeerRole.Ibgp, new StrictBGPPeerRegistry());
    peer.instantiateServiceInstance();
    final ListenerRegistration<?> reg = this.mock.registerUpdateListener(peer);
    reg.close();
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType) RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId) LinkstateSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.LinkstateSubsequentAddressFamily) LinkstateAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.LinkstateAddressFamily) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl) Test(org.junit.Test)

Example 54 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables in project bgpcep by opendaylight.

the class ParserToSalTest method testWithoutLinkstate.

@Test
public void testWithoutLinkstate() throws InterruptedException, ExecutionException {
    final List<BgpTableType> tables = ImmutableList.of(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
    final RIBImpl rib = new RIBImpl(this.tableRegistry, new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext1, this.dispatcher, this.codecsRegistry, getDomBroker(), this.policies, tables, Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory.createBestPathSelectionStrategy()));
    rib.instantiateServiceInstance();
    assertTablesExists(tables);
    final BGPPeer peer = AbstractAddPathTest.configurePeer(this.tableRegistry, this.localAddress.getIpv4AddressNoZone(), rib, null, PeerRole.Ibgp, new StrictBGPPeerRegistry());
    peer.instantiateServiceInstance();
    final ListenerRegistration<?> reg = this.mock.registerUpdateListener(peer);
    reg.close();
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType) RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl) UnicastSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily) Test(org.junit.Test)

Example 55 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables in project bgpcep by opendaylight.

the class PeerTest method testClassicPeer.

@Test
public void testClassicPeer() throws Exception {
    this.classic = AbstractAddPathTest.configurePeer(this.tableRegistry, this.neighborAddress.getIpv4AddressNoZone(), getRib(), null, PeerRole.Ibgp, new StrictBGPPeerRegistry());
    this.classic.instantiateServiceInstance();
    this.mockSession();
    assertEquals(this.neighborAddress.getIpv4AddressNoZone().getValue(), this.classic.getName());
    this.classic.onSessionUp(this.session);
    assertEquals("BGPPeer{name=127.0.0.1, tables=[TablesKey{_afi=interface org.opendaylight.yang.gen.v1" + ".urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily," + " _safi=interface org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types" + ".rev200120.UnicastSubsequentAddressFamily}]}", this.classic.toString());
    final Nlri n1 = new NlriBuilder().setPrefix(new Ipv4Prefix("8.0.1.0/28")).build();
    final Nlri n2 = new NlriBuilder().setPrefix(new Ipv4Prefix("127.0.0.1/32")).build();
    final Nlri n3 = new NlriBuilder().setPrefix(new Ipv4Prefix("2.2.2.2/24")).build();
    final List<Nlri> nlris = Lists.newArrayList(n1, n2, n3);
    final UpdateBuilder ub = new UpdateBuilder();
    ub.setNlri(nlris);
    final Origin origin = new OriginBuilder().setValue(BgpOrigin.Igp).build();
    final AsPath asPath = new AsPathBuilder().setSegments(Collections.emptyList()).build();
    final CNextHop nextHop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4AddressNoZone("127.0.0.1")).build()).build();
    final AttributesBuilder ab = new AttributesBuilder();
    ub.setAttributes(ab.setOrigin(origin).setAsPath(asPath).setCNextHop(nextHop).build());
    try {
        this.classic.onMessage(this.session, ub.build());
        fail();
    } catch (final BGPDocumentedException e) {
        assertEquals(BGPError.MANDATORY_ATTR_MISSING_MSG + "LOCAL_PREF", e.getMessage());
        assertEquals(BGPError.WELL_KNOWN_ATTR_MISSING.getCode(), e.getError().getCode());
        assertEquals(BGPError.WELL_KNOWN_ATTR_MISSING.getSubcode(), e.getError().getSubcode());
        assertArrayEquals(new byte[] { LocalPreferenceAttributeParser.TYPE }, e.getData());
    }
    assertEquals(0, this.routes.size());
    final LocalPref localPref = new LocalPrefBuilder().setPref(Uint32.valueOf(100)).build();
    ub.setAttributes(ab.setLocalPref(localPref).build());
    this.classic.onMessage(this.session, ub.build());
    assertEquals(3, this.routes.size());
    // create new peer so that it gets advertized routes from RIB
    final BGPPeer testingPeer = AbstractAddPathTest.configurePeer(this.tableRegistry, this.neighborAddress.getIpv4AddressNoZone(), getRib(), null, PeerRole.Ibgp, new StrictBGPPeerRegistry());
    testingPeer.instantiateServiceInstance();
    testingPeer.onSessionUp(this.session);
    assertEquals(3, this.routes.size());
    final Nlri n11 = new NlriBuilder().setPrefix(new Ipv4Prefix("8.0.1.0/28")).build();
    final Nlri n22 = new NlriBuilder().setPrefix(new Ipv4Prefix("8.0.1.16/28")).build();
    final List<Nlri> nlris2 = Lists.newArrayList(n11, n22);
    ub.setNlri(nlris2);
    final WithdrawnRoutes w1 = new WithdrawnRoutesBuilder().setPrefix(new Ipv4Prefix("8.0.1.0/28")).build();
    final WithdrawnRoutes w2 = new WithdrawnRoutesBuilder().setPrefix(new Ipv4Prefix("127.0.0.1/32")).build();
    final WithdrawnRoutes w3 = new WithdrawnRoutesBuilder().setPrefix(new Ipv4Prefix("2.2.2.2/24")).build();
    final List<WithdrawnRoutes> wrs = Lists.newArrayList(w1, w2, w3);
    ub.setWithdrawnRoutes(wrs);
    this.classic.onMessage(this.session, ub.build());
    assertEquals(2, this.routes.size());
    this.classic.onMessage(this.session, new KeepaliveBuilder().build());
    this.classic.onMessage(this.session, new UpdateBuilder().setAttributes(new AttributesBuilder().addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(new MpUnreachNlriBuilder().setAfi(IPV4_AFI).setSafi(SAFI).build()).build()).build()).build());
    this.classic.onMessage(this.session, new RouteRefreshBuilder().setAfi(IPV4_AFI).setSafi(SAFI).build());
    this.classic.onMessage(this.session, new RouteRefreshBuilder().setAfi(Ipv6AddressFamily.class).setSafi(SAFI).build());
    assertEquals(2, this.routes.size());
    this.classic.releaseConnection();
}
Also used : Origin(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.Origin) BgpOrigin(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.BgpOrigin) LocalPrefBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPrefBuilder) Ipv6AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily) Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) OriginBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.OriginBuilder) UpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder) WithdrawnRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.WithdrawnRoutes) WithdrawnRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.WithdrawnRoutesBuilder) AsPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPathBuilder) Ipv4NextHopCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv4NextHopCaseBuilder) LocalPref(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPref) KeepaliveBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.KeepaliveBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) AttributesUnreachBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreachBuilder) RouteRefreshBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.RouteRefreshBuilder) MpUnreachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlriBuilder) CNextHop(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.CNextHop) Nlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.Nlri) AsPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPath) Ipv4NextHopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder) BGPDocumentedException(org.opendaylight.protocol.bgp.parser.BGPDocumentedException) NlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.NlriBuilder) MpUnreachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlriBuilder) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)10 ArrayList (java.util.ArrayList)9 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)9 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)9 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)7 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)6 ByteBuf (io.netty.buffer.ByteBuf)6 Map (java.util.Map)6 ExecutionException (java.util.concurrent.ExecutionException)6 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)6 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)6 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)6 HashMap (java.util.HashMap)5 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)5 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)5 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)5 BigInteger (java.math.BigInteger)4 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)4 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)4