Update the existing sockopt test-case to do some some
basic checks on the newly added counters.
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
.../selftests/net/mptcp/mptcp_sockopt.c | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
index ae61f39556ca..0c58de3ef339 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
@@ -51,6 +51,11 @@ struct mptcp_info {
__u8 mptcpi_local_addr_used;
__u8 mptcpi_local_addr_max;
__u8 mptcpi_csum_enabled;
+ __u32 mptcpi_retransmits;
+ __u64 mptcpi_bytes_retrans;
+ __u64 mptcpi_bytes_sent;
+ __u64 mptcpi_bytes_received;
+ __u64 mptcpi_bytes_acked;
};
struct mptcp_subflow_data {
@@ -83,6 +88,7 @@ struct mptcp_subflow_addrs {
struct so_state {
struct mptcp_info mi;
+ struct mptcp_info last_sample;
uint64_t mptcpi_rcv_delta;
uint64_t tcpi_rcv_delta;
};
@@ -320,6 +326,7 @@ static void do_getsockopt_mptcp_info(struct so_state *s, int fd, size_t w)
assert(olen == sizeof(i));
+ s->last_sample = i;
if (s->mi.mptcpi_write_seq == 0)
s->mi = i;
@@ -556,6 +563,19 @@ static void process_one_client(int fd, int pipefd)
do_getsockopts(&s, fd, ret, ret2);
if (s.mptcpi_rcv_delta != (uint64_t)ret + 1)
xerror("mptcpi_rcv_delta %" PRIu64 ", expect %" PRIu64, s.mptcpi_rcv_delta, ret + 1, s.mptcpi_rcv_delta - ret);
+ if (s.last_sample.mptcpi_bytes_sent != ret2)
+ xerror("mptcpi_bytes_sent %" PRIu64 ", expect %" PRIu64,
+ s.last_sample.mptcpi_bytes_sent, ret2,
+ s.last_sample.mptcpi_bytes_sent - ret2);
+ if (s.last_sample.mptcpi_bytes_received != ret)
+ xerror("mptcpi_bytes_received %" PRIu64 ", expect %" PRIu64,
+ s.last_sample.mptcpi_bytes_received, ret,
+ s.last_sample.mptcpi_bytes_received - ret);
+ if (s.last_sample.mptcpi_bytes_acked != ret)
+ xerror("mptcpi_bytes_acked %" PRIu64 ", expect %" PRIu64,
+ s.last_sample.mptcpi_bytes_acked, ret2,
+ s.last_sample.mptcpi_bytes_acked - ret2);
+
close(fd);
}
--
2.40.0
Hi Paolo, On 04/05/2023 18:40, Paolo Abeni wrote: > Update the existing sockopt test-case to do some some > basic checks on the newly added counters. > > Signed-off-by: Paolo Abeni <pabeni@redhat.com> > --- > .../selftests/net/mptcp/mptcp_sockopt.c | 20 +++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c > index ae61f39556ca..0c58de3ef339 100644 > --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c > +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c > @@ -51,6 +51,11 @@ struct mptcp_info { > __u8 mptcpi_local_addr_used; > __u8 mptcpi_local_addr_max; > __u8 mptcpi_csum_enabled; > + __u32 mptcpi_retransmits; > + __u64 mptcpi_bytes_retrans; > + __u64 mptcpi_bytes_sent; > + __u64 mptcpi_bytes_received; > + __u64 mptcpi_bytes_acked; > }; > > struct mptcp_subflow_data { > @@ -83,6 +88,7 @@ struct mptcp_subflow_addrs { > > struct so_state { > struct mptcp_info mi; > + struct mptcp_info last_sample; > uint64_t mptcpi_rcv_delta; > uint64_t tcpi_rcv_delta; > }; > @@ -320,6 +326,7 @@ static void do_getsockopt_mptcp_info(struct so_state *s, int fd, size_t w) > > assert(olen == sizeof(i)); > > + s->last_sample = i; > if (s->mi.mptcpi_write_seq == 0) > s->mi = i; > > @@ -556,6 +563,19 @@ static void process_one_client(int fd, int pipefd) > do_getsockopts(&s, fd, ret, ret2); > if (s.mptcpi_rcv_delta != (uint64_t)ret + 1) > xerror("mptcpi_rcv_delta %" PRIu64 ", expect %" PRIu64, s.mptcpi_rcv_delta, ret + 1, s.mptcpi_rcv_delta - ret); To support old kernels, I guess the best is to store the "length" of the getsockopt(MPTCP_INFO) and only check these new following conditions if the "length" received from the kernel is bigger than a certain size (by looking at the offset of the mptcpi_retransmits field in the mptcp_info structure I suppose)? > + if (s.last_sample.mptcpi_bytes_sent != ret2) > + xerror("mptcpi_bytes_sent %" PRIu64 ", expect %" PRIu64, > + s.last_sample.mptcpi_bytes_sent, ret2, > + s.last_sample.mptcpi_bytes_sent - ret2); > + if (s.last_sample.mptcpi_bytes_received != ret) > + xerror("mptcpi_bytes_received %" PRIu64 ", expect %" PRIu64, > + s.last_sample.mptcpi_bytes_received, ret, > + s.last_sample.mptcpi_bytes_received - ret); > + if (s.last_sample.mptcpi_bytes_acked != ret) > + xerror("mptcpi_bytes_acked %" PRIu64 ", expect %" PRIu64, > + s.last_sample.mptcpi_bytes_acked, ret2, > + s.last_sample.mptcpi_bytes_acked - ret2); > + Cheers, Matt -- Tessares | Belgium | Hybrid Access Solutions www.tessares.net
© 2016 - 2024 Red Hat, Inc.