diff --git a/src/stirling/source_connectors/socket_tracer/protocols/mongodb/parse.cc b/src/stirling/source_connectors/socket_tracer/protocols/mongodb/parse.cc index 3c2ca0911dd..56f58a8754d 100644 --- a/src/stirling/source_connectors/socket_tracer/protocols/mongodb/parse.cc +++ b/src/stirling/source_connectors/socket_tracer/protocols/mongodb/parse.cc @@ -64,9 +64,10 @@ ParseState ParseFrame(message_type_t type, std::string_view* buf, Frame* frame, return ParseState::kInvalid; } - // Parser will ignore Op Codes that have been deprecated/removed from version 5.0 onwards. - if (!(frame_type == Type::kOPMsg || frame_type == Type::kOPCompressed || - frame_type == Type::kReserved)) { + // Parser will ignore Op Codes that have been deprecated/removed from version 5.0 onwards as well + // as kOPCompressed and kReserved which are not supported by the parser yet. + if (frame_type != Type::kOPMsg) { + buf->remove_prefix(frame->length); return ParseState::kIgnored; } diff --git a/src/stirling/source_connectors/socket_tracer/protocols/mongodb/parse_test.cc b/src/stirling/source_connectors/socket_tracer/protocols/mongodb/parse_test.cc index ba587af622c..b6c89f0455d 100644 --- a/src/stirling/source_connectors/socket_tracer/protocols/mongodb/parse_test.cc +++ b/src/stirling/source_connectors/socket_tracer/protocols/mongodb/parse_test.cc @@ -391,6 +391,7 @@ TEST_F(MongoDBParserTest, ParseFrameWhenUnsupportedType) { ParseState state = ParseFrame(message_type_t::kRequest, &frame_view, &frame, &state_order); EXPECT_EQ(state, ParseState::kIgnored); + EXPECT_EQ(frame_view.length(), 0); } TEST_F(MongoDBParserTest, ParseFrameInvalidFlagBits) {