@Test public void createRouterArpFlow_ipV4() throws Exception { IndexedTenant tenant = getTestIndexedTenant(); SubnetBuilder subnetBuilder = new SubnetBuilder(); subnetBuilder.setId(SUBNET_0); subnetBuilder.setParent(L2FD_ID); subnetBuilder.setVirtualRouterIp(new IpAddress(IPV4_0)); MatchBuilder matchBuilder = new MatchBuilder().setEthernetMatch(ethernetMatch(null, null, ARP)) .setLayer3Match(new ArpMatchBuilder().setArpOp(1) .setArpTargetTransportAddress(new Ipv4Prefix(IPV4_0.getValue() + IP_PREFIX_32)) .build()); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg6.class, (long) 5)); Match match = matchBuilder.build(); List<Action> actions = new ArrayList<>(); actions.add(nxMoveEthSrcToEthDstAction()); actions.add(setDlSrcAction(DestinationMapper.ROUTER_MAC)); actions.add(nxLoadArpOpAction(BigInteger.valueOf(2L))); actions.add(nxMoveArpShaToArpThaAction()); actions.add(nxLoadArpShaAction(new BigInteger(1, bytesFromHexString(DestinationMapper.ROUTER_MAC.getValue())))); actions.add(nxMoveArpSpaToArpTpaAction()); actions.add(nxLoadArpSpaAction(IPV4_0.getValue())); actions.add(outputAction(new NodeConnectorId(NODE_ID.getValue() + ":INPORT"))); List<Instruction> instructions = new ArrayList<>(); InstructionBuilder instructionBuilder = new InstructionBuilder(); instructionBuilder.setInstruction(applyActionIns(actions.toArray(new Action[actions.size()]))).setOrder(0); instructions.add(instructionBuilder.build()); InstructionsBuilder instructionsBuilder = new InstructionsBuilder(); instructionsBuilder.setInstruction(instructions); Flow flow = buildFlow(FlowIdUtils.newFlowId(tableId, "routerarp", match), tableId, 50, match, instructionsBuilder.build()).build(); flows.createRouterArpFlow(50, tenant, subnetBuilder.build(), ofWriter); verify(ofWriter, times(1)).writeFlow(any(NodeId.class), anyShort(), eq(flow)); }
void createRouterArpFlow(int priority, IndexedTenant indexedTenant, Subnet subnet, OfWriter ofWriter) throws Exception { Tenant tenant = indexedTenant.getTenant(); if (tenant != null) { L3Context l3Context = utils.getL3ContextForSubnet(indexedTenant, subnet); if (l3Context != null) { int contextOrdinal = OrdinalFactory.getContextOrdinal(tenant.getId(), l3Context.getId()); MacAddress routerMac = utils.routerPortMac(l3Context, subnet.getVirtualRouterIp(), indexedTenant.getTenant().getId()); if (routerMac != null) { if (subnet.getVirtualRouterIp().getIpv4Address() == null && subnet.getVirtualRouterIp().getIpv6Address() != null) { LOG.warn("IPv6 virtual router {} for subnet {} not supported", subnet.getVirtualRouterIp(), subnet.getId() .getValue()); return; } String ipv4Value = subnet.getVirtualRouterIp().getIpv4Address().getValue(); BigInteger intRouterMac = new BigInteger(1, bytesFromHexString(routerMac.getValue())); MatchBuilder matchBuilder = new MatchBuilder() .setEthernetMatch(ethernetMatch(null, null, ARP)) .setLayer3Match(new ArpMatchBuilder() .setArpOp(1) .setArpTargetTransportAddress(new Ipv4Prefix(ipv4Value + "/32")) .build()); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg6.class, (long) contextOrdinal)); Match match = matchBuilder.build(); FlowId flowId = FlowIdUtils.newFlowId(tableId, "routerarp", match); FlowBuilder flowBuilder = base(tableId).setPriority(priority) .setId(flowId) .setMatch(match) .setInstructions(instructions(applyActionIns(nxMoveEthSrcToEthDstAction(), setDlSrcAction(routerMac), nxLoadArpOpAction(BigInteger.valueOf(2L)), nxMoveArpShaToArpThaAction(), nxLoadArpShaAction(intRouterMac), nxMoveArpSpaToArpTpaAction(), nxLoadArpSpaAction(ipv4Value), outputAction(new NodeConnectorId(nodeId.getValue() + ":INPORT"))))); ofWriter.writeFlow(nodeId, tableId, flowBuilder.build()); } } else { LOG.error("No L3 Context found associated with subnet {}.", subnet.getId()); } } }
DestinationMapperFlows { void createRouterArpFlow(int priority, IndexedTenant indexedTenant, Subnet subnet, OfWriter ofWriter) throws Exception { Tenant tenant = indexedTenant.getTenant(); if (tenant != null) { L3Context l3Context = utils.getL3ContextForSubnet(indexedTenant, subnet); if (l3Context != null) { int contextOrdinal = OrdinalFactory.getContextOrdinal(tenant.getId(), l3Context.getId()); MacAddress routerMac = utils.routerPortMac(l3Context, subnet.getVirtualRouterIp(), indexedTenant.getTenant().getId()); if (routerMac != null) { if (subnet.getVirtualRouterIp().getIpv4Address() == null && subnet.getVirtualRouterIp().getIpv6Address() != null) { LOG.warn("IPv6 virtual router {} for subnet {} not supported", subnet.getVirtualRouterIp(), subnet.getId() .getValue()); return; } String ipv4Value = subnet.getVirtualRouterIp().getIpv4Address().getValue(); BigInteger intRouterMac = new BigInteger(1, bytesFromHexString(routerMac.getValue())); MatchBuilder matchBuilder = new MatchBuilder() .setEthernetMatch(ethernetMatch(null, null, ARP)) .setLayer3Match(new ArpMatchBuilder() .setArpOp(1) .setArpTargetTransportAddress(new Ipv4Prefix(ipv4Value + "/32")) .build()); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg6.class, (long) contextOrdinal)); Match match = matchBuilder.build(); FlowId flowId = FlowIdUtils.newFlowId(tableId, "routerarp", match); FlowBuilder flowBuilder = base(tableId).setPriority(priority) .setId(flowId) .setMatch(match) .setInstructions(instructions(applyActionIns(nxMoveEthSrcToEthDstAction(), setDlSrcAction(routerMac), nxLoadArpOpAction(BigInteger.valueOf(2L)), nxMoveArpShaToArpThaAction(), nxLoadArpShaAction(intRouterMac), nxMoveArpSpaToArpTpaAction(), nxLoadArpSpaAction(ipv4Value), outputAction(new NodeConnectorId(nodeId.getValue() + ":INPORT"))))); ofWriter.writeFlow(nodeId, tableId, flowBuilder.build()); } } else { LOG.error("No L3 Context found associated with subnet {}.", subnet.getId()); } } } }
DestinationMapperFlows { void createRouterArpFlow(int priority, IndexedTenant indexedTenant, Subnet subnet, OfWriter ofWriter) throws Exception { Tenant tenant = indexedTenant.getTenant(); if (tenant != null) { L3Context l3Context = utils.getL3ContextForSubnet(indexedTenant, subnet); if (l3Context != null) { int contextOrdinal = OrdinalFactory.getContextOrdinal(tenant.getId(), l3Context.getId()); MacAddress routerMac = utils.routerPortMac(l3Context, subnet.getVirtualRouterIp(), indexedTenant.getTenant().getId()); if (routerMac != null) { if (subnet.getVirtualRouterIp().getIpv4Address() == null && subnet.getVirtualRouterIp().getIpv6Address() != null) { LOG.warn("IPv6 virtual router {} for subnet {} not supported", subnet.getVirtualRouterIp(), subnet.getId() .getValue()); return; } String ipv4Value = subnet.getVirtualRouterIp().getIpv4Address().getValue(); BigInteger intRouterMac = new BigInteger(1, bytesFromHexString(routerMac.getValue())); MatchBuilder matchBuilder = new MatchBuilder() .setEthernetMatch(ethernetMatch(null, null, ARP)) .setLayer3Match(new ArpMatchBuilder() .setArpOp(1) .setArpTargetTransportAddress(new Ipv4Prefix(ipv4Value + "/32")) .build()); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg6.class, (long) contextOrdinal)); Match match = matchBuilder.build(); FlowId flowId = FlowIdUtils.newFlowId(tableId, "routerarp", match); FlowBuilder flowBuilder = base(tableId).setPriority(priority) .setId(flowId) .setMatch(match) .setInstructions(instructions(applyActionIns(nxMoveEthSrcToEthDstAction(), setDlSrcAction(routerMac), nxLoadArpOpAction(BigInteger.valueOf(2L)), nxMoveArpShaToArpThaAction(), nxLoadArpShaAction(intRouterMac), nxMoveArpSpaToArpTpaAction(), nxLoadArpSpaAction(ipv4Value), outputAction(new NodeConnectorId(nodeId.getValue() + ":INPORT"))))); ofWriter.writeFlow(nodeId, tableId, flowBuilder.build()); } } else { LOG.error("No L3 Context found associated with subnet {}.", subnet.getId()); } } } DestinationMapperFlows(DestinationMapperUtils utils, NodeId nodeId, short tableId); }
DestinationMapperFlows { void createRouterArpFlow(int priority, IndexedTenant indexedTenant, Subnet subnet, OfWriter ofWriter) throws Exception { Tenant tenant = indexedTenant.getTenant(); if (tenant != null) { L3Context l3Context = utils.getL3ContextForSubnet(indexedTenant, subnet); if (l3Context != null) { int contextOrdinal = OrdinalFactory.getContextOrdinal(tenant.getId(), l3Context.getId()); MacAddress routerMac = utils.routerPortMac(l3Context, subnet.getVirtualRouterIp(), indexedTenant.getTenant().getId()); if (routerMac != null) { if (subnet.getVirtualRouterIp().getIpv4Address() == null && subnet.getVirtualRouterIp().getIpv6Address() != null) { LOG.warn("IPv6 virtual router {} for subnet {} not supported", subnet.getVirtualRouterIp(), subnet.getId() .getValue()); return; } String ipv4Value = subnet.getVirtualRouterIp().getIpv4Address().getValue(); BigInteger intRouterMac = new BigInteger(1, bytesFromHexString(routerMac.getValue())); MatchBuilder matchBuilder = new MatchBuilder() .setEthernetMatch(ethernetMatch(null, null, ARP)) .setLayer3Match(new ArpMatchBuilder() .setArpOp(1) .setArpTargetTransportAddress(new Ipv4Prefix(ipv4Value + "/32")) .build()); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg6.class, (long) contextOrdinal)); Match match = matchBuilder.build(); FlowId flowId = FlowIdUtils.newFlowId(tableId, "routerarp", match); FlowBuilder flowBuilder = base(tableId).setPriority(priority) .setId(flowId) .setMatch(match) .setInstructions(instructions(applyActionIns(nxMoveEthSrcToEthDstAction(), setDlSrcAction(routerMac), nxLoadArpOpAction(BigInteger.valueOf(2L)), nxMoveArpShaToArpThaAction(), nxLoadArpShaAction(intRouterMac), nxMoveArpSpaToArpTpaAction(), nxLoadArpSpaAction(ipv4Value), outputAction(new NodeConnectorId(nodeId.getValue() + ":INPORT"))))); ofWriter.writeFlow(nodeId, tableId, flowBuilder.build()); } } else { LOG.error("No L3 Context found associated with subnet {}.", subnet.getId()); } } } DestinationMapperFlows(DestinationMapperUtils utils, NodeId nodeId, short tableId);  }
DestinationMapperFlows { void createRouterArpFlow(int priority, IndexedTenant indexedTenant, Subnet subnet, OfWriter ofWriter) throws Exception { Tenant tenant = indexedTenant.getTenant(); if (tenant != null) { L3Context l3Context = utils.getL3ContextForSubnet(indexedTenant, subnet); if (l3Context != null) { int contextOrdinal = OrdinalFactory.getContextOrdinal(tenant.getId(), l3Context.getId()); MacAddress routerMac = utils.routerPortMac(l3Context, subnet.getVirtualRouterIp(), indexedTenant.getTenant().getId()); if (routerMac != null) { if (subnet.getVirtualRouterIp().getIpv4Address() == null && subnet.getVirtualRouterIp().getIpv6Address() != null) { LOG.warn("IPv6 virtual router {} for subnet {} not supported", subnet.getVirtualRouterIp(), subnet.getId() .getValue()); return; } String ipv4Value = subnet.getVirtualRouterIp().getIpv4Address().getValue(); BigInteger intRouterMac = new BigInteger(1, bytesFromHexString(routerMac.getValue())); MatchBuilder matchBuilder = new MatchBuilder() .setEthernetMatch(ethernetMatch(null, null, ARP)) .setLayer3Match(new ArpMatchBuilder() .setArpOp(1) .setArpTargetTransportAddress(new Ipv4Prefix(ipv4Value + "/32")) .build()); addNxRegMatch(matchBuilder, RegMatch.of(NxmNxReg6.class, (long) contextOrdinal)); Match match = matchBuilder.build(); FlowId flowId = FlowIdUtils.newFlowId(tableId, "routerarp", match); FlowBuilder flowBuilder = base(tableId).setPriority(priority) .setId(flowId) .setMatch(match) .setInstructions(instructions(applyActionIns(nxMoveEthSrcToEthDstAction(), setDlSrcAction(routerMac), nxLoadArpOpAction(BigInteger.valueOf(2L)), nxMoveArpShaToArpThaAction(), nxLoadArpShaAction(intRouterMac), nxMoveArpSpaToArpTpaAction(), nxLoadArpSpaAction(ipv4Value), outputAction(new NodeConnectorId(nodeId.getValue() + ":INPORT"))))); ofWriter.writeFlow(nodeId, tableId, flowBuilder.build()); } } else { LOG.error("No L3 Context found associated with subnet {}.", subnet.getId()); } } } DestinationMapperFlows(DestinationMapperUtils utils, NodeId nodeId, short tableId);   }