Search in sources :

Example 6 with BgpLinkLsNlriVer4

use of org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4 in project onos by opennetworkinglab.

the class BgpLocalRibImpl method add.

@Override
public void add(BgpSessionInfo sessionInfo, BgpLSNlri nlri, PathAttrNlriDetails details) throws BgpParseException {
    int decisionResult;
    log.debug("Add to local RIB {}", details.toString());
    PathAttrNlriDetailsLocalRib detailsLocRib = new PathAttrNlriDetailsLocalRib(sessionInfo.remoteBgpId().ipAddress(), sessionInfo.remoteBgpIdentifier(), sessionInfo.remoteBgpASNum(), sessionInfo.isIbgpSession(), details);
    if (nlri instanceof BgpNodeLSNlriVer4) {
        BgpNodeLSIdentifier nodeLsIdentifier = ((BgpNodeLSNlriVer4) nlri).getLocalNodeDescriptors();
        if (nodeTree.containsKey(nodeLsIdentifier)) {
            BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo();
            // Compare local RIB entry with the current attribute
            decisionResult = selectionAlgo.compare(nodeTree.get(nodeLsIdentifier), detailsLocRib);
            if (decisionResult <= 0) {
                for (BgpNodeListener l : bgpController.listener()) {
                    l.addNode((BgpNodeLSNlriVer4) nlri, details);
                }
                nodeTree.replace(nodeLsIdentifier, detailsLocRib);
                log.debug("Local RIB update node: {}", detailsLocRib.toString());
            }
        } else {
            nodeTree.put(nodeLsIdentifier, detailsLocRib);
            for (BgpNodeListener l : bgpController.listener()) {
                l.addNode((BgpNodeLSNlriVer4) nlri, details);
            }
            bgpController.notifyTopologyChange();
            log.debug("Local RIB add node: {}", detailsLocRib.toString());
        }
    } else if (nlri instanceof BgpLinkLsNlriVer4) {
        BgpLinkLSIdentifier linkLsIdentifier = ((BgpLinkLsNlriVer4) nlri).getLinkIdentifier();
        if (linkTree.containsKey(linkLsIdentifier)) {
            BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo();
            // Compare local RIB entry with the current attribute
            decisionResult = selectionAlgo.compare(linkTree.get(linkLsIdentifier), detailsLocRib);
            if (decisionResult <= 0) {
                linkTree.replace(linkLsIdentifier, detailsLocRib);
                for (BgpLinkListener l : bgpController.linkListener()) {
                    l.addLink((BgpLinkLsNlriVer4) nlri, details);
                }
                log.debug("Local RIB update link: {}", detailsLocRib.toString());
            }
        } else {
            linkTree.put(linkLsIdentifier, detailsLocRib);
            for (BgpLinkListener l : bgpController.linkListener()) {
                l.addLink((BgpLinkLsNlriVer4) nlri, details);
            }
            bgpController.notifyTopologyChange();
            log.debug("Local RIB add link: {}", detailsLocRib.toString());
        }
    } else if (nlri instanceof BgpPrefixIPv4LSNlriVer4) {
        BgpPrefixLSIdentifier prefixIdentifier = ((BgpPrefixIPv4LSNlriVer4) nlri).getPrefixIdentifier();
        if (prefixTree.containsKey(prefixIdentifier)) {
            BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo();
            // Compare local RIB entry with the current attribute
            decisionResult = selectionAlgo.compare(prefixTree.get(prefixIdentifier), detailsLocRib);
            if (decisionResult <= 0) {
                prefixTree.replace(prefixIdentifier, detailsLocRib);
                for (BgpPrefixListener l : bgpController.prefixListener()) {
                    l.addPrefix((BgpPrefixIPv4LSNlriVer4) nlri, details);
                }
                log.debug("Local RIB update prefix: {}", detailsLocRib.toString());
            }
        } else {
            prefixTree.put(prefixIdentifier, detailsLocRib);
            for (BgpPrefixListener l : bgpController.prefixListener()) {
                l.addPrefix((BgpPrefixIPv4LSNlriVer4) nlri, details);
            }
            log.debug("Local RIB add prefix: {}", detailsLocRib.toString());
        }
    }
}
Also used : BgpNodeListener(org.onosproject.bgp.controller.BgpNodeListener) BgpPrefixListener(org.onosproject.bgp.controller.BgpPrefixListener) PathAttrNlriDetailsLocalRib(org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib) BgpPrefixLSIdentifier(org.onosproject.bgpio.protocol.linkstate.BgpPrefixLSIdentifier) BgpLinkListener(org.onosproject.bgp.controller.BgpLinkListener) BgpNodeLSNlriVer4(org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4) BgpPrefixIPv4LSNlriVer4(org.onosproject.bgpio.protocol.linkstate.BgpPrefixIPv4LSNlriVer4) BgpNodeLSIdentifier(org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier) BgpLinkLsNlriVer4(org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4) BgpLinkLSIdentifier(org.onosproject.bgpio.protocol.linkstate.BgpLinkLSIdentifier)

Example 7 with BgpLinkLsNlriVer4

use of org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4 in project onos by opennetworkinglab.

the class BgpLocalRibImpl method localRibUpdateLink.

/**
 * Update localRIB link based on available peer adjacency RIB.
 *
 * @param o adjacency-in/VPN adjacency-in
 * @throws BgpParseException BGP parse exceptions
 */
public void localRibUpdateLink(Object o) throws BgpParseException {
    if (o instanceof AdjRibIn) {
        AdjRibIn adjRib = (AdjRibIn) o;
        log.debug("Update local RIB link.");
        Set<BgpLinkLSIdentifier> linkKeys = adjRib.linkTree().keySet();
        for (BgpLinkLSIdentifier key : linkKeys) {
            PathAttrNlriDetails pathAttrNlri = adjRib.linkTree().get(key);
            BgpLinkLsNlriVer4 linkNlri = new BgpLinkLsNlriVer4(pathAttrNlri.protocolID().getType(), pathAttrNlri.identifier(), key, null, false);
            decisionProcess(linkNlri);
        }
    }
    if (o instanceof VpnAdjRibIn) {
        VpnAdjRibIn vpnAdjRib = (VpnAdjRibIn) o;
        log.debug("Update local RIB VPN link");
        Set<RouteDistinguisher> linkKeysVpn = vpnAdjRib.vpnLinkTree().keySet();
        Map<BgpLinkLSIdentifier, PathAttrNlriDetails> link;
        for (RouteDistinguisher keyVpnLink : linkKeysVpn) {
            link = vpnAdjRib.vpnLinkTree().get(keyVpnLink);
            Set<BgpLinkLSIdentifier> vpnLinkKeys = link.keySet();
            for (BgpLinkLSIdentifier key : vpnLinkKeys) {
                PathAttrNlriDetails pathAttrNlri = vpnAdjRib.linkTree().get(key);
                BgpLinkLsNlriVer4 linkNlri = new BgpLinkLsNlriVer4(pathAttrNlri.protocolID().getType(), pathAttrNlri.identifier(), key, keyVpnLink, true);
                decisionProcess(linkNlri, keyVpnLink);
            }
        }
    }
}
Also used : PathAttrNlriDetails(org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails) RouteDistinguisher(org.onosproject.bgpio.types.RouteDistinguisher) BgpLinkLsNlriVer4(org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4) BgpLinkLSIdentifier(org.onosproject.bgpio.protocol.linkstate.BgpLinkLSIdentifier)

Aggregations

BgpLinkLsNlriVer4 (org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4)7 BgpLinkLSIdentifier (org.onosproject.bgpio.protocol.linkstate.BgpLinkLSIdentifier)3 BgpNodeLSNlriVer4 (org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4)3 BgpPrefixIPv4LSNlriVer4 (org.onosproject.bgpio.protocol.linkstate.BgpPrefixIPv4LSNlriVer4)3 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)2 Test (org.junit.Test)2 BgpLinkListener (org.onosproject.bgp.controller.BgpLinkListener)2 BgpLSNlri (org.onosproject.bgpio.protocol.BgpLSNlri)2 PathAttrNlriDetails (org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails)2 PathAttrNlriDetailsLocalRib (org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib)2 BgpHeader (org.onosproject.bgpio.types.BgpHeader)2 BgpValueType (org.onosproject.bgpio.types.BgpValueType)2 MpReachNlri (org.onosproject.bgpio.types.MpReachNlri)2 LinkedList (java.util.LinkedList)1 IpPrefix (org.onlab.packet.IpPrefix)1 BgpId (org.onosproject.bgp.controller.BgpId)1 BgpNodeListener (org.onosproject.bgp.controller.BgpNodeListener)1 BgpPrefixListener (org.onosproject.bgp.controller.BgpPrefixListener)1 BgpSessionInfo (org.onosproject.bgp.controller.BgpSessionInfo)1 BgpNodeLSIdentifier (org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier)1