Changeset 5778738 for lib/format_dag25.c


Ignore:
Timestamp:
01/07/10 11:04:13 (12 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:
4b6e1b2
Parents:
2d69532
Message:
  • Fixed major bug where we were sleeping whenever a packet did not match a specified BPF filter when reading from a DAG card, rather than immediately checking if there was another suitable packet available. This was causing libtrace to get massively behind in reading packets from the DAG card so the DAG buffer would overflow and packets would be dropped.
  • NOTE: the dag2.4 version of this fix has not been fully tested (or even compiled) because we upgraded the box that used to have the old DAG cards in
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_dag25.c

    r1aa4bf7 r5778738  
    888888        uint32_t flags = 0;
    889889
    890         /* Need to call dag_available so that the top pointer will get
    891          * updated, otherwise we'll never see any data! */
    892         numbytes = dag_available(trace);
    893 
    894         /* May as well not bother calling dag_get_record if dag_available
    895          * suggests that there's no data */
    896         if (numbytes != 0)
    897                 erfptr = dag_get_record(trace);
    898         if (erfptr == NULL) {
    899                 /* No packet available */
    900                 event.type = TRACE_EVENT_SLEEP;
    901                 event.seconds = 0.0001;
    902                 return event;
    903         }
    904         //dag_form_packet(erfptr, packet);
    905         if (dag_prepare_packet(trace, packet, erfptr, TRACE_RT_DATA_ERF,
    906                                 flags)) {
    907                 event.type = TRACE_EVENT_TERMINATE;
    908                 return event;
    909         }
    910 
    911 
    912         event.size = trace_get_capture_length(packet) + trace_get_framing_length(packet);
    913         if (trace->filter) {
    914                 if (trace_apply_filter(trace->filter, packet)) {
     890        do {
     891                erfptr = NULL;
     892                numbytes = 0;
     893       
     894                /* Need to call dag_available so that the top pointer will get
     895                 * updated, otherwise we'll never see any data! */
     896                numbytes = dag_available(trace);
     897
     898                /* May as well not bother calling dag_get_record if
     899                 * dag_available suggests that there's no data */
     900                if (numbytes != 0)
     901                        erfptr = dag_get_record(trace);
     902                if (erfptr == NULL) {
     903                        /* No packet available */
     904                        event.type = TRACE_EVENT_SLEEP;
     905                        event.seconds = 0.0001;
     906                        break;
     907                }
     908                //dag_form_packet(erfptr, packet);
     909                if (dag_prepare_packet(trace, packet, erfptr,
     910                                        TRACE_RT_DATA_ERF, flags)) {
     911                        event.type = TRACE_EVENT_TERMINATE;
     912                        break;
     913                }
     914
     915
     916                event.size = trace_get_capture_length(packet) +
     917                                trace_get_framing_length(packet);
     918                if (trace->filter) {
     919                        if (trace_apply_filter(trace->filter, packet)) {
     920                                event.type = TRACE_EVENT_PACKET;
     921                        } else {
     922                                /* This packet isn't useful so we want to
     923                                 * immediately see if there is another suitable
     924                                 * one - we definitely DO NOT want to return
     925                                 * a sleep event in this case, like we used to
     926                                 * do! */
     927                                continue;
     928                        }
     929                } else {
    915930                        event.type = TRACE_EVENT_PACKET;
    916                 } else {
    917                         event.type = TRACE_EVENT_SLEEP;
    918                         event.seconds = 0.000001;
    919                         return event;
    920931                }
    921         } else {
    922                 event.type = TRACE_EVENT_PACKET;
    923         }
    924 
    925         if (trace->snaplen > 0) {
    926                 trace_set_capture_length(packet, trace->snaplen);
    927         }
     932
     933                if (trace->snaplen > 0) {
     934                        trace_set_capture_length(packet, trace->snaplen);
     935                }
     936                break;
     937        } while (1);
    928938
    929939        return event;
Note: See TracChangeset for help on using the changeset viewer.