Search in sources :

Example 76 with Uint32

use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.

the class SnatExternalRoutersListener method add.

@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public void add(InstanceIdentifier<Routers> identifier, Routers routers) {
    if (natMode != NatMode.Conntrack) {
        return;
    }
    String routerName = routers.getRouterName();
    if (upgradeState.isUpgradeInProgress()) {
        LOG.warn("add event for ext-router {}, but upgrade is in progress.", routerName);
        return;
    }
    LOG.info("add : external router event for {}", routerName);
    Uint32 routerId = NatUtil.getVpnId(dataBroker, routerName);
    NatUtil.createRouterIdsConfigDS(dataBroker, routerId, routerName);
    Uuid bgpVpnUuid = NatUtil.getVpnForRouter(dataBroker, routerName);
    if (bgpVpnUuid != null) {
        // Router associated to BGPVPN, ignoring it.
        return;
    }
    // Allocate Primary NAPTSwitch for this router
    centralizedSwitchScheduler.scheduleCentralizedSwitch(routers);
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Uint32(org.opendaylight.yangtools.yang.common.Uint32)

Example 77 with Uint32

use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.

the class SnatExternalRoutersListener method update.

@Override
public void update(InstanceIdentifier<Routers> identifier, Routers original, Routers update) {
    if (natMode != NatMode.Conntrack) {
        return;
    }
    String routerName = original.getRouterName();
    Uint32 routerId = NatUtil.getVpnId(dataBroker, routerName);
    if (routerId == NatConstants.INVALID_ID) {
        LOG.error("update : external router event - Invalid routerId for routerName {}", routerName);
        return;
    }
    LOG.info("update :called for router {} with originalSNATStatus {} and updatedSNATStatus {}", routerName, original.isEnableSnat(), update.isEnableSnat());
    if (!upgradeState.isUpgradeInProgress()) {
        centralizedSwitchScheduler.updateCentralizedSwitch(original, update);
    }
    if (!Objects.equals(original.getSubnetIds(), update.getSubnetIds()) || !Objects.equals(original.getExternalIps(), update.getExternalIps())) {
        LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, confTx -> natServiceManager.notify(confTx, update, original, null, null, SnatServiceManager.Action.SNAT_ROUTER_UPDATE)), LOG, "error handling external router update");
    }
}
Also used : CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) NatserviceConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.config.rev170206.NatserviceConfig) LoggerFactory(org.slf4j.LoggerFactory) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) Singleton(javax.inject.Singleton) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) NatMode(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.config.rev170206.NatserviceConfig.NatMode) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers) UpgradeState(org.opendaylight.serviceutils.upgrade.UpgradeState) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Logger(org.slf4j.Logger) AbstractAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener) IdManagerService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService) Objects(java.util.Objects) CentralizedSwitchScheduler(org.opendaylight.netvirt.natservice.api.CentralizedSwitchScheduler) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) ExtRouters(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExtRouters) SnatServiceManager(org.opendaylight.netvirt.natservice.api.SnatServiceManager) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) Uint32(org.opendaylight.yangtools.yang.common.Uint32)

Example 78 with Uint32

use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.

the class NatTunnelInterfaceStateListener method hndlTepAddOnNonNaptSwitch.

private boolean hndlTepAddOnNonNaptSwitch(Uint64 srcDpnId, Uint64 primaryDpnId, String tunnelType, String srcTepIp, String destTepIp, String tunnelName, String routerName, Uint32 routerId, Uuid vpnName, TypedWriteTransaction<Configuration> confTx) {
    /*
        1) Install default NAT rule from table 21 to 26
        2) Install the group which forward packet to the tunnel port for the NAPT switch.
        3) Install the flow 26 which forwards the packet to the group.
        */
    LOG.debug("hndlTepAddOnNonNaptSwitch : SNAT -> Processing TEP add for the DPN {} having the router {} since " + "its THE NON NAPT switch for the TUNNEL TYPE {} b/w SRC IP {} and DST IP {} " + "and TUNNEL NAME {} ", srcDpnId, routerName, tunnelType, srcTepIp, destTepIp, tunnelName);
    LOG.debug("hndlTepAddOnNonNaptSwitch : SNAT -> Install default NAT rule from table 21 to 26");
    Uint32 vpnId;
    if (vpnName == null) {
        LOG.debug("hndlTepAddOnNonNaptSwitch : SNAT -> Internal VPN associated to router {}", routerId);
        vpnId = routerId;
        if (vpnId == NatConstants.INVALID_ID) {
            LOG.error("hndlTepAddOnNonNaptSwitch : SNAT -> Invalid Internal VPN ID returned for routerName {}", routerId);
            return false;
        }
        LOG.debug("hndlTepAddOnNonNaptSwitch : SNAT -> Retrieved vpnId {} for router {}", vpnId, routerName);
        // Install default entry in FIB to SNAT table
        LOG.debug("hndlTepAddOnNonNaptSwitch : Installing default route in FIB on DPN {} for router {} with" + " vpn {}...", srcDpnId, routerName, vpnId);
        defaultRouteProgrammer.installDefNATRouteInDPN(srcDpnId, vpnId, confTx);
        LOG.debug("hndlTepAddOnNonNaptSwitch : SNAT -> Install the group which forward packet to the tunnel port " + "for the NAPT switch {} and the flow 26 which forwards to group", primaryDpnId);
        externalRouterListner.handleSwitches(srcDpnId, routerName, routerId, primaryDpnId);
    } else {
        LOG.debug("hndlTepAddOnNonNaptSwitch : SNAT -> External BGP VPN (Private BGP) associated to router {}", routerId);
        vpnId = NatUtil.getVpnId(dataBroker, vpnName.getValue());
        if (vpnId == NatConstants.INVALID_ID) {
            LOG.error("hndlTepAddOnNonNaptSwitch : SNAT -> Invalid Private BGP VPN ID returned for routerName {}", routerId);
            return false;
        }
        if (routerId == NatConstants.INVALID_ID) {
            LOG.error("hndlTepAddOnNonNaptSwitch : SNAT -> Invalid routId returned for routerName {}", routerId);
            return false;
        }
        LOG.debug("hndlTepAddOnNonNaptSwitch : SNAT -> Retrieved vpnId {} for router {}", vpnId, routerId);
        // Install default entry in FIB to SNAT table
        LOG.debug("hndlTepAddOnNonNaptSwitch : Installing default route in FIB on dpn {} for routerId {} " + "with vpnId {}...", srcDpnId, routerId, vpnId);
        defaultRouteProgrammer.installDefNATRouteInDPN(srcDpnId, vpnId, routerId, confTx);
        LOG.debug("hndlTepAddOnNonNaptSwitch : Install group in non NAPT switch {} for router {}", srcDpnId, routerName);
        List<BucketInfo> bucketInfoForNonNaptSwitches = externalRouterListner.getBucketInfoForNonNaptSwitches(srcDpnId, primaryDpnId, routerName, routerId);
        Uint32 groupId = NatUtil.getUniqueId(idManager, NatConstants.SNAT_IDPOOL_NAME, NatUtil.getGroupIdKey(routerName));
        if (groupId != NatConstants.INVALID_ID) {
            externalRouterListner.installGroup(srcDpnId, routerName, groupId, bucketInfoForNonNaptSwitches);
            LOG.debug("hndlTepAddOnNonNaptSwitch : SNAT -> in the SNAT miss entry pointing to group {} " + "in the non NAPT switch {}", groupId, srcDpnId);
            FlowEntity flowEntity = externalRouterListner.buildSnatFlowEntityWithUpdatedVpnId(srcDpnId, routerName, groupId, vpnId);
            mdsalManager.addFlow(confTx, flowEntity);
        } else {
            LOG.error("hndlTepAddOnNonNaptSwitch: Unable to obtain group ID for Key: {}", routerName);
        }
    }
    return true;
}
Also used : BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) Uint32(org.opendaylight.yangtools.yang.common.Uint32) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 79 with Uint32

use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.

the class NatEvpnUtil method getTunnelIdForRouter.

public static Uint64 getTunnelIdForRouter(IdManagerService idManager, DataBroker dataBroker, String routerName, Uint32 routerId) {
    /* Only if the router is part of an L3VPN-Over-VXLAN, Router_lPort_Tag which will be carved out per router
         from 'interfaces' POOL and used as tunnel_id. Otherwise we will continue to use router-id as the tunnel-id
         in the following Flows.

         1) PSNAT_TABLE (on Non-NAPT) -> Send to Remote Group
         2) INTERNAL_TUNNEL_TABLE (on NAPT) -> Send to OUTBOUND_NAPT_TABLE */
    String rd = NatUtil.getVpnRd(dataBroker, routerName);
    Uint32 l3Vni = getL3Vni(dataBroker, rd);
    if (isL3VpnOverVxLan(l3Vni)) {
        Uint32 routerLportTag = NatUtil.getUniqueId(idManager, IfmConstants.IFM_IDPOOL_NAME, routerName);
        if (routerLportTag != NatConstants.INVALID_ID) {
            LOG.trace("getTunnelIdForRouter : Successfully allocated Router_lPort_Tag = {} from ID Manager for " + "Router ID = {}", routerLportTag, routerId);
            return Uint64.valueOf(routerLportTag.longValue());
        } else {
            LOG.warn("getTunnelIdForRouter : Failed to allocate Router_lPort_Tag from ID Manager for Router ID:{} " + "Continue to use router-id as tunnel-id", routerId);
            return Uint64.valueOf(routerId.longValue());
        }
    }
    return Uint64.valueOf(routerId.longValue());
}
Also used : Uint32(org.opendaylight.yangtools.yang.common.Uint32)

Example 80 with Uint32

use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.

the class NatEvpnUtil method releaseLPortTagForRouter.

public static void releaseLPortTagForRouter(DataBroker dataBroker, IdManagerService idManager, String routerName) {
    String rd = NatUtil.getVpnRd(dataBroker, routerName);
    Uint32 l3Vni = NatEvpnUtil.getL3Vni(dataBroker, rd);
    if (!NatEvpnUtil.isL3VpnOverVxLan(l3Vni)) {
        LOG.info("releaseLPortTagForRouter : Router:{} is not part of L3VPNOverVxlan", routerName);
        return;
    }
    if (NatUtil.releaseId(idManager, IfmConstants.IFM_IDPOOL_NAME, routerName) == NatConstants.INVALID_ID) {
        LOG.error("releaseLPortTagForRouter: Unable to release VNI for router {}", routerName);
    }
}
Also used : Uint32(org.opendaylight.yangtools.yang.common.Uint32)

Aggregations

Uint32 (org.opendaylight.yangtools.yang.common.Uint32)394 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)111 ArrayList (java.util.ArrayList)105 ExecutionException (java.util.concurrent.ExecutionException)79 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)68 List (java.util.List)60 Optional (java.util.Optional)52 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)51 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)51 Logger (org.slf4j.Logger)51 LoggerFactory (org.slf4j.LoggerFactory)51 ManagedNewTransactionRunner (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner)49 Inject (javax.inject.Inject)48 Singleton (javax.inject.Singleton)48 Test (org.junit.Test)48 ManagedNewTransactionRunnerImpl (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl)48 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)46 Collections (java.util.Collections)44 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)43 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)38