diff options
author | Dmitry Safonov <dima@arista.com> | 2023-12-15 02:36:15 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-12-17 10:41:54 +0000 |
commit | cfbab37b3da094579b8f7492e4df8a8a4c8c41b0 (patch) | |
tree | 076f5ad47295c05ecb5ad74d5ad482e09d5e3c10 /tools/testing/selftests/net/tcp_ao/lib/utils.c | |
parent | 37a8997fc5a5a6ffc60b197d048a9351d1043efd (diff) |
selftests/net: Add TCP-AO library
Provide functions to create selftests dedicated to TCP-AO.
They can run in parallel, as they use temporary net namespaces.
They can be very specific to the feature being tested.
This will allow to create a lot of TCP-AO tests, without complicating
one binary with many --options and to create scenarios, that are
hard to put in bash script that uses one binary.
Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing/selftests/net/tcp_ao/lib/utils.c')
-rw-r--r-- | tools/testing/selftests/net/tcp_ao/lib/utils.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/testing/selftests/net/tcp_ao/lib/utils.c b/tools/testing/selftests/net/tcp_ao/lib/utils.c new file mode 100644 index 000000000000..372daca525f5 --- /dev/null +++ b/tools/testing/selftests/net/tcp_ao/lib/utils.c @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "aolib.h" +#include <string.h> + +void randomize_buffer(void *buf, size_t buflen) +{ + int *p = (int *)buf; + size_t words = buflen / sizeof(int); + size_t leftover = buflen % sizeof(int); + + if (!buflen) + return; + + while (words--) + *p++ = rand(); + + if (leftover) { + int tmp = rand(); + + memcpy(buf + buflen - leftover, &tmp, leftover); + } +} + +const struct sockaddr_in6 addr_any6 = { + .sin6_family = AF_INET6, +}; + +const struct sockaddr_in addr_any4 = { + .sin_family = AF_INET, +}; |