From 255fe69c90fb0d437d26ce0a6966841b3663aa05 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Wed, 5 Jan 2022 12:09:45 +1100 Subject: [PATCH] ctdb-tests: Add extra IPv6 socket parsing tests Add tests to confirm that square brackets are handled and that IPv4-mapped IPv6 addresses are parsed as expected. Signed-off-by: Martin Schwenke Reviewed-by: Volker Lendecke --- ctdb/tests/src/protocol_util_test.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ctdb/tests/src/protocol_util_test.c b/ctdb/tests/src/protocol_util_test.c index edd2a3411a0..841d290cb3f 100644 --- a/ctdb/tests/src/protocol_util_test.c +++ b/ctdb/tests/src/protocol_util_test.c @@ -367,6 +367,25 @@ int main(int argc, char *argv[]) test_sock_addr_cmp("fe80::6af7:28ff:fefa:d136:123", "fe80::6af7:28ff:fefa:d136:122" , true, 1); + /* + * Confirm equivalence of IPv6 sockets with and without + * square-brackets + */ + test_sock_addr_cmp("[::1]:234", "::1:234", true, 0); + test_sock_addr_cmp("[fe80::6af7:28ff:fefa:d136]:234", + "fe80::6af7:28ff:fefa:d136:234", + true, + 0); + /* Check IPv4-mapped IPv6 addresses */ + test_sock_addr_cmp("::ffff:172.16.0.27:977", + "172.16.0.27:977", + true, + 0); + test_sock_addr_cmp("[::ffff:172.16.0.27]:977", + "172.16.0.27:977", + true, + 0); + test_sock_addr_mask_from_string("127.0.0.1/8"); test_sock_addr_mask_from_string("::1/128"); test_sock_addr_mask_from_string("fe80::6af7:28ff:fefa:d136/64");