Changeset 3fe009c


Ignore:
Timestamp:
02/23/16 15:33:33 (5 years ago)
Author:
Perry Lorier <git@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, master, ndag_format, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
9636216
Parents:
6d082e6 (diff), e4eff86 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of https://github.com/wanduow/libtrace

Files:
1 added
29 edited

Legend:

Unmodified
Added
Removed
  • Makefile.am

    r60f3c4c ra2ce0a6  
    2222        $(RM) -rf autom4te.cache/
    2323
    24 dist-hook:
    25         if which svnversion > /dev/null; then \
    26                 r=`svnversion -nc . | sed -e 's/^[^:]*://;s/[A-Za-z]//'` ;\
    27                 sed -i "s/SVN_REVISION.*/SVN_REVISION $$r/" $(distdir)/lib/libtrace.h.in; \
    28         fi
    29 
    3024if HAS_DOXYGEN
    3125docs/doxygen/man/man3/*.3: docs
  • README

    ra7c8f4a r3e5518a  
    1 libtrace 3.0.21
     1libtrace 3.0.22
    22
    33---------------------------------------------------------------------------
    4 Copyright (c) 2007-2014 The University of Waikato, Hamilton, New Zealand.
     4Copyright (c) 2007-2015 The University of Waikato, Hamilton, New Zealand.
    55All rights reserved.
    66
  • configure.in

    r092a09c r3e5518a  
    44# and in the README
    55
    6 AC_INIT([libtrace],[3.0.21],[contact@wand.net.nz],[libtrace])
     6AC_INIT([libtrace],[3.0.22],[contact@wand.net.nz],[libtrace])
    77
    88LIBTRACE_MAJOR=3
    99LIBTRACE_MID=0
    10 LIBTRACE_MINOR=21
     10LIBTRACE_MINOR=22
    1111
    1212# OpenSolaris hides libraries like libncurses in /usr/gnu/lib, which is not
     
    418418if test "$ac_cv_search_dlopen" != "none required"; then
    419419        LIBPKTDUMP_LIBS="$LIBPKTDUMP_LIBS $ac_cv_search_dlopen"
     420        if test "$dpdk_found" = 1; then
     421                LIBTRACE_LIBS="$LIBTRACE_LIBS -Wl,$ac_cv_search_dlopen"
     422        fi
    420423fi
    421424
  • lib/format_dag25.c

    r51d1f64 rc5ac872  
    104104/* "Global" data that is stored for each DAG output trace */
    105105struct dag_format_data_out_t {
     106        /* String containing the DAG device name */
     107        char *device_name;
    106108        /* The DAG device being used for writing */
    107109        struct dag_dev_t *device;
     
    132134        } duck;
    133135
    134         /* The DAG device that we are reading from */
     136        /* String containing the DAG device name */
     137        char *device_name;
     138        /* The DAG device that we are reading from */
    135139        struct dag_dev_t *device;
    136140        /* The DAG stream that we are reading from */
     
    146150        /* The number of packets that have been dropped */
    147151        uint64_t drops;
     152
     153        uint8_t seeninterface[4];
    148154};
    149155
     
    206212        FORMAT_DATA_OUT->stream_attached = 0;
    207213        FORMAT_DATA_OUT->device = NULL;
     214        FORMAT_DATA_OUT->device_name = NULL;
    208215        FORMAT_DATA_OUT->dagstream = 0;
    209216        FORMAT_DATA_OUT->waiting = 0;
     
    221228        FORMAT_DATA->stream_attached = 0;
    222229        FORMAT_DATA->drops = 0;
     230        FORMAT_DATA->device_name = NULL;
    223231        FORMAT_DATA->device = NULL;
    224232        FORMAT_DATA->dagstream = 0;
     
    226234        FORMAT_DATA->bottom = NULL;
    227235        FORMAT_DATA->top = NULL;
     236        memset(FORMAT_DATA->seeninterface, 0, sizeof(FORMAT_DATA->seeninterface));
    228237}
    229238
     
    275284        dag_close(dev->fd);
    276285        if (dev->dev_name)
    277         free(dev->dev_name);
     286                free(dev->dev_name);
    278287        free(dev);
    279288}
     
    389398/* Creates and initialises a DAG output trace */
    390399static int dag_init_output(libtrace_out_t *libtrace) {
    391         char *dag_dev_name = NULL;
    392400        char *scan = NULL;
    393401        struct dag_dev_t *dag_device = NULL;
     
    412420         * If no stream is specified, we will write using stream 1 */
    413421        if ((scan = strchr(libtrace->uridata,',')) == NULL) {
    414                 dag_dev_name = strdup(libtrace->uridata);
     422                FORMAT_DATA_OUT->device_name = strdup(libtrace->uridata);
    415423        } else {
    416                 dag_dev_name = (char *)strndup(libtrace->uridata,
     424                FORMAT_DATA_OUT->device_name =
     425                                (char *)strndup(libtrace->uridata,
    417426                                (size_t)(scan - libtrace->uridata));
    418427                stream = atoi(++scan);
     
    421430
    422431        /* See if our DAG device is already open */
    423         dag_device = dag_find_open_device(dag_dev_name);
     432        dag_device = dag_find_open_device(FORMAT_DATA_OUT->device_name);
    424433
    425434        if (dag_device == NULL) {
    426435                /* Device not yet opened - open it ourselves */
    427                 dag_device = dag_open_output_device(libtrace, dag_dev_name);
    428         } else {
    429                 /* Otherwise, just use the existing one */
    430                 free(dag_dev_name);
    431                 dag_dev_name = NULL;
     436                dag_device = dag_open_output_device(libtrace,
     437                                FORMAT_DATA_OUT->device_name);
    432438        }
    433439
    434440        /* Make sure we have successfully opened a DAG device */
    435441        if (dag_device == NULL) {
    436                 if (dag_dev_name) {
    437                         free(dag_dev_name);
     442                if (FORMAT_DATA_OUT->device_name) {
     443                        free(FORMAT_DATA_OUT->device_name);
     444                        FORMAT_DATA_OUT->device_name = NULL;
    438445                }
    439446                pthread_mutex_unlock(&open_dag_mutex);
     
    448455/* Creates and initialises a DAG input trace */
    449456static int dag_init_input(libtrace_t *libtrace) {
    450         char *dag_dev_name = NULL;
    451457        char *scan = NULL;
    452458        int stream = 0;
     
    464470         * If no stream is specified, we will read from stream 0 */
    465471        if ((scan = strchr(libtrace->uridata,',')) == NULL) {
    466                 dag_dev_name = strdup(libtrace->uridata);
     472                FORMAT_DATA->device_name = strdup(libtrace->uridata);
    467473        } else {
    468                 dag_dev_name = (char *)strndup(libtrace->uridata,
     474                FORMAT_DATA->device_name = (char *)strndup(libtrace->uridata,
    469475                                (size_t)(scan - libtrace->uridata));
    470476                stream = atoi(++scan);
     
    474480
    475481        /* See if our DAG device is already open */
    476         dag_device = dag_find_open_device(dag_dev_name);
     482        dag_device = dag_find_open_device(FORMAT_DATA->device_name);
    477483
    478484        if (dag_device == NULL) {
    479485                /* Device not yet opened - open it ourselves */
    480                 dag_device = dag_open_device(libtrace, dag_dev_name);
    481         } else {
    482                 /* Otherwise, just use the existing one */
    483                 free(dag_dev_name);
    484                 dag_dev_name = NULL;
     486                dag_device=dag_open_device(libtrace, FORMAT_DATA->device_name);
    485487        }
    486488
    487489        /* Make sure we have successfully opened a DAG device */
    488490        if (dag_device == NULL) {
    489                 if (dag_dev_name)
    490                         free(dag_dev_name);
    491                 dag_dev_name = NULL;
     491                if (FORMAT_DATA->device_name)
     492                        free(FORMAT_DATA->device_name);
     493                FORMAT_DATA->device_name = NULL;
    492494                pthread_mutex_unlock(&open_dag_mutex);
    493495                return -1;
     
    521523                        /* This option is used to specify the frequency of DUCK
    522524                         * updates */
    523                         DUCK.duck_freq = *(int *)data;
     525                        DUCK.duck_freq = *(int *)data;
    524526                        return 0;
    525527                case TRACE_OPTION_SNAPLEN:
     
    557559
    558560        if (dag_attach_stream(FORMAT_DATA_OUT->device->fd,
    559                         FORMAT_DATA_OUT->dagstream, 0, 1048576) < 0) {
     561                        FORMAT_DATA_OUT->dagstream, 0, 4 * 1024 * 1024) < 0) {
    560562                trace_set_err_out(libtrace, errno, "Cannot attach DAG stream");
    561563                return -1;
     
    581583static int dag_start_input(libtrace_t *libtrace) {
    582584        struct timeval zero, nopoll;
    583         uint8_t *top, *bottom;
    584         uint8_t diff = 0;
     585        uint8_t *top, *bottom, *starttop;
    585586        top = bottom = NULL;
    586587
     
    608609                                &nopoll);
    609610
     611        starttop = dag_advance_stream(FORMAT_DATA->device->fd,
     612                                        FORMAT_DATA->dagstream,
     613                                        &bottom);
     614
    610615        /* Should probably flush the memory hole now */
    611         do {
     616        top = starttop;
     617        while (starttop - bottom > 0) {
     618                bottom += (starttop - bottom);
    612619                top = dag_advance_stream(FORMAT_DATA->device->fd,
    613620                                        FORMAT_DATA->dagstream,
    614621                                        &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;
     622        }
     623        FORMAT_DATA->top = top;
     624        FORMAT_DATA->bottom = bottom;
    621625        FORMAT_DATA->processed = 0;
    622626        FORMAT_DATA->drops = 0;
     
    676680        if (DUCK.dummy_duck)
    677681                trace_destroy_dead(DUCK.dummy_duck);
     682        if (FORMAT_DATA->device_name)
     683                free(FORMAT_DATA->device_name);
    678684        free(libtrace->format_data);
    679685        pthread_mutex_unlock(&open_dag_mutex);
     
    709715        if (FORMAT_DATA_OUT->device->ref_count == 0)
    710716                dag_close_device(FORMAT_DATA_OUT->device);
     717        if (FORMAT_DATA_OUT->device_name)
     718                free(FORMAT_DATA_OUT->device_name);
    711719        free(libtrace->format_data);
    712720        pthread_mutex_unlock(&open_dag_mutex);
     
    714722}
    715723
     724#ifdef DAGIOC_CARD_DUCK
     725#define LIBTRACE_DUCK_IOCTL DAGIOC_CARD_DUCK
     726#define LIBTRACE_DUCK_VERSION TRACE_RT_DUCK_5_0
     727#else
     728#ifdef DAGIOCDUCK
     729#define LIBTRACE_DUCK_IOCTL DAGIOCDUCK
     730#define LIBTRACE_DUCK_VERSION TRACE_RT_DUCK_2_5
     731#else
     732#warning "DAG appears to be missing DUCK support"
     733#endif
     734#endif
     735
    716736/* Extracts DUCK information from the DAG card and produces a DUCK packet */
    717737static int dag_get_duckinfo(libtrace_t *libtrace,
    718738                                libtrace_packet_t *packet) {
     739
     740        if (DUCK.duck_freq == 0)
     741                return 0;
     742
     743#ifndef LIBTRACE_DUCK_IOCTL
     744        trace_set_err(libtrace, errno,
     745                "Requested DUCK information but unable to determine the correct ioctl for DUCK");
     746        DUCK.duck_freq = 0;
     747        return -1;
     748#endif
     749
     750        if (DUCK.last_pkt - DUCK.last_duck < DUCK.duck_freq)
     751                return 0;
    719752
    720753        /* Allocate memory for the DUCK data */
     
    736769        /* No need to check if we can get DUCK or not - we're modern
    737770         * enough so just grab the DUCK info */
    738         if ((ioctl(FORMAT_DATA->device->fd, DAGIOCDUCK,
     771        if ((ioctl(FORMAT_DATA->device->fd, LIBTRACE_DUCK_IOCTL,
    739772                                        (duckinf_t *)packet->payload) < 0)) {
    740                 trace_set_err(libtrace, errno, "Error using DAGIOCDUCK");
     773                trace_set_err(libtrace, errno, "Error using DUCK ioctl");
     774                DUCK.duck_freq = 0;
    741775                return -1;
    742776        }
    743777
    744         packet->type = TRACE_RT_DUCK_2_5;
    745 
    746         /* Set the packet's tracce to point at a DUCK trace, so that the
     778        packet->type = LIBTRACE_DUCK_VERSION;
     779
     780        /* Set the packet's trace to point at a DUCK trace, so that the
    747781         * DUCK format functions will be called on the packet rather than the
    748782         * DAG ones */
    749783        if (!DUCK.dummy_duck)
    750                 DUCK.dummy_duck = trace_create_dead("rt:localhost:3434");
     784                DUCK.dummy_duck = trace_create_dead("duck:dummy");
    751785        packet->trace = DUCK.dummy_duck;
     786        DUCK.last_duck = DUCK.last_pkt;
    752787        return sizeof(duckinf_t);
    753788}
     
    843878        } else {
    844879                /* Use the ERF loss counter */
    845                 DATA(libtrace)->drops += ntohs(erfptr->lctr);
     880                if (FORMAT_DATA->seeninterface[erfptr->flags.iface] == 0) {
     881                        FORMAT_DATA->seeninterface[erfptr->flags.iface] = 1;
     882                } else {
     883                        FORMAT_DATA->drops += ntohs(erfptr->lctr);
     884                }
    846885        }
    847886
     
    10441083
    10451084        /* Check if we're due for a DUCK report */
    1046         if (DUCK.last_pkt - DUCK.last_duck > DUCK.duck_freq &&
    1047                         DUCK.duck_freq != 0) {
    1048                 size = dag_get_duckinfo(libtrace, packet);
    1049                 DUCK.last_duck = DUCK.last_pkt;
    1050                 if (size != 0) {
    1051                         return size;
    1052                 }
    1053                 /* No DUCK support, so don't waste our time anymore */
    1054                 DUCK.duck_freq = 0;
    1055         }
     1085        size = dag_get_duckinfo(libtrace, packet);
     1086
     1087        if (size != 0)
     1088                return size;
     1089
    10561090
    10571091        /* Don't let anyone try to free our DAG memory hole! */
     
    11111145        int numbytes;
    11121146        uint32_t flags = 0;
    1113         struct timeval minwait;
     1147        struct timeval minwait, tv;
    11141148       
    11151149        minwait.tv_sec = 0;
    11161150        minwait.tv_usec = 10000;
     1151
     1152        /* Check if we're meant to provide a DUCK update */
     1153        numbytes = dag_get_duckinfo(libtrace, packet);
     1154        if (numbytes < 0) {
     1155                event.type = TRACE_EVENT_TERMINATE;
     1156                return event;
     1157        } else if (numbytes > 0) {
     1158                event.type = TRACE_EVENT_PACKET;
     1159                return event;
     1160        }
    11171161       
    11181162        if (dag_set_stream_poll(FORMAT_DATA->device->fd,
     
    11871231                }
    11881232
     1233                /* Update the DUCK timer */
     1234                tv = trace_get_timeval(packet);
     1235                DUCK.last_pkt = tv.tv_sec;
     1236               
    11891237                if (libtrace->snaplen > 0) {
    11901238                        trace_set_capture_length(packet, libtrace->snaplen);
  • lib/format_dpdk.c

    r9f43919 rb585975  
     1
    12/*
    23 * This file is part of libtrace
     
    6970 * code (that we still attempt to support).
    7071 *
    71  * Currently 1.5 to 1.7 is supported.
     72 * DPDK v1.7.1 is recommended.
     73 * However 1.5 to 1.8 are likely supported.
    7274 */
    7375#include <rte_eal.h>
     
    8688/* 1.6.0r2 :
    8789 *      rte_eal_pci_set_blacklist() is removed
    88  *      device_list is renamed ot pci_device_list
     90 *      device_list is renamed to pci_device_list
     91 *      In the 1.7.0 release rte_eal_pci_probe is called by rte_eal_init
     92 *      as such we do apply the whitelist before rte_eal_init.
     93 *      This also works correctly with DPDK 1.6.0r2.
    8994 *
    9095 * Replaced by:
     
    108113#else
    109114#       define DPDK_USE_PMD_INIT 0
     115#endif
     116
     117/* 1.7.0-rc3 :
     118 *
     119 * Since 1.7.0-rc3 rte_eal_pci_probe is called as part of rte_eal_init.
     120 * Somewhere between 1.7 and 1.8 calling it twice broke so we should not call
     121 * it twice.
     122 */
     123#if RTE_VERSION < RTE_VERSION_NUM(1, 7, 0, 3)
     124#       define DPDK_USE_PCI_PROBE 1
     125#else
     126#       define DPDK_USE_PCI_PROBE 0
     127#endif
     128
     129/* 1.8.0-rc1 :
     130 * LOG LEVEL is a command line option which overrides what
     131 * we previously set it to.
     132 */
     133#if RTE_VERSION >= RTE_VERSION_NUM(1, 8, 0, 1)
     134#       define DPDK_USE_LOG_LEVEL 1
     135#else
     136#       define DPDK_USE_LOG_LEVEL 0
    110137#endif
    111138
     
    329356#else /* DPDK_USE_BLACKLIST */
    330357#include <rte_devargs.h>
    331 static int blacklist_devices(struct dpdk_format_data_t *format_data UNUSED, struct rte_pci_addr *whitelist)
     358static int whitelist_device(struct dpdk_format_data_t *format_data UNUSED, struct rte_pci_addr *whitelist)
    332359{
    333360        char pci_str[20] = {0};
     
    353380 */
    354381static int parse_pciaddr(char * str, struct rte_pci_addr * addr, long * core) {
    355     char * wrkstr;
    356     char * pch;
     382    int matches;
    357383    assert(str);
    358     wrkstr = strdup(str);
    359    
    360     pch = strtok(wrkstr,":");
    361     if (pch == NULL || pch[0] == 0) {
    362         free(wrkstr); return -1;
    363     }
    364     addr->domain = (uint16_t) atoi(pch);
    365 
    366     pch = strtok(NULL,":");
    367     if (pch == NULL || pch[0] == 0) {
    368         free(wrkstr); return -1;
    369     }
    370     addr->bus = (uint8_t) atoi(pch);
    371 
    372     pch = strtok(NULL,".");
    373     if (pch == NULL || pch[0] == 0) {
    374         free(wrkstr); return -1;
    375     }
    376     addr->devid = (uint8_t) atoi(pch);
    377 
    378     pch = strtok(NULL,"-"); /* Might not find the '-' it's optional */
    379     if (pch == NULL || pch[0] == 0) {
    380         free(wrkstr); return -1;
    381     }
    382     addr->function = (uint8_t) atoi(pch);
    383 
    384     pch = strtok(NULL, ""); /* Find end of string */
    385    
    386     if (pch != NULL && pch[0] != 0) {
    387         *core = (long) atoi(pch);
    388     }
    389 
    390     free(wrkstr);
    391     return 0;
     384    matches = sscanf(str, "%4"SCNx16":%2"SCNx8":%2"SCNx8".%2"SCNx8"-%ld",
     385                     &addr->domain, &addr->bus, &addr->devid, &addr->function, core);
     386    if (matches >= 4) {
     387        return 0;
     388    } else {
     389        return -1;
     390    }
    392391}
    393392
     
    398397    struct rte_config * global_config;
    399398    long nb_cpu = sysconf(_SC_NPROCESSORS_ONLN);
    400    
     399
    401400    if (nb_cpu <= 0) {
    402401        perror("sysconf(_SC_NPROCESSORS_ONLN) failed. Falling back to the first core.");
     
    405404    if (nb_cpu > RTE_MAX_LCORE)
    406405        nb_cpu = RTE_MAX_LCORE;
    407    
     406
    408407    global_config = rte_eal_get_configuration();
    409    
     408
    410409    if (global_config != NULL) {
    411410        int i;
    412411        fprintf(stderr, "Intel DPDK setup\n"
    413                "---Version      : %"PRIu32"\n"
    414                "---Magic        : %"PRIu32"\n"
     412               "---Version      : %s\n"
    415413               "---Master LCore : %"PRIu32"\n"
    416414               "---LCore Count  : %"PRIu32"\n",
    417                global_config->version, global_config->magic,
     415               rte_version(),
    418416               global_config->master_lcore, global_config->lcore_count);
    419        
     417
    420418        for (i = 0 ; i < nb_cpu; i++) {
    421             fprintf(stderr, "   ---Core %d : %s\n", i, 
     419            fprintf(stderr, "   ---Core %d : %s\n", i,
    422420                   global_config->lcore_role[i] == ROLE_RTE ? "on" : "off");
    423421        }
    424        
     422
    425423        const char * proc_type;
    426424        switch (global_config->process_type) {
     
    442440        fprintf(stderr, "---Process Type : %s\n", proc_type);
    443441    }
    444    
     442
    445443}
    446444#endif
     
    486484#if DEBUG
    487485    rte_set_log_level(RTE_LOG_DEBUG);
    488 #else 
     486#else
    489487    rte_set_log_level(RTE_LOG_WARNING);
    490488#endif
     
    494492     * port that already in use.
    495493     */
    496     char* argv[] = {"libtrace", "-c", cpu_number, "-n", "1", "--proc-type", "auto",
    497                 "--file-prefix", mem_map, "-m", "256", NULL};
     494    char* argv[] = {"libtrace",
     495                    "-c", cpu_number,
     496                    "-n", "1",
     497                    "--proc-type", "auto",
     498                    "--file-prefix", mem_map,
     499                    "-m", "256",
     500#if DPDK_USE_LOG_LEVEL
     501#       if DEBUG
     502                    "--log-level", "8", /* RTE_LOG_DEBUG */
     503#       else
     504                    "--log-level", "5", /* RTE_LOG_WARNING */
     505#       endif
     506#endif
     507                    NULL};
    498508    int argc = sizeof(argv) / sizeof(argv[0]) - 1;
    499509
     
    543553    snprintf(cpu_number, sizeof(cpu_number), "%x", 0x1 << (my_cpu - 1));
    544554
     555#if !DPDK_USE_BLACKLIST
     556    /* Black list all ports besides the one that we want to use */
     557    if ((ret = whitelist_device(format_data, &use_addr)) < 0) {
     558        snprintf(err, errlen, "Intel DPDK - Whitelisting PCI device failed,"
     559                 " are you sure the address is correct?: %s", strerror(-ret));
     560        return -1;
     561    }
     562#endif
    545563
    546564        /* Give the memory map a unique name */
     
    572590#endif
    573591
     592#if DPDK_USE_BLACKLIST
    574593    /* Blacklist all ports besides the one that we want to use */
    575594        if ((ret = blacklist_devices(format_data, &use_addr)) < 0) {
     
    578597                return -1;
    579598        }
    580 
     599#endif
     600
     601#if DPDK_USE_PCI_PROBE
    581602    /* This loads DPDK drivers against all ports that are not blacklisted */
    582603        if ((ret = rte_eal_pci_probe()) < 0) {
     
    585606        return -1;
    586607    }
     608#endif
    587609
    588610    format_data->nb_ports = rte_eth_dev_count();
     
    845867                       8, sizeof(struct rte_pktmbuf_pool_private),
    846868                       rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL,
    847                        0, MEMPOOL_F_SP_PUT | MEMPOOL_F_SC_GET);
     869                       rte_socket_id(), MEMPOOL_F_SP_PUT | MEMPOOL_F_SC_GET);
    848870
    849871        if (format_data->pktmbuf_pool == NULL) {
     
    876898     */
    877899    ret = rte_eth_tx_queue_setup(format_data->port, format_data->queue_id,
    878                         format_data->nb_tx_buf, SOCKET_ID_ANY, &tx_conf);
     900                        format_data->nb_tx_buf, rte_socket_id(), &tx_conf);
    879901    if (ret < 0) {
    880902        snprintf(err, errlen, "Intel DPDK - Cannot configure TX queue on port"
     
    885907    /* Initialise the RX queue with some packets from memory */
    886908    ret = rte_eth_rx_queue_setup(format_data->port, format_data->queue_id,
    887                             format_data->nb_rx_buf, SOCKET_ID_ANY,
     909                            format_data->nb_rx_buf, rte_socket_id(),
    888910                            &rx_conf, format_data->pktmbuf_pool);
    889911    if (ret < 0) {
     
    11511173#if GET_MAC_CRC_CHECKSUM
    11521174    /* Add back in the CRC sum */
    1153     pkt->pkt.pkt_len += ETHER_CRC_LEN;
    1154     pkt->pkt.data_len += ETHER_CRC_LEN;
     1175    rte_pktmbuf_pkt_len(pkt) += ETHER_CRC_LEN;
     1176    rte_pktmbuf_data_len(pkt) += ETHER_CRC_LEN;
    11551177    hdr->flags |= INCLUDES_CHECKSUM;
    11561178#endif
     
    12941316        /* Poll for a single packet */
    12951317        nb_rx = rte_eth_rx_burst(FORMAT(libtrace)->port,
    1296                             FORMAT(libtrace)->queue_id, pkts_burst, 1);       
     1318                            FORMAT(libtrace)->queue_id, pkts_burst, 1);
    12971319        if (nb_rx > 0) { /* Got a packet - otherwise we keep spining */
    12981320            return dpdk_ready_pkt(libtrace, packet, pkts_burst[0]);
     1321        }
     1322        if (libtrace_halt) {
     1323            return 0;
    12991324        }
    13001325    }
  • lib/format_duck.c

    r9b097ea rc5ac872  
    216216                duck_size = sizeof(duck2_5_t);
    217217                packet->type = TRACE_RT_DUCK_2_5;
     218        } else if (DATA(libtrace)->dag_version == TRACE_RT_DUCK_5_0) {
     219                duck_size = sizeof(duck5_0_t);
     220                packet->type = TRACE_RT_DUCK_5_0;
    218221        } else {
    219222                trace_set_err(libtrace, TRACE_ERR_BAD_PACKET,
     
    252255
    253256        if (packet->type != TRACE_RT_DUCK_2_4
    254                         && packet->type != TRACE_RT_DUCK_2_5) {
     257                        && packet->type != TRACE_RT_DUCK_2_5 &&
     258                        packet->type != TRACE_RT_DUCK_5_0) {
    255259                trace_set_err_out(libtrace, TRACE_ERR_BAD_PACKET,
    256260                                "Only DUCK packets may be written to a DUCK file");
     
    287291                case TRACE_RT_DUCK_2_5:
    288292                        return sizeof(duck2_5_t);
     293                case TRACE_RT_DUCK_5_0:
     294                        return sizeof(duck5_0_t);
    289295                default:
    290296                        trace_set_err(packet->trace,TRACE_ERR_BAD_PACKET,
  • lib/format_erf.c

    rc70f59f rc69aecb  
    480480                                        packet->buffer,
    481481                                        (size_t)dag_record_size)) == -1) {
    482                 trace_set_err(libtrace,errno,"read(%s)",
    483                                 libtrace->uridata);
     482                trace_set_err(libtrace,errno,"reading ERF file");
    484483                return -1;
    485484        }
     
    488487                return 0;
    489488        }
     489
     490        if (numbytes < (int)dag_record_size) {
     491                trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Incomplete ERF header");
     492                return -1;
     493        }
    490494
    491495        rlen = ntohs(((dag_record_t *)packet->buffer)->rlen);
     
    522526                return -1;
    523527        }
     528
     529        if (numbytes < (int)size) {
     530                trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Incomplete ERF record");
     531                return -1;
     532        }
    524533       
    525534        if (erf_prepare_packet(libtrace, packet, packet->buffer,
  • lib/format_linux.c

    r63af502 r1bad1e2  
    10781078        assert((((unsigned long) header) & (pagesize - 1)) == 0);
    10791079
    1080         while (1) {
     1080        /* TP_STATUS_USER means that we can read the frame.
     1081         * When a slot does not have this flag set, the frame is not
     1082         * ready for consumption.
     1083         */
     1084        while (!(header->tp_status & TP_STATUS_USER)) {
    10811085                pollset.fd = FORMAT(libtrace->format_data)->fd;
    10821086                pollset.events = POLLIN;
     
    10891093                        return -1;
    10901094                } else if (ret == 0) {
    1091                         /* Poll timed out - check if we should exit */
    1092                         if (libtrace_halt)
    1093                                 return 0;
    1094                         continue;
    1095                 }
    1096 
    1097                 /* TP_STATUS_USER means that we can use the frame.
    1098                  * When a slot does not have this flag set, the frame is not
    1099                  * ready for consumption.
    1100                  */
    1101                 if (header->tp_status & TP_STATUS_USER)
    1102                         break;
     1095                        /* Poll timed out - check if we should exit */
     1096                        if (libtrace_halt)
     1097                                return 0;
     1098                        continue;
     1099                }
    11031100        }
    11041101
  • lib/format_pcapfile.c

    rc70f59f rc69aecb  
    210210               
    211211                if (err<1) {
    212                         if (err == 0) {
    213                                 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED,
    214                                                 "Reading pcap file header\n");
    215                         }
     212                        trace_set_err(libtrace, TRACE_ERR_INIT_FAILED,
     213                                "Error while reading pcap file header\n");
    216214                        return -1;
    217215                }
    218                
     216       
     217                if (err != (int)sizeof(DATA(libtrace)->header)) {
     218                        trace_set_err(libtrace, TRACE_ERR_INIT_FAILED,
     219                                "Incomplete pcap file header");
     220                        return -1;
     221                }
     222               
    219223                if (!header_is_magic(&(DATA(libtrace)->header))) {
    220224                        trace_set_err(libtrace,TRACE_ERR_INIT_FAILED,
     
    359363                        packet->buffer,
    360364                        sizeof(libtrace_pcapfile_pkt_hdr_t));
    361 
    362365        if (err<0) {
    363366                trace_set_err(libtrace,errno,"reading packet");
     
    368371                return 0;
    369372        }
     373
     374        if (err < (int)sizeof(libtrace_pcapfile_pkt_hdr_t)) {
     375                trace_set_err(libtrace, errno, "Incomplete pcap packet header");
     376                return -1;
     377        }
    370378
    371379        bytes_to_read = swapl(libtrace,((libtrace_pcapfile_pkt_hdr_t*)packet->buffer)->caplen);
     
    391399                        );
    392400
    393        
    394401        if (err<0) {
    395402                trace_set_err(libtrace,errno,"reading packet");
     
    399406                return 0;
    400407        }
     408
     409        if (err < (int)bytes_to_read) {
     410                trace_set_err(libtrace, errno, "Incomplete pcap packet body");
     411                return -1;
     412        }
    401413
    402414        if (pcapfile_prepare_packet(libtrace, packet, packet->buffer,
  • lib/format_rt.c

    rc70f59f rc5ac872  
    430430                case TRACE_RT_DUCK_2_4:
    431431                case TRACE_RT_DUCK_2_5:
     432                case TRACE_RT_DUCK_5_0:
    432433                        if (!RT_INFO->dummy_duck) {
    433434                                RT_INFO->dummy_duck = trace_create_dead("duck:dummy");
  • lib/format_tsh.c

    rc909fad rc69aecb  
    147147                return 0;
    148148        }
     149
     150        if (numbytes < (int)sizeof(tsh_pkt_header_t)) {
     151                trace_set_err(libtrace, errno, "Incomplete TSH header");
     152                return -1;
     153        }
    149154
    150155        buffer2 = (char*)buffer2 + numbytes;
  • lib/libtrace.h.in

    r6d082e6 rc5ac872  
    109109            ((@LIBTRACE_MAJOR@<<16)|(@LIBTRACE_MID@<<8)|(@LIBTRACE_MINOR@))
    110110
    111 /** Replaced with the current SVN revision number when 'make dist' is invoked
    112  *  to create a distributable tarball */
    113 #define LIBTRACE_SVN_REVISION 0
     111/** This used to be replaced with the current SVN revision number when
     112 * 'make dist' was invoked to create a distributable tarball. We don't use
     113 * SVN anymore and there probably isn't any need to know the exact revision
     114 * number either these days. */
     115#define LIBTRACE_SVN_REVISION LIBTRACE_API_VERSION
    114116
    115117/** DAG driver version installed on the current system */
     
    381383        TRACE_RT_CLIENTDROP     =17,/**< Reliable client was lost */
    382384        TRACE_RT_METADATA       =18,/**< Packet contains server meta-data */
     385        TRACE_RT_DUCK_5_0       =19,/**< Dag 5.0 Duck */
    383386
    384387        /** Not actually used - all DATA types begin from this value */
  • lib/libtrace_int.h

    r10f924c r6fc1ae7  
    746746 * immediately
    747747 */
    748 extern int libtrace_halt;
     748extern volatile int libtrace_halt;
    749749
    750750/** Registers a new capture format module.
  • lib/protocols_application.c

    r6d082e6 r3fc3267  
    2525 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2626 */
     27#include <stdlib.h>
    2728#include "libtrace.h"
    2829
    29 DLLEXPORT void *trace_get_payload_from_vxlan(libtrace_vxlan_t *vxlan,
    30                                             uint32_t *remaining)
     30void *trace_get_payload_from_vxlan(libtrace_vxlan_t *vxlan, uint32_t *remaining)
    3131{
    3232    if (remaining) {
     
    4343
    4444
    45 DLLEXPORT libtrace_vxlan_t *trace_get_vxlan_from_udp(libtrace_udp_t *udp,
    46                 uint32_t *remaining)
     45libtrace_vxlan_t *trace_get_vxlan_from_udp(libtrace_udp_t *udp,
     46        uint32_t *remaining)
    4747{
    4848    if (udp->dest != htons(4789)) { /* UDP port number for vxlan */
  • lib/rt_protocol.h

    r81c0b9e rc5ac872  
    249249} PACKED duck2_5_t;
    250250
     251typedef struct duck5_0 {
     252        int64_t         Phase_Correction;
     253        uint64_t        Last_Ticks;
     254        uint64_t        Last_TSC;
     255        /* XXX Stat_Start and Stat_End are time_t in dagioctl.h, which means
     256         * they could in theory be 32 or 64 bit depending on the architecture
     257         * when capturing. I'm going to assume 5.0 era DAG captures are taking
     258         * place on a 64 bit arch, rather than have to deal with the varying
     259         * sizes (especially given nobody really uses DUCK these days).
     260         */
     261        uint64_t        Stat_Start, Stat_End;
     262        uint32_t        Crystal_Freq;
     263        uint32_t        Synth_Freq;
     264        uint32_t        Resyncs;
     265        uint32_t        Bad_Pulses;
     266        uint32_t        Worst_Freq_Err, Worst_Phase_Err;
     267        uint32_t        Health_Thresh;
     268        uint32_t        Pulses, Single_Pulses_Missing, Longest_Pulse_Missing;
     269        uint32_t        Health, Sickness;
     270        int32_t         Freq_Err, Phase_Err;
     271        uint32_t        Set_Duck_Field;
     272} PACKED duck5_0_t;
     273
    251274/*
    252275typedef struct rt_duck_2_4 {
  • lib/trace.c

    r7fda5c5 r6fc1ae7  
    105105static struct libtrace_format_t *formats_list = NULL;
    106106
    107 int libtrace_halt = 0;
     107volatile int libtrace_halt = 0;
    108108
    109109/* strncpy is not assured to copy the final \0, so we
  • libwandio/ior-bzip.c

    r60f3c4c re4eff86  
    3333
    3434
     35#include "config.h"
    3536#include "wandio.h"
    3637#include <bzlib.h>
  • libwandio/ior-lzma.c

    r0e46fbc re4eff86  
    3232 */
    3333
    34 
     34#include "config.h"
    3535#include "wandio.h"
    3636#include <lzma.h>
  • libwandio/ior-peek.c

    rce7153d re4eff86  
    3232 */
    3333
     34#include "config.h"
    3435#include "wandio.h"
    3536#include <sys/types.h>
  • libwandio/ior-stdio.c

    r10f924c re4eff86  
    3434
    3535#define _GNU_SOURCE 1
     36#include "config.h"
    3637#include "wandio_internal.h"
    3738#include "wandio.h"
  • libwandio/ior-zlib.c

    r60f3c4c re4eff86  
    3333
    3434
     35#include "config.h"
    3536#include "wandio.h"
    3637#include <zlib.h>
     
    5657        int outoffset;
    5758        enum err_t err;
     59        size_t sincelastend;
    5860};
    5961
     
    8385        DATA(io)->strm.opaque = NULL;
    8486        DATA(io)->err = ERR_OK;
     87        DATA(io)->sincelastend = 1;
    8588
    8689        inflateInit2(&DATA(io)->strm, 15 | 32);
     
    108111                                sizeof(DATA(io)->inbuff));
    109112                        if (bytes_read == 0) {
    110                                 /* EOF */
     113                                /* If we get EOF immediately after a
     114                                 * Z_STREAM_END, then we assume we've reached
     115                                 * the end of the file. If there was data
     116                                 * between the Z_STREAM_END and the EOF, the
     117                                 * file has more likely been truncated.
     118                                 */
     119                                if (DATA(io)->sincelastend > 0) {
     120                                        fprintf(stderr, "Unexpected EOF while reading compressed file -- file is probably incomplete\n");
     121                                        errno = EIO;
     122                                        DATA(io)->err = ERR_ERROR;
     123                                        return -1;
     124                                }
     125
     126                                /* EOF */
    111127                                if (DATA(io)->strm.avail_out == (uint32_t)len) {
    112                                         DATA(io)->err = ERR_EOF;
     128                                        DATA(io)->err = ERR_EOF;
    113129                                        return 0;
    114130                                }
     
    128144                        DATA(io)->strm.next_in = DATA(io)->inbuff;
    129145                        DATA(io)->strm.avail_in = bytes_read;
     146                        DATA(io)->sincelastend += bytes_read;
    130147                }
    131148                /* Decompress some data into the output buffer */
     
    144161                                inflateInit2(&DATA(io)->strm, 15 | 32);
    145162                                DATA(io)->err = ERR_OK;
     163                                DATA(io)->sincelastend = 0;
    146164                                break;
    147165                        default:
  • libwandio/iow-bzip.c

    r60f3c4c re4eff86  
    3232 */
    3333
     34#include "config.h"
    3435#include "wandio.h"
    3536#include <bzlib.h>
  • libwandio/iow-lzma.c

    r0e46fbc re4eff86  
    3232
    3333
     34#include "config.h"
    3435#include <lzma.h>
    3536#include "wandio.h"
  • libwandio/iow-lzo.c

    rfa7faf3 re4eff86  
    4040 */
    4141
     42#include "config.h"
    4243#include <lzo/lzo1x.h>
    4344#include "wandio_internal.h"
    4445#include "wandio.h"
    45 #include "config.h"
    4646#include <sys/types.h>
    4747#include <sys/stat.h>
  • libwandio/iow-stdio.c

    r10f924c re4eff86  
    3434
    3535#define _GNU_SOURCE 1
     36#include "config.h"
    3637#include "wandio_internal.h"
    3738#include "wandio.h"
  • libwandio/iow-zlib.c

    r60f3c4c re4eff86  
    3333
    3434
     35#include "config.h"
    3536#include <zlib.h>
    3637#include "wandio.h"
  • test/test-vxlan.c

    r6d082e6 r3fc3267  
    7070    (void)argv;
    7171
    72     trace = trace_create("pcapfile:vxlan.pcap");
     72    trace = trace_create("pcapfile:traces/vxlan.pcap");
    7373    iferr(trace);
    7474
  • tools/tracestats/tracestats.c

    rc0ccccd r3c54095  
    157157
    158158        if (trace_is_err(trace))
    159                 trace_perror(trace,"%s",uri);
     159                trace_perror(trace,"Processing trace");
    160160
    161161        trace_destroy(trace);
  • tools/tracestats/tracesummary

    r3bfeb7d r065cab9  
    1818                --filter 'port domain' \
    1919                --filter 'icmp[icmptype]=icmp-echoreply' \
    20                 $@
     20                "$@"
Note: See TracChangeset for help on using the changeset viewer.