Skip to content

Commit b8696ab

Browse files
committed
Merge branch 'develop'
2 parents 402e146 + c3a8356 commit b8696ab

File tree

8 files changed

+48
-10
lines changed

8 files changed

+48
-10
lines changed

README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
libtrace 4.0.21
1+
libtrace 4.0.22
22

33
Code and documentation added since version 4.0.20 is
44
Copyright (c) 2023 Shane Alcock and has been contributed as per

configure.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
# Now you only need to update the version number in two places - below,
44
# and in the README
55

6-
AC_INIT([libtrace],[4.0.21],[shane@alcock.co.nz],[libtrace])
6+
AC_INIT([libtrace],[4.0.22],[shane@alcock.co.nz],[libtrace])
77

88
LIBTRACE_MAJOR=4
99
LIBTRACE_MID=0
10-
LIBTRACE_MINOR=21
10+
LIBTRACE_MINOR=22
1111

1212
# OpenSolaris hides libraries like libncurses in /usr/gnu/lib, which is not
1313
# searched by default - add it to LDFLAGS so we at least have a chance of

debian/changelog

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
libtrace4 (4.0.22-1) unstable; urgency=medium
2+
3+
* Fix segmentation fault when closing an ndag input that had
4+
set a hasher function and was configured to use multiple
5+
processing threads.
6+
* Disable setting a hasher function on ndag inputs, as this
7+
is not generally a good idea anyway (ndag inputs are already
8+
hashed by the ndag sender).
9+
* Fix problem where trace_write_packet() would throw an error on
10+
ring outputs because a write could not be completed without
11+
blocking and there was no mechanism for trying the write again
12+
later.
13+
14+
-- Shane Alcock <shane@alcock.co.nz> Wed, 14 Jun 2023 17:48:08 +1200
15+
116
libtrace4 (4.0.21-1) unstable; urgency=medium
217

318
* Fixed issue where idle per packets threads would use 100% CPU

lib/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ endif
146146

147147
AM_CPPFLAGS= @ADD_INCLS@
148148
libtrace_la_LIBADD = @LIBTRACE_LIBS@ @LTLIBOBJS@ $(DPDKLIBS)
149-
libtrace_la_LDFLAGS=-version-info 7:5:0 @ADD_LDFLAGS@
149+
libtrace_la_LDFLAGS=-version-info 7:6:0 @ADD_LDFLAGS@
150150
dagapi.c:
151151
cp @DAG_TOOLS_DIR@/dagapi.c .
152152

lib/format_linux_ring.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ static int linuxring_write_packet(libtrace_out_t *libtrace,
839839
FORMAT_DATA_OUT->queue++;
840840
FORMAT_DATA_OUT->queue %= FORMAT_DATA_OUT->tx_max_queue;
841841
if (FORMAT_DATA_OUT->queue == 0) {
842-
ret = linuxring_flush_output_nonblocking(libtrace);
842+
ret = linuxring_flush_output_blocking(libtrace);
843843
if (ret < 0) {
844844
return -1;
845845
}
@@ -879,7 +879,7 @@ static struct libtrace_format_t linuxring = {
879879
linuxring_fin_packet, /* fin_packet */
880880
NULL, /* can_hold_packet */
881881
linuxring_write_packet, /* write_packet */
882-
linuxring_flush_output_nonblocking, /* flush_output */
882+
linuxring_flush_output_blocking, /* flush_output */
883883
linuxring_get_link_type, /* get_link_type */
884884
linuxring_get_direction, /* get_direction */
885885
linuxring_set_direction, /* set_direction */

lib/format_ndag.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ typedef struct ndag_format_data {
123123
char *localiface;
124124
uint16_t nextthreadid;
125125
recvstream_t *receivers;
126+
int receiver_cnt;
126127

127128
pthread_t controlthread;
128129
libtrace_message_queue_t controlqueue;
@@ -261,6 +262,7 @@ static int join_multicast_group(char *groupaddr, char *localiface,
261262
goto sockcreateover;
262263
}
263264

265+
memset(&greq, 0, sizeof(greq));
264266
greq.gr_interface = interface;
265267
memcpy(&(greq.gr_group), group->ai_addr, group->ai_addrlen);
266268

@@ -311,6 +313,7 @@ static int ndag_init_input(libtrace_t *libtrace) {
311313
FORMAT_DATA->localiface = NULL;
312314
FORMAT_DATA->nextthreadid = 0;
313315
FORMAT_DATA->receivers = NULL;
316+
FORMAT_DATA->receiver_cnt = 0;
314317
FORMAT_DATA->consterfframing = -1;
315318

316319
scan = strchr(libtrace->uridata, ',');
@@ -506,6 +509,8 @@ static void *ndag_controller_run(void *tdata) {
506509
close(sock);
507510
}
508511

512+
freeaddrinfo(receiveaddr);
513+
509514
/* Control channel has fallen over, should probably encourage libtrace
510515
* to halt the receiver threads as well.
511516
*/
@@ -543,6 +548,7 @@ static int ndag_start_threads(libtrace_t *libtrace, uint32_t maxthreads)
543548
libtrace_message_queue_init(&(FORMAT_DATA->receivers[i].mqueue),
544549
sizeof(ndag_internal_message_t));
545550
}
551+
FORMAT_DATA->receiver_cnt = maxthreads;
546552

547553
/* Start the controller thread */
548554
/* TODO consider affinity of this thread? */
@@ -610,9 +616,11 @@ static int ndag_pause_input(libtrace_t *libtrace) {
610616
int i;
611617

612618
/* Close the existing receiver sockets */
613-
for (i = 0; i < libtrace->perpkt_thread_count; i++) {
619+
for (i = 0; i < FORMAT_DATA->receiver_cnt; i++) {
614620
halt_ndag_receiver(&(FORMAT_DATA->receivers[i]));
615621
}
622+
ndag_paused = 1;
623+
pthread_join(FORMAT_DATA->controlthread, NULL);
616624
return 0;
617625
}
618626

@@ -1564,7 +1572,7 @@ static void ndag_get_statistics(libtrace_t *libtrace, libtrace_stat_t *stat) {
15641572
stat->missing = 0;
15651573

15661574
/* TODO Is this thread safe? */
1567-
for (i = 0; i < libtrace->perpkt_thread_count; i++) {
1575+
for (i = 0; i < FORMAT_DATA->receiver_cnt; i++) {
15681576
stat->dropped += FORMAT_DATA->receivers[i].dropped_upstream;
15691577
stat->received += FORMAT_DATA->receivers[i].received_packets;
15701578
stat->missing += FORMAT_DATA->receivers[i].missing_records;
@@ -1599,6 +1607,9 @@ static int ndag_pregister_thread(libtrace_t *libtrace, libtrace_thread_t *t,
15991607
return 0;
16001608
}
16011609

1610+
if (t->perpkt_num >= FORMAT_DATA->receiver_cnt) {
1611+
return 0;
1612+
}
16021613
recvr = &(FORMAT_DATA->receivers[t->perpkt_num]);
16031614
t->format_data = recvr;
16041615

lib/trace_parallel.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2585,6 +2585,15 @@ DLLEXPORT int trace_set_hasher(libtrace_t *trace, enum hasher_types type,
25852585
return -1;
25862586
}
25872587

2588+
if (strcmp(trace->format->name, "ndag") == 0) {
2589+
/* ndag should never have a hasher applied to it -- each
2590+
* multicast stream is already hashed separately by the
2591+
* sender and trying to hash in libtrace will just make
2592+
* ndag run in single threaded mode instead.
2593+
*/
2594+
return 0;
2595+
}
2596+
25882597
// Save the requirements
25892598
trace->hasher_type = type;
25902599
if (hasher) {

rpm/libtrace4.spec

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Name: libtrace4
2-
Version: 4.0.21
3-
Release: 2%{?dist}
2+
Version: 4.0.22
3+
Release: 1%{?dist}
44
Summary: C Library for capturing and analysing network packets
55

66
License: LGPLv3
@@ -127,6 +127,9 @@ find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
127127

128128

129129
%changelog
130+
* Wed Jun 14 2023 Shane Alcock <shane@alcock.co.nz> - 4.0.22-1
131+
- Updated for 4.0.22 release
132+
130133
* Mon May 22 2023 Shane Alcock <shane@alcock.co.nz> - 4.0.21-2
131134
- Rebuild 4.0.21 to resolve DPDK dependency problems
132135

0 commit comments

Comments
 (0)