From c2e14b84e90b6b6226e43467be177f7258375749 Mon Sep 17 00:00:00 2001 From: eupakir Date: Tue, 13 Mar 2018 16:59:50 +0530 Subject: [PATCH] NETVIRT-1144: PNF failure: Ping External Network PNF from Vm Instance 1 The rotuer<->bgpvpn swap procedure was being triggered even for addition of a new adjacency to the vpn-interface, leading to a delay of two seconds(the sleep present in the swap logic) in learning the PNF route. Change-Id: I1178545da1d11dd7635fbdeb7f5848b25d2ade1a Signed-off-by: eupakir --- .../vpnmanager/VpnInterfaceManager.java | 64 ++++++++++--------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java b/vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java index 05528c6d25..39704f6a8d 100755 --- a/vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java +++ b/vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java @@ -1558,38 +1558,40 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase newVpnList = update.getVpnInstanceNames().stream() .map(VpnInstanceNames::getVpnName).collect(Collectors.toList()); oldVpnList.removeAll(newVpnList); - for (String oldVpnName: oldVpnList) { - isSwap = Boolean.TRUE; - LOG.info("handleVpnSwapForVpnInterface: VPN Interface update event - intfName {} remove vpnName {} running" - + " config-driven swap removal", interfaceName, oldVpnName); - removeVpnInterfaceCall(identifier, original, oldVpnName, interfaceName); - LOG.info("handleVpnSwapForVpnInterface: Processed Remove for update on VPNInterface {} upon VPN swap" - + "from old vpn {} to newVpn(s) {}", interfaceName, oldVpnName, newVpnList); - } - //Wait for previous interface bindings to be removed - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - //Ignore - } newVpnList.removeAll(oldVpnListCopy); - for (String newVpnName: newVpnList) { - String primaryRd = VpnUtil.getPrimaryRd(dataBroker, newVpnName); - isSwap = Boolean.TRUE; - if (!VpnUtil.isVpnPendingDelete(dataBroker, primaryRd)) { - LOG.info("handleVpnSwapForVpnInterface: VPN Interface update event - intfName {} onto vpnName {}" - + "running config-driven swap addition", interfaceName, newVpnName); - final Adjacencies origAdjs = original.getAugmentation(Adjacencies.class); - final List oldAdjs = (origAdjs != null && origAdjs.getAdjacency() != null) - ? origAdjs.getAdjacency() : new ArrayList<>(); - final Adjacencies updateAdjs = update.getAugmentation(Adjacencies.class); - final List newAdjs = (updateAdjs != null && updateAdjs.getAdjacency() != null) - ? updateAdjs.getAdjacency() : new ArrayList<>(); - - addVpnInterfaceCall(identifier, update, oldAdjs, newAdjs, newVpnName); - LOG.info("handleVpnSwapForVpnInterface: Processed Add for update on VPNInterface {}" - + "from oldVpn(s) {} to newVpn {} upon VPN swap", - interfaceName, oldVpnListCopy, newVpnName); + if (!oldVpnList.isEmpty() || !newVpnList.isEmpty()) { + for (String oldVpnName: oldVpnList) { + isSwap = Boolean.TRUE; + LOG.info("handleVpnSwapForVpnInterface: VPN Interface update event - intfName {} remove vpnName {}" + + " running config-driven swap removal", interfaceName, oldVpnName); + removeVpnInterfaceCall(identifier, original, oldVpnName, interfaceName); + LOG.info("handleVpnSwapForVpnInterface: Processed Remove for update on VPNInterface {} upon VPN swap" + + "from old vpn {} to newVpn(s) {}", interfaceName, oldVpnName, newVpnList); + } + //Wait for previous interface bindings to be removed + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + //Ignore + } + for (String newVpnName: newVpnList) { + String primaryRd = VpnUtil.getPrimaryRd(dataBroker, newVpnName); + isSwap = Boolean.TRUE; + if (!VpnUtil.isVpnPendingDelete(dataBroker, primaryRd)) { + LOG.info("handleVpnSwapForVpnInterface: VPN Interface update event - intfName {} onto vpnName {}" + + "running config-driven swap addition", interfaceName, newVpnName); + final Adjacencies origAdjs = original.getAugmentation(Adjacencies.class); + final List oldAdjs = (origAdjs != null && origAdjs.getAdjacency() != null) + ? origAdjs.getAdjacency() : new ArrayList<>(); + final Adjacencies updateAdjs = update.getAugmentation(Adjacencies.class); + final List newAdjs = (updateAdjs != null && updateAdjs.getAdjacency() != null) + ? updateAdjs.getAdjacency() : new ArrayList<>(); + + addVpnInterfaceCall(identifier, update, oldAdjs, newAdjs, newVpnName); + LOG.info("handleVpnSwapForVpnInterface: Processed Add for update on VPNInterface {}" + + "from oldVpn(s) {} to newVpn {} upon VPN swap", + interfaceName, oldVpnListCopy, newVpnName); + } } } return isSwap; -- 2.36.6