Java Code Examples for org.onlab.packet.Ethernet#getPayload()
The following examples show how to use
org.onlab.packet.Ethernet#getPayload() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenstackTroubleshootManager.java From onos with Apache License 2.0 | 6 votes |
@Override public void process(PacketContext context) { if (context.isHandled()) { return; } InboundPacket pkt = context.inPacket(); Ethernet ethernet = pkt.parsed(); if (ethernet == null || ethernet.getEtherType() == Ethernet.TYPE_ARP) { return; } IPv4 iPacket = (IPv4) ethernet.getPayload(); if (iPacket.getProtocol() == IPv4.PROTOCOL_ICMP) { eventExecutor.execute(() -> processIcmpPacket(context, ethernet)); } }
Example 2
Source File: IcmpHandler.java From onos with Apache License 2.0 | 6 votes |
@Override public void process(PacketContext context) { // Stop processing if the packet has been handled, since we // can't do any more to it. if (context.isHandled()) { return; } Ethernet packet = context.inPacket().parsed(); if (packet == null) { return; } if (packet.getEtherType() == Ethernet.TYPE_IPV4) { IPv4 ipv4Packet = (IPv4) packet.getPayload(); if (ipv4Packet.getProtocol() == IPv4.PROTOCOL_ICMP) { processPacketIn(context.inPacket()); } } }
Example 3
Source File: K8sSwitchingArpHandler.java From onos with Apache License 2.0 | 6 votes |
private void processArpReply(PacketContext context, Ethernet ethPacket) { ARP arpPacket = (ARP) ethPacket.getPayload(); ConnectPoint cp = context.inPacket().receivedFrom(); K8sNode k8sNode = k8sNodeService.node(cp.deviceId()); if (k8sNode != null && ethPacket.getDestinationMAC().equals(k8sNode.extBridgeMac())) { IpAddress srcIp = IpAddress.valueOf(IpAddress.Version.INET, arpPacket.getSenderProtocolAddress()); MacAddress srcMac = MacAddress.valueOf(arpPacket.getSenderHardwareAddress()); // we only add the host IP - MAC map store once, // mutable MAP scenario is not considered for now if (!extHostMacStore.containsKey(srcIp)) { extHostMacStore.put(srcIp, srcMac); } } }
Example 4
Source File: IcmpHandler.java From onos with Apache License 2.0 | 6 votes |
private void processPacketIn(InboundPacket pkt) { boolean ipMatches = false; Ethernet ethernet = pkt.parsed(); IPv4 ipv4 = (IPv4) ethernet.getPayload(); ConnectPoint connectPoint = pkt.receivedFrom(); IpAddress destIpAddress = IpAddress.valueOf(ipv4.getDestinationAddress()); Interface targetInterface = interfaceService.getMatchingInterface(destIpAddress); if (targetInterface == null) { log.trace("No matching interface for {}", destIpAddress); return; } for (InterfaceIpAddress interfaceIpAddress: targetInterface.ipAddressesList()) { if (interfaceIpAddress.ipAddress().equals(destIpAddress)) { ipMatches = true; break; } } if (((ICMP) ipv4.getPayload()).getIcmpType() == ICMP.TYPE_ECHO_REQUEST && ipMatches) { sendIcmpResponse(ethernet, connectPoint); } }
Example 5
Source File: Dhcp6DirectPacketClassifier.java From onos with Apache License 2.0 | 6 votes |
@Override public boolean match(PacketContext packet) { Ethernet eth = packet.inPacket().parsed(); if (eth.getEtherType() == Ethernet.TYPE_IPV6) { IPv6 ipv6Packet = (IPv6) eth.getPayload(); if (ipv6Packet.getNextHeader() == IPv6.PROTOCOL_UDP) { UDP udpPacket = (UDP) ipv6Packet.getPayload(); //Directly connected host if (udpPacket.getDestinationPort() == UDP.DHCP_V6_SERVER_PORT && udpPacket.getSourcePort() == UDP.DHCP_V6_CLIENT_PORT) { DHCP6 dhcp6 = (DHCP6) udpPacket.getPayload(); if (dhcp6.getMsgType() == DHCP6.MsgType.SOLICIT.value()) { return true; } } } } return false; }
Example 6
Source File: TunnellingConnectivityManager.java From onos with Apache License 2.0 | 6 votes |
@Override public void process(PacketContext context) { // Stop processing if the packet has been handled, since we // can't do any more to it. if (context.isHandled()) { return; } Ethernet packet = context.inPacket().parsed(); if (packet == null) { return; } if (packet.getEtherType() == Ethernet.TYPE_IPV4) { IPv4 ipv4Packet = (IPv4) packet.getPayload(); if (ipv4Packet.getProtocol() == IPv4.PROTOCOL_TCP) { TCP tcpPacket = (TCP) ipv4Packet.getPayload(); if (tcpPacket.getDestinationPort() == BGP_PORT || tcpPacket.getSourcePort() == BGP_PORT) { forward(context); } } } }
Example 7
Source File: OpenstackTroubleshootManager.java From onos with Apache License 2.0 | 5 votes |
/** * Processes the received ICMP packet. * * @param context packet context * @param ethernet ethernet */ private void processIcmpPacket(PacketContext context, Ethernet ethernet) { IPv4 ipPacket = (IPv4) ethernet.getPayload(); ICMP icmp = (ICMP) ipPacket.getPayload(); log.trace("Processing ICMP packet source MAC:{}, source IP:{}," + "dest MAC:{}, dest IP:{}", ethernet.getSourceMAC(), IpAddress.valueOf(ipPacket.getSourceAddress()), ethernet.getDestinationMAC(), IpAddress.valueOf(ipPacket.getDestinationAddress())); String icmpId = icmpId(icmp); // if the ICMP ID is not contained in ICMP ID set, we do not handle it if (!icmpIds.contains(icmpId)) { return; } switch (icmp.getIcmpType()) { case TYPE_ECHO_REPLY: handleIcmpEchoReply(ipPacket, icmp); context.block(); icmpIds.remove(icmpId); break; default: break; } }
Example 8
Source File: IcmpHandlerTest.java From onos with Apache License 2.0 | 5 votes |
@Test public void testPing6RemoteGatewaySamePair() { // Expected behavior expect(segmentRoutingManager.deviceService.isAvailable(LOCAL_LEAF1)) .andReturn(true) .times(1); expect(segmentRoutingManager.deviceService.isAvailable(LOCAL_LEAF2)) .andReturn(true) .times(1); replay(segmentRoutingManager.deviceService); // Process icmpHandler.processIcmpv6(ETH_REQ_IPV6_SAME, CP2025); // Verify packet-out Ethernet ethernet = packetService.getEthernetPacket(ETH_REQ_IPV6_SAME.getSourceMAC()); assertNotNull(ethernet); assertThat(ethernet.getSourceMAC(), is(ETH_REQ_IPV6_SAME.getDestinationMAC())); assertThat(ethernet.getDestinationMAC(), is(ETH_REQ_IPV6_SAME.getSourceMAC())); assertTrue(ethernet.getPayload() instanceof MPLS); MPLS mpls = (MPLS) ethernet.getPayload(); assertThat(mpls.getLabel(), is(LOCAL_LEAF1_SID6)); assertTrue(mpls.getPayload() instanceof IPv6); IPv6 ip = (IPv6) mpls.getPayload(); assertThat(ip.getSourceAddress(), is(DST_IPV6_SAME.toOctets())); assertThat(ip.getDestinationAddress(), is(SRC_IPV61.toOctets())); assertTrue(ip.getPayload() instanceof ICMP6); ICMP6 icmp = (ICMP6) ip.getPayload(); assertThat(icmp.getIcmpType(), is(ECHO_REPLY)); // Verify behavior verify(segmentRoutingManager.deviceService); }
Example 9
Source File: IcmpHandlerTest.java From onos with Apache License 2.0 | 5 votes |
@Test public void testPing4LoopbackPairDifferentLeaf() { // Expected behavior expect(segmentRoutingManager.deviceService.isAvailable(LOCAL_LEAF1)) .andReturn(true) .times(1); expect(segmentRoutingManager.deviceService.isAvailable(LOCAL_LEAF2)) .andReturn(true) .times(1); replay(segmentRoutingManager.deviceService); // Process icmpHandler.processIcmp(ETH_REQ_IPV4_LOOPBACK_PAIR, CP2021); // Verify packet-out Ethernet ethernet = packetService.getEthernetPacket(ETH_REQ_IPV4_LOOPBACK_PAIR.getSourceMAC()); assertNotNull(ethernet); assertThat(ethernet.getSourceMAC(), is(ETH_REQ_IPV4_LOOPBACK_PAIR.getDestinationMAC())); assertThat(ethernet.getDestinationMAC(), is(ETH_REQ_IPV4_LOOPBACK_PAIR.getSourceMAC())); assertTrue(ethernet.getPayload() instanceof IPv4); IPv4 ip = (IPv4) ethernet.getPayload(); assertThat(ip.getSourceAddress(), is(DST_IPV4_LOOPBACK_PAIR.toInt())); assertThat(ip.getDestinationAddress(), is(SRC_IPV41.toInt())); assertTrue(ip.getPayload() instanceof ICMP); ICMP icmp = (ICMP) ip.getPayload(); assertThat(icmp.getIcmpType(), is(TYPE_ECHO_REPLY)); assertThat(icmp.getIcmpCode(), is(CODE_ECHO_REPLY)); // Verify behavior verify(segmentRoutingManager.deviceService); }
Example 10
Source File: DhcpManager.java From onos with Apache License 2.0 | 5 votes |
@Override public void process(PacketContext context) { Ethernet packet = context.inPacket().parsed(); if (packet == null) { return; } if (packet.getEtherType() == Ethernet.TYPE_IPV4) { IPv4 ipv4Packet = (IPv4) packet.getPayload(); if (ipv4Packet.getProtocol() == IPv4.PROTOCOL_UDP) { UDP udpPacket = (UDP) ipv4Packet.getPayload(); if (udpPacket.getDestinationPort() == UDP.DHCP_SERVER_PORT && udpPacket.getSourcePort() == UDP.DHCP_CLIENT_PORT) { // This is meant for the dhcp server so process the packet here. DHCP dhcpPayload = (DHCP) udpPacket.getPayload(); processDhcpPacket(context, dhcpPayload); } } } else if (packet.getEtherType() == Ethernet.TYPE_ARP) { ARP arpPacket = (ARP) packet.getPayload(); if ((arpPacket.getOpCode() == ARP.OP_REQUEST) && Objects.equals(myIP, Ip4Address.valueOf(arpPacket.getTargetProtocolAddress()))) { processArpPacket(context, packet); } } }
Example 11
Source File: IcmpHandler.java From onos with Apache License 2.0 | 5 votes |
private void sendIcmpResponse(Ethernet icmpRequest, ConnectPoint outport) { Ethernet icmpReplyEth = new Ethernet(); IPv4 icmpRequestIpv4 = (IPv4) icmpRequest.getPayload(); IPv4 icmpReplyIpv4 = new IPv4(); int destAddress = icmpRequestIpv4.getDestinationAddress(); icmpReplyIpv4.setDestinationAddress(icmpRequestIpv4.getSourceAddress()); icmpReplyIpv4.setSourceAddress(destAddress); icmpReplyIpv4.setTtl((byte) 64); icmpReplyIpv4.setChecksum((short) 0); ICMP icmpReply = new ICMP(); icmpReply.setPayload(((ICMP) icmpRequestIpv4.getPayload()).getPayload()); icmpReply.setIcmpType(ICMP.TYPE_ECHO_REPLY); icmpReply.setIcmpCode(ICMP.CODE_ECHO_REPLY); icmpReply.setChecksum((short) 0); icmpReplyIpv4.setPayload(icmpReply); icmpReplyEth.setPayload(icmpReplyIpv4); icmpReplyEth.setEtherType(Ethernet.TYPE_IPV4); icmpReplyEth.setDestinationMACAddress(icmpRequest.getSourceMACAddress()); icmpReplyEth.setSourceMACAddress(icmpRequest.getDestinationMACAddress()); icmpReplyEth.setVlanID(icmpRequest.getVlanID()); sendPacketOut(outport, icmpReplyEth); }
Example 12
Source File: IcmpHandlerTest.java From onos with Apache License 2.0 | 5 votes |
@Test public void testPing4GatewayPair() { // Expected behavior expect(segmentRoutingManager.deviceService.isAvailable(LOCAL_LEAF1)) .andReturn(true) .times(1); expect(segmentRoutingManager.deviceService.isAvailable(LOCAL_LEAF2)) .andReturn(true) .times(1); replay(segmentRoutingManager.deviceService); // Process icmpHandler.processIcmp(ETH_REQ_IPV4_GATEWAY_PAIR, CP2011); // Verify packet-out Ethernet ethernet = packetService.getEthernetPacket(ETH_REQ_IPV4_GATEWAY_PAIR.getSourceMAC()); assertNotNull(ethernet); assertThat(ethernet.getSourceMAC(), is(ETH_REQ_IPV4_GATEWAY_PAIR.getDestinationMAC())); assertThat(ethernet.getDestinationMAC(), is(ETH_REQ_IPV4_GATEWAY_PAIR.getSourceMAC())); assertTrue(ethernet.getPayload() instanceof IPv4); IPv4 ip = (IPv4) ethernet.getPayload(); assertThat(ip.getSourceAddress(), is(DST_IPV4_GATEWAY_PAIR.toInt())); assertThat(ip.getDestinationAddress(), is(SRC_IPV41.toInt())); assertTrue(ip.getPayload() instanceof ICMP); ICMP icmp = (ICMP) ip.getPayload(); assertThat(icmp.getIcmpType(), is(TYPE_ECHO_REPLY)); assertThat(icmp.getIcmpCode(), is(CODE_ECHO_REPLY)); // Verify behavior verify(segmentRoutingManager.deviceService); }
Example 13
Source File: RouterAdvertisementManager.java From onos with Apache License 2.0 | 5 votes |
@Override public void run() { // TODO : Validate Router Solicitation // Pause already running unsolicited RA threads in received connect point ConnectPoint connectPoint = packet.receivedFrom(); List<InterfaceIpAddress> addresses = deactivateRouterAdvertisement(connectPoint); /* Multicast RA(ie. Unsolicited RA) TX time is not preciously tracked so to make sure that * Unicast RA(ie. Router Solicitation Response) is TXed before Mulicast RA * logic adapted here is disable Mulicast RA, TX Unicast RA and then restore Multicast RA. */ log.trace("Processing Router Solicitations from {}", connectPoint); try { Ethernet ethernet = packet.parsed(); IPv6 ipv6 = (IPv6) ethernet.getPayload(); RAWorkerThread worker = new RAWorkerThread(connectPoint, addresses, raThreadDelay, ethernet.getSourceMAC(), ipv6.getSourceAddress()); // TODO : Estimate TX time as in RFC 4861, Section 6.2.6 and schedule TX based on it CompletableFuture<Void> sraHandlerFuture = CompletableFuture.runAsync(worker, executors); sraHandlerFuture.get(); } catch (Exception e) { log.error("Failed to respond to router solicitation. {}", e); } finally { activateRouterAdvertisement(connectPoint, addresses); log.trace("Restored Unsolicited Router Advertisements on {}", connectPoint); } }
Example 14
Source File: IcmpHandlerTest.java From onos with Apache License 2.0 | 5 votes |
@Test public void testPing6LoopbackPair() { // Expected behavior expect(segmentRoutingManager.deviceService.isAvailable(LOCAL_LEAF1)) .andReturn(true) .times(1); expect(segmentRoutingManager.deviceService.isAvailable(LOCAL_LEAF2)) .andReturn(true) .times(1); replay(segmentRoutingManager.deviceService); // Process icmpHandler.processIcmpv6(ETH_REQ_IPV6_LOOPBACK_PAIR, CP2021); // Verify packet-out Ethernet ethernet = packetService.getEthernetPacket(ETH_REQ_IPV6_LOOPBACK_PAIR.getSourceMAC()); assertNotNull(ethernet); assertThat(ethernet.getSourceMAC(), is(ETH_REQ_IPV6_LOOPBACK_PAIR.getDestinationMAC())); assertThat(ethernet.getDestinationMAC(), is(ETH_REQ_IPV6_LOOPBACK_PAIR.getSourceMAC())); assertTrue(ethernet.getPayload() instanceof IPv6); IPv6 ip = (IPv6) ethernet.getPayload(); assertThat(ip.getSourceAddress(), is(DST_IPV6_LOOPBACK_PAIR.toOctets())); assertThat(ip.getDestinationAddress(), is(SRC_IPV61.toOctets())); assertTrue(ip.getPayload() instanceof ICMP6); ICMP6 icmp = (ICMP6) ip.getPayload(); assertThat(icmp.getIcmpType(), is(ECHO_REPLY)); // Verify behavior verify(segmentRoutingManager.deviceService); }
Example 15
Source File: NeighborSolicitationTest.java From onos with Apache License 2.0 | 5 votes |
/** * Tests DAD neighbor solicitation. * Source IP should be all-zero. */ @Test public void testBuildNdpSolicitDad() throws Exception { Ethernet ethPacket = NeighborSolicitation.buildNdpSolicit(TARGET_IP, Ip6Address.ZERO, DST_IP, SRC_MAC, DST_MAC, VLAN_ID); IPv6 ipPacket = (IPv6) ethPacket.getPayload(); ICMP6 icmp6Packet = (ICMP6) ipPacket.getPayload(); NeighborSolicitation nsPacket = (NeighborSolicitation) icmp6Packet.getPayload(); assertEquals("DAD NS should have no option", 0, nsPacket.getOptions().size()); }
Example 16
Source File: PimPacketHandler.java From onos with Apache License 2.0 | 5 votes |
/** * Sanitize and process the packet. * TODO: replace ConnectPoint with PIMInterface when PIMInterface has been added. * * @param ethPkt the packet starting with the Ethernet header. * @param pimi the PIM Interface the packet arrived on. */ public void processPacket(Ethernet ethPkt, PimInterface pimi) { checkNotNull(ethPkt); checkNotNull(pimi); // Sanitize the ethernet header to ensure it is IPv4. IPv6 we'll deal with later if (ethPkt.getEtherType() != Ethernet.TYPE_IPV4) { return; } // Get the IP header IPv4 ip = (IPv4) ethPkt.getPayload(); if (ip.getProtocol() != IPv4.PROTOCOL_PIM) { return; } // Get the address of our the neighbor that sent this packet to us. IpAddress nbraddr = IpAddress.valueOf(ip.getDestinationAddress()); if (log.isTraceEnabled()) { log.trace("Packet {} received on port {}", nbraddr, pimi); } // Get the PIM header PIM pim = (PIM) ip.getPayload(); checkNotNull(pim); // Process the pim packet switch (pim.getPimMsgType()) { case PIM.TYPE_HELLO: pimi.processHello(ethPkt); break; case PIM.TYPE_JOIN_PRUNE_REQUEST: pimi.processJoinPrune(ethPkt); log.debug("Received a PIM Join/Prune message"); break; default: log.debug("Received unsupported PIM type: {}", pim.getPimMsgType()); break; } }
Example 17
Source File: IcmpHandlerTest.java From onos with Apache License 2.0 | 5 votes |
@Test public void testPing4LoopbackPair() { // Expected behavior expect(segmentRoutingManager.deviceService.isAvailable(LOCAL_LEAF1)) .andReturn(true) .times(1); expect(segmentRoutingManager.deviceService.isAvailable(LOCAL_LEAF2)) .andReturn(true) .times(1); replay(segmentRoutingManager.deviceService); // Process icmpHandler.processIcmp(ETH_REQ_IPV4_LOOPBACK_PAIR, CP2011); // Verify packet-out Ethernet ethernet = packetService.getEthernetPacket(ETH_REQ_IPV4_LOOPBACK_PAIR.getSourceMAC()); assertNotNull(ethernet); assertThat(ethernet.getSourceMAC(), is(ETH_REQ_IPV4_LOOPBACK_PAIR.getDestinationMAC())); assertThat(ethernet.getDestinationMAC(), is(ETH_REQ_IPV4_LOOPBACK_PAIR.getSourceMAC())); assertTrue(ethernet.getPayload() instanceof IPv4); IPv4 ip = (IPv4) ethernet.getPayload(); assertThat(ip.getSourceAddress(), is(DST_IPV4_LOOPBACK_PAIR.toInt())); assertThat(ip.getDestinationAddress(), is(SRC_IPV41.toInt())); assertTrue(ip.getPayload() instanceof ICMP); ICMP icmp = (ICMP) ip.getPayload(); assertThat(icmp.getIcmpType(), is(TYPE_ECHO_REPLY)); assertThat(icmp.getIcmpCode(), is(CODE_ECHO_REPLY)); // Verify behavior verify(segmentRoutingManager.deviceService); }
Example 18
Source File: OpenstackRoutingSnatHandler.java From onos with Apache License 2.0 | 4 votes |
private void processSnatPacket(PacketContext context, Ethernet eth) { if (getStatefulSnatFlag()) { return; } IPv4 iPacket = (IPv4) eth.getPayload(); InboundPacket packetIn = context.inPacket(); int patPort = getPortNum(); InstancePort srcInstPort = instancePortService.instancePort(eth.getSourceMAC()); if (srcInstPort == null) { log.error(ERR_PACKET_IN + "source host(MAC:{}) does not exist", eth.getSourceMAC()); return; } IpAddress srcIp = IpAddress.valueOf(iPacket.getSourceAddress()); Subnet srcSubnet = getSourceSubnet(srcInstPort, srcIp); Router osRouter = getRouterFromSubnet(srcSubnet, osRouterService); if (osRouter == null || osRouter.getExternalGatewayInfo() == null) { // this router does not have external connectivity log.warn("No router is associated with the given subnet {}", srcSubnet); return; } IpAddress externalGatewayIp = externalGatewayIpSnatEnabled(osRouter, osNetworkAdminService); if (externalGatewayIp == null) { return; } ExternalPeerRouter externalPeerRouter = externalPeerRouterFromSubnet( srcSubnet, osRouterService, osNetworkService); if (externalPeerRouter == null) { return; } populateSnatFlowRules(context.inPacket(), srcInstPort, TpPort.tpPort(patPort), externalGatewayIp, externalPeerRouter); packetOut(eth.duplicate(), packetIn.receivedFrom().deviceId(), patPort, externalGatewayIp, externalPeerRouter); }
Example 19
Source File: VirtualPublicHosts.java From onos with Apache License 2.0 | 4 votes |
@Override public void process(PacketContext context) { InboundPacket pkt = context.inPacket(); Ethernet ethPkt = pkt.parsed(); // Only handle the ARP packets if (ethPkt == null || ethPkt.getEtherType() != Ethernet.TYPE_ARP) { return; } ARP arpPacket = (ARP) ethPkt.getPayload(); // Only handle ARP request packets if (arpPacket.getOpCode() != ARP.OP_REQUEST) { return; } Ip4Address targetIpAddress = Ip4Address .valueOf(arpPacket.getTargetProtocolAddress()); // Only handle an ARP request when the target IP address inside is // an assigned public IP address if (!vbngConfigService.isAssignedPublicIpAddress(targetIpAddress)) { return; } MacAddress virtualHostMac = vbngConfigService.getPublicFacingMac(); if (virtualHostMac == null) { return; } ConnectPoint srcConnectPoint = pkt.receivedFrom(); Ethernet eth = ARP.buildArpReply(targetIpAddress, virtualHostMac, ethPkt); TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder(); builder.setOutput(srcConnectPoint.port()); packetService.emit(new DefaultOutboundPacket( srcConnectPoint.deviceId(), builder.build(), ByteBuffer.wrap(eth.serialize()))); }
Example 20
Source File: MaoRoutingManager.java From ONOS_LoadBalance_Routing_Forward with Apache License 2.0 | 4 votes |
@Override public void process(PacketContext context) { if (context.isHandled()) { return; } Ethernet pkt = context.inPacket().parsed(); if (pkt.getEtherType() == Ethernet.TYPE_IPV4) { HostId srcHostId = HostId.hostId(pkt.getSourceMAC()); HostId dstHostId = HostId.hostId(pkt.getDestinationMAC()); Set<Path> paths = getLoadBalancePaths(srcHostId, dstHostId); if (paths.isEmpty()) { log.warn("paths is Empty !!! no Path is available"); context.block(); return; } IPv4 ipPkt = (IPv4) pkt.getPayload(); TrafficSelector selector = DefaultTrafficSelector.builder() .matchEthType(Ethernet.TYPE_IPV4) .matchIPSrc(IpPrefix.valueOf(ipPkt.getSourceAddress(), 32)) .matchIPDst(IpPrefix.valueOf(ipPkt.getDestinationAddress(), 32)) .build(); boolean isContain; // synchronized (intentMap) { isContain = intentMap.containsKey(selector.criteria()); // } if (isContain) { context.block(); return; } Path result = paths.iterator().next(); log.info("\n------ Mao Path Info ------\nSrc:{}, Dst:{}\n{}", IpPrefix.valueOf(ipPkt.getSourceAddress(), 32).toString(), IpPrefix.valueOf(ipPkt.getDestinationAddress(), 32), result.links().toString().replace("Default", "\n")); PathIntent pathIntent = PathIntent.builder() .path(result) .appId(appId) .priority(65432) .selector(selector) .treatment(DefaultTrafficTreatment.emptyTreatment()) .build(); intentService.submit(pathIntent); // synchronized (intentMap) { intentMap.put(selector.criteria(), pathIntent); // } context.block(); } }