Changeset b8d8186 for lib/trace.c


Ignore:
Timestamp:
08/07/14 11:21:10 (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:
4649fea
Parents:
cd8efa6
Message:

Fix strangeness when using bogus filters on int:

Changes:

  • Make sure trace_start returns -1 for int: if the provided filter failed to compile, rather than falling through to using trace_apply_filter on the first packet (and failing). This is also more consistent with what pcapint: already does.
  • Check for -1 return value from trace_apply_filter, rather than treating -1 as a successful match.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace.c

    rf7bcbfb rb8d8186  
    723723                do {
    724724                        size_t ret;
     725                        int filtret;
    725726                        /* Clear the packet cache */
    726727                        trace_clear_cache(packet);
     
    733734                                 * packet
    734735                                 */
    735                                 if (!trace_apply_filter(libtrace->filter,packet)){
     736                                filtret = trace_apply_filter(libtrace->filter, packet);
     737                                if (filtret == -1) {
     738                                        /* Error compiling filter, probably */
     739                                        return ~0U;
     740                                }
     741                               
     742                                if (filtret == 0) {
    736743                                        ++libtrace->filtered_packets;
    737744                                        continue;
     
    11131120        if (packet->trace->format->trace_event) {
    11141121                event=packet->trace->format->trace_event(trace,packet);
    1115                 if (event.type == TRACE_EVENT_PACKET) {
     1122                if (event.type == TRACE_EVENT_PACKET) {
    11161123                        ++trace->accepted_packets;
    11171124                }
Note: See TracChangeset for help on using the changeset viewer.