diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c770ba..5f9c4b4 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,7 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_VERBOSE_MAKEFILE TRUE) set(CMAKE_CXX_EXTENSIONS FALSE) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) if(DEFINED CONAN_DEPS) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) diff --git a/bpf_program/probes/connections.h b/bpf_program/probes/connections.h index f0c4939..e1f7af2 100644 --- a/bpf_program/probes/connections.h +++ b/bpf_program/probes/connections.h @@ -47,7 +47,7 @@ int kretprobe__tcp_v4_connect(struct pt_regs *ctx) } status = bpf_map_lookup_elem(&nettracer_status, &zero); - if (status == NULL || status->state != GUESS_STATE_READY) { + if (status == NULL) { return 0; } @@ -151,7 +151,7 @@ int kretprobe__inet_csk_accept(struct pt_regs *ctx) return 0; status = bpf_map_lookup_elem(&nettracer_status, &zero); - if (status == NULL || status->state != GUESS_STATE_READY) { + if (status == NULL) { return 0; } @@ -219,7 +219,7 @@ int kprobe__tcp_close(struct pt_regs *ctx) sk = (struct sock *) PT_REGS_PARM1(ctx); status = bpf_map_lookup_elem(&nettracer_status, &zero); - if (status == NULL || status->state != GUESS_STATE_READY) { + if (status == NULL) { return 0; } diff --git a/bpf_program/probes/metrics.h b/bpf_program/probes/metrics.h index f8d8215..d3f1b0b 100644 --- a/bpf_program/probes/metrics.h +++ b/bpf_program/probes/metrics.h @@ -19,7 +19,7 @@ static int send_metric(struct sock* sk, int32_t bytes_sent) { struct guess_status_t* status; uint32_t zero = 0; status = bpf_map_lookup_elem(&nettracer_status, &zero); - if (status == NULL || status->state != GUESS_STATE_READY) { + if (status == NULL) { return 0; } @@ -96,7 +96,7 @@ int kprobe__tcp_cleanup_rbuf(struct pt_regs* ctx) { struct guess_status_t *status; uint32_t zero = 0; status = bpf_map_lookup_elem(&nettracer_status, &zero); - if (status == NULL || status->state != GUESS_STATE_READY) { + if (status == NULL) { return 0; } @@ -137,7 +137,7 @@ int kprobe__tcp_retransmit_skb(struct pt_regs* ctx) { struct guess_status_t *status; uint32_t zero = 0; status = bpf_map_lookup_elem(&nettracer_status, &zero); - if (status == NULL || status->state != GUESS_STATE_READY) { + if (status == NULL) { return 0; } diff --git a/bpf_program/tuples_utilities.h b/bpf_program/tuples_utilities.h index d0efa27..30146c0 100644 --- a/bpf_program/tuples_utilities.h +++ b/bpf_program/tuples_utilities.h @@ -21,7 +21,7 @@ static bool check_family(struct sock *sk, uint16_t expected_family) { family = 0; status = bpf_map_lookup_elem(&nettracer_status, &zero); - if (status == NULL || status->state != GUESS_STATE_READY) { + if (status == NULL) { return 0; } diff --git a/libnettracer/src/offsetguess.cpp b/libnettracer/src/offsetguess.cpp index 4690178..56f2a9c 100644 --- a/libnettracer/src/offsetguess.cpp +++ b/libnettracer/src/offsetguess.cpp @@ -64,7 +64,7 @@ bool OffsetGuessing::makeGuessingAttempt(int status_fd) { // which in turn are called in kretprobe tcp_v(4|6)_connect uint64_t pid_tgid = (uint64_t)getpid() << 32 | syscall(SYS_gettid); - logger->debug("guess thread pid: {:d}", pid_tgid); + logger->trace("guess thread pid: {:d}", pid_tgid); // prepare server ipv4 and client ipv6 on this thread localsock = startLocalSock(); @@ -107,7 +107,6 @@ bool OffsetGuessing::makeGuessingAttempt(int status_fd) { // limit how many failed attempts at communicating with the BPF side are accepted int maxRetries = 100; - unsigned rttCurrentAttempts = 0; unsigned rttCurrentReps = 0; @@ -208,13 +207,14 @@ bool OffsetGuessing::makeGuessingAttempt(int status_fd) { return false; } } + logger->debug("offsets status: {:d}", status.what); return true; } template void OffsetGuessing::guessSimpleField(T& statusValue, const T& expectedValue, uint16_t& offset, guess_status_t& status, const std::string& fieldStr, const guess_field& next) { if (statusValue == expectedValue) { - logger->debug("{} offset: {:#010x}", fieldStr, offset); + logger->info("{} offset: {:#010x}", fieldStr, offset); status.what = next; } else { @@ -226,7 +226,7 @@ void OffsetGuessing::guessSimpleField(T& statusValue, const T& expectedValue, ui void OffsetGuessing::guessNetns() { if (status.netns == expected.netns) { - logger->debug("Network namespace offset: {:#010x}", status.offset_netns); + logger->info("Network namespace offset: {:#010x}", status.offset_netns); status.what = GUESS_FIELD_DADDR_IPV6; } else { ++status.offset_ino; @@ -264,10 +264,10 @@ bool OffsetGuessing::guessRTT(unsigned& currentAttempts, unsigned& currentReps, const unsigned maxAttempts = 10; // that many offsets may be verified const unsigned requiredReps = 3; // value at an offset must match with the expected value at least that many times in a row - if (status.rtt == expected.rtt && status.rtt_var == expected.rtt_var) { + if (status.rtt == expected.rtt) { if (++currentReps == requiredReps) { - logger->debug("RTT offset: {:#010x}", status.offset_rtt); - logger->debug("RTT var offset: {:#010x}", status.offset_rtt_var); + logger->info("RTT offset: {:#010x}", status.offset_rtt); + logger->info("RTT var offset: {:#010x}", status.offset_rtt_var); status.state = GUESS_STATE_READY; } else { // reload expected RTT @@ -275,17 +275,12 @@ bool OffsetGuessing::guessRTT(unsigned& currentAttempts, unsigned& currentReps, logger->error("Couldn't restart client for RTT guessing"); return false; } - try { - auto expectedOpt{getExpectedValues(skipIPv6)}; - if (!expectedOpt) { - return false; - } - expected = *expectedOpt; - } - catch (const std::runtime_error& ex) { - logger->error(ex.what()); + auto expectedOpt{getExpectedValues(skipIPv6)}; + if (!expectedOpt) { return false; } + logger->debug("Updating expected RTT: {:d},{:d} -> {:d},{:d} ", expected.rtt, expected.rtt_var, expectedOpt->rtt, expectedOpt->rtt_var); + expected = *expectedOpt; status.rtt = expected.rtt; status.rtt_var = expected.rtt_var; status.state = GUESS_STATE_CHECKING; @@ -307,6 +302,7 @@ bool OffsetGuessing::guessRTT(unsigned& currentAttempts, unsigned& currentReps, status.rtt = expected.rtt; status.rtt_var = expected.rtt_var; status.state = GUESS_STATE_CHECKING; + logger->trace("current RTT offset: {:d}", status.offset_rtt); } return true; } diff --git a/version.properties b/version.properties index 4d3251e..68a38bd 100644 --- a/version.properties +++ b/version.properties @@ -1 +1 @@ -version=1.1.10 +version=1.1.11