Search in sources :

Example 1 with Hop

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop in project netvirt by opendaylight.

the class NatTunnelInterfaceStateListener method hndlTepAddOnNaptSwitch.

private boolean hndlTepAddOnNaptSwitch(BigInteger srcDpnId, String tunnelType, String srcTepIp, String destTepIp, String tunnelName, long routerId, Optional<Routers> routerData, String nextHopIp, Uuid vpnName, ProviderTypes extNwProvType, WriteTransaction writeFlowInvTx) {
    if (!routerData.isPresent()) {
        LOG.warn("hndlTepAddOnNaptSwitch: routerData is not present");
        return false;
    }
    Routers router = routerData.get();
    String routerName = router.getRouterName();
    LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Processing TEP add for the DPN {} having the router {} since " + "its THE NAPT switch for the TUNNEL TYPE {} b/w SRC IP {} and DST IP {} " + "and TUNNEL NAME {} ", srcDpnId, routerName, tunnelType, srcTepIp, destTepIp, tunnelName);
    Uuid networkId = router.getNetworkId();
    if (networkId == null) {
        LOG.warn("hndlTepAddOnNaptSwitch : SNAT -> Ignoring TEP add since the router {} is not associated to the " + "external network", routerName);
        return false;
    }
    LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Router {} is associated with Ext nw {}", routerId, networkId);
    Long vpnId;
    if (vpnName == null) {
        LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Internal VPN associated to router {}", routerId);
        vpnId = NatUtil.getNetworkVpnIdFromRouterId(dataBroker, routerId);
        if (vpnId == NatConstants.INVALID_ID) {
            LOG.error("hndlTepAddOnNaptSwitch : Invalid External VPN-ID returned for routerName {}", routerName);
            return false;
        }
        LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Retrieved External VPN-ID {} for router {}", vpnId, routerId);
    } else {
        LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Private BGP VPN associated to router {}", routerId);
        vpnId = NatUtil.getVpnId(dataBroker, vpnName.getValue());
        if (vpnId == null || vpnId == NatConstants.INVALID_ID) {
            LOG.error("hndlTepAddOnNaptSwitch : Invalid vpnId returned for routerName {}", routerName);
            return false;
        }
        LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Retrieved vpnId {} for router {}", vpnId, routerId);
    }
    /*1) Withdraw the old route to the external IP from the BGP which was having the
             next hop as the old TEP IP.
          2) Advertise to the BGP about the new route to the external IP having the
          new TEP IP as the next hop.
          3) Populate a new FIB entry with the next hop IP as the new TEP IP using the
          FIB manager.
        */
    // Withdraw the old route to the external IP from the BGP which was having the
    // next hop as the old TEP IP.
    final String externalVpnName = NatUtil.getAssociatedVPN(dataBroker, networkId);
    if (externalVpnName == null) {
        LOG.error("hndlTepAddOnNaptSwitch :  SNAT -> No VPN associated with ext nw {} in router {}", networkId, routerId);
        return false;
    }
    Collection<String> externalIps = NatUtil.getExternalIpsForRouter(dataBroker, routerId);
    LOG.debug("hndlTepAddOnNaptSwitch : Clearing the FIB entries but not the BGP routes");
    for (String externalIp : externalIps) {
        String rd = NatUtil.getVpnRd(dataBroker, externalVpnName);
        LOG.debug("hndlTepAddOnNaptSwitch : Removing Fib entry rd {} prefix {}", rd, externalIp);
        fibManager.removeFibEntry(rd, externalIp, null);
    }
    /*
        Advertise to the BGP about the new route to the external IP having the
        new TEP IP as the next hop.
        Populate a new FIB entry with the next hop IP as the new TEP IP using the
        FIB manager.
        */
    String rd = NatUtil.getVpnRd(dataBroker, externalVpnName);
    if (extNwProvType == null) {
        return false;
    }
    String gwMacAddress = null;
    long l3Vni = 0;
    if (extNwProvType == ProviderTypes.VXLAN) {
        // Get the External Gateway MAC Address which is Router gateway MAC address for SNAT
        gwMacAddress = NatUtil.getExtGwMacAddFromRouterName(dataBroker, routerName);
        if (gwMacAddress != null) {
            LOG.debug("hndlTepAddOnNaptSwitch : External Gateway MAC address {} found for External Router ID {}", gwMacAddress, routerId);
        } else {
            LOG.error("hndlTepAddOnNaptSwitch : No External Gateway MAC address found for External Router ID {}", routerId);
            return false;
        }
        // get l3Vni value for external VPN
        l3Vni = NatEvpnUtil.getL3Vni(dataBroker, rd);
        if (l3Vni == NatConstants.DEFAULT_L3VNI_VALUE) {
            LOG.debug("hndlTepAddOnNaptSwitch : L3VNI value is not configured in Internet VPN {} and RD {} " + "Carve-out L3VNI value from OpenDaylight VXLAN VNI Pool and continue to installing " + "NAT flows", vpnName, rd);
            l3Vni = NatOverVxlanUtil.getInternetVpnVni(idManager, externalVpnName, routerId).longValue();
        }
    }
    for (final String externalIp : externalIps) {
        long serviceId = 0;
        String fibExternalIp = NatUtil.validateAndAddNetworkMask(externalIp);
        if (extNwProvType == ProviderTypes.VXLAN) {
            LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Advertise the route to the externalIp {} " + "having nextHopIp {}", externalIp, nextHopIp);
            NatEvpnUtil.addRoutesForVxLanProvType(dataBroker, bgpManager, fibManager, externalVpnName, rd, externalIp, nextHopIp, l3Vni, tunnelName, gwMacAddress, writeFlowInvTx, RouteOrigin.STATIC, srcDpnId);
            serviceId = l3Vni;
        } else {
            Long label = externalRouterListner.checkExternalIpLabel(routerId, externalIp);
            if (label == null || label == NatConstants.INVALID_ID) {
                LOG.error("hndlTepAddOnNaptSwitch : SNAT->Unable to advertise to the DC GW " + "since label is invalid");
                return false;
            }
            LOG.debug("hndlTepAddOnNaptSwitch : SNAT -> Advertise the route to the externalIp {} " + "having nextHopIp {}", externalIp, nextHopIp);
            long l3vni = 0;
            if (NatUtil.isOpenStackVniSemanticsEnforcedForGreAndVxlan(elanManager, extNwProvType)) {
                l3vni = NatOverVxlanUtil.getInternetVpnVni(idManager, externalVpnName, l3vni).longValue();
            }
            Uuid externalSubnetId = NatUtil.getExternalSubnetForRouterExternalIp(externalIp, router);
            NatUtil.addPrefixToBGP(dataBroker, bgpManager, fibManager, externalVpnName, rd, externalSubnetId, fibExternalIp, nextHopIp, networkId.getValue(), null, /* mac-address */
            label, l3vni, RouteOrigin.STATIC, srcDpnId);
            serviceId = label;
        }
        LOG.debug("hndlTepAddOnNaptSwitch: SNAT -> Install custom FIB routes " + "(Table 21 -> Push MPLS label to Tunnel port");
        List<Instruction> customInstructions = new ArrayList<>();
        int customInstructionIndex = 0;
        long externalSubnetVpnId = NatUtil.getExternalSubnetVpnIdForRouterExternalIp(dataBroker, externalIp, router);
        if (externalSubnetVpnId != NatConstants.INVALID_ID) {
            LOG.debug("hndlTepAddOnNaptSwitch : Will install custom FIB router with external subnet VPN ID {}", externalSubnetVpnId);
            BigInteger subnetIdMetaData = MetaDataUtil.getVpnIdMetadata(externalSubnetVpnId);
            customInstructions.add(new InstructionWriteMetadata(subnetIdMetaData, MetaDataUtil.METADATA_MASK_VRFID).buildInstruction(customInstructionIndex));
            customInstructionIndex++;
        }
        customInstructions.add(new InstructionGotoTable(NwConstants.INBOUND_NAPT_TABLE).buildInstruction(customInstructionIndex));
        CreateFibEntryInput input = new CreateFibEntryInputBuilder().setVpnName(externalVpnName).setSourceDpid(srcDpnId).setInstruction(customInstructions).setIpAddress(fibExternalIp).setServiceId(serviceId).setInstruction(customInstructions).build();
        Future<RpcResult<Void>> future = fibRpcService.createFibEntry(input);
        ListenableFuture<RpcResult<Void>> listenableFuture = JdkFutureAdapters.listenInPoolThread(future);
        Futures.addCallback(listenableFuture, new FutureCallback<RpcResult<Void>>() {

            @Override
            public void onFailure(@Nonnull Throwable error) {
                LOG.error("hndlTepAddOnNaptSwitch : SNAT->Error in generate label or fib install process", error);
            }

            @Override
            public void onSuccess(@Nonnull RpcResult<Void> result) {
                if (result.isSuccessful()) {
                    LOG.info("hndlTepAddOnNaptSwitch : SNAT -> Successfully installed custom FIB routes " + "for prefix {}", externalIp);
                } else {
                    LOG.error("hndlTepAddOnNaptSwitch : SNAT -> Error in rpc call to create custom Fib entries " + "for prefix {} in DPN {}, {}", externalIp, srcDpnId, result.getErrors());
                }
            }
        }, MoreExecutors.directExecutor());
    }
    return true;
}
Also used : InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers) CreateFibEntryInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fib.rpc.rev160121.CreateFibEntryInputBuilder) ArrayList(java.util.ArrayList) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) CreateFibEntryInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fib.rpc.rev160121.CreateFibEntryInput) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) BigInteger(java.math.BigInteger) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)

Example 2 with Hop

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop in project netvirt by opendaylight.

the class Ipv6PktHandlerTest method testonPacketReceivedNeighborSolicitationWithInvalidPayload.

@Test
public void testonPacketReceivedNeighborSolicitationWithInvalidPayload() throws Exception {
    // incorrect checksum
    pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
    "33 33 FF F5 00 00", // Source MAC
    "00 01 02 03 04 05", // IPv6
    "86 DD", // Version 6, traffic class E0, no flowlabel
    "6E 00 00 00", // Payload length
    "00 18", // Next header is ICMPv6
    "3A", // Hop limit
    "FF", // Source IP
    "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", // Destination IP
    "FF 02 00 00 00 00 00 00 00 00 00 01 FF F5 00 00", // ICMPv6 neighbor solicitation
    "87", // Code
    "00", // Checksum (invalid, should be 67 3C)
    "67 3E", // ICMPv6 message body
    "00 00 00 00", // Target
    "FE 80 00 00 00 00 00 00 C0 00 54 FF FE F5 00 00")).build());
    // wait on this thread until the async job is completed in the packet handler.
    waitForPacketProcessing();
    verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
    // unavailable ip
    when(ifMgrInstance.obtainV6Interface(any())).thenReturn(null);
    counter = pktHandler.getPacketProcessedCounter();
    pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
    "33 33 FF F5 00 00", // Source MAC
    "00 01 02 03 04 05", // IPv6
    "86 DD", // Version 6, traffic class E0, no flowlabel
    "6E 00 00 00", // Payload length
    "00 18", // Next header is ICMPv6
    "3A", // Hop limit
    "FF", // Source IP
    "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", // Destination IP
    "FF 02 00 00 00 00 00 00 00 00 00 01 FF F5 00 00", // ICMPv6 neighbor solicitation
    "87", // Code
    "00", // Checksum (valid)
    "67 3C", // ICMPv6 message body
    "00 00 00 00", // Target
    "FE 80 00 00 00 00 00 00 C0 00 54 FF FE F5 00 00")).build());
    // wait on this thread until the async job is completed in the packet handler.
    waitForPacketProcessing();
    verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
}
Also used : TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder) Test(org.junit.Test)

Example 3 with Hop

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop in project netvirt by opendaylight.

the class Ipv6PktHandlerTest method testonPacketReceivedRouterSolicitationWithMultipleSubnets.

@Test
public void testonPacketReceivedRouterSolicitationWithMultipleSubnets() throws Exception {
    VirtualPort intf = Mockito.mock(VirtualPort.class);
    when(intf.getMacAddress()).thenReturn("50:7B:9D:78:54:F3");
    when(ifMgrInstance.obtainV6Interface(any())).thenReturn(intf);
    when(ifMgrInstance.getInterfaceNameFromTag(anyLong())).thenReturn("ddec9dba-d831-4ad7-84b9-00d7f65f052f");
    when(ifMgrInstance.getRouterV6InterfaceForNetwork(any())).thenReturn(intf);
    IpAddress gwIpAddress = Mockito.mock(IpAddress.class);
    when(gwIpAddress.getIpv4Address()).thenReturn(null);
    when(gwIpAddress.getIpv6Address()).thenReturn(new Ipv6Address("2001:db8:1111::1"));
    VirtualSubnet v6Subnet1 = VirtualSubnet.builder().gatewayIp(gwIpAddress).subnetCidr(new IpPrefix("2001:db8:1111::/64".toCharArray())).ipv6AddressMode(Ipv6Constants.IPV6_SLAAC).ipv6RAMode(Ipv6Constants.IPV6_SLAAC).build();
    VirtualRouter virtualRouter = VirtualRouter.builder().build();
    v6Subnet1.setRouter(virtualRouter);
    VirtualSubnet v6Subnet2 = VirtualSubnet.builder().gatewayIp(gwIpAddress).subnetCidr(new IpPrefix("2001:db8:2222::/64".toCharArray())).ipv6AddressMode(Ipv6Constants.IPV6_DHCPV6_STATELESS).ipv6RAMode(Ipv6Constants.IPV6_DHCPV6_STATELESS).build();
    v6Subnet2.setRouter(virtualRouter);
    VirtualSubnet v6Subnet3 = VirtualSubnet.builder().gatewayIp(gwIpAddress).subnetCidr(new IpPrefix("2001:db8:3333::/64".toCharArray())).ipv6AddressMode(Ipv6Constants.IPV6_DHCPV6_STATEFUL).ipv6RAMode(Ipv6Constants.IPV6_DHCPV6_STATEFUL).build();
    v6Subnet3.setRouter(virtualRouter);
    List<VirtualSubnet> subnetList = new ArrayList<>();
    subnetList.add(v6Subnet1);
    subnetList.add(v6Subnet2);
    subnetList.add(v6Subnet3);
    when(intf.getSubnets()).thenReturn(subnetList);
    InstanceIdentifier<Node> ncId = InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:1"))).build();
    NodeConnectorRef ncRef = new NodeConnectorRef(ncId);
    BigInteger mdata = new BigInteger(String.valueOf(0x1000000));
    Metadata metadata = new MetadataBuilder().setMetadata(mdata).build();
    MatchBuilder matchbuilder = new MatchBuilder().setMetadata(metadata);
    pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
    "33 33 00 00 00 02", // Source MAC
    "FA 16 3E 69 2C F3", // IPv6
    "86 DD", // Version 6, traffic class E0, no flowlabel
    "60 00 00 00", // Payload length
    "00 10", // Next header is ICMPv6
    "3A", // Hop limit
    "FF", // Source IP
    "FE 80 00 00 00 00 00 00 F8 16 3E FF FE 69 2C F3", // Destination IP
    "FF 02 00 00 00 00 00 00 00 00 00 00 00 00 00 02", // ICMPv6 router solicitation
    "85", // Code
    "00", // Checksum (valid)
    "B4 47", // ICMPv6 message body
    "00 00 00 00", // ICMPv6 Option: Source Link Layer Address
    "01", // Length
    "01", // Link Layer Address
    "FA 16 3E 69 2C F3")).setIngress(ncRef).setMatch(matchbuilder.build()).build());
    // wait on this thread until the async job is completed in the packet handler.
    waitForPacketProcessing();
    verify(pktProcessService, times(1)).transmitPacket(any(TransmitPacketInput.class));
    byte[] expectedPayload = ipv6TestUtils.buildPacket(// Destination MAC
    "FA 16 3E 69 2C F3", // Source MAC
    "50 7B 9D 78 54 F3", // IPv6
    "86 DD", // Version 6, traffic class E0, no flowlabel
    "60 00 00 00", // Payload length
    "00 78", // Next header is ICMPv6
    "3A", // Hop limit
    "FF", // Source IP
    "FE 80 00 00 00 00 00 00 52 7B 9D FF FE 78 54 F3", // Destination IP
    "FE 80 00 00 00 00 00 00 F8 16 3E FF FE 69 2C F3", // ICMPv6 router advertisement.
    "86", // Code
    "00", // Checksum (valid)
    "59 41", // Current Hop Limit
    "40", // ICMPv6 RA Flags
    "C0", // Router Lifetime
    "11 94", // Reachable time
    "00 01 D4 C0", // Retransmission time.
    "00 00 00 00", // Type: Source Link-Layer Option
    "01", // Option length
    "01", // Source Link layer address
    "50 7B 9D 78 54 F3", // Type: Prefix Information
    "03", // Option length
    "04", // Prefix length
    "40", // Prefix flags
    "C0", // Valid lifetime
    "00 27 8D 00", // Preferred lifetime
    "00 09 3A 80", // Reserved
    "00 00 00 00", // Prefix
    "20 01 0D B8 11 11 00 00 00 00 00 00 00 00 00 00", // Type: Prefix Information
    "03", // Option length
    "04", // Prefix length
    "40", // Prefix flags
    "C0", // Valid lifetime
    "00 27 8D 00", // Preferred lifetime
    "00 09 3A 80", // Reserved
    "00 00 00 00", // Prefix
    "20 01 0D B8 22 22 00 00 00 00 00 00 00 00 00 00", // Type: Prefix Information
    "03", // Option length
    "04", // Prefix length
    "40", // Prefix flags
    "80", // Valid lifetime
    "00 27 8D 00", // Preferred lifetime
    "00 09 3A 80", // Reserved
    "00 00 00 00", // Prefix
    "20 01 0D B8 33 33 00 00 00 00 00 00 00 00 00 00");
    verify(pktProcessService).transmitPacket(new TransmitPacketInputBuilder().setPayload(expectedPayload).setNode(new NodeRef(ncId)).setEgress(ncRef).build());
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) MetadataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder) TransmitPacketInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) ArrayList(java.util.ArrayList) Metadata(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Test(org.junit.Test)

Example 4 with Hop

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop in project netvirt by opendaylight.

the class Ipv6PktHandlerTest method testonPacketReceivedRouterSolicitationWithInvalidPayload.

@Test
public void testonPacketReceivedRouterSolicitationWithInvalidPayload() throws Exception {
    // incorrect checksum in Router Solicitation
    pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
    "33 33 FF F5 00 00", // Source MAC
    "00 01 02 03 04 05", // IPv6
    "86 DD", // Version 6, traffic class E0, no flowlabel
    "6E 00 00 00", // Payload length
    "00 18", // Next header is ICMPv6
    "3A", // Hop limit
    "FF", // Source IP
    "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", // Destination IP
    "FF 02 00 00 00 00 00 00 00 00 00 01 FF F5 00 00", // ICMPv6 router solicitation
    "85", // Code
    "00", // Checksum (invalid, should be 67 3C)
    "69 3E", // ICMPv6 message body
    "00 00 00 00", // Target
    "FE 80 00 00 00 00 00 00 C0 00 54 FF FE F5 00 00")).build());
    // wait on this thread until the async job is completed in the packet handler.
    waitForPacketProcessing();
    verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
    // Request from an unknown port (i.e., unknown MAC Address)
    when(ifMgrInstance.obtainV6Interface(any())).thenReturn(null);
    counter = pktHandler.getPacketProcessedCounter();
    pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
    "33 33 FF F5 00 00", // Source MAC
    "00 01 02 03 04 05", // IPv6
    "86 DD", // Version 6, traffic class E0, no flowlabel
    "6E 00 00 00", // Payload length
    "00 18", // Next header is ICMPv6
    "3A", // Hop limit
    "FF", // Source IP
    "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", // Destination IP
    "FF 02 00 00 00 00 00 00 00 00 00 01 FF F5 00 00", // ICMPv6 router solicitation
    "85", // Code
    "00", // Checksum (valid)
    "69 3C", // ICMPv6 message body
    "00 00 00 00", // Target
    "FE 80 00 00 00 00 00 00 C0 00 54 FF FE F5 00 00")).build());
    // wait on this thread until the async job is completed in the packet handler.
    waitForPacketProcessing();
    verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
}
Also used : TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder) Test(org.junit.Test)

Example 5 with Hop

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop in project netvirt by opendaylight.

the class Ipv6PktHandlerTest method testOnPacketReceivedWithInvalidParams.

@Test
public void testOnPacketReceivedWithInvalidParams() throws Exception {
    // invalid ethtype
    pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
    "33 33 FF F5 00 00", // Source MAC
    "00 01 02 03 04 05", // Invalid (fake IPv6)
    "80 00", // Version 6, traffic class E0, no flowlabel
    "6E 00 00 00", // Payload length
    "00 18", // Next header is authentication
    "3A", // Hop limit
    "FF", // Source IP
    "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", // Destination IP
    "FF 02 00 00 00 00 00 00 00 00 00 01 FF F5 00 00")).build());
    verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
    // invalid ipv6 header
    pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
    "33 33 FF F5 00 00", // Source MAC
    "00 01 02 03 04 05", // IPv6
    "86 DD", // Version 6, traffic class E0, no flowlabel
    "6E 00 00 00", // Payload length
    "00 18", // Next header is authentication
    "33", // Hop limit
    "FF", // Source IP
    "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", // Destination IP
    "FF 02 00 00 00 00 00 00 00 00 00 01 FF F5 00 00")).build());
    verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
    // invalid icmpv6 header
    pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
    "33 33 FF F5 00 00", // Source MAC
    "00 01 02 03 04 05", // IPv6
    "86 DD", // Version 6, traffic class E0, no flowlabel
    "6E 00 00 00", // Payload length
    "00 18", // Next header is ICMPv6
    "3A", // Hop limit
    "FF", // Source IP
    "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", // Destination IP
    "FF 02 00 00 00 00 00 00 00 00 00 01 FF F5 00 00", // ICMPv6 router solicitation
    "85", // Code
    "00", // Checksum (valid)
    "67 3C", // ICMPv6 message body
    "00 00 00 00", // Target
    "FE 80 00 00 00 00 00 00 C0 00 54 FF FE F5 00 00")).build());
    verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
}
Also used : TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)25 ArrayList (java.util.ArrayList)17 Hop (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop)12 ByteBuf (io.netty.buffer.ByteBuf)10 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)10 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)9 UpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.UpdateBuilder)8 Ipv4NextHopCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCase)8 Ipv4NextHopCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCaseBuilder)8 Ipv4NextHopBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder)8 BigInteger (java.math.BigInteger)7 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)7 ExplicitLocatorPath (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPath)7 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)7 TransmitPacketInput (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput)7 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update)7 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)7 AsPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPathBuilder)7 OriginBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.OriginBuilder)7 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)6