Skip to content

Commit

Permalink
stats: Only collect crypt over stats for received data packets
Browse files Browse the repository at this point in the history
This is more for consistency really. The TX code only accumulates the
crypto overhead for data packets because it's not worth adding all the
accounting code around the ping/pong & pmtu transmitters.
  • Loading branch information
chrissie-c committed Nov 23, 2017
1 parent 9d83f0b commit eb79dbe
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions libknet/threads_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ static void _parse_recv_from_links(knet_handle_t knet_h, int sockfd, const struc
knet_node_id_t dst_host_ids[KNET_MAX_HOST];
size_t dst_host_ids_entries = 0;
int bcast = 1;
int was_decrypted = 0;
uint64_t crypt_time = 0;
struct timespec recvtime;
struct knet_header *inbuf = msg->msg_hdr.msg_iov->iov_base;
unsigned char *outbuf = (unsigned char *)msg->msg_hdr.msg_iov->iov_base;
Expand All @@ -250,7 +252,7 @@ static void _parse_recv_from_links(knet_handle_t knet_h, int sockfd, const struc
if (knet_h->crypto_instance) {
struct timespec start_time;
struct timespec end_time;
uint64_t crypt_time;


clock_gettime(CLOCK_MONOTONIC, &start_time);
if (crypto_authenticate_and_decrypt(knet_h,
Expand All @@ -270,13 +272,10 @@ static void _parse_recv_from_links(knet_handle_t knet_h, int sockfd, const struc
if (crypt_time > knet_h->stats.rx_crypt_time_max) {
knet_h->stats.rx_crypt_time_max = crypt_time;
}
knet_h->stats.rx_crypt_time_ave =
(knet_h->stats.rx_crypt_time_ave * knet_h->stats.rx_crypt_packets +
crypt_time) / (knet_h->stats.rx_crypt_packets+1);
knet_h->stats.rx_crypt_packets++;

len = outlen;
inbuf = (struct knet_header *)knet_h->recv_from_links_buf_decrypt;
was_decrypted++;
}

if (len < (ssize_t)(KNET_HEADER_SIZE + 1)) {
Expand Down Expand Up @@ -420,6 +419,13 @@ static void _parse_recv_from_links(knet_handle_t knet_h, int sockfd, const struc
if (knet_h->enabled != 1) /* data forward is disabled */
break;

/* Only update the crypto overhead for data packets. Mainly to be
consistent with TX */
knet_h->stats.rx_crypt_time_ave =
(knet_h->stats.rx_crypt_time_ave * knet_h->stats.rx_crypt_packets +
crypt_time) / (knet_h->stats.rx_crypt_packets+1);
knet_h->stats.rx_crypt_packets++;

if (knet_h->dst_host_filter_fn) {
size_t host_idx;
int found = 0;
Expand Down

0 comments on commit eb79dbe

Please sign in to comment.