Changeset 9cc1266 for lib/trace.c


Ignore:
Timestamp:
02/22/11 10:01:08 (10 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, 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:
e4e94c38
Parents:
ae76c14
Message:
  • Fixed poor performance of the event API by greatly reducing the amount of packets created, copied and freed
  • We now cache the transport header and payload length for each packet
  • We now deal with Linux SLL Ethernet captures taken using tcpdump with -i any correctly.
  • Changed parameters for internal function trace_get_payload_from_sll - it now sets both the arphrd type and the next protocol
  • Moved ARPHRD definitions into a separate header file, as they come in handy anywhere we deal with SLL headers
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace.c

    rdfbdd796 r9cc1266  
    243243        libtrace->event.psize = 0;
    244244        libtrace->event.trace_last_ts = 0.0;
     245        libtrace->event.waiting = false;
    245246        libtrace->filter = NULL;
    246247        libtrace->snaplen = 0;
     
    590591        if (libtrace->uridata)
    591592                free(libtrace->uridata);
     593        if (libtrace->event.packet)
     594                trace_destroy_packet(libtrace->event.packet);
    592595        free(libtrace);
    593596}
     
    624627
    625628        packet->buf_control=TRACE_CTRL_PACKET;
    626         packet->capture_length=-1;
     629        trace_clear_cache(packet);
    627630        return packet;
    628631}
     
    648651        /* Reset the cache - better to recalculate than try to convert
    649652         * the values over to the new packet */
    650         dest->capture_length = -1;
    651         dest->l3_header = NULL;
    652         dest->l3_ethertype = 0;
    653        
     653        trace_clear_cache(dest);       
    654654        /* Ooooh nasty memcpys! This is why we want to avoid copying packets
    655655         * as much as possible */
     
    712712                        size_t ret;
    713713                        /* Clear the packet cache */
    714                         packet->capture_length = -1;
    715                         packet->l3_header = NULL;
    716                         packet->l3_ethertype = 0;
    717 
     714                        trace_clear_cache(packet);
    718715                        ret=libtrace->format->read_packet(libtrace,packet);
    719716                        if (ret==(size_t)-1 || ret==0) {
     
    777774       
    778775        /* Clear packet cache */
    779         packet->capture_length = -1;
    780         packet->l3_header = NULL;
    781         packet->l3_ethertype = 0;
     776        trace_clear_cache(packet);
    782777
    783778        if (trace->format->prepare_packet) {
     
    10991094
    11001095        /* Clear the packet cache */
    1101         packet->capture_length = -1;
    1102         packet->l3_header = NULL;
    1103         packet->l3_ethertype = 0;
     1096        trace_clear_cache(packet);
    11041097       
    11051098        /* Store the trace we are reading from into the packet opaque
     
    18181811        assert(trace);
    18191812        return trace->accepted_packets;
     1813}
     1814
     1815void trace_clear_cache(libtrace_packet_t *packet) {
     1816
     1817        packet->l3_header = NULL;
     1818        packet->l4_header = NULL;
     1819        packet->l3_ethertype = 0;
     1820        packet->transport_proto = 0;
     1821        packet->capture_length = -1;
     1822        packet->payload_length = -1;
     1823
    18201824}
    18211825
Note: See TracChangeset for help on using the changeset viewer.