@@ -87,9 +87,6 @@ bool MirrorOrch::bake()
8787{
8888 SWSS_LOG_ENTER ();
8989
90- // Freeze the route update during orchagent restoration
91- m_freeze = true ;
92-
9390 deque<KeyOpFieldsValuesTuple> entries;
9491 vector<string> keys;
9592 m_mirrorTable.getKeys (keys);
@@ -134,23 +131,6 @@ bool MirrorOrch::bake()
134131 return Orch::bake ();
135132}
136133
137- bool MirrorOrch::postBake ()
138- {
139- SWSS_LOG_ENTER ();
140-
141- SWSS_LOG_NOTICE (" Start MirrorOrch post-baking" );
142-
143- // Unfreeze the route update
144- m_freeze = false ;
145-
146- Orch::doTask ();
147-
148- // Clean up the recovery cache
149- m_recoverySessionMap.clear ();
150-
151- return Orch::postBake ();
152- }
153-
154134void MirrorOrch::update (SubjectType type, void *cntx)
155135{
156136 SWSS_LOG_ENTER ();
@@ -340,7 +320,7 @@ bool MirrorOrch::validateSrcPortList(const string& srcPortList)
340320 return true ;
341321}
342322
343- void MirrorOrch::createEntry (const string& key, const vector<FieldValueTuple>& data)
323+ task_process_status MirrorOrch::createEntry (const string& key, const vector<FieldValueTuple>& data)
344324{
345325 SWSS_LOG_ENTER ();
346326
@@ -349,7 +329,7 @@ void MirrorOrch::createEntry(const string& key, const vector<FieldValueTuple>& d
349329 {
350330 SWSS_LOG_NOTICE (" Failed to create session, session %s already exists" ,
351331 key.c_str ());
352- return ;
332+ return task_process_status::task_duplicated ;
353333 }
354334
355335 string platform = getenv (" platform" ) ? getenv (" platform" ) : " " ;
@@ -364,7 +344,7 @@ void MirrorOrch::createEntry(const string& key, const vector<FieldValueTuple>& d
364344 if (!entry.srcIp .isV4 ())
365345 {
366346 SWSS_LOG_ERROR (" Unsupported version of sessions %s source IP address" , key.c_str ());
367- return ;
347+ return task_process_status::task_invalid_entry ;
368348 }
369349 }
370350 else if (fvField (i) == MIRROR_SESSION_DST_IP)
@@ -373,7 +353,7 @@ void MirrorOrch::createEntry(const string& key, const vector<FieldValueTuple>& d
373353 if (!entry.dstIp .isV4 ())
374354 {
375355 SWSS_LOG_ERROR (" Unsupported version of sessions %s destination IP address" , key.c_str ());
376- return ;
356+ return task_process_status::task_invalid_entry ;
377357 }
378358 }
379359 else if (fvField (i) == MIRROR_SESSION_GRE_TYPE)
@@ -398,7 +378,7 @@ void MirrorOrch::createEntry(const string& key, const vector<FieldValueTuple>& d
398378 {
399379 SWSS_LOG_ERROR (" Failed to get policer %s" ,
400380 fvValue (i).c_str ());
401- return ;
381+ return task_process_status::task_need_retry ;
402382 }
403383
404384 m_policerOrch->increaseRefCount (fvValue (i));
@@ -409,7 +389,7 @@ void MirrorOrch::createEntry(const string& key, const vector<FieldValueTuple>& d
409389 if (!validateSrcPortList (fvValue (i)))
410390 {
411391 SWSS_LOG_ERROR (" Failed to get valid source port list %s" , fvValue (i).c_str ());
412- return ;
392+ return task_process_status::task_invalid_entry ;
413393 }
414394 entry.src_port = fvValue (i);
415395 }
@@ -418,7 +398,7 @@ void MirrorOrch::createEntry(const string& key, const vector<FieldValueTuple>& d
418398 if (!validateDstPort (fvValue (i)))
419399 {
420400 SWSS_LOG_ERROR (" Failed to get valid destination port %s" , fvValue (i).c_str ());
421- return ;
401+ return task_process_status::task_invalid_entry ;
422402 }
423403 entry.dst_port = fvValue (i);
424404 }
@@ -428,7 +408,7 @@ void MirrorOrch::createEntry(const string& key, const vector<FieldValueTuple>& d
428408 || fvValue (i) == MIRROR_BOTH_DIRECTION))
429409 {
430410 SWSS_LOG_ERROR (" Failed to get valid direction %s" , fvValue (i).c_str ());
431- return ;
411+ return task_process_status::task_invalid_entry ;
432412 }
433413 entry.direction = fvValue (i);
434414 }
@@ -439,18 +419,18 @@ void MirrorOrch::createEntry(const string& key, const vector<FieldValueTuple>& d
439419 else
440420 {
441421 SWSS_LOG_ERROR (" Failed to parse session %s configuration. Unknown attribute %s" , key.c_str (), fvField (i).c_str ());
442- return ;
422+ return task_process_status::task_invalid_entry ;
443423 }
444424 }
445425 catch (const exception& e)
446426 {
447427 SWSS_LOG_ERROR (" Failed to parse session %s attribute %s error: %s." , key.c_str (), fvField (i).c_str (), e.what ());
448- return ;
428+ return task_process_status::task_invalid_entry ;
449429 }
450430 catch (...)
451431 {
452432 SWSS_LOG_ERROR (" Failed to parse session %s attribute %s. Unknown error has been occurred" , key.c_str (), fvField (i).c_str ());
453- return ;
433+ return task_process_status::task_failed ;
454434 }
455435 }
456436
@@ -470,6 +450,8 @@ void MirrorOrch::createEntry(const string& key, const vector<FieldValueTuple>& d
470450 // Attach the destination IP to the routeOrch
471451 m_routeOrch->attach (this , entry.dstIp );
472452 }
453+
454+ return task_process_status::task_success;
473455}
474456
475457task_process_status MirrorOrch::deleteEntry (const string& name)
@@ -1412,11 +1394,6 @@ void MirrorOrch::doTask(Consumer& consumer)
14121394{
14131395 SWSS_LOG_ENTER ();
14141396
1415- if (m_freeze)
1416- {
1417- return ;
1418- }
1419-
14201397 if (!gPortsOrch ->allPortsReady ())
14211398 {
14221399 return ;
@@ -1429,26 +1406,32 @@ void MirrorOrch::doTask(Consumer& consumer)
14291406
14301407 string key = kfvKey (t);
14311408 string op = kfvOp (t);
1409+ task_process_status task_status = task_process_status::task_failed;
14321410
14331411 if (op == SET_COMMAND)
14341412 {
1435- createEntry (key, kfvFieldsValues (t));
1413+ task_status = createEntry (key, kfvFieldsValues (t));
14361414 }
14371415 else if (op == DEL_COMMAND)
14381416 {
1439- auto task_status = deleteEntry (key);
1440- // Specifically retry the task when asked
1441- if (task_status == task_process_status::task_need_retry)
1442- {
1443- it++;
1444- continue ;
1445- }
1417+ task_status = deleteEntry (key);
14461418 }
14471419 else
14481420 {
14491421 SWSS_LOG_ERROR (" Unknown operation type %s" , op.c_str ());
14501422 }
14511423
1452- consumer.m_toSync .erase (it++);
1424+ // Specifically retry the task when asked
1425+ if (task_status == task_process_status::task_need_retry)
1426+ {
1427+ it++;
1428+ }
1429+ else
1430+ {
1431+ consumer.m_toSync .erase (it++);
1432+ }
14531433 }
1434+
1435+ // Clear any recovery state that might be leftover from warm reboot
1436+ m_recoverySessionMap.clear ();
14541437}
0 commit comments