@@ -857,6 +857,76 @@ void performNotifySyncd(const std::string& request, const std::string response)
857
857
// OK
858
858
}
859
859
860
+ void performFdbFlush (
861
+ _In_ const std::string& request,
862
+ _In_ const std::string response)
863
+ {
864
+ SWSS_LOG_ENTER ();
865
+
866
+ // 2017-05-13.20:47:24.883499|f|SAI_OBJECT_TYPE_FDB_FLUSH:oid:0x21000000000000|
867
+ // 2017-05-13.20:47:24.883499|F|SAI_STATUS_SUCCESS
868
+
869
+ // timestamp|action|data
870
+ auto r = swss::tokenize (request, ' |' );
871
+ auto R = swss::tokenize (response, ' |' );
872
+
873
+ if (r[1 ] != " f" || R[1 ] != " F" )
874
+ {
875
+ SWSS_LOG_THROW (" invalid fdb flush request/response %s/%s" , request.c_str (), response.c_str ());
876
+ }
877
+
878
+ if (r.size () > 3 && r[3 ].size () != 0 )
879
+ {
880
+ SWSS_LOG_NOTICE (" %zu %zu, %s" , r.size (), r[3 ].size (), r[3 ].c_str ());
881
+ // TODO currently we support only flush fdb entries with no attributes
882
+ SWSS_LOG_THROW (" currently fdb flush supports only no attributes, but some given: %s" , request.c_str ());
883
+ }
884
+
885
+ // objecttype:objectid (object id may contain ':')
886
+ auto & data = r[2 ];
887
+ auto start = data.find_first_of (" :" );
888
+ auto str_object_type = data.substr (0 , start);
889
+ auto str_object_id = data.substr (start + 1 );
890
+
891
+ sai_object_type_t ot = deserialize_object_type (str_object_type);
892
+
893
+ if (ot != SAI_OBJECT_TYPE_FDB_FLUSH)
894
+ {
895
+ SWSS_LOG_THROW (" expected object type %s, but got: %s on %s" ,
896
+ sai_serialize_object_type (SAI_OBJECT_TYPE_FDB_FLUSH).c_str (),
897
+ str_object_type.c_str (),
898
+ request.c_str ());
899
+ }
900
+
901
+ sai_object_id_t local_switch_id;
902
+ sai_deserialize_object_id (str_object_id, local_switch_id);
903
+
904
+ if (sai_switch_id_query (local_switch_id) != local_switch_id)
905
+ {
906
+ SWSS_LOG_THROW (" fdb flush object is not switch id: %s, switch_id_query: %s" ,
907
+ str_object_id.c_str (),
908
+ sai_serialize_object_id (sai_switch_id_query (local_switch_id)).c_str ());
909
+ }
910
+
911
+ auto switch_id = translate_local_to_redis (local_switch_id);
912
+
913
+ // TODO currently we support only flush fdb entries with no attributes
914
+ sai_status_t status = sai_metadata_sai_fdb_api->flush_fdb_entries (switch_id, 0 , NULL );
915
+
916
+ // check status
917
+ sai_status_t expected_status;
918
+ sai_deserialize_status (R[2 ], expected_status);
919
+
920
+ if (status != expected_status)
921
+ {
922
+ SWSS_LOG_THROW (" fdb flush got status %s, but expecting: %s" ,
923
+ sai_serialize_status (status).c_str (),
924
+ R[2 ].c_str ());
925
+ }
926
+
927
+ // fdb flush OK
928
+ }
929
+
860
930
std::vector<std::string> tokenize (
861
931
_In_ std::string input,
862
932
_In_ const std::string &delim)
@@ -1189,6 +1259,25 @@ int replay(int argc, char **argv)
1189
1259
performNotifySyncd (line, response);
1190
1260
}
1191
1261
continue ;
1262
+
1263
+ case ' f' :
1264
+ {
1265
+ std::string response;
1266
+
1267
+ do
1268
+ {
1269
+ // this line may be notification, we need to skip
1270
+ if (!std::getline (infile, response))
1271
+ {
1272
+ SWSS_LOG_THROW (" failed to read next file from file, previous: %s" , line.c_str ());
1273
+ }
1274
+ }
1275
+ while (response[response.find_first_of (" |" ) + 1 ] == ' n' );
1276
+
1277
+ performFdbFlush (line, response);
1278
+ }
1279
+ continue ;
1280
+
1192
1281
case ' @' :
1193
1282
performSleep (line);
1194
1283
continue ;
@@ -1217,6 +1306,7 @@ int replay(int argc, char **argv)
1217
1306
continue ; // skip over query responses
1218
1307
case ' #' :
1219
1308
case ' n' :
1309
+ SWSS_LOG_INFO (" skipping op %c line %s" , op, line.c_str ());
1220
1310
continue ; // skip comment and notification
1221
1311
1222
1312
default :
0 commit comments