NETVIRT-1410 Vrf advertised after routes to DC-GW 20/77320/7
authoreupakir <kiran.n.upadhyaya@ericsson.com>
Mon, 29 Oct 2018 13:24:18 +0000 (18:54 +0530)
committerSam Hague <shague@redhat.com>
Thu, 27 Dec 2018 16:39:24 +0000 (16:39 +0000)
On a Router/Network association, the vpn-op update to configure IpFamily
was being done after the creation of Vpn Interfaces. THis was leading to
the Networks being written to bgp before the vrf, causing failure in
advertisement of the route to DC-Gw.
This fix swaps the order of IpFamily update and VPN Interface creation.

Change-Id: I52ebf0b5abd9869dfe1c08b2f2511d0ec8468a02
Signed-off-by: eupakir <kiran.n.upadhyaya@ericsson.com>
fibmanager/impl/src/main/java/org/opendaylight/netvirt/fibmanager/VrfEntryListener.java
neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronvpnManager.java

index e4c2c97997e5a1b764d12cbc8baac742008434f3..75d9beaae7f0c2d08ecb33208b10bbb8fc302db8 100755 (executable)
@@ -1547,10 +1547,13 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                             }
                         }
                     }
-                    nextHopManager.removeNextHopPointer(nextHopManager
-                            .getRemoteSelectGroupKey(vpnInstance.getVpnId(), vrfEntry.getDestPrefix()));
-                    nextHopManager.removeNextHopPointer(nextHopManager
-                            .getLocalSelectGroupKey(vpnInstance.getVpnId(), vrfEntry.getDestPrefix()));
+                    if (extraRouteOptional.isPresent()) {
+                        //Remove select groups only for extra-routes
+                        nextHopManager.removeNextHopPointer(nextHopManager
+                                .getRemoteSelectGroupKey(vpnInstance.getVpnId(), vrfEntry.getDestPrefix()));
+                        nextHopManager.removeNextHopPointer(nextHopManager
+                                .getLocalSelectGroupKey(vpnInstance.getVpnId(), vrfEntry.getDestPrefix()));
+                    }
                 })), MAX_RETRIES);
         }
 
index 57ac08433fb7393d8cb05e33748d70d40c4aa10d..c0098e2fff6f33c443c2526ab60100b579631fa4 100644 (file)
@@ -2298,29 +2298,31 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
     @SuppressWarnings("checkstyle:IllegalCatch")
     protected void associateRouterToVpn(Uuid vpnId, Uuid routerId) {
         updateVpnMaps(vpnId, null, routerId, null, null);
-        LOG.debug("Updating association of subnets to external vpn {}", vpnId.getValue());
-        IpVersionChoice ipVersion = IpVersionChoice.UNDEFINED;
+        LOG.debug("associateRouterToVpn: Updating association of subnets to external vpn {}", vpnId.getValue());
         List<Subnetmap> subMapList = neutronvpnUtils.getNeutronRouterSubnetMapList(routerId);
+        IpVersionChoice ipVersion = IpVersionChoice.UNDEFINED;
         for (Subnetmap sn : subMapList) {
-            updateVpnForSubnet(routerId, vpnId, sn.getId(), true);
             IpVersionChoice ipVers = neutronvpnUtils.getIpVersionFromString(sn.getSubnetIp());
             if (!ipVersion.isIpVersionChosen(ipVers)) {
                 ipVersion = ipVersion.addVersion(ipVers);
             }
         }
         if (ipVersion != IpVersionChoice.UNDEFINED) {
-            LOG.debug("vpnInstanceOpDataEntry is getting update with ip address family {} for VPN {} ", ipVersion,
-                    vpnId);
+            LOG.debug("associateRouterToVpn: Updating vpnInstanceOpDataEntrywith ip address family {} for VPN {} ",
+                    ipVersion, vpnId);
             neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), ipVersion, true);
         }
+        for (Subnetmap sn : subMapList) {
+            updateVpnForSubnet(routerId, vpnId, sn.getId(), true);
+        }
 
         try {
             checkAndPublishRouterAssociatedtoVpnNotification(routerId, vpnId);
-            LOG.debug("notification upon association of router {} to VPN {} published", routerId.getValue(),
-                    vpnId.getValue());
+            LOG.debug("associateRouterToVpn: notification upon association of router {} to VPN {} published",
+                    routerId.getValue(), vpnId.getValue());
         } catch (Exception e) {
-            LOG.error("publishing of notification upon association of router {} to VPN {} failed : ", routerId
-                    .getValue(), vpnId.getValue(), e);
+            LOG.error("associateRouterToVpn: publishing of notification upon association of router {} to VPN {}"
+                    + " failed : ", routerId.getValue(), vpnId.getValue(), e);
         }
     }
 
@@ -2351,22 +2353,23 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
             if (ipVersion.isIpVersionChosen(ipVers)) {
                 ipVersion = ipVersion.addVersion(ipVers);
             }
-            LOG.debug("Updating association of subnets to internal vpn {}", routerId.getValue());
+            LOG.debug("dissociateRouterFromVpn: Updating association of subnets to internal vpn {}",
+                    routerId.getValue());
             updateVpnForSubnet(vpnId, routerId, sn.getId(), false);
         }
         if (ipVersion != IpVersionChoice.UNDEFINED) {
-            LOG.debug("vpnInstanceOpDataEntry is getting update with ip address family {} for VPN {} ",
+            LOG.debug("dissociateRouterFromVpn; Updating vpnInstanceOpDataEntry with ip address family {} for VPN {} ",
                     ipVersion, vpnId);
             neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), ipVersion,
                     false);
         }
         try {
             checkAndPublishRouterDisassociatedFromVpnNotification(routerId, vpnId);
-            LOG.debug("notification upon disassociation of router {} from VPN {} published", routerId.getValue(),
-                    vpnId.getValue());
+            LOG.debug("dissociateRouterFromVpn: notification upon disassociation of router {} from VPN {} published",
+                    routerId.getValue(), vpnId.getValue());
         } catch (Exception e) {
-            LOG.error("publishing of notification upon disassociation of router {} from VPN {} failed : ", routerId
-                    .getValue(), vpnId.getValue(), e);
+            LOG.error("dissociateRouterFromVpn: publishing of notification upon disassociation of router {}"
+                    + " from VPN {} failed : ", routerId.getValue(), vpnId.getValue(), e);
         }
     }
 
@@ -2447,6 +2450,17 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                     continue;
                 }
                 IpVersionChoice ipVersion = IpVersionChoice.UNDEFINED;
+                for (Subnetmap subnetmap : subnetmapList) {
+                    IpVersionChoice ipVers = neutronvpnUtils.getIpVersionFromString(subnetmap.getSubnetIp());
+                    if (!ipVersion.isIpVersionChosen(ipVers)) {
+                        ipVersion = ipVersion.addVersion(ipVers);
+                    }
+                }
+                if (ipVersion != IpVersionChoice.UNDEFINED) {
+                    LOG.debug("associateNetworksToVpn: Updating vpnInstanceOpDataEntry with ip address family {}"
+                            + " for VPN {} ", ipVersion, vpnId);
+                    neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), ipVersion, true);
+                }
                 for (Subnetmap subnetmap : subnetmapList) {
                     Uuid subnetId = subnetmap.getId();
                     Uuid subnetVpnId = neutronvpnUtils.getVpnForSubnet(subnetId);
@@ -2457,10 +2471,6 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                                 + " as it is already associated", subnetId.getValue(), vpnId.getValue()));
                         continue;
                     }
-                    IpVersionChoice ipVers = neutronvpnUtils.getIpVersionFromString(subnetmap.getSubnetIp());
-                    if (!ipVersion.isIpVersionChosen(ipVers)) {
-                        ipVersion = ipVersion.addVersion(ipVers);
-                    }
                     if (!NeutronvpnUtils.getIsExternal(network)) {
                         LOG.debug("associateNetworksToVpn: Add subnet {} to VPN {}", subnetId.getValue(),
                                 vpnId.getValue());
@@ -2470,11 +2480,6 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                         passedNwList.add(nw);
                     }
                 }
-                if (ipVersion != IpVersionChoice.UNDEFINED) {
-                    LOG.debug("vpnInstanceOpDataEntry is getting update with ip address family {} for VPN {} ",
-                            ipVersion, vpnId);
-                    neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), ipVersion, true);
-                }
                 passedNwList.add(nw);
             }
         } catch (ReadFailedException e) {
@@ -2607,14 +2612,14 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 }
             }
             if (ipVersion != IpVersionChoice.UNDEFINED) {
-                LOG.debug("vpnInstanceOpDataEntry is getting update with ip address family {} for VPN {}",
-                        ipVersion, vpnId);
+                LOG.debug("dissociateNetworksFromVpn: Updating vpnInstanceOpDataEntryupdate with ip address family {}"
+                        + " for VPN {}", ipVersion, vpnId);
                 neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), ipVersion, false);
             }
         }
         clearFromVpnMaps(vpnId, null, new ArrayList<>(passedNwList));
-        LOG.info("Network(s) {} disassociated from L3VPN {} successfully", passedNwList.toString(),
-                vpnId.getValue());
+        LOG.info("dissociateNetworksFromVpn: Network(s) {} disassociated from L3VPN {} successfully",
+                passedNwList.toString(), vpnId.getValue());
         return failedNwList;
     }