- InstanceIdentifier<VpnToDpnList> srcId =
- VpnUtil.getVpnToDpnListIdentifier(rd, srcDpnId);
- Optional<VpnToDpnList> srcDpnInVpn =
- VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL, srcId);
- if (tunTypeVal == VpnConstants.ITMTunnelLocType.Internal.getValue()) {
- destDpnId = new BigInteger(stateTunnelList.getDstInfo().getTepDeviceId());
- InstanceIdentifier<VpnToDpnList> destId =
- VpnUtil.getVpnToDpnListIdentifier(rd, destDpnId);
- Optional<VpnToDpnList> destDpnInVpn =
- VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL, destId);
- if (!(srcDpnInVpn.isPresent() &&
- destDpnInVpn.isPresent())) {
- LOG.trace(" srcDpn {} - destDPN {}, do not share the VPN {} with rd {}.",
- srcDpnId, destDpnId, vpnInstance.getVpnInstanceName(), rd);
- continue;
- }
+ } catch (Exception e) {
+ LOG.error("handleTunnelEventForDPN: Exception {} when querying for GetDpnInterfaceList"
+ + " for remoteDpnid {} srcTepIp {} destTepIp {}, trace {}", e, remoteDpnId,
+ srcTepIp, destTepIp, e.getStackTrace());
+ }
+ }
+
+ /*
+ * Iterate over the list of VpnInterface for a SrcDpn on which TEP is added or deleted and read the adj.
+ * Update the adjacencies with the updated nexthop.
+ */
+ Iterator<String> interfacelistIter = srcDpninterfacelist.iterator();
+ String intfName = null;
+ List<Uuid> subnetList = new ArrayList<>();
+ Map<Long, String> vpnIdRdMap = new HashMap<>();
+ Set<String> listVpnName = new HashSet<String>();
+
+ while (interfacelistIter.hasNext()) {
+ intfName = interfacelistIter.next();
+ VpnInterface vpnInterface =
+ VpnUtil.getConfiguredVpnInterface(dataBroker, intfName);
+ if (vpnInterface != null) {
+ listVpnName.addAll(VpnHelper
+ .getVpnInterfaceVpnInstanceNamesString(vpnInterface.getVpnInstanceNames()));
+ handleTunnelEventForDPNVpn(stateTunnelList, action, vpnIdRdMap,
+ tunnelAction, isTepDeletedOnDpn,
+ subnetList, TunnelEventProcessingMethod.POPULATESUBNETS,
+ vpnInterface);
+ }
+ }
+ /*
+ * Iterate over the list of VpnInterface for destDPN and get the prefix .
+ * Create remote rule for each of those prefix on srcDPN.
+ */
+ interfacelistIter = destDpninterfacelist.iterator();
+ while (interfacelistIter.hasNext()) {
+ intfName = interfacelistIter.next();
+ VpnInterface vpnInterface =
+ VpnUtil.getConfiguredVpnInterface(dataBroker, intfName);
+ if (vpnInterface != null) {
+ 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);