Search in sources :

Example 36 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project netvirt by opendaylight.

the class ArpNotificationHandler method onArpRequestReceived.

@Override
public void onArpRequestReceived(ArpRequestReceived notification) {
    String srcInterface = notification.getInterface();
    IpAddress srcIP = notification.getSrcIpaddress();
    MacAddress srcMac = MacAddress.getDefaultInstance(notification.getSrcMac().getValue());
    IpAddress targetIP = notification.getDstIpaddress();
    Uint64 metadata = notification.getMetadata();
    boolean isGarp = srcIP.equals(targetIP);
    if (!isGarp) {
        LOG.info("ArpNotification Non-Gratuitous Request Received from " + "interface {} and IP {} having MAC {} target destination {}, ignoring..", srcInterface, srcIP.stringValue(), srcMac.getValue(), targetIP.stringValue());
        return;
    }
    LOG.info("ArpNotification Gratuitous Request Received from interface {} and IP {} having MAC {} " + "target destination {}, learning MAC", srcInterface, srcIP.stringValue(), srcMac.getValue(), targetIP.stringValue());
    processIpLearning(srcInterface, srcIP, srcMac, metadata, targetIP);
}
Also used : IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 37 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project netvirt by opendaylight.

the class Ipv6NaPacketListener method onNaReceived.

@Override
public void onNaReceived(NeighborAdvertisePacket naPacket) {
    PacketMetadata pktMetadata = naPacket.augmentation(PacketMetadata.class);
    if (pktMetadata == null) {
        return;
    }
    String srcInterface = pktMetadata.getInterface();
    IpAddress srcIP = new IpAddress(naPacket.getSourceIpv6());
    MacAddress srcMac = naPacket.getSourceMac();
    IpAddress targetIP = new IpAddress(naPacket.getTargetAddress());
    Uint64 metadata = pktMetadata.getMetadata();
    LOG.debug("NA notification received from interface {} and IP {} having MAC {}, targetIP={}", srcInterface, srcIP.stringValue(), srcMac.getValue(), targetIP.stringValue());
    validateAndProcessIpLearning(srcInterface, srcIP, srcMac, targetIP, metadata);
}
Also used : PacketMetadata(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.ipv6.nd.util.rev170210.PacketMetadata) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 38 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project netvirt by opendaylight.

the class AbstractIpLearnNotificationHandler method processIpLearning.

protected void processIpLearning(String srcInterface, IpAddress srcIP, MacAddress srcMac, Uint64 metadata, IpAddress dstIP) {
    if (!VpnUtil.isArpLearningEnabled()) {
        LOG.trace("Not handling packet as ARP Based Learning is disabled");
        return;
    }
    if (metadata == null || Objects.equals(metadata, Uint64.ZERO)) {
        return;
    }
    Optional<List<String>> vpnList = vpnUtil.getVpnHandlingIpv4AssociatedWithInterface(srcInterface);
    if (!vpnList.isPresent()) {
        LOG.info("IP LEARN NO_RESOLVE: VPN  not configured. Ignoring responding to ARP/NA requests from this" + " Interface {}.", srcInterface);
        return;
    }
    String srcIpToQuery = srcIP.stringValue();
    String destIpToQuery = dstIP.stringValue();
    for (String vpnName : vpnList.get()) {
        LOG.info("Received ARP/NA for sender MAC {} and sender IP {} via interface {}", srcMac.getValue(), srcIpToQuery, srcInterface);
        final ReentrantLock lock = lockFor(vpnName, srcIpToQuery);
        lock.lock();
        try {
            VpnPortipToPort vpnPortipToPort = vpnUtil.getNeutronPortFromVpnPortFixedIp(vpnName, srcIpToQuery);
            // Check if this IP belongs to  external network
            if (vpnPortipToPort == null) {
                String extSubnetId = vpnUtil.getAssociatedExternalSubnet(srcIpToQuery);
                if (extSubnetId != null) {
                    vpnPortipToPort = vpnUtil.getNeutronPortFromVpnPortFixedIp(extSubnetId, srcIpToQuery);
                }
            }
            if (vpnPortipToPort != null && !vpnPortipToPort.isLearntIp()) {
                /*
                     * This is a well known neutron port and so should be ignored from being
                     * discovered...unless it is an Octavia VIP
                     */
                String portName = vpnPortipToPort.getPortName();
                Port neutronPort = neutronVpnManager.getNeutronPort(portName);
                if (neutronPort == null) {
                    LOG.warn("{} should have been a neutron port but could not retrieve it. Aborting processing", portName);
                    continue;
                }
                if (!"Octavia".equals(neutronPort.getDeviceOwner())) {
                    LOG.debug("Neutron port {} is not an Octavia port, ignoring", portName);
                    continue;
                }
            }
            // after reboot, it would be ignored.
            if (vpnPortipToPort != null && vpnPortipToPort.isLearntIp()) {
                if (System.currentTimeMillis() < this.bootupTime + config.getBootDelayArpLearning().toJava() * 1000) {
                    LOG.trace("GARP/Arp Response not handled for IP {} vpnName {} for time {}s", vpnPortipToPort.getPortFixedip(), vpnName, config.getBootDelayArpLearning());
                    continue;
                }
            }
            LearntVpnVipToPort learntVpnVipToPort = vpnUtil.getLearntVpnVipToPort(vpnName, srcIpToQuery);
            if (learntVpnVipToPort != null) {
                String oldPortName = learntVpnVipToPort.getPortName();
                String oldMac = learntVpnVipToPort.getMacAddress();
                if (!oldMac.equalsIgnoreCase(srcMac.getValue())) {
                    // MAC has changed for requested IP
                    LOG.info("ARP/NA Source IP/MAC data modified for IP {} with MAC {} and Port {}", srcIpToQuery, srcMac, srcInterface);
                    vpnUtil.createLearntVpnVipToPortEvent(vpnName, srcIpToQuery, destIpToQuery, oldPortName, oldMac, LearntVpnVipToPortEventAction.Delete, null);
                    putVpnIpToMigrateIpCache(vpnName, srcIpToQuery, srcMac);
                }
            } else if (!isIpInMigrateCache(vpnName, srcIpToQuery)) {
                if (vpnPortipToPort != null && !vpnPortipToPort.getPortName().equals(srcInterface)) {
                    LOG.trace("LearntIp: {} vpnName {} is already present in VpnPortIpToPort with " + "PortName {} ", srcIpToQuery, vpnName, vpnPortipToPort.getPortName());
                    vpnUtil.createLearntVpnVipToPortEvent(vpnName, srcIpToQuery, destIpToQuery, vpnPortipToPort.getPortName(), vpnPortipToPort.getMacAddress(), LearntVpnVipToPortEventAction.Delete, null);
                    continue;
                }
                learnMacFromIncomingPacket(vpnName, srcInterface, srcIP, srcMac, dstIP);
            }
        } finally {
            lock.unlock();
        }
    }
}
Also used : ReentrantLock(java.util.concurrent.locks.ReentrantLock) VpnPortipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) VpnPortipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) List(java.util.List) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort)

Example 39 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project netvirt by opendaylight.

the class ElanGroupListener method update.

@Override
public void update(InstanceIdentifier<Group> identifier, @Nullable Group original, Group update) {
    LOG.trace("received group updated {}", update.key().getGroupId());
    final Uint64 dpnId = getDpnId(identifier.firstKeyOf(Node.class).getId().getValue());
    if (dpnId == null) {
        return;
    }
    List<L2GatewayDevice> allDevices = ElanL2GwCacheUtils.getAllElanDevicesFromCache();
    if (allDevices.isEmpty()) {
        LOG.trace("no elan devices present in cache {}", update.key().getGroupId());
        return;
    }
    int expectedElanFootprint = 0;
    final ElanInstance elanInstance = getElanInstanceFromGroupId(update);
    if (elanInstance == null) {
        LOG.trace("no elan instance is null {}", update.key().getGroupId());
        return;
    }
    final int devicesSize = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanInstance.getElanInstanceName()).size();
    if (devicesSize == 0) {
        LOG.trace("no elan devices in elan cache {} {}", elanInstance.getElanInstanceName(), update.key().getGroupId());
        return;
    }
    boolean updateGroup = false;
    List<DpnInterfaces> dpns = elanUtils.getElanDPNByName(elanInstance.getElanInstanceName());
    if (dpns.size() > 0) {
        expectedElanFootprint += dpns.size();
    } else {
        updateGroup = true;
    }
    expectedElanFootprint += devicesSize;
    if (update.getBuckets() != null && update.getBuckets().getBucket() != null) {
        if (update.getBuckets().getBucket().size() != expectedElanFootprint) {
            updateGroup = true;
        } else {
            LOG.trace("no of buckets matched perfectly {} {}", elanInstance.getElanInstanceName(), update.key().getGroupId());
        }
    }
    if (updateGroup) {
        List<Bucket> bucketList = elanL2GatewayMulticastUtils.getRemoteBCGroupBuckets(elanInstance, null, dpnId, 0, elanInstance.getElanTag().toJava());
        // remove local bcgroup bucket
        expectedElanFootprint--;
        if (bucketList.size() != expectedElanFootprint) {
            // no point in retrying if not able to meet expected foot print
            return;
        }
        LOG.trace("no of buckets mismatched {} {}", elanInstance.getElanInstanceName(), update.key().getGroupId());
        elanClusterUtils.runOnlyInOwnerNode(elanInstance.getElanInstanceName(), "updating broadcast group", () -> {
            LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> elanL2GatewayMulticastUtils.setupElanBroadcastGroups(elanInstance, dpnId, confTx)), LOG, "Error setting up ELAN BGs");
            return null;
        });
    } else {
        LOG.trace("no buckets in the update {} {}", elanInstance.getElanInstanceName(), update.key().getGroupId());
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) ElanL2GatewayMulticastUtils(org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils) Uint64(org.opendaylight.yangtools.yang.common.Uint64) ElanL2GwCacheUtils(org.opendaylight.netvirt.elanmanager.utils.ElanL2GwCacheUtils) LoggerFactory(org.slf4j.LoggerFactory) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) Singleton(javax.inject.Singleton) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) ElanClusterUtils(org.opendaylight.netvirt.elan.utils.ElanClusterUtils) ElanUtils(org.opendaylight.netvirt.elan.utils.ElanUtils) Nullable(org.eclipse.jdt.annotation.Nullable) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) Logger(org.slf4j.Logger) AbstractClusteredAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractClusteredAsyncDataTreeChangeListener) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) ElanInstanceCache(org.opendaylight.netvirt.elan.cache.ElanInstanceCache) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) List(java.util.List) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 40 with Received

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project netvirt by opendaylight.

the class HwvtepPhysicalSwitchListener method updated.

/**
 * Upon update checks if the tunnels Ip was null earlier and it got newly added.
 * In that case simply call add.
 * If not then check if Tunnel Ip has been updated from an old value to new value.
 * If yes. delete old ITM tunnels of odl Tunnel Ipand add new ITM tunnels with new Tunnel
 * IP then call added ().
 *
 * @param identifier iid
 * @param phySwitchBefore ps Node before update
 * @param phySwitchAfter ps Node after update
 */
@Override
protected void updated(InstanceIdentifier<PhysicalSwitchAugmentation> identifier, PhysicalSwitchAugmentation phySwitchBefore, PhysicalSwitchAugmentation phySwitchAfter) {
    NodeId nodeId = getNodeId(identifier);
    LOG.trace("Received PhysicalSwitch Update Event for node {}: PhysicalSwitch Before: {}, " + "PhysicalSwitch After: {}", nodeId.getValue(), phySwitchBefore, phySwitchAfter);
    String psName = getPsName(identifier);
    if (psName == null) {
        LOG.error("PhysicalSwitchListener Could not find the physical switch name for node {}", nodeId.getValue());
        return;
    }
    L2GatewayDevice existingDevice = l2GatewayCache.get(psName);
    if (!Objects.equals(phySwitchAfter.getTunnelIps(), phySwitchBefore.getTunnelIps())) {
        LOG.info("PhysicalSwitchListener Received physical switch update for {} before teps {} after teps {}", nodeId.getValue(), phySwitchBefore.getTunnelIps(), phySwitchAfter.getTunnelIps());
    }
    InstanceIdentifier<Node> globalNodeIid = getManagedByNodeIid(identifier);
    if (DEVICE_NOT_CACHED_OR_PARENT_CONNECTED.test(existingDevice, globalNodeIid)) {
        if (TUNNEL_IP_AVAILABLE.test(phySwitchAfter)) {
            added(identifier, phySwitchAfter);
        }
    } else {
        if (!Objects.equals(phySwitchAfter.getTunnelIps(), phySwitchBefore.getTunnelIps()) && TUNNEL_IP_CHANGED.test(phySwitchAfter, existingDevice)) {
            final String hwvtepId = existingDevice.getHwvtepNodeId();
            elanClusterUtils.runOnlyInOwnerNode(existingDevice.getDeviceName(), "handling Physical Switch add create itm tunnels ", () -> {
                LOG.info("PhysicalSwitchListener Deleting itm tunnels for {}", existingDevice.getDeviceName());
                L2GatewayUtils.deleteItmTunnels(itmRpcService, hwvtepId, existingDevice.getDeviceName(), existingDevice.getTunnelIp());
                // TODO remove these sleeps
                Thread.sleep(10000L);
                LOG.info("Creating itm tunnels for device {}", existingDevice.getDeviceName());
                ElanL2GatewayUtils.createItmTunnels(dataBroker, itmRpcService, hwvtepId, psName, phySwitchAfter.getTunnelIps().get(0).getTunnelIpsKey());
                return Collections.emptyList();
            });
            try {
                // TODO remove the sleep by using better itm api to detect finish of prev op
                Thread.sleep(20000L);
            } catch (InterruptedException e) {
                LOG.error("Interrupted ");
            }
            existingDevice.setTunnelIps(new HashSet<>());
            added(identifier, phySwitchAfter);
        }
    }
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Aggregations

ExecutionException (java.util.concurrent.ExecutionException)29 ArrayList (java.util.ArrayList)24 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)23 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)18 BigInteger (java.math.BigInteger)16 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)16 List (java.util.List)13 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)13 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)13 Test (org.junit.Test)12 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)12 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)12 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)11 UnknownHostException (java.net.UnknownHostException)10 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)10 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)9 Network (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)9 Collections (java.util.Collections)8 Map (java.util.Map)8 VpnInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.VpnInterface)8