Search in sources :

Example 16 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project netvirt by opendaylight.

the class ElanItmUtils method getExternalTunnelItmEgressAction.

public List<Action> getExternalTunnelItmEgressAction(BigInteger srcDpnId, String nexthopIP, long vni) {
    List<Action> result = Collections.emptyList();
    GetExternalTunnelInterfaceNameInput input = new GetExternalTunnelInterfaceNameInputBuilder().setDestinationNode(nexthopIP).setSourceNode(srcDpnId.toString()).setTunnelType(TunnelTypeVxlan.class).build();
    Future<RpcResult<GetExternalTunnelInterfaceNameOutput>> output = itmRpcService.getExternalTunnelInterfaceName(input);
    try {
        if (output.get().isSuccessful()) {
            GetExternalTunnelInterfaceNameOutput tunnelInterfaceNameOutput = output.get().getResult();
            String tunnelIfaceName = tunnelInterfaceNameOutput.getInterfaceName();
            LOG.debug("Received tunnelInterfaceName from getTunnelInterfaceName RPC {}", tunnelIfaceName);
            result = buildTunnelItmEgressActions(tunnelIfaceName, vni);
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Error in RPC call getTunnelInterfaceName {}", e);
    }
    return result;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) GetExternalTunnelInterfaceNameInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetExternalTunnelInterfaceNameInput) GetExternalTunnelInterfaceNameOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetExternalTunnelInterfaceNameOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) ExecutionException(java.util.concurrent.ExecutionException) GetExternalTunnelInterfaceNameInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetExternalTunnelInterfaceNameInputBuilder)

Example 17 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project netvirt by opendaylight.

the class ElanItmUtils method getInternalTunnelItmEgressAction.

/**
 * Builds the list of actions to be taken when sending the packet over an internal VxLAN tunnel interface, such
 * as setting the serviceTag/segmentationID on the VNI field of the VxLAN header, setting the vlanId if it proceeds
 * and output the packet over the right port.
 *
 * @param sourceDpnId
 *            Dpn where the tunnelInterface is located
 * @param destinationDpnId
 *            Dpn where the packet must be sent to. It is used here in order
 *            to select the right tunnel interface.
 * @param tunnelKey
 *            Tunnel key to be sent on the VxLAN header.
 * @return the internal itm egress action
 */
public List<Action> getInternalTunnelItmEgressAction(BigInteger sourceDpnId, BigInteger destinationDpnId, long tunnelKey) {
    List<Action> result = Collections.emptyList();
    LOG.trace("In getInternalItmEgressAction Action source {}, destination {}, serviceTag/Vni {}", sourceDpnId, destinationDpnId, tunnelKey);
    Class<? extends TunnelTypeBase> tunType = TunnelTypeVxlan.class;
    GetTunnelInterfaceNameInput input = new GetTunnelInterfaceNameInputBuilder().setDestinationDpid(destinationDpnId).setSourceDpid(sourceDpnId).setTunnelType(tunType).build();
    Future<RpcResult<GetTunnelInterfaceNameOutput>> output = itmRpcService.getTunnelInterfaceName(input);
    try {
        if (output.get().isSuccessful()) {
            GetTunnelInterfaceNameOutput tunnelInterfaceNameOutput = output.get().getResult();
            String tunnelIfaceName = tunnelInterfaceNameOutput.getInterfaceName();
            LOG.info("Received tunnelInterfaceName from getTunnelInterfaceName RPC {}", tunnelIfaceName);
            result = buildTunnelItmEgressActions(tunnelIfaceName, tunnelKey);
        } else {
            LOG.trace("Tunnel interface doesn't exist between srcDpId {} dstDpId {}", sourceDpnId, destinationDpnId);
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Error in RPC call getTunnelInterfaceName {}", e);
    }
    return result;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) GetTunnelInterfaceNameInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetTunnelInterfaceNameOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameOutput) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) GetTunnelInterfaceNameInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameInputBuilder) ExecutionException(java.util.concurrent.ExecutionException)

Example 18 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project netvirt by opendaylight.

the class DhcpPktHandler method onPacketReceived.

// TODO: Handle this in a separate thread
@Override
public void onPacketReceived(PacketReceived packet) {
    if (!config.isControllerDhcpEnabled()) {
        return;
    }
    Class<? extends PacketInReason> pktInReason = packet.getPacketInReason();
    short tableId = packet.getTableId().getValue();
    if ((tableId == NwConstants.DHCP_TABLE || tableId == NwConstants.DHCP_TABLE_EXTERNAL_TUNNEL) && isPktInReasonSendtoCtrl(pktInReason)) {
        byte[] inPayload = packet.getPayload();
        Ethernet ethPkt = new Ethernet();
        try {
            ethPkt.deserialize(inPayload, 0, inPayload.length * NetUtils.NUM_BITS_IN_A_BYTE);
        } catch (PacketException e) {
            LOG.warn("Failed to decode DHCP Packet.", e);
            LOG.trace("Received packet {}", packet);
            return;
        }
        DHCP pktIn;
        pktIn = getDhcpPktIn(ethPkt);
        if (pktIn != null) {
            LOG.trace("DHCPPkt received: {}", pktIn);
            LOG.trace("Received Packet: {}", packet);
            BigInteger metadata = packet.getMatch().getMetadata().getMetadata();
            long portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue();
            String macAddress = DHCPUtils.byteArrayToString(ethPkt.getSourceMACAddress());
            BigInteger tunnelId = packet.getMatch().getTunnel() == null ? null : packet.getMatch().getTunnel().getTunnelId();
            String interfaceName = getInterfaceNameFromTag(portTag);
            InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(interfaceName);
            if (interfaceInfo == null) {
                LOG.error("Failed to get interface info for interface name {}", interfaceName);
                return;
            }
            Port port;
            if (tunnelId != null) {
                port = dhcpExternalTunnelManager.readVniMacToPortCache(tunnelId, macAddress);
            } else {
                port = getNeutronPort(interfaceName);
            }
            Subnet subnet = getNeutronSubnet(port);
            String serverMacAddress = interfaceInfo.getMacAddress();
            String serverIp = null;
            if (subnet != null) {
                java.util.Optional<SubnetToDhcpPort> dhcpPortData = DhcpServiceUtils.getSubnetDhcpPortData(broker, subnet.getUuid().getValue());
                /* If enable_dhcp_service flag was enabled and an ODL network DHCP Port data was made available use
                     * the ports Fixed IP as server IP for DHCP communication.
                     */
                if (dhcpPortData.isPresent()) {
                    serverIp = dhcpPortData.get().getPortFixedip();
                    serverMacAddress = dhcpPortData.get().getPortMacaddress();
                } else {
                    // DHCP Neutron Port not found for this network
                    LOG.error("Neutron DHCP port is not available for the Subnet {} and port {}.", subnet.getUuid(), port.getUuid());
                    return;
                }
            }
            DHCP replyPkt = handleDhcpPacket(pktIn, interfaceName, macAddress, port, subnet, serverIp);
            if (replyPkt == null) {
                LOG.warn("Unable to construct reply packet for interface name {}", interfaceName);
                return;
            }
            byte[] pktOut = getDhcpPacketOut(replyPkt, ethPkt, serverMacAddress);
            sendPacketOut(pktOut, interfaceInfo.getDpId(), interfaceName, tunnelId);
        }
    }
}
Also used : SubnetToDhcpPort(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.api.rev150710.subnet.dhcp.port.data.SubnetToDhcpPort) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) PacketException(org.opendaylight.openflowplugin.libraries.liblldp.PacketException) DHCP(org.opendaylight.netvirt.dhcpservice.api.DHCP) SubnetToDhcpPort(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.api.rev150710.subnet.dhcp.port.data.SubnetToDhcpPort) Ethernet(org.opendaylight.genius.mdsalutil.packet.Ethernet) BigInteger(java.math.BigInteger) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) Subnet(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet)

Example 19 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project netvirt by opendaylight.

the class DhcpInterfaceAddJob method call.

@Override
public List<ListenableFuture<Void>> call() {
    String interfaceName = interfaceAdd.getName();
    LOG.trace("Received add DCN for interface {}, dpid {}", interfaceName, dpnId);
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = interfaceManager.getInterfaceInfoFromConfigDataStore(interfaceName);
    if (iface != null) {
        IfTunnel tunnelInterface = iface.getAugmentation(IfTunnel.class);
        if (tunnelInterface != null && !tunnelInterface.isInternal()) {
            IpAddress tunnelIp = tunnelInterface.getTunnelDestination();
            List<BigInteger> dpns = DhcpServiceUtils.getListOfDpns(dataBroker);
            if (dpns.contains(dpnId)) {
                return dhcpExternalTunnelManager.handleTunnelStateUp(tunnelIp, dpnId);
            }
            return Collections.emptyList();
        }
    }
    if (!dpnId.equals(DhcpMConstants.INVALID_DPID)) {
        Port port = dhcpManager.getNeutronPort(interfaceName);
        Subnet subnet = dhcpManager.getNeutronSubnet(port);
        if (null == subnet || !subnet.isEnableDhcp()) {
            LOG.debug("DHCP is not enabled for port {}", port.getName());
            return Collections.emptyList();
        }
        List<ListenableFuture<Void>> futures = new ArrayList<>();
        // Support for VM migration use cases.
        futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> DhcpServiceUtils.bindDhcpService(interfaceName, NwConstants.DHCP_TABLE, tx)));
        LOG.info("DhcpInterfaceEventListener add isEnableDhcp:{}", subnet.isEnableDhcp());
        futures.addAll(installDhcpEntries(interfaceAdd.getName(), dpnId));
        LOG.trace("Checking ElanDpnInterface {} for dpn {} ", interfaceName, dpnId);
        String subnetId = subnet.getUuid().getValue();
        java.util.Optional<SubnetToDhcpPort> subnetToDhcp = DhcpServiceUtils.getSubnetDhcpPortData(dataBroker, subnetId);
        if (!subnetToDhcp.isPresent()) {
            return Collections.emptyList();
        }
        LOG.trace("Installing the Arp responder for interface {} with DHCP MAC {} & IP {}.", interfaceName, subnetToDhcp.get().getPortMacaddress(), subnetToDhcp.get().getPortFixedip());
        ArpReponderInputBuilder builder = new ArpReponderInputBuilder();
        builder.setDpId(dpnId).setInterfaceName(interfaceName).setSpa(subnetToDhcp.get().getPortFixedip()).setSha(subnetToDhcp.get().getPortMacaddress()).setLportTag(interfaceAdd.getIfIndex());
        builder.setInstructions(ArpResponderUtil.getInterfaceInstructions(interfaceManager, interfaceName, subnetToDhcp.get().getPortFixedip(), subnetToDhcp.get().getPortMacaddress()));
        elanService.addArpResponderFlow(builder.buildForInstallFlow());
        return futures;
    }
    return Collections.emptyList();
}
Also used : ListenableFuture(com.google.common.util.concurrent.ListenableFuture) DhcpMConstants(org.opendaylight.netvirt.dhcpservice.api.DhcpMConstants) LoggerFactory(org.slf4j.LoggerFactory) Callable(java.util.concurrent.Callable) IElanService(org.opendaylight.netvirt.elanmanager.api.IElanService) DhcpExternalTunnelManager(org.opendaylight.netvirt.dhcpservice.DhcpExternalTunnelManager) ArrayList(java.util.ArrayList) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) DhcpServiceUtils(org.opendaylight.netvirt.dhcpservice.DhcpServiceUtils) ArpReponderInputBuilder(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder) ArpResponderUtil(org.opendaylight.netvirt.elan.arp.responder.ArpResponderUtil) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) BigInteger(java.math.BigInteger) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) Logger(org.slf4j.Logger) Subnet(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) DhcpManager(org.opendaylight.netvirt.dhcpservice.DhcpManager) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) List(java.util.List) SubnetToDhcpPort(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.api.rev150710.subnet.dhcp.port.data.SubnetToDhcpPort) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Collections(java.util.Collections) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) SubnetToDhcpPort(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.api.rev150710.subnet.dhcp.port.data.SubnetToDhcpPort) ArrayList(java.util.ArrayList) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) SubnetToDhcpPort(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.api.rev150710.subnet.dhcp.port.data.SubnetToDhcpPort) ArpReponderInputBuilder(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder) BigInteger(java.math.BigInteger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Subnet(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet)

Example 20 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project netvirt by opendaylight.

the class NeutronSubnetChangeListener method remove.

@Override
protected void remove(InstanceIdentifier<Subnet> identifier, Subnet input) {
    LOG.trace("Removing subnet : key: {}, value={}", identifier, input);
    Uuid networkId = input.getNetworkId();
    Uuid subnetId = input.getUuid();
    Network network = neutronvpnUtils.getNeutronNetwork(networkId);
    if (network == null || !NeutronvpnUtils.isNetworkTypeSupported(network)) {
        LOG.warn("neutron vpn received a subnet remove() for a network without a provider extension augmentation " + "or with an unsupported network type for the subnet {} which is part of network {}", subnetId.getValue(), network);
        return;
    }
    handleNeutronSubnetDeleted(subnetId, networkId);
    externalSubnetHandler.handleExternalSubnetRemoved(network, subnetId);
    neutronvpnUtils.removeFromSubnetCache(input);
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Network(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)

Aggregations

BigInteger (java.math.BigInteger)26 ArrayList (java.util.ArrayList)20 ExecutionException (java.util.concurrent.ExecutionException)16 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)13 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)13 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)10 List (java.util.List)10 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)10 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)9 UnknownHostException (java.net.UnknownHostException)8 VpnInterface (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)8 Network (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)8 Optional (com.google.common.base.Optional)7 Test (org.junit.Test)7 PacketException (org.opendaylight.openflowplugin.libraries.liblldp.PacketException)7 Collections (java.util.Collections)6 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)6 FutureCallback (com.google.common.util.concurrent.FutureCallback)5 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)5 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)5