@Override protected Ip featureValueOf(AbstractRoute actual) { return actual.getNextHopIp(); } }
@Override public String toString() { return this.getClass().getSimpleName() + "<" + _network + ",nhip:" + getNextHopIp() + ",nhint:" + getNextHopInterface() + ">"; }
@Override public Ip evaluate(Environment env) { return env.getOriginalRoute().getNextHopIp(); }
private Multimap<Ip, AbstractRoute> getResolvedNextHopWithRoutes( String nextHopInterfaceName, Map<AbstractRoute, Map<String, Map<Ip, Set<AbstractRoute>>>> nextHopInterfacesByRoute) { ImmutableMultimap.Builder<Ip, AbstractRoute> resolvedNextHopWithRoutesBuilder = new ImmutableMultimap.Builder<>(); // Loop over all matching routes that use nextHopInterfaceName as one of the next hop // interfaces. for (Entry<AbstractRoute, Map<String, Map<Ip, Set<AbstractRoute>>>> e : nextHopInterfacesByRoute.entrySet()) { // finalNextHops: final resolved next hop IP -> interface routes Map<Ip, Set<AbstractRoute>> finalNextHops = e.getValue().get(nextHopInterfaceName); if (finalNextHops == null || finalNextHops.isEmpty()) { continue; } AbstractRoute matchingRoute = e.getKey(); Ip nextHopIp = matchingRoute.getNextHopIp(); if (nextHopIp.equals(Route.UNSET_ROUTE_NEXT_HOP_IP)) { resolvedNextHopWithRoutesBuilder.put(nextHopIp, matchingRoute); } else { for (Ip resolvedNextHopIp : finalNextHops.keySet()) { resolvedNextHopWithRoutesBuilder.put(resolvedNextHopIp, matchingRoute); } } } return resolvedNextHopWithRoutesBuilder.build(); }
private Map<String, Map<String, Map<String, Set<AbstractRoute>>>> computeRoutesWithOwnedNextHopIpArpFalse() { return computeRoutesWithNextHopIpArpFalseFilter( route -> _ipSpaceToBDD.toBDD(route.getNextHopIp()).and(_unownedIpsBDD).isZero()); }
private Map<String, Map<String, Map<String, Set<AbstractRoute>>>> computeRoutesWithUnownedNextHopIpArpFalse() { return computeRoutesWithNextHopIpArpFalseFilter( route -> !_ipSpaceToBDD.toBDD(route.getNextHopIp()).and(_unownedIpsBDD).isZero()); }
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 =
if (accept) { if (!generatedRoute.getDiscard()) { grb.setNextHopIp(contributingCandidate.getNextHopIp());
.computeIfAbsent( new RouteRowSecondaryKey( route.getNextHopIp(), route.getProtocol().protocolName()), k -> new TreeSet<>()) RouteRowAttribute.builder() .setNextHop( computeNextHopNode(route.getNextHopIp(), ipOwners)) .setAdminDistance(route.getAdministrativeCost()) .setMetric(route.getMetric())
ImmutableMap.of( i1, ImmutableMap.of(r1.getNextHopIp(), ImmutableSet.of(ifaceRoute))), ifaceRoute, ImmutableMap.of(
ImmutableMap.of( i1, ImmutableMap.of(r1.getNextHopIp(), ImmutableSet.of(ifaceRoute))))) .build())); _someoneReplies = ImmutableMap.of(c1, ImmutableMap.of(i1, P2.getEndIp().toIpSpace()));
/** * 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(); }
ImmutableMap.of( i1, ImmutableMap.of(r1.getNextHopIp(), ImmutableSet.of(ifaceRoute))), r2, ImmutableMap.of( i1, ImmutableMap.of(r2.getNextHopIp(), ImmutableSet.of(ifaceRoute))))) .build())); _someoneReplies = ImmutableMap.of(c1, ImmutableMap.of(i1, P2.getEndIp().toIpSpace()));
outInterface, ImmutableMap.of( nextHopIpRoute1.getNextHopIp(), ImmutableSet.of(ifaceRoute))), nextHopIpRoute2, ImmutableMap.of( outInterface, ImmutableMap.of( nextHopIpRoute2.getNextHopIp(), ImmutableSet.of(ifaceRoute))), ifaceRoute, ImmutableMap.of(
outInterface, ImmutableMap.of( nextHopIpRoute1.getNextHopIp(), ImmutableSet.of(ifaceRoute))), nextHopIpRoute2, ImmutableMap.of( outInterface, ImmutableMap.of( nextHopIpRoute2.getNextHopIp(), ImmutableSet.of(ifaceRoute))), ifaceRoute, ImmutableMap.of(
_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);
localPreference = BgpRoute.DEFAULT_LOCAL_PREFERENCE; } else { nextHopIp = route.getNextHopIp(); BgpRoute remoteIbgpRoute = (BgpRoute) route; localPreference = remoteIbgpRoute.getLocalPreference();