From 4afed3485426445ea93220d00fe57e86f5429d24 Mon Sep 17 00:00:00 2001 From: Neel Nadgir Date: Tue, 11 Apr 2023 06:43:13 -0700 Subject: [PATCH 1/4] Start server automatically during tests. (#63) * Start server automatically during tests. Fixes #32 * Update github actions to not start uperf server --- .github/workflows/c-cpp.yml | 4 ---- tests/test.sh | 19 ++++++++++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index daa7d0f..0e26854 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -25,9 +25,5 @@ jobs: run: ./configure - name: make run: make - - name: start localhost server - run: ./src/uperf -s & - - name: start localhost server for vsock - run: ./src/uperf -s -S vsock & - name: make check run: make check diff --git a/tests/test.sh b/tests/test.sh index afa3e33..afa2920 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -12,7 +12,24 @@ if [[ "$profile" == *".vsock.xml" ]]; then fi fi +# Start server +serverpid="" +if pgrep uperf ; then + echo "uperf server already running; please stop it and try again" + exit +else + echo "Starting server - $uperf -s $csocket" + $uperf -s $csocket & + serverpid=$! +fi + echo h=$host duration=10s $uperf $csocket -m $profile >>log h=$host duration=10s $uperf $csocket -m $profile >> log 2>&1 +exitstatus=$? - +# kill server +if [[ serverpid != "" ]] ; then + echo "Killing $serverpid" + kill -9 $serverpid +fi +exit $exitstatus From 766ca23b9ef0f52a37f8dc2727c8ffe2d1346932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20T=C3=BCxen?= Date: Fri, 26 Apr 2024 15:19:48 +0200 Subject: [PATCH 2/4] Fix compilation if stdatomic.h is present (#65) At least recent versions of macOS and FreeBSD provide stdatomic.h. Fix building uperf on these platfroms. --- src/shm.h | 7 +++++++ src/sync.h | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/shm.h b/src/shm.h index 7ba7696..617e048 100644 --- a/src/shm.h +++ b/src/shm.h @@ -18,6 +18,9 @@ #ifndef _SHM_H #define _SHM_H +#ifdef HAVE_STDATOMIC_H +#include +#endif /* HAVE_STDATOMIC_H */ #include "logging.h" #include "sync.h" #include "workorder.h" @@ -75,7 +78,11 @@ struct uperf_shm { uperf_log_t log; int global_error; uint32_t sstate1[NUM_STATES]; +#ifdef HAVE_STDATOMIC_H + atomic_uint finished; +#else uint32_t finished; +#endif /* HAVE_STDATOMIC_H */ int cleaned_up; /* callouts */ diff --git a/src/sync.h b/src/sync.h index 84282f6..7392f7c 100644 --- a/src/sync.h +++ b/src/sync.h @@ -23,6 +23,9 @@ #ifndef _SYNC_H #define _SYNC_H +#ifdef HAVE_STDATOMIC_H +#include +#endif /* HAVE_STDATOMIC_H */ #include #define BARRIER_REACHED(a) !barrier_notreached((a)) @@ -36,7 +39,11 @@ typedef struct sync_barrier { pthread_mutexattr_t count_mtx_attr; pthread_mutex_t count_mutex; #endif /* HAVE_ATOMIC_H && HAVE_STDATOMIC_H */ +#ifdef HAVE_STDATOMIC_H + atomic_uint count; +#else volatile unsigned int count; +#endif /* HAVE_STDATOMIC_H */ volatile unsigned int limit; int group; int txn; From 63a84bd9467747fac8d8f4ba441442f204a5528e Mon Sep 17 00:00:00 2001 From: msvoelker Date: Wed, 28 May 2025 14:02:47 +0200 Subject: [PATCH 3/4] Add bblog option for TCP connect to be able to set the TCP_LOG socket option. (#66) --- src/generic.c | 9 +++++++++ src/parse.c | 12 ++++++++++++ src/workorder.h | 1 + 3 files changed, 22 insertions(+) diff --git a/src/generic.c b/src/generic.c index a0f731d..39dd60a 100644 --- a/src/generic.c +++ b/src/generic.c @@ -480,6 +480,15 @@ set_tcp_options(int fd, flowop_options_t *f) } #else uperf_warn("Configuring TCP stack not supported"); +#endif + } + if (f && f->bblog > 0) { +#ifdef TCP_LOG + if (setsockopt(fd, IPPROTO_TCP, TCP_LOG, &(f->bblog), sizeof (f->bblog)) < 0) { + ulog_warn("Cannot set TCP_LOG:"); + } +#else + uperf_warn("Configuring TCP black box logging not supported"); #endif } } diff --git a/src/parse.c b/src/parse.c index f5545d4..140f215 100644 --- a/src/parse.c +++ b/src/parse.c @@ -559,6 +559,18 @@ parse_option(char *option, flowop_t *flowop) strlcpy(flowop->options.cc, value, sizeof(flowop->options.cc)); } else if (strcasecmp(key, "stack") == 0) { strlcpy(flowop->options.stack, value, sizeof(flowop->options.stack)); + } else if (strcasecmp(key, "bblog") == 0) { + int res; + + res = string2int(value); + if (res >= 0) { + flowop->options.bblog = res; + } else { + snprintf(err, sizeof(err), + "Cannot understand bblog:%s", value); + add_error(err); + return (UPERF_FAILURE); + } } #ifdef HAVE_SCTP else if (strcasecmp(key, "sctp_rto_min") == 0) { diff --git a/src/workorder.h b/src/workorder.h index bda4841..fc37f64 100644 --- a/src/workorder.h +++ b/src/workorder.h @@ -59,6 +59,7 @@ struct flowop_options { uint64_t count; /* Flowop execute Count */ uint64_t poll_timeout; /* In nanoseconds */ uint32_t encaps_port; /* Port used for UDP encapsulation */ + uint32_t bblog; /* TCP black box logging */ uint32_t sctp_rto_min; /* Minimum SCTP RTO */ uint32_t sctp_rto_max; /* Maximum SCTP RTO */ uint32_t sctp_rto_initial; /* Initial SCTP RTO */ From 9ed32ca1c313bed525580cc1a8c6eb7772fbedaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20T=C3=BCxen?= Date: Tue, 5 Aug 2025 14:19:57 +0200 Subject: [PATCH 4/4] Fix function declaration (#68) --- src/hwcounter.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hwcounter.h b/src/hwcounter.h index 3b10c49..6c262ae 100644 --- a/src/hwcounter.h +++ b/src/hwcounter.h @@ -59,8 +59,8 @@ typedef struct { int init_status; }hwcounter_t; -int hwcounter_init(); -int hwcounter_fini(); +int hwcounter_init(void); +int hwcounter_fini(hwcounter_t *)); int hwcounter_validate_events(char *, char *); int hwcounter_finilwp(hwcounter_t *); int hwcounter_snap(hwcounter_t *, int);