From: Chetan Arakere Gowdru Date: Mon, 9 Sep 2019 11:44:19 +0000 (+0530) Subject: Stale Floating IP entry in dpn-op-elements X-Git-Tag: release/magnesium~77 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=29a151ad3ed588b3e54194951b0faa7c4e0614f4;p=netvirt.git Stale Floating IP entry in dpn-op-elements Problem Description: It's been oberserved that the VM's neutron Port is deleted first before floating-ip with which it associated. As a result, when floating-ip-info delete event is triggered, the ifmgr RPC query to get the DPNID first check for ietf-interface config (which is already cleared) and return with empty DpnID. As a result, the flow for clear the DNAT related flows and withdrawal of Floating IP route from vpn-instance-op-data didn't succeeded. Solution: Change are to query the interface-state Oper DS to get the DPNID instead of ifmmgr RPC call. Change-Id: Ic12746e73e62d62b8310d391e51e42d376b465e4 Signed-off-by: Chetan Arakere Gowdru --- diff --git a/natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/FloatingIPListener.java b/natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/FloatingIPListener.java index e10e70799c..ff2d32403f 100644 --- a/natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/FloatingIPListener.java +++ b/natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/FloatingIPListener.java @@ -450,10 +450,14 @@ public class FloatingIPListener extends AsyncDataTreeChangeListenerBase identifier, VpnMap vpnMap) { Uuid vpnUuid = vpnMap.getVpnId(); String vpnName = vpnUuid.getValue(); - vpnMap.getRouterIds().stream() + if (vpnMap.getRouterIds() != null) { + vpnMap.getRouterIds().stream() .filter(router -> !(Objects.equals(router.getRouterId(), vpnUuid))) .forEach(router -> { String routerName = router.getRouterId().getValue(); LOG.info("REMOVE: Router {} is disassociated from Vpn {}", routerName, vpnName); onRouterAssociatedToVpn(vpnName, routerName); }); + } } @Override protected void remove(InstanceIdentifier identifier, VpnMap vpnMap) { Uuid vpnUuid = vpnMap.getVpnId(); String vpnName = vpnUuid.getValue(); - vpnMap.getRouterIds().stream() + if (vpnMap.getRouterIds() != null) { + vpnMap.getRouterIds().stream() .filter(router -> !(Objects.equals(router.getRouterId(), vpnUuid))) .forEach(router -> { String routerName = router.getRouterId().getValue(); LOG.info("REMOVE: Router {} is disassociated from Vpn {}", routerName, vpnName); onRouterDisassociatedFromVpn(vpnName, routerName); }); + } } @Override @@ -101,21 +107,44 @@ public class NatVpnMapsChangeListener extends AsyncDataTreeChangeListenerBase ! original.getRouterIds().contains(router)) + List updatedRouterIdList = updated.getRouterIds(); + List originalRouterIdList = original.getRouterIds(); + List routersAddedList = null; + List routersRemovedList = null; + + if (originalRouterIdList == null && updatedRouterIdList != null) { + routersAddedList = updatedRouterIdList; + } else if (originalRouterIdList != null && updatedRouterIdList != null) { + routersAddedList = updatedRouterIdList.stream() + .filter(routerId -> (!originalRouterIdList.contains(routerId))) + .collect(Collectors.toList()); + } + + if (originalRouterIdList != null && updatedRouterIdList == null) { + routersRemovedList = originalRouterIdList; + } else if (originalRouterIdList != null && updatedRouterIdList != null) { + routersRemovedList = originalRouterIdList.stream() + .filter(routerId -> (!updatedRouterIdList.contains(routerId))) + .collect(Collectors.toList()); + } + + if (routersAddedList != null) { + routersAddedList.stream() .filter(router -> !(Objects.equals(router.getRouterId(), updated.getVpnId()))) .forEach(router -> { String routerName = router.getRouterId().getValue(); onRouterAssociatedToVpn(vpnName, routerName); }); + } - original.getRouterIds().stream() - .filter(router -> ! updated.getRouterIds().contains(router)) + if (routersRemovedList != null) { + routersRemovedList.stream() .filter(router -> !(Objects.equals(router.getRouterId(), original.getVpnId()))) .forEach(router -> { String routerName = router.getRouterId().getValue(); onRouterDisassociatedFromVpn(vpnName, routerName); }); + } } @Override diff --git a/natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/VpnFloatingIpHandler.java b/natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/VpnFloatingIpHandler.java index 12113b409d..548ee48f52 100644 --- a/natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/VpnFloatingIpHandler.java +++ b/natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/internal/VpnFloatingIpHandler.java @@ -343,7 +343,7 @@ public class VpnFloatingIpHandler implements FloatingIPHandler { String rd = NatUtil.getVpnRd(confTx, vpnName); String fibExternalIp = NatUtil.validateAndAddNetworkMask(externalIp); NatUtil.removePrefixFromBGP(bgpManager, fibManager, rd, fibExternalIp, vpnName); - + NatUtil.deletePrefixToInterface(dataBroker, NatUtil.getVpnId(dataBroker, vpnName), fibExternalIp); //Remove custom FIB routes //Future> removeFibEntry(RemoveFibEntryInput input);