+ handleTunnelEventForDPNVpn(stateTunnelList, action, vpnIdRdMap,
+ tunnelAction, isTepDeletedOnDpn,
+ subnetList, TunnelEventProcessingMethod.MANAGEREMOTEROUTES,
+ vpnInterface);
+ }
+ }
+
+ //Iterate over the VpnId-to-Rd map.
+ for (Map.Entry<Long, String> entry : vpnIdRdMap.entrySet()) {
+ Long vpnId = entry.getKey();
+ rd = entry.getValue();
+ if (tunnelAction == TunnelAction.TUNNEL_EP_ADD
+ && tunTypeVal == VpnConstants.ITMTunnelLocType.External.getValue()) {
+ fibManager.populateExternalRoutesOnDpn(srcDpnId, vpnId, rd, srcTepIp, destTepIp);
+ } else if (tunnelAction == TunnelAction.TUNNEL_EP_DELETE
+ && tunTypeVal == VpnConstants.ITMTunnelLocType.External.getValue()) {
+ fibManager.cleanUpExternalRoutesOnDpn(srcDpnId, vpnId, rd, srcTepIp, destTepIp);
+ }
+ }
+ if (listVpnName.size() >= 1) {
+ if (tunnelAction == TunnelAction.TUNNEL_EP_ADD) {
+ for (Uuid subnetId : subnetList) {
+ // Populate the List of subnets
+ vpnSubnetRouteHandler.updateSubnetRouteOnTunnelUpEvent(subnetId, srcDpnId);
+ }
+ }
+ if ((tunnelAction == TunnelAction.TUNNEL_EP_DELETE) && isTepDeletedOnDpn) {
+ for (Uuid subnetId : subnetList) {
+ // Populate the List of subnets
+ vpnSubnetRouteHandler.updateSubnetRouteOnTunnelDownEvent(subnetId, srcDpnId);
+ }
+ }
+ }
+ } catch (RuntimeException e) {
+ LOG.error("handleTunnelEventForDpn: Unable to handle the tunnel event for srcDpnId {} srcTepIp {}"
+ + " remoteDpnId {} destTepIp {}", srcDpnId, srcTepIp, remoteDpnId, destTepIp, e);
+ }
+ }
+
+ // TODO Clean up the exception handling
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ private void handleTunnelEventForDPNVpn(StateTunnelList stateTunnelList, UpdateRouteAction action,
+ Map<Long, String> vpnIdRdMap, TunnelAction tunnelAction,
+ boolean isTepDeletedOnDpn, List<Uuid> subnetList,
+ TunnelEventProcessingMethod method,
+ VpnInterface cfgVpnInterface) {
+ String rd;
+ String intfName = cfgVpnInterface.getName();
+ final BigInteger srcDpnId = new BigInteger(stateTunnelList.getSrcInfo().getTepDeviceId());
+ String destTepIp = String.valueOf(stateTunnelList.getDstInfo().getTepIp().getValue());
+ String srcTepIp = String.valueOf(stateTunnelList.getSrcInfo().getTepIp().getValue());
+ int tunTypeVal = getTunnelType(stateTunnelList);
+ BigInteger remoteDpnId = null;
+ if (tunTypeVal == VpnConstants.ITMTunnelLocType.Internal.getValue()) {
+ remoteDpnId = new BigInteger(stateTunnelList.getDstInfo().getTepDeviceId());
+ }
+ if (cfgVpnInterface.getVpnInstanceNames() == null) {
+ LOG.warn("handleTunnelEventForDpn: no vpnName found for interface {}", intfName);
+ return;
+ }
+ for (VpnInstanceNames vpnInstance : cfgVpnInterface.getVpnInstanceNames()) {
+ String vpnName = vpnInstance.getVpnName();
+ if (method == TunnelEventProcessingMethod.POPULATESUBNETS) {
+ Optional<VpnInterfaceOpDataEntry> opVpnInterface = VpnUtil
+ .getVpnInterfaceOpDataEntry(dataBroker, intfName, vpnName);
+ if (opVpnInterface.isPresent() && !opVpnInterface.get().isScheduledForRemove()) {
+ VpnInterfaceOpDataEntry vpnInterface = opVpnInterface.get();