@Override protected Long featureValueOf(AbstractRoute actual) { return actual.getMetric(); } }
/** * Remove a route from backup route map if it was present and backup route map exists * * @param route Route to remove */ public final void removeBackupRoute(R route) { if (_backupRoutes != null) { SortedSet<R> routes = _backupRoutes.get(route.getNetwork()); if (routes != null) { routes.remove(route); } } }
@Override protected Ip featureValueOf(AbstractRoute actual) { return actual.getNextHopIp(); } }
@Override public String toString() { return this.getClass().getSimpleName() + "<" + _network + ",nhip:" + getNextHopIp() + ",nhint:" + getNextHopInterface() + ">"; }
/** * Converts a {@link AbstractRoute} to a {@link Row} * * @param hostName {@link String} host-name of the node containing the route * @param vrfName {@link String} name of the VRF containing the route * @param abstractRoute {@link AbstractRoute} to convert * @param columnMetadataMap Column metadata of the columns for this {@link Row} c * @return {@link Row} representing the {@link AbstractRoute} */ private static Row abstractRouteToRow( String hostName, String vrfName, AbstractRoute abstractRoute, Map<String, ColumnMetadata> columnMetadataMap, @Nullable Map<Ip, Set<String>> ipOwners) { return Row.builder(columnMetadataMap) .put(COL_NODE, new Node(hostName)) .put(COL_VRF_NAME, vrfName) .put(COL_NETWORK, abstractRoute.getNetwork()) .put(COL_NEXT_HOP_IP, abstractRoute.getNextHopIp()) .put(COL_NEXT_HOP, computeNextHopNode(abstractRoute.getNextHopIp(), ipOwners)) .put(COL_PROTOCOL, abstractRoute.getProtocol()) .put( COL_TAG, abstractRoute.getTag() == AbstractRoute.NO_TAG ? null : abstractRoute.getTag()) .put(COL_ADMIN_DISTANCE, abstractRoute.getAdministrativeCost()) .put(COL_METRIC, abstractRoute.getMetric()) .build(); }
transformedOutgoingRouteBuilder.setTag(route.getTag()); RoutingProtocol remoteRouteProtocol = route.getProtocol(); transformedOutgoingRouteBuilder.setNetwork(route.getNetwork()); transformedOutgoingRouteBuilder.setMetric(route.getMetric()); localPreference = BgpRoute.DEFAULT_LOCAL_PREFERENCE; } else { nextHopIp = route.getNextHopIp(); BgpRoute remoteIbgpRoute = (BgpRoute) route; localPreference = remoteIbgpRoute.getLocalPreference(); nextHopIp = ((BgpActivePeerConfig) toNeighbor).getPeerAddress(); } else { String nextHopInterface = route.getNextHopInterface(); InterfaceAddress nextHopAddress = fromVrf.getInterfaces().get(nextHopInterface).getAddress(); transformedOutgoingRouteBuilder.setSrcProtocol(route.getProtocol()); return transformedOutgoingRouteBuilder;
int maxPrefixLength, @Nullable AbstractRoute parentRoute) { Prefix network = route.getNetwork(); if (seenNetworks.contains(network)) { return; if (route.getNonForwarding()) { if (parentRoute == null) { return; } else { seenNetworks.remove(parentRoute.getNetwork()); collectNextHopInterfaces( rib, String nextHopInterface = route.getNextHopInterface(); if (!Route.UNSET_NEXT_HOP_INTERFACE.equals(nextHopInterface)) { Ip finalNextHopIp = route.getNextHopIp().equals(Route.UNSET_ROUTE_NEXT_HOP_IP) ? mostRecentNextHopIp : route.getNextHopIp(); Map<Ip, Set<AbstractRoute>> nextHopInterfaceRoutesByFinalNextHopIp = nextHopInterfaces.computeIfAbsent(nextHopInterface, k -> new HashMap<>()); nextHopInterfaceRoutes.add(route); } else { Ip nextHopIp = route.getNextHopIp(); if (!nextHopIp.equals(Route.UNSET_ROUTE_NEXT_HOP_IP)) { Set<AbstractRoute> nextHopLongestPrefixMatchRoutes =
_dataPlane.getRibs().get(currentNodeName).get(vrfName).longestPrefixMatch(dstIp).stream() .sorted() .map(rc -> new RouteInfo(rc.getProtocol(), rc.getNetwork(), rc.getNextHopIp())) .distinct() .collect(ImmutableList.toImmutableList()); Ip nextHopIp = routeCandidate.getNextHopIp(); if (nextHopIp.equals(Route.UNSET_ROUTE_NEXT_HOP_IP)) { resolvedNextHopWithRoutes.put(nextHopIp, routeCandidate);
.filter( route -> (network == null || network.equals(route.getNetwork())) && protocolSpec.getProtocols().contains(route.getProtocol())) .forEach( route ->
@Override protected RoutingProtocol featureValueOf(AbstractRoute actual) { return actual.getProtocol(); } }
@Override protected Boolean featureValueOf(AbstractRoute actual) { return actual.getNonForwarding(); } }
@Override protected String featureValueOf(AbstractRoute actual) { return actual.getNextHopInterface(); } }
@Override public Result evaluate(Environment environment) { int lhs; if (environment.getReadFromIntermediateBgpAttributes()) { lhs = environment.getIntermediateBgpAttributes().getTag(); } else if (environment.getUseOutputAttributes()) { lhs = environment.getOutputRoute().getTag(); } else { lhs = environment.getOriginalRoute().getTag(); } int rhs = _tag.evaluate(environment); return _cmp.apply(lhs, rhs); }
@Override protected Integer featureValueOf(AbstractRoute actual) { return actual.getAdministrativeCost(); } }
.filter( route -> (network == null || network.equals(route.getNetwork())) && protocolSpec.getProtocols().contains(route.getProtocol())) .forEach( route -> routesGroups .computeIfAbsent( new RouteRowKey(node, vrfName, route.getNetwork()), k -> new HashMap<>()) .computeIfAbsent( new RouteRowSecondaryKey( route.getNextHopIp(), route.getProtocol().protocolName()), k -> new TreeSet<>()) .add( RouteRowAttribute.builder() .setNextHop( computeNextHopNode(route.getNextHopIp(), ipOwners)) .setAdminDistance(route.getAdministrativeCost()) .setMetric(route.getMetric()) .setTag(route.getTag()) .build()));
@Override public Result evaluate(Environment environment) { Result result = new Result(); // Workaround: Treat ISIS_ANY as a special value if (_protocol == RoutingProtocol.ISIS_ANY) { result.setBooleanValue(ISIS_EXPANSION.contains(environment.getOriginalRoute().getProtocol())); } else { result.setBooleanValue(environment.getOriginalRoute().getProtocol().equals(_protocol)); } return result; }
/** Returns the forwarding routes stored in this node. */ private Set<R> getForwardingRoutes() { return _routes.stream() .filter(r -> !r.getNonForwarding()) .collect(ImmutableSet.toImmutableSet()); }
/** * Add route to backup route map if the route map is not null * * @param route Route to add */ public final void addBackupRoute(R route) { if (_backupRoutes != null) { _backupRoutes.computeIfAbsent(route.getNetwork(), k -> new TreeSet<>()).add(route); } }
@Override public Ip evaluate(Environment env) { return env.getOriginalRoute().getNextHopIp(); }