- Timestamp:
- 06/23/17 14:25:59 (4 years ago)
- Branches:
- cachetimestamps, develop, dpdk-ndag, etsilive, master, ndag_format, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance
- Children:
- 4578626
- Parents:
- 633339d (diff), 1105ce0 (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. - Location:
- lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_linux_common.c
rdb84bb2 rd47ca18 61 61 static int linuxnative_configure_bpf(libtrace_t *libtrace, 62 62 libtrace_filter_t *filter) { 63 #if def HAVE_LIBPCAP63 #if defined(HAVE_LIBPCAP) && defined(HAVE_BPF) 64 64 struct ifreq ifr; 65 65 unsigned int arphrd; … … 125 125 return 0; 126 126 #else 127 return -1 127 return -1; 128 128 #endif 129 129 } … … 404 404 * pre-compiled. 405 405 */ 406 #ifdef HAVE_BPF 406 407 if (filter != NULL) { 407 408 /* Check if the filter was successfully compiled. If not, … … 424 425 } 425 426 } 427 #endif 426 428 427 429 /* Consume any buffered packets that were received before the socket -
lib/format_pcap.c
r633339d rfdf1f7b 128 128 129 129 /* If a filter has been configured, compile and apply it */ 130 #ifdef HAVE_BPF 130 131 if (DATA(libtrace)->filter) { 131 132 if (DATA(libtrace)->filter->flag == 0) { … … 143 144 } 144 145 } 146 #endif 145 147 return 0; 146 148 } … … 152 154 switch(option) { 153 155 case TRACE_OPTION_FILTER: 156 #ifdef HAVE_BPF 154 157 DATA(libtrace)->filter=data; 155 158 return 0; 159 #else 160 return -1; 161 #endif 156 162 case TRACE_OPTION_SNAPLEN: 157 163 /* Snapping isn't supported directly, so fall thru … … 211 217 switch(option) { 212 218 case TRACE_OPTION_FILTER: 219 #ifdef HAVE_BPF 213 220 DATA(libtrace)->filter=(libtrace_filter_t*)data; 214 221 return 0; 222 #else 223 return -1; 224 #endif 215 225 case TRACE_OPTION_SNAPLEN: 216 226 DATA(libtrace)->snaplen=*(int*)data; … … 298 308 #endif 299 309 /* Set a filter if one is defined */ 310 #ifdef HAVE_BPF 300 311 if (DATA(libtrace)->filter) { 301 312 struct pcap_pkthdr *pcap_hdr = NULL; … … 342 353 return -1; 343 354 } 355 #endif 344 356 return 0; /* success */ 345 357 } -
lib/trace.c
radb2c4c rd47ca18 1350 1350 trace_create_filter_from_bytecode(void *bf_insns, unsigned int bf_len) 1351 1351 { 1352 #ifndef HAVE_BPF _FILTER1352 #ifndef HAVE_BPF 1353 1353 fprintf(stderr, "This version of libtrace does not have BPF support\n"); 1354 1354 return NULL; … … 1377 1377 */ 1378 1378 DLLEXPORT libtrace_filter_t *trace_create_filter(const char *filterstring) { 1379 #ifdef HAVE_BPF _FILTER1379 #ifdef HAVE_BPF 1380 1380 libtrace_filter_t *filter = (libtrace_filter_t*) 1381 1381 malloc(sizeof(libtrace_filter_t)); … … 1392 1392 DLLEXPORT void trace_destroy_filter(libtrace_filter_t *filter) 1393 1393 { 1394 #ifdef HAVE_BPF _FILTER1394 #ifdef HAVE_BPF 1395 1395 free(filter->filterstring); 1396 1396 if (filter->flag) … … 1417 1417 void *linkptr, 1418 1418 libtrace_linktype_t linktype ) { 1419 #ifdef HAVE_BPF _FILTER1419 #ifdef HAVE_BPF 1420 1420 /* It just so happens that the underlying libs used by pthread arn't 1421 1421 * thread safe, namely lex/flex thingys, so single threaded compile … … 1481 1481 DLLEXPORT int trace_apply_filter(libtrace_filter_t *filter, 1482 1482 const libtrace_packet_t *packet) { 1483 #ifdef HAVE_BPF _FILTER1483 #ifdef HAVE_BPF 1484 1484 void *linkptr = 0; 1485 1485 uint32_t clen = 0; -
lib/trace_parallel.c
rf4fdcd1 rb606855 805 805 break; 806 806 case MESSAGE_DO_STOP: 807 /* Either FINISHED or FINISHING */ 807 808 assert(trace->started == false); 808 assert(trace->state == STATE_FINISHED);809 809 /* Mark the current packet as EOF */ 810 810 packet->error = 0; 811 break;811 goto hasher_eof; 812 812 default: 813 813 fprintf(stderr, "Hasher thread didn't expect message code=%d\n", message.code); … … 850 850 } 851 851 } 852 852 hasher_eof: 853 853 /* Broadcast our last failed read to all threads */ 854 854 for (i = 0; i < trace->perpkt_thread_count; i++) { … … 862 862 ASSERT_RET(pthread_mutex_lock(&trace->libtrace_lock), == 0); 863 863 if (trace->perpkt_threads[i].state != THREAD_FINISHED) { 864 // Unlock early otherwise we could deadlock865 864 libtrace_ringbuffer_write(&trace->perpkt_threads[i].rbuffer, bcast); 865 } else { 866 libtrace_ocache_free(&trace->packet_freelist, (void **) &bcast, 1, 1); 866 867 } 867 868 ASSERT_RET(pthread_mutex_unlock(&trace->libtrace_lock), == 0);
Note: See TracChangeset
for help on using the changeset viewer.