Search in sources :

Example 81 with Uint64

use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.

the class NatTunnelInterfaceStateListener method hndlTepEvntsForDpn.

private void hndlTepEvntsForDpn(StateTunnelList stateTunnelList, TunnelAction tunnelAction) {
    LOG.trace("hndlTepEvntsForDpn : stateTunnelList {}", stateTunnelList);
    final Uint64 srcDpnId = stateTunnelList.getSrcInfo() != null ? Uint64.valueOf(stateTunnelList.getSrcInfo().getTepDeviceId()) : Uint64.ZERO;
    final String srcTepIp = stateTunnelList.getSrcInfo() != null ? stateTunnelList.getSrcInfo().getTepIp().stringValue() : null;
    final String destTepIp = stateTunnelList.getDstInfo() != null ? stateTunnelList.getDstInfo().getTepIp().stringValue() : null;
    LOG.trace("hndlTepEvntsForDpn : Handle tunnel event for srcDpn {} SrcTepIp {} DestTepIp {} ", srcDpnId, srcTepIp, destTepIp);
    if (srcDpnId == Uint64.ZERO || srcTepIp == null || destTepIp == null) {
        LOG.error("hndlTepEvntsForDpn invalid srcDpnId {}, srcTepIp {}, destTepIp {}", srcDpnId, srcTepIp, destTepIp);
        return;
    }
    int tunTypeVal = getTunnelType(stateTunnelList);
    LOG.trace("hndlTepEvntsForDpn : tunTypeVal is {}", tunTypeVal);
    String srcTepId = stateTunnelList.getSrcInfo().getTepDeviceId() != null ? stateTunnelList.getSrcInfo().getTepDeviceId() : "0";
    String tunnelType = stateTunnelList.getTransportType() != null ? stateTunnelList.getTransportType().toString() : null;
    String tunnelName = stateTunnelList.getTunnelInterfaceName();
    if (tunTypeVal == NatConstants.ITMTunnelLocType.Invalid.getValue() || srcDpnId.equals(Uint64.ZERO) || srcTepIp == null || destTepIp == null) {
        LOG.warn("hndlTepEvntsForDpn : Ignoring TEP event {} for the DPN {} " + "since its a INVALID TUNNEL TYPE {} b/w SRC IP {} and DST IP {} and " + "TUNNEL NAME {} ", tunnelAction, srcTepId, tunnelType, srcTepIp, destTepIp, tunnelName);
        return;
    }
    switch(tunnelAction) {
        case TUNNEL_EP_ADD:
            try {
                txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
                    if (isTunnelInLogicalGroup(stateTunnelList) || !hndlTepAddForAllRtrs(srcDpnId, tunnelType, tunnelName, srcTepIp, destTepIp, tx)) {
                        LOG.debug("hndlTepEvntsForDpn : Unable to process TEP ADD");
                    }
                }).get();
            } catch (InterruptedException | ExecutionException e) {
                LOG.error("Error processing tunnel endpoint addition", e);
            }
            break;
        case TUNNEL_EP_DELETE:
            // Moved the current implementation logic to NatTepChangeListener.remove()
            break;
        case TUNNEL_EP_UPDATE:
            break;
        default:
            LOG.warn("hndlTepEvntsForDpn: unknown tunnelAction: {}", tunnelAction);
            break;
    }
}
Also used : CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) IFibManager(org.opendaylight.netvirt.fibmanager.api.IFibManager) NatserviceConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.config.rev170206.NatserviceConfig) InternalToExternalPortMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap) FibRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fib.rpc.rev160121.FibRpcService) LoggerFactory(org.slf4j.LoggerFactory) TepTypeInternal(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TepTypeInternal) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ProviderTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) RouterPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts) PreDestroy(javax.annotation.PreDestroy) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) Map(java.util.Map) IBgpManager(org.opendaylight.netvirt.bgpmanager.api.IBgpManager) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers) CreateFibEntryOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fib.rpc.rev160121.CreateFibEntryOutput) DpnRoutersList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.dpn.routers.DpnRoutersList) Collection(java.util.Collection) Configuration(org.opendaylight.mdsal.binding.util.Datastore.Configuration) TunnelsState(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelsState) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) List(java.util.List) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) TypedWriteTransaction(org.opendaylight.mdsal.binding.util.TypedWriteTransaction) Optional(java.util.Optional) CreateFibEntryInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fib.rpc.rev160121.CreateFibEntryInput) TypedReadWriteTransaction(org.opendaylight.mdsal.binding.util.TypedReadWriteTransaction) NonNull(org.eclipse.jdt.annotation.NonNull) SnatServiceManager(org.opendaylight.netvirt.natservice.api.SnatServiceManager) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) Uint64(org.opendaylight.yangtools.yang.common.Uint64) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) OdlInterfaceRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService) CreateFibEntryInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fib.rpc.rev160121.CreateFibEntryInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) IElanService(org.opendaylight.netvirt.elanmanager.api.IElanService) Singleton(javax.inject.Singleton) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) Strings(com.google.common.base.Strings) FibEntryInputs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fib.rpc.rev160121.FibEntryInputs) RoutersList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.dpn.routers.dpn.routers.list.RoutersList) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) NatMode(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.config.rev170206.NatserviceConfig.NatMode) TepTypeHwvtep(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TepTypeHwvtep) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Logger(org.slf4j.Logger) TepTypeExternal(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TepTypeExternal) RouteOrigin(org.opendaylight.netvirt.fibmanager.api.RouteOrigin) AbstractAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener) IdManagerService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService) FutureCallback(com.google.common.util.concurrent.FutureCallback) ExecutionException(java.util.concurrent.ExecutionException) Futures(com.google.common.util.concurrent.Futures) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) RoutersListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.dpn.routers.dpn.routers.list.RoutersListKey) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) MetaDataUtil(org.opendaylight.genius.mdsalutil.MetaDataUtil) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) ExecutionException(java.util.concurrent.ExecutionException) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 82 with Uint64

use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.

the class NatVpnMapsChangeListener method handleDNATConfigurationForRouterAssociation.

void handleDNATConfigurationForRouterAssociation(String routerName, String vpnName, String externalNetwork) throws ExecutionException, InterruptedException {
    InstanceIdentifier<RouterPorts> routerPortsId = NatUtil.getRouterPortsId(routerName);
    Optional<RouterPorts> optRouterPorts = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsId);
    if (!optRouterPorts.isPresent()) {
        LOG.debug("handleDNATConfigurationForRouterAssociation : Could not read Router Ports data " + "object with id: {} to handle associate vpn {}", routerName, vpnName);
        return;
    }
    Uuid networkId = Uuid.getDefaultInstance(externalNetwork);
    for (Ports port : optRouterPorts.get().nonnullPorts().values()) {
        String portName = port.getPortName();
        Uint64 dpnId = NatUtil.getDpnForInterface(interfaceManager, portName);
        if (dpnId.equals(Uint64.ZERO)) {
            LOG.warn("handleDNATConfigurationForRouterAssociation : DPN not found for {}, " + "skip handling of router {} association with vpn {}", portName, routerName, vpnName);
            continue;
        }
        for (InternalToExternalPortMap intExtPortMap : port.nonnullInternalToExternalPortMap().values()) {
            // remove all NAT related entries with routerName
            // floatingIpListener.removeNATOnlyFlowEntries(dpnId, portName, routerName, null,
            // intExtPortMap.getInternalIp(), externalIp);
            // Create NAT entries with VPN Id
            LOG.debug("handleDNATConfigurationForRouterAssociation : Updating DNAT flows with VPN metadata {} ", vpnName);
            floatingIpListener.createNATOnlyFlowEntries(dpnId, routerName, vpnName, networkId, intExtPortMap);
        }
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RouterPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts) RouterPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports) InternalToExternalPortMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 83 with Uint64

use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.

the class NaptFlowRemovedEventHandler method onFlowRemoved.

@Override
public void onFlowRemoved(FlowRemoved flowRemoved) {
    /*
        If the removed flow is from the OUTBOUND NAPT table :
        1) Get the ActionInfo of the flow.
        2) From the ActionInfo of the flow get the internal IP address, port and the protocol.
        3) Get the Metadata matching info of the flow.
        4) From the Metadata matching info of the flow get router ID.
        5) Querry the container intext-ip-port-map using the router ID
           and the internal IP address, port to get the external IP address, port
        6) Instantiate an NaptEntry event and populate the external IP address, port and the router ID.
        7) Place the NaptEntry event to the queue.
*/
    short tableId = flowRemoved.getTableId().toJava();
    RemovedFlowReason removedReasonFlag = flowRemoved.getReason();
    if (tableId == NwConstants.OUTBOUND_NAPT_TABLE && RemovedFlowReason.OFPRRIDLETIMEOUT.equals(removedReasonFlag)) {
        LOG.info("onFlowRemoved : triggered for table-{} entry", tableId);
        // Get the internal internal IP address and the port number from the IPv4 match.
        Ipv4Prefix internalIpv4Address = null;
        Layer3Match layer3Match = flowRemoved.getMatch().getLayer3Match();
        if (layer3Match instanceof Ipv4Match) {
            Ipv4Match internalIpv4Match = (Ipv4Match) layer3Match;
            internalIpv4Address = internalIpv4Match.getIpv4Source();
        }
        if (internalIpv4Address == null) {
            LOG.error("onFlowRemoved : Matching internal IP is null while retrieving the " + "value from the Outbound NAPT flow");
            return;
        }
        // Get the internal IP as a string
        String internalIpv4AddressAsString = internalIpv4Address.getValue();
        String[] internalIpv4AddressParts = internalIpv4AddressAsString.split("/");
        String internalIpv4HostAddress = null;
        if (internalIpv4AddressParts.length >= 1) {
            internalIpv4HostAddress = internalIpv4AddressParts[0];
        }
        // Get the protocol from the layer4 match
        NAPTEntryEvent.Protocol protocol = null;
        Integer internalPortNumber = null;
        Layer4Match layer4Match = flowRemoved.getMatch().getLayer4Match();
        if (layer4Match instanceof TcpMatch) {
            TcpMatchFields tcpMatchFields = (TcpMatchFields) layer4Match;
            internalPortNumber = tcpMatchFields.getTcpSourcePort().getValue().toJava();
            protocol = NAPTEntryEvent.Protocol.TCP;
        } else if (layer4Match instanceof UdpMatch) {
            UdpMatchFields udpMatchFields = (UdpMatchFields) layer4Match;
            internalPortNumber = udpMatchFields.getUdpSourcePort().getValue().toJava();
            protocol = NAPTEntryEvent.Protocol.UDP;
        }
        if (protocol == null) {
            LOG.error("onFlowRemoved : Matching protocol is null while retrieving the value " + "from the Outbound NAPT flow");
            return;
        }
        // Get the router ID from the metadata.
        Uint32 routerId;
        Uint64 metadata = flowRemoved.getMatch().getMetadata().getMetadata();
        if (MetaDataUtil.getNatRouterIdFromMetadata(metadata) != 0) {
            routerId = Uint32.valueOf(MetaDataUtil.getNatRouterIdFromMetadata(metadata));
        } else {
            LOG.error("onFlowRemoved : Null exception while retrieving routerId");
            return;
        }
        String flowDpn = NatUtil.getDpnFromNodeRef(flowRemoved.getNode());
        NAPTEntryEvent naptEntryEvent = new NAPTEntryEvent(internalIpv4HostAddress, internalPortNumber, flowDpn, routerId, NAPTEntryEvent.Operation.DELETE, protocol);
        naptEventdispatcher.addFlowRemovedNaptEvent(naptEntryEvent);
    } else {
        LOG.debug("onFlowRemoved : Received flow removed notification due to flowdelete from switch for flowref");
    }
}
Also used : Layer3Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match) UdpMatchFields(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.UdpMatchFields) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) TcpMatchFields(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.TcpMatchFields) RemovedFlowReason(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.RemovedFlowReason) TcpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch) Layer4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer4Match) UdpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 84 with Uint64

use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.

the class NaptPacketInHandler method onPacketReceived.

@Override
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void onPacketReceived(PacketReceived packetReceived) {
    String internalIPAddress = "";
    int portNumber = 0;
    NAPTEntryEvent.Operation operation = NAPTEntryEvent.Operation.ADD;
    NAPTEntryEvent.Protocol protocol;
    Short tableId = packetReceived.getTableId().getValue().toJava();
    LOG.trace("onPacketReceived : packet: {}, tableId {}", packetReceived, tableId);
    if (tableId == NwConstants.OUTBOUND_NAPT_TABLE) {
        LOG.debug("onPacketReceived : NAPTPacketInHandler Packet for Outbound NAPT Table");
        byte[] inPayload = packetReceived.getPayload();
        Ethernet ethPkt = new Ethernet();
        if (inPayload != null) {
            try {
                ethPkt.deserialize(inPayload, 0, inPayload.length * Byte.SIZE);
            } catch (Exception e) {
                LOG.warn("onPacketReceived: Failed to decode Packet", e);
                return;
            }
            if (ethPkt.getPayload() instanceof IPv4) {
                IPv4 ipPkt = (IPv4) ethPkt.getPayload();
                byte[] ipSrc = Ints.toByteArray(ipPkt.getSourceAddress());
                internalIPAddress = NWUtil.toStringIpAddress(ipSrc);
                LOG.trace("onPacketReceived : Retrieved internalIPAddress {}", internalIPAddress);
                if (ipPkt.getPayload() instanceof TCP) {
                    TCP tcpPkt = (TCP) ipPkt.getPayload();
                    portNumber = tcpPkt.getSourcePort();
                    if (portNumber < 0) {
                        portNumber = 32767 + portNumber + 32767 + 2;
                        LOG.trace("onPacketReceived : Retrieved and extracted TCP portNumber {}", portNumber);
                    }
                    protocol = NAPTEntryEvent.Protocol.TCP;
                    LOG.trace("onPacketReceived : Retrieved TCP portNumber {}", portNumber);
                } else if (ipPkt.getPayload() instanceof UDP) {
                    UDP udpPkt = (UDP) ipPkt.getPayload();
                    portNumber = udpPkt.getSourcePort();
                    if (portNumber < 0) {
                        portNumber = 32767 + portNumber + 32767 + 2;
                        LOG.trace("onPacketReceived : Retrieved and extracted UDP portNumber {}", portNumber);
                    }
                    protocol = NAPTEntryEvent.Protocol.UDP;
                    LOG.trace("onPacketReceived : Retrieved UDP portNumber {}", portNumber);
                } else {
                    LOG.error("onPacketReceived : Incoming Packet is neither TCP or UDP packet");
                    return;
                }
            } else {
                LOG.error("onPacketReceived : Incoming Packet is not IPv4 packet");
                return;
            }
            if (internalIPAddress != null) {
                Uint64 metadata = packetReceived.getMatch().getMetadata().getMetadata();
                Uint32 routerId = Uint32.valueOf(MetaDataUtil.getNatRouterIdFromMetadata(metadata));
                if (routerId.longValue() <= 0) {
                    LOG.error("onPacketReceived : Router ID is invalid");
                    return;
                }
                String sourceIPPortKey = routerId + NatConstants.COLON_SEPARATOR + internalIPAddress + NatConstants.COLON_SEPARATOR + portNumber;
                NatPacketProcessingState state = INCOMING_PKT_MAP.get(sourceIPPortKey);
                if (state == null) {
                    state = new NatPacketProcessingState(System.currentTimeMillis());
                    INCOMING_PKT_MAP.put(sourceIPPortKey, state);
                    LOG.trace("onPacketReceived : Processing new SNAT({}) Packet", sourceIPPortKey);
                    // send to Event Queue
                    NAPTEntryEvent naptEntryEvent = new NAPTEntryEvent(internalIPAddress, portNumber, routerId, operation, protocol, packetReceived, false, state);
                    LOG.info("onPacketReceived : First Packet IN Queue Size : {}", ((ThreadPoolExecutor) firstPacketExecutorService).getQueue().size());
                    firstPacketExecutorService.execute(() -> naptEventHandler.handleEvent(naptEntryEvent));
                } else {
                    LOG.trace("onPacketReceived : SNAT({}) Packet already processed.", sourceIPPortKey);
                    NAPTEntryEvent naptEntryEvent = new NAPTEntryEvent(internalIPAddress, portNumber, routerId, operation, protocol, packetReceived, true, state);
                    LOG.debug("onPacketReceived : Retry Packet IN Queue Size : {}", ((ThreadPoolExecutor) retryPacketExecutorService).getQueue().size());
                    long firstPacketInTime = state.getFirstPacketInTime();
                    retryPacketExecutorService.execute(() -> {
                        if (System.currentTimeMillis() - firstPacketInTime > 4000) {
                            LOG.error("onPacketReceived : Flow not installed even after 4sec." + "Dropping SNAT ({}) Packet", sourceIPPortKey);
                            removeIncomingPacketMap(sourceIPPortKey);
                            return;
                        }
                        naptEventHandler.handleEvent(naptEntryEvent);
                    });
                }
            } else {
                LOG.error("onPacketReceived : Retrived internalIPAddress is NULL");
            }
        }
    } else {
        LOG.trace("onPacketReceived : Packet is not from the Outbound NAPT table");
    }
}
Also used : TCP(org.opendaylight.genius.mdsalutil.packet.TCP) UDP(org.opendaylight.genius.mdsalutil.packet.UDP) IPv4(org.opendaylight.genius.mdsalutil.packet.IPv4) Ethernet(org.opendaylight.genius.mdsalutil.packet.Ethernet) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 85 with Uint64

use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.

the class NaptSwitchHA method buildSnatFlowEntity.

public FlowEntity buildSnatFlowEntity(Uint64 dpId, String routerName, long groupId, Uint32 routerVpnId, int addordel) {
    FlowEntity flowEntity;
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerVpnId.longValue()), MetaDataUtil.METADATA_MASK_VRFID));
    String flowRef = getFlowRefSnat(dpId, NwConstants.PSNAT_TABLE, routerName);
    if (addordel == NatConstants.ADD_FLOW) {
        List<ActionInfo> actionsInfo = new ArrayList<>();
        Uint64 tunnelId = NatUtil.getTunnelIdForNonNaptToNaptFlow(dataBroker, natOverVxlanUtil, elanManager, idManager, routerVpnId, routerName);
        actionsInfo.add(new ActionSetFieldTunnelId(tunnelId));
        LOG.debug("buildSnatFlowEntity : Setting the tunnel to the list of action infos {}", actionsInfo);
        actionsInfo.add(new ActionGroup(groupId));
        List<InstructionInfo> instructions = new ArrayList<>();
        instructions.add(new InstructionApplyActions(actionsInfo));
        flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.PSNAT_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
    } else {
        flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.PSNAT_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_SNAT_TABLE, matches, null);
    }
    return flowEntity;
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Aggregations

Uint64 (org.opendaylight.yangtools.yang.common.Uint64)306 ArrayList (java.util.ArrayList)119 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)104 ExecutionException (java.util.concurrent.ExecutionException)86 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)66 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)65 ManagedNewTransactionRunner (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner)64 ManagedNewTransactionRunnerImpl (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl)64 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)64 Logger (org.slf4j.Logger)63 LoggerFactory (org.slf4j.LoggerFactory)63 Inject (javax.inject.Inject)59 Singleton (javax.inject.Singleton)59 List (java.util.List)58 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)58 CONFIGURATION (org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION)54 Optional (java.util.Optional)49 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)48 Collections (java.util.Collections)48 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)48