@@ -216,86 +216,94 @@ void AclTableManager::enqueue(const std::string &table_name, const swss::KeyOpFi
216216 m_entries.push_back (entry);
217217}
218218
219- void AclTableManager::drain ()
220- {
221- SWSS_LOG_ENTER ();
219+ void AclTableManager::drainWithNotExecuted () {
220+ drainMgmtWithNotExecuted (m_entries, m_publisher);
221+ }
222222
223- for (const auto &key_op_fvs_tuple : m_entries)
224- {
225- std::string table_name;
226- std::string db_key;
227- parseP4RTKey (kfvKey (key_op_fvs_tuple), &table_name, &db_key);
228- SWSS_LOG_NOTICE (" P4AclTableManager drain tuple for table %s" , QuotedVar (table_name).c_str ());
229- if (table_name != APP_P4RT_ACL_TABLE_DEFINITION_NAME)
230- {
231- ReturnCode status = ReturnCode (StatusCode::SWSS_RC_INVALID_PARAM)
232- << " Invalid table " << QuotedVar (table_name);
233- SWSS_LOG_ERROR (" %s" , status.message ().c_str ());
234- m_publisher->publish (APP_P4RT_TABLE_NAME, kfvKey (key_op_fvs_tuple), kfvFieldsValues (key_op_fvs_tuple),
235- status,
236- /* replace=*/ true );
237- continue ;
238- }
239- const std::vector<swss::FieldValueTuple> &attributes = kfvFieldsValues (key_op_fvs_tuple);
223+ ReturnCode AclTableManager::drain () {
224+ SWSS_LOG_ENTER ();
240225
241- ReturnCode status;
242- const std::string &operation = kfvOp (key_op_fvs_tuple);
243- if (operation == SET_COMMAND)
244- {
245- auto app_db_entry_or = deserializeAclTableDefinitionAppDbEntry (db_key, attributes);
246- if (!app_db_entry_or.ok ())
247- {
248- status = app_db_entry_or.status ();
249- SWSS_LOG_ERROR (" Unable to deserialize APP DB entry with key %s: %s" ,
250- QuotedVar (table_name + " :" + db_key).c_str (), status.message ().c_str ());
251- m_publisher->publish (APP_P4RT_TABLE_NAME, kfvKey (key_op_fvs_tuple), kfvFieldsValues (key_op_fvs_tuple),
252- status,
253- /* replace=*/ true );
254- continue ;
255- }
256- auto &app_db_entry = *app_db_entry_or;
257-
258- status = validateAclTableDefinitionAppDbEntry (app_db_entry);
259- if (!status.ok ())
260- {
261- SWSS_LOG_ERROR (" Validation failed for ACL definition APP DB entry with key %s: %s" ,
262- QuotedVar (table_name + " :" + db_key).c_str (), status.message ().c_str ());
263- m_publisher->publish (APP_P4RT_TABLE_NAME, kfvKey (key_op_fvs_tuple), kfvFieldsValues (key_op_fvs_tuple),
264- status,
265- /* replace=*/ true );
266- continue ;
267- }
268- auto *acl_table_definition = getAclTable (app_db_entry.acl_table_name );
269- if (acl_table_definition == nullptr )
270- {
271- SWSS_LOG_NOTICE (" ACL table SET %s" , app_db_entry.acl_table_name .c_str ());
272- status = processAddTableRequest (app_db_entry);
273- }
274- else
275- {
276- // All attributes in sai_acl_table_attr_t are CREATE_ONLY.
277- status = ReturnCode (StatusCode::SWSS_RC_UNIMPLEMENTED)
278- << " Unable to update ACL table definition in APP DB entry with key "
279- << QuotedVar (table_name + " :" + db_key)
280- << " : All attributes in sai_acl_table_attr_t are CREATE_ONLY." ;
281- }
282- }
283- else if (operation == DEL_COMMAND)
284- {
285- status = processDeleteTableRequest (db_key);
286- }
287- else
288- {
289- status = ReturnCode (StatusCode::SWSS_RC_INVALID_PARAM) << " Unknown operation type " << QuotedVar (operation);
290- }
291- if (!status.ok ())
292- {
293- SWSS_LOG_ERROR (" Processed DEFINITION entry status: %s" , status.message ().c_str ());
294- }
295- m_publisher->publish (APP_P4RT_TABLE_NAME, kfvKey (key_op_fvs_tuple), kfvFieldsValues (key_op_fvs_tuple), status,
226+ ReturnCode status;
227+ while (!m_entries.empty ()) {
228+ auto key_op_fvs_tuple = m_entries.front ();
229+ m_entries.pop_front ();
230+ std::string table_name;
231+ std::string db_key;
232+
233+ parseP4RTKey (kfvKey (key_op_fvs_tuple), &table_name, &db_key);
234+ SWSS_LOG_NOTICE (" P4AclTableManager drain tuple for table %s" ,
235+ QuotedVar (table_name).c_str ());
236+ if (table_name != APP_P4RT_ACL_TABLE_DEFINITION_NAME) {
237+ status = ReturnCode (StatusCode::SWSS_RC_INVALID_PARAM)
238+ << " Invalid table " << QuotedVar (table_name);
239+ SWSS_LOG_ERROR (" %s" , status.message ().c_str ());
240+ m_publisher->publish (APP_P4RT_TABLE_NAME, kfvKey (key_op_fvs_tuple),
241+ kfvFieldsValues (key_op_fvs_tuple), status,
242+ /* replace=*/ true );
243+ break ;
244+ }
245+ const std::vector<swss::FieldValueTuple>& attributes =
246+ kfvFieldsValues (key_op_fvs_tuple);
247+
248+ const std::string& operation = kfvOp (key_op_fvs_tuple);
249+ if (operation == SET_COMMAND) {
250+ auto app_db_entry_or =
251+ deserializeAclTableDefinitionAppDbEntry (db_key, attributes);
252+ if (!app_db_entry_or.ok ()) {
253+ status = app_db_entry_or.status ();
254+ SWSS_LOG_ERROR (" Unable to deserialize APP DB entry with key %s: %s" ,
255+ QuotedVar (table_name + " :" + db_key).c_str (),
256+ status.message ().c_str ());
257+ m_publisher->publish (APP_P4RT_TABLE_NAME, kfvKey (key_op_fvs_tuple),
258+ kfvFieldsValues (key_op_fvs_tuple), status,
296259 /* replace=*/ true );
297- }
298- m_entries.clear ();
260+ break ;
261+ }
262+ auto & app_db_entry = *app_db_entry_or;
263+
264+ status = validateAclTableDefinitionAppDbEntry (app_db_entry);
265+ if (!status.ok ()) {
266+ SWSS_LOG_ERROR (
267+ " Validation failed for ACL definition APP DB entry with key %s: %s" ,
268+ QuotedVar (table_name + " :" + db_key).c_str (),
269+ status.message ().c_str ());
270+ m_publisher->publish (APP_P4RT_TABLE_NAME, kfvKey (key_op_fvs_tuple),
271+ kfvFieldsValues (key_op_fvs_tuple), status,
272+ /* replace=*/ true );
273+ break ;
274+ }
275+ auto * acl_table_definition = getAclTable (app_db_entry.acl_table_name );
276+ if (acl_table_definition == nullptr ) {
277+ SWSS_LOG_NOTICE (" ACL table SET %s" ,
278+ app_db_entry.acl_table_name .c_str ());
279+ status = processAddTableRequest (app_db_entry);
280+ } else {
281+ // All attributes in sai_acl_table_attr_t are CREATE_ONLY.
282+ status =
283+ ReturnCode (StatusCode::SWSS_RC_UNIMPLEMENTED)
284+ << " Unable to update ACL table definition in APP DB entry with key "
285+ << QuotedVar (table_name + " :" + db_key)
286+ << " : All attributes in sai_acl_table_attr_t are CREATE_ONLY." ;
287+ }
288+ } else if (operation == DEL_COMMAND) {
289+ status = processDeleteTableRequest (db_key);
290+ } else {
291+ status = ReturnCode (StatusCode::SWSS_RC_INVALID_PARAM)
292+ << " Unknown operation type " << QuotedVar (operation);
293+ }
294+ if (!status.ok ()) {
295+ SWSS_LOG_ERROR (" Processed DEFINITION entry status: %s" ,
296+ status.message ().c_str ());
297+ }
298+ m_publisher->publish (APP_P4RT_TABLE_NAME, kfvKey (key_op_fvs_tuple),
299+ kfvFieldsValues (key_op_fvs_tuple), status,
300+ /* replace=*/ true );
301+ if (!status.ok ()) {
302+ break ;
303+ }
304+ }
305+ drainWithNotExecuted ();
306+ return status;
299307}
300308
301309ReturnCodeOr<P4AclTableDefinitionAppDbEntry> AclTableManager::deserializeAclTableDefinitionAppDbEntry (
0 commit comments