Changeset 3fe009c
- Timestamp:
- 02/23/16 15:33:33 (5 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, master, ndag_format, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- 9636216
- Parents:
- 6d082e6 (diff), e4eff86 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 1 added
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile.am
r60f3c4c ra2ce0a6 22 22 $(RM) -rf autom4te.cache/ 23 23 24 dist-hook:25 if which svnversion > /dev/null; then \26 r=`svnversion -nc . | sed -e 's/^[^:]*://;s/[A-Za-z]//'` ;\27 sed -i "s/SVN_REVISION.*/SVN_REVISION $$r/" $(distdir)/lib/libtrace.h.in; \28 fi29 30 24 if HAS_DOXYGEN 31 25 docs/doxygen/man/man3/*.3: docs -
README
ra7c8f4a r3e5518a 1 libtrace 3.0.2 11 libtrace 3.0.22 2 2 3 3 --------------------------------------------------------------------------- 4 Copyright (c) 2007-201 4The University of Waikato, Hamilton, New Zealand.4 Copyright (c) 2007-2015 The University of Waikato, Hamilton, New Zealand. 5 5 All rights reserved. 6 6 -
configure.in
r092a09c r3e5518a 4 4 # and in the README 5 5 6 AC_INIT([libtrace],[3.0.2 1],[contact@wand.net.nz],[libtrace])6 AC_INIT([libtrace],[3.0.22],[contact@wand.net.nz],[libtrace]) 7 7 8 8 LIBTRACE_MAJOR=3 9 9 LIBTRACE_MID=0 10 LIBTRACE_MINOR=2 110 LIBTRACE_MINOR=22 11 11 12 12 # OpenSolaris hides libraries like libncurses in /usr/gnu/lib, which is not … … 418 418 if test "$ac_cv_search_dlopen" != "none required"; then 419 419 LIBPKTDUMP_LIBS="$LIBPKTDUMP_LIBS $ac_cv_search_dlopen" 420 if test "$dpdk_found" = 1; then 421 LIBTRACE_LIBS="$LIBTRACE_LIBS -Wl,$ac_cv_search_dlopen" 422 fi 420 423 fi 421 424 -
lib/format_dag25.c
r51d1f64 rc5ac872 104 104 /* "Global" data that is stored for each DAG output trace */ 105 105 struct dag_format_data_out_t { 106 /* String containing the DAG device name */ 107 char *device_name; 106 108 /* The DAG device being used for writing */ 107 109 struct dag_dev_t *device; … … 132 134 } duck; 133 135 134 /* The DAG device that we are reading from */ 136 /* String containing the DAG device name */ 137 char *device_name; 138 /* The DAG device that we are reading from */ 135 139 struct dag_dev_t *device; 136 140 /* The DAG stream that we are reading from */ … … 146 150 /* The number of packets that have been dropped */ 147 151 uint64_t drops; 152 153 uint8_t seeninterface[4]; 148 154 }; 149 155 … … 206 212 FORMAT_DATA_OUT->stream_attached = 0; 207 213 FORMAT_DATA_OUT->device = NULL; 214 FORMAT_DATA_OUT->device_name = NULL; 208 215 FORMAT_DATA_OUT->dagstream = 0; 209 216 FORMAT_DATA_OUT->waiting = 0; … … 221 228 FORMAT_DATA->stream_attached = 0; 222 229 FORMAT_DATA->drops = 0; 230 FORMAT_DATA->device_name = NULL; 223 231 FORMAT_DATA->device = NULL; 224 232 FORMAT_DATA->dagstream = 0; … … 226 234 FORMAT_DATA->bottom = NULL; 227 235 FORMAT_DATA->top = NULL; 236 memset(FORMAT_DATA->seeninterface, 0, sizeof(FORMAT_DATA->seeninterface)); 228 237 } 229 238 … … 275 284 dag_close(dev->fd); 276 285 if (dev->dev_name) 277 free(dev->dev_name);286 free(dev->dev_name); 278 287 free(dev); 279 288 } … … 389 398 /* Creates and initialises a DAG output trace */ 390 399 static int dag_init_output(libtrace_out_t *libtrace) { 391 char *dag_dev_name = NULL;392 400 char *scan = NULL; 393 401 struct dag_dev_t *dag_device = NULL; … … 412 420 * If no stream is specified, we will write using stream 1 */ 413 421 if ((scan = strchr(libtrace->uridata,',')) == NULL) { 414 dag_dev_name = strdup(libtrace->uridata);422 FORMAT_DATA_OUT->device_name = strdup(libtrace->uridata); 415 423 } else { 416 dag_dev_name = (char *)strndup(libtrace->uridata, 424 FORMAT_DATA_OUT->device_name = 425 (char *)strndup(libtrace->uridata, 417 426 (size_t)(scan - libtrace->uridata)); 418 427 stream = atoi(++scan); … … 421 430 422 431 /* See if our DAG device is already open */ 423 dag_device = dag_find_open_device( dag_dev_name);432 dag_device = dag_find_open_device(FORMAT_DATA_OUT->device_name); 424 433 425 434 if (dag_device == NULL) { 426 435 /* Device not yet opened - open it ourselves */ 427 dag_device = dag_open_output_device(libtrace, dag_dev_name); 428 } else { 429 /* Otherwise, just use the existing one */ 430 free(dag_dev_name); 431 dag_dev_name = NULL; 436 dag_device = dag_open_output_device(libtrace, 437 FORMAT_DATA_OUT->device_name); 432 438 } 433 439 434 440 /* Make sure we have successfully opened a DAG device */ 435 441 if (dag_device == NULL) { 436 if (dag_dev_name) { 437 free(dag_dev_name); 442 if (FORMAT_DATA_OUT->device_name) { 443 free(FORMAT_DATA_OUT->device_name); 444 FORMAT_DATA_OUT->device_name = NULL; 438 445 } 439 446 pthread_mutex_unlock(&open_dag_mutex); … … 448 455 /* Creates and initialises a DAG input trace */ 449 456 static int dag_init_input(libtrace_t *libtrace) { 450 char *dag_dev_name = NULL;451 457 char *scan = NULL; 452 458 int stream = 0; … … 464 470 * If no stream is specified, we will read from stream 0 */ 465 471 if ((scan = strchr(libtrace->uridata,',')) == NULL) { 466 dag_dev_name = strdup(libtrace->uridata);472 FORMAT_DATA->device_name = strdup(libtrace->uridata); 467 473 } else { 468 dag_dev_name = (char *)strndup(libtrace->uridata,474 FORMAT_DATA->device_name = (char *)strndup(libtrace->uridata, 469 475 (size_t)(scan - libtrace->uridata)); 470 476 stream = atoi(++scan); … … 474 480 475 481 /* See if our DAG device is already open */ 476 dag_device = dag_find_open_device( dag_dev_name);482 dag_device = dag_find_open_device(FORMAT_DATA->device_name); 477 483 478 484 if (dag_device == NULL) { 479 485 /* Device not yet opened - open it ourselves */ 480 dag_device = dag_open_device(libtrace, dag_dev_name); 481 } else { 482 /* Otherwise, just use the existing one */ 483 free(dag_dev_name); 484 dag_dev_name = NULL; 486 dag_device=dag_open_device(libtrace, FORMAT_DATA->device_name); 485 487 } 486 488 487 489 /* Make sure we have successfully opened a DAG device */ 488 490 if (dag_device == NULL) { 489 if ( dag_dev_name)490 free( dag_dev_name);491 dag_dev_name = NULL;491 if (FORMAT_DATA->device_name) 492 free(FORMAT_DATA->device_name); 493 FORMAT_DATA->device_name = NULL; 492 494 pthread_mutex_unlock(&open_dag_mutex); 493 495 return -1; … … 521 523 /* This option is used to specify the frequency of DUCK 522 524 * updates */ 523 525 DUCK.duck_freq = *(int *)data; 524 526 return 0; 525 527 case TRACE_OPTION_SNAPLEN: … … 557 559 558 560 if (dag_attach_stream(FORMAT_DATA_OUT->device->fd, 559 FORMAT_DATA_OUT->dagstream, 0, 1048576) < 0) {561 FORMAT_DATA_OUT->dagstream, 0, 4 * 1024 * 1024) < 0) { 560 562 trace_set_err_out(libtrace, errno, "Cannot attach DAG stream"); 561 563 return -1; … … 581 583 static int dag_start_input(libtrace_t *libtrace) { 582 584 struct timeval zero, nopoll; 583 uint8_t *top, *bottom; 584 uint8_t diff = 0; 585 uint8_t *top, *bottom, *starttop; 585 586 top = bottom = NULL; 586 587 … … 608 609 &nopoll); 609 610 611 starttop = dag_advance_stream(FORMAT_DATA->device->fd, 612 FORMAT_DATA->dagstream, 613 &bottom); 614 610 615 /* Should probably flush the memory hole now */ 611 do { 616 top = starttop; 617 while (starttop - bottom > 0) { 618 bottom += (starttop - bottom); 612 619 top = dag_advance_stream(FORMAT_DATA->device->fd, 613 620 FORMAT_DATA->dagstream, 614 621 &bottom); 615 assert(top && bottom); 616 diff = top - bottom; 617 bottom -= diff; 618 } while (diff != 0); 619 FORMAT_DATA->top = NULL; 620 FORMAT_DATA->bottom = NULL; 622 } 623 FORMAT_DATA->top = top; 624 FORMAT_DATA->bottom = bottom; 621 625 FORMAT_DATA->processed = 0; 622 626 FORMAT_DATA->drops = 0; … … 676 680 if (DUCK.dummy_duck) 677 681 trace_destroy_dead(DUCK.dummy_duck); 682 if (FORMAT_DATA->device_name) 683 free(FORMAT_DATA->device_name); 678 684 free(libtrace->format_data); 679 685 pthread_mutex_unlock(&open_dag_mutex); … … 709 715 if (FORMAT_DATA_OUT->device->ref_count == 0) 710 716 dag_close_device(FORMAT_DATA_OUT->device); 717 if (FORMAT_DATA_OUT->device_name) 718 free(FORMAT_DATA_OUT->device_name); 711 719 free(libtrace->format_data); 712 720 pthread_mutex_unlock(&open_dag_mutex); … … 714 722 } 715 723 724 #ifdef DAGIOC_CARD_DUCK 725 #define LIBTRACE_DUCK_IOCTL DAGIOC_CARD_DUCK 726 #define LIBTRACE_DUCK_VERSION TRACE_RT_DUCK_5_0 727 #else 728 #ifdef DAGIOCDUCK 729 #define LIBTRACE_DUCK_IOCTL DAGIOCDUCK 730 #define LIBTRACE_DUCK_VERSION TRACE_RT_DUCK_2_5 731 #else 732 #warning "DAG appears to be missing DUCK support" 733 #endif 734 #endif 735 716 736 /* Extracts DUCK information from the DAG card and produces a DUCK packet */ 717 737 static int dag_get_duckinfo(libtrace_t *libtrace, 718 738 libtrace_packet_t *packet) { 739 740 if (DUCK.duck_freq == 0) 741 return 0; 742 743 #ifndef LIBTRACE_DUCK_IOCTL 744 trace_set_err(libtrace, errno, 745 "Requested DUCK information but unable to determine the correct ioctl for DUCK"); 746 DUCK.duck_freq = 0; 747 return -1; 748 #endif 749 750 if (DUCK.last_pkt - DUCK.last_duck < DUCK.duck_freq) 751 return 0; 719 752 720 753 /* Allocate memory for the DUCK data */ … … 736 769 /* No need to check if we can get DUCK or not - we're modern 737 770 * enough so just grab the DUCK info */ 738 if ((ioctl(FORMAT_DATA->device->fd, DAGIOCDUCK,771 if ((ioctl(FORMAT_DATA->device->fd, LIBTRACE_DUCK_IOCTL, 739 772 (duckinf_t *)packet->payload) < 0)) { 740 trace_set_err(libtrace, errno, "Error using DAGIOCDUCK"); 773 trace_set_err(libtrace, errno, "Error using DUCK ioctl"); 774 DUCK.duck_freq = 0; 741 775 return -1; 742 776 } 743 777 744 packet->type = TRACE_RT_DUCK_2_5;745 746 /* Set the packet's trac ce to point at a DUCK trace, so that the778 packet->type = LIBTRACE_DUCK_VERSION; 779 780 /* Set the packet's trace to point at a DUCK trace, so that the 747 781 * DUCK format functions will be called on the packet rather than the 748 782 * DAG ones */ 749 783 if (!DUCK.dummy_duck) 750 DUCK.dummy_duck = trace_create_dead(" rt:localhost:3434");784 DUCK.dummy_duck = trace_create_dead("duck:dummy"); 751 785 packet->trace = DUCK.dummy_duck; 786 DUCK.last_duck = DUCK.last_pkt; 752 787 return sizeof(duckinf_t); 753 788 } … … 843 878 } else { 844 879 /* Use the ERF loss counter */ 845 DATA(libtrace)->drops += ntohs(erfptr->lctr); 880 if (FORMAT_DATA->seeninterface[erfptr->flags.iface] == 0) { 881 FORMAT_DATA->seeninterface[erfptr->flags.iface] = 1; 882 } else { 883 FORMAT_DATA->drops += ntohs(erfptr->lctr); 884 } 846 885 } 847 886 … … 1044 1083 1045 1084 /* Check if we're due for a DUCK report */ 1046 if (DUCK.last_pkt - DUCK.last_duck > DUCK.duck_freq && 1047 DUCK.duck_freq != 0) { 1048 size = dag_get_duckinfo(libtrace, packet); 1049 DUCK.last_duck = DUCK.last_pkt; 1050 if (size != 0) { 1051 return size; 1052 } 1053 /* No DUCK support, so don't waste our time anymore */ 1054 DUCK.duck_freq = 0; 1055 } 1085 size = dag_get_duckinfo(libtrace, packet); 1086 1087 if (size != 0) 1088 return size; 1089 1056 1090 1057 1091 /* Don't let anyone try to free our DAG memory hole! */ … … 1111 1145 int numbytes; 1112 1146 uint32_t flags = 0; 1113 struct timeval minwait ;1147 struct timeval minwait, tv; 1114 1148 1115 1149 minwait.tv_sec = 0; 1116 1150 minwait.tv_usec = 10000; 1151 1152 /* Check if we're meant to provide a DUCK update */ 1153 numbytes = dag_get_duckinfo(libtrace, packet); 1154 if (numbytes < 0) { 1155 event.type = TRACE_EVENT_TERMINATE; 1156 return event; 1157 } else if (numbytes > 0) { 1158 event.type = TRACE_EVENT_PACKET; 1159 return event; 1160 } 1117 1161 1118 1162 if (dag_set_stream_poll(FORMAT_DATA->device->fd, … … 1187 1231 } 1188 1232 1233 /* Update the DUCK timer */ 1234 tv = trace_get_timeval(packet); 1235 DUCK.last_pkt = tv.tv_sec; 1236 1189 1237 if (libtrace->snaplen > 0) { 1190 1238 trace_set_capture_length(packet, libtrace->snaplen); -
lib/format_dpdk.c
r9f43919 rb585975 1 1 2 /* 2 3 * This file is part of libtrace … … 69 70 * code (that we still attempt to support). 70 71 * 71 * Currently 1.5 to 1.7 is supported. 72 * DPDK v1.7.1 is recommended. 73 * However 1.5 to 1.8 are likely supported. 72 74 */ 73 75 #include <rte_eal.h> … … 86 88 /* 1.6.0r2 : 87 89 * rte_eal_pci_set_blacklist() is removed 88 * device_list is renamed ot pci_device_list 90 * device_list is renamed to pci_device_list 91 * In the 1.7.0 release rte_eal_pci_probe is called by rte_eal_init 92 * as such we do apply the whitelist before rte_eal_init. 93 * This also works correctly with DPDK 1.6.0r2. 89 94 * 90 95 * Replaced by: … … 108 113 #else 109 114 # define DPDK_USE_PMD_INIT 0 115 #endif 116 117 /* 1.7.0-rc3 : 118 * 119 * Since 1.7.0-rc3 rte_eal_pci_probe is called as part of rte_eal_init. 120 * Somewhere between 1.7 and 1.8 calling it twice broke so we should not call 121 * it twice. 122 */ 123 #if RTE_VERSION < RTE_VERSION_NUM(1, 7, 0, 3) 124 # define DPDK_USE_PCI_PROBE 1 125 #else 126 # define DPDK_USE_PCI_PROBE 0 127 #endif 128 129 /* 1.8.0-rc1 : 130 * LOG LEVEL is a command line option which overrides what 131 * we previously set it to. 132 */ 133 #if RTE_VERSION >= RTE_VERSION_NUM(1, 8, 0, 1) 134 # define DPDK_USE_LOG_LEVEL 1 135 #else 136 # define DPDK_USE_LOG_LEVEL 0 110 137 #endif 111 138 … … 329 356 #else /* DPDK_USE_BLACKLIST */ 330 357 #include <rte_devargs.h> 331 static int blacklist_devices(struct dpdk_format_data_t *format_data UNUSED, struct rte_pci_addr *whitelist)358 static int whitelist_device(struct dpdk_format_data_t *format_data UNUSED, struct rte_pci_addr *whitelist) 332 359 { 333 360 char pci_str[20] = {0}; … … 353 380 */ 354 381 static int parse_pciaddr(char * str, struct rte_pci_addr * addr, long * core) { 355 char * wrkstr; 356 char * pch; 382 int matches; 357 383 assert(str); 358 wrkstr = strdup(str); 359 360 pch = strtok(wrkstr,":"); 361 if (pch == NULL || pch[0] == 0) { 362 free(wrkstr); return -1; 363 } 364 addr->domain = (uint16_t) atoi(pch); 365 366 pch = strtok(NULL,":"); 367 if (pch == NULL || pch[0] == 0) { 368 free(wrkstr); return -1; 369 } 370 addr->bus = (uint8_t) atoi(pch); 371 372 pch = strtok(NULL,"."); 373 if (pch == NULL || pch[0] == 0) { 374 free(wrkstr); return -1; 375 } 376 addr->devid = (uint8_t) atoi(pch); 377 378 pch = strtok(NULL,"-"); /* Might not find the '-' it's optional */ 379 if (pch == NULL || pch[0] == 0) { 380 free(wrkstr); return -1; 381 } 382 addr->function = (uint8_t) atoi(pch); 383 384 pch = strtok(NULL, ""); /* Find end of string */ 385 386 if (pch != NULL && pch[0] != 0) { 387 *core = (long) atoi(pch); 388 } 389 390 free(wrkstr); 391 return 0; 384 matches = sscanf(str, "%4"SCNx16":%2"SCNx8":%2"SCNx8".%2"SCNx8"-%ld", 385 &addr->domain, &addr->bus, &addr->devid, &addr->function, core); 386 if (matches >= 4) { 387 return 0; 388 } else { 389 return -1; 390 } 392 391 } 393 392 … … 398 397 struct rte_config * global_config; 399 398 long nb_cpu = sysconf(_SC_NPROCESSORS_ONLN); 400 399 401 400 if (nb_cpu <= 0) { 402 401 perror("sysconf(_SC_NPROCESSORS_ONLN) failed. Falling back to the first core."); … … 405 404 if (nb_cpu > RTE_MAX_LCORE) 406 405 nb_cpu = RTE_MAX_LCORE; 407 406 408 407 global_config = rte_eal_get_configuration(); 409 408 410 409 if (global_config != NULL) { 411 410 int i; 412 411 fprintf(stderr, "Intel DPDK setup\n" 413 "---Version : %"PRIu32"\n" 414 "---Magic : %"PRIu32"\n" 412 "---Version : %s\n" 415 413 "---Master LCore : %"PRIu32"\n" 416 414 "---LCore Count : %"PRIu32"\n", 417 global_config->version, global_config->magic,415 rte_version(), 418 416 global_config->master_lcore, global_config->lcore_count); 419 417 420 418 for (i = 0 ; i < nb_cpu; i++) { 421 fprintf(stderr, " ---Core %d : %s\n", i, 419 fprintf(stderr, " ---Core %d : %s\n", i, 422 420 global_config->lcore_role[i] == ROLE_RTE ? "on" : "off"); 423 421 } 424 422 425 423 const char * proc_type; 426 424 switch (global_config->process_type) { … … 442 440 fprintf(stderr, "---Process Type : %s\n", proc_type); 443 441 } 444 442 445 443 } 446 444 #endif … … 486 484 #if DEBUG 487 485 rte_set_log_level(RTE_LOG_DEBUG); 488 #else 486 #else 489 487 rte_set_log_level(RTE_LOG_WARNING); 490 488 #endif … … 494 492 * port that already in use. 495 493 */ 496 char* argv[] = {"libtrace", "-c", cpu_number, "-n", "1", "--proc-type", "auto", 497 "--file-prefix", mem_map, "-m", "256", NULL}; 494 char* argv[] = {"libtrace", 495 "-c", cpu_number, 496 "-n", "1", 497 "--proc-type", "auto", 498 "--file-prefix", mem_map, 499 "-m", "256", 500 #if DPDK_USE_LOG_LEVEL 501 # if DEBUG 502 "--log-level", "8", /* RTE_LOG_DEBUG */ 503 # else 504 "--log-level", "5", /* RTE_LOG_WARNING */ 505 # endif 506 #endif 507 NULL}; 498 508 int argc = sizeof(argv) / sizeof(argv[0]) - 1; 499 509 … … 543 553 snprintf(cpu_number, sizeof(cpu_number), "%x", 0x1 << (my_cpu - 1)); 544 554 555 #if !DPDK_USE_BLACKLIST 556 /* Black list all ports besides the one that we want to use */ 557 if ((ret = whitelist_device(format_data, &use_addr)) < 0) { 558 snprintf(err, errlen, "Intel DPDK - Whitelisting PCI device failed," 559 " are you sure the address is correct?: %s", strerror(-ret)); 560 return -1; 561 } 562 #endif 545 563 546 564 /* Give the memory map a unique name */ … … 572 590 #endif 573 591 592 #if DPDK_USE_BLACKLIST 574 593 /* Blacklist all ports besides the one that we want to use */ 575 594 if ((ret = blacklist_devices(format_data, &use_addr)) < 0) { … … 578 597 return -1; 579 598 } 580 599 #endif 600 601 #if DPDK_USE_PCI_PROBE 581 602 /* This loads DPDK drivers against all ports that are not blacklisted */ 582 603 if ((ret = rte_eal_pci_probe()) < 0) { … … 585 606 return -1; 586 607 } 608 #endif 587 609 588 610 format_data->nb_ports = rte_eth_dev_count(); … … 845 867 8, sizeof(struct rte_pktmbuf_pool_private), 846 868 rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL, 847 0, MEMPOOL_F_SP_PUT | MEMPOOL_F_SC_GET);869 rte_socket_id(), MEMPOOL_F_SP_PUT | MEMPOOL_F_SC_GET); 848 870 849 871 if (format_data->pktmbuf_pool == NULL) { … … 876 898 */ 877 899 ret = rte_eth_tx_queue_setup(format_data->port, format_data->queue_id, 878 format_data->nb_tx_buf, SOCKET_ID_ANY, &tx_conf);900 format_data->nb_tx_buf, rte_socket_id(), &tx_conf); 879 901 if (ret < 0) { 880 902 snprintf(err, errlen, "Intel DPDK - Cannot configure TX queue on port" … … 885 907 /* Initialise the RX queue with some packets from memory */ 886 908 ret = rte_eth_rx_queue_setup(format_data->port, format_data->queue_id, 887 format_data->nb_rx_buf, SOCKET_ID_ANY,909 format_data->nb_rx_buf, rte_socket_id(), 888 910 &rx_conf, format_data->pktmbuf_pool); 889 911 if (ret < 0) { … … 1151 1173 #if GET_MAC_CRC_CHECKSUM 1152 1174 /* Add back in the CRC sum */ 1153 pkt->pkt.pkt_len+= ETHER_CRC_LEN;1154 pkt->pkt.data_len+= ETHER_CRC_LEN;1175 rte_pktmbuf_pkt_len(pkt) += ETHER_CRC_LEN; 1176 rte_pktmbuf_data_len(pkt) += ETHER_CRC_LEN; 1155 1177 hdr->flags |= INCLUDES_CHECKSUM; 1156 1178 #endif … … 1294 1316 /* Poll for a single packet */ 1295 1317 nb_rx = rte_eth_rx_burst(FORMAT(libtrace)->port, 1296 FORMAT(libtrace)->queue_id, pkts_burst, 1); 1318 FORMAT(libtrace)->queue_id, pkts_burst, 1); 1297 1319 if (nb_rx > 0) { /* Got a packet - otherwise we keep spining */ 1298 1320 return dpdk_ready_pkt(libtrace, packet, pkts_burst[0]); 1321 } 1322 if (libtrace_halt) { 1323 return 0; 1299 1324 } 1300 1325 } -
lib/format_duck.c
r9b097ea rc5ac872 216 216 duck_size = sizeof(duck2_5_t); 217 217 packet->type = TRACE_RT_DUCK_2_5; 218 } else if (DATA(libtrace)->dag_version == TRACE_RT_DUCK_5_0) { 219 duck_size = sizeof(duck5_0_t); 220 packet->type = TRACE_RT_DUCK_5_0; 218 221 } else { 219 222 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, … … 252 255 253 256 if (packet->type != TRACE_RT_DUCK_2_4 254 && packet->type != TRACE_RT_DUCK_2_5) { 257 && packet->type != TRACE_RT_DUCK_2_5 && 258 packet->type != TRACE_RT_DUCK_5_0) { 255 259 trace_set_err_out(libtrace, TRACE_ERR_BAD_PACKET, 256 260 "Only DUCK packets may be written to a DUCK file"); … … 287 291 case TRACE_RT_DUCK_2_5: 288 292 return sizeof(duck2_5_t); 293 case TRACE_RT_DUCK_5_0: 294 return sizeof(duck5_0_t); 289 295 default: 290 296 trace_set_err(packet->trace,TRACE_ERR_BAD_PACKET, -
lib/format_erf.c
rc70f59f rc69aecb 480 480 packet->buffer, 481 481 (size_t)dag_record_size)) == -1) { 482 trace_set_err(libtrace,errno,"read(%s)", 483 libtrace->uridata); 482 trace_set_err(libtrace,errno,"reading ERF file"); 484 483 return -1; 485 484 } … … 488 487 return 0; 489 488 } 489 490 if (numbytes < (int)dag_record_size) { 491 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Incomplete ERF header"); 492 return -1; 493 } 490 494 491 495 rlen = ntohs(((dag_record_t *)packet->buffer)->rlen); … … 522 526 return -1; 523 527 } 528 529 if (numbytes < (int)size) { 530 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Incomplete ERF record"); 531 return -1; 532 } 524 533 525 534 if (erf_prepare_packet(libtrace, packet, packet->buffer, -
lib/format_linux.c
r63af502 r1bad1e2 1078 1078 assert((((unsigned long) header) & (pagesize - 1)) == 0); 1079 1079 1080 while (1) { 1080 /* TP_STATUS_USER means that we can read the frame. 1081 * When a slot does not have this flag set, the frame is not 1082 * ready for consumption. 1083 */ 1084 while (!(header->tp_status & TP_STATUS_USER)) { 1081 1085 pollset.fd = FORMAT(libtrace->format_data)->fd; 1082 1086 pollset.events = POLLIN; … … 1089 1093 return -1; 1090 1094 } else if (ret == 0) { 1091 /* Poll timed out - check if we should exit */ 1092 if (libtrace_halt) 1093 return 0; 1094 continue; 1095 } 1096 1097 /* TP_STATUS_USER means that we can use the frame. 1098 * When a slot does not have this flag set, the frame is not 1099 * ready for consumption. 1100 */ 1101 if (header->tp_status & TP_STATUS_USER) 1102 break; 1095 /* Poll timed out - check if we should exit */ 1096 if (libtrace_halt) 1097 return 0; 1098 continue; 1099 } 1103 1100 } 1104 1101 -
lib/format_pcapfile.c
rc70f59f rc69aecb 210 210 211 211 if (err<1) { 212 if (err == 0) { 213 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, 214 "Reading pcap file header\n"); 215 } 212 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, 213 "Error while reading pcap file header\n"); 216 214 return -1; 217 215 } 218 216 217 if (err != (int)sizeof(DATA(libtrace)->header)) { 218 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, 219 "Incomplete pcap file header"); 220 return -1; 221 } 222 219 223 if (!header_is_magic(&(DATA(libtrace)->header))) { 220 224 trace_set_err(libtrace,TRACE_ERR_INIT_FAILED, … … 359 363 packet->buffer, 360 364 sizeof(libtrace_pcapfile_pkt_hdr_t)); 361 362 365 if (err<0) { 363 366 trace_set_err(libtrace,errno,"reading packet"); … … 368 371 return 0; 369 372 } 373 374 if (err < (int)sizeof(libtrace_pcapfile_pkt_hdr_t)) { 375 trace_set_err(libtrace, errno, "Incomplete pcap packet header"); 376 return -1; 377 } 370 378 371 379 bytes_to_read = swapl(libtrace,((libtrace_pcapfile_pkt_hdr_t*)packet->buffer)->caplen); … … 391 399 ); 392 400 393 394 401 if (err<0) { 395 402 trace_set_err(libtrace,errno,"reading packet"); … … 399 406 return 0; 400 407 } 408 409 if (err < (int)bytes_to_read) { 410 trace_set_err(libtrace, errno, "Incomplete pcap packet body"); 411 return -1; 412 } 401 413 402 414 if (pcapfile_prepare_packet(libtrace, packet, packet->buffer, -
lib/format_rt.c
rc70f59f rc5ac872 430 430 case TRACE_RT_DUCK_2_4: 431 431 case TRACE_RT_DUCK_2_5: 432 case TRACE_RT_DUCK_5_0: 432 433 if (!RT_INFO->dummy_duck) { 433 434 RT_INFO->dummy_duck = trace_create_dead("duck:dummy"); -
lib/format_tsh.c
rc909fad rc69aecb 147 147 return 0; 148 148 } 149 150 if (numbytes < (int)sizeof(tsh_pkt_header_t)) { 151 trace_set_err(libtrace, errno, "Incomplete TSH header"); 152 return -1; 153 } 149 154 150 155 buffer2 = (char*)buffer2 + numbytes; -
lib/libtrace.h.in
r6d082e6 rc5ac872 109 109 ((@LIBTRACE_MAJOR@<<16)|(@LIBTRACE_MID@<<8)|(@LIBTRACE_MINOR@)) 110 110 111 /** Replaced with the current SVN revision number when 'make dist' is invoked 112 * to create a distributable tarball */ 113 #define LIBTRACE_SVN_REVISION 0 111 /** This used to be replaced with the current SVN revision number when 112 * 'make dist' was invoked to create a distributable tarball. We don't use 113 * SVN anymore and there probably isn't any need to know the exact revision 114 * number either these days. */ 115 #define LIBTRACE_SVN_REVISION LIBTRACE_API_VERSION 114 116 115 117 /** DAG driver version installed on the current system */ … … 381 383 TRACE_RT_CLIENTDROP =17,/**< Reliable client was lost */ 382 384 TRACE_RT_METADATA =18,/**< Packet contains server meta-data */ 385 TRACE_RT_DUCK_5_0 =19,/**< Dag 5.0 Duck */ 383 386 384 387 /** Not actually used - all DATA types begin from this value */ -
lib/libtrace_int.h
r10f924c r6fc1ae7 746 746 * immediately 747 747 */ 748 extern int libtrace_halt;748 extern volatile int libtrace_halt; 749 749 750 750 /** Registers a new capture format module. -
lib/protocols_application.c
r6d082e6 r3fc3267 25 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 26 26 */ 27 #include <stdlib.h> 27 28 #include "libtrace.h" 28 29 29 DLLEXPORT void *trace_get_payload_from_vxlan(libtrace_vxlan_t *vxlan, 30 uint32_t *remaining) 30 void *trace_get_payload_from_vxlan(libtrace_vxlan_t *vxlan, uint32_t *remaining) 31 31 { 32 32 if (remaining) { … … 43 43 44 44 45 DLLEXPORTlibtrace_vxlan_t *trace_get_vxlan_from_udp(libtrace_udp_t *udp,46 45 libtrace_vxlan_t *trace_get_vxlan_from_udp(libtrace_udp_t *udp, 46 uint32_t *remaining) 47 47 { 48 48 if (udp->dest != htons(4789)) { /* UDP port number for vxlan */ -
lib/rt_protocol.h
r81c0b9e rc5ac872 249 249 } PACKED duck2_5_t; 250 250 251 typedef struct duck5_0 { 252 int64_t Phase_Correction; 253 uint64_t Last_Ticks; 254 uint64_t Last_TSC; 255 /* XXX Stat_Start and Stat_End are time_t in dagioctl.h, which means 256 * they could in theory be 32 or 64 bit depending on the architecture 257 * when capturing. I'm going to assume 5.0 era DAG captures are taking 258 * place on a 64 bit arch, rather than have to deal with the varying 259 * sizes (especially given nobody really uses DUCK these days). 260 */ 261 uint64_t Stat_Start, Stat_End; 262 uint32_t Crystal_Freq; 263 uint32_t Synth_Freq; 264 uint32_t Resyncs; 265 uint32_t Bad_Pulses; 266 uint32_t Worst_Freq_Err, Worst_Phase_Err; 267 uint32_t Health_Thresh; 268 uint32_t Pulses, Single_Pulses_Missing, Longest_Pulse_Missing; 269 uint32_t Health, Sickness; 270 int32_t Freq_Err, Phase_Err; 271 uint32_t Set_Duck_Field; 272 } PACKED duck5_0_t; 273 251 274 /* 252 275 typedef struct rt_duck_2_4 { -
lib/trace.c
r7fda5c5 r6fc1ae7 105 105 static struct libtrace_format_t *formats_list = NULL; 106 106 107 int libtrace_halt = 0;107 volatile int libtrace_halt = 0; 108 108 109 109 /* strncpy is not assured to copy the final \0, so we -
libwandio/ior-bzip.c
r60f3c4c re4eff86 33 33 34 34 35 #include "config.h" 35 36 #include "wandio.h" 36 37 #include <bzlib.h> -
libwandio/ior-lzma.c
r0e46fbc re4eff86 32 32 */ 33 33 34 34 #include "config.h" 35 35 #include "wandio.h" 36 36 #include <lzma.h> -
libwandio/ior-peek.c
rce7153d re4eff86 32 32 */ 33 33 34 #include "config.h" 34 35 #include "wandio.h" 35 36 #include <sys/types.h> -
libwandio/ior-stdio.c
r10f924c re4eff86 34 34 35 35 #define _GNU_SOURCE 1 36 #include "config.h" 36 37 #include "wandio_internal.h" 37 38 #include "wandio.h" -
libwandio/ior-zlib.c
r60f3c4c re4eff86 33 33 34 34 35 #include "config.h" 35 36 #include "wandio.h" 36 37 #include <zlib.h> … … 56 57 int outoffset; 57 58 enum err_t err; 59 size_t sincelastend; 58 60 }; 59 61 … … 83 85 DATA(io)->strm.opaque = NULL; 84 86 DATA(io)->err = ERR_OK; 87 DATA(io)->sincelastend = 1; 85 88 86 89 inflateInit2(&DATA(io)->strm, 15 | 32); … … 108 111 sizeof(DATA(io)->inbuff)); 109 112 if (bytes_read == 0) { 110 /* EOF */ 113 /* If we get EOF immediately after a 114 * Z_STREAM_END, then we assume we've reached 115 * the end of the file. If there was data 116 * between the Z_STREAM_END and the EOF, the 117 * file has more likely been truncated. 118 */ 119 if (DATA(io)->sincelastend > 0) { 120 fprintf(stderr, "Unexpected EOF while reading compressed file -- file is probably incomplete\n"); 121 errno = EIO; 122 DATA(io)->err = ERR_ERROR; 123 return -1; 124 } 125 126 /* EOF */ 111 127 if (DATA(io)->strm.avail_out == (uint32_t)len) { 112 128 DATA(io)->err = ERR_EOF; 113 129 return 0; 114 130 } … … 128 144 DATA(io)->strm.next_in = DATA(io)->inbuff; 129 145 DATA(io)->strm.avail_in = bytes_read; 146 DATA(io)->sincelastend += bytes_read; 130 147 } 131 148 /* Decompress some data into the output buffer */ … … 144 161 inflateInit2(&DATA(io)->strm, 15 | 32); 145 162 DATA(io)->err = ERR_OK; 163 DATA(io)->sincelastend = 0; 146 164 break; 147 165 default: -
libwandio/iow-bzip.c
r60f3c4c re4eff86 32 32 */ 33 33 34 #include "config.h" 34 35 #include "wandio.h" 35 36 #include <bzlib.h> -
libwandio/iow-lzma.c
r0e46fbc re4eff86 32 32 33 33 34 #include "config.h" 34 35 #include <lzma.h> 35 36 #include "wandio.h" -
libwandio/iow-lzo.c
rfa7faf3 re4eff86 40 40 */ 41 41 42 #include "config.h" 42 43 #include <lzo/lzo1x.h> 43 44 #include "wandio_internal.h" 44 45 #include "wandio.h" 45 #include "config.h"46 46 #include <sys/types.h> 47 47 #include <sys/stat.h> -
libwandio/iow-stdio.c
r10f924c re4eff86 34 34 35 35 #define _GNU_SOURCE 1 36 #include "config.h" 36 37 #include "wandio_internal.h" 37 38 #include "wandio.h" -
libwandio/iow-zlib.c
r60f3c4c re4eff86 33 33 34 34 35 #include "config.h" 35 36 #include <zlib.h> 36 37 #include "wandio.h" -
test/test-vxlan.c
r6d082e6 r3fc3267 70 70 (void)argv; 71 71 72 trace = trace_create("pcapfile: vxlan.pcap");72 trace = trace_create("pcapfile:traces/vxlan.pcap"); 73 73 iferr(trace); 74 74 -
tools/tracestats/tracestats.c
rc0ccccd r3c54095 157 157 158 158 if (trace_is_err(trace)) 159 trace_perror(trace," %s",uri);159 trace_perror(trace,"Processing trace"); 160 160 161 161 trace_destroy(trace); -
tools/tracestats/tracesummary
r3bfeb7d r065cab9 18 18 --filter 'port domain' \ 19 19 --filter 'icmp[icmptype]=icmp-echoreply' \ 20 $@20 "$@"
Note: See TracChangeset
for help on using the changeset viewer.