Search in sources :

Example 86 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 ArpMonitoringHandler method add.

@Override
protected void add(InstanceIdentifier<LearntVpnVipToPort> identifier, LearntVpnVipToPort value) {
    runOnlyInOwnerNode("ArpMonitoringHandler: add event", () -> {
        try {
            InetAddress srcInetAddr = InetAddress.getByName(value.getPortFixedip());
            if (value.getMacAddress() == null) {
                LOG.warn("The mac address received is null for VpnPortipToPort {}, ignoring the DTCN", value);
                return;
            }
            MacAddress srcMacAddress = MacAddress.getDefaultInstance(value.getMacAddress());
            String vpnName = value.getVpnName();
            MacEntry macEntry = new MacEntry(vpnName, srcMacAddress, srcInetAddr, value.getPortName(), value.getCreationTime());
            jobCoordinator.enqueueJob(buildJobKey(srcInetAddr.toString(), vpnName), new ArpMonitorStartTask(macEntry, arpMonitorProfileId, dataBroker, alivenessManager, neutronVpnService, interfaceManager));
        } catch (UnknownHostException e) {
            LOG.error("Error in deserializing packet {} with exception", value, e);
        }
    });
}
Also used : UnknownHostException(java.net.UnknownHostException) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) InetAddress(java.net.InetAddress)

Example 87 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 ArpNotificationHandler method onArpRequestReceived.

@Override
public void onArpRequestReceived(ArpRequestReceived notification) {
    String srcInterface = notification.getInterface();
    IpAddress srcIP = notification.getSrcIpaddress();
    PhysAddress srcMac = notification.getSrcMac();
    IpAddress targetIP = notification.getDstIpaddress();
    BigInteger 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.getIpv4Address().getValue(), srcMac.getValue(), targetIP.getIpv4Address().getValue());
        return;
    }
    LOG.info("ArpNotification Gratuitous Request Received from " + "interface {} and IP {} having MAC {} target destination {}, learning MAC", srcInterface, srcIP.getIpv4Address().getValue(), srcMac.getValue(), targetIP.getIpv4Address().getValue());
    processArpLearning(srcInterface, srcIP, srcMac, metadata, targetIP);
}
Also used : BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 88 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 ArpNotificationHandler method onArpResponseReceived.

@Override
public void onArpResponseReceived(ArpResponseReceived notification) {
    String srcInterface = notification.getInterface();
    IpAddress srcIP = notification.getSrcIpaddress();
    PhysAddress srcMac = notification.getSrcMac();
    LOG.info("ArpNotification Response Received from interface {} and IP {} having MAC {}, learning MAC", srcInterface, srcIP.getIpv4Address().getValue(), srcMac.getValue());
    List<Adjacency> adjacencies = VpnUtil.getAdjacenciesForVpnInterfaceFromConfig(dataBroker, srcInterface);
    if (adjacencies != null) {
        for (Adjacency adj : adjacencies) {
            String ipAddress = adj.getIpAddress();
            try {
                if (NWUtil.isIpInSubnet(NWUtil.ipAddressToInt(srcIP.getIpv4Address().getValue()), ipAddress)) {
                    return;
                }
            } catch (UnknownHostException e) {
                LOG.error("Subnet string {} not convertible to InetAdddress", srcIP, e);
            }
        }
    }
    BigInteger metadata = notification.getMetadata();
    IpAddress targetIP = notification.getDstIpaddress();
    LOG.trace("ArpNotification Response Received from interface {} and IP {} having MAC {}, learning MAC", srcInterface, srcIP.getIpv4Address().getValue(), srcMac.getValue());
    processArpLearning(srcInterface, srcIP, srcMac, metadata, targetIP);
}
Also used : UnknownHostException(java.net.UnknownHostException) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 89 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 ArpNotificationHandler method processArpLearning.

private void processArpLearning(String srcInterface, IpAddress srcIP, PhysAddress srcMac, BigInteger metadata, IpAddress dstIP) {
    if (metadata != null && !Objects.equals(metadata, BigInteger.ZERO)) {
        Optional<List<String>> vpnList = VpnUtil.getVpnHandlingIpv4AssociatedWithInterface(dataBroker, srcInterface);
        if (vpnList.isPresent()) {
            for (String vpnName : vpnList.get()) {
                LOG.info("Received ARP for sender MAC {} and sender IP {} via interface {}", srcMac.getValue(), srcIP.getIpv4Address().getValue(), srcInterface);
                String ipToQuery = srcIP.getIpv4Address().getValue();
                LOG.info("ARP being processed for Source IP {}", ipToQuery);
                VpnPortipToPort vpnPortipToPort = VpnUtil.getNeutronPortFromVpnPortFixedIp(dataBroker, vpnName, ipToQuery);
                if (vpnPortipToPort != null) {
                    /* This is a well known neutron port and so should be ignored
                         * from being discovered
                         */
                    continue;
                }
                LearntVpnVipToPort learntVpnVipToPort = VpnUtil.getLearntVpnVipToPort(dataBroker, vpnName, ipToQuery);
                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 Source IP/MAC data modified for IP {} with MAC {} and Port {}", ipToQuery, srcMac, srcInterface);
                        synchronized ((vpnName + ipToQuery).intern()) {
                            removeMipAdjacency(vpnName, oldPortName, srcIP);
                            VpnUtil.removeLearntVpnVipToPort(dataBroker, vpnName, ipToQuery);
                            putVpnIpToMigrateArpCache(vpnName, ipToQuery, srcMac);
                        }
                    }
                } else if (!isIpInArpMigrateCache(vpnName, ipToQuery)) {
                    learnMacFromArpPackets(vpnName, srcInterface, srcIP, srcMac, dstIP);
                }
            }
        } else {
            LOG.info("ARP NO_RESOLVE: VPN  not configured. Ignoring responding to ARP requests from this" + " Interface {}.", srcInterface);
            return;
        }
    }
}
Also used : VpnPortipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort) ArrayList(java.util.ArrayList) List(java.util.List) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort)

Example 90 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 BgpConfigurationManager method replayNbrConfig.

private static boolean replayNbrConfig(List<Neighbors> neighbors, BgpRouter br) {
    if (neighbors == null || neighbors.isEmpty()) {
        LOG.error("Replaying nbr configuration, received NULL list ");
        return true;
    }
    List<ReplayNbr> replayNbrList = new ArrayList<>();
    for (Neighbors nbr : neighbors) {
        if (nbr != null) {
            replayNbrList.add(new ReplayNbr(nbr, true));
        }
    }
    final int numberOfNbrRetries = 3;
    RetryOnException nbrRetry = new RetryOnException(numberOfNbrRetries);
    do {
        for (ReplayNbr replayNbr : replayNbrList) {
            if (!replayNbr.isShouldRetry()) {
                continue;
            }
            boolean replayDone = false;
            LOG.debug("Replaying addNbr {}", replayNbr.getNbr().getAddress().getValue());
            replayDone = false;
            try {
                final String md5password = extractMd5Secret(replayNbr.getNbr());
                br.addNeighbor(replayNbr.getNbr().getAddress().getValue(), replayNbr.getNbr().getRemoteAs().longValue(), md5password);
                UpdateSource us = replayNbr.getNbr().getUpdateSource();
                if (us != null) {
                    LOG.debug("Replaying updatesource along with nbr: {} US-ip: {} to peer {}", replayNbr.getNbr().getAddress().getValue(), us.getSourceIp().getValue(), us.getPeerIp().getValue());
                    br.addUpdateSource(us.getPeerIp().getValue(), us.getSourceIp().getValue());
                }
                replayDone = true;
            } catch (TException | BgpRouterException eNbr) {
                LOG.debug("Replaying addNbr {}, exception: ", replayNbr.getNbr().getAddress().getValue(), eNbr);
            }
            boolean replaySuccess = true;
            replaySuccess = replaySuccess && replayDone;
            LOG.debug("Replay addNbr {} successful", replayNbr.getNbr().getAddress().getValue());
            // Update Source handling
            UpdateSource us = replayNbr.getNbr().getUpdateSource();
            if (replayDone == false && us != null) {
                LOG.debug("Replaying updatesource {} to peer {}", us.getSourceIp().getValue(), us.getPeerIp().getValue());
                replayDone = false;
                try {
                    br.addUpdateSource(us.getPeerIp().getValue(), us.getSourceIp().getValue());
                    replayDone = true;
                } catch (TException | BgpRouterException eUs) {
                    LOG.debug("Replaying UpdateSource for Nbr {}, exception:", replayNbr.getNbr().getAddress().getValue(), eUs);
                }
                LOG.debug("Replay updatesource {} successful", us.getSourceIp().getValue());
                replaySuccess = replaySuccess && replayDone;
            }
            // Ebgp Multihope
            EbgpMultihop en = replayNbr.getNbr().getEbgpMultihop();
            if (en != null) {
                replayDone = false;
                try {
                    br.addEbgpMultihop(en.getPeerIp().getValue(), en.getNhops().intValue());
                    replayDone = true;
                } catch (TException | BgpRouterException eEbgpMhop) {
                    LOG.debug("Replaying EbgpMultihop for Nbr {}, exception: ", replayNbr.getNbr().getAddress().getValue(), eEbgpMhop);
                }
                replaySuccess = replaySuccess && replayDone;
            }
            // afs
            List<AddressFamilies> afs = replayNbr.getNbr().getAddressFamilies();
            if (afs != null) {
                for (AddressFamilies af : afs) {
                    af_afi afi = af_afi.findByValue(af.getAfi().intValue());
                    af_safi safi = af_safi.findByValue(af.getSafi().intValue());
                    replayDone = false;
                    try {
                        br.addAddressFamily(af.getPeerIp().getValue(), afi, safi);
                        replayDone = true;
                    } catch (TException | BgpRouterException eAFs) {
                        LOG.debug("Replaying AddressFamily for Nbr {}, exception:", replayNbr.getNbr().getAddress().getValue(), eAFs);
                    }
                    replaySuccess = replaySuccess && replayDone;
                }
            }
            // replay is success --> no need to replay this nbr in next iteration.
            replayNbr.setShouldRetry(replaySuccess ? false : true);
        }
    } while (nbrRetry.decrementAndRetry());
    boolean replaySuccess = true;
    for (ReplayNbr replayNbr : replayNbrList) {
        replaySuccess = replaySuccess && !replayNbr.isShouldRetry();
    }
    return replaySuccess;
}
Also used : TException(org.apache.thrift.TException) ArrayList(java.util.ArrayList) Neighbors(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Neighbors) EbgpMultihop(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighbors.EbgpMultihop) org.opendaylight.netvirt.bgpmanager.thrift.gen.af_safi(org.opendaylight.netvirt.bgpmanager.thrift.gen.af_safi) BgpRouterException(org.opendaylight.netvirt.bgpmanager.thrift.client.BgpRouterException) AddressFamilies(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighbors.AddressFamilies) org.opendaylight.netvirt.bgpmanager.thrift.gen.af_afi(org.opendaylight.netvirt.bgpmanager.thrift.gen.af_afi) UpdateSource(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighbors.UpdateSource)

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