9
9
#include " tokenize.h"
10
10
#include " shellcmd.h"
11
11
#include " exec.h"
12
+ #include " warm_restart.h"
12
13
13
14
using namespace std ;
14
15
using namespace swss ;
@@ -107,7 +108,8 @@ static int cmdIpTunnelRouteDel(const std::string& pfx, std::string & res)
107
108
TunnelMgr::TunnelMgr (DBConnector *cfgDb, DBConnector *appDb, const std::vector<std::string> &tableNames) :
108
109
Orch(cfgDb, tableNames),
109
110
m_appIpInIpTunnelTable(appDb, APP_TUNNEL_DECAP_TABLE_NAME),
110
- m_cfgPeerTable(cfgDb, CFG_PEER_SWITCH_TABLE_NAME)
111
+ m_cfgPeerTable(cfgDb, CFG_PEER_SWITCH_TABLE_NAME),
112
+ m_cfgTunnelTable(cfgDb, CFG_TUNNEL_TABLE_NAME)
111
113
{
112
114
std::vector<string> peer_keys;
113
115
m_cfgPeerTable.getKeys (peer_keys);
@@ -126,6 +128,23 @@ TunnelMgr::TunnelMgr(DBConnector *cfgDb, DBConnector *appDb, const std::vector<s
126
128
}
127
129
}
128
130
}
131
+
132
+ if (WarmStart::isWarmStart ())
133
+ {
134
+ std::vector<string> tunnel_keys;
135
+ m_cfgTunnelTable.getKeys (tunnel_keys);
136
+
137
+ for (auto tunnel: tunnel_keys)
138
+ {
139
+ m_tunnelReplay.insert (tunnel);
140
+ }
141
+ if (m_tunnelReplay.empty ())
142
+ {
143
+ finalizeWarmReboot ();
144
+ }
145
+
146
+ }
147
+
129
148
130
149
auto consumerStateTable = new swss::ConsumerStateTable (appDb, APP_TUNNEL_ROUTE_TABLE_NAME,
131
150
TableConsumable::DEFAULT_POP_BATCH_SIZE, default_orch_pri);
@@ -191,6 +210,11 @@ void TunnelMgr::doTask(Consumer &consumer)
191
210
++it;
192
211
}
193
212
}
213
+
214
+ if (!replayDone && m_tunnelReplay.empty () && WarmStart::isWarmStart ())
215
+ {
216
+ finalizeWarmReboot ();
217
+ }
194
218
}
195
219
196
220
bool TunnelMgr::doTunnelTask (const KeyOpFieldsValuesTuple & t)
@@ -230,8 +254,16 @@ bool TunnelMgr::doTunnelTask(const KeyOpFieldsValuesTuple & t)
230
254
SWSS_LOG_NOTICE (" Peer/Remote IP not configured" );
231
255
}
232
256
233
- m_appIpInIpTunnelTable.set (tunnelName, kfvFieldsValues (t));
257
+ /* If the tunnel is already in hardware (i.e. present in the replay),
258
+ * don't try to create it again since it will cause an OA crash
259
+ * (warmboot case)
260
+ */
261
+ if (m_tunnelReplay.find (tunnelName) == m_tunnelReplay.end ())
262
+ {
263
+ m_appIpInIpTunnelTable.set (tunnelName, kfvFieldsValues (t));
264
+ }
234
265
}
266
+ m_tunnelReplay.erase (tunnelName);
235
267
m_tunnelCache[tunnelName] = tunInfo;
236
268
}
237
269
else
@@ -356,3 +388,13 @@ bool TunnelMgr::configIpTunnel(const TunnelInfo& tunInfo)
356
388
357
389
return true ;
358
390
}
391
+
392
+
393
+ void TunnelMgr::finalizeWarmReboot ()
394
+ {
395
+ replayDone = true ;
396
+ WarmStart::setWarmStartState (" tunnelmgrd" , WarmStart::REPLAYED);
397
+ SWSS_LOG_NOTICE (" tunnelmgrd warmstart state set to REPLAYED" );
398
+ WarmStart::setWarmStartState (" tunnelmgrd" , WarmStart::RECONCILED);
399
+ SWSS_LOG_NOTICE (" tunnelmgrd warmstart state set to RECONCILED" );
400
+ }
0 commit comments