Bug 7444 : External routes are not getting populated 27/49827/4
authorkarthikeyan <karthikeyan.k@altencalsoftlabs.com>
Tue, 27 Dec 2016 06:05:11 +0000 (11:35 +0530)
committerAlon Kochba <alonko@hpe.com>
Sun, 1 Jan 2017 09:16:52 +0000 (09:16 +0000)
Description:
External routes are not getting populated in fib after recreating vpn and
associating to extnet as well as enable-snat true or false use cases

Solution:

Existing Behaviour:
======================
when disable the SNAT in neutron router, exiting implementation
will get the primary (NAPT) switch id from the DS. When re-enable the
SNAT existing code still it is fetching the primary (NAPT) switch id from
DS. Which leads to get the invalid value (zero) which was set during
disable SNAT.

Changed Behaviour:
====================
When re-enable the SNAT, it invokes the Update() code for re-election process for
getting primary (NAPT) switch id instead of directly querying to DS. Since
DS contains the Invalid (zero) Primary NAPT switch id.

Patch-Set 3: Changes:
==========================
Observed class cast exception when floatingIPHandler.cleanupFibEntries()
method. Changes has been done to declare this method in FloatingIPHandler
Interface to avoid this casting exception.

Change-Id: I8c5cf5fafc79f9933fedbbaad31d9c672696421e
Signed-off-by: karthikeyan <karthikeyan.k@altencalsoftlabs.com>
vpnservice/natservice/natservice-impl/src/main/java/org/opendaylight/netvirt/natservice/internal/ExternalRoutersListener.java
vpnservice/natservice/natservice-impl/src/main/java/org/opendaylight/netvirt/natservice/internal/FloatingIPHandler.java
vpnservice/natservice/natservice-impl/src/main/java/org/opendaylight/netvirt/natservice/internal/FloatingIPListener.java
vpnservice/natservice/natservice-impl/src/main/java/org/opendaylight/netvirt/natservice/internal/VpnFloatingIpHandler.java

index bb663b06021520d7bc5e5fe5aa7c325b28e1e624..c0c60f39cd7ec23f4b1695ae59633fb16aa466cf 100644 (file)
@@ -1094,8 +1094,14 @@ public class ExternalRoutersListener extends AsyncDataTreeChangeListenerBase<Rou
                 List<String> externalIps = NatUtil.getExternalIpsForRouter(dataBroker,routerId);
                 handleDisableSnat(original, networkUuid, externalIps, false, null, dpnId);
             } else {
+                // Allocate Primary Napt Switch for existing router
+                BigInteger primarySwitchId = getPrimaryNaptSwitch(routerName, routerId);
+                if(primarySwitchId == null || primarySwitchId.equals(BigInteger.ZERO)){
+                    LOG.error("NAT Service: Failed to get or allocated NAPT switch in ExternalRouterListener.Update()");
+                    return;
+                }
                 LOG.info("NAT Service : SNAT enabled for Router {}", original.getRouterName());
-                handleEnableSnat(original, routerId, dpnId);
+                handleEnableSnat(original, routerId, primarySwitchId);
             }
         }
 
index ad637869cb639f856db8d8bfc050dbcf15cbd58a..ac631e8285a429996f020c1887f82a0b19cb50fa 100644 (file)
@@ -20,4 +20,5 @@ public interface FloatingIPHandler {
     void onRemoveFloatingIp(BigInteger dpnId, String routerId, Uuid networkId, InternalToExternalPortMap mapping,
                             long label);
 
+    void cleanupFibEntries(final BigInteger dpnId, final String vpnName, final String externalIp, final long label);
 }
index 669898a345d5db4db2239503dfb13973ecc7967b..275dda3d48fabee286efa86e6be40e593cdf4842 100644 (file)
@@ -572,7 +572,7 @@ public class FloatingIPListener extends AsyncDataTreeChangeListenerBase<Internal
             LOG.error("NAT Service : Could not retrieve label for prefix {} in router {}", internalIp, routerId);
             return;
         }
-        ((VpnFloatingIpHandler) floatingIPHandler).cleanupFibEntries(dpnId, vpnName, externalIp, label);
+        floatingIPHandler.cleanupFibEntries(dpnId, vpnName, externalIp, label);
         removeOperationalDS(routerName, interfaceName, internalIp, externalIp);
     }
 
index 713a094043c3adb682557e31530d334e778de857..2399548640ba8cef84fb4a74e125174fd0dc0277 100644 (file)
@@ -230,7 +230,7 @@ public class VpnFloatingIpHandler implements FloatingIPHandler {
         cleanupFibEntries(dpnId, vpnName, externalIp, label);
     }
 
-    void cleanupFibEntries(final BigInteger dpnId, final String vpnName, final String externalIp, final long label ) {
+    public void cleanupFibEntries(final BigInteger dpnId, final String vpnName, final String externalIp, final long label ) {
         //Remove Prefix from BGP
         String rd = NatUtil.getVpnRd(dataBroker, vpnName);
         NatUtil.removePrefixFromBGP(dataBroker, bgpManager, fibManager, rd, externalIp + "/32", LOG);