7
7
#include " netdispatcher.h"
8
8
#include " netlink.h"
9
9
#include " fdbsyncd/fdbsync.h"
10
+ #include " warm_restart.h"
10
11
11
12
using namespace std ;
12
13
using namespace swss ;
@@ -35,6 +36,7 @@ int main(int argc, char **argv)
35
36
Selectable *temps;
36
37
int ret;
37
38
Select s;
39
+ SelectableTimer replayCheckTimer (timespec {0 , 0 });
38
40
39
41
using namespace std ::chrono;
40
42
@@ -45,7 +47,29 @@ int main(int argc, char **argv)
45
47
if (sync .getRestartAssist ()->isWarmStartInProgress ())
46
48
{
47
49
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 ;
49
73
}
50
74
51
75
netlink.registerGroup (RTNLGRP_LINK);
@@ -67,14 +91,41 @@ int main(int argc, char **argv)
67
91
{
68
92
s.select (&temps);
69
93
70
- if (temps == (Selectable *)sync .getFdbStateTable ())
94
+ if (temps == (Selectable *)sync .getFdbStateTable ())
71
95
{
72
96
sync .processStateFdb ();
73
97
}
74
98
else if (temps == (Selectable *)sync .getCfgEvpnNvoTable ())
75
99
{
76
100
sync .processCfgEvpnNvo ();
77
101
}
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
+ }
78
129
else
79
130
{
80
131
/*
@@ -88,7 +139,7 @@ int main(int argc, char **argv)
88
139
sync .m_reconcileDone = true ;
89
140
sync .getRestartAssist ()->stopReconcileTimer (s);
90
141
sync .getRestartAssist ()->reconcile ();
91
- SWSS_LOG_NOTICE (" VXLAN FDB VNI Reconcillation Complete (Timer) " );
142
+ SWSS_LOG_NOTICE (" VXLAN FDB VNI Reconcillation Complete" );
92
143
}
93
144
}
94
145
}
0 commit comments