Search in sources :

Example 36 with Other

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project netvirt by opendaylight.

the class VPNServiceChainHandler method programScfToVpnPipeline.

/**
 * L3VPN Service chaining: It moves traffic from a ServiceChain to a L3VPN.
 *
 * @param vpnName Vpn Instance Name. Typicall the UUID
 * @param scfTag ServiceChainForwarding Tag
 * @param servChainTag ServiceChain Tag
 * @param dpnId DpnId in which the egress pseudo logical port belongs
 * @param vpnPseudoLportTag VpnPseudo Logical port tag
 * @param isLastServiceChain Flag stating if there is no other ServiceChain
 *        using this VpnPseudoPort
 * @param addOrRemove States if pipeline must be installed or removed
 */
public void programScfToVpnPipeline(String vpnName, long scfTag, int servChainTag, long dpnId, int vpnPseudoLportTag, boolean isLastServiceChain, int addOrRemove) {
    // These Flows must be installed in the DPN where the last SF in the ServiceChain is located
    // + ScForwardingTable (75):  (This one is created and maintained by ScHopManager)
    // - Match:  scfTag + servChainId + lportTagOfvVSF    Instr: VpnPseudoPortTag + SI=L3VPN + GOTO LPortDisp
    // And these 2 flows must be installed in all Dpns where the Vpn is present:
    // + LPortDisp (17):
    // - Match:  VpnPseudoPortTag + SI==L3VPN    Instr: setVpnTag + GOTO FIB
    // + FIB (21): (one entry per VrfEntry, and it is maintained by FibManager)
    // - Match:  vrfTag==vpnTag + eth_type=IPv4  + dst_ip   Instr:  Output DC-GW
    // 
    LOG.info("L3VPN: Service Chaining programScfToVpnPipeline [Started]: Parameters Vpn Name: {} ", vpnName);
    String rd = VpnServiceChainUtils.getVpnRd(dataBroker, vpnName);
    if (rd == null || rd.isEmpty()) {
        LOG.warn("programScfToVpnPipeline: Could not find Router-distinguisher for VPN {}. No further actions", vpnName);
        return;
    }
    VpnInstanceOpDataEntry vpnInstance = getVpnInstance(rd);
    LOG.debug("programScfToVpnPipeline: rd={}, lportTag={} ", rd, vpnPseudoLportTag);
    // Find out the set of DPNs for the given VPN ID
    if (vpnInstance != null) {
        if (addOrRemove == NwConstants.ADD_FLOW || addOrRemove == NwConstants.DEL_FLOW && isLastServiceChain) {
            Long vpnId = vpnInstance.getVpnId();
            List<VpnToDpnList> vpnToDpnList = vpnInstance.getVpnToDpnList();
            if (vpnToDpnList != null) {
                List<BigInteger> dpns = new ArrayList<>();
                for (VpnToDpnList dpnInVpn : vpnToDpnList) {
                    dpns.add(dpnInVpn.getDpnId());
                }
                if (!dpns.contains(BigInteger.valueOf(dpnId))) {
                    LOG.debug("Dpn {} is not included in the current VPN Footprint", dpnId);
                    dpns.add(BigInteger.valueOf(dpnId));
                }
                for (BigInteger dpn : dpns) {
                    VpnServiceChainUtils.programLPortDispatcherFlowForScfToVpn(mdsalManager, vpnId, dpn, vpnPseudoLportTag, addOrRemove);
                }
            } else {
                LOG.debug("Could not find VpnToDpn list for VPN {} with rd {}", vpnName, rd);
            }
        }
        // We need to keep a fake VpnInterface in the DPN where the last vSF (before the VpnPseudoPort) is
        // located, because in case the last real VpnInterface is removed from that DPN, we still need
        // the Fib table programmed there
        String intfName = VpnServiceChainUtils.buildVpnPseudoPortIfName(dpnId, scfTag, servChainTag, vpnPseudoLportTag);
        vpnFootprintService.updateVpnToDpnMapping(BigInteger.valueOf(dpnId), vpnName, rd, intfName, null, /*ipAddressSourceValuePair*/
        addOrRemove == NwConstants.ADD_FLOW);
    }
    LOG.info("L3VPN: Service Chaining programScfToVpnPipeline [End]");
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger)

Example 37 with Other

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project netvirt by opendaylight.

the class NatTunnelInterfaceStateListener method hndlTepDelForSnatInEachRtr.

private void hndlTepDelForSnatInEachRtr(RoutersList router, long routerId, BigInteger dpnId, String tunnelType, String srcTepIp, String destTepIp, String tunnelName, ProviderTypes extNwProvType, WriteTransaction writeFlowInvTx) {
    /*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 = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, extRoutersId);
    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
    BigInteger naptId = NatUtil.getPrimaryNaptfromRouterName(dataBroker, routerName);
    if (naptId == null || naptId.equals(BigInteger.ZERO) || !naptId.equals(dpnId)) {
        LOG.warn("hndlTepDelForSnatInEachRtr : SNAT -> Ignoring TEP delete for the DPN {} since" + " its NOT a NAPT switch for the TUNNEL TYPE {} b/w SRC IP {} and DST IP {} and" + "TUNNEL NAME {} ", dpnId, tunnelType, srcTepIp, destTepIp, tunnelName);
        return;
    }
    if (natMode == NatMode.Conntrack) {
        natServiceManager.notify(routerData.get(), 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 {} having the router {} " + "since the Router instance {} not found in ExtRouters model b/w SRC IP {} and DST " + "IP {} and TUNNEL NAME {} ", dpnId, routerData.get().getRouterName(), tunnelType, srcTepIp, destTepIp, tunnelName);
            return;
        }
        LOG.debug("hndlTepDelForSnatInEachRtr : SNAT->Router {} is associated with ext nw {}", routerId, networkId);
        Uuid bgpVpnUuid = NatUtil.getVpnForRouter(dataBroker, routerName);
        Long bgpVpnId;
        if (bgpVpnUuid == null) {
            LOG.debug("hndlTepDelForSnatInEachRtr : SNAT->Internal VPN-ID {} associated to router {}", routerId, routerName);
            bgpVpnId = routerId;
            // Install default entry in FIB to SNAT table
            LOG.debug("hndlTepDelForSnatInEachRtr : Installing default route in FIB on DPN {} for router {} with" + " vpn {}...", dpnId, routerName, bgpVpnId);
            defaultRouteProgrammer.installDefNATRouteInDPN(dpnId, bgpVpnId, writeFlowInvTx);
        } 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;
            }
            LOG.debug("hndlTepDelForSnatInEachRtr :SNAT->External BGP VPN (Private BGP) {} associated to router {}", bgpVpnId, routerName);
            // Install default entry in FIB to SNAT table
            LOG.debug("hndlTepDelForSnatInEachRtr : Installing default route in FIB on dpn {} for routerId {} " + "with vpnId {}...", dpnId, routerId, bgpVpnId);
            defaultRouteProgrammer.installDefNATRouteInDPN(dpnId, bgpVpnId, routerId, writeFlowInvTx);
        }
        if (routerData.get().isEnableSnat()) {
            LOG.info("hndlTepDelForSnatInEachRtr : SNAT enabled for router {}", routerId);
            long 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.
            removeSNATFromDPN(dpnId, routerName, routerId, routerVpnId, networkId, extNwProvType, writeFlowInvTx);
        } 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) BigInteger(java.math.BigInteger)

Example 38 with Other

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project netvirt by opendaylight.

the class NatUtil method checkForRoutersWithSameExtNetAndNaptSwitch.

public static boolean checkForRoutersWithSameExtNetAndNaptSwitch(DataBroker broker, Uuid networkId, String routerName, BigInteger dpnId) {
    InstanceIdentifier<Networks> id = buildNetworkIdentifier(networkId);
    Optional<Networks> networkData = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, id);
    if (networkData != null && networkData.isPresent()) {
        List<Uuid> routerUuidList = networkData.get().getRouterIds();
        if (routerUuidList != null && !routerUuidList.isEmpty()) {
            for (Uuid routerUuid : routerUuidList) {
                String sharedRouterName = routerUuid.getValue();
                if (!routerName.equals(sharedRouterName)) {
                    BigInteger swtichDpnId = NatUtil.getPrimaryNaptfromRouterName(broker, sharedRouterName);
                    if (swtichDpnId == null) {
                        continue;
                    } else if (swtichDpnId.equals(dpnId)) {
                        LOG.debug("checkForRoutersWithSameExtNetAndNaptSwitch: external-network {} is " + "associated with other active router {} on NAPT switch {}", networkId, sharedRouterName, swtichDpnId);
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : Networks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.Networks) ExternalNetworks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalNetworks) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) BigInteger(java.math.BigInteger)

Example 39 with Other

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project netvirt by opendaylight.

the class NaptEventHandler method handleEvent.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void handleEvent(final NAPTEntryEvent naptEntryEvent) {
    /*
            Flow programming logic of the OUTBOUND NAPT TABLE :
            1) Get the internal IP address, port number, router ID from the event.
            2) Use the NAPT service getExternalAddressMapping() to get the External IP and the port.
            3) Build the flow for replacing the Internal IP and port with the External IP and port.
              a) Write the matching criteria.
              b) Match the router ID in the metadata.
              d) Write the VPN ID to the metadata.
              e) Write the other data.
              f) Set the apply actions instruction with the action setfield.
            4) Write the flow to the OUTBOUND NAPT Table and forward to FIB table for routing the traffic.

            Flow programming logic of the INBOUND NAPT TABLE :
            Same as Outbound table logic except that :
            1) Build the flow for replacing the External IP and port with the Internal IP and port.
            2) Match the VPN ID in the metadata.
            3) Write the router ID to the metadata.
            5) Write the flow to the INBOUND NAPT Table and forward to FIB table for routing the traffic.
    */
    try {
        Long routerId = naptEntryEvent.getRouterId();
        LOG.trace("handleEvent : Time Elapsed before procesing snat ({}:{}) packet is {} ms," + "routerId: {},isPktProcessed:{}", naptEntryEvent.getIpAddress(), naptEntryEvent.getPortNumber(), System.currentTimeMillis() - naptEntryEvent.getObjectCreationTime(), routerId, naptEntryEvent.isPktProcessed());
        // Get the DPN ID
        BigInteger dpnId = NatUtil.getPrimaryNaptfromRouterId(dataBroker, routerId);
        long bgpVpnId = NatConstants.INVALID_ID;
        if (dpnId == null) {
            LOG.warn("handleEvent : dpnId is null. Assuming the router ID {} as the BGP VPN ID and proceeding....", routerId);
            bgpVpnId = routerId;
            LOG.debug("handleEvent : BGP VPN ID {}", bgpVpnId);
            String vpnName = NatUtil.getRouterName(dataBroker, bgpVpnId);
            String routerName = NatUtil.getRouterIdfromVpnInstance(dataBroker, vpnName);
            if (routerName == null) {
                LOG.error("handleEvent : Unable to find router for VpnName {}", vpnName);
                return;
            }
            routerId = NatUtil.getVpnId(dataBroker, routerName);
            LOG.debug("handleEvent : Router ID {}", routerId);
            dpnId = NatUtil.getPrimaryNaptfromRouterId(dataBroker, routerId);
            if (dpnId == null) {
                LOG.error("handleEvent : dpnId is null for the router {}", routerId);
                return;
            }
        }
        if (naptEntryEvent.getOperation() == NAPTEntryEvent.Operation.ADD) {
            LOG.debug("handleEvent : Inside Add operation of NaptEventHandler");
            // Build and install the NAPT translation flows in the Outbound and Inbound NAPT tables
            if (!naptEntryEvent.isPktProcessed()) {
                // Get the External Gateway MAC Address
                String extGwMacAddress = NatUtil.getExtGwMacAddFromRouterId(dataBroker, routerId);
                if (extGwMacAddress != null) {
                    LOG.debug("handleEvent : External Gateway MAC address {} found for External Router ID {}", extGwMacAddress, routerId);
                } else {
                    LOG.error("handleEvent : No External Gateway MAC address found for External Router ID {}", routerId);
                    return;
                }
                // Get the external network ID from the ExternalRouter model
                Uuid networkId = NatUtil.getNetworkIdFromRouterId(dataBroker, routerId);
                if (networkId == null) {
                    LOG.error("handleEvent : networkId is null");
                    return;
                }
                // Get the VPN ID from the ExternalNetworks model
                Uuid vpnUuid = NatUtil.getVpnIdfromNetworkId(dataBroker, networkId);
                if (vpnUuid == null) {
                    LOG.error("handleEvent : vpnUuid is null");
                    return;
                }
                Long vpnId = NatUtil.getVpnId(dataBroker, vpnUuid.getValue());
                // Get the internal IpAddress, internal port number from the event
                String internalIpAddress = naptEntryEvent.getIpAddress();
                int internalPort = naptEntryEvent.getPortNumber();
                SessionAddress internalAddress = new SessionAddress(internalIpAddress, internalPort);
                NAPTEntryEvent.Protocol protocol = naptEntryEvent.getProtocol();
                // Get the external IP address for the corresponding internal IP address
                SessionAddress externalAddress = naptManager.getExternalAddressMapping(routerId, internalAddress, naptEntryEvent.getProtocol());
                if (externalAddress == null) {
                    LOG.error("handleEvent : externalAddress is null");
                    return;
                }
                Long vpnIdFromExternalSubnet = getVpnIdFromExternalSubnet(routerId, externalAddress.getIpAddress());
                if (vpnIdFromExternalSubnet != NatConstants.INVALID_ID) {
                    vpnId = vpnIdFromExternalSubnet;
                }
                // Added External Gateway MAC Address
                Future<RpcResult<AddFlowOutput>> addFlowResult = buildAndInstallNatFlowsOptionalRpc(dpnId, NwConstants.INBOUND_NAPT_TABLE, vpnId, routerId, bgpVpnId, externalAddress, internalAddress, protocol, extGwMacAddress, true);
                final BigInteger finalDpnId = dpnId;
                final Long finalVpnId = vpnId;
                final Long finalRouterId = routerId;
                final long finalBgpVpnId = bgpVpnId;
                Futures.addCallback(JdkFutureAdapters.listenInPoolThread(addFlowResult), new FutureCallback<RpcResult<AddFlowOutput>>() {

                    @Override
                    public void onSuccess(@Nullable RpcResult<AddFlowOutput> result) {
                        LOG.debug("handleEvent : Configured inbound rule for {} to {}", internalAddress, externalAddress);
                        Future<RpcResult<AddFlowOutput>> addFlowResult = buildAndInstallNatFlowsOptionalRpc(finalDpnId, NwConstants.OUTBOUND_NAPT_TABLE, finalVpnId, finalRouterId, finalBgpVpnId, internalAddress, externalAddress, protocol, extGwMacAddress, true);
                        Futures.addCallback(JdkFutureAdapters.listenInPoolThread(addFlowResult), new FutureCallback<RpcResult<AddFlowOutput>>() {

                            @Override
                            public void onSuccess(@Nullable RpcResult<AddFlowOutput> result) {
                                LOG.debug("handleEvent : Configured outbound rule, sending packet out" + "from {} to {}", internalAddress, externalAddress);
                                prepareAndSendPacketOut(naptEntryEvent, finalRouterId);
                            }

                            @Override
                            public void onFailure(@Nonnull Throwable throwable) {
                                LOG.error("handleEvent : Error configuring outbound " + "SNAT flows using RPC for SNAT connection from {} to {}", internalAddress, externalAddress);
                            }
                        }, MoreExecutors.directExecutor());
                    }

                    @Override
                    public void onFailure(@Nonnull Throwable throwable) {
                        LOG.error("handleEvent : Error configuring inbound SNAT flows " + "using RPC for SNAT connection from {} to {}", internalAddress, externalAddress);
                    }
                }, MoreExecutors.directExecutor());
                NatPacketProcessingState state = naptEntryEvent.getState();
                if (state != null) {
                    state.setFlowInstalledTime(System.currentTimeMillis());
                }
            } else {
                prepareAndSendPacketOut(naptEntryEvent, routerId);
            }
            LOG.trace("handleEvent : Time elapsed after Processsing snat ({}:{}) packet: {}ms,isPktProcessed:{} ", naptEntryEvent.getIpAddress(), naptEntryEvent.getPortNumber(), System.currentTimeMillis() - naptEntryEvent.getObjectCreationTime(), naptEntryEvent.isPktProcessed());
        } else {
            LOG.debug("handleEvent : Inside delete Operation of NaptEventHandler");
            removeNatFlows(dpnId, NwConstants.INBOUND_NAPT_TABLE, routerId, naptEntryEvent.getIpAddress(), naptEntryEvent.getPortNumber());
            LOG.info("handleEvent : exited for removeEvent for IP {}, port {}, routerID : {}", naptEntryEvent.getIpAddress(), naptEntryEvent.getPortNumber(), routerId);
        }
    } catch (Exception e) {
        LOG.error("handleEvent :Exception in NaptEventHandler.handleEvent() payload {}", naptEntryEvent, e);
    }
}
Also used : AddFlowOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput) Nonnull(javax.annotation.Nonnull) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) NatPacketProcessingState(org.opendaylight.netvirt.natservice.internal.NaptPacketInHandler.NatPacketProcessingState) UnknownHostException(java.net.UnknownHostException) ExecutionException(java.util.concurrent.ExecutionException) PacketException(org.opendaylight.openflowplugin.libraries.liblldp.PacketException) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) BigInteger(java.math.BigInteger) Future(java.util.concurrent.Future) FutureCallback(com.google.common.util.concurrent.FutureCallback) Nullable(javax.annotation.Nullable)

Example 40 with Other

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project netvirt by opendaylight.

the class VrfEntryListener method update.

@Override
// originalRoutePath is a little dicey - safest to keep the checking even if not needed.
@SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE")
protected void update(InstanceIdentifier<VrfEntry> identifier, VrfEntry original, VrfEntry update) {
    Preconditions.checkNotNull(update, "VrfEntry should not be null or empty.");
    final String rd = identifier.firstKeyOf(VrfTables.class).getRouteDistinguisher();
    LOG.debug("UPDATE: Updating Fib Entries to rd {} prefix {} route-paths {} origin {} old-origin {}", rd, update.getDestPrefix(), update.getRoutePaths(), update.getOrigin(), original.getOrigin());
    // Handle BGP Routes first
    if (RouteOrigin.value(update.getOrigin()) == RouteOrigin.BGP) {
        bgpRouteVrfEntryHandler.updateFlows(identifier, original, update, rd);
        LOG.info("UPDATE: Updated BGP advertised Fib Entry with rd {} prefix {} route-paths {}", rd, update.getDestPrefix(), update.getRoutePaths());
        return;
    }
    if (RouteOrigin.value(update.getOrigin()) == RouteOrigin.STATIC) {
        List<RoutePaths> originalRoutePath = original.getRoutePaths();
        List<RoutePaths> updateRoutePath = update.getRoutePaths();
        LOG.info("UPDATE: Original route-path {} update route-path {} ", originalRoutePath, updateRoutePath);
        // Updates need to be handled for extraroute even if original vrf entry route path is null or
        // updated vrf entry route path is null. This can happen during tunnel events.
        Optional<VpnInstanceOpDataEntry> optVpnInstance = fibUtil.getVpnInstanceOpData(rd);
        List<String> usedRds = new ArrayList<>();
        if (optVpnInstance.isPresent()) {
            usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, optVpnInstance.get().getVpnId(), update.getDestPrefix());
        }
        // has nexthop , route needs to be created on remote Dpns
        if (originalRoutePath == null || originalRoutePath.isEmpty() && updateRoutePath != null && !updateRoutePath.isEmpty() && usedRds.isEmpty()) {
            // TODO(vivek): Though ugly, Not handling this code now, as each
            // tep add event will invoke flow addition
            LOG.trace("Original VRF entry NH is null for destprefix {}. And the prefix is not an extra route." + " This event is IGNORED here.", update.getDestPrefix());
            return;
        }
        // has nexthop empty'ed out, route needs to be removed from remote Dpns
        if (updateRoutePath == null || updateRoutePath.isEmpty() && originalRoutePath != null && !originalRoutePath.isEmpty() && usedRds.isEmpty()) {
            LOG.trace("Original VRF entry had valid NH for destprefix {}. And the prefix is not an extra route." + "This event is IGNORED here.", update.getDestPrefix());
            return;
        }
        // Update the used rds and vpntoextraroute containers only for the deleted nextHops.
        List<String> nextHopsRemoved = FibHelper.getNextHopListFromRoutePaths(original);
        nextHopsRemoved.removeAll(FibHelper.getNextHopListFromRoutePaths(update));
        WriteTransaction writeOperTxn = dataBroker.newWriteOnlyTransaction();
        nextHopsRemoved.parallelStream().forEach(nextHopRemoved -> fibUtil.updateUsedRdAndVpnToExtraRoute(writeOperTxn, nextHopRemoved, rd, update.getDestPrefix()));
        CheckedFuture<Void, TransactionCommitFailedException> operFuture = writeOperTxn.submit();
        try {
            operFuture.get();
        } catch (InterruptedException | ExecutionException e) {
            LOG.error("Exception encountered while submitting operational future for update vrfentry {}", update, e);
        }
        createFibEntries(identifier, update);
        LOG.info("UPDATE: Updated static Fib Entry with rd {} prefix {} route-paths {}", rd, update.getDestPrefix(), update.getRoutePaths());
        return;
    }
    // Handle all other routes only on a cluster reboot
    if (original.equals(update)) {
        // Reboot use-case
        createFibEntries(identifier, update);
        LOG.info("UPDATE: Updated Non-static Fib Entry with rd {} prefix {} route-paths {}", rd, update.getDestPrefix(), update.getRoutePaths());
        return;
    }
    LOG.info("UPDATE: Ignoring update for FIB entry with rd {} prefix {} route-origin {} route-paths {}", rd, update.getDestPrefix(), update.getOrigin(), update.getRoutePaths());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) ExecutionException(java.util.concurrent.ExecutionException) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

ArrayList (java.util.ArrayList)26 BigInteger (java.math.BigInteger)23 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)13 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)10 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)8 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)7 ExecutionException (java.util.concurrent.ExecutionException)6 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)6 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Test (org.junit.Test)4 L2vlan (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan)4 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)4 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)4 VrfTablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4 HashSet (java.util.HashSet)3 List (java.util.List)3 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)3