use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.State in project bgpcep by opendaylight.
the class AbstractBestPathSelector method isExistingPathBetter.
/**
* Chooses best route according to BGP best path selection.
*
* @param state attributes of the new route
* @return true if the existing path is better, false if the new path is better
*/
protected boolean isExistingPathBetter(@Nonnull final BestPathState state) {
/*
* 2. prefer path with higher LOCAL_PREF
*
* FIXME: for eBGP cases (when the LOCAL_PREF is missing), we should assign a policy-based preference
* before we ever get here.
*/
if (this.bestState.getLocalPref() == null && state.getLocalPref() != null) {
return true;
}
if (this.bestState.getLocalPref() != null && state.getLocalPref() == null) {
return false;
}
if (state.getLocalPref() != null && state.getLocalPref() > this.bestState.getLocalPref()) {
return false;
}
if (state.getLocalPref() != null && state.getLocalPref() < this.bestState.getLocalPref()) {
return true;
}
// 4. prefer the path with the shortest AS_PATH.
if (this.bestState.getAsPathLength() != state.getAsPathLength()) {
return this.bestState.getAsPathLength() < state.getAsPathLength();
}
// - IGP is lower than Exterior Gateway Protocol (EGP), and EGP is lower than INCOMPLETE
if (!this.bestState.getOrigin().equals(state.getOrigin())) {
final BgpOrigin bo = this.bestState.getOrigin();
final BgpOrigin no = state.getOrigin();
// This trick relies on the order in which the values are declared in the model.
return no.ordinal() > bo.ordinal();
}
// FIXME: we should be able to cache the best AS
final Long bestAs = this.bestState.getPeerAs();
final Long newAs = state.getPeerAs();
/*
* Checks 6 and 7 are mutually-exclusive, as MEDs are comparable
* only when the routes originated from the same AS. On the other
* hand, when they are from the same AS, they are in the same iBGP/eBGP
* relationship.
*
*/
if (bestAs.equals(newAs)) {
// 6. prefer the path with the lowest multi-exit discriminator (MED)
if (this.bestState.getMultiExitDisc() != null || state.getMultiExitDisc() != null) {
final Long bmed = this.bestState.getMultiExitDisc();
final Long nmed = state.getMultiExitDisc();
return nmed > bmed;
}
} else {
/*
* 7. prefer eBGP over iBGP paths
*
* EBGP is peering between two different AS, whereas IBGP is between same AS (Autonomous System),
* so we just compare the AS numbers to our AS.
*
* FIXME: we should know this information from the peer directly.
*/
if (this.ourAs != bestAs && this.ourAs == newAs) {
return true;
}
}
/*
* 10. Prefer the route that comes from the BGP router with the lowest router ID.
*
* This is normally guaranteed by the iteration order of our caller, which runs selection
* in the order of increasing router ID, but RFC-4456 Route Reflection throws a wrench into that.
*
* With RFC-5004, this gets a bit easier, because it completely eliminates step f) and later :-)
*
* RFC-5004 states that this algorithm should end here and select existing path over new path in the
* best path selection process. Benefits are listed in the RFC: @see http://tools.ietf.org/html/rfc500
* - This algorithm SHOULD NOT be applied when either path is from a BGP Confederation peer.
* - not applicable, we don't deal with confederation peers
* - The algorithm SHOULD NOT be applied when both paths are from peers with an identical BGP identifier
* (i.e., there exist parallel BGP sessions between two BGP speakers).
* - not applicable, BUG-2631 prevents parallel sessions to be created.
*/
return true;
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.State in project bgpcep by opendaylight.
the class PCCTunnelManagerImplTest method testReturnDelegationNoRetake.
@Test
public void testReturnDelegationNoRetake() throws InterruptedException {
final PCCTunnelManager tunnelManager = new PCCTunnelManagerImpl(0, ADDRESS, 0, 0, TIMER, this.timerHandler);
tunnelManager.onSessionUp(this.session1);
tunnelManager.onSessionUp(this.session2);
tunnelManager.onMessagePcInitiate(createRequests(1), this.session1);
tunnelManager.onMessagePcupd(createUpdate(1), this.session1);
// wait for state timeout expires
Thread.sleep(500);
Mockito.verify(this.session1, Mockito.times(3)).sendReport(Mockito.any(Pcrpt.class));
Mockito.verify(this.session2, Mockito.times(2)).sendReport(Mockito.any(Pcrpt.class));
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.State in project bgpcep by opendaylight.
the class PCCTunnelManagerImpl method reportToAll.
protected void reportToAll(final Updates update, final PCCSession session) {
final PlspId plspId = update.getLsp().getPlspId();
final PCCTunnel tunnel = this.tunnels.get(plspId);
final long srpId = update.getSrp().getOperationId().getValue();
if (tunnel != null) {
if (hasDelegation(tunnel, session)) {
final Srp srp = createSrp(update.getSrp().getOperationId().getValue());
final Path path = updToRptPath(update.getPath());
final List<Subobject> subobjects = update.getPath().getEro().getSubobject();
final Lsp lsp = update.getLsp();
sendToAll(tunnel, plspId, subobjects, srp, path, lsp);
// update tunnel state
tunnel.setLspState(path);
} else {
session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.UPDATE_REQ_FOR_NON_LSP, srpId));
}
} else {
session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.UNKNOWN_PLSP_ID, srpId));
}
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.State in project openflowplugin by opendaylight.
the class NodeConnectorInventoryEventTranslator method processUpdatedConnector.
private void processUpdatedConnector(final DataTreeModification<T> modification) {
final InstanceIdentifier<T> identifier = modification.getRootPath().getRootIdentifier();
InstanceIdentifier<NodeConnector> nodeConnectorInstanceId = identifier.firstIdentifierOf(NodeConnector.class);
if (compareIITail(identifier, II_TO_FLOW_CAPABLE_NODE_CONNECTOR)) {
FlowCapableNodeConnector flowConnector = (FlowCapableNodeConnector) modification.getRootNode().getDataAfter();
if (isPortDown(flowConnector)) {
notifyNodeConnectorDisappeared(nodeConnectorInstanceId);
} else {
notifyNodeConnectorAppeared(nodeConnectorInstanceId, flowConnector);
}
} else if (compareIITail(identifier, II_TO_STATE)) {
FlowCapableNodeConnector flowNodeConnector = iiToDownFlowCapableNodeConnectors.get(nodeConnectorInstanceId);
if (flowNodeConnector != null) {
State state = (State) modification.getRootNode().getDataAfter();
if (!state.isLinkDown()) {
FlowCapableNodeConnectorBuilder flowCapableNodeConnectorBuilder = new FlowCapableNodeConnectorBuilder(flowNodeConnector);
flowCapableNodeConnectorBuilder.setState(state);
notifyNodeConnectorAppeared(nodeConnectorInstanceId, flowCapableNodeConnectorBuilder.build());
iiToDownFlowCapableNodeConnectors.remove(nodeConnectorInstanceId);
}
}
}
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.State in project openflowplugin by opendaylight.
the class NodeConnectorInventoryEventTranslatorTest method testNodeConnectorUpdateToLinkDown.
/**
* Test that checks if {@link NodeConnectorEventsObserver#nodeConnectorRemoved} is called
* for each FlowCapableNodeConnector item that have link down state removed in
* {@link org.opendaylight.controller.md.sal.binding.api.DataTreeModification}.
*/
@Test
public void testNodeConnectorUpdateToLinkDown() {
FlowCapableNodeConnector fcnc = TestUtils.createFlowCapableNodeConnector(true, false).build();
DataTreeModification dataTreeModification = setupDataTreeChange(SUBTREE_MODIFIED, NODE_CONNECTOR_INSTANCE_IDENTIFIER, fcnc);
translator.onDataTreeChanged(Collections.singleton(dataTreeModification));
verify(eventsObserver).nodeConnectorRemoved(ID);
}
Aggregations