@Test public void testMatchSessionReturnFlow() { BDDPacket pkt = new BDDPacket(); MemoizedIpAccessListToBdd toBdd = new MemoizedIpAccessListToBdd( pkt, BDDSourceManager.empty(pkt), ImmutableMap.of(), ImmutableMap.of()); Ip dstIp = Ip.parse("1.1.1.1"); Ip srcIp = Ip.parse("2.2.2.2"); Flow.Builder fb = Flow.builder().setIngressNode("node").setIngressVrf("vrf").setDstIp(dstIp).setSrcIp(srcIp); BDD returnFlowDstIpBdd = pkt.getDstIp().value(srcIp.asLong()); BDD returnFlowSrcIpBdd = pkt.getSrcIp().value(dstIp.asLong()); { Flow flow = fb.setIpProtocol(IpProtocol.TCP).setDstPort(100).setSrcPort(20).build(); BDD returnFlowBdd = toBdd.toBdd(matchSessionReturnFlow(flow).toAclLineMatchExpr()); assertEquals( returnFlowBdd, BDDOps.andNull( returnFlowDstIpBdd, returnFlowSrcIpBdd, pkt.getDstPort().value(flow.getSrcPort()), pkt.getSrcPort().value(flow.getDstPort()), pkt.getIpProtocol().value(flow.getIpProtocol()))); } { Flow flow = fb.setIpProtocol(IpProtocol.UDP).setDstPort(100).setSrcPort(20).build(); BDD returnFlowBdd = toBdd.toBdd(matchSessionReturnFlow(flow).toAclLineMatchExpr()); assertEquals( returnFlowBdd, BDDOps.andNull( returnFlowDstIpBdd, returnFlowSrcIpBdd, pkt.getDstPort().value(flow.getSrcPort()), pkt.getSrcPort().value(flow.getDstPort()), pkt.getIpProtocol().value(flow.getIpProtocol()))); } { Flow flow = fb.setIpProtocol(IpProtocol.ICMP).setIcmpType(100).setIcmpCode(20).build(); BDD returnFlowBdd = toBdd.toBdd(matchSessionReturnFlow(flow).toAclLineMatchExpr()); assertEquals( returnFlowBdd, BDDOps.andNull( returnFlowDstIpBdd, returnFlowSrcIpBdd, pkt.getIpProtocol().value(flow.getIpProtocol()))); } }
@VisibleForTesting static SessionMatchExpr matchSessionReturnFlow(Flow forwardFlow) { IpProtocol ipProtocol = forwardFlow.getIpProtocol(); checkArgument( IpProtocol.IP_PROTOCOLS_WITH_SESSIONS.contains(ipProtocol), "cannot match session return flow with IP protocol %s", ipProtocol); return new SessionMatchExpr( ipProtocol, forwardFlow.getDstIp(), forwardFlow.getSrcIp(), forwardFlow.getDstPort(), forwardFlow.getSrcPort()); }
FlowTracer { @VisibleForTesting static SessionMatchExpr matchSessionReturnFlow(Flow forwardFlow) { IpProtocol ipProtocol = forwardFlow.getIpProtocol(); checkArgument( IpProtocol.IP_PROTOCOLS_WITH_SESSIONS.contains(ipProtocol), "cannot match session return flow with IP protocol %s", ipProtocol); return new SessionMatchExpr( ipProtocol, forwardFlow.getDstIp(), forwardFlow.getSrcIp(), forwardFlow.getDstPort(), forwardFlow.getSrcPort()); } }
FlowTracer { @VisibleForTesting static SessionMatchExpr matchSessionReturnFlow(Flow forwardFlow) { IpProtocol ipProtocol = forwardFlow.getIpProtocol(); checkArgument( IpProtocol.IP_PROTOCOLS_WITH_SESSIONS.contains(ipProtocol), "cannot match session return flow with IP protocol %s", ipProtocol); return new SessionMatchExpr( ipProtocol, forwardFlow.getDstIp(), forwardFlow.getSrcIp(), forwardFlow.getDstPort(), forwardFlow.getSrcPort()); } @VisibleForTesting  FlowTracer(
      TracerouteEngineImplContext tracerouteContext,
      Configuration currentConfig,
      @Nullable String ingressInterface,
      Node currentNode,
      TraceRecorder traceRecorder,
      @Nullable NodeInterfacePair lastHopNodeAndOutgoingInterface,
      List<FirewallSessionTraceInfo> newSessions,
      Flow originalFlow,
      @Nonnull String vrfName,
      List<HopInfo> hops,
      List<Step<?>> steps,
      Stack<Breadcrumb> breadcrumbs,
      Flow currentFlow,
      int origNewSessionsSize,
      int origBreadcrumbsSize); }
FlowTracer { @VisibleForTesting static SessionMatchExpr matchSessionReturnFlow(Flow forwardFlow) { IpProtocol ipProtocol = forwardFlow.getIpProtocol(); checkArgument( IpProtocol.IP_PROTOCOLS_WITH_SESSIONS.contains(ipProtocol), "cannot match session return flow with IP protocol %s", ipProtocol); return new SessionMatchExpr( ipProtocol, forwardFlow.getDstIp(), forwardFlow.getSrcIp(), forwardFlow.getDstPort(), forwardFlow.getSrcPort()); } @VisibleForTesting  FlowTracer(
      TracerouteEngineImplContext tracerouteContext,
      Configuration currentConfig,
      @Nullable String ingressInterface,
      Node currentNode,
      TraceRecorder traceRecorder,
      @Nullable NodeInterfacePair lastHopNodeAndOutgoingInterface,
      List<FirewallSessionTraceInfo> newSessions,
      Flow originalFlow,
      @Nonnull String vrfName,
      List<HopInfo> hops,
      List<Step<?>> steps,
      Stack<Breadcrumb> breadcrumbs,
      Flow currentFlow,
      int origNewSessionsSize,
      int origBreadcrumbsSize);  }
FlowTracer { @VisibleForTesting static SessionMatchExpr matchSessionReturnFlow(Flow forwardFlow) { IpProtocol ipProtocol = forwardFlow.getIpProtocol(); checkArgument( IpProtocol.IP_PROTOCOLS_WITH_SESSIONS.contains(ipProtocol), "cannot match session return flow with IP protocol %s", ipProtocol); return new SessionMatchExpr( ipProtocol, forwardFlow.getDstIp(), forwardFlow.getSrcIp(), forwardFlow.getDstPort(), forwardFlow.getSrcPort()); } @VisibleForTesting  FlowTracer(
      TracerouteEngineImplContext tracerouteContext,
      Configuration currentConfig,
      @Nullable String ingressInterface,
      Node currentNode,
      TraceRecorder traceRecorder,
      @Nullable NodeInterfacePair lastHopNodeAndOutgoingInterface,
      List<FirewallSessionTraceInfo> newSessions,
      Flow originalFlow,
      @Nonnull String vrfName,
      List<HopInfo> hops,
      List<Step<?>> steps,
      Stack<Breadcrumb> breadcrumbs,
      Flow currentFlow,
      int origNewSessionsSize,
      int origBreadcrumbsSize);   }