Search in sources :

Example 21 with FixedIps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps in project netvirt by opendaylight.

the class VpnManagerImpl method doAddArpResponderFlowsToExternalNetworkIps.

private void doAddArpResponderFlowsToExternalNetworkIps(String id, Collection<String> fixedIps, String macAddress, BigInteger dpnId, Uuid extNetworkId, WriteTransaction writeTx, String extInterfaceName) {
    Interface extInterfaceState = InterfaceUtils.getInterfaceStateFromOperDS(dataBroker, extInterfaceName);
    if (extInterfaceState == null) {
        LOG.debug("No interface state found for interface {}. Delaying responder flows for {}", extInterfaceName, id);
        return;
    }
    Integer lportTag = extInterfaceState.getIfIndex();
    if (lportTag == null) {
        LOG.debug("No Lport tag found for interface {}. Delaying flows for router-id {}", extInterfaceName, id);
        return;
    }
    if (macAddress == null) {
        LOG.debug("Failed to install arp responder flows for router-gateway-ip {} for router {}." + "External Gw MacAddress is missing.", fixedIps, id);
        return;
    }
    addArpResponderFlowsToExternalNetworkIps(id, fixedIps, macAddress, dpnId, extInterfaceName, lportTag, writeTx);
}
Also used : BigInteger(java.math.BigInteger) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)

Example 22 with FixedIps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps in project netvirt by opendaylight.

the class VpnManagerImpl method addArpResponderFlowsToExternalNetworkIps.

@Override
public void addArpResponderFlowsToExternalNetworkIps(String id, Collection<String> fixedIps, String macAddress, BigInteger dpnId, Uuid extNetworkId, WriteTransaction writeTx) {
    if (dpnId == null || BigInteger.ZERO.equals(dpnId)) {
        LOG.warn("Failed to install arp responder flows for router {}. DPN id is missing.", id);
        return;
    }
    String extInterfaceName = elanService.getExternalElanInterface(extNetworkId.getValue(), dpnId);
    if (extInterfaceName != null) {
        doAddArpResponderFlowsToExternalNetworkIps(id, fixedIps, macAddress, dpnId, extNetworkId, writeTx, extInterfaceName);
        return;
    }
    LOG.warn("Failed to install responder flows for {}. No external interface found for DPN id {}", id, dpnId);
    if (!upgradeState.isUpgradeInProgress()) {
        return;
    }
    // The following through the end of the function deals with an upgrade scenario where the neutron configuration
    // is restored before the OVS switches reconnect. In such a case, the elan-dpn-interfaces entries will be
    // missing from the operational data store. In order to mitigate this we use DataTreeEventCallbackRegistrar
    // to wait for the exact operational md-sal object we need to contain the external interface we need.
    LOG.info("Upgrade in process, waiting for an external interface to appear on dpn {} for elan {}", dpnId, extNetworkId.getValue());
    InstanceIdentifier<DpnInterfaces> dpnInterfacesIid = elanService.getElanDpnInterfaceOperationalDataPath(extNetworkId.getValue(), dpnId);
    eventCallbacks.onAddOrUpdate(LogicalDatastoreType.OPERATIONAL, dpnInterfacesIid, (unused, alsoUnused) -> {
        LOG.info("Reattempting write of arp responder for external interfaces for external network {}", extNetworkId);
        DpnInterfaces dpnInterfaces = elanService.getElanInterfaceInfoByElanDpn(extNetworkId.getValue(), dpnId);
        if (dpnInterfaces == null) {
            LOG.error("Could not retrieve DpnInterfaces for {}, {}", extNetworkId.getValue(), dpnId);
            return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
        }
        String extIfc = null;
        for (String dpnInterface : dpnInterfaces.getInterfaces()) {
            if (interfaceManager.isExternalInterface(dpnInterface)) {
                extIfc = dpnInterface;
                break;
            }
        }
        if (extIfc == null) {
            if (upgradeState.isUpgradeInProgress()) {
                LOG.info("External interface not found yet in elan {} on dpn {}, keep waiting", extNetworkId.getValue(), dpnInterfaces);
                return DataTreeEventCallbackRegistrar.NextAction.CALL_AGAIN;
            } else {
                return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
            }
        }
        final String extIfcFinal = extIfc;
        ListenableFuture<Void> listenableFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
            doAddArpResponderFlowsToExternalNetworkIps(id, fixedIps, macAddress, dpnId, extNetworkId, tx, extIfcFinal);
        });
        ListenableFutures.addErrorLogging(listenableFuture, LOG, "Error while configuring arp responder for ext. interface");
        return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
    });
}
Also used : DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces)

Example 23 with FixedIps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps in project netvirt by opendaylight.

the class SubnetRouteInterfaceStateChangeListener method getSubnetId.

@Nonnull
protected List<Uuid> getSubnetId(Interface intrf) {
    List<Uuid> listSubnetIds = new ArrayList<>();
    if (!NeutronUtils.isUuid(intrf.getName())) {
        LOG.debug("SubnetRouteInterfaceListener: Interface {} doesn't have valid uuid pattern", intrf.getName());
        return listSubnetIds;
    }
    PortOpDataEntry portOpEntry = subOpDpnManager.getPortOpDataEntry(intrf.getName());
    if (portOpEntry != null) {
        List<Uuid> subnet = portOpEntry.getSubnetIds();
        if (subnet != null) {
            return subnet;
        }
        return listSubnetIds;
    }
    LOG.trace("SubnetRouteInterfaceListener : Received Port {} event for {} that is not part of subnetRoute", intrf.getOperStatus(), intrf.getName());
    Port port = neutronVpnManager.getNeutronPort(intrf.getName());
    if (port == null) {
        return listSubnetIds;
    }
    List<FixedIps> portIps = port.getFixedIps();
    if (port.getFixedIps() != null) {
        for (FixedIps portIp : portIps) {
            listSubnetIds.add(portIp.getSubnetId());
        }
    }
    return listSubnetIds;
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) PortOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.port.op.data.PortOpDataEntry) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) ArrayList(java.util.ArrayList) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) Nonnull(javax.annotation.Nonnull)

Example 24 with FixedIps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps in project netvirt by opendaylight.

the class IfMgr method updateRouterIntf.

public void updateRouterIntf(Uuid portId, Uuid rtrId, List<FixedIps> fixedIpsList) {
    LOG.info("updateRouterIntf portId {}, fixedIpsList {} ", portId, fixedIpsList);
    VirtualPort intf = getPort(portId);
    if (intf == null) {
        LOG.info("Skip Router interface update for non-ipv6 port {}", portId);
        return;
    }
    List<Ipv6Address> existingIPv6AddressList = intf.getIpv6AddressesWithoutLLA();
    List<Ipv6Address> newlyAddedIpv6AddressList = new ArrayList<>();
    intf.clearSubnetInfo();
    for (FixedIps fip : fixedIpsList) {
        IpAddress fixedIp = fip.getIpAddress();
        if (fixedIp.getIpv4Address() != null) {
            continue;
        }
        // Save the interface ipv6 address in its fully expanded format
        Ipv6Address addr = new Ipv6Address(InetAddresses.forString(fixedIp.getIpv6Address().getValue()).getHostAddress());
        fixedIp = new IpAddress(addr);
        Uuid subnetId = fip.getSubnetId();
        intf.setSubnetInfo(subnetId, fixedIp);
        VirtualRouter rtr = getRouter(rtrId);
        VirtualSubnet snet = getSubnet(subnetId);
        if (rtr != null && snet != null) {
            snet.setRouter(rtr);
            intf.setSubnet(subnetId, snet);
            rtr.addSubnet(snet);
        } else if (snet != null) {
            intf.setSubnet(subnetId, snet);
            addUnprocessed(unprocessedRouterIntfs, rtrId, intf);
        } else {
            addUnprocessed(unprocessedRouterIntfs, rtrId, intf);
            addUnprocessed(unprocessedSubnetIntfs, subnetId, intf);
        }
        Uuid networkID = intf.getNetworkID();
        if (networkID != null) {
            vrouterv6IntfMap.put(networkID, intf);
        }
        if (existingIPv6AddressList.contains(fixedIp.getIpv6Address())) {
            existingIPv6AddressList.remove(fixedIp.getIpv6Address());
        } else {
            newlyAddedIpv6AddressList.add(fixedIp.getIpv6Address());
        }
    }
    /* This is a port update event for routerPort. Check if any IPv6 subnet is added
         or removed from the router port. Depending on subnet added/removed, we add/remove
         the corresponding flows from IPV6_TABLE(45).
         */
    for (Ipv6Address ipv6Address : newlyAddedIpv6AddressList) {
        // Some v6 subnets are associated to the routerPort add the corresponding NS Flows.
        programIcmpv6NSPuntFlowForAddress(intf, ipv6Address, Ipv6Constants.ADD_FLOW);
    }
    for (Ipv6Address ipv6Address : existingIPv6AddressList) {
        // Some v6 subnets are disassociated from the routerPort, remove the corresponding NS Flows.
        programIcmpv6NSPuntFlowForAddress(intf, ipv6Address, Ipv6Constants.DEL_FLOW);
    }
}
Also used : IVirtualPort(org.opendaylight.netvirt.ipv6service.api.IVirtualPort) IVirtualSubnet(org.opendaylight.netvirt.ipv6service.api.IVirtualSubnet) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) IVirtualRouter(org.opendaylight.netvirt.ipv6service.api.IVirtualRouter)

Example 25 with FixedIps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps in project netvirt by opendaylight.

the class NeutronPortChangeListener method update.

@Override
protected void update(InstanceIdentifier<Port> identifier, Port original, Port update) {
    if (update.getDeviceOwner().equalsIgnoreCase(Ipv6Constants.NETWORK_ROUTER_GATEWAY)) {
        // Todo: revisit when IPv6 north-south support is implemented.
        LOG.info("IPv6Service (TODO): Skipping router_gateway port {} for update event", update);
        return;
    }
    LOG.debug("update port notification handler is invoked for port {} ", update);
    Set<FixedIps> oldIPs = getFixedIpSet(original.getFixedIps());
    Set<FixedIps> newIPs = getFixedIpSet(update.getFixedIps());
    if (!oldIPs.equals(newIPs)) {
        Boolean portIncludesV6Address = Boolean.FALSE;
        ifMgr.clearAnyExistingSubnetInfo(update.getUuid());
        List<FixedIps> ipList = update.getFixedIps();
        for (FixedIps fixedip : ipList) {
            if (fixedip.getIpAddress().getIpv4Address() != null) {
                continue;
            }
            portIncludesV6Address = Boolean.TRUE;
            addInterfaceInfo(update, fixedip);
        }
        if (update.getDeviceOwner().equalsIgnoreCase(Ipv6Constants.NETWORK_ROUTER_INTERFACE)) {
            ifMgr.updateRouterIntf(update.getUuid(), new Uuid(update.getDeviceId()), update.getFixedIps());
        } else {
            ifMgr.updateHostIntf(update.getUuid(), portIncludesV6Address);
        }
    }
}
Also used : 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)

Aggregations

FixedIps (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps)27 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)20 ArrayList (java.util.ArrayList)17 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)11 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)7 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)6 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)6 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)6 HashSet (java.util.HashSet)5 LearntVpnVipToPort (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort)5 BigInteger (java.math.BigInteger)4 Test (org.junit.Test)4 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)4 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)4 ExecutionException (java.util.concurrent.ExecutionException)3 IpVersionChoice (org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)3 PortBindingExtension (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 Collections (java.util.Collections)2 List (java.util.List)2