[SCM] Samba Shared Repository - branch master updated
Volker Lendecke
vlendec at samba.org
Thu Jan 13 17:03:01 UTC 2022
The branch, master has been updated
via 7163846a491 ctdb-protocol: Print IPv6 sockets with RFC5952 "[2001:db8::1]:80" notation
via 255fe69c90f ctdb-tests: Add extra IPv6 socket parsing tests
via 224e99804ef ctdb-protocol: Allow rfc5952 "[2001:db8::1]:80" ipv6 notation
via 820b0a63cca ctdb-protocol: Save 50 bytes .text segment
via baaedd69b3e ctdb-protocol: rindex->strrchr
from 8c0391d38e5 dsdb/schema: let dsdb_syntax_DN_BINARY_drsuapi_to_ldb return WERR_DS_INVALID_ATTRIBUTE_SYNTAX
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 7163846a49165cc3d70b2b20909af2ed19778e7a
Author: Martin Schwenke <martin at meltin.net>
Date: Thu Dec 30 12:29:58 2021 +1100
ctdb-protocol: Print IPv6 sockets with RFC5952 "[2001:db8::1]:80" notation
RFC5952 says the existing style is not recommended and the [] style
should be employed.
There are more optimised ways of adding the square brackets but they
tend to be uglier.
Parsing IPv6 sockets without [] is now tested indirectly by parsing
examples in both styles and comparing the results.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Signed-off-by: Volker Lendecke <vl at samba.org>
Autobuild-User(master): Volker Lendecke <vl at samba.org>
Autobuild-Date(master): Thu Jan 13 17:02:21 UTC 2022 on sn-devel-184
commit 255fe69c90fb0d437d26ce0a6966841b3663aa05
Author: Martin Schwenke <martin at meltin.net>
Date: Wed Jan 5 12:09:45 2022 +1100
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 <martin at meltin.net>
Reviewed-by: Volker Lendecke <vl at samba.org>
commit 224e99804efef960ef4ce2ff2f4f6dced1e74146
Author: Volker Lendecke <vl at samba.org>
Date: Thu Dec 23 11:52:38 2021 +0100
ctdb-protocol: Allow rfc5952 "[2001:db8::1]:80" ipv6 notation
Bug: https://bugzilla.samba.org/show_bug.cgi?id=14934
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 820b0a63ccaceb4d66b18e3bcd585400a0b99ed2
Author: Volker Lendecke <vl at samba.org>
Date: Wed Dec 29 14:46:14 2021 +0100
ctdb-protocol: Save 50 bytes .text segment
Having this as a small static .text is simpler than having to create
this on the stack.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit baaedd69b3e02cdef06353bd5a21a5c5e6079604
Author: Volker Lendecke <vl at samba.org>
Date: Wed Dec 29 15:10:28 2021 +0100
ctdb-protocol: rindex->strrchr
According to "man rindex" on debian bullseye rindex() was deprecated
in Posix.1-2001 and removed from Posix.1-2008.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Martin Schwenke <martin at meltin.net>
-----------------------------------------------------------------------
Summary of changes:
ctdb/protocol/protocol_util.c | 52 ++++++++++++++++++++-----
ctdb/tests/UNIT/cunit/system_socket_test_002.sh | 10 +++--
ctdb/tests/src/protocol_util_test.c | 49 ++++++++++++++++-------
3 files changed, 83 insertions(+), 28 deletions(-)
Changeset truncated at 500 lines:
diff --git a/ctdb/protocol/protocol_util.c b/ctdb/protocol/protocol_util.c
index 2d0a6f33038..28631c8de61 100644
--- a/ctdb/protocol/protocol_util.c
+++ b/ctdb/protocol/protocol_util.c
@@ -119,6 +119,7 @@ int ctdb_sock_addr_to_buf(char *buf, socklen_t buflen,
ctdb_sock_addr *addr, bool with_port)
{
const char *t;
+ size_t len = 0;
switch (addr->sa.sa_family) {
case AF_INET:
@@ -127,15 +128,36 @@ int ctdb_sock_addr_to_buf(char *buf, socklen_t buflen,
if (t == NULL) {
return errno;
}
+ if (with_port) {
+ len = strlen(buf);
+ }
break;
- case AF_INET6:
- t = inet_ntop(addr->ip6.sin6_family, &addr->ip6.sin6_addr,
- buf, buflen);
+ case AF_INET6: {
+ char tmp[INET6_ADDRSTRLEN];
+
+ t = inet_ntop(addr->ip6.sin6_family,
+ &addr->ip6.sin6_addr,
+ tmp,
+ sizeof(tmp));
if (t == NULL) {
return errno;
}
+
+ if (with_port) {
+ int ret = snprintf(buf, buflen, "[%s]", tmp);
+ if (ret < 0) {
+ return ENOSPC;
+ }
+ len = (size_t)ret;
+ } else {
+ len = strlcpy(buf, tmp, buflen);
+ }
+ if (len >= buflen){
+ return ENOSPC;
+ }
break;
+ }
default:
return EAFNOSUPPORT;
@@ -143,7 +165,6 @@ int ctdb_sock_addr_to_buf(char *buf, socklen_t buflen,
}
if (with_port) {
- size_t len = strlen(buf);
int ret;
ret = snprintf(buf+len, buflen-len,
@@ -230,16 +251,29 @@ static int ip_from_string(const char *str, ctdb_sock_addr *addr)
/* IPv4 or IPv6 address?
*
- * Use rindex() because we need the right-most ':' below for
+ * Use strrchr() because we need the right-most ':' below for
* IPv4-mapped IPv6 addresses anyway...
*/
- p = rindex(str, ':');
+ p = strrchr(str, ':');
if (p == NULL) {
ret = ipv4_from_string(str, &addr->ip);
} else {
- uint8_t ipv4_mapped_prefix[12] = {
+ static const uint8_t ipv4_mapped_prefix[12] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff
};
+ size_t len = strlen(str);
+ char s[64];
+
+ len = strlcpy(s, str, sizeof(s));
+ if (len >= sizeof(s)) {
+ return EINVAL;
+ }
+
+ if ((len >= 2) && (s[0] == '[') && (s[len-1] == ']')) {
+ s[len-1] = '\0';
+ str = s+1;
+ p = strrchr(str, ':');
+ }
ret = ipv6_from_string(str, &addr->ip6);
if (ret != 0) {
@@ -286,7 +320,7 @@ int ctdb_sock_addr_from_string(const char *str,
return EINVAL;
}
- p = rindex(s, ':');
+ p = strrchr(s, ':');
if (p == NULL) {
return EINVAL;
}
@@ -324,7 +358,7 @@ int ctdb_sock_addr_mask_from_string(const char *str,
return EINVAL;
}
- p = rindex(s, '/');
+ p = strrchr(s, '/');
if (p == NULL) {
return EINVAL;
}
diff --git a/ctdb/tests/UNIT/cunit/system_socket_test_002.sh b/ctdb/tests/UNIT/cunit/system_socket_test_002.sh
index 8bea074bd8d..417ad8f4792 100755
--- a/ctdb/tests/UNIT/cunit/system_socket_test_002.sh
+++ b/ctdb/tests/UNIT/cunit/system_socket_test_002.sh
@@ -38,7 +38,8 @@ ok <<EOF
000030 00 00 00 00 50 10 04 d2 0f c0 00 00
00003c
EOF
-tcp_test "fe80::6af7:28ff:fefa:d136:445" "fe80::6af7:28ff:fefb:d137:54321" 0 0 0
+tcp_test "[fe80::6af7:28ff:fefa:d136]:445" \
+ "[fe80::6af7:28ff:fefb:d137]:54321" 0 0 0
ok <<EOF
000000 60 00 00 00 00 14 06 40 fe 80 00 00 00 00 00 00
@@ -47,7 +48,8 @@ ok <<EOF
000030 00 00 00 00 50 14 04 d2 0f bc 00 00
00003c
EOF
-tcp_test "fe80::6af7:28ff:fefa:d136:445" "fe80::6af7:28ff:fefb:d137:54321" 0 0 1
+tcp_test "[fe80::6af7:28ff:fefa:d136]:445" \
+ "[fe80::6af7:28ff:fefb:d137]:54321" 0 0 1
ok <<EOF
000000 60 00 00 00 00 14 06 40 fe 80 00 00 00 00 00 00
@@ -56,5 +58,5 @@ ok <<EOF
000030 a0 5b 00 00 50 14 04 d2 36 30 00 00
00003c
EOF
-tcp_test "fe80::6af7:28ff:fefa:d136:445" \
- "fe80::6af7:28ff:fefb:d137:54321" 12345 23456 1
+tcp_test "[fe80::6af7:28ff:fefa:d136]:445" \
+ "[fe80::6af7:28ff:fefb:d137]:54321" 12345 23456 1
diff --git a/ctdb/tests/src/protocol_util_test.c b/ctdb/tests/src/protocol_util_test.c
index edd2a3411a0..4ffe58c680c 100644
--- a/ctdb/tests/src/protocol_util_test.c
+++ b/ctdb/tests/src/protocol_util_test.c
@@ -307,20 +307,20 @@ static void test_connection_list_read_bad(const char *s1)
#define CONN6 \
"\
-fe80::6af7:28ff:fefa:d136:12345 fe80::6af7:28ff:fefa:d137:54321\n\
-fe80::6af7:28ff:fefa:d138:12345 fe80::6af7:28ff:fefa:d137:54322\n\
-fe80::6af7:28ff:fefa:d136:12346 fe80::6af7:28ff:fefa:d137:54323\n\
-fe80::6af7:28ff:fefa:d132:12345 fe80::6af7:28ff:fefa:d137:54324\n\
-fe80::6af7:28ff:fefa:d136:12345 fe80::6af7:28ff:fefa:d137:54325\n\
+[fe80::6af7:28ff:fefa:d136]:12345 [fe80::6af7:28ff:fefa:d137]:54321\n\
+[fe80::6af7:28ff:fefa:d138]:12345 [fe80::6af7:28ff:fefa:d137]:54322\n\
+[fe80::6af7:28ff:fefa:d136]:12346 [fe80::6af7:28ff:fefa:d137]:54323\n\
+[fe80::6af7:28ff:fefa:d132]:12345 [fe80::6af7:28ff:fefa:d137]:54324\n\
+[fe80::6af7:28ff:fefa:d136]:12345 [fe80::6af7:28ff:fefa:d137]:54325\n\
"
#define CONN6_SORT \
"\
-fe80::6af7:28ff:fefa:d132:12345 fe80::6af7:28ff:fefa:d137:54324\n\
-fe80::6af7:28ff:fefa:d136:12345 fe80::6af7:28ff:fefa:d137:54321\n\
-fe80::6af7:28ff:fefa:d136:12345 fe80::6af7:28ff:fefa:d137:54325\n\
-fe80::6af7:28ff:fefa:d136:12346 fe80::6af7:28ff:fefa:d137:54323\n\
-fe80::6af7:28ff:fefa:d138:12345 fe80::6af7:28ff:fefa:d137:54322\n\
+[fe80::6af7:28ff:fefa:d132]:12345 [fe80::6af7:28ff:fefa:d137]:54324\n\
+[fe80::6af7:28ff:fefa:d136]:12345 [fe80::6af7:28ff:fefa:d137]:54321\n\
+[fe80::6af7:28ff:fefa:d136]:12345 [fe80::6af7:28ff:fefa:d137]:54325\n\
+[fe80::6af7:28ff:fefa:d136]:12346 [fe80::6af7:28ff:fefa:d137]:54323\n\
+[fe80::6af7:28ff:fefa:d138]:12345 [fe80::6af7:28ff:fefa:d137]:54322\n\
"
int main(int argc, char *argv[])
@@ -333,9 +333,9 @@ int main(int argc, char *argv[])
test_sock_addr_to_string("0.0.0.0:0", true);
test_sock_addr_to_string("127.0.0.1:123", true);
- test_sock_addr_to_string("::1:234", true);
+ test_sock_addr_to_string("[::1]:234", true);
test_sock_addr_to_string("192.168.2.1:123", true);
- test_sock_addr_to_string("fe80::6af7:28ff:fefa:d136:234", true);
+ test_sock_addr_to_string("[fe80::6af7:28ff:fefa:d136]:234", true);
test_sock_addr_from_string_bad("0.0.0", false);
test_sock_addr_from_string_bad("0.0.0:0", true);
@@ -367,19 +367,38 @@ 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");
test_sock_addr_mask_from_string_bad("127.0.0.1");
test_connection_to_string("127.0.0.1:12345 127.0.0.2:54321");
- test_connection_to_string("fe80::6af7:28ff:fefa:d137:12345 "
- "fe80::6af7:28ff:fefa:d138:54321");
+ test_connection_to_string("[fe80::6af7:28ff:fefa:d137]:12345 "
+ "[fe80::6af7:28ff:fefa:d138]:54321");
test_connection_from_string_bad("127.0.0.1:12345 127.0.0.2:");
test_connection_from_string_bad("127.0.0.1:12345");
test_connection_from_string_bad("127.0.0.1:12345 "
- "fe80::6af7:28ff:fefa:d136:122");
+ "[fe80::6af7:28ff:fefa:d136]:122");
test_connection_from_string_bad("Junk!");
test_connection_from_string_bad("More junk");
--
Samba Shared Repository
More information about the samba-cvs
mailing list