Changeset 65a41fd


Ignore:
Timestamp:
11/17/05 15:05:10 (15 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:
08f7fca
Parents:
de99828
Message:

Fixed bug in erf_write_packet where a packet with an rxerror would have
a NULL payload and hence, rlen would be greater than the amount of data
written out. This causes major problems when the trace is later read back
in.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_erf.c

    re3b0188 r65a41fd  
    547547                return 0;
    548548        }
     549
    549550        rlen = ntohs(((dag_record_t *)buffer)->rlen);
    550551        buffer2 = buffer + dag_record_size;
    551552        size = rlen - dag_record_size;
    552553        assert(size < LIBTRACE_PACKET_BUFSIZE);
     554       
    553555        /* If your trace is legacy, or corrupt, then this assert may fire. */
    554556        /* turns out some older traces have fixed snaplens, which are padded
     
    611613        buffer = packet->buffer;
    612614
     615       
    613616        do {
    614617                if (tracefifo_out_available(libtrace->fifo) == 0 || read_required) {
     
    627630                }
    628631                tracefifo_out_update(libtrace->fifo,sizeof(uint32_t));
    629 
    630632                // Read in packet size
    631633                if (tracefifo_out_read(libtrace->fifo,
     
    679681                return -1;
    680682        }
    681         if ((numbytes = LIBTRACE_WRITE(OUTPUT.file, buffer, size)) == 0) {
    682                 perror("libtrace_write");
    683                 return -1;
    684         }
    685         return numbytes + pad + dag_record_size;
     683
     684        if (buffer) {
     685                if ((numbytes = LIBTRACE_WRITE(OUTPUT.file, buffer, size)) == 0) {
     686                        perror("libtrace_write");
     687                        return -1;
     688                }
     689       
     690                return numbytes + pad + dag_record_size;
     691        }
     692        return numbytes;
    686693}
    687694               
     
    690697        dag_record_t erfhdr;
    691698        int pad = 0;
     699        dag_record_t *dag_hdr = (dag_record_t *)packet->buffer;
    692700        void *payload = (void *)trace_get_link(packet);
    693701
    694702        pad = erf_get_padding(packet);
     703
     704        /* If we've had an rxerror, we have no payload to write - fix rlen to
     705         * be the correct length */
     706        if (payload == NULL) {
     707                dag_hdr->rlen = htons(dag_record_size + pad);
     708        }
     709       
    695710        if (packet->trace->format == &erf ||
    696711#if HAVE_DAG
Note: See TracChangeset for help on using the changeset viewer.