Search in sources :

Example 91 with Actions

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);
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) 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) PacketMetadataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.ipv6.nd.util.rev170210.PacketMetadataBuilder) ArrayList(java.util.ArrayList) Metadata(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix) 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) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) 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) Uint64(org.opendaylight.yangtools.yang.common.Uint64) Test(org.junit.Test)

Example 92 with Actions

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;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) ArrayList(java.util.ArrayList) RouterAdvertisementPacketBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.ipv6.nd.packet.rev160620.RouterAdvertisementPacketBuilder) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo)

Example 93 with Actions

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);
}
Also used : NxmNxReg4(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg4) ActionPuntToController(org.opendaylight.genius.mdsalutil.actions.ActionPuntToController) ArrayList(java.util.ArrayList) ActionRegLoad(org.opendaylight.genius.mdsalutil.actions.ActionRegLoad) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) NxMatchRegister(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchRegister) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Example 94 with Actions

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();
}
Also used : InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder) ArrayList(java.util.ArrayList) InstructionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder) ActionResponseConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData) ArrayList(java.util.ArrayList) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) List(java.util.List) ApplyActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder)

Example 95 with Actions

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();
}
Also used : AsPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPathBuilder) SegmentsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.as.path.SegmentsBuilder) ArrayList(java.util.ArrayList) Segments(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.as.path.Segments) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)

Aggregations

ArrayList (java.util.ArrayList)139 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)86 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)45 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)42 Test (org.junit.Test)40 PushVlanActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder)33 GroupActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder)32 PopMplsActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder)32 PopPbbActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder)32 PopVlanActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder)32 PushMplsActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder)32 PushPbbActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder)32 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)29 ByteBuf (io.netty.buffer.ByteBuf)28 ExecutionException (java.util.concurrent.ExecutionException)28 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)27 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)26 OutputActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder)24 SetMplsTtlActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder)22 SetNwTtlActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder)22