Search in sources :

Example 1 with ArpReponderInputBuilder

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

the class VpnManagerImpl method installArpResponderFlowsToExternalNetworkIp.

private void installArpResponderFlowsToExternalNetworkIp(String macAddress, BigInteger dpnId, String extInterfaceName, int lportTag, String fixedIp) {
    // reset the split-horizon bit to allow traffic to be sent back to the
    // provider port
    List<Instruction> instructions = new ArrayList<>();
    instructions.add(new InstructionWriteMetadata(BigInteger.ZERO, MetaDataUtil.METADATA_MASK_SH_FLAG).buildInstruction(1));
    instructions.addAll(ArpResponderUtil.getExtInterfaceInstructions(interfaceManager, extInterfaceName, fixedIp, macAddress));
    ArpReponderInputBuilder builder = new ArpReponderInputBuilder().setDpId(dpnId).setInterfaceName(extInterfaceName).setSpa(fixedIp).setSha(macAddress).setLportTag(lportTag);
    builder.setInstructions(instructions);
    elanService.addArpResponderFlow(builder.buildForInstallFlow());
}
Also used : ArpReponderInputBuilder(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder) ArrayList(java.util.ArrayList) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)

Example 2 with ArpReponderInputBuilder

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

the class ArpResponderHandler method addArpResponderFlow.

/**
 * Add ARP Responder flow, by invoking ELan RPC service.
 *
 * @param dpnId
 *            dpn Id on which ARP responder flow to be added
 * @param lportTag
 *            lport tag of the interface
 * @param interfaceName
 *            interface to which ARP responder flow to be added
 * @param gatewayIp
 *            gateway ip of the interface
 * @param mac
 *            mac address
 */
public void addArpResponderFlow(BigInteger dpnId, int lportTag, String interfaceName, String gatewayIp, String mac) {
    LOG.trace("Creating the ARP Responder flow for VPN Interface {}", interfaceName);
    ArpReponderInputBuilder builder = new ArpReponderInputBuilder();
    builder.setDpId(dpnId).setInterfaceName(interfaceName).setSpa(gatewayIp).setSha(mac).setLportTag(lportTag);
    builder.setInstructions(ArpResponderUtil.getInterfaceInstructions(interfaceManager, interfaceName, gatewayIp, mac));
    elanService.addArpResponderFlow(builder.buildForInstallFlow());
}
Also used : ArpReponderInputBuilder(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder)

Example 3 with ArpReponderInputBuilder

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

the class DhcpNeutronPortListener method add.

@Override
protected void add(InstanceIdentifier<Port> identifier, Port add) {
    LOG.trace("Port added {}", add);
    if (NeutronConstants.IS_ODL_DHCP_PORT.test(add)) {
        jobCoordinator.enqueueJob(getJobKey(add), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
            DhcpServiceUtils.createSubnetDhcpPortData(add, (subnetDhcpPortIdfr, subnetToDhcpport) -> tx.put(LogicalDatastoreType.CONFIGURATION, subnetDhcpPortIdfr, subnetToDhcpport));
            processArpResponderForElanDpns(add, arpInput -> {
                LOG.trace("Installing ARP RESPONDER Flows  for dhcp port {} ipaddress {} with mac {} on dpn {}", arpInput.getInterfaceName(), arpInput.getSpa(), arpInput.getSha(), arpInput.getDpId());
                ArpReponderInputBuilder builder = new ArpReponderInputBuilder(arpInput);
                builder.setInstructions(ArpResponderUtil.getInterfaceInstructions(interfaceManager, arpInput.getInterfaceName(), arpInput.getSpa(), arpInput.getSha()));
                elanService.addArpResponderFlow(builder.buildForInstallFlow());
            });
        })));
        java.util.Optional<String> ip4Address = DhcpServiceUtils.getIpV4Address(add);
        if (ip4Address.isPresent()) {
            dhcpExternalTunnelManager.addOrRemoveDhcpArpFlowforElan(add.getNetworkId().getValue(), true, ip4Address.get(), add.getMacAddress().getValue());
        }
    }
    if (!isVnicTypeDirectOrMacVtap(add)) {
        return;
    }
    addPort(add);
}
Also used : ArpReponderInputBuilder(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder)

Example 4 with ArpReponderInputBuilder

use of org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder 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 5 with ArpReponderInputBuilder

use of org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder 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)

Aggregations

ArpReponderInputBuilder (org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder)6 ArrayList (java.util.ArrayList)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 BigInteger (java.math.BigInteger)1 Collections (java.util.Collections)1 List (java.util.List)1 Callable (java.util.concurrent.Callable)1 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)1 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)1 ManagedNewTransactionRunnerImpl (org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl)1 IInterfaceManager (org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager)1 NwConstants (org.opendaylight.genius.mdsalutil.NwConstants)1 InstructionWriteMetadata (org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)1 DhcpExternalTunnelManager (org.opendaylight.netvirt.dhcpservice.DhcpExternalTunnelManager)1 DhcpManager (org.opendaylight.netvirt.dhcpservice.DhcpManager)1 DhcpServiceUtils (org.opendaylight.netvirt.dhcpservice.DhcpServiceUtils)1 DhcpMConstants (org.opendaylight.netvirt.dhcpservice.api.DhcpMConstants)1 ArpResponderInput (org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput)1 ArpResponderUtil (org.opendaylight.netvirt.elan.arp.responder.ArpResponderUtil)1 IElanService (org.opendaylight.netvirt.elanmanager.api.IElanService)1