Changes in / [14b7489:314239a]


Ignore:
Files:
3 added
37 edited

Legend:

Unmodified
Added
Removed
  • AUTHORS

    r31da9bb r92db9e4  
    3333   well as reporting several bugs
    3434 * Richard Cziva for contributing to the DPDK support
     35 * Robert Zeh for resolving some wandio errors that were causing crashes
     36 * Anthony Coddington for adding ERF provenance support and fixing a number
     37   of other ERF/DAG issues
    3538 * Jamie Curtis for fixing a couple of bugs many many years ago
    3639 * Brendon Jones for creating the original Windows DLLs and writing bits of
  • README

    re3fa533 r0e8f8cb  
    1 libtrace 4.0.2
     1libtrace 4.0.3
    22
    33---------------------------------------------------------------------------
    4 Copyright (c) 2007-2017 The University of Waikato, Hamilton, New Zealand.
     4Copyright (c) 2007-2018 The University of Waikato, Hamilton, New Zealand.
    55All rights reserved.
    66
     
    2727
    2828Bugs should be reported by either emailing contact@wand.net.nz or filing
    29 an issue at https://github.com/wanduow/libtrace
     29an issue at https://github.com/LibtraceTeam/libtrace
    3030
    3131It is licensed under the GNU Lesser General Public License (GPL) version 3.
     
    3434
    3535A detailed ChangeLog can be found on the libtrace wiki:
    36 https://github.com/wanduow/libtrace/wiki/ChangeLog
     36https://github.com/LibtraceTeam/libtrace/wiki/ChangeLog
    3737
    3838Documentation, usage instructions and a detailed tutorial can also found
  • configure.in

    r9993cde r0e8f8cb  
    44# and in the README
    55
    6 AC_INIT([libtrace],[4.0.2],[contact@wand.net.nz],[libtrace])
     6AC_INIT([libtrace],[4.0.3],[contact@wand.net.nz],[libtrace])
    77
    88LIBTRACE_MAJOR=4
    99LIBTRACE_MID=0
    10 LIBTRACE_MINOR=2
     10LIBTRACE_MINOR=3
    1111
    1212# OpenSolaris hides libraries like libncurses in /usr/gnu/lib, which is not
     
    247247        AC_MSG_ERROR(libpcap0.8 or greater is required to compile libtrace. If you have installed it in a non-standard location please use LDFLAGS to specify the location of the library)
    248248else
    249         TOOL_LIBS="$TOOL_LIBS -lpcap"
     249        TOOLS_LIBS="$TOOLS_LIBS -lpcap"
    250250        LIBTRACE_LIBS="$LIBTRACE_LIBS -lpcap"
    251251        AC_DEFINE([HAVE_LIBPCAP],1,[compile with libpcap support])
     
    403403        # So instead simply check for existence
    404404        if test "$RTE_SDK" != ""; then
    405                 AC_CHECK_FILE("$RTE_SDK/$RTE_TARGET/lib/libintel_dpdk.a", dpdk_found="libintel_dpdk.a", dpdk_found=0)
     405                AC_CHECK_FILE("$RTE_SDK/$RTE_TARGET/lib/libintel_dpdk.a", dpdk_found=":libintel_dpdk.a", dpdk_found=0)
    406406        fi
    407407        # DPDK 2.1.0+ renames this to libdpdk from libintel_dpdk
    408408        if test "$dpdk_found" = 0 -a "$RTE_SDK" != ""; then
    409                 AC_CHECK_FILE("$RTE_SDK/$RTE_TARGET/lib/libdpdk.a", dpdk_found="libdpdk.a", dpdk_found=0)
     409                AC_CHECK_FILE("$RTE_SDK/$RTE_TARGET/lib/libdpdk.a", dpdk_found=":libdpdk.a", dpdk_found=0)
     410        fi
     411        if test "$dpdk_found" = 0 -a "$RTE_SDK" != ""; then
     412                AC_CHECK_FILE("$RTE_SDK/$RTE_TARGET/lib/libdpdk.so", dpdk_found="dpdk", dpdk_found=0)
    410413        fi
    411414        if test "$dpdk_found" != 0 -a "$RTE_SDK" != ""; then
     
    414417                AC_SUBST([RTE_SDK])
    415418                # Force dpdk library to be statically linked to allow compiler optimisations
    416                 LIBTRACE_LIBS="$LIBTRACE_LIBS -Wl,--whole-archive -Wl,-l:$dpdk_found -Wl,--no-whole-archive -Wl,-lm"
     419                LIBTRACE_LIBS="$LIBTRACE_LIBS -Wl,--whole-archive -Wl,-l$dpdk_found -Wl,--no-whole-archive -Wl,-lm"
    417420                AC_DEFINE(HAVE_DPDK,1,[conditional for building with DPDK live capture support])
    418421                libtrace_dpdk=true
  • lib/Makefile.am

    rea75ec2 r49969f2  
    22include_HEADERS = libtrace.h libtrace_parallel.h
    33pkginclude_HEADERS = dagformat.h lt_inttypes.h daglegacy.h \
    4         rt_protocol.h erftypes.h \
     4        rt_protocol.h erftypes.h pthread_spinlock.h \
    55        data-struct/ring_buffer.h data-struct/object_cache.h \
    66        data-struct/vector.h \
     
    3434
    3535if HAVE_DPDK
    36 NATIVEFORMATS+= format_dpdk.c
     36NATIVEFORMATS+= format_dpdk.c format_dpdkndag.c
    3737# So we also make libtrace.mk in dpdk otherwise automake tries to expand
    3838# it too early which I cannot seem to stop unless we use a path that
  • lib/data-struct/message_queue.h

    ree6e802 r16bb26f  
    2626#include <pthread.h>
    2727#include <limits.h>
    28 #include "../libtrace.h"
    29 #include "../pthread_spinlock.h"
     28#include "libtrace.h"
     29#include "pthread_spinlock.h"
    3030
    3131#ifndef LIBTRACE_MESSAGE_QUEUE
     
    4040} libtrace_message_queue_t;
    4141
    42 void libtrace_message_queue_init(libtrace_message_queue_t *mq, size_t message_len);
    43 int libtrace_message_queue_put(libtrace_message_queue_t *mq, const void *message);
    44 int libtrace_message_queue_count(const libtrace_message_queue_t *mq);
    45 int libtrace_message_queue_get(libtrace_message_queue_t *mq, void *message);
    46 int libtrace_message_queue_try_get(libtrace_message_queue_t *mq, void *message);
    47 void libtrace_message_queue_destroy(libtrace_message_queue_t *mq);
    48 int libtrace_message_queue_get_fd(libtrace_message_queue_t *mq);
     42DLLEXPORT void libtrace_message_queue_init(libtrace_message_queue_t *mq,
     43        size_t message_len);
     44DLLEXPORT int libtrace_message_queue_put(libtrace_message_queue_t *mq,
     45        const void *message);
     46DLLEXPORT int libtrace_message_queue_count(const libtrace_message_queue_t *mq);
     47DLLEXPORT int libtrace_message_queue_get(libtrace_message_queue_t *mq,
     48        void *message);
     49DLLEXPORT int libtrace_message_queue_try_get(libtrace_message_queue_t *mq,
     50        void *message);
     51DLLEXPORT void libtrace_message_queue_destroy(libtrace_message_queue_t *mq);
     52DLLEXPORT int libtrace_message_queue_get_fd(libtrace_message_queue_t *mq);
    4953
    5054#endif
  • lib/data-struct/ring_buffer.h

    ree6e802 r49969f2  
    2626#include <pthread.h>
    2727#include <semaphore.h>
    28 #include "../libtrace.h"
    29 #include "../pthread_spinlock.h"
     28#include "libtrace.h"
     29#include "pthread_spinlock.h"
    3030
    3131#ifndef LIBTRACE_RINGBUFFER_H
  • lib/erftypes.h

    ree6e802 ra857389  
    162162#endif
    163163
     164/** Provenance Metadata Record */
     165#ifndef ERF_TYPE_META
     166#define ERF_TYPE_META   27
     167#endif
     168/* TODO: Endace has deprecated TYPE_* in favour of ERF_TYPE_*. New types do not have TYPE_* aliases. */
     169#ifndef TYPE_META
     170#define TYPE_META       ERF_TYPE_META
     171#endif
     172
    164173/** Padding record */
    165174#ifndef TYPE_PAD
     
    167176#endif
    168177
     178#ifndef ERF_TYPE_MAX
     179#define ERF_TYPE_MAX    TYPE_PAD
     180#endif
    169181
    170182#endif /* _ERFTYPES_H_ */
  • lib/format_atmhdr.c

    ree6e802 r2c457ec  
    137137        {
    138138                if (numbytes != 0) {
    139                         trace_set_err(libtrace,errno,"read(%s)",libtrace->uridata);
     139                        trace_set_err(libtrace,TRACE_ERR_WANDIO_FAILED,"read(%s)",libtrace->uridata);
    140140                }
    141141                return numbytes;
  • lib/format_dag25.c

    rdb84bb2 ra857389  
    187187                switch(erfptr->type) {
    188188                        case TYPE_ETH:
     189                        case TYPE_COLOR_ETH:
    189190                        case TYPE_DSM_COLOR_ETH:
     191                        case TYPE_COLOR_HASH_ETH:
    190192                                return 2;
    191193                        default:                return 0;
     
    626628
    627629        /* Attach and start the DAG stream */
    628         if (dag_attach_stream(FORMAT_DATA_OUT->device->fd,
     630        if (dag_attach_stream64(FORMAT_DATA_OUT->device->fd,
    629631                        FORMAT_DATA_OUT->dagstream, 0, 4 * 1024 * 1024) < 0) {
    630632                trace_set_err_out(libtrace, errno, "Cannot attach DAG stream");
     
    640642
    641643        /* We don't want the dag card to do any sleeping */
    642         dag_set_stream_poll(FORMAT_DATA_OUT->device->fd,
     644        dag_set_stream_poll64(FORMAT_DATA_OUT->device->fd,
    643645                        FORMAT_DATA_OUT->dagstream, 0, &zero,
    644646                        &nopoll);
     
    658660
    659661        /* Attach and start the DAG stream */
    660         if (dag_attach_stream(FORMAT_DATA->device->fd,
     662        if (dag_attach_stream64(FORMAT_DATA->device->fd,
    661663                              stream->dagstream, 0, 0) < 0) {
    662664                trace_set_err(libtrace, errno, "Cannot attach DAG stream #%u",
     
    674676
    675677        /* We don't want the dag card to do any sleeping */
    676         if (dag_set_stream_poll(FORMAT_DATA->device->fd,
     678        if (dag_set_stream_poll64(FORMAT_DATA->device->fd,
    677679                            stream->dagstream, 0, &zero,
    678680                            &nopoll) < 0) {
     
    866868        /* Wait until the buffer is nearly clear before exiting the program,
    867869         * as we will lose packets otherwise */
    868         dag_tx_get_stream_space
     870        dag_tx_get_stream_space64
    869871                (FORMAT_DATA_OUT->device->fd,
    870872                 FORMAT_DATA_OUT->dagstream,
    871                  dag_get_stream_buffer_size(FORMAT_DATA_OUT->device->fd,
     873                 dag_get_stream_buffer_size64(FORMAT_DATA_OUT->device->fd,
    872874                                            FORMAT_DATA_OUT->dagstream) - 8);
    873875
     
    10501052        /* No loss counter for DSM coloured records - have to use some
    10511053         * other API */
    1052         if (erfptr->type == TYPE_DSM_COLOR_ETH) {
     1054        if (erf_is_color_type(erfptr->type)) {
    10531055                /* TODO */
    10541056        } else {
     
    11001102        if (FORMAT_DATA_OUT->waiting == 0) {
    11011103                FORMAT_DATA_OUT->txbuffer =
    1102                         dag_tx_get_stream_space(FORMAT_DATA_OUT->device->fd,
     1104                        dag_tx_get_stream_space64(FORMAT_DATA_OUT->device->fd,
    11031105                                                FORMAT_DATA_OUT->dagstream,
    11041106                                                16908288);
     
    12861288        }
    12871289
    1288         if (dag_set_stream_poll(FORMAT_DATA->device->fd, stream_data->dagstream,
     1290        if (dag_set_stream_poll64(FORMAT_DATA->device->fd, stream_data->dagstream,
    12891291                                sizeof(dag_record_t), &maxwait,
    12901292                                &pollwait) == -1) {
     
    13921394        }
    13931395       
    1394         if (dag_set_stream_poll(FORMAT_DATA->device->fd,
     1396        if (dag_set_stream_poll64(FORMAT_DATA->device->fd,
    13951397                                FORMAT_DATA_FIRST->dagstream, 0, &minwait,
    13961398                                &minwait) == -1) {
  • lib/format_dpdk.c

    rdb84bb2 r8ed07df  
    4242#include "libtrace_arphrd.h"
    4343#include "hash_toeplitz.h"
     44#include "format_dpdk.h"
    4445
    4546#ifdef HAVE_INTTYPES_H
     
    5455#include <endian.h>
    5556#include <string.h>
     57#include <math.h>
    5658
    5759#if HAVE_LIBNUMA
    5860#include <numa.h>
    5961#endif
    60 
    61 /* We can deal with any minor differences by checking the RTE VERSION
    62  * Typically DPDK backports some fixes (typically for building against
    63  * newer kernels) to the older version of DPDK.
    64  *
    65  * These get released with the rX suffix. The following macros where added
    66  * in these new releases.
    67  *
    68  * Below this is a log of version that required changes to the libtrace
    69  * code (that we still attempt to support).
    70  *
    71  * DPDK 16.04 or newer is recommended.
    72  * However 1.6 and newer are still likely supported.
    73  */
    74 #include <rte_eal.h>
    75 #include <rte_version.h>
    76 #ifndef RTE_VERSION_NUM
    77 #       define RTE_VERSION_NUM(a,b,c,d) ((a) << 24 | (b) << 16 | (c) << 8 | (d))
    78 #endif
    79 #ifndef RTE_VER_PATCH_RELEASE
    80 #       define RTE_VER_PATCH_RELEASE 0
    81 #endif
    82 #ifndef RTE_VERSION
    83 #       define RTE_VERSION RTE_VERSION_NUM(RTE_VER_MAJOR,RTE_VER_MINOR, \
    84         RTE_VER_PATCH_LEVEL, RTE_VER_PATCH_RELEASE)
    85 #endif
    86 
    87 /* 1.6.0r2 :
    88  *      rte_eal_pci_set_blacklist() is removed
    89  *      device_list is renamed to pci_device_list
    90  *      In the 1.7.0 release rte_eal_pci_probe is called by rte_eal_init
    91  *      as such we do apply the whitelist before rte_eal_init.
    92  *      This also works correctly with DPDK 1.6.0r2.
    93  *
    94  * Replaced by:
    95  *      rte_devargs (we can simply whitelist)
    96  */
    97 #if RTE_VERSION <= RTE_VERSION_NUM(1, 6, 0, 1)
    98 #       define DPDK_USE_BLACKLIST 1
    99 #else
    100 #       define DPDK_USE_BLACKLIST 0
    101 #endif
    102 
    103 /*
    104  * 1.7.0 :
    105  *      rte_pmd_init_all is removed
    106  *
    107  * Replaced by:
    108  *      Nothing, no longer needed
    109  */
    110 #if RTE_VERSION < RTE_VERSION_NUM(1, 7, 0, 0)
    111 #       define DPDK_USE_PMD_INIT 1
    112 #else
    113 #       define DPDK_USE_PMD_INIT 0
    114 #endif
    115 
    116 /* 1.7.0-rc3 :
    117  *
    118  * Since 1.7.0-rc3 rte_eal_pci_probe is called as part of rte_eal_init.
    119  * Somewhere between 1.7 and 1.8 calling it twice broke so we should not call
    120  * it twice.
    121  */
    122 #if RTE_VERSION < RTE_VERSION_NUM(1, 7, 0, 3)
    123 #       define DPDK_USE_PCI_PROBE 1
    124 #else
    125 #       define DPDK_USE_PCI_PROBE 0
    126 #endif
    127 
    128 /* 1.8.0-rc1 :
    129  * LOG LEVEL is a command line option which overrides what
    130  * we previously set it to.
    131  */
    132 #if RTE_VERSION >= RTE_VERSION_NUM(1, 8, 0, 1)
    133 #       define DPDK_USE_LOG_LEVEL 1
    134 #else
    135 #       define DPDK_USE_LOG_LEVEL 0
    136 #endif
    137 
    138 /* 1.8.0-rc2
    139  * rx/tx_conf thresholds can be set to NULL in rte_eth_rx/tx_queue_setup
    140  * this uses the default values, which are better tuned per device
    141  * See issue #26
    142  */
    143 #if RTE_VERSION >= RTE_VERSION_NUM(1, 8, 0, 2)
    144 #       define DPDK_USE_NULL_QUEUE_CONFIG 1
    145 #else
    146 #       define DPDK_USE_NULL_QUEUE_CONFIG 0
    147 #endif
    148 
    149 /* 2.0.0-rc1
    150  * Unifies RSS hash between cards
    151  */
    152 #if RTE_VERSION >= RTE_VERSION_NUM(2, 0, 0, 1)
    153 #       define RX_RSS_FLAGS (ETH_RSS_IP | ETH_RSS_UDP | ETH_RSS_TCP | \
    154                              ETH_RSS_SCTP)
    155 #else
    156 #       define RX_RSS_FLAGS (ETH_RSS_IPV4_UDP | ETH_RSS_IPV6 | ETH_RSS_IPV4 | \
    157                              ETH_RSS_IPV4_TCP | ETH_RSS_IPV6_TCP |\
    158                              ETH_RSS_IPV6_UDP)
    159 #endif
    160 
    161 /* v16.07-rc1 - deprecated
    162  * rte_mempool_avail_count to replace rte_mempool_count
    163  * rte_mempool_in_use_count to replace rte_mempool_free_count
    164  */
    165 #if RTE_VERSION < RTE_VERSION_NUM(16, 7, 0, 1)
    166 #define rte_mempool_avail_count rte_mempool_count
    167 #define rte_mempool_in_use_count rte_mempool_free_count
    168 #endif
    169 
    170 #include <rte_per_lcore.h>
    171 #include <rte_debug.h>
    172 #include <rte_errno.h>
    173 #include <rte_common.h>
    174 #include <rte_log.h>
    175 #include <rte_memcpy.h>
    176 #include <rte_prefetch.h>
    177 #include <rte_branch_prediction.h>
    178 #include <rte_pci.h>
    179 #include <rte_ether.h>
    180 #include <rte_ethdev.h>
    181 #include <rte_ring.h>
    182 #include <rte_mempool.h>
    183 #include <rte_mbuf.h>
    184 #include <rte_launch.h>
    185 #include <rte_lcore.h>
    186 #include <rte_per_lcore.h>
    187 #include <rte_cycles.h>
    188 #include <pthread.h>
    189 #ifdef __FreeBSD__
    190 #include <pthread_np.h>
    191 #endif
    192 
    193 /* 16.04-rc3 ETH_LINK_SPEED_X are replaced with ETH_SPEED_NUM_X.
    194  * ETH_LINK_SPEED_ are reused as flags, ugly.
    195  * We use the new way in this code.
    196  */
    197 #ifndef ETH_SPEED_NUM_1G
    198         #define ETH_SPEED_NUM_1G ETH_LINK_SPEED_1000
    199         #define ETH_SPEED_NUM_10G ETH_LINK_SPEED_10G
    200         #define ETH_SPEED_NUM_20G ETH_LINK_SPEED_20G
    201         #define ETH_SPEED_NUM_40G ETH_LINK_SPEED_40G
    202 #endif
    203 
    204 /* The default size of memory buffers to use - This is the max size of standard
    205  * ethernet packet less the size of the MAC CHECKSUM */
    206 #define RX_MBUF_SIZE 1514
    207 
    208 /* The minimum number of memory buffers per queue tx or rx. Based on
    209  * the requirement of the memory pool with 128 per thread buffers, needing
    210  * at least 128*1.5 = 192 buffers. Our code allocates 128*2 to be safe.
    211  */
    212 #define MIN_NB_BUF 128
    213 
    214 /* Number of receive memory buffers to use
    215  * By default this is limited by driver to 4k and must be a multiple of 128.
    216  * A modification can be made to the driver to remove this limit.
    217  * This can be increased in the driver and here.
    218  * Should be at least MIN_NB_BUF.
    219  * We choose 2K rather than 4K because it enables the usage of sse vector
    220  * drivers which are significantly faster than using the larger buffer.
    221  */
    222 #define NB_RX_MBUF (4096/2)
    223 
    224 /* Number of send memory buffers to use.
    225  * Same limits apply as those to NB_TX_MBUF.
    226  */
    227 #define NB_TX_MBUF 1024
    228 
    229 /* The size of the PCI blacklist needs to be big enough to contain
    230  * every PCI device address (listed by lspci every bus:device.function tuple).
    231  */
    232 #define BLACK_LIST_SIZE 50
    233 
    234 /* The maximum number of characters the mempool name can be */
    235 #define MEMPOOL_NAME_LEN 20
    236 
    237 /* For single threaded libtrace we read packets as a batch/burst
    238  * this is the maximum size of said burst */
    239 #define BURST_SIZE 32
    24062
    24163#define MBUF(x) ((struct rte_mbuf *) x)
     
    25981#endif
    26082
    261 /* ~~~~~~~~~~~~~~~~~~~~~~ Advance settings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    262  * THESE MAY REQUIRE MODIFICATIONS TO INTEL DPDK
    263  *
    264  * Make sure you understand what these are doing before enabling them.
    265  * They might make traces incompatible with other builds etc.
    266  *
    267  * These are also included to show how to do somethings which aren't
    268  * obvious in the DPDK documentation.
    269  */
    270 
    271 /* Print verbose messages to stderr */
    272 #define DEBUG 0
    273 
    274 /* Use clock_gettime() for nanosecond resolution rather than gettimeofday()
    275  * only turn on if you know clock_gettime is a vsyscall on your system
    276  * otherwise could be a large overhead. Again gettimeofday() should be
    277  * vsyscall also if it's not you should seriously consider updating your
    278  * kernel.
    279  */
    280 #ifdef HAVE_CLOCK_GETTIME
    281 /* You can turn this on (set to 1) to prefer clock_gettime */
    282 #define USE_CLOCK_GETTIME 1
    283 #else
    284 /* DON'T CHANGE THIS !!! */
    285 #define USE_CLOCK_GETTIME 0
    286 #endif
    287 
    288 /* This is fairly safe to turn on - currently there appears to be a 'bug'
    289  * in DPDK that will remove the checksum by making the packet appear 4bytes
    290  * smaller than what it really is. Most formats don't include the checksum
    291  * hence writing out a port such as int: ring: and dpdk: assumes there
    292  * is no checksum and will attempt to write the checksum as part of the
    293  * packet
    294  */
    295 #define GET_MAC_CRC_CHECKSUM 0
    296 
    297 /* This requires a modification of the pmd drivers (inside Intel DPDK)
    298  * TODO this requires updating (packet sizes are wrong TS most likely also)
    299  */
    300 #define HAS_HW_TIMESTAMPS_82580 0
    301 
    302 #if HAS_HW_TIMESTAMPS_82580
    303 # define TS_NBITS_82580     40
    304 /* The maximum on the +ve or -ve side that we can be, make it half way */
    305 # define MAXSKEW_82580 ((uint64_t) (.5 * (double)(1ull<<TS_NBITS_82580)))
    306 #define WITHIN_VARIANCE(v1,v2,var) (((v1) - (var) < (v2)) && ((v1) + (var) > (v2)))
    307 #endif
    30883
    30984static pthread_mutex_t dpdk_lock = PTHREAD_MUTEX_INITIALIZER;
    31085/* Memory pools Per NUMA node */
    31186static struct rte_mempool * mem_pools[4][RTE_MAX_LCORE] = {{0}};
    312 
    313 /* As per Intel 82580 specification - mismatch in 82580 datasheet
    314  * it states ts is stored in Big Endian, however its actually Little */
    315 struct hw_timestamp_82580 {
    316         uint64_t reserved;
    317         uint64_t timestamp; /* Little Endian only lower 40 bits are valid */
    318 };
    319 
    320 enum paused_state {
    321         DPDK_NEVER_STARTED,
    322         DPDK_RUNNING,
    323         DPDK_PAUSED,
    324 };
    325 
    326 struct dpdk_per_stream_t
    327 {
    328         uint16_t queue_id;
    329         uint64_t ts_last_sys; /* System timestamp of our most recent packet in nanoseconds */
    330         struct rte_mempool *mempool;
    331         int lcore;
    332 #if HAS_HW_TIMESTAMPS_82580
    333         /* Timestamping only relevant to RX */
    334         uint64_t ts_first_sys; /* Sytem timestamp of the first packet in nanoseconds */
    335         uint32_t wrap_count; /* Number of times the NIC clock has wrapped around completely */
    336 #endif
    337 } ALIGN_STRUCT(CACHE_LINE_SIZE);
    338 
    339 #if HAS_HW_TIMESTAMPS_82580
    340 #define DPDK_EMPTY_STREAM {-1, 0, NULL, -1, 0, 0}
    341 #else
    342 #define DPDK_EMPTY_STREAM {-1, 0, NULL, -1}
    343 #endif
    344 
    345 typedef struct dpdk_per_stream_t dpdk_per_stream_t;
    34687
    34788/* Used by both input and output however some fields are not used
     
    473214        int matches;
    474215        assert(str);
    475         matches = sscanf(str, "%4"SCNx16":%2"SCNx8":%2"SCNx8".%2"SCNx8"-%ld",
     216        matches = sscanf(str, "%8"SCNx32":%2"SCNx8":%2"SCNx8".%2"SCNx8"-%ld",
    476217                         &addr->domain, &addr->bus, &addr->devid,
    477218                         &addr->function, core);
     
    687428
    688429#if DEBUG
    689         rte_set_log_level(RTE_LOG_DEBUG);
     430        rte_log_set_global_level(RTE_LOG_DEBUG);
    690431#else
    691         rte_set_log_level(RTE_LOG_WARNING);
     432        rte_log_set_global_level(RTE_LOG_WARNING);
    692433#endif
    693434
     
    833574}
    834575
    835 static int dpdk_init_input (libtrace_t *libtrace) {
     576int dpdk_init_input (libtrace_t *libtrace) {
    836577        dpdk_per_stream_t stream = DPDK_EMPTY_STREAM;
    837578        char err[500];
     
    875616static int dpdk_init_output(libtrace_out_t *libtrace)
    876617{
     618        dpdk_per_stream_t stream = DPDK_EMPTY_STREAM;
    877619        char err[500];
    878620        err[0] = 0;
     
    897639        FORMAT(libtrace)->burst_offset = 0;
    898640
     641        FORMAT(libtrace)->per_stream = libtrace_list_init(sizeof(struct dpdk_per_stream_t));
     642        libtrace_list_push_back(FORMAT(libtrace)->per_stream, &stream);
     643
    899644        if (dpdk_init_environment(libtrace->uridata, FORMAT(libtrace), err, sizeof(err)) != 0) {
    900645                trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "%s", err);
     
    916661 *
    917662 */
    918 static int dpdk_config_input (libtrace_t *libtrace,
     663int dpdk_config_input (libtrace_t *libtrace,
    919664                              trace_option_t option,
    920665                              void *data) {
     
    1071816 * @param cb_arg The dpdk_format_data_t structure associated with the format
    1072817 */
    1073 static void dpdk_lsc_callback(uint8_t port, enum rte_eth_event_type event,
    1074                               void *cb_arg) {
     818static int dpdk_lsc_callback(uint16_t port, enum rte_eth_event_type event,
     819                              void *cb_arg, void *retparam UNUSED) {
    1075820        struct dpdk_format_data_t * format_data = cb_arg;
    1076821        struct rte_eth_link link_info;
     
    1107852        }
    1108853#endif
     854        return 0;
    1109855}
    1110856
     
    13191065                        port_conf.rxmode.max_rx_pkt_len = 0;
    13201066                } else {
     1067                        double expn;
     1068
    13211069                        /* Use jumbo frames */
    13221070                        port_conf.rxmode.jumbo_frame = 1;
    13231071                        port_conf.rxmode.max_rx_pkt_len = format_data->snaplen;
     1072
     1073                        /* Use less buffers if we're supporting jumbo frames
     1074                         * otherwise we won't be able to allocate memory.
     1075                         */
     1076                        if (format_data->snaplen > 1500) {
     1077                                format_data->nb_rx_buf /= 2;
     1078                        }
     1079
     1080                        /* snaplen should be rounded up to next power of two
     1081                         * to ensure enough memory is allocated for each
     1082                         * mbuf :(
     1083                         */
     1084                        expn = ceil(log2((double)(format_data->snaplen)));
     1085                        format_data->snaplen = pow(2, (int)expn);
    13241086                }
    13251087
     
    15121274}
    15131275
    1514 static int dpdk_start_input (libtrace_t *libtrace) {
     1276int dpdk_start_input (libtrace_t *libtrace) {
    15151277        char err[500];
    15161278        err[0] = 0;
     
    15421304}
    15431305
    1544 static int dpdk_pstart_input (libtrace_t *libtrace) {
     1306int dpdk_pstart_input (libtrace_t *libtrace) {
    15451307        char err[500];
    15461308        int i=0, phys_cores=0;
     
    16151377 *                in any other manner including statistics functions.
    16161378 */
    1617 static int dpdk_pregister_thread(libtrace_t *libtrace, libtrace_thread_t *t, bool reading)
     1379int dpdk_pregister_thread(libtrace_t *libtrace, libtrace_thread_t *t, bool reading)
    16181380{
    16191381#if DEBUG
     
    16651427 * they are destroyed.
    16661428 */
    1667 static void dpdk_punregister_thread(libtrace_t *libtrace UNUSED, libtrace_thread_t *t UNUSED)
     1429void dpdk_punregister_thread(libtrace_t *libtrace UNUSED, libtrace_thread_t *t UNUSED)
    16681430{
    16691431        struct rte_config *cfg = rte_eal_get_configuration();
     
    17011463}
    17021464
    1703 static int dpdk_pause_input(libtrace_t * libtrace) {
     1465int dpdk_pause_input(libtrace_t * libtrace) {
    17041466        libtrace_list_node_t *tmp = FORMAT_DATA_HEAD(libtrace);
    17051467        /* This stops the device, but can be restarted using rte_eth_dev_start() */
     
    17561518}
    17571519
    1758 static int dpdk_fin_input(libtrace_t * libtrace) {
     1520int dpdk_fin_input(libtrace_t * libtrace) {
    17591521        libtrace_list_node_t * n;
    17601522        /* Free our memory structures */
     
    18491611}
    18501612
    1851 static int dpdk_get_framing_length (const libtrace_packet_t *packet) {
     1613int dpdk_get_framing_length (const libtrace_packet_t *packet) {
    18521614        struct dpdk_addt_hdr * hdr = get_addt_hdr(packet);
    18531615        if (hdr->flags & INCLUDES_HW_TIMESTAMP)
     
    18581620}
    18591621
    1860 static int dpdk_prepare_packet(libtrace_t *libtrace UNUSED,
     1622int dpdk_prepare_packet(libtrace_t *libtrace UNUSED,
    18611623                               libtrace_packet_t *packet, void *buffer,
    18621624                               libtrace_rt_types_t rt_type, uint32_t flags) {
     
    21161878/** Reads at least one packet or returns an error
    21171879 */
    2118 static inline int dpdk_read_packet_stream (libtrace_t *libtrace,
     1880int dpdk_read_packet_stream (libtrace_t *libtrace,
    21191881                                           dpdk_per_stream_t *stream,
    21201882                                           libtrace_message_queue_t *mesg,
     
    21811943}
    21821944
    2183 static int dpdk_read_packet (libtrace_t *libtrace, libtrace_packet_t *packet) {
     1945int dpdk_read_packet (libtrace_t *libtrace, libtrace_packet_t *packet) {
    21841946        int nb_rx; /* Number of rx packets we've received */
    21851947        dpdk_per_stream_t *stream = FORMAT_DATA_FIRST(libtrace);
     
    21991961        if (FORMAT(libtrace)->burst_size != FORMAT(libtrace)->burst_offset) {
    22001962                packet->buffer = FORMAT(libtrace)->burst_pkts[FORMAT(libtrace)->burst_offset++];
     1963                packet->trace = libtrace;
    22011964                dpdk_prepare_packet(libtrace, packet, packet->buffer, packet->type, 0);
    22021965                return 1; // TODO should be bytes read, which essentially useless anyway
     
    22101973                FORMAT(libtrace)->burst_offset = 1;
    22111974                packet->buffer = FORMAT(libtrace)->burst_pkts[0];
     1975                packet->trace = libtrace;
    22121976                dpdk_prepare_packet(libtrace, packet, packet->buffer, packet->type, 0);
    22131977                return 1;
     
    22492013}
    22502014
    2251 static void dpdk_get_stats(libtrace_t *trace, libtrace_stat_t *stats) {
     2015void dpdk_get_stats(libtrace_t *trace, libtrace_stat_t *stats) {
    22522016        struct rte_eth_stats dev_stats = {0};
    22532017
     
    22832047 * create a select()able file descriptor in DPDK.
    22842048 */
    2285 static libtrace_eventobj_t dpdk_trace_event(libtrace_t *trace,
     2049libtrace_eventobj_t dpdk_trace_event(libtrace_t *trace,
    22862050                                            libtrace_packet_t *packet) {
    22872051        libtrace_eventobj_t event = {0,0,0.0,0};
  • lib/format_erf.c

    r0317e3c r207e288  
    120120} erf_index_t;
    121121
    122 
    123122/* Ethernet packets have a 2 byte padding before the packet
    124123 * so that the IP header is aligned on a 32 bit boundary.
    125124 */
    126 static int erf_get_padding(const libtrace_packet_t *packet)
     125static inline int erf_get_padding(const libtrace_packet_t *packet)
    127126{
    128127        if (packet->trace->format->type==TRACE_FORMAT_ERF ||
    129128                        packet->trace->format->type == TRACE_FORMAT_NDAG ||
    130                         packet->trace->format->type == TRACE_FORMAT_RAWERF) {
     129                        packet->trace->format->type == TRACE_FORMAT_RAWERF ||
     130                        packet->trace->format->type == TRACE_FORMAT_DPDK_NDAG) {
    131131                dag_record_t *erfptr = (dag_record_t *)packet->header;
    132132                switch((erfptr->type & 0x7f)) {
    133                         case TYPE_ETH:         
     133                        case TYPE_ETH:
     134                        case TYPE_COLOR_ETH:
    134135                        case TYPE_DSM_COLOR_ETH:
     136                        case TYPE_COLOR_HASH_ETH:
    135137                                return 2;
    136138                        default:                return 0;
     
    145147}
    146148
     149int erf_is_color_type(uint8_t erf_type)
     150{
     151        switch(erf_type & 0x7f) {
     152                case TYPE_COLOR_HDLC_POS:
     153                case TYPE_DSM_COLOR_HDLC_POS:
     154                case TYPE_COLOR_ETH:
     155                case TYPE_DSM_COLOR_ETH:
     156                case TYPE_COLOR_HASH_POS:
     157                case TYPE_COLOR_HASH_ETH:
     158                        return 1;
     159        }
     160
     161        return 0;
     162}
     163
    147164int erf_get_framing_length(const libtrace_packet_t *packet)
    148165{
     
    150167        dag_record_t *erfptr = NULL;
    151168        uint64_t *exthdr = NULL;
    152        
     169        uint8_t *firstbyte;
     170
    153171        erfptr = (dag_record_t *)packet->header;
    154172        if ((erfptr->type & 0x80) == 0x80) {
     
    157175                extsize += 8;
    158176
    159                 while (*exthdr < (1UL << 31)) {
     177                firstbyte = (uint8_t *)exthdr;
     178                while ((*firstbyte & 0x80) == 0x80) {
    160179                        extsize += 8;
    161180                        exthdr ++;
     181                        firstbyte = (uint8_t *)exthdr;
    162182                        assert(extsize <= ntohs(erfptr->rlen));
    163183                }
    164184        }
    165        
    166 
    167185        return dag_record_size + extsize + erf_get_padding(packet);
    168186}
     
    199217        }
    200218        /* Is this a proper typed packet */
    201         if ((erf->type & 0x7f) > TYPE_AAL2) {
     219        if ((erf->type & 0x7f) > ERF_TYPE_MAX) {
    202220                return 0;
    203221        }
     
    432450       
    433451        dag_record_t *erfptr;
    434        
     452
    435453        if (packet->buffer != buffer &&
    436454                packet->buf_control == TRACE_CTRL_PACKET) {
     
    463481
    464482        /* Check for loss */
    465         if ((erfptr->type & 0x7f) == TYPE_DSM_COLOR_ETH) {
     483        if (erf_is_color_type(erfptr->type)) {
    466484                /* No idea how we get this yet */
    467485
     
    520538
    521539        /* Unknown/corrupt */
    522         if ((((dag_record_t *)packet->buffer)->type & 0x7f) >= TYPE_RAW_LINK) {
     540        if ((((dag_record_t *)packet->buffer)->type & 0x7f) > ERF_TYPE_MAX) {
    523541                trace_set_err(libtrace, TRACE_ERR_BAD_PACKET,
    524542                                "Corrupt or Unknown ERF type");
     
    757775        dag_record_t *erfptr = 0;
    758776        erfptr = (dag_record_t *)packet->header;
     777
     778        if ((erfptr->type & 0x7f) == TYPE_META)
     779                return 0;
     780
    759781        return ntohs(erfptr->wlen);
    760782}
     
    763785        dag_record_t *erfptr = 0;
    764786        assert(packet);
    765         if(size  > trace_get_capture_length(packet)) {
     787        erfptr = (dag_record_t *)packet->header;
     788
     789        if(size > trace_get_capture_length(packet) || (erfptr->type & 0x7f) == TYPE_META) {
    766790                /* Can't make a packet larger */
    767791                return trace_get_capture_length(packet);
    768792        }
     793
    769794        /* Reset cached capture length - otherwise we will both return the
    770795         * wrong value here and subsequent get_capture_length() calls will
    771796         * return the wrong value. */
    772797        packet->capture_length = -1;
    773         erfptr = (dag_record_t *)packet->header;
    774798        erfptr->rlen = htons(size + erf_get_framing_length(packet));
    775799        return trace_get_capture_length(packet);
  • lib/format_erf.h

    ree6e802 ra857389  
    5353int erf_get_wire_length(const libtrace_packet_t *packet);
    5454size_t erf_set_capture_length(libtrace_packet_t *packet, size_t size);
     55int erf_is_color_type(uint8_t erf_type);
    5556
    5657#endif
  • lib/format_legacy.c

    ree6e802 r2c457ec  
    269269                                                (size_t)64)) != 64) {
    270270                        if (numbytes < 0) {
    271                                 trace_set_err(libtrace,errno,"read(%s)",libtrace->uridata);
     271                                trace_set_err(libtrace,TRACE_ERR_WANDIO_FAILED,"read(%s)",libtrace->uridata);
    272272                        } else if (numbytes > 0) {
    273273                               
     
    310310                                                (size_t)68)) != 68) {
    311311                        if (numbytes < 0) {
    312                                 trace_set_err(libtrace,errno,"read(%s)",libtrace->uridata);
     312                                trace_set_err(libtrace,TRACE_ERR_WANDIO_FAILED,"read(%s)",libtrace->uridata);
    313313                        } else if (numbytes > 0)
    314314                                continue;
  • lib/format_linux_common.h

    rdb84bb2 r4697684  
    394394                        return TRACE_TYPE_ETH;
    395395                case LIBTRACE_ARPHRD_PPP:
     396                case LIBTRACE_ARPHRD_IPGRE:
    396397                        return TRACE_TYPE_NONE;
    397398                case LIBTRACE_ARPHRD_IEEE80211_RADIOTAP:
  • lib/format_ndag.c

    r9993cde r3004d6c  
     1/*
     2 *
     3 * Copyright (c) 2007-2017 The University of Waikato, Hamilton, New Zealand.
     4 * All rights reserved.
     5 *
     6 * This file is part of libtrace.
     7 *
     8 * This code has been developed by the University of Waikato WAND
     9 * research group. For further information please see http://www.wand.net.nz/
     10 *
     11 * libtrace is free software; you can redistribute it and/or modify
     12 * it under the terms of the GNU Lesser General Public License as published by
     13 * the Free Software Foundation; either version 3 of the License, or
     14 * (at your option) any later version.
     15 *
     16 * libtrace is distributed in the hope that it will be useful,
     17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     19 * GNU Lesser General Public License for more details.
     20 *
     21 * You should have received a copy of the GNU Lesser General Public License
     22 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     23 *
     24 *
     25 */
     26
    127
    228#define _GNU_SOURCE
     
    6187        int nextwriteind;
    6288        int savedsize[ENCAP_BUFFERS];
     89        uint64_t nextts;
    6390        uint32_t startidle;
    6491        uint64_t recordcount;
    6592
    6693        int bufavail;
     94        int bufwaiting;
    6795
    6896#if HAVE_RECVMMSG
     
    85113        uint64_t missing_records;
    86114        uint64_t received_packets;
     115
     116        fd_set allsocks;
     117        int maxfd;
    87118} recvstream_t;
    88119
     
    205236                        "Failed to bind to multicast socket %s:%s -- %s\n",
    206237                                groupaddr, portstr, strerror(errno));
    207                 close(sock);
    208238                sock = -1;
    209239                goto sockcreateover;
     
    292322
    293323}
    294        
     324
    295325static int ndag_parse_control_message(libtrace_t *libtrace, char *msgbuf,
    296326                int msgsize, uint16_t *ptmap) {
     
    380410                        "Unable to join multicast group for nDAG control channel");
    381411                trace_interrupt();
     412                pthread_exit(NULL);
    382413        }
    383414
     
    457488                FORMAT_DATA->receivers[i].received_packets = 0;
    458489                FORMAT_DATA->receivers[i].missing_records = 0;
     490                FD_ZERO(&(FORMAT_DATA->receivers[i].allsocks));
     491                FORMAT_DATA->receivers[i].maxfd = -1;
    459492
    460493                libtrace_message_queue_init(&(FORMAT_DATA->receivers[i].mqueue),
     
    560593        uint16_t ndag_reccount = 0;
    561594        int nr;
     595        uint16_t rlen;
    562596
    563597        if ((flags & TRACE_PREP_OWN_BUFFER) == TRACE_PREP_OWN_BUFFER) {
     
    602636        if ((ndag_reccount & 0x8000) != 0) {
    603637                /* Record was truncated -- update rlen appropriately */
    604                 erfptr->rlen = htons(ssock->savedsize[nr] -
    605                                 (ssock->nextread - ssock->saved[nr]));
    606         }
    607         ssock->nextread += ntohs(erfptr->rlen);
     638                rlen = ssock->savedsize[nr] -
     639                                (ssock->nextread - ssock->saved[nr]);
     640                erfptr->rlen = htons(rlen);
     641        } else {
     642                rlen = ntohs(erfptr->rlen);
     643        }
     644        ssock->nextread += rlen;
     645        ssock->nextts = 0;
     646
     647        assert(ssock->nextread - ssock->saved[nr] <= ssock->savedsize[nr]);
    608648
    609649        if (ssock->nextread - ssock->saved[nr] >= ssock->savedsize[nr]) {
     
    611651                 * move on. */
    612652                ssock->savedsize[nr] = 0;
    613                 ssock->bufavail ++;
    614 
    615                 assert(ssock->bufavail > 0 && ssock->bufavail <= ENCAP_BUFFERS);
     653                ssock->bufwaiting ++;
     654
    616655                nr ++;
    617656                if (nr == ENCAP_BUFFERS) {
     
    624663
    625664        packet->order = erf_get_erf_timestamp(packet);
    626         packet->error = packet->payload ? ntohs(erfptr->rlen) :
    627                         erf_get_framing_length(packet);
    628 
    629         return ntohs(erfptr->rlen);
     665        packet->error = rlen;
     666        return rlen;
    630667}
    631668
     
    705742        ssock->saved = (char **)malloc(sizeof(char *) * ENCAP_BUFFERS);
    706743        ssock->bufavail = ENCAP_BUFFERS;
     744        ssock->bufwaiting = 0;
    707745        ssock->startidle = 0;
     746        ssock->nextts = 0;
    708747
    709748        for (i = 0; i < ENCAP_BUFFERS; i++) {
     
    729768        ssock->nextread = NULL;;
    730769        ssock->nextreadind = 0;
     770        ssock->nextwriteind = 0;
    731771        ssock->recordcount = 0;
    732772        rt->sourcecount += 1;
     773        FD_SET(ssock->sock, &(rt->allsocks));
     774        if (ssock->sock > rt->maxfd) {
     775                rt->maxfd = ssock->sock;
     776        }
    733777
    734778        fprintf(stderr, "Added new stream %s:%u to thread %d\n",
     
    837881                fprintf(stderr, "Received invalid record on the channel for %s:%u.\n",
    838882                                ssock->groupaddr, ssock->port);
     883                FD_CLR(ssock->sock, &(rt->allsocks));
    839884                close(ssock->sock);
    840885                ssock->sock = -1;
     
    847892
    848893        assert(ssock->bufavail >= 0);
    849 
    850         if (ssock->nextwriteind >= ENCAP_BUFFERS) {
     894        if (ssock->nextwriteind >= ENCAP_BUFFERS) {
    851895                ssock->nextwriteind = 0;
    852896        }
     
    874918                rt->missing_records += seq_cmp(
    875919                                ntohl(encaphdr->seqno), ssock->expectedseq);
     920
    876921        }
    877922        ssock->expectedseq = ntohl(encaphdr->seqno) + 1;
     
    942987                                        ssock->port);
    943988
     989                                FD_CLR(ssock->sock, &(rt->allsocks));
    944990                                close(ssock->sock);
    945991                                ssock->sock = -1;
     
    951997                                ssock->groupaddr, ssock->port,
    952998                                strerror(errno));
     999                        FD_CLR(ssock->sock, &(rt->allsocks));
    9531000                        close(ssock->sock);
    9541001                        ssock->sock = -1;
     
    9871034        int i, readybufs, gottime;
    9881035        struct timeval tv;
     1036        fd_set fds;
     1037        struct timeval zerotv;
    9891038
    9901039        readybufs = 0;
    9911040        gottime = 0;
    9921041
    993         for (i = 0; i < rt->sourcecount; i ++) {
     1042        fds = rt->allsocks;
     1043
     1044        if (rt->maxfd == -1) {
     1045                return 0;
     1046        }
     1047
     1048        zerotv.tv_sec = 0;
     1049        zerotv.tv_usec = 0;
     1050
     1051        if (select(rt->maxfd + 1, &fds, NULL, NULL, &zerotv) == -1) {
     1052                /* log the error? XXX */
     1053                return -1;
     1054        }
     1055
     1056        for (i = 0; i < rt->sourcecount; i++) {
     1057                if (!FD_ISSET(rt->sources[i].sock, &fds)) {
     1058                        continue;
     1059                }
    9941060                readybufs += receive_from_single_socket(&(rt->sources[i]),
    9951061                                &tv, &gottime, rt);
     
    10821148        dag_record_t *daghdr;
    10831149
     1150        /* If we only have one source, then no need to do any
     1151         * timestamp parsing or byteswapping.
     1152         */
     1153        if (rt->sourcecount == 1) {
     1154                if (readable_data(&(rt->sources[0]))) {
     1155                        return &(rt->sources[0]);
     1156                }
     1157                return NULL;
     1158        }
     1159
     1160
    10841161        for (i = 0; i < rt->sourcecount; i ++) {
    10851162                if (!readable_data(&(rt->sources[i]))) {
     
    10871164                }
    10881165
    1089                 daghdr = (dag_record_t *)(rt->sources[i].nextread);
    1090                 currentts = bswap_le_to_host64(daghdr->ts);
     1166                if (rt->sources[i].nextts == 0) {
     1167                        daghdr = (dag_record_t *)(rt->sources[i].nextread);
     1168                        currentts = bswap_le_to_host64(daghdr->ts);
     1169                        rt->sources[i].nextts = currentts;
     1170                } else {
     1171                        currentts = rt->sources[i].nextts;
     1172                }
    10911173
    10921174                if (earliest == 0 || earliest > currentts) {
     
    10941176                        ssock = &(rt->sources[i]);
    10951177                }
    1096                 /*
    1097                 fprintf(stderr, "%d %d %lu %lu %lu\n", rt->threadindex,
    1098                                 i, currentts,
    1099                                 rt->sources[i].recordcount,
    1100                                 rt->missing_records);
    1101                 */
    11021178        }
    11031179        return ssock;
     
    11061182static int ndag_read_packet(libtrace_t *libtrace, libtrace_packet_t *packet) {
    11071183
    1108         int rem;
     1184        int rem, ret;
    11091185        streamsock_t *nextavail = NULL;
    11101186        rem = receive_encap_records_block(libtrace, &(FORMAT_DATA->receivers[0]),
     
    11231199         * a libtrace ERF packet. */
    11241200
    1125         return ndag_prepare_packet_stream(libtrace,
     1201        ret = ndag_prepare_packet_stream(libtrace,
    11261202                        &(FORMAT_DATA->receivers[0]), nextavail,
    11271203                        packet, TRACE_PREP_DO_NOT_OWN_BUFFER);
     1204        nextavail->bufavail += nextavail->bufwaiting;
     1205        nextavail->bufwaiting = 0;
     1206        return ret;
    11281207}
    11291208
     
    11321211
    11331212        recvstream_t *rt;
    1134         int rem;
     1213        int rem, i;
    11351214        size_t read_packets = 0;
    11361215        streamsock_t *nextavail = NULL;
     
    11721251        } while (1);
    11731252
     1253        for (i = 0; i < rt->sourcecount; i++) {
     1254                streamsock_t *src = &(rt->sources[i]);
     1255                src->bufavail += src->bufwaiting;
     1256                src->bufwaiting = 0;
     1257                assert(src->bufavail >= 0 && src->bufavail <= ENCAP_BUFFERS);
     1258        }
     1259
    11741260        return read_packets;
    11751261
     
    11811267
    11821268        libtrace_eventobj_t event = {0,0,0.0,0};
    1183         int rem;
     1269        int rem, i;
    11841270        streamsock_t *nextavail = NULL;
    11851271
     
    12531339                break;
    12541340        } while (1);
     1341
     1342        for (i = 0; i < FORMAT_DATA->receivers[0].sourcecount; i++) {
     1343                streamsock_t *src = &(FORMAT_DATA->receivers[0].sources[i]);
     1344                src->bufavail += src->bufwaiting;
     1345                src->bufwaiting = 0;
     1346                assert(src->bufavail >= 0 && src->bufavail <= ENCAP_BUFFERS);
     1347        }
    12551348
    12561349        return event;
  • lib/format_ndag.h

    r4bab977 rbe32cc7  
     1/*
     2 *
     3 * Copyright (c) 2007-2017 The University of Waikato, Hamilton, New Zealand.
     4 * All rights reserved.
     5 *
     6 * This file is part of libtrace.
     7 *
     8 * This code has been developed by the University of Waikato WAND
     9 * research group. For further information please see http://www.wand.net.nz/
     10 *
     11 * libtrace is free software; you can redistribute it and/or modify
     12 * it under the terms of the GNU Lesser General Public License as published by
     13 * the Free Software Foundation; either version 3 of the License, or
     14 * (at your option) any later version.
     15 *
     16 * libtrace is distributed in the hope that it will be useful,
     17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     19 * GNU Lesser General Public License for more details.
     20 *
     21 * You should have received a copy of the GNU Lesser General Public License
     22 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     23 *
     24 *
     25 */
     26
     27
    128#ifndef FORMAT_NDAG_H_
    229#define FORMAT_NDAG_H_
  • lib/format_pcap.c

    r4578626 r5a70a80  
    498498        link = trace_get_packet_buffer(packet,&linktype,&remaining);
    499499
     500        /* Silently discard RT metadata packets and packets with an
     501         * unknown linktype. */
     502        if (linktype == TRACE_TYPE_NONDATA || linktype == TRACE_TYPE_UNKNOWN || linktype == TRACE_TYPE_ERF_META) {
     503                return 0;
     504        }
     505
    500506        /* We may have to convert this packet into a suitable PCAP packet */
    501507
     
    581587{
    582588        int err;
    583 
    584         if (trace_get_link_type(packet) == TRACE_TYPE_NONDATA)
     589        libtrace_linktype_t linktype = trace_get_link_type(packet);
     590
     591        /* Silently discard RT metadata packets and packets with an
     592         * unknown linktype. */
     593        if (linktype == TRACE_TYPE_NONDATA || linktype == TRACE_TYPE_UNKNOWN || linktype == TRACE_TYPE_ERF_META) {
    585594                return 0;
     595        }
    586596
    587597        if (!OUTPUT.trace.pcap) {
  • lib/format_pcapfile.c

    r633339d r5a70a80  
    357357                        sizeof(libtrace_pcapfile_pkt_hdr_t));
    358358        if (err<0) {
    359                 trace_set_err(libtrace,errno,"reading packet");
     359                trace_set_err(libtrace,TRACE_ERR_WANDIO_FAILED,"reading packet");
    360360                return -1;
    361361        }
     
    366366
    367367        if (err < (int)sizeof(libtrace_pcapfile_pkt_hdr_t)) {
    368                 trace_set_err(libtrace, errno, "Incomplete pcap packet header");
     368                trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Incomplete pcap packet header");
    369369                return -1;
    370370        }
     
    393393
    394394        if (err<0) {
    395                 trace_set_err(libtrace,errno,"reading packet");
     395                trace_set_err(libtrace,TRACE_ERR_WANDIO_FAILED,"reading packet");
    396396                return -1;
    397397        }
     
    401401
    402402        if (err < (int)bytes_to_read) {
    403                 trace_set_err(libtrace, errno, "Incomplete pcap packet body");
     403                trace_set_err(libtrace, TRACE_ERR_WANDIO_FAILED, "Incomplete pcap packet body");
    404404                return -1;
    405405        }
     
    431431        /* Silently discard RT metadata packets and packets with an
    432432         * unknown linktype. */
    433         if (linktype == TRACE_TYPE_NONDATA || linktype == TRACE_TYPE_UNKNOWN) {
     433        if (linktype == TRACE_TYPE_NONDATA || linktype == TRACE_TYPE_UNKNOWN || linktype == TRACE_TYPE_ERF_META) {
    434434                return 0;
    435435        }
  • lib/format_pcapng.c

    red5b2ce r2c457ec  
    330330                err = wandio_read(libtrace->io, buf, nextread);
    331331                if (err < 0) {
    332                         trace_set_err(libtrace, errno,
     332                        trace_set_err(libtrace, TRACE_ERR_WANDIO_FAILED,
    333333                                "Reading section header options");
    334334                        return -1;
     
    351351        err = wandio_read(libtrace->io, body, to_read);
    352352        if (err < 0) {
    353                 trace_set_err(libtrace, errno,
     353                trace_set_err(libtrace, TRACE_ERR_WANDIO_FAILED,
    354354                        "Failed to read pcapng interface options");
    355355                return err;
     
    444444
    445445        if (err < 0) {
    446                 trace_set_err(libtrace, errno,
     446                trace_set_err(libtrace, TRACE_ERR_WANDIO_FAILED,
    447447                        "Reading pcapng section header block");
    448448                return -1;
     
    519519
    520520        if (err < 0) {
    521                 trace_set_err(libtrace, errno,
     521                trace_set_err(libtrace, TRACE_ERR_WANDIO_FAILED,
    522522                        "Reading pcapng interface header block");
    523523                return -1;
     
    626626
    627627        if (err < 0) {
    628                 trace_set_err(libtrace, errno, "reading pcapng name resolution block");
     628                trace_set_err(libtrace, TRACE_ERR_WANDIO_FAILED, "reading pcapng name resolution block");
    629629                return -1;
    630630        }
     
    682682
    683683        if (err < 0) {
    684                 trace_set_err(libtrace, errno, "reading pcapng custom block");
     684                trace_set_err(libtrace, TRACE_ERR_WANDIO_FAILED, "reading pcapng custom block");
    685685                return -1;
    686686        }
     
    740740
    741741        if (err < 0) {
    742                 trace_set_err(libtrace, errno, "reading pcapng interface stats");
     742                trace_set_err(libtrace, TRACE_ERR_WANDIO_FAILED, "reading pcapng interface stats");
    743743                return -1;
    744744        }
     
    861861
    862862        if (err < 0) {
    863                 trace_set_err(libtrace, errno, "reading pcapng simple packet");
     863                trace_set_err(libtrace, TRACE_ERR_WANDIO_FAILED, "reading pcapng simple packet");
    864864                return -1;
    865865        }
     
    930930
    931931        if (err < 0) {
    932                 trace_set_err(libtrace, errno, "reading pcapng enhanced packet");
     932                trace_set_err(libtrace, TRACE_ERR_WANDIO_FAILED, "reading pcapng enhanced packet");
    933933                return -1;
    934934        }
     
    10391039                err = wandio_peek(libtrace->io, &peeker, sizeof(peeker));
    10401040                if (err < 0) {
    1041                         trace_set_err(libtrace, errno, "reading pcapng packet");
     1041                        trace_set_err(libtrace, TRACE_ERR_WANDIO_FAILED, "reading pcapng packet");
    10421042                        return -1;
    10431043                }
     
    10481048
    10491049                if (err < (int)sizeof(struct pcapng_peeker)) {
    1050                         trace_set_err(libtrace, errno, "Incomplete pcapng block");
     1050                        trace_set_err(libtrace, TRACE_ERR_WANDIO_FAILED, "Incomplete pcapng block");
    10511051                        return -1;
    10521052                }
  • lib/format_tsh.c

    ree6e802 r2c457ec  
    131131                                        buffer2,
    132132                                        (size_t)sizeof(tsh_pkt_header_t))) == -1) {
    133                 trace_set_err(libtrace,errno,"read(%s)",
     133                trace_set_err(libtrace,TRACE_ERR_WANDIO_FAILED,"read(%s)",
    134134                                libtrace->uridata);
    135135                return -1;
     
    141141
    142142        if (numbytes < (int)sizeof(tsh_pkt_header_t)) {
    143                 trace_set_err(libtrace, errno, "Incomplete TSH header");
     143                trace_set_err(libtrace, TRACE_ERR_WANDIO_FAILED, "Incomplete TSH header");
    144144                return -1;
    145145        }
     
    152152                                (size_t)sizeof(libtrace_ip_t)+16))  /* 16 bytes of transport header */
    153153                        != sizeof(libtrace_ip_t)+16) {
    154                 trace_set_err(libtrace,errno,"read(%s)",
     154                trace_set_err(libtrace,TRACE_ERR_WANDIO_FAILED,"read(%s)",
    155155                                libtrace->uridata);
    156156                return -1;
     
    167167                                buffer2,
    168168                                16)) != 16) {
    169                 trace_set_err(libtrace,errno,"read(%s)",
     169                trace_set_err(libtrace,TRACE_ERR_WANDIO_FAILED,"read(%s)",
    170170                                libtrace->uridata);
    171171                return -1;
  • lib/hash_toeplitz.h

    r6f7cd4b re4eaca5  
    2828 * toeplitz hashing - see microsoft rss code
    2929 */
     30#include "config.h"
    3031#include <stdint.h>
    3132#include <stddef.h>
     
    5354} toeplitz_conf_t;
    5455
    55 void toeplitz_hash_expand_key(toeplitz_conf_t *conf);
    56 uint32_t toeplitz_hash(const toeplitz_conf_t *tc, const uint8_t *data, size_t offset, size_t n, uint32_t result);
    57 uint32_t toeplitz_first_hash(const toeplitz_conf_t *tc, const uint8_t *data, size_t n);
    58 void toeplitz_init_config(toeplitz_conf_t *conf, bool bidirectional);
    59 uint64_t toeplitz_hash_packet(const libtrace_packet_t * pkt, const toeplitz_conf_t *cnf);
    60 void toeplitz_ncreate_bikey(uint8_t *key, size_t num);
    61 void toeplitz_create_bikey(uint8_t *key);
    62 void toeplitz_ncreate_unikey(uint8_t *key, size_t num);
    63 void toeplitz_create_unikey(uint8_t *key);
     56DLLEXPORT void toeplitz_hash_expand_key(toeplitz_conf_t *conf);
     57DLLEXPORT uint32_t toeplitz_hash(const toeplitz_conf_t *tc, const uint8_t *data, size_t offset, size_t n, uint32_t result);
     58DLLEXPORT uint32_t toeplitz_first_hash(const toeplitz_conf_t *tc, const uint8_t *data, size_t n);
     59DLLEXPORT void toeplitz_init_config(toeplitz_conf_t *conf, bool bidirectional);
     60DLLEXPORT uint64_t toeplitz_hash_packet(const libtrace_packet_t * pkt, const toeplitz_conf_t *cnf);
     61DLLEXPORT void toeplitz_ncreate_bikey(uint8_t *key, size_t num);
     62DLLEXPORT void toeplitz_create_bikey(uint8_t *key);
     63DLLEXPORT void toeplitz_ncreate_unikey(uint8_t *key, size_t num);
     64DLLEXPORT void toeplitz_create_unikey(uint8_t *key);
    6465
    6566
  • lib/libtrace.h.in

    rea75ec2 r29cafc0  
    305305        TRACE_ERR_RT_FAILURE    = -10,
    306306        /** Compression format unsupported */
    307         TRACE_ERR_UNSUPPORTED_COMPRESS  = -11
     307        TRACE_ERR_UNSUPPORTED_COMPRESS  = -11,
     308        /** Wandio has returned an error */
     309        TRACE_ERR_WANDIO_FAILED = -12 
    308310};
    309311
     
    330332#ifdef __OpenBSD__
    331333        TRACE_DLT_OPENBSD_LOOP=12,
    332         TRACE_DLT_RAW = 14
     334        TRACE_DLT_RAW = 14,
    333335#else
    334336        TRACE_DLT_RAW = 12,
     
    367369       TRACE_TYPE_METADATA = 18,        /**< WDCAP-style meta-data */
    368370       TRACE_TYPE_NONDATA = 19,         /**< Not a data packet */
    369        TRACE_TYPE_OPENBSD_LOOP = 20     /**< OpenBSD loopback */
     371       TRACE_TYPE_OPENBSD_LOOP = 20,    /**< OpenBSD loopback */
     372       TRACE_TYPE_ERF_META = 21 /**< ERF Provenance metadata record */
    370373} libtrace_linktype_t;
    371374
     
    394397        TRACE_FORMAT_PCAPNG     =18,    /**< PCAP-NG trace file */
    395398        TRACE_FORMAT_NDAG       =19,    /**< DAG multicast over a network */
     399        TRACE_FORMAT_DPDK_NDAG       =20,    /**< DAG multicast over a network, received via DPDK */
    396400};
    397401
     
    17911795DLLEXPORT int trace_read_packet(libtrace_t *trace, libtrace_packet_t *packet);
    17921796
     1797/** Converts the data provided in buffer into a valid libtrace packet
     1798 *
     1799 * @param trace         An input trace of the same format as the "packet"
     1800 *                      contained in the buffer
     1801 * @param packet        The libtrace packet to prepare
     1802 * @param buffer        A buffer containing the packet data, including the
     1803 *                      capture format header
     1804 * @param rt_type       The RT type for the packet that is being prepared
     1805 * @param flags         Used to specify options for the preparation function,
     1806 *                      e.g. who owns the packet buffer
     1807 *
     1808 * @return -1 if an error occurs, 0 otherwise
     1809 *
     1810 * Packet preparation is a tricky concept - the idea is to take the data
     1811 * pointed to by 'buffer' and treat it as a packet record of the same capture
     1812 * format as that used by the input trace. The provided libtrace packet then
     1813 * has its internal pointers and values set to describe the packet record in
     1814 * the buffer.
     1815 *
     1816 * The primary use of this function is to allow the RT packet reader to
     1817 * easily and safely convert packets from the RT format back into the format
     1818 * that they were originally captured with., essentially removing the RT
     1819 * encapsulation.
     1820 *
     1821 * This function is now available via the exported API, as it can have some
     1822 * uses outside of internal libtrace contexts. However, we strongly advise
     1823 * that you avoid using this function unless you really know what you are
     1824 * doing.
     1825 */
     1826DLLEXPORT int trace_prepare_packet(libtrace_t *trace, libtrace_packet_t *packet,
     1827                void *buffer, libtrace_rt_types_t rt_type, uint32_t flags);
     1828
     1829/** Flags for prepare_packet functions */
     1830enum {
     1831        /** The buffer memory has been allocated by libtrace and should be
     1832         * freed when the packet is destroyed. */
     1833        TRACE_PREP_OWN_BUFFER           =1,
     1834
     1835        /** The buffer memory is externally-owned and must not be freed by
     1836         * libtrace when the packet is destroyed. */
     1837        TRACE_PREP_DO_NOT_OWN_BUFFER    =0
     1838};
     1839
     1840
    17931841/** Event types
    17941842 * see \ref libtrace_eventobj_t and \ref trace_event
  • lib/libtrace_int.h

    rea75ec2 re375e0f  
    182182        THREAD_PAUSED,
    183183        THREAD_STATE_MAX
     184};
     185
     186enum hash_owner {
     187        HASH_OWNED_LIBTRACE,
     188        HASH_OWNED_EXTERNAL,
    184189};
    185190
     
    347352        fn_hasher hasher;
    348353        void *hasher_data;
     354        enum hash_owner hasher_owner;
    349355        /** The pread_packet choosen path for the configuration */
    350356        int (*pread)(libtrace_t *, libtrace_thread_t *, libtrace_packet_t **, size_t);
     
    426432 */
    427433void trace_clear_cache(libtrace_packet_t *packet);
    428 
    429 /** Converts the data provided in buffer into a valid libtrace packet
    430  *
    431  * @param trace         An input trace of the same format as the "packet"
    432  *                      contained in the buffer
    433  * @param packet        The libtrace packet to prepare
    434  * @param buffer        A buffer containing the packet data, including the
    435  *                      capture format header
    436  * @param rt_type       The RT type for the packet that is being prepared
    437  * @param flags         Used to specify options for the preparation function,
    438  *                      e.g. who owns the packet buffer
    439  *
    440  * @return -1 if an error occurs, 0 otherwise
    441  *
    442  * Packet preparation is a tricky concept - the idea is to take the data
    443  * pointed to by 'buffer' and treat it as a packet record of the same capture
    444  * format as that used by the input trace. The provided libtrace packet then
    445  * has its internal pointers and values set to describe the packet record in
    446  * the buffer.
    447  *
    448  * The primary use of this function is to allow the RT packet reader to
    449  * easily and safely convert packets from the RT format back into the format
    450  * that they were originally captured with., essentially removing the RT
    451  * encapsulation.
    452  *
    453  * We've decided not to make this function available via the exported API
    454  * because there are several issues that can arise if it is not used very
    455  * carefully and it is not very useful outside of internal contexts anyway.
    456  */
    457 int trace_prepare_packet(libtrace_t *trace, libtrace_packet_t *packet,
    458                 void *buffer, libtrace_rt_types_t rt_type, uint32_t flags);
    459 
    460 /** Flags for prepare_packet functions */
    461 enum {
    462         /** The buffer memory has been allocated by libtrace and should be
    463          * freed when the packet is destroyed. */
    464         TRACE_PREP_OWN_BUFFER           =1,
    465        
    466         /** The buffer memory is externally-owned and must not be freed by
    467          * libtrace when the packet is destroyed. */
    468         TRACE_PREP_DO_NOT_OWN_BUFFER    =0
    469 };
    470434
    471435
     
    12851249/** Constructor for Intels DPDK format module */
    12861250void dpdk_constructor(void);
     1251
     1252/** Constructor for receiving network DAG via Intels DPDK format module */
     1253void dpdkndag_constructor(void);
     1254
    12871255#endif
    12881256
  • lib/libtrace_parallel.h

    ree6e802 r5c07bfe  
    13371337DLLEXPORT int trace_get_perpkt_threads(libtrace_t* t);
    13381338
     1339/** Returns the internal unique ID for a packet processing thread.
     1340 *
     1341 * @param thread The thread being queried.
     1342 * @return The ID number of the thread or -1 if the thread is not a processing
     1343 * thread or is otherwise invalid.
     1344 */
     1345DLLEXPORT int trace_get_perpkt_thread_id(libtrace_thread_t *thread);
     1346
    13391347/**
    13401348 * Sets a combiner function for an input trace.
  • lib/linktypes.c

    red5b2ce ra857389  
    102102                /* Used for test traces within WAND */
    103103                case TRACE_TYPE_80211_PRISM:   
     104                /* Could use DLT_ERF, but would only really make sense with PCAP-NG */
     105                case TRACE_TYPE_ERF_META:
    104106                /* Probably == PPP */
    105107                /* TODO: We haven't researched these yet */
     
    169171                case TYPE_ATM:          return TRACE_TYPE_ATM;
    170172                case TYPE_AAL5:         return TRACE_TYPE_AAL5;
     173                case TYPE_COLOR_ETH:return TRACE_TYPE_ETH;
    171174                case TYPE_DSM_COLOR_ETH:return TRACE_TYPE_ETH;
     175                case TYPE_COLOR_HASH_ETH:return TRACE_TYPE_ETH;
    172176                case TYPE_IPV4:         return TRACE_TYPE_NONE;
    173177                case TYPE_IPV6:         return TRACE_TYPE_NONE;
     178                case TYPE_META:         return TRACE_TYPE_ERF_META;
    174179        }
    175180        return ~0U;
     
    183188                case TRACE_TYPE_ATM:    return TYPE_ATM;
    184189                case TRACE_TYPE_AAL5:   return TYPE_AAL5;
     190                case TRACE_TYPE_ERF_META: return TYPE_META;
    185191               
    186192                /* Not technically correct! Could be IPv6 packet
     
    218224                case LIBTRACE_ARPHRD_IEEE80211_RADIOTAP: return TRACE_TYPE_80211_RADIO;
    219225                case LIBTRACE_ARPHRD_PPP: return TRACE_TYPE_NONE;
     226                case LIBTRACE_ARPHRD_IPGRE: return TRACE_TYPE_NONE;
    220227                case LIBTRACE_ARPHRD_LOOPBACK: return TRACE_TYPE_ETH;
    221228                case LIBTRACE_ARPHRD_SIT: return TRACE_TYPE_ETH;
  • lib/protocols_l2.c

    r99351e3 ra857389  
    482482                case TRACE_TYPE_80211_PRISM:
    483483                case TRACE_TYPE_PFLOG:
     484                case TRACE_TYPE_ERF_META:
    484485                        break;
    485486                case TRACE_TYPE_UNKNOWN:
     
    517518                                case TRACE_TYPE_80211_PRISM:
    518519                                case TRACE_TYPE_PFLOG:
     520                                case TRACE_TYPE_ERF_META:
    519521                                        break;
    520522                                case TRACE_TYPE_UNKNOWN:
     
    583585                case TRACE_TYPE_METADATA:
    584586                case TRACE_TYPE_NONDATA:
     587                case TRACE_TYPE_ERF_META:
    585588                case TRACE_TYPE_UNKNOWN:
    586589                        return NULL;
     
    685688                case TRACE_TYPE_NONDATA:
    686689                case TRACE_TYPE_OPENBSD_LOOP:
     690                case TRACE_TYPE_ERF_META:
    687691                case TRACE_TYPE_UNKNOWN:
    688692                        return NULL;
     
    734738                case TRACE_TYPE_NONDATA:
    735739                case TRACE_TYPE_OPENBSD_LOOP:
     740                case TRACE_TYPE_ERF_META:
    736741                case TRACE_TYPE_UNKNOWN:
    737742                        /* No MAC address */
  • lib/protocols_pktmeta.c

    ree6e802 ra857389  
    138138                case TRACE_TYPE_80211_RADIO:
    139139                case TRACE_TYPE_80211_PRISM:
     140                case TRACE_TYPE_ERF_META:
    140141                        return pktbuf;
    141142                /* Non metadata packets */
     
    211212                case TRACE_TYPE_NONDATA:
    212213                case TRACE_TYPE_OPENBSD_LOOP:
     214                case TRACE_TYPE_ERF_META:
    213215                case TRACE_TYPE_UNKNOWN:
    214216                        /* In this case, the pointer passed in does not point
  • lib/trace.c

    rea75ec2 re375e0f  
    152152#endif
    153153#ifdef HAVE_DPDK
    154         dpdk_constructor();
     154                dpdk_constructor();
     155                dpdkndag_constructor();
    155156#endif
    156157        }
     
    270271        libtrace->hasher = NULL;
    271272        libtrace->hasher_data = NULL;
     273        libtrace->hasher_owner = HASH_OWNED_EXTERNAL;
    272274        libtrace_zero_ocache(&libtrace->packet_freelist);
    273275        libtrace_zero_thread(&libtrace->hasher_thread);
     
    737739        }
    738740
     741        if (libtrace->hasher_owner == HASH_OWNED_LIBTRACE) {
     742                if (libtrace->hasher_data) {
     743                        free(libtrace->hasher_data);
     744                }
     745        }
     746
     747
    739748        if (libtrace->perpkt_cbs)
    740749                trace_destroy_callback_set(libtrace->perpkt_cbs);
     
    15091518        linktype = trace_get_link_type(packet);
    15101519
    1511         if (linktype == TRACE_TYPE_NONDATA)
     1520        if (linktype == TRACE_TYPE_NONDATA || linktype == TRACE_TYPE_ERF_META)
    15121521                return 1;
    15131522
  • lib/trace_parallel.c

    re8db2d4 re375e0f  
    287287}
    288288
     289DLLEXPORT int trace_get_perpkt_thread_id(libtrace_thread_t *thread) {
     290        return thread->perpkt_num;
     291}
     292
    289293/**
    290294 * Changes the overall traces state and signals the condition.
     
    21562160        trace->hasher_type = type;
    21572161        if (hasher) {
     2162                if (trace->hasher_owner == HASH_OWNED_LIBTRACE) {
     2163                        if (trace->hasher_data) {
     2164                                free(trace->hasher_data);
     2165                        }
     2166                }
    21582167                trace->hasher = hasher;
    21592168                trace->hasher_data = data;
     2169                trace->hasher_owner = HASH_OWNED_EXTERNAL;
    21602170        } else {
    21612171                trace->hasher = NULL;
    21622172                trace->hasher_data = NULL;
     2173                trace->hasher_owner = HASH_OWNED_LIBTRACE;
    21632174        }
    21642175
  • test/do-tests-parallel.sh

    rccef50c r43b773a  
    2020echo \* Read erf
    2121do_test ./test-format-parallel erf
     22
     23echo \* Read erf provenance
     24do_test ./test-format-parallel erfprov
    2225
    2326echo \* Read pcap
  • test/do-tests.sh

    rccef50c r43b773a  
    3333do_test ./test-format erf
    3434do_test ./test-decode erf
     35
     36echo \* Read erf provenance
     37do_test ./test-format erfprov
    3538
    3639echo \* Read pcap
  • test/test-format-parallel.c

    r568a341 r43b773a  
    6666        if (!strcmp(type,"erf"))
    6767                return "erf:traces/100_packets.erf";
     68        if (!strcmp(type,"erfprov"))
     69                return "erf:traces/provenance.erf";
    6870        if (!strcmp(type,"rawerf"))
    6971                return "rawerf:traces/100_packets.erf";
  • test/test-format.c

    r568a341 r43b773a  
    8787        if (!strcmp(type, "tsh"))
    8888                return "tsh:traces/10_packets.tsh.gz";
     89        if (!strcmp(type, "erfprov"))
     90                return "erf:traces/provenance.erf";
    8991        return type;
    9092}
  • tools/tracertstats/tracertstats.c

    r8e11beb r02d13cb  
    4747#include <getopt.h>
    4848#include <inttypes.h>
     49#include <signal.h>
     50
    4951#include <lt_inttypes.h>
    50 
    5152#include "libtrace_parallel.h"
    5253#include "output.h"
     
    8081uint64_t count;
    8182uint64_t bytes;
     83
     84struct libtrace_t *currenttrace;
     85
     86static void cleanup_signal(int signal UNUSED) {
     87        if (currenttrace) {
     88                trace_pstop(currenttrace);
     89        }
     90}
    8291
    8392static void report_results(double ts,uint64_t count,uint64_t bytes)
     
    188197        thread_data_t *td = (thread_data_t *)tls;
    189198        int i;
     199        size_t wlen;
    190200
    191201        if (IS_LIBTRACE_META_PACKET(packet)) {
     
    203213                                sizeof(statistic_t) * filter_count);
    204214        }
     215        wlen = trace_get_wire_length(packet);
     216        if (wlen == 0) {
     217                /* Don't count ERF provenance and similar packets */
     218                return packet;
     219        }
    205220        for(i=0;i<filter_count;++i) {
    206221                if(trace_apply_filter(filters[i].filter, packet)) {
    207222                        td->results->filters[i].count++;
    208                         td->results->filters[i].bytes+=trace_get_wire_length(packet);
     223                        td->results->filters[i].bytes+=wlen;
    209224                }
    210225        }
    211226
    212227        td->results->total.count++;
    213         td->results->total.bytes +=trace_get_wire_length(packet);
     228        td->results->total.bytes += wlen;
    214229        return packet;
    215230}
     
    281296        trace_set_result_cb(repcbs, cb_result);
    282297
     298        currenttrace = trace;
    283299        if (trace_pstart(trace, NULL, pktcbs, repcbs)==-1) {
    284300                trace_perror(trace,"Failed to start trace");
     
    329345
    330346        int i;
     347        struct sigaction sigact;
    331348       
    332349        while(1) {
     
    414431                        return 0;
    415432        }
    416                
     433       
     434        sigact.sa_handler = cleanup_signal;
     435        sigemptyset(&sigact.sa_mask);
     436        sigact.sa_flags = SA_RESTART;
     437
     438        sigaction(SIGINT, &sigact, NULL);
     439        sigaction(SIGTERM, &sigact, NULL);
     440
     441
    417442        for(i=optind;i<argc;++i) {
    418443                run_trace(argv[i]);
  • tools/tracesplit/tracesplit.c

    r8e11beb r92cf299  
    294294                }
    295295
    296                 if (trace_config_output(output,
    297                                         TRACE_OPTION_OUTPUT_COMPRESSTYPE,
    298                                         &compress_type) == -1) {
    299                         trace_perror_output(output, "Unable to set compression type");
    300                 }
     296                if (compress_type != TRACE_OPTION_COMPRESSTYPE_NONE) {
     297                        if (trace_config_output(output,
     298                                                TRACE_OPTION_OUTPUT_COMPRESSTYPE,
     299                                                &compress_type) == -1) {
     300                                trace_perror_output(output, "Unable to set compression type");
     301                        }
     302                }
    301303
    302304                trace_start_output(output);
  • tools/tracestats/tracestats.c

    r8e11beb r02d13cb  
    105105        libtrace_stat_t *stats = NULL;
    106106        int i;
     107        double pct;
    107108
    108109        stats = trace_get_statistics(trace, NULL);
    109         printf("%-30s\t%12s\t%12s\t%7s\n","filter","count","bytes","%");
     110        printf("%-30s\t%12s\t%12s\t%7s\n","filter","count","bytes","% count");
    110111        for(i=0;i<filter_count;++i) {
    111                 printf("%30s:\t%12"PRIu64"\t%12"PRIu64"\t%7.03f\n",filters[i].expr,counters[i+1].count,counters[i+1].bytes,counters[i+1].count*100.0/counters[0].count);
     112                if (counters[0].count == 0) {
     113                        pct = 0.0;
     114                } else {
     115                        pct = counters[i+1].count*100.0/counters[0].count;
     116                }
     117                printf("%30s:\t%12"PRIu64"\t%12"PRIu64"\t%7.03f\n",filters[i].expr,counters[i+1].count,counters[i+1].bytes,pct);
    112118        }
    113119        if (stats->received_valid)
     
    160166        /* Apply filters to every packet note the result */
    161167        wlen = trace_get_wire_length(pkt);
     168        if (wlen == 0) {
     169                /* Don't count ERF provenance etc. */
     170                return pkt;
     171        }
    162172        for(i=0;i<filter_count;++i) {
    163173                if (filters[i].filter == NULL)
  • tools/tracetop/tracetop.cc

    r8e11beb r817713f  
    408408                switch (display_as) {
    409409                        case BYTES:
    410                                 printw("%7"PRIu64"\t%7"PRIu64"\n",
     410                                printw("%7" PRIu64 "\t%7" PRIu64 "\n",
    411411                                                pq.top().bytes,
    412412                                                pq.top().packets);
    413413                                break;
    414414                        case BITS_PER_SEC:
    415                                 printw("%14.03f\t%"PRIu64"\n",
     415                                printw("%14.03f\t%" PRIu64 "\n",
    416416                                                8.0*pq.top().bytes/interval,
    417417                                                pq.top().packets);
Note: See TracChangeset for help on using the changeset viewer.