Reset the "current conversation elements" after each dissector call

packet_info has items that correspond to the single "most recent"
conversation set via conversation_set_conv_addr_port_endpoints or
conversation_set_elements_by_id. These should be reset after each
call of a dissector, because they are only relevant for the
dissector and any additional higher level dissectors it calls.

Lower level protocols and protocols at the same level (i.e., in
different PDUs of a shared lower level protocol) don't want to
automatically use those conversation elements to find the current
conversation.

Separately, there should be an array or linked list of all conversation
elements set in a packet, so that it can be used by the conversation table,
conversation filters, etc., instead of just accessing the most recent
conversation / conversation based on the last set address and ports.

Fix #18278
This commit is contained in:
John Thacker 2022-09-04 13:23:04 -04:00 committed by AndersBroman
parent 5723e43293
commit 80e287f82c
1 changed files with 10 additions and 0 deletions

View File

@ -861,6 +861,9 @@ call_dissector_work(dissector_handle_t handle, tvbuff_t *tvb, packet_info *pinfo
int len;
guint saved_layers_len = 0;
guint saved_tree_count = tree ? tree->tree_data->count : 0;
gboolean saved_use_conv_addr_port_endpoints;
struct conversation_addr_port_endpoints *saved_conv_addr_port_endpoints;
struct conversation_element *saved_conv_elements;
if (handle->protocol != NULL &&
!proto_is_protocol_enabled(handle->protocol)) {
@ -875,6 +878,10 @@ call_dissector_work(dissector_handle_t handle, tvbuff_t *tvb, packet_info *pinfo
saved_layers_len = wmem_list_count(pinfo->layers);
DISSECTOR_ASSERT(saved_layers_len < PINFO_LAYER_MAX_RECURSION_DEPTH);
saved_use_conv_addr_port_endpoints = pinfo->use_conv_addr_port_endpoints;
saved_conv_addr_port_endpoints = pinfo->conv_addr_port_endpoints;
saved_conv_elements = pinfo->conv_elements;
/*
* can_desegment is set to 2 by anyone which offers the
* desegmentation api/service.
@ -931,6 +938,9 @@ call_dissector_work(dissector_handle_t handle, tvbuff_t *tvb, packet_info *pinfo
}
pinfo->current_proto = saved_proto;
pinfo->can_desegment = saved_can_desegment;
pinfo->use_conv_addr_port_endpoints = saved_use_conv_addr_port_endpoints;
pinfo->conv_addr_port_endpoints = saved_conv_addr_port_endpoints;
pinfo->conv_elements = saved_conv_elements;
return len;
}