[SCM] Samba Shared Repository - branch master updated

Martin Schwenke martins at samba.org
Wed Nov 25 12:22:02 UTC 2015


The branch, master has been updated
       via  1ee7053 ctdb-protocol: Fix marshalling for struct ctdb_rec_data
       via  8ded8e8 ctdb-protocol: Add API to extract ctdb_ltdb_header from TDB_DATA
       via  5f5b319 ctdb-protocol: Fix marshalling of struct ctdb_public_ip_list
       via  5498b71 ctdb-protocol: Fix marshalling of struct ctdb_addr_info
       via  5878177 ctdb-protocol: Do not expect a reply for SHUTDOWN control
       via  3fc6a89 ctdb-protocol: Add marshalling for TDB_DATA
       via  3d84399 ctdb-protocol: Add utility function ctdb_sock_addr_to_string
       via  af13e56 ctdb-system: Use protocol/protocol.h instead of ctdb_private.h
       via  2bad37d ctdb-include: Make client header self contained
       via  28fb899 ctdb-include: Make protocol headers self contained
      from  8024e19 s3: smbd: Tear down global_smbXsrv_client in the correct order.

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 1ee7053180057ea526870182b5619a206b4d103b
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Nov 6 17:07:35 2015 +1100

    ctdb-protocol: Fix marshalling for struct ctdb_rec_data
    
    If the header is specified, then the datalen should be incremented.
    
    There are two ways of marshalling ctdb_rec_data:
    
    1. ctdb_rec_data->header is NULL and ctdb_rec_data->data embeds both
       the header and the value. Used in recovery for push/pull of records.
    
    2. ctdb_rec_data->header is not NULL and ctdb_rec_data->data embeds
       only the value.  Used everywhere else.
    
    In both cases, the wire format includes the header and the value.
    There is nothing in the wire format to inform the unmarshalling code
    whether to extract the header separately or not.
    
    In the current code the header is extracted depending on whether the
    header argument to the extractor routine is NULL or not.  This is insane
    and highly error-prone.
    
    So in the new API, unmarshalling code never extracts the header.  If the
    caller requires the header, then it can be extracted separately using
    special function ctdb_ltdb_header_extract().
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Wed Nov 25 13:21:48 CET 2015 on sn-devel-104

commit 8ded8e81b0f0da8a3ea79d63d575b6493e4a87f3
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Nov 10 18:29:39 2015 +1100

    ctdb-protocol: Add API to extract ctdb_ltdb_header from TDB_DATA
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 5f5b3193a32dbbe2030f69a6a6c44a51af9901aa
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Nov 6 14:27:33 2015 +1100

    ctdb-protocol: Fix marshalling of struct ctdb_public_ip_list
    
    There can be 0 public addresses.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 5498b71b3d544fcc76cc69e476f4cd5cc45ae5cd
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Nov 6 13:06:26 2015 +1100

    ctdb-protocol: Fix marshalling of struct ctdb_addr_info
    
    ctdb_addr_info->iface can be NULL.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 587817774a2747c8494fcab3e7edf78dbcfa50ae
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Nov 5 17:08:46 2015 +1100

    ctdb-protocol: Do not expect a reply for SHUTDOWN control
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3fc6a895489a9990405f86b0c01dfb7dec8eb4ef
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Nov 9 15:58:56 2015 +1100

    ctdb-protocol: Add marshalling for TDB_DATA
    
    This is required when ctdb client wants to send arbitrary data as part
    of CTDB_REQ_MESSAGE.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3d84399f5ec12954db9638627fd1d747cc4acb71
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Nov 2 16:24:15 2015 +1100

    ctdb-protocol: Add utility function ctdb_sock_addr_to_string
    
    This is a duplicate function to ctdb_addr_to_str, but ctdb-util cannot
    be linked with the code using new API mainly because it code in ctdb-util
    requires struct ctdb_context.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit af13e56271d4352a28352a89b651d569afda2314
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Nov 2 16:03:29 2015 +1100

    ctdb-system: Use protocol/protocol.h instead of ctdb_private.h
    
    Since this code does not need any private structures defined in
    ctdb_private.h, protocol/protocol.h should suffice.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2bad37db9832baa6201eca737c84f7c0976449eb
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Nov 2 17:54:45 2015 +1100

    ctdb-include: Make client header self contained
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 28fb8993e0b2645449223aa1f40cf410063a6de6
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Nov 2 16:01:13 2015 +1100

    ctdb-include: Make protocol headers self contained
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 ctdb/client/client.h                 |   3 +
 ctdb/common/system_aix.c             |   2 +-
 ctdb/common/system_common.c          |   2 +-
 ctdb/common/system_freebsd.c         |   2 +-
 ctdb/common/system_gnu.c             |   2 +-
 ctdb/common/system_kfreebsd.c        |   2 +-
 ctdb/common/system_linux.c           |   2 +-
 ctdb/common/system_util.c            |   2 +-
 ctdb/protocol/protocol.h             |   4 ++
 ctdb/protocol/protocol_api.h         |   6 ++
 ctdb/protocol/protocol_client.c      |   2 +-
 ctdb/protocol/protocol_message.c     |  12 ++++
 ctdb/protocol/protocol_private.h     |   5 ++
 ctdb/protocol/protocol_types.c       | 104 +++++++++++++++++++++++++++--------
 ctdb/protocol/protocol_util.c        |  28 ++++++++++
 ctdb/tests/src/protocol_types_test.c |  21 +++++--
 16 files changed, 161 insertions(+), 38 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/client/client.h b/ctdb/client/client.h
index 3f720fc..3a16069 100644
--- a/ctdb/client/client.h
+++ b/ctdb/client/client.h
@@ -20,6 +20,9 @@
 #ifndef __CTDB_CLIENT_H__
 #define __CTDB_CLIENT_H__
 
+#include <talloc.h>
+#include <tevent.h>
+
 #include "protocol/protocol.h"
 #include "common/srvid.h"
 
diff --git a/ctdb/common/system_aix.c b/ctdb/common/system_aix.c
index a380f1c..d323e5c 100644
--- a/ctdb/common/system_aix.c
+++ b/ctdb/common/system_aix.c
@@ -26,7 +26,7 @@
 
 #include "lib/util/debug.h"
 
-#include "ctdb_private.h"
+#include "protocol/protocol.h"
 
 #include <netinet/if_ether.h>
 #include <netinet/ip6.h>
diff --git a/ctdb/common/system_common.c b/ctdb/common/system_common.c
index 9c8e983..e11bcb2 100644
--- a/ctdb/common/system_common.c
+++ b/ctdb/common/system_common.c
@@ -23,7 +23,7 @@
 
 #include "lib/util/debug.h"
 
-#include "ctdb_private.h"
+#include "protocol/protocol.h"
 
 #include "common/logging.h"
 #include "common/system.h"
diff --git a/ctdb/common/system_freebsd.c b/ctdb/common/system_freebsd.c
index 21a300b..e88e9e2 100644
--- a/ctdb/common/system_freebsd.c
+++ b/ctdb/common/system_freebsd.c
@@ -31,7 +31,7 @@
 
 #include "lib/util/debug.h"
 
-#include "ctdb_private.h"
+#include "protocol/protocol.h"
 
 #include <net/ethernet.h>
 #include <netinet/ip6.h>
diff --git a/ctdb/common/system_gnu.c b/ctdb/common/system_gnu.c
index aeed56c..1246205 100644
--- a/ctdb/common/system_gnu.c
+++ b/ctdb/common/system_gnu.c
@@ -30,7 +30,7 @@
 
 #include "lib/util/debug.h"
 
-#include "ctdb_private.h"
+#include "protocol/protocol.h"
 
 #include <net/ethernet.h>
 #include <netinet/ip6.h>
diff --git a/ctdb/common/system_kfreebsd.c b/ctdb/common/system_kfreebsd.c
index b241aa8..b030317 100644
--- a/ctdb/common/system_kfreebsd.c
+++ b/ctdb/common/system_kfreebsd.c
@@ -30,7 +30,7 @@
 
 #include "lib/util/debug.h"
 
-#include "ctdb_private.h"
+#include "protocol/protocol.h"
 
 #include <net/ethernet.h>
 #include <netinet/ip6.h>
diff --git a/ctdb/common/system_linux.c b/ctdb/common/system_linux.c
index 23c83d4..6447f56 100644
--- a/ctdb/common/system_linux.c
+++ b/ctdb/common/system_linux.c
@@ -25,7 +25,7 @@
 
 #include "lib/util/debug.h"
 
-#include "ctdb_private.h"
+#include "protocol/protocol.h"
 
 #include <netinet/if_ether.h>
 #include <netinet/ip6.h>
diff --git a/ctdb/common/system_util.c b/ctdb/common/system_util.c
index 81aa00b..e6c4f17 100644
--- a/ctdb/common/system_util.c
+++ b/ctdb/common/system_util.c
@@ -27,7 +27,7 @@
 
 #include "lib/util/debug.h"
 
-#include "ctdb_private.h"
+#include "protocol/protocol.h"
 
 #include "common/logging.h"
 #include "common/system.h"
diff --git a/ctdb/protocol/protocol.h b/ctdb/protocol/protocol.h
index 672b5ed..a2a0c45 100644
--- a/ctdb/protocol/protocol.h
+++ b/ctdb/protocol/protocol.h
@@ -20,6 +20,8 @@
 #ifndef __CTDB_PROTOCOL_H__
 #define __CTDB_PROTOCOL_H__
 
+#include <tdb.h>
+
 #define CTDB_MAGIC	0x43544442 /* CTDB */
 #define CTDB_PROTOCOL	1
 
@@ -980,6 +982,8 @@ union ctdb_message_data {
 	struct ctdb_disable_message *disable;
 	/* SRVID_DISABLE_IP_CHECK */
 	uint32_t timeout;
+	/* Other */
+	TDB_DATA data;
 };
 
 struct ctdb_req_message {
diff --git a/ctdb/protocol/protocol_api.h b/ctdb/protocol/protocol_api.h
index cc00b44..6fb9cec 100644
--- a/ctdb/protocol/protocol_api.h
+++ b/ctdb/protocol/protocol_api.h
@@ -20,6 +20,8 @@
 #ifndef __CTDB_PROTOCOL_API_H__
 #define __CTDB_PROTOCOL_API_H__
 
+#include <talloc.h>
+
 #include "protocol/protocol.h"
 
 /* From protocol/protocol_types.c */
@@ -29,6 +31,8 @@ void ctdb_ltdb_header_push(struct ctdb_ltdb_header *header, uint8_t *buf);
 int ctdb_ltdb_header_pull(uint8_t *buf, size_t buflen,
 			  struct ctdb_ltdb_header *header);
 
+int ctdb_ltdb_header_extract(TDB_DATA *data, struct ctdb_ltdb_header *header);
+
 size_t ctdb_rec_data_len(struct ctdb_rec_data *rec);
 void ctdb_rec_data_push(struct ctdb_rec_data *rec, uint8_t *buf);
 int ctdb_rec_data_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
@@ -660,4 +664,6 @@ enum ctdb_runstate ctdb_runstate_from_string(const char *runstate_str);
 const char *ctdb_event_to_string(enum ctdb_event event);
 enum ctdb_event ctdb_event_from_string(const char *event_str);
 
+const char *ctdb_sock_addr_to_string(TALLOC_CTX *mem_ctx, ctdb_sock_addr *addr);
+
 #endif /* __CTDB_PROTOCOL_API_H__ */
diff --git a/ctdb/protocol/protocol_client.c b/ctdb/protocol/protocol_client.c
index 3bfcef8..a4c19d9 100644
--- a/ctdb/protocol/protocol_client.c
+++ b/ctdb/protocol/protocol_client.c
@@ -673,7 +673,7 @@ void ctdb_req_control_shutdown(struct ctdb_req_control *request)
 	request->pad = 0;
 	request->srvid = 0;
 	request->client_id = 0;
-	request->flags = 0;
+	request->flags = CTDB_CTRL_FLAG_NOREPLY;
 
 	request->rdata.opcode = CTDB_CONTROL_SHUTDOWN;
 }
diff --git a/ctdb/protocol/protocol_message.c b/ctdb/protocol/protocol_message.c
index 07d2dbb..696367e 100644
--- a/ctdb/protocol/protocol_message.c
+++ b/ctdb/protocol/protocol_message.c
@@ -101,6 +101,10 @@ static size_t ctdb_message_data_len(union ctdb_message_data *mdata,
 	case CTDB_SRVID_DISABLE_IP_CHECK:
 		len = ctdb_uint32_len(mdata->timeout);
 		break;
+
+	default:
+		len = ctdb_tdb_data_len(mdata->data);
+		break;
 	}
 
 	return len;
@@ -171,6 +175,10 @@ static void ctdb_message_data_push(union ctdb_message_data *mdata,
 	case CTDB_SRVID_DISABLE_IP_CHECK:
 		ctdb_uint32_push(mdata->timeout, buf);
 		break;
+
+	default:
+		ctdb_tdb_data_push(mdata->data, buf);
+		break;
 	}
 }
 
@@ -251,6 +259,10 @@ static int ctdb_message_data_pull(uint8_t *buf, size_t buflen,
 	case CTDB_SRVID_DISABLE_IP_CHECK:
 		ret = ctdb_uint32_pull(buf, buflen, mem_ctx, &mdata->timeout);
 		break;
+
+	default:
+		ret = ctdb_tdb_data_pull(buf, buflen, mem_ctx, &mdata->data);
+		break;
 	}
 
 	return ret;
diff --git a/ctdb/protocol/protocol_private.h b/ctdb/protocol/protocol_private.h
index ffe3fb2..65193d9 100644
--- a/ctdb/protocol/protocol_private.h
+++ b/ctdb/protocol/protocol_private.h
@@ -265,6 +265,11 @@ void ctdb_srvid_message_push(struct ctdb_srvid_message *msg, uint8_t *buf);
 int ctdb_srvid_message_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
 			    struct ctdb_srvid_message **out);
 
+size_t ctdb_tdb_data_len(TDB_DATA data);
+void ctdb_tdb_data_push(TDB_DATA data, uint8_t *buf);
+int ctdb_tdb_data_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
+		       TDB_DATA *out);
+
 size_t ctdb_disable_message_len(struct ctdb_disable_message *disable);
 void ctdb_disable_message_push(struct ctdb_disable_message *disable,
 			       uint8_t *buf);
diff --git a/ctdb/protocol/protocol_types.c b/ctdb/protocol/protocol_types.c
index f868d76..e36d2e8 100644
--- a/ctdb/protocol/protocol_types.c
+++ b/ctdb/protocol/protocol_types.c
@@ -494,6 +494,21 @@ int ctdb_ltdb_header_pull(uint8_t *buf, size_t buflen,
 	return 0;
 }
 
+int ctdb_ltdb_header_extract(TDB_DATA *data, struct ctdb_ltdb_header *header)
+{
+	int ret;
+
+	ret = ctdb_ltdb_header_pull(data->dptr, data->dsize, header);
+	if (ret != 0) {
+		return ret;
+	}
+
+	data->dptr += sizeof(struct ctdb_ltdb_header);
+	data->dsize -= sizeof(struct ctdb_ltdb_header);
+
+	return 0;
+}
+
 struct ctdb_rec_data_wire {
 	uint32_t length;
 	uint32_t reqid;
@@ -518,6 +533,9 @@ void ctdb_rec_data_push(struct ctdb_rec_data *rec, uint8_t *buf)
 	wire->reqid = rec->reqid;
 	wire->keylen = rec->key.dsize;
 	wire->datalen = rec->data.dsize;
+	if (rec->header != NULL) {
+		wire->datalen += sizeof(struct ctdb_ltdb_header);
+	}
 
 	memcpy(wire->data, rec->key.dptr, rec->key.dsize);
 	offset = rec->key.dsize;
@@ -555,12 +573,10 @@ static int ctdb_rec_data_pull_data(uint8_t *buf, size_t buflen,
 	key->dptr = wire->data;
 	offset = wire->keylen;
 
-	if (wire->length - n == sizeof(struct ctdb_ltdb_header)) {
-		*header = (struct ctdb_ltdb_header *)&wire->data[offset];
-		offset += sizeof(struct ctdb_ltdb_header);
-	} else {
-		*header = NULL;
-	}
+	/* Always set header to NULL.  If it is required, exact it using
+	 * ctdb_rec_data_extract_header()
+	 */
+	*header = NULL;
 
 	data->dsize = wire->datalen;
 	data->dptr = &wire->data[offset];
@@ -587,16 +603,7 @@ static int ctdb_rec_data_pull_elems(uint8_t *buf, size_t buflen,
 	}
 
 	out->reqid = reqid;
-
-	if (header != NULL) {
-		out->header = talloc_memdup(mem_ctx, header,
-					    sizeof(struct ctdb_ltdb_header));
-		if (out->header == NULL) {
-			return ENOMEM;
-		}
-	} else {
-		out->header = NULL;
-	}
+	out->header = NULL;
 
 	out->key.dsize = key.dsize;
 	if (key.dsize > 0) {
@@ -1458,8 +1465,14 @@ struct ctdb_addr_info_wire {
 
 size_t ctdb_addr_info_len(struct ctdb_addr_info *arp)
 {
-	return offsetof(struct ctdb_addr_info_wire, iface) +
-	       strlen(arp->iface)+1;
+	uint32_t len;
+
+	len = offsetof(struct ctdb_addr_info_wire, iface);
+	if (arp->iface != NULL) {
+	       len += strlen(arp->iface)+1;
+	}
+
+	return len;
 }
 
 void ctdb_addr_info_push(struct ctdb_addr_info *addr_info, uint8_t *buf)
@@ -1468,8 +1481,12 @@ void ctdb_addr_info_push(struct ctdb_addr_info *addr_info, uint8_t *buf)
 
 	wire->addr = addr_info->addr;
 	wire->mask = addr_info->mask;
-	wire->len = strlen(addr_info->iface)+1;
-	memcpy(wire->iface, addr_info->iface, wire->len);
+	if (addr_info->iface == NULL) {
+		wire->len = 0;
+	} else {
+		wire->len = strlen(addr_info->iface)+1;
+		memcpy(wire->iface, addr_info->iface, wire->len);
+	}
 }
 
 int ctdb_addr_info_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
@@ -1493,10 +1510,15 @@ int ctdb_addr_info_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
 	addr_info->addr = wire->addr;
 	addr_info->mask = wire->mask;
 
-	addr_info->iface = talloc_strndup(addr_info, wire->iface, wire->len);
-	if (addr_info->iface == NULL) {
-		talloc_free(addr_info);
-		return ENOMEM;
+	if (wire->len == 0) {
+		addr_info->iface = NULL;
+	} else {
+		addr_info->iface = talloc_strndup(addr_info, wire->iface,
+						  wire->len);
+		if (addr_info->iface == NULL) {
+			talloc_free(addr_info);
+			return ENOMEM;
+		}
 	}
 
 	*out = addr_info;
@@ -1660,6 +1682,11 @@ int ctdb_public_ip_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
 	}
 
 	pubip_list->num = wire->num;
+	if (wire->num == 0) {
+		pubip_list->ip = NULL;
+		*out = pubip_list;
+		return 0;
+	}
 	pubip_list->ip = talloc_array(pubip_list, struct ctdb_public_ip,
 				      wire->num);
 	if (pubip_list->ip == NULL) {
@@ -2424,6 +2451,35 @@ int ctdb_disable_message_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
 	return 0;
 }
 
+size_t ctdb_tdb_data_len(TDB_DATA data)
+{
+	return data.dsize;
+}
+
+void ctdb_tdb_data_push(TDB_DATA data, uint8_t *buf)
+{
+	memcpy(buf, data.dptr, data.dsize);
+}
+
+int ctdb_tdb_data_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
+		       TDB_DATA *out)
+{
+	TDB_DATA data;
+
+	data.dsize = buflen;
+	if (data.dsize > 0) {
+		data.dptr = talloc_memdup(mem_ctx, buf, buflen);
+		if (data.dptr == NULL) {
+			return ENOMEM;
+		}
+	} else {
+		data.dptr = NULL;
+	}
+
+	*out = data;
+	return 0;
+}
+
 size_t ctdb_server_id_len(struct ctdb_server_id *sid)
 {
 	return sizeof(struct ctdb_server_id);
diff --git a/ctdb/protocol/protocol_util.c b/ctdb/protocol/protocol_util.c
index 1082b0b..823849f 100644
--- a/ctdb/protocol/protocol_util.c
+++ b/ctdb/protocol/protocol_util.c
@@ -112,3 +112,31 @@ enum ctdb_event ctdb_event_from_string(const char *event_str)
 
 	return CTDB_EVENT_MAX;
 }
+
+const char *ctdb_sock_addr_to_string(TALLOC_CTX *mem_ctx, ctdb_sock_addr *addr)
+{
+	char *cip;
+
+	cip = talloc_size(mem_ctx, 128);
+	if (cip == NULL) {
+		return "Memory Error";
+	}
+
+	switch (addr->sa.sa_family) {
+	case AF_INET:
+		inet_ntop(addr->ip.sin_family, &addr->ip.sin_addr,
+			  cip, 128);
+		break;
+
+	case AF_INET6:
+		inet_ntop(addr->ip6.sin6_family, &addr->ip6.sin6_addr,
+			  cip, 128);
+		break;
+
+	default:
+		sprintf(cip, "Unknown family %u", addr->sa.sa_family);
+		break;
+	}
+
+	return cip;
+}
diff --git a/ctdb/tests/src/protocol_types_test.c b/ctdb/tests/src/protocol_types_test.c
index 4e85315..bab104c 100644
--- a/ctdb/tests/src/protocol_types_test.c
+++ b/ctdb/tests/src/protocol_types_test.c
@@ -215,11 +215,12 @@ static void fill_ctdb_rec_data(TALLOC_CTX *mem_ctx, struct ctdb_rec_data *p)
 static void verify_ctdb_rec_data(struct ctdb_rec_data *p1,
 				 struct ctdb_rec_data *p2)
 {
+	struct ctdb_ltdb_header header;
+
 	assert(p1->reqid == p2->reqid);
-	if (p1->header == NULL || p2->header == NULL) {
-		assert(p1->header == p2->header);
-	} else {
-		verify_ctdb_ltdb_header(p1->header, p2->header);
+	if (p1->header != NULL) {
+		assert(ctdb_ltdb_header_extract(&p2->data, &header) == 0);
+		verify_ctdb_ltdb_header(p1->header, &header);
 	}
 	verify_tdb_data(&p1->key, &p2->key);
 	verify_tdb_data(&p1->data, &p2->data);
@@ -556,7 +557,11 @@ static void fill_ctdb_addr_info(TALLOC_CTX *mem_ctx, struct ctdb_addr_info *p)
 {
 	fill_ctdb_sock_addr(mem_ctx, &p->addr);
 	p->mask = rand_int(33);
-	fill_ctdb_string(mem_ctx, &p->iface);
+	if (rand_int(2) == 0) {
+		p->iface = NULL;
+	} else {
+		fill_ctdb_string(mem_ctx, &p->iface);
+	}
 }
 
 static void verify_ctdb_addr_info(struct ctdb_addr_info *p1,
@@ -607,7 +612,11 @@ static void fill_ctdb_public_ip_list(TALLOC_CTX *mem_ctx,
 {
 	int i;
 
-	p->num = rand_int(32) + 1;
+	p->num = rand_int(32);
+	if (p->num == 0) {
+		p->ip = NULL;
+		return;
+	}
 	p->ip = talloc_array(mem_ctx, struct ctdb_public_ip, p->num);
 	assert(p->ip != NULL);
 	for (i=0; i<p->num; i++) {


-- 
Samba Shared Repository



More information about the samba-cvs mailing list