BGP Minor fixes 08/75308/2
authorVyshakh Krishnan CH <vyshakh.krishnan.c.h@ericsson.com>
Sun, 19 Aug 2018 11:14:34 +0000 (16:44 +0530)
committerVivekanandan Narasimhan <vivek.konnect@gmail.com>
Mon, 27 Aug 2018 06:00:48 +0000 (06:00 +0000)
Fix to :

1. set more bits when lot of routes are synced from QBGP
2. handle entity owener ship correctly

Change-Id: If0297b665e3ddc4f835f437bb27173aa9750a154
Signed-off-by: Vyshakh Krishnan CH <vyshakh.krishnan.c.h@ericsson.com>
bgpmanager/impl/src/main/java/org/opendaylight/netvirt/bgpmanager/BgpConfigurationManager.java
bgpmanager/impl/src/main/java/org/opendaylight/netvirt/bgpmanager/thrift/client/BgpRouter.java
bgpmanager/impl/src/main/java/org/opendaylight/netvirt/bgpmanager/thrift/client/BgpSyncHandle.java

index de83f6ab613c697764c8bd24f38dfa4d961c68c7..8b85234ea58667403dbecf152134a859a974f765 100755 (executable)
@@ -149,7 +149,8 @@ public class BgpConfigurationManager {
     private static final String DEF_CHOST = "255.255.255.255"; // Invalid Host IP
     private static final String DEF_CPORT = "7644";
     private static final String DEF_BGP_SDNC_MIP = "127.0.0.1";
-    private static final String BGP_SDNC_MIP = "vpnservice.bgp.thrift.sdnc.mip";
+    //vpnservice.bgp.thrift.bgp.mip is the MIP present with ODL. Here we open 6644 port
+    private static final String BGP_SDNC_MIP = "vpnservice.bgp.thrift.bgp.mip";
     private static final int RESTART_DEFAULT_GR = 90;
     private static final int DS_RETRY_COUNT = 100; //100 retries, each after WAIT_TIME_BETWEEN_EACH_TRY_MILLIS seconds
     private static final long WAIT_TIME_BETWEEN_EACH_TRY_MILLIS = 1000L; //one second sleep after every retry
@@ -251,13 +252,18 @@ public class BgpConfigurationManager {
         ClearBgpCli.setHostAddr(hostStartup);
         bgpRouter = BgpRouter.newInstance(this::getConfig, this::isBGPEntityOwner);
         delayEorSeconds = Integer.parseInt(getProperty(BGP_EOR_DELAY, DEF_BGP_EOR_DELAY));
-        registerCallbacks();
 
         entityOwnershipUtils = new EntityOwnershipUtils(entityOwnershipService);
 
         candidateRegistration = registerEntityCandidate(entityOwnershipService);
         entityListenerRegistration = registerEntityListener(entityOwnershipService);
 
+        /*register callbacks for reactors, shall be called after EoS registration.
+         * as listeners user EoS service to identify Owner node. Listener call-backs
+         * can get triggered immediately after registeration (before EoS register complete)
+        */
+        registerCallbacks();
+
         LOG.info("BGP Configuration manager initialized");
         initer.countDown();
 
@@ -438,6 +444,10 @@ public class BgpConfigurationManager {
     }
 
     public boolean isBGPEntityOwner() {
+        if (entityOwnershipUtils == null) {
+            LOG.error("entityOwnershipUtils is NULL when listener callbacks fired");
+            return false;
+        }
         return entityOwnershipUtils.isEntityOwner(new Entity(BGP_ENTITY_TYPE_FOR_OWNERSHIP, BGP_ENTITY_NAME), 0, 1);
     }
 
@@ -500,6 +510,24 @@ public class BgpConfigurationManager {
             bgpRouter.configServerUpdated();
 
             synchronized (BgpConfigurationManager.this) {
+                Bgp conf = getConfig();
+                if (conf != null) {
+                    AsId asId = conf.getAsId();
+                    if (asId != null) {
+                        long asNum = asId.getLocalAs();
+                        try {
+                            bgpRouter.stopBgp(asNum);
+                            stopBgpCountersTask();
+                            stopBgpAlarmsTask();
+                        } catch (TException | BgpRouterException e) {
+                            LOG.error("{} Delete received exception; {}", YANG_OBJ, DEL_WARN, e);
+                        }
+                    } else {
+                        LOG.debug("bgp as-id is null while removing config-server");
+                    }
+                } else {
+                    LOG.error("Config Null while removing the config-server");
+                }
                 bgpRouter.disconnect();
             }
         }
index 3de29a1e7e6f78fd7e24f48f372de766fc583eab..0afd7afea74a814ba1bc95ec2be903a851d47086 100644 (file)
@@ -478,6 +478,7 @@ public final class BgpRouter {
             return BgpRouterException.BGP_ERR_IN_ITER;
         }
         handle.setState(BgpSyncHandle.INITED);
+        handle.setMore(1);
         return 0;
     }
 
@@ -518,6 +519,7 @@ public final class BgpRouter {
 
         // TODO: receive correct protocol_type here, currently populating with dummy protocol type
         Routes outRoutes = bgpClient.getRoutes(protocol_type.PROTOCOL_ANY, op, winSize, afi);
+        handle.setMore(outRoutes.more);
         if (outRoutes.more == 0) {
             handle.setState(BgpSyncHandle.DONE);
         }
index 705bbf036c46fec832da94760d5b87ee8afa4db0..6549f577116416f109d30a58457437027b13a22f 100644 (file)
@@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory;
 
 public class BgpSyncHandle {
     private static final Logger LOG = LoggerFactory.getLogger(BgpSyncHandle.class);
+    private int more = 1;
 
     public static final int INITED = 1;
     public static final int ITERATING = 2;
@@ -62,4 +63,9 @@ public class BgpSyncHandle {
     public int setState(int newState) {
         return this.state.getAndSet(newState);
     }
+
+    public int setMore(int localMore) {
+        this.more = localMore;
+        return this.more;
+    }
 }