diff options
author | Guy Harris <guy@alum.mit.edu> | 2018-12-26 12:35:42 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2018-12-26 21:03:59 +0000 |
commit | c3a7986b86f5355e6bd1791f70b78c91bcdac247 (patch) | |
tree | 23dd944514f5ea3ccda3bf2a5521685708ac07fd /epan | |
parent | 52d22b25ab5ed51d2899dc22517d9cf0361faa58 (diff) |
Don't allocate per-frame data if we don't have an F5 trailer.
The F5 trailer dissector is called before the taps are called, so there
is no reason why the taps should attach information to the frame if
there isn't any information attached - if there's an F5 trailer, there
will be information attached to the frame, so there's no need to attach
one, and if there's no F5 trailer, there's no analysis to be done, so
there's no need to attach one.
That way, we don't waste memory that we aren't going to use (about 100MB
for a large capture I have that has almost 3 million packets).
Change-Id: I471b6c9b0fc6eb36f3aff35d6fba2f73c3a0eb90
Ping-Bug: 15385
Reviewed-on: https://code.wireshark.org/review/31210
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-f5ethtrailer.c | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/epan/dissectors/packet-f5ethtrailer.c b/epan/dissectors/packet-f5ethtrailer.c index 0721c67ec8..540ed0eaab 100644 --- a/epan/dissectors/packet-f5ethtrailer.c +++ b/epan/dissectors/packet-f5ethtrailer.c @@ -1262,26 +1262,6 @@ static struct f5eth_analysis_data_t *new_f5eth_analysis_data_t(void) } /* new_f5eth_analysis_data_t() */ -/*-----------------------------------------------------------------------------------------------*/ -/** \brief Retrieves the analysis data structure from the packet info. If it doesn't exist, it - * creates one and attaches it. - * - * @param pinfo A pointer to the packet info to look at for the analysis data. - * @return A pointer to the analysis data structure retrieved or created. NULL if error. - */ -static struct f5eth_analysis_data_t *get_f5eth_analysis_data(packet_info *pinfo) -{ - struct f5eth_analysis_data_t *analysis_data; - - analysis_data = (struct f5eth_analysis_data_t*)p_get_proto_data(wmem_file_scope(), pinfo, - proto_f5ethtrailer, 0); - if(analysis_data == NULL) { - analysis_data = new_f5eth_analysis_data_t(); - p_add_proto_data(wmem_file_scope(), pinfo, proto_f5ethtrailer, 0, analysis_data); - } - return(analysis_data); -} /* get_f5eth_analysis_data() */ - /* Functions for find a subtree of a particular type of the current tree. */ /** Structure used as the anonymous data in the proto_tree_children_foreach() function */ @@ -1399,9 +1379,12 @@ static gboolean ip_tap_pkt( epan_dissect_t *edt _U_, const void *data ) { - struct f5eth_analysis_data_t *ad = get_f5eth_analysis_data(pinfo); + struct f5eth_analysis_data_t *ad; const ws_ip4 *iph; + ad = (struct f5eth_analysis_data_t*)p_get_proto_data(wmem_file_scope(), pinfo, + proto_f5ethtrailer, 0); + if(ad == NULL) return(FALSE); /* No F5 information */ if(ad->ip_visited == 1) return(FALSE); ad->ip_visited = 1; @@ -1433,9 +1416,12 @@ static gboolean ipv6_tap_pkt( epan_dissect_t *edt _U_, const void *data ) { - struct f5eth_analysis_data_t *ad = get_f5eth_analysis_data(pinfo); + struct f5eth_analysis_data_t *ad; const struct ws_ip6_hdr *ipv6h; + ad = (struct f5eth_analysis_data_t*)p_get_proto_data(wmem_file_scope(), pinfo, + proto_f5ethtrailer, 0); + if(ad == NULL) return(FALSE); /* No F5 information */ if(ad->ip_visited == 1) return(FALSE); ad->ip_visited = 1; @@ -1470,9 +1456,12 @@ static gboolean tcp_tap_pkt( epan_dissect_t *edt _U_, const void *data ) { - struct f5eth_analysis_data_t *ad = get_f5eth_analysis_data(pinfo); + struct f5eth_analysis_data_t *ad; const tcp_info_t *tcph; + ad = (struct f5eth_analysis_data_t*)p_get_proto_data(wmem_file_scope(), pinfo, + proto_f5ethtrailer, 0); + if(ad == NULL) return(FALSE); /* No F5 information */ if(ad->tcp_visited == 1) return(FALSE); ad->tcp_visited = 1; @@ -2765,9 +2754,13 @@ dissect_f5ethtrailer( if(pref_perform_analysis) { /* Get the analysis data information for this packet */ - ad = get_f5eth_analysis_data(pinfo); - - if(ad != NULL && ad->analysis_done == 0) { + ad = (struct f5eth_analysis_data_t*)p_get_proto_data(wmem_file_scope(), pinfo, + proto_f5ethtrailer, 0); + if(ad == NULL) { + ad = new_f5eth_analysis_data_t(); + p_add_proto_data(wmem_file_scope(), pinfo, proto_f5ethtrailer, 0, ad); + } + if(ad->analysis_done == 0) { ad->pkt_ingress = tdata->ingress; if(tdata->flows_set == 1) { ad->pkt_has_flow = tdata->flow == 0 ? 0 : 1; |