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);
}
}
}
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();
}
}
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();
}
}
Aggregations