use of org.batfish.datamodel.FibNullRoute in project batfish by batfish.
the class FlowTracer method buildRoutingStep.
@VisibleForTesting
static RoutingStep buildRoutingStep(String vrf, FibAction fibAction, Set<FibEntry> fibEntries) {
RoutingStep.Builder routingStepBuilder = RoutingStep.builder();
List<RouteInfo> routeInfos = fibEntriesToRouteInfos(fibEntries);
RoutingStepDetail.Builder routingStepDetailBuilder = RoutingStepDetail.builder().setVrf(vrf).setRoutes(routeInfos);
fibAction.accept(new FibActionVisitor<Void>() {
@Override
public Void visitFibForward(FibForward fibForward) {
assert !routeInfos.isEmpty();
RouteInfo primaryRouteInfo = routeInfos.get(0);
if (primaryRouteInfo.getNextHop() instanceof NextHopVtep) {
NextHopVtep nhVtep = (NextHopVtep) primaryRouteInfo.getNextHop();
routingStepDetailBuilder.setForwardingDetail(ForwardedIntoVxlanTunnel.of(nhVtep.getVni(), nhVtep.getVtepIp()));
} else {
Optional<Ip> maybeResolvedNextHopIp = fibForward.getArpIp();
if (!maybeResolvedNextHopIp.isPresent()) {
routingStepDetailBuilder.setForwardingDetail(ForwardedOutInterface.of(fibForward.getInterfaceName()));
} else {
Ip resolvedNextHopIp = maybeResolvedNextHopIp.get();
routingStepDetailBuilder.setForwardingDetail(ForwardedOutInterface.of(fibForward.getInterfaceName(), resolvedNextHopIp)).setArpIp(resolvedNextHopIp);
}
}
routingStepDetailBuilder.setOutputInterface(fibForward.getInterfaceName());
routingStepBuilder.setAction(FORWARDED);
return null;
}
@Override
public Void visitFibNextVrf(FibNextVrf fibNextVrf) {
routingStepDetailBuilder.setForwardingDetail(DelegatedToNextVrf.of(fibNextVrf.getNextVrf()));
routingStepBuilder.setAction(FORWARDED_TO_NEXT_VRF);
return null;
}
@Override
public Void visitFibNullRoute(FibNullRoute fibNullRoute) {
routingStepDetailBuilder.setForwardingDetail(Discarded.instance());
routingStepBuilder.setAction(NULL_ROUTED);
return null;
}
});
return routingStepBuilder.setDetail(routingStepDetailBuilder.build()).build();
}
use of org.batfish.datamodel.FibNullRoute in project batfish by batfish.
the class FlowTracerTest method testBuildRoutingStepFibNullRouted.
@Test
public void testBuildRoutingStepFibNullRouted() {
Prefix prefix = Prefix.parse("12.12.12.12/30");
FibNullRoute fibNullRoute = FibNullRoute.INSTANCE;
Set<FibEntry> fibEntries = ImmutableSet.of(new FibEntry(fibNullRoute, ImmutableList.of(StaticRoute.testBuilder().setNextHopIp(Ip.parse("2.2.2.2")).setNetwork(prefix).setAdministrativeCost(1).build())));
RoutingStep routingStep = buildRoutingStep("vrf", fibNullRoute, fibEntries);
assertThat(routingStep.getAction(), equalTo(StepAction.NULL_ROUTED));
assertThat(routingStep.getDetail().getVrf(), equalTo("vrf"));
assertThat(routingStep.getDetail().getRoutes(), equalTo(ImmutableList.of(new RouteInfo(RoutingProtocol.STATIC, prefix, NextHopIp.of(Ip.parse("2.2.2.2")), 1, 0))));
assertThat(routingStep.getDetail().getArpIp(), nullValue());
assertThat(routingStep.getDetail().getOutputInterface(), nullValue());
}
Aggregations