use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message 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));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message 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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message 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));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message 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));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message in project netvirt by opendaylight.
the class NexthopManager method createLocalNextHop.
public long createLocalNextHop(long vpnId, BigInteger dpnId, String ifName, String ipNextHopAddress, String ipPrefixAddress, String gwMacAddress, String jobKey) {
String vpnName = fibUtil.getVpnNameFromId(vpnId);
if (vpnName == null) {
return 0;
}
String macAddress = fibUtil.getMacAddressFromPrefix(ifName, vpnName, ipPrefixAddress);
String ipAddress = macAddress != null ? ipPrefixAddress : ipNextHopAddress;
long groupId = createNextHopPointer(getNextHopKey(vpnId, ipAddress));
if (groupId == 0) {
LOG.error("Unable to allocate groupId for vpnId {} , prefix {} IntfName {}, nextHopAddr {}", vpnId, ipAddress, ifName, ipNextHopAddress);
return groupId;
}
String nextHopLockStr = vpnId + ipAddress;
jobCoordinator.enqueueJob(jobKey, () -> {
synchronized (nextHopLockStr.intern()) {
VpnNexthop nexthop = getVpnNexthop(vpnId, ipAddress);
LOG.trace("nexthop: {} retrieved for vpnId {}, prefix {}, ifName {} on dpn {}", nexthop, vpnId, ipAddress, ifName, dpnId);
if (nexthop == null) {
String encMacAddress = macAddress == null ? fibUtil.getMacAddressFromPrefix(ifName, vpnName, ipAddress) : macAddress;
List<BucketInfo> listBucketInfo = new ArrayList<>();
List<ActionInfo> listActionInfo = new ArrayList<>();
int actionKey = 0;
// MAC re-write
if (encMacAddress != null) {
if (gwMacAddress != null) {
LOG.trace("The Local NextHop Group Source Mac {} for VpnInterface {} on VPN {}", gwMacAddress, ifName, vpnId);
listActionInfo.add(new ActionSetFieldEthernetSource(actionKey++, new MacAddress(gwMacAddress)));
}
listActionInfo.add(new ActionSetFieldEthernetDestination(actionKey++, new MacAddress(encMacAddress)));
// listActionInfo.add(0, new ActionPopMpls());
} else {
// FIXME: Log message here.
LOG.debug("mac address for new local nexthop is null");
}
listActionInfo.addAll(getEgressActionsForInterface(ifName, actionKey));
BucketInfo bucket = new BucketInfo(listActionInfo);
listBucketInfo.add(bucket);
GroupEntity groupEntity = MDSALUtil.buildGroupEntity(dpnId, groupId, ipAddress, GroupTypes.GroupAll, listBucketInfo);
LOG.trace("Install LNH Group: id {}, mac address {}, interface {} for prefix {}", groupId, encMacAddress, ifName, ipAddress);
// Try to install group directly on the DPN bypassing the FRM, in order to avoid waiting for the
// group to get installed before programming the flows
installGroupOnDpn(groupId, dpnId, ipAddress, listBucketInfo, getNextHopKey(vpnId, ipAddress), GroupTypes.GroupAll);
// install Group
mdsalApiManager.syncInstallGroup(groupEntity);
// update MD-SAL DS
addVpnNexthopToDS(dpnId, vpnId, ipAddress, groupId);
} else {
// nexthop exists already; a new flow is going to point to
// it, increment the flowrefCount by 1
int flowrefCnt = nexthop.getFlowrefCount() + 1;
VpnNexthop nh = new VpnNexthopBuilder().setKey(new VpnNexthopKey(ipAddress)).setFlowrefCount(flowrefCnt).build();
LOG.trace("Updating vpnnextHop {} for refCount {} to Operational DS", nh, flowrefCnt);
MDSALUtil.syncUpdate(dataBroker, LogicalDatastoreType.OPERATIONAL, getVpnNextHopIdentifier(vpnId, ipAddress), nh);
}
}
return Collections.emptyList();
});
return groupId;
}
Aggregations