use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Actions in project netvirt by opendaylight.
the class Ipv6PktHandlerTest method testonPacketReceivedRouterSolicitationWithMultipleSubnets.
@Test
public void testonPacketReceivedRouterSolicitationWithMultipleSubnets() throws Exception {
VirtualPort intf = Mockito.mock(VirtualPort.class);
when(intf.getDpId()).thenReturn(Uint64.valueOf(1));
when(intf.getMacAddress()).thenReturn("50:7B:9D:78:54:F3");
when(intf.getIntfUUID()).thenReturn(Uuid.getDefaultInstance("ddec9dba-d831-4ad7-84b9-00d7f65f052f"));
when(ifMgrInstance.obtainV6Interface(any())).thenReturn(intf);
when(ifMgrInstance.getInterfaceNameFromTag(anyLong())).thenReturn("ddec9dba-d831-4ad7-84b9-00d7f65f052f");
when(ifMgrInstance.getRouterV6InterfaceForNetwork(any())).thenReturn(intf);
List<Action> actions = new ArrayList<>();
actions.add(new ActionNxResubmit(NwConstants.EGRESS_LPORT_DISPATCHER_TABLE).buildAction());
when(ifMgrInstance.getEgressAction(any())).thenReturn(actions);
when(pktProcessService.transmitPacket(any())).thenReturn(Mockito.mock(ListenableFuture.class));
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(new Ipv6Prefix("2001:db8:1111::/64"))).ipv6AddressMode(Ipv6ServiceConstants.IPV6_SLAAC).ipv6RAMode(Ipv6ServiceConstants.IPV6_SLAAC).build();
VirtualRouter virtualRouter = VirtualRouter.builder().build();
v6Subnet1.setRouter(virtualRouter);
VirtualSubnet v6Subnet2 = VirtualSubnet.builder().gatewayIp(gwIpAddress).subnetCidr(new IpPrefix(new Ipv6Prefix("2001:db8:2222::/64"))).ipv6AddressMode(Ipv6ServiceConstants.IPV6_DHCPV6_STATELESS).ipv6RAMode(Ipv6ServiceConstants.IPV6_DHCPV6_STATELESS).build();
v6Subnet2.setRouter(virtualRouter);
VirtualSubnet v6Subnet3 = VirtualSubnet.builder().gatewayIp(gwIpAddress).subnetCidr(new IpPrefix(new Ipv6Prefix("2001:db8:3333::/64"))).ipv6AddressMode(Ipv6ServiceConstants.IPV6_DHCPV6_STATEFUL).ipv6RAMode(Ipv6ServiceConstants.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);
Uint64 dpnId = Uint64.valueOf("1");
NodeConnectorRef ncRef = MDSALUtil.getDefaultNodeConnRef(dpnId);
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 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");
TransmitPacketInput transmitPacketInput = MDSALUtil.getPacketOut(actions, expectedPayload, dpnId);
verify(pktProcessService).transmitPacket(transmitPacketInput);
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Actions in project netvirt by opendaylight.
the class Ipv6RouterAdvt method transmitRtrAdvertisement.
public boolean transmitRtrAdvertisement(Ipv6RouterAdvertisementType raType, VirtualPort routerPort, long elanTag, @Nullable RouterSolicitationPacket rsPdu, Uint64 dpnId, Uuid port, long ipv6RouterReachableTime) {
RouterAdvertisementPacketBuilder raPacket = new RouterAdvertisementPacketBuilder();
updateRAResponse(raType, rsPdu, raPacket, routerPort, ipv6RouterReachableTime);
// Serialize the response packet
byte[] txPayload = fillRouterAdvertisementPacket(raPacket.build());
TransmitPacketInput input = null;
/* Send solicited router advertisement to requested VM port only.
* Send periodic unsolicited router advertisement to ELAN broadcast group.
*/
if (raType == Ipv6RouterAdvertisementType.SOLICITED_ADVERTISEMENT) {
List<Action> actions = ifMgr.getEgressAction(port.getValue());
if (actions == null || actions.isEmpty()) {
LOG.error("Unable to send solicited router advertisement packet out. Since Egress " + "action is empty for interface {}. ", port.getValue());
return false;
}
input = MDSALUtil.getPacketOut(actions, txPayload, dpnId);
LOG.debug("Transmitting the Router Advt packet out to port {}", port.getValue());
} else {
/* Here we handle UNSOLICITED_ADVERTISEMENT, CEASE_ADVERTISEMENT */
long elanGroupId = Ipv6ServiceUtils.getRemoteBCGroup(elanTag);
List<ActionInfo> lstActionInfo = new ArrayList<>();
lstActionInfo.add(new ActionGroup(elanGroupId));
input = MDSALUtil.getPacketOutDefault(lstActionInfo, txPayload, dpnId);
LOG.debug("Transmitting the Router Advt packet out to ELAN Group ID {}", elanGroupId);
}
LoggingFutures.addErrorLogging(packetService.transmitPacket(input), LOG, "transmitPacket");
return true;
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Actions in project netvirt by opendaylight.
the class ElanNodeListener method addGarpLearnMatchFlow.
private void addGarpLearnMatchFlow(Uint64 dpId, TypedReadWriteTransaction<Configuration> tx) {
List<ActionInfo> actions = new ArrayList<>();
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(MatchEthernetType.ARP);
matches.add(new NxMatchRegister(NxmNxReg4.class, GARP_LEARN_MATCH_VALUE, ARP_LEARN_MATCH_MASK));
actions.add(new ActionRegLoad(NxmNxReg4.class, 0, 31, 0));
actions.add(new ActionPuntToController());
actions.add(new ActionNxResubmit(NwConstants.ELAN_SMAC_LEARNED_TABLE));
actions.add(new ActionNxResubmit(NwConstants.ELAN_SMAC_TABLE));
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionApplyActions(actions));
String flowid = String.valueOf(NwConstants.ELAN_BASE_TABLE) + NwConstants.FLOWID_SEPARATOR + "garp.match";
FlowEntity garpFlow = MDSALUtil.buildFlowEntity(dpId, NwConstants.ELAN_BASE_TABLE, flowid, NwConstants.DEFAULT_ARP_FLOW_PRIORITY, "GARP learn match flow", 0, 0, ElanConstants.COOKIE_ELAN_BASE_SMAC, matches, instructions);
mdsalManager.addFlow(tx, garpFlow);
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Actions in project openflowplugin by opendaylight.
the class FlowStatsResponseConvertor method wrapOF10ActionsToInstruction.
/**
* Method wraps openflow 1.0 actions list to Apply Action Instructions.
*
* @param actionsList list of action
* @param ipProtocol ip protocol
* @return OF10 actions as an instructions
*/
private Instructions wrapOF10ActionsToInstruction(List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> actionsList, final short version, final Short ipProtocol) {
ActionResponseConvertorData actionResponseConvertorData = new ActionResponseConvertorData(version);
actionResponseConvertorData.setActionPath(ActionPath.FLOWS_STATISTICS_UPDATE_WRITE_ACTIONS);
actionResponseConvertorData.setIpProtocol(ipProtocol);
ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
final Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>> actions = getConvertorExecutor().convert(actionsList, actionResponseConvertorData);
applyActionsBuilder.setAction(FlowConvertorUtil.wrapActionList(actions.orElse(Collections.emptyList())));
applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
InstructionBuilder instBuilder = new InstructionBuilder();
instBuilder.setInstruction(applyActionsCaseBuilder.build());
instBuilder.setKey(new InstructionKey(0));
instBuilder.setOrder(0);
List<Instruction> salInstructionList = new ArrayList<>();
salInstructionList.add(instBuilder.build());
InstructionsBuilder instructionsBuilder = new InstructionsBuilder();
instructionsBuilder.setInstruction(salInstructionList);
return instructionsBuilder.build();
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Actions in project bgpcep by opendaylight.
the class AsPathPrepend method applyExportAction.
@Override
public Attributes applyExportAction(final RouteEntryBaseAttributes routeEntryInfo, final BGPRouteEntryExportParameters exportParameters, final Attributes attributes, final SetAsPathPrepend actions) {
final List<Segments> oldSegments = attributes.getAsPath().getSegments();
/*
* We need to check the first segment.
* If it has as-set then new as-sequence with local AS is prepended.
* If it has as-sequence, we may add local AS when it has less than 255 elements.
* Otherwise we need to create new as-sequence for local AS.
*/
final ArrayList<AsNumber> newAsSequence = new ArrayList<>();
newAsSequence.add(new AsNumber(routeEntryInfo.getLocalAs()));
List<Segments> newSegments = new ArrayList<>();
if (oldSegments == null || oldSegments.isEmpty()) {
newSegments = Collections.singletonList(new SegmentsBuilder().setAsSequence(newAsSequence).build());
} else {
final Segments firstSegment = oldSegments.remove(0);
final List<AsNumber> firstAsSequence = firstSegment.getAsSequence();
if (firstAsSequence != null && firstAsSequence.size() < Values.UNSIGNED_BYTE_MAX_VALUE) {
newAsSequence.addAll(firstAsSequence);
newSegments.add(new SegmentsBuilder().setAsSequence(newAsSequence).build());
} else {
newSegments.add(new SegmentsBuilder().setAsSequence(newAsSequence).build());
newSegments.add(firstSegment);
}
newSegments.addAll(oldSegments);
}
return new AttributesBuilder(attributes).setAsPath(new AsPathBuilder().setSegments(newSegments).build()).build();
}
Aggregations