Changeset c70f59f


Ignore:
Timestamp:
08/25/14 11:33:39 (6 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
7fda5c5
Parents:
a79eae41
Message:

Don't increment accepted_packets in trace_event

For formats that use the normal trace_event_device and
trace_event_trace functions to implement trace_event functionality,
this was resulting in accepted_packets being incremented twice:
once in the call to trace_read_packet within the standard event
function and once again in trace_event.

Removed the increment from trace_event and updated all formats
that provide a custom trace_event implementation to make sure they
either call trace_read_packet themselves or update the counters
properly (with the former preferred wherever possible).

Thanks to Alistair King for finding this bug.

Location:
lib
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • lib/format_dag24.c

    rc909fad rc70f59f  
    473473                        } else {
    474474                                /* Do not sleep - try to read another packet */
     475                                trace->filtered_packets ++;
    475476                                continue;
    476477                        }
     
    483484                        trace_set_capture_length(packet, trace->snaplen);
    484485                }
    485 
     486                trace->accepted_packets ++;
    486487                return event;
    487488        } while (1);
  • lib/format_dag25.c

    rc909fad rc70f59f  
    11341134                                 * a sleep event in this case, like we used to
    11351135                                 * do! */
     1136                                trace->filtered_packets ++;
    11361137                                trace_clear_cache(packet);
    11371138                                continue;
     
    11441145                        trace_set_capture_length(packet, trace->snaplen);
    11451146                }
     1147                trace->accepted_packets ++;
    11461148                break;
    11471149        } while (1);
  • lib/format_dpdk.c

    r2138553 rc70f59f  
    12721272                if (!trace_apply_filter(trace->filter, packet)) {
    12731273                    /* Failed the filter so we loop for another packet */
     1274                    trace->filtered_packets ++;
    12741275                    continue;
    12751276                }
    12761277            }
     1278            trace->accepted_packets ++;
    12771279        } else {
    12781280            /* We only want to sleep for a very short time - we are non-blocking */
  • lib/format_erf.c

    rf7bcbfb rc70f59f  
    746746         * we just need to read and return the next packet in the trace */
    747747        if (IN_OPTIONS.real_time) {
    748                 event.size = erf_read_packet(libtrace, packet);
     748                event.size = trace_read_packet(libtrace, packet);
    749749                if (event.size < 1)
    750750                        event.type = TRACE_EVENT_TERMINATE;
  • lib/format_linux.c

    rb8d8186 rc70f59f  
    10991099        if(header->tp_status & TP_STATUS_USER){
    11001100                /* We have a frame waiting */
    1101                 event.size = linuxring_read_packet(libtrace, packet);
     1101                event.size = trace_read_packet(libtrace, packet);
    11021102                event.type = TRACE_EVENT_PACKET;
    11031103        } else {
  • lib/format_pcapfile.c

    rf7bcbfb rc70f59f  
    713713
    714714        if (IN_OPTIONS.real_time) {
    715                 event.size = pcapfile_read_packet(libtrace, packet);
     715                event.size = trace_read_packet(libtrace, packet);
    716716                if (event.size < 1)
    717717                        event.type = TRACE_EVENT_TERMINATE;
  • lib/format_rt.c

    r90e8d92 rc70f59f  
    780780                        if (packet->type == TRACE_RT_END_DATA)
    781781                                event.type = TRACE_EVENT_TERMINATE;
    782                         else
     782                        else {
    783783                                /* Since several RT messages can have zero-byte
    784784                                 * length (once the framing is removed), an
     
    786786                                 * PACKET event */
    787787                                event.type = TRACE_EVENT_PACKET;
     788                                trace->accepted_packets ++;
     789                        }
    788790
    789791                }       
    790792                else {
    791793                        event.type = TRACE_EVENT_PACKET;
     794                        trace->accepted_packets ++;
    792795                }
    793796
     
    795798                        if (!trace_apply_filter(trace->filter, packet)) {
    796799                                trace_clear_cache(packet);
    797                                 continue;
     800                                trace->filtered_packets ++;
     801                                continue;
    798802                        }
    799803                }
  • lib/trace.c

    rb8d8186 rc70f59f  
    11191119
    11201120        if (packet->trace->format->trace_event) {
    1121                 event=packet->trace->format->trace_event(trace,packet);
    1122                 if (event.type == TRACE_EVENT_PACKET) {
    1123                         ++trace->accepted_packets;
    1124                 }
     1121                /* Note: incrementing accepted, filtered etc. packet
     1122                 * counters is handled by the format-specific
     1123                 * function so don't increment them here.
     1124                 */
     1125                event=packet->trace->format->trace_event(trace,packet);
    11251126        }
    11261127        return event;
Note: See TracChangeset for help on using the changeset viewer.