Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
salcock committed Jun 14, 2023
2 parents 402e146 + c3a8356 commit b8696ab
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
libtrace 4.0.21
libtrace 4.0.22

Code and documentation added since version 4.0.20 is
Copyright (c) 2023 Shane Alcock and has been contributed as per
Expand Down
4 changes: 2 additions & 2 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# Now you only need to update the version number in two places - below,
# and in the README

AC_INIT([libtrace],[4.0.21],[[email protected]],[libtrace])
AC_INIT([libtrace],[4.0.22],[[email protected]],[libtrace])

LIBTRACE_MAJOR=4
LIBTRACE_MID=0
LIBTRACE_MINOR=21
LIBTRACE_MINOR=22

# OpenSolaris hides libraries like libncurses in /usr/gnu/lib, which is not
# searched by default - add it to LDFLAGS so we at least have a chance of
Expand Down
15 changes: 15 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
libtrace4 (4.0.22-1) unstable; urgency=medium

* Fix segmentation fault when closing an ndag input that had
set a hasher function and was configured to use multiple
processing threads.
* Disable setting a hasher function on ndag inputs, as this
is not generally a good idea anyway (ndag inputs are already
hashed by the ndag sender).
* Fix problem where trace_write_packet() would throw an error on
ring outputs because a write could not be completed without
blocking and there was no mechanism for trying the write again
later.

-- Shane Alcock <[email protected]> Wed, 14 Jun 2023 17:48:08 +1200

libtrace4 (4.0.21-1) unstable; urgency=medium

* Fixed issue where idle per packets threads would use 100% CPU
Expand Down
2 changes: 1 addition & 1 deletion lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ endif

AM_CPPFLAGS= @ADD_INCLS@
libtrace_la_LIBADD = @LIBTRACE_LIBS@ @LTLIBOBJS@ $(DPDKLIBS)
libtrace_la_LDFLAGS=-version-info 7:5:0 @ADD_LDFLAGS@
libtrace_la_LDFLAGS=-version-info 7:6:0 @ADD_LDFLAGS@
dagapi.c:
cp @DAG_TOOLS_DIR@/dagapi.c .

Expand Down
4 changes: 2 additions & 2 deletions lib/format_linux_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ static int linuxring_write_packet(libtrace_out_t *libtrace,
FORMAT_DATA_OUT->queue++;
FORMAT_DATA_OUT->queue %= FORMAT_DATA_OUT->tx_max_queue;
if (FORMAT_DATA_OUT->queue == 0) {
ret = linuxring_flush_output_nonblocking(libtrace);
ret = linuxring_flush_output_blocking(libtrace);
if (ret < 0) {
return -1;
}
Expand Down Expand Up @@ -879,7 +879,7 @@ static struct libtrace_format_t linuxring = {
linuxring_fin_packet, /* fin_packet */
NULL, /* can_hold_packet */
linuxring_write_packet, /* write_packet */
linuxring_flush_output_nonblocking, /* flush_output */
linuxring_flush_output_blocking, /* flush_output */
linuxring_get_link_type, /* get_link_type */
linuxring_get_direction, /* get_direction */
linuxring_set_direction, /* set_direction */
Expand Down
15 changes: 13 additions & 2 deletions lib/format_ndag.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ typedef struct ndag_format_data {
char *localiface;
uint16_t nextthreadid;
recvstream_t *receivers;
int receiver_cnt;

pthread_t controlthread;
libtrace_message_queue_t controlqueue;
Expand Down Expand Up @@ -261,6 +262,7 @@ static int join_multicast_group(char *groupaddr, char *localiface,
goto sockcreateover;
}

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

Expand Down Expand Up @@ -311,6 +313,7 @@ static int ndag_init_input(libtrace_t *libtrace) {
FORMAT_DATA->localiface = NULL;
FORMAT_DATA->nextthreadid = 0;
FORMAT_DATA->receivers = NULL;
FORMAT_DATA->receiver_cnt = 0;
FORMAT_DATA->consterfframing = -1;

scan = strchr(libtrace->uridata, ',');
Expand Down Expand Up @@ -506,6 +509,8 @@ static void *ndag_controller_run(void *tdata) {
close(sock);
}

freeaddrinfo(receiveaddr);

/* Control channel has fallen over, should probably encourage libtrace
* to halt the receiver threads as well.
*/
Expand Down Expand Up @@ -543,6 +548,7 @@ static int ndag_start_threads(libtrace_t *libtrace, uint32_t maxthreads)
libtrace_message_queue_init(&(FORMAT_DATA->receivers[i].mqueue),
sizeof(ndag_internal_message_t));
}
FORMAT_DATA->receiver_cnt = maxthreads;

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

/* Close the existing receiver sockets */
for (i = 0; i < libtrace->perpkt_thread_count; i++) {
for (i = 0; i < FORMAT_DATA->receiver_cnt; i++) {
halt_ndag_receiver(&(FORMAT_DATA->receivers[i]));
}
ndag_paused = 1;
pthread_join(FORMAT_DATA->controlthread, NULL);
return 0;
}

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

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

if (t->perpkt_num >= FORMAT_DATA->receiver_cnt) {
return 0;
}
recvr = &(FORMAT_DATA->receivers[t->perpkt_num]);
t->format_data = recvr;

Expand Down
9 changes: 9 additions & 0 deletions lib/trace_parallel.c
Original file line number Diff line number Diff line change
Expand Up @@ -2585,6 +2585,15 @@ DLLEXPORT int trace_set_hasher(libtrace_t *trace, enum hasher_types type,
return -1;
}

if (strcmp(trace->format->name, "ndag") == 0) {
/* ndag should never have a hasher applied to it -- each
* multicast stream is already hashed separately by the
* sender and trying to hash in libtrace will just make
* ndag run in single threaded mode instead.
*/
return 0;
}

// Save the requirements
trace->hasher_type = type;
if (hasher) {
Expand Down
7 changes: 5 additions & 2 deletions rpm/libtrace4.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: libtrace4
Version: 4.0.21
Release: 2%{?dist}
Version: 4.0.22
Release: 1%{?dist}
Summary: C Library for capturing and analysing network packets

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


%changelog
* Wed Jun 14 2023 Shane Alcock <[email protected]> - 4.0.22-1
- Updated for 4.0.22 release

* Mon May 22 2023 Shane Alcock <[email protected]> - 4.0.21-2
- Rebuild 4.0.21 to resolve DPDK dependency problems

Expand Down

0 comments on commit b8696ab

Please sign in to comment.