Search in sources :

Example 86 with Uint64

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

the class NatTepChangeListener method hndlTepDelForSnatInEachRtr.

private void hndlTepDelForSnatInEachRtr(RoutersList router, Uint32 routerId, Uint64 dpnId, String srcTepIp, Boolean isFipExists, ProviderTypes extNwProvType, TypedReadWriteTransaction<Configuration> confTx) throws ExecutionException, InterruptedException {
    /*SNAT :
        1) Elect a new switch as the primary NAPT
        2) Advertise the new routes to BGP for the newly elected TEP IP as the DPN IP
        3) This will make sure old routes are withdrawn and new routes are advertised.
         */
    String routerName = router.getRouter();
    LOG.debug("hndlTepDelForSnatInEachRtr : SNAT -> Trying to clear routes to the External fixed IP associated " + "to the router {}", routerName);
    // Check if this is externalRouter else ignore
    InstanceIdentifier<Routers> extRoutersId = NatUtil.buildRouterIdentifier(routerName);
    Optional<Routers> routerData = Optional.empty();
    try {
        routerData = confTx.read(extRoutersId).get();
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Error retrieving routers {}", extRoutersId, e);
    }
    if (!routerData.isPresent()) {
        LOG.debug("hndlTepDelForSnatInEachRtr : SNAT->Ignoring TEP del for router {} since its not External Router", routerName);
        return;
    }
    // Check if the DPN having the router is the NAPT switch
    Uint64 naptId = NatUtil.getPrimaryNaptfromRouterName(dataBroker, routerName);
    if (naptId == null || naptId.equals(Uint64.ZERO) || !naptId.equals(dpnId)) {
        LOG.error("hndlTepDelForSnatInEachRtr : SNAT -> Ignoring TEP delete for the DPN {} since" + "srcTepIp : {} is NOT a NAPT switch", dpnId, srcTepIp);
        return;
    }
    if (natMode == NatMode.Conntrack) {
        Routers extRouter = routerData.get();
        natServiceManager.notify(confTx, extRouter, null, naptId, dpnId, SnatServiceManager.Action.CNT_ROUTER_DISBL);
        if (extRouter.isEnableSnat()) {
            natServiceManager.notify(confTx, extRouter, null, naptId, dpnId, SnatServiceManager.Action.SNAT_ROUTER_DISBL);
        }
    } else {
        Uuid networkId = routerData.get().getNetworkId();
        if (networkId == null) {
            LOG.error("hndlTepDelForSnatInEachRtr : SNAT -> Ignoring TEP delete for the DPN {} for router {}" + "as external network configuraton is missing", dpnId, routerName);
            return;
        }
        LOG.debug("hndlTepDelForSnatInEachRtr : SNAT->Router {} is associated with ext nw {}", routerId, networkId);
        Uuid bgpVpnUuid = NatUtil.getVpnForRouter(dataBroker, routerName);
        Uint32 bgpVpnId;
        if (bgpVpnUuid == null) {
            LOG.debug("hndlTepDelForSnatInEachRtr : SNAT->Internal VPN-ID {} associated to router {}", routerId, routerName);
            bgpVpnId = routerId;
        } else {
            bgpVpnId = NatUtil.getVpnId(dataBroker, bgpVpnUuid.getValue());
            if (bgpVpnId == NatConstants.INVALID_ID) {
                LOG.error("hndlTepDelForSnatInEachRtr :SNAT->Invalid Private BGP VPN ID returned for routerName {}", routerName);
                return;
            }
        }
        if (!isFipExists) {
            // Remove default entry in FIB to SNAT table
            LOG.debug("NAT Service : Installing default route in FIB on DPN {} for router {} with" + " vpn {}...", dpnId, routerName, bgpVpnId);
            defaultRouteProgrammer.installDefNATRouteInDPN(dpnId, bgpVpnId, routerId, confTx);
        }
        if (routerData.get().isEnableSnat()) {
            LOG.info("hndlTepDelForSnatInEachRtr : SNAT enabled for router {}", routerId);
            Uint32 routerVpnId = routerId;
            if (bgpVpnId != NatConstants.INVALID_ID) {
                LOG.debug("hndlTepDelForSnatInEachRtr : SNAT -> Private BGP VPN ID (Internal BGP VPN ID) {} " + "associated to the router {}", bgpVpnId, routerName);
                routerVpnId = bgpVpnId;
            } else {
                LOG.debug("hndlTepDelForSnatInEachRtr : SNAT -> Internal L3 VPN ID (Router ID) {} " + "associated to the router {}", routerVpnId, routerName);
            }
            // Re-elect the other available switch as the NAPT switch and program the NAT flows.
            String externalVpnName = NatUtil.getAssociatedVPN(dataBroker, routerData.get().getNetworkId());
            NatUtil.removeSNATFromDPN(dataBroker, mdsalManager, idManager, naptSwitchHA, dpnId, routerData.get(), routerId, routerVpnId, externalVpnName, extNwProvType, confTx);
        } else {
            LOG.info("hndlTepDelForSnatInEachRtr : SNAT is not enabled for router {} to handle addDPN event {}", routerId, dpnId);
        }
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers) ExecutionException(java.util.concurrent.ExecutionException) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 87 with Uint64

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

the class NatTepChangeListener method remove.

@Override
public void remove(InstanceIdentifier<TunnelEndPoints> key, TunnelEndPoints tep) {
    /*
         * Whenever the TEP on a given DPNID is removed, this API take care
         * of withdrawing the FIB entries for those Floating-IP existing on this
         * DPN and perform re-election of NAPT Switch for a VRF to which the current
         * DPN is elected as NAPT Switch.
         */
    Uint64 srcDpnId = key.firstIdentifierOf(DPNTEPsInfo.class).firstKeyOf(DPNTEPsInfo.class).getDPNID();
    final String srcTepIp = tep.getIpAddress().stringValue();
    String tunnelType = tep.getTunnelType().getName();
    LOG.debug("NAT Service : Remove Event triggered for Tep on DPN:{} having IP:{} and tunnelType:{}", srcDpnId, srcTepIp, tunnelType);
    handleTepDelForAllRtrs(srcDpnId, srcTepIp);
}
Also used : DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 88 with Uint64

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

the class SNATDefaultRouteProgrammer method addOrDelDefaultFibRouteToSNATForSubnet.

public void addOrDelDefaultFibRouteToSNATForSubnet(Subnets subnet, String networkId, int flowAction, Uint32 vpnId) {
    String providerNet = NatUtil.getElanInstancePhysicalNetwok(networkId, dataBroker);
    Set<Uint64> dpnList = natSwitchCache.getSwitchesConnectedToExternal(providerNet);
    for (Uint64 dpn : dpnList) {
        addOrDelDefaultFibRouteToSNATForSubnetInDpn(subnet, networkId, flowAction, vpnId, dpn);
    }
}
Also used : Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 89 with Uint64

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

the class VxlanGreConntrackBasedSnatService method addTerminatingServiceTblEntryForVxlanGre.

protected void addTerminatingServiceTblEntryForVxlanGre(TypedWriteTransaction<Configuration> confTx, Uint64 dpnId, String routerName, Uint32 routerId, int elanId) {
    LOG.info("installTerminatingServiceTblEntryForVxlanGre : creating entry for" + "Terminating Service Table for switch {}, routerId {}", dpnId, routerId);
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    Uint64 tunnelId = Uint64.valueOf(routerId);
    if (elanManager.isOpenStackVniSemanticsEnforced()) {
        tunnelId = natOverVxlanUtil.getRouterVni(routerName, routerId);
    }
    matches.add(new MatchTunnelId(tunnelId));
    List<ActionInfo> actionsInfos = new ArrayList<>();
    List<NxCtAction> ctActionsList = new ArrayList<>();
    NxCtAction nxCtAction = new ActionNxConntrack.NxNat(0, 0, 0, null, null, 0, 0);
    ctActionsList.add(nxCtAction);
    ActionNxConntrack actionNxConntrack = new ActionNxConntrack(0, 0, elanId, NwConstants.OUTBOUND_NAPT_TABLE, ctActionsList);
    ActionSetFieldMeta actionSetFieldMeta = new ActionSetFieldMeta(MetaDataUtil.getVpnIdMetadata(routerId.longValue()));
    actionsInfos.add(actionSetFieldMeta);
    actionsInfos.add(actionNxConntrack);
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionApplyActions(actionsInfos));
    String flowRef = getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, routerId);
    NatUtil.addFlow(confTx, mdsalManager, dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, flowRef, NatConstants.DEFAULT_TS_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
}
Also used : ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionNxConntrack(org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack) ActionSetFieldMeta(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldMeta) MatchTunnelId(org.opendaylight.genius.mdsalutil.matches.MatchTunnelId) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) NxCtAction(org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack.NxCtAction) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 90 with Uint64

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

the class ElanInterfaceManager method removeLocalBroadcastGroup.

public void removeLocalBroadcastGroup(ElanInstance elanInfo, InterfaceInfo interfaceInfo, TypedReadWriteTransaction<Configuration> deleteFlowGroupTx) throws ExecutionException, InterruptedException {
    Uint64 dpnId = interfaceInfo.getDpId();
    long groupId = ElanUtils.getElanLocalBCGId(elanInfo.getElanTag().toJava());
    LOG.trace("deleted the localBroadCast Group:{}", groupId);
    mdsalManager.removeGroup(deleteFlowGroupTx, dpnId, groupId);
}
Also used : Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Aggregations

Uint64 (org.opendaylight.yangtools.yang.common.Uint64)306 ArrayList (java.util.ArrayList)119 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)104 ExecutionException (java.util.concurrent.ExecutionException)86 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)66 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)65 ManagedNewTransactionRunner (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner)64 ManagedNewTransactionRunnerImpl (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl)64 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)64 Logger (org.slf4j.Logger)63 LoggerFactory (org.slf4j.LoggerFactory)63 Inject (javax.inject.Inject)59 Singleton (javax.inject.Singleton)59 List (java.util.List)58 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)58 CONFIGURATION (org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION)54 Optional (java.util.Optional)49 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)48 Collections (java.util.Collections)48 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)48