Changeset 2fa43fa


Ignore:
Timestamp:
08/25/15 17:43:01 (5 years ago)
Author:
Richard Sanger <rsangerarj@…>
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:
9a3a846
Parents:
f2066fa
Message:

Fixes an issue with old programs reusing a packet over multi traces

Fixes a bug that Shane found. In the case an old libtrace program used
a single packet and cycled over multiple traces. Closing the trace
and then reusing the packet with a new trace will try to finish
the packet which requires the old format to be present.

As such we now keep track of the last packet against the format,
and finish this when the trace is destroyed.

Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace_int.h

    rf2066fa r2fa43fa  
    307307        /** The sequence is like accepted_packets but we don't reset this after a pause. */
    308308        uint64_t sequence_number;
     309        /** The packet read out by the trace, backwards compatibility to allow us to finalise
     310         * a packet when the trace is destroyed */
     311        libtrace_packet_t *last_packet;
    309312        /** The filename from the uri for the trace */
    310313        char *uridata;
  • lib/trace.c

    r4007dbb r2fa43fa  
    261261        libtrace->filtered_packets = 0;
    262262        libtrace->accepted_packets = 0;
     263        libtrace->last_packet = NULL;
    263264       
    264265        /* Parallel inits */
     
    383384        libtrace->io = NULL;
    384385        libtrace->filtered_packets = 0;
     386        libtrace->accepted_packets = 0;
     387        libtrace->last_packet = NULL;
    385388       
    386389        /* Parallel inits */
     
    549552                return -1;
    550553        }
     554
     555        /* Finish the last packet we read - for backwards compatibility */
     556        if (libtrace->last_packet)
     557                trace_fin_packet(libtrace->last_packet);
     558        assert(libtrace->last_packet == NULL);
     559
    551560        if (libtrace->format->pause_input)
    552561                libtrace->format->pause_input(libtrace);
     562
    553563        libtrace->started=false;
    554564        return 0;
     
    689699        }
    690700
     701        /* Finish any the last packet we read - for backwards compatibility */
     702        if (libtrace->last_packet)
     703                trace_fin_packet(libtrace->last_packet);
     704        assert(libtrace->last_packet == NULL);
     705
    691706        if (libtrace->format) {
    692707                if (libtrace->started && libtrace->format->pause_input)
     
    827842                        packet->trace->format->fin_packet(packet);
    828843                }
     844                if (packet->trace && packet->trace->last_packet == packet)
     845                        packet->trace->last_packet = NULL;
    829846
    830847                // No matter what we remove the header and link pointers
     
    905922                        ++libtrace->accepted_packets;
    906923                        ++libtrace->sequence_number;
     924                        libtrace->last_packet = packet;
    907925                        return ret;
    908926                } while(1);
Note: See TracChangeset for help on using the changeset viewer.