Search in sources :

Example 1 with BgpSessionInfo

use of org.onosproject.bgp.controller.BgpSessionInfo in project onos by opennetworkinglab.

the class BgpLocalRibImpl method selectionProcessPrefix.

/**
 * Selection process for local RIB prefix.
 *
 * @param nlri NLRI to update
 * @param isVpnRib true if VPN local RIB, otherwise false
 * @throws BgpParseException BGP parse exception
 */
public void selectionProcessPrefix(BgpLSNlri nlri, boolean isVpnRib) throws BgpParseException {
    BgpPeerImpl peer;
    BgpSessionInfo sessionInfo;
    int decisionResult;
    boolean containsKey;
    BgpPrefixLSIdentifier prefixIdentifier = ((BgpPrefixIPv4LSNlriVer4) nlri).getPrefixIdentifier();
    /* Here, we are checking if the given prefix is contained in the AdjacencyRib of any peer
           or not. If none of the peer's AdjacencyRib has it, prefix can be marked for deletion.
         */
    boolean shouldDeletePrefix = false;
    if (prefixTree.containsKey(prefixIdentifier)) {
        shouldDeletePrefix = true;
    }
    for (BgpId bgpId : bgpController.connectedPeers().keySet()) {
        peer = (BgpPeerImpl) (bgpController.getPeer(bgpId));
        if (prefixTree.containsKey(prefixIdentifier)) {
            containsKey = (!isVpnRib) ? (peer.adjacencyRib().prefixTree().containsKey(prefixIdentifier)) : (peer.vpnAdjacencyRib().prefixTree().containsKey(prefixIdentifier));
            if (!containsKey) {
                continue;
            }
            sessionInfo = peer.sessionInfo();
            PathAttrNlriDetailsLocalRib detailsLocRib = new PathAttrNlriDetailsLocalRib(sessionInfo.remoteBgpId().ipAddress(), sessionInfo.remoteBgpIdentifier(), sessionInfo.remoteBgpASNum(), sessionInfo.isIbgpSession(), ((!isVpnRib) ? (peer.adjacencyRib().prefixTree().get(prefixIdentifier)) : (peer.vpnAdjacencyRib().prefixTree().get(prefixIdentifier))));
            BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo();
            decisionResult = selectionAlgo.compare(prefixTree.get(prefixIdentifier), detailsLocRib);
            if (decisionResult < 0) {
                prefixTree.replace(prefixIdentifier, detailsLocRib);
                log.debug("Local RIB prefix updated: {}", detailsLocRib.toString());
            }
            shouldDeletePrefix = false;
        }
        if (shouldDeletePrefix) {
            log.debug("Local RIB remove prefix: {}", prefixIdentifier.toString());
            for (BgpPrefixListener l : bgpController.prefixListener()) {
                l.deletePrefix((BgpPrefixIPv4LSNlriVer4) nlri);
            }
            prefixTree.remove(prefixIdentifier);
        }
    }
}
Also used : BgpPrefixListener(org.onosproject.bgp.controller.BgpPrefixListener) BgpPrefixLSIdentifier(org.onosproject.bgpio.protocol.linkstate.BgpPrefixLSIdentifier) PathAttrNlriDetailsLocalRib(org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib) BgpSessionInfo(org.onosproject.bgp.controller.BgpSessionInfo) BgpId(org.onosproject.bgp.controller.BgpId) BgpPrefixIPv4LSNlriVer4(org.onosproject.bgpio.protocol.linkstate.BgpPrefixIPv4LSNlriVer4)

Example 2 with BgpSessionInfo

use of org.onosproject.bgp.controller.BgpSessionInfo in project onos by opennetworkinglab.

the class BgpLocalRibImpl method selectionProcessNode.

/**
 * Selection process for local RIB node.
 *
 * @param nlri NLRI to update
 * @param isVpnRib true if VPN  local RIB, otherwise false
 * @throws BgpParseException throws BGP parse exception
 */
public void selectionProcessNode(BgpLSNlri nlri, boolean isVpnRib) throws BgpParseException {
    BgpPeerImpl peer;
    BgpSessionInfo sessionInfo;
    int decisionResult;
    boolean containsKey;
    BgpNodeLSIdentifier nodeLsIdentifier = ((BgpNodeLSNlriVer4) nlri).getLocalNodeDescriptors();
    /* Here, we are checking if the given node is contained in the AdjacencyRib of any peer
           or not. If none of the peer's AdjacencyRib has it, node can be marked for deletion.
         */
    boolean shouldDeleteNode = false;
    if (nodeTree.containsKey(nodeLsIdentifier)) {
        shouldDeleteNode = true;
    }
    for (BgpId bgpId : bgpController.connectedPeers().keySet()) {
        peer = (BgpPeerImpl) (bgpController.getPeer(bgpId));
        if (nodeTree.containsKey(nodeLsIdentifier)) {
            containsKey = (!isVpnRib) ? (peer.adjacencyRib().nodeTree().containsKey(nodeLsIdentifier)) : (peer.vpnAdjacencyRib().nodeTree().containsKey(nodeLsIdentifier));
            if (!containsKey) {
                continue;
            }
            sessionInfo = peer.sessionInfo();
            PathAttrNlriDetailsLocalRib detailsLocRib = new PathAttrNlriDetailsLocalRib(sessionInfo.remoteBgpId().ipAddress(), sessionInfo.remoteBgpIdentifier(), sessionInfo.remoteBgpASNum(), sessionInfo.isIbgpSession(), (!isVpnRib) ? (peer.adjacencyRib().nodeTree().get(nodeLsIdentifier)) : (peer.vpnAdjacencyRib().nodeTree().get(nodeLsIdentifier)));
            BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo();
            decisionResult = selectionAlgo.compare(nodeTree.get(nodeLsIdentifier), detailsLocRib);
            if (decisionResult < 0) {
                nodeTree.replace(nodeLsIdentifier, detailsLocRib);
                log.debug("Local RIB node updated: {}", detailsLocRib.toString());
            }
            shouldDeleteNode = false;
        }
    }
    if (shouldDeleteNode) {
        log.debug("Local RIB delete node: {}", nodeLsIdentifier.toString());
        for (BgpNodeListener l : bgpController.listener()) {
            l.deleteNode((BgpNodeLSNlriVer4) nlri);
        }
        nodeTree.remove(nodeLsIdentifier);
        bgpController.notifyTopologyChange();
    }
}
Also used : BgpNodeListener(org.onosproject.bgp.controller.BgpNodeListener) PathAttrNlriDetailsLocalRib(org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib) BgpSessionInfo(org.onosproject.bgp.controller.BgpSessionInfo) BgpId(org.onosproject.bgp.controller.BgpId) BgpNodeLSNlriVer4(org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4) BgpNodeLSIdentifier(org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier)

Example 3 with BgpSessionInfo

use of org.onosproject.bgp.controller.BgpSessionInfo in project onos by opennetworkinglab.

the class BgpLocalRibImpl method selectionProcessLink.

/**
 * Selection process for local RIB link.
 *
 * @param nlri NLRI to update
 * @param isVpnRib true if VPN local RIB, otherwise false
 * @throws BgpParseException BGP parse exception
 */
public void selectionProcessLink(BgpLSNlri nlri, boolean isVpnRib) throws BgpParseException {
    BgpPeerImpl peer;
    BgpSessionInfo sessionInfo;
    int decisionResult;
    boolean containsKey;
    BgpLinkLSIdentifier linkLsIdentifier = ((BgpLinkLsNlriVer4) nlri).getLinkIdentifier();
    /* Here, we are checking if the given link is contained in the AdjacencyRib of any peer
           or not. If none of the peer's AdjacencyRib has it, link can be marked for deletion.
         */
    boolean shouldDeleteLink = false;
    if (linkTree.containsKey(linkLsIdentifier)) {
        shouldDeleteLink = true;
    }
    for (BgpId bgpId : bgpController.connectedPeers().keySet()) {
        peer = (BgpPeerImpl) (bgpController.getPeer(bgpId));
        if (linkTree.containsKey(linkLsIdentifier)) {
            containsKey = (!isVpnRib) ? (peer.adjacencyRib().linkTree().containsKey(linkLsIdentifier)) : (peer.vpnAdjacencyRib().linkTree().containsKey(linkLsIdentifier));
            if (!containsKey) {
                continue;
            }
            sessionInfo = peer.sessionInfo();
            PathAttrNlriDetailsLocalRib detailsLocRib = new PathAttrNlriDetailsLocalRib(sessionInfo.remoteBgpId().ipAddress(), sessionInfo.remoteBgpIdentifier(), sessionInfo.remoteBgpASNum(), sessionInfo.isIbgpSession(), ((!isVpnRib) ? (peer.adjacencyRib().linkTree().get(linkLsIdentifier)) : (peer.vpnAdjacencyRib().linkTree().get(linkLsIdentifier))));
            BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo();
            decisionResult = selectionAlgo.compare(linkTree.get(linkLsIdentifier), detailsLocRib);
            if (decisionResult < 0) {
                linkTree.replace(linkLsIdentifier, detailsLocRib);
                log.debug("Local RIB link updated: {}", detailsLocRib.toString());
            }
            shouldDeleteLink = false;
        }
    }
    if (shouldDeleteLink) {
        log.debug("Local RIB remove link: {}", linkLsIdentifier.toString());
        for (BgpLinkListener l : bgpController.linkListener()) {
            l.deleteLink((BgpLinkLsNlriVer4) nlri);
        }
        linkTree.remove(linkLsIdentifier);
        bgpController.notifyTopologyChange();
    }
}
Also used : PathAttrNlriDetailsLocalRib(org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib) BgpSessionInfo(org.onosproject.bgp.controller.BgpSessionInfo) BgpLinkListener(org.onosproject.bgp.controller.BgpLinkListener) BgpId(org.onosproject.bgp.controller.BgpId) BgpLinkLsNlriVer4(org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4) BgpLinkLSIdentifier(org.onosproject.bgpio.protocol.linkstate.BgpLinkLSIdentifier)

Aggregations

BgpId (org.onosproject.bgp.controller.BgpId)3 BgpSessionInfo (org.onosproject.bgp.controller.BgpSessionInfo)3 PathAttrNlriDetailsLocalRib (org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib)3 BgpLinkListener (org.onosproject.bgp.controller.BgpLinkListener)1 BgpNodeListener (org.onosproject.bgp.controller.BgpNodeListener)1 BgpPrefixListener (org.onosproject.bgp.controller.BgpPrefixListener)1 BgpLinkLSIdentifier (org.onosproject.bgpio.protocol.linkstate.BgpLinkLSIdentifier)1 BgpLinkLsNlriVer4 (org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4)1 BgpNodeLSIdentifier (org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier)1 BgpNodeLSNlriVer4 (org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4)1 BgpPrefixIPv4LSNlriVer4 (org.onosproject.bgpio.protocol.linkstate.BgpPrefixIPv4LSNlriVer4)1 BgpPrefixLSIdentifier (org.onosproject.bgpio.protocol.linkstate.BgpPrefixLSIdentifier)1