- Timestamp:
- 12/18/12 15:03:38 (8 years ago)
- 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:
- a8c3d1d
- Parents:
- 7d6d80e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_linux.c
r5b825b3 rf19c3e9 366 366 FORMAT(libtrace->format_data)->rx_ring = NULL; 367 367 FORMAT(libtrace->format_data)->rxring_offset = 0; 368 FORMAT(libtrace->format_data)->max_order = MAX_ORDER; 368 369 } 369 370 static int linuxring_init_input(libtrace_t *libtrace) … … 388 389 DATAOUT(libtrace)->txring_offset = 0; 389 390 DATAOUT(libtrace)->queue = 0; 391 DATAOUT(libtrace)->max_order = MAX_ORDER; 390 392 } 391 393 static int linuxnative_init_output(libtrace_out_t *libtrace) … … 524 526 return 0; 525 527 } 526 static inline int socket_to_packetmmap( char * uridata, int ring_type,528 static inline int socket_to_packetmmap( char * uridata, int ring_type, 527 529 int fd, 528 530 struct tpacket_req * req, 529 531 char ** ring_location, 530 uint32_t *max_order ){531 socklen_t len;532 uint32_t *max_order, 533 char *error){ 532 534 int val; 533 535 534 536 /* Switch to TPACKET header version 2, we only try support v2 because v1 had problems */ 535 val = TPACKET_V2;536 len = sizeof(val);537 if(getsockopt(fd,538 SOL_PACKET,539 PACKET_HDRLEN,540 &val,541 &len) == -1){542 return -1;543 }544 537 545 538 val = TPACKET_V2; … … 549 542 &val, 550 543 sizeof(val)) == -1){ 544 strncpy(error, "TPACKET2 not supported", 2048); 551 545 return -1; 552 546 } … … 557 551 while(1) { 558 552 if (*max_order <= 0) { 553 strncpy(error,"Cannot allocate enough memory for ring buffer", 2048); 559 554 return -1; 560 555 } … … 568 563 (*max_order)--; 569 564 } else { 565 strncpy(error, "Error setting the ring buffer size", 2048); 570 566 return -1; 571 567 } … … 581 577 fd, 0); 582 578 if(*ring_location == MAP_FAILED){ 579 strncpy(error, "Failed to map memory for ring buffer", 2048); 583 580 return -1; 584 581 } … … 586 583 } 587 584 static int linuxring_start_input(libtrace_t *libtrace){ 588 585 586 char error[2048]; 589 587 590 588 /* We set the socket up the same and then convert it to PACKET_MMAP */ … … 597 595 &FORMAT(libtrace->format_data)->req, 598 596 &FORMAT(libtrace->format_data)->rx_ring, 599 &FORMAT(libtrace->format_data)->max_order ) != 0){600 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED,601 "TPACKET2 not supported or ring buffer is too large");597 &FORMAT(libtrace->format_data)->max_order, 598 error) != 0){ 599 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, error); 602 600 close(DATAOUT(libtrace)->fd); 603 601 free(libtrace->format_data); 602 libtrace->format_data = NULL; 604 603 return -1; 605 604 } … … 621 620 static int linuxring_start_output(libtrace_out_t *libtrace) 622 621 { 622 char error[2048]; 623 623 /* We set the socket up the same and then convert it to PACKET_MMAP */ 624 624 if(linuxnative_start_output(libtrace) != 0) … … 630 630 &DATAOUT(libtrace)->req, 631 631 &DATAOUT(libtrace)->tx_ring, 632 &DATAOUT(libtrace)->max_order ) != 0){633 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED,634 "TPACKET2 not supported or ring buffer is too large");632 &DATAOUT(libtrace)->max_order, 633 error) != 0){ 634 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, error); 635 635 close(DATAOUT(libtrace)->fd); 636 636 free(libtrace->format_data); 637 libtrace->format_data = NULL; 637 638 return -1; 638 639 }
Note: See TracChangeset
for help on using the changeset viewer.