Search in sources :

Example 1 with ArpResponderInput

use of org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput in project netvirt by opendaylight.

the class DhcpNeutronPortListener method processArpResponderForElanDpns.

/**
 * Handle(Add/Remove) ARP Responder for DHCP IP on all the DPNs when DHCP is
 * enabled/disabled on subnet add or update or delete.
 *
 * @param port
 *            DHCP port for which ARP Responder flow to be added when dhcp
 *            flag is enabled on the subnet or DHCP port for which ARP
 *            Responder flow to be removed when dhcp flag is disabled on the
 *            Subnet
 * @param arpResponderAction
 *            ARP Responder Action to be performed i.e., add or remove flow
 */
private void processArpResponderForElanDpns(Port port, Consumer<ArpResponderInput> arpResponderAction) {
    java.util.Optional<String> ip4Address = DhcpServiceUtils.getIpV4Address(port);
    if (!ip4Address.isPresent()) {
        LOG.warn("There is no IPv4Address for port {}, not performing ARP responder add/remove flow operation", port.getName());
        return;
    }
    ElanHelper.getDpnInterfacesInElanInstance(broker, port.getNetworkId().getValue()).stream().map(ifName -> DhcpServiceUtils.getInterfaceInfo(interfaceManager, ifName)).forEach(interfaceInfo -> {
        ArpResponderInput arpResponderInput = new ArpResponderInput.ArpReponderInputBuilder().setDpId(interfaceInfo.getDpId()).setInterfaceName(interfaceInfo.getInterfaceName()).setLportTag(interfaceInfo.getInterfaceTag()).setSha(port.getMacAddress().getValue()).setSpa(ip4Address.get()).build();
        arpResponderAction.accept(arpResponderInput);
    });
}
Also used : Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports) DhcpMConstants(org.opendaylight.netvirt.dhcpservice.api.DhcpMConstants) LoggerFactory(org.slf4j.LoggerFactory) PortBindingExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension) IElanService(org.opendaylight.netvirt.elanmanager.api.IElanService) Singleton(javax.inject.Singleton) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) Neutron(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron) Inject(javax.inject.Inject) AsyncClusteredDataTreeChangeListenerBase(org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase) PreDestroy(javax.annotation.PreDestroy) ArpReponderInputBuilder(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder) NeutronConstants(org.opendaylight.netvirt.neutronvpn.api.utils.NeutronConstants) Locale(java.util.Locale) ArpResponderUtil(org.opendaylight.netvirt.elan.arp.responder.ArpResponderUtil) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) BigInteger(java.math.BigInteger) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) Named(javax.inject.Named) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) DhcpserviceConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.config.rev150710.DhcpserviceConfig) Logger(org.slf4j.Logger) Subnet(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet) ElanHelper(org.opendaylight.netvirt.elanmanager.api.ElanHelper) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) Consumer(java.util.function.Consumer) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) List(java.util.List) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) PostConstruct(javax.annotation.PostConstruct) Collections(java.util.Collections) ArpResponderInput(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput) ArpResponderInput(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput) ArpReponderInputBuilder(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder)

Example 2 with ArpResponderInput

use of org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput in project netvirt by opendaylight.

the class DhcpInterfaceRemoveJob method call.

@Override
public List<ListenableFuture<Void>> call() {
    String interfaceName = interfaceDel.getName();
    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.handleTunnelStateDown(tunnelIp, dpnId);
            }
            return Collections.emptyList();
        }
    }
    List<ListenableFuture<Void>> futures = new ArrayList<>();
    // Support for VM migration use cases.
    futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> DhcpServiceUtils.unbindDhcpService(interfaceName, tx)));
    java.util.Optional<String> subnetId = DhcpServiceUtils.getNeutronSubnetId(port);
    if (subnetId.isPresent()) {
        java.util.Optional<SubnetToDhcpPort> subnetToDhcp = DhcpServiceUtils.getSubnetDhcpPortData(dataBroker, subnetId.get());
        if (subnetToDhcp.isPresent()) {
            LOG.trace("Removing ArpResponder flow for last interface {} on DPN {}", interfaceName, dpnId);
            ArpResponderInput arpInput = new ArpResponderInput.ArpReponderInputBuilder().setDpId(dpnId).setInterfaceName(interfaceName).setSpa(subnetToDhcp.get().getPortFixedip()).setLportTag(interfaceDel.getIfIndex()).buildForRemoveFlow();
            elanService.removeArpResponderFlow(arpInput);
        }
    }
    futures.addAll(unInstallDhcpEntries(interfaceDel.getName(), dpnId));
    return futures;
}
Also used : ListenableFuture(com.google.common.util.concurrent.ListenableFuture) InterfaceNameMacAddresses(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.api.rev150710.InterfaceNameMacAddresses) 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) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) BigInteger(java.math.BigInteger) InterfaceNameMacAddressKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.api.rev150710._interface.name.mac.addresses.InterfaceNameMacAddressKey) Nullable(javax.annotation.Nullable) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) Logger(org.slf4j.Logger) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) InterfaceNameMacAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.api.rev150710._interface.name.mac.addresses.InterfaceNameMacAddress) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) FutureCallback(com.google.common.util.concurrent.FutureCallback) 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) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) SubnetToDhcpPort(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.api.rev150710.subnet.dhcp.port.data.SubnetToDhcpPort) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Collections(java.util.Collections) ArpResponderInput(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) ArrayList(java.util.ArrayList) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) ArpResponderInput(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput) SubnetToDhcpPort(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.api.rev150710.subnet.dhcp.port.data.SubnetToDhcpPort) 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)

Example 3 with ArpResponderInput

use of org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput in project netvirt by opendaylight.

the class VpnManagerImpl method removeArpResponderFlowsToExternalNetworkIp.

private void removeArpResponderFlowsToExternalNetworkIp(BigInteger dpnId, Integer lportTag, String fixedIp, String extInterfaceName) {
    ArpResponderInput arpInput = new ArpReponderInputBuilder().setDpId(dpnId).setInterfaceName(extInterfaceName).setSpa(fixedIp).setLportTag(lportTag).buildForRemoveFlow();
    elanService.removeArpResponderFlow(arpInput);
}
Also used : ArpResponderInput(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput) ArpReponderInputBuilder(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder)

Example 4 with ArpResponderInput

use of org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput in project netvirt by opendaylight.

the class DhcpExternalTunnelManager method uninstallDhcpArpResponderFlows.

private void uninstallDhcpArpResponderFlows(BigInteger dpnId, String interfaceName, int lportTag, String dhcpIpAddress) {
    LOG.trace("Removing SR-IOV DHCP ArpResponder flow for interface {} on DPN {}", interfaceName, dpnId);
    ArpResponderInput arpInput = new ArpResponderInput.ArpReponderInputBuilder().setDpId(dpnId).setInterfaceName(interfaceName).setSpa(dhcpIpAddress).setLportTag(lportTag).buildForRemoveFlow();
    elanService.removeArpResponderFlow(arpInput);
}
Also used : ArpResponderInput(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput)

Aggregations

ArpResponderInput (org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput)4 BigInteger (java.math.BigInteger)2 Collections (java.util.Collections)2 List (java.util.List)2 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)2 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)2 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)2 ManagedNewTransactionRunnerImpl (org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl)2 IInterfaceManager (org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager)2 ArpReponderInputBuilder (org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder)2 IElanService (org.opendaylight.netvirt.elanmanager.api.IElanService)2 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)2 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1 Callable (java.util.concurrent.Callable)1