Changeset 70bf39a


Ignore:
Timestamp:
11/10/14 17:02:21 (7 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:
21f3226
Parents:
3c54095
Message:

Fix dodgy stream buffer flushing in DAG

Not sure what was going on with that flushing code, but I'm pretty sure
that wasn't going to work.

Ignore loss counters on the first packet observed on each interface.
Modern DAG interfaces treat any packets that appear while you're not
capturing as lost, so stopping and restarting a DAG capture will always
result in a non-zero loss counter. We tend to use the loss counter to
only indicate packets lost during active capture, so we need to compensate.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_dag25.c

    r51d1f64 r70bf39a  
    146146        /* The number of packets that have been dropped */
    147147        uint64_t drops;
     148
     149        uint8_t seeninterface[4];
    148150};
    149151
     
    226228        FORMAT_DATA->bottom = NULL;
    227229        FORMAT_DATA->top = NULL;
     230        memset(FORMAT_DATA->seeninterface, 0, sizeof(FORMAT_DATA->seeninterface));
    228231}
    229232
     
    275278        dag_close(dev->fd);
    276279        if (dev->dev_name)
    277         free(dev->dev_name);
     280                free(dev->dev_name);
    278281        free(dev);
    279282}
     
    557560
    558561        if (dag_attach_stream(FORMAT_DATA_OUT->device->fd,
    559                         FORMAT_DATA_OUT->dagstream, 0, 1048576) < 0) {
     562                        FORMAT_DATA_OUT->dagstream, 0, 4 * 1024 * 1024) < 0) {
    560563                trace_set_err_out(libtrace, errno, "Cannot attach DAG stream");
    561564                return -1;
     
    581584static int dag_start_input(libtrace_t *libtrace) {
    582585        struct timeval zero, nopoll;
    583         uint8_t *top, *bottom;
    584         uint8_t diff = 0;
     586        uint8_t *top, *bottom, *starttop;
     587        uint64_t diff = 0;
    585588        top = bottom = NULL;
    586589
     
    608611                                &nopoll);
    609612
     613        starttop = dag_advance_stream(FORMAT_DATA->device->fd,
     614                                        FORMAT_DATA->dagstream,
     615                                        &bottom);
     616
    610617        /* Should probably flush the memory hole now */
    611         do {
     618        while (starttop - bottom > 0) {
     619                bottom += (starttop - bottom);
    612620                top = dag_advance_stream(FORMAT_DATA->device->fd,
    613621                                        FORMAT_DATA->dagstream,
    614622                                        &bottom);
    615                 assert(top && bottom);
    616                 diff = top - bottom;
    617                 bottom -= diff;
    618         } while (diff != 0);
    619         FORMAT_DATA->top = NULL;
    620         FORMAT_DATA->bottom = NULL;
     623        }
     624        FORMAT_DATA->top = top;
     625        FORMAT_DATA->bottom = bottom;
    621626        FORMAT_DATA->processed = 0;
    622627        FORMAT_DATA->drops = 0;
     
    843848        } else {
    844849                /* Use the ERF loss counter */
    845                 DATA(libtrace)->drops += ntohs(erfptr->lctr);
     850                if (FORMAT_DATA->seeninterface[erfptr->flags.iface] == 0) {
     851                        FORMAT_DATA->seeninterface[erfptr->flags.iface] = 1;
     852                } else {
     853                        FORMAT_DATA->drops += ntohs(erfptr->lctr);
     854                }
    846855        }
    847856
Note: See TracChangeset for help on using the changeset viewer.