Changeset 52656ed


Ignore:
Timestamp:
09/04/07 16:50:19 (14 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
5798dc6
Parents:
2cf30f6
Message:
  • Updated autotools to detect DAG 3.X drivers. The new detection method will also catch DAG 2.5, but this is not a problem because the API is the same so DAG 2.5 and DAG 3 can use the same code within libtrace.
  • Changed format_dag25.c to manage the dag stream manually, similar to format_dag24.c.
  • Libtrace programs using DAG 2.5 and greater should now detach the DAG stream properly, provided they are exited cleanly.
  • The snaplen can now be configured for DAG 2.5 and DAG 3.0 inputs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • configure.in

    r994beed r52656ed  
    173173])
    174174
     175# DAG 3.0 actually puts header files and shared libraries into sensible
     176# places now, so we should be able to do a simple CHECK_LIB to see if
     177# they're there!
     178
     179# Addendum: It turns out DAG 2.5 does this too, so we'll match DAG2.5 in here
     180# also. This isn't such a bad thing, the DAG2.5 API is essentially the same as
     181# DAG 3.0 and libtrace will use the same format_dagXX source for both
     182libtrace_dag=false
     183libtrace_dag_version=none
     184
     185if test "$with_dag" != no; then
     186        AC_CHECK_LIB(dag, dag_open, dag_found=1, dag_found=0)
     187        if test "$dag_found" = 1; then
     188                ADD_LIBS="$ADD_LIBS -ldag"
     189                AC_DEFINE(HAVE_DAG_API, 1, [define if you have a DAG API])
     190                AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG support])
     191                libtrace_dag=true
     192               
     193                AC_DEFINE(DAG_VERSION,30,[defines the DAG driver version])
     194                libtrace_dag_version=30
     195        fi
     196fi
     197
    175198# turn the test part of the next block into a function, so it can be
    176199# called multiple times for $dag_root, /root/dag, /usr/local/lib
    177 libtrace_dag=false
    178 libtrace_dag2_4=false
    179 dag_drv_v="DAG not present"
    180 if test "$with_dag" != no; then
    181         AC_MSG_CHECKING(whether we have DAG API)
     200#dag_drv_v="DAG not present"
     201
     202# Now check for 2.4 DAG drivers which don't install as cleanly!
     203if test "$with_dag" != no -a "$libtrace_dag" = false; then
     204        AC_MSG_CHECKING(whether we have DAG 2.4 API)
    182205
    183206        if test -r "$dag_root/lib"; then
     
    206229                AC_DEFINE(HAVE_DAG_API, 1, [define if you have a DAG API])
    207230                AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG support])
     231                AC_DEFINE(DAG_VERSION, 24, [defines the DAG driver version])
     232                libtrace_dag_version=24
    208233        else
    209234                if test "$want_dag" = yes; then
     
    215240        AC_MSG_RESULT($libtrace_dag)
    216241
    217         if test "$libtrace_dag" != false; then
    218                 AC_MSG_CHECKING(if we are using DAG 2.4)
    219                 if grep '2.4.' $dag_root/VERSION > /dev/null 2>&1; then
    220                         libtrace_dag2_4=true
    221                         AC_DEFINE(DAG_VERSION_2_4, 1, [define if using DAG 2.4])
    222                 else
    223                         libtrace_dag2_4=false
    224                 fi
    225                 AC_MSG_RESULT($libtrace_dag2_4)
    226                 dag_drv_v=`cat $dag_root/VERSION`
    227         fi
    228 fi
    229 DAG_VERSION_NUM=$dag_drv_v
     242fi
     243
    230244AC_CHECK_LIB(z, gzopen)
    231245
    232246AM_CONDITIONAL([HAVE_BPF], [test "$ac_cv_have_decl_BIOCSETIF" = yes ])
    233247AM_CONDITIONAL([HAVE_DAG], [test "$libtrace_dag" = true])
    234 AM_CONDITIONAL([DAG2_4], [test "$libtrace_dag2_4" = true])
     248AM_CONDITIONAL([DAG2_4], [test "$libtrace_dag_version" = 24])
     249AM_CONDITIONAL([DAG2_5], [test "$libtrace_dag_version" = 25])
     250AM_CONDITIONAL([DAG3_0], [test "$libtrace_dag_version" = 30])
    235251AM_CONDITIONAL([HAVE_ZLIB], [test "$ac_cv_lib_z_gzopen" = yes])
    236252AM_CONDITIONAL([HAVE_NETPACKET_PACKET_H], [test "$libtrace_netpacket_packet_h" = true])
     
    269285reportopt "Compiled with compressed trace (zlib) support" $ac_cv_lib_z_gzopen
    270286if test x"$libtrace_dag" = xtrue; then
    271         if test x"$libtrace_dag2_4"; then
     287        if test "$libtrace_dag_version" = 24; then
    272288                AC_MSG_NOTICE([Compiled with DAG support: 2.4])
     289        elif test "$libtrace_dag_version" = 30; then
     290                AC_MSG_NOTICE([Compiled with DAG support: 3.0])
    273291        else
    274292                AC_MSG_NOTICE([Compiled with DAG support: 2.5])
    275         fi
     293        fi     
    276294else
    277295        AC_MSG_NOTICE([Compiled with DAG support: No])
  • lib/format_dag25.c

    r708f9ae r52656ed  
    7575        int fd;
    7676        unsigned int dagstream;
     77        int stream_attached;
     78        uint8_t *bottom;
     79        uint8_t *top;
    7780};
    7881
     
    105108        DUCK.last_pkt = 0;
    106109        DUCK.dummy_duck = NULL;
    107 
     110        FORMAT_DATA->stream_attached = 0;
     111       
    108112        return 0;
    109113}
     
    111115static int dag_config_input(libtrace_t *libtrace, trace_option_t option,
    112116                                void *data) {
    113         switch(option) {
     117        char conf_str[4096];
     118        switch(option) {
    114119                case TRACE_OPTION_META_FREQ:
    115120                        DUCK.duck_freq = *(int *)data;
    116121                        return 0;
    117122                case TRACE_OPTION_SNAPLEN:
    118                         /* Surely we can set this?? Fall through for now*/
    119                         return -1;
     123                        snprintf(conf_str, 4096, "varlen slen=%i", *(int *)data);
     124                        if (dag_configure(FORMAT_DATA->fd, conf_str) != 0) {
     125                                trace_set_err(libtrace, errno, "Failed to configure snaplen on DAG card: %s", libtrace->uridata);
     126                                return -1;
     127                        }
     128                        return 0;
    120129                case TRACE_OPTION_PROMISC:
    121130                        /* DAG already operates in a promisc fashion */
     
    152161                return -1;
    153162        }
     163        FORMAT_DATA->stream_attached = 1;
    154164        /* We don't want the dag card to do any sleeping */
    155165        dag_set_stream_poll(FORMAT_DATA->fd,
     
    158168       
    159169        /* Should probably flush the memory hole now */
     170       
    160171        do {
    161172                top = dag_advance_stream(FORMAT_DATA->fd,
     
    164175                assert(top && bottom);
    165176                diff = top - bottom;
     177                bottom -= diff;
    166178        } while (diff != 0);
    167179
     
    180192                return -1;
    181193        }
    182 
     194        FORMAT_DATA->stream_attached = 0;
    183195        return 0;
    184196}
    185197
    186198static int dag_fin_input(libtrace_t *libtrace) {
     199        if (FORMAT_DATA->stream_attached)
     200                dag_pause_input(libtrace);
     201        dag_close(FORMAT_DATA->fd);
    187202        if (DUCK.dummy_duck)
    188203                trace_destroy_dead(DUCK.dummy_duck);
     
    193208static int dag_get_duckinfo(libtrace_t *libtrace,
    194209                                libtrace_packet_t *packet) {
    195         daginf_t lt_dag_inf;
    196 
    197210        if (packet->buf_control == TRACE_CTRL_EXTERNAL ||
    198211                        !packet->buffer) {
     
    224237}
    225238
    226 dag_record_t *dag_get_record(libtrace_t *libtrace) {
     239static int dag_available(libtrace_t *libtrace) {
     240        uint32_t diff = FORMAT_DATA->top - FORMAT_DATA->bottom;
     241        if (diff >= dag_record_size)
     242                return diff;
     243        FORMAT_DATA->top = dag_advance_stream(FORMAT_DATA->fd,
     244                        FORMAT_DATA->dagstream,
     245                        &(FORMAT_DATA->bottom));
     246        if (FORMAT_DATA->top == NULL) {
     247                trace_set_err(libtrace, errno, "dag_advance_stream failed!");
     248                return -1;
     249        }
     250        diff = FORMAT_DATA->top - FORMAT_DATA->bottom;
     251        return diff;
     252}
     253
     254static dag_record_t *dag_get_record(libtrace_t *libtrace) {
    227255        dag_record_t *erfptr = NULL;
    228256        uint16_t size;
    229         erfptr = (dag_record_t *) dag_rx_stream_next_record(FORMAT_DATA->fd,
    230                         FORMAT_DATA->dagstream);
     257        erfptr = (dag_record_t *)FORMAT_DATA->bottom;
    231258        if (!erfptr)
    232259                return NULL;
    233260        size = ntohs(erfptr->rlen);
    234261        assert( size >= dag_record_size );
     262        /* Make certain we have the full packet available */
     263        if (size > (FORMAT_DATA->top - FORMAT_DATA->bottom))
     264                return NULL;
     265        FORMAT_DATA->bottom += size;
    235266        return erfptr;
    236267}
    237268
    238 void dag_form_packet(dag_record_t *erfptr, libtrace_packet_t *packet) {
     269static void dag_form_packet(dag_record_t *erfptr, libtrace_packet_t *packet) {
    239270        packet->buffer = erfptr;
    240271        packet->header = erfptr;
     
    257288        struct timeval tv;
    258289        dag_record_t *erfptr = NULL;
    259 
     290        int numbytes = 0;
     291       
    260292        if (DUCK.last_pkt - DUCK.last_duck > DUCK.duck_freq &&
    261293                        DUCK.duck_freq != 0) {
     
    276308
    277309        do {
     310                numbytes = dag_available(libtrace);
     311                if (numbytes < 0)
     312                        return numbytes;
     313                if (numbytes < dag_record_size)
     314                        /* Block until we see a packet */
     315                        continue;
    278316                erfptr = dag_get_record(libtrace);
    279317        } while (erfptr == NULL);
  • lib/libtrace_int.h

    re1fdc05 r52656ed  
    109109#  include "dagnew.h"
    110110#  include "dagapi.h"
    111 #       ifndef DAG_VERSION_2_4
     111#       if DAG_VERSION == 25
    112112#               include <daginf.h>
    113113#       endif
Note: See TracChangeset for help on using the changeset viewer.