Skip to content

Commit

Permalink
[links] extend knet_link_set_ping_timers ABI to be ready for future e…
Browse files Browse the repository at this point in the history
…xpansion

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
  • Loading branch information
fabbione committed Nov 24, 2017
1 parent d6fa6f9 commit f641ba8
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 66 deletions.
6 changes: 6 additions & 0 deletions libknet/libknet.h
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,12 @@ int knet_link_get_enable(knet_handle_t knet_h, knet_node_id_t host_id, uint8_t l
*
* timeout - if no pong is received within this time,
* the link is declared dead, in milliseconds.
* NOTE: in future it will be possible to set timeout to 0
* for an autocalculated timeout based on interval, pong_count
* and latency. The API already accept 0 as value and it will
* return ENOSYS / -1. Once the automatic calculation feature
* will be implemented, this call will only return EINVAL
* for incorrect values.
*
* precision - how many values of latency are used to calculate
* the average link latency (see also knet_link_get_status(3))
Expand Down
2 changes: 1 addition & 1 deletion libknet/links.c
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ int knet_link_set_ping_timers(knet_handle_t knet_h, knet_node_id_t host_id, uint
}

if (!timeout) {
errno = EINVAL;
errno = ENOSYS;
return -1;
}

Expand Down
2 changes: 1 addition & 1 deletion libknet/man/knet_link_set_ping_timers.3
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ link_id - see knet_link_set_config(3)
.PP
interval - specify the ping interval in milliseconds.
.PP
timeout - if no pong is received within this time, the link is declared dead, in milliseconds.
timeout - if no pong is received within this time, the link is declared dead, in milliseconds. NOTE: in future it will be possible to set timeout to 0 for an autocalculated timeout based on interval, pong_count and latency. The API already accept 0 as value and it will return ENOSYS / -1. Once the automatic calculation feature will be implemented, this call will only return EINVAL for incorrect values.
.PP
precision - how many values of latency are used to calculate the average link latency (see also knet_link_get_status(3))
.SH RETURN VALUE
Expand Down
124 changes: 62 additions & 62 deletions libknet/man/libknet.h.3
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,23 @@ int knet_strtoaddr(const char *, const char *, struct sockaddr_storage
.RS
.nf
\fB
struct knet_handle_crypto_cfg {
char \fIcrypto_model\fP;
char \fIcrypto_cipher_type\fP;
char \fIcrypto_hash_type\fP;
unsigned char \fIprivate_key\fP;
unsigned int \fIprivate_key_len\fP;
};
\fP
.fi
.RE
.SS ""
.PP
.sp
.sp
.RS
.nf
\fB
struct knet_transport_info {
const char *\fIname\fP;
uint8_t \fIid\fP;
Expand All @@ -99,6 +116,21 @@ struct knet_transport_info {
.RS
.nf
\fB
struct knet_crypto_info {
const char *\fIname\fP;
uint8_t \fIproperties\fP;
char \fIpad\fP;
};
\fP
.fi
.RE
.SS ""
.PP
.sp
.sp
.RS
.nf
\fB
struct knet_handle_compress_cfg {
char \fIcompress_model\fP;
uint32_t \fIcompress_threshold\fP;
Expand All @@ -114,6 +146,36 @@ struct knet_handle_compress_cfg {
.RS
.nf
\fB
struct knet_compress_info {
const char *\fIname\fP;
uint8_t \fIproperties\fP;
char \fIpad\fP;
};
\fP
.fi
.RE
.SS ""
.PP
.sp
.sp
.RS
.nf
\fB
struct knet_host_status {
uint8_t \fIreachable\fP;
uint8_t \fIremote\fP;
uint8_t \fIexternal\fP;
};
\fP
.fi
.RE
.SS ""
.PP
.sp
.sp
.RS
.nf
\fB
struct knet_link_status {
size_t \fIsize\fP;
char \fIsrc_ipaddr\fP;
Expand All @@ -139,21 +201,6 @@ struct knet_link_status {
.RS
.nf
\fB
struct knet_crypto_info {
const char *\fIname\fP;
uint8_t \fIproperties\fP;
char \fIpad\fP;
};
\fP
.fi
.RE
.SS ""
.PP
.sp
.sp
.RS
.nf
\fB
struct knet_handle_stats {
size_t \fIsize\fP;
uint64_t \fItx_uncompressed_packets\fP;
Expand Down Expand Up @@ -182,53 +229,6 @@ struct knet_handle_stats {
\fP
.fi
.RE
.SS ""
.PP
.sp
.sp
.RS
.nf
\fB
struct knet_handle_crypto_cfg {
char \fIcrypto_model\fP;
char \fIcrypto_cipher_type\fP;
char \fIcrypto_hash_type\fP;
unsigned char \fIprivate_key\fP;
unsigned int \fIprivate_key_len\fP;
};
\fP
.fi
.RE
.SS ""
.PP
.sp
.sp
.RS
.nf
\fB
struct knet_host_status {
uint8_t \fIreachable\fP;
uint8_t \fIremote\fP;
uint8_t \fIexternal\fP;
};
\fP
.fi
.RE
.SS ""
.PP
.sp
.sp
.RS
.nf
\fB
struct knet_compress_info {
const char *\fIname\fP;
uint8_t \fIproperties\fP;
char \fIpad\fP;
};
\fP
.fi
.RE
.SH SEE ALSO
.PP
.nh
Expand Down
4 changes: 2 additions & 2 deletions libknet/tests/api_knet_link_set_ping_timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ static void test(void)

flush_logs(logfds[0], stdout);

printf("Test knet_link_set_ping_timers with incorrect timeout\n");
printf("Test knet_link_set_ping_timers with 0 timeout\n");

if ((!knet_link_set_ping_timers(knet_h, 1, 0, 1000, 0, 2048)) || (errno != EINVAL)) {
if ((!knet_link_set_ping_timers(knet_h, 1, 0, 1000, 0, 2048)) || (errno != ENOSYS)) {
printf("knet_link_set_ping_timers accepted invalid timeout or returned incorrect error: %s\n", strerror(errno));
knet_host_remove(knet_h, 1);
knet_handle_free(knet_h);
Expand Down

0 comments on commit f641ba8

Please sign in to comment.