use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.
the class Ipv6ServiceUtils method installIcmpv6NaResponderFlow.
public void installIcmpv6NaResponderFlow(short tableId, Uint64 dpId, Long elanTag, int lportTag, IVirtualPort intf, Ipv6Address ndTargetAddr, String rtrIntMacAddress, int addOrRemove, TypedReadWriteTransaction tx, Boolean isTllOptionSet) throws ExecutionException, InterruptedException {
List<MatchInfo> neighborAdvertisementMatch = getIcmpv6NaResponderMatch(elanTag, lportTag, intf.getMacAddress(), ndTargetAddr, isTllOptionSet);
short priority = isTllOptionSet ? Ipv6ServiceConstants.SLLOPTION_SET_FLOW_PRIORITY : Ipv6ServiceConstants.DEFAULT_FLOW_PRIORITY;
if (addOrRemove == Ipv6ServiceConstants.DEL_FLOW) {
FlowEntity rsFlowEntity = MDSALUtil.buildFlowEntity(dpId, tableId, Boolean.TRUE.equals(isTllOptionSet) ? getIPv6OvsFlowRef(tableId, dpId, lportTag, ndTargetAddr.getValue(), intf.getMacAddress()) : getIPv6OvsFlowRef(tableId, dpId, lportTag, ndTargetAddr.getValue()), priority, "IPv6NA", 0, 0, NwConstants.COOKIE_IPV6_TABLE, neighborAdvertisementMatch, null);
LOG.debug("installIcmpv6NaResponderFlow: Removing IPv6 Neighbor Advertisement Flow on " + "DpId {} for the NDTraget {}, elanTag {}, lportTag {}", dpId, ndTargetAddr.getValue(), elanTag, lportTag);
// mdsalUtil.removeFlowToTx(rsFlowEntity, tx);
mdsalUtil.removeFlow(tx, rsFlowEntity);
} else {
List<ActionInfo> actionsInfos = new ArrayList<>();
// Move Eth Src to Eth Dst
actionsInfos.add(new ActionMoveSourceDestinationEth());
actionsInfos.add(new ActionSetFieldEthernetSource(new MacAddress(rtrIntMacAddress)));
// Move Ipv6 Src to Ipv6 Dst
actionsInfos.add(new ActionMoveSourceDestinationIpv6());
actionsInfos.add(new ActionSetSourceIpv6(ndTargetAddr.getValue()));
actionsInfos.add(new ActionSetIpv6NdTarget(ndTargetAddr));
if (Boolean.TRUE.equals(isTllOptionSet)) {
actionsInfos.add(new ActionSetIpv6NdTll(new MacAddress(rtrIntMacAddress)));
actionsInfos.add(new ActionNdReserved(Long.parseLong("3758096384")));
} else {
actionsInfos.add(new ActionNdReserved(Long.parseLong("3221225472")));
}
actionsInfos.add(new ActionNxLoadInPort(Uint64.ZERO));
actionsInfos.add(new ActionNxResubmit(NwConstants.LPORT_DISPATCHER_TABLE));
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionApplyActions(actionsInfos));
FlowEntity rsFlowEntity = MDSALUtil.buildFlowEntity(dpId, tableId, Boolean.TRUE.equals(isTllOptionSet) ? getIPv6OvsFlowRef(tableId, dpId, lportTag, ndTargetAddr.getValue(), intf.getMacAddress()) : getIPv6OvsFlowRef(tableId, dpId, lportTag, ndTargetAddr.getValue()), priority, "IPv6NA", 0, 0, NwConstants.COOKIE_IPV6_TABLE, neighborAdvertisementMatch, instructions);
LOG.debug("installIcmpv6NaResponderFlow: Installing IPv6 Neighbor Advertisement Flow on " + "DpId {} for the NDTraget {}, elanTag {}, lportTag {}", dpId, ndTargetAddr.getValue(), elanTag, lportTag);
mdsalUtil.addFlow(tx, rsFlowEntity);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.
the class Ipv6ServiceUtils method installIcmpv6RsPuntFlow.
public void installIcmpv6RsPuntFlow(short tableId, Uint64 dpId, Long elanTag, int addOrRemove) {
if (dpId == null || dpId.equals(Ipv6ServiceConstants.INVALID_DPID)) {
return;
}
String flowId = getIPv6FlowRef(dpId, elanTag, "IPv6RS");
if (addOrRemove == Ipv6ServiceConstants.DEL_FLOW) {
LOG.trace("Removing IPv6 Router Solicitation Flow DpId {}, elanTag {}", dpId, elanTag);
LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(Datastore.CONFIGURATION, tx -> {
mdsalUtil.removeFlow(tx, dpId, flowId, tableId);
}), LOG, "Error while removing flow={}", flowId);
} else {
List<ActionInfo> actionsInfos = new ArrayList<>();
// Punt to controller
actionsInfos.add(new ActionPuntToController());
int rdPuntTimeout = ipv6serviceConfig.getRouterDiscoveryPuntTimeout().toJava();
if (isRdPuntProtectionEnabled(rdPuntTimeout)) {
actionsInfos.add(getLearnActionForRsPuntProtection(rdPuntTimeout));
}
List<InstructionInfo> instructions = Arrays.asList(new InstructionApplyActions(actionsInfos));
List<MatchInfo> routerSolicitationMatch = getIcmpv6RSMatch(elanTag);
FlowEntity rsFlowEntity = MDSALUtil.buildFlowEntity(dpId, tableId, flowId, Ipv6ServiceConstants.DEFAULT_FLOW_PRIORITY, "IPv6RS", 0, 0, NwConstants.COOKIE_IPV6_TABLE, routerSolicitationMatch, instructions);
LOG.trace("Installing IPv6 Router Solicitation Flow DpId {}, elanTag {}", dpId, elanTag);
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, tx -> {
mdsalUtil.addFlow(tx, rsFlowEntity);
}), LOG, "Error while adding flow={}", rsFlowEntity);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.
the class Ipv6ServiceUtils method installIcmpv6NaForwardFlow.
public void installIcmpv6NaForwardFlow(short tableId, IVirtualPort vmPort, Uint64 dpId, Long elanTag, int addOrRemove) {
List<MatchInfo> matches = getIcmpv6NAMatch(elanTag);
List<InstructionInfo> instructions = new ArrayList<>();
List<ActionInfo> actionsInfos = new ArrayList<>();
actionsInfos.add(new ActionNxResubmit(NwConstants.LPORT_DISPATCHER_TABLE));
instructions.add(new InstructionApplyActions(actionsInfos));
for (Ipv6Address ipv6Address : vmPort.getIpv6Addresses()) {
matches.add(new MatchIpv6Source(ipv6Address.getValue() + NwConstants.IPV6PREFIX));
String flowId = getIPv6FlowRef(dpId, elanTag, vmPort.getIntfUUID().getValue() + Ipv6ServiceConstants.FLOWID_SEPARATOR + ipv6Address.getValue());
FlowEntity rsFlowEntity = MDSALUtil.buildFlowEntity(dpId, tableId, flowId, Ipv6ServiceConstants.DEFAULT_FLOW_PRIORITY, "IPv6NA", 0, 0, NwConstants.COOKIE_IPV6_TABLE, matches, instructions);
if (addOrRemove == Ipv6ServiceConstants.DEL_FLOW) {
LOG.trace("Removing IPv6 Neighbor Advertisement Flow DpId {}, elanTag {}, ipv6Address {}", dpId, elanTag, ipv6Address.getValue());
mdsalUtil.removeFlow(rsFlowEntity);
} else {
LOG.trace("Installing IPv6 Neighbor Advertisement Flow DpId {}, elanTag {}, ipv6Address {}", dpId, elanTag, ipv6Address.getValue());
mdsalUtil.installFlow(rsFlowEntity);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.
the class Ipv6PktHandlerTest method testonPacketReceivedRouterSolicitationWithInvalidPayload.
@Test
public void testonPacketReceivedRouterSolicitationWithInvalidPayload() throws Exception {
// incorrect checksum in Router Solicitation
Uint64 mdata = Uint64.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 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")).setMatch(matchbuilder.build()).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.getInterfaceNameFromTag(anyLong())).thenReturn("ddec9dba-d831-4ad7-84b9-00d7f65f052f");
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")).setMatch(matchbuilder.build()).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.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 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));
}
Aggregations