77#include " netdispatcher.h"
88#include " netlink.h"
99#include " fdbsyncd/fdbsync.h"
10+ #include " warm_restart.h"
1011
1112using namespace std ;
1213using namespace swss ;
@@ -35,6 +36,7 @@ int main(int argc, char **argv)
3536 Selectable *temps;
3637 int ret;
3738 Select s;
39+ SelectableTimer replayCheckTimer (timespec{0 , 0 });
3840
3941 using namespace std ::chrono;
4042
@@ -45,7 +47,29 @@ int main(int argc, char **argv)
4547 if (sync.getRestartAssist ()->isWarmStartInProgress ())
4648 {
4749 sync.getRestartAssist ()->readTablesToMap ();
48- SWSS_LOG_NOTICE (" Starting ReconcileTimer" );
50+
51+ steady_clock::time_point starttime = steady_clock::now ();
52+ while (!sync.isIntfRestoreDone ())
53+ {
54+ duration<double > time_span =
55+ duration_cast<duration<double >>(steady_clock::now () - starttime);
56+ int pasttime = int (time_span.count ());
57+
58+ if (pasttime > INTF_RESTORE_MAX_WAIT_TIME)
59+ {
60+ SWSS_LOG_INFO (" timed-out before all interface data was replayed to kernel!!!" );
61+ throw runtime_error (" fdbsyncd: timedout on interface data replay" );
62+ }
63+ sleep (1 );
64+ }
65+ replayCheckTimer.setInterval (timespec{1 , 0 });
66+ replayCheckTimer.start ();
67+ s.addSelectable (&replayCheckTimer);
68+ }
69+ else
70+ {
71+ sync.getRestartAssist ()->warmStartDisabled ();
72+ sync.m_reconcileDone = true ;
4973 }
5074
5175 netlink.registerGroup (RTNLGRP_LINK);
@@ -67,14 +91,41 @@ int main(int argc, char **argv)
6791 {
6892 s.select (&temps);
6993
70- if (temps == (Selectable *)sync.getFdbStateTable ())
94+ if (temps == (Selectable *)sync.getFdbStateTable ())
7195 {
7296 sync.processStateFdb ();
7397 }
7498 else if (temps == (Selectable *)sync.getCfgEvpnNvoTable ())
7599 {
76100 sync.processCfgEvpnNvo ();
77101 }
102+ else if (temps == &replayCheckTimer)
103+ {
104+ if (sync.getFdbStateTable ()->empty () && sync.getCfgEvpnNvoTable ()->empty ())
105+ {
106+ sync.getRestartAssist ()->appDataReplayed ();
107+ SWSS_LOG_NOTICE (" FDB Replay Complete" );
108+ s.removeSelectable (&replayCheckTimer);
109+
110+ /* Obtain warm-restart timer defined for routing application */
111+ uint32_t warmRestartIval = WarmStart::getWarmStartTimer (" bgp" ," bgp" );
112+ if (warmRestartIval)
113+ {
114+ sync.getRestartAssist ()->setReconcileInterval (warmRestartIval);
115+ }
116+ // Else the interval is already set to default value
117+
118+ // TODO: Optimise the reconcillation time using eoiu - issue#1657
119+ SWSS_LOG_NOTICE (" Starting ReconcileTimer" );
120+ sync.getRestartAssist ()->startReconcileTimer (s);
121+ }
122+ else
123+ {
124+ replayCheckTimer.setInterval (timespec{1 , 0 });
125+ // re-start replay check timer
126+ replayCheckTimer.start ();
127+ }
128+ }
78129 else
79130 {
80131 /*
@@ -88,7 +139,7 @@ int main(int argc, char **argv)
88139 sync.m_reconcileDone = true ;
89140 sync.getRestartAssist ()->stopReconcileTimer (s);
90141 sync.getRestartAssist ()->reconcile ();
91- SWSS_LOG_NOTICE (" VXLAN FDB VNI Reconcillation Complete (Timer) " );
142+ SWSS_LOG_NOTICE (" VXLAN FDB VNI Reconcillation Complete" );
92143 }
93144 }
94145 }
0 commit comments