svn commit: samba r22098 - in
branches/SAMBA_4_0/source/cluster/ctdb: common include tcp
tridge at samba.org
tridge at samba.org
Fri Apr 6 04:43:54 GMT 2007
Author: tridge
Date: 2007-04-06 04:43:54 +0000 (Fri, 06 Apr 2007)
New Revision: 22098
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=22098
Log:
merged from bzr tree
Modified:
branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb.c
branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_call.c
branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_message.c
branches/SAMBA_4_0/source/cluster/ctdb/include/ctdb_private.h
branches/SAMBA_4_0/source/cluster/ctdb/tcp/tcp_connect.c
Changeset:
Modified: branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb.c
===================================================================
--- branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb.c 2007-04-06 01:09:19 UTC (rev 22097)
+++ branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb.c 2007-04-06 04:43:54 UTC (rev 22098)
@@ -205,6 +205,16 @@
return;
}
+ if (hdr->ctdb_magic != CTDB_MAGIC) {
+ ctdb_set_error(ctdb, "Non CTDB packet rejected\n");
+ return;
+ }
+
+ if (hdr->ctdb_version != CTDB_VERSION) {
+ ctdb_set_error(ctdb, "Bad CTDB version 0x%x rejected\n", hdr->ctdb_version);
+ return;
+ }
+
switch (hdr->operation) {
case CTDB_REQ_CALL:
ctdb_request_call(ctdb, hdr);
Modified: branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_call.c
===================================================================
--- branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_call.c 2007-04-06 01:09:19 UTC (rev 22097)
+++ branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_call.c 2007-04-06 04:43:54 UTC (rev 22098)
@@ -125,6 +125,8 @@
CTDB_NO_MEMORY_FATAL(ctdb, r);
r->hdr.length = len + msglen;
+ r->hdr.ctdb_magic = CTDB_MAGIC;
+ r->hdr.ctdb_version = CTDB_VERSION;
r->hdr.operation = CTDB_REPLY_ERROR;
r->hdr.destnode = hdr->srcnode;
r->hdr.srcnode = ctdb->vnn;
@@ -153,6 +155,8 @@
r = ctdb->methods->allocate_pkt(ctdb, sizeof(*r));
CTDB_NO_MEMORY_FATAL(ctdb, r);
r->hdr.length = sizeof(*r);
+ r->hdr.ctdb_magic = CTDB_MAGIC;
+ r->hdr.ctdb_version = CTDB_VERSION;
r->hdr.operation = CTDB_REPLY_REDIRECT;
r->hdr.destnode = c->hdr.srcnode;
r->hdr.srcnode = ctdb->vnn;
@@ -184,6 +188,8 @@
r = ctdb->methods->allocate_pkt(ctdb, len);
CTDB_NO_MEMORY_FATAL(ctdb, r);
r->hdr.length = len;
+ r->hdr.ctdb_magic = CTDB_MAGIC;
+ r->hdr.ctdb_version = CTDB_VERSION;
r->hdr.operation = CTDB_REQ_DMASTER;
r->hdr.destnode = ctdb_lmaster(ctdb, key);
r->hdr.srcnode = ctdb->vnn;
@@ -264,6 +270,8 @@
r = ctdb->methods->allocate_pkt(ctdb, len);
CTDB_NO_MEMORY_FATAL(ctdb, r);
r->hdr.length = len;
+ r->hdr.ctdb_magic = CTDB_MAGIC;
+ r->hdr.ctdb_version = CTDB_VERSION;
r->hdr.operation = CTDB_REPLY_DMASTER;
r->hdr.destnode = c->dmaster;
r->hdr.srcnode = ctdb->vnn;
@@ -346,6 +354,8 @@
r = ctdb->methods->allocate_pkt(ctdb, len);
CTDB_NO_MEMORY_FATAL(ctdb, r);
r->hdr.length = len;
+ r->hdr.ctdb_magic = CTDB_MAGIC;
+ r->hdr.ctdb_version = CTDB_VERSION;
r->hdr.operation = CTDB_REPLY_CALL;
r->hdr.destnode = hdr->srcnode;
r->hdr.srcnode = hdr->destnode;
@@ -576,6 +586,8 @@
CTDB_NO_MEMORY_NULL(ctdb, state->c);
state->c->hdr.length = len;
+ state->c->hdr.ctdb_magic = CTDB_MAGIC;
+ state->c->hdr.ctdb_version = CTDB_VERSION;
state->c->hdr.operation = CTDB_REQ_CALL;
state->c->hdr.destnode = header.dmaster;
state->c->hdr.srcnode = ctdb->vnn;
Modified: branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_message.c
===================================================================
--- branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_message.c 2007-04-06 01:09:19 UTC (rev 22097)
+++ branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_message.c 2007-04-06 04:43:54 UTC (rev 22098)
@@ -64,6 +64,8 @@
CTDB_NO_MEMORY(ctdb, r);
r->hdr.length = len;
+ r->hdr.ctdb_magic = CTDB_MAGIC;
+ r->hdr.ctdb_version = CTDB_VERSION;
r->hdr.operation = CTDB_REQ_MESSAGE;
r->hdr.destnode = vnn;
r->hdr.srcnode = ctdb->vnn;
Modified: branches/SAMBA_4_0/source/cluster/ctdb/include/ctdb_private.h
===================================================================
--- branches/SAMBA_4_0/source/cluster/ctdb/include/ctdb_private.h 2007-04-06 01:09:19 UTC (rev 22097)
+++ branches/SAMBA_4_0/source/cluster/ctdb/include/ctdb_private.h 2007-04-06 04:43:54 UTC (rev 22098)
@@ -155,11 +155,16 @@
CTDB_REQ_MESSAGE = 6
};
+#define CTDB_MAGIC 0x43544442 /* CTDB */
+#define CTDB_VERSION 1
+
/*
packet structures
*/
struct ctdb_req_header {
uint32_t length;
+ uint32_t ctdb_magic;
+ uint32_t ctdb_version;
uint32_t operation;
uint32_t destnode;
uint32_t srcnode;
Modified: branches/SAMBA_4_0/source/cluster/ctdb/tcp/tcp_connect.c
===================================================================
--- branches/SAMBA_4_0/source/cluster/ctdb/tcp/tcp_connect.c 2007-04-06 01:09:19 UTC (rev 22097)
+++ branches/SAMBA_4_0/source/cluster/ctdb/tcp/tcp_connect.c 2007-04-06 04:43:54 UTC (rev 22098)
@@ -98,6 +98,7 @@
struct ctdb_tcp_node *tnode = talloc_get_type(node->private,
struct ctdb_tcp_node);
struct ctdb_context *ctdb = node->ctdb;
+ struct sockaddr_in sock_in;
struct sockaddr_in sock_out;
tnode->fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
@@ -109,7 +110,21 @@
}
sock_out.sin_port = htons(node->address.port);
sock_out.sin_family = PF_INET;
-
+
+
+ /* Bind our side of the socketpair to the same address we use to listen
+ * on incoming CTDB traffic.
+ * We must specify this address to make sure that the address we expose to
+ * the remote side is actually routable in case CTDB traffic will run on
+ * a dedicated non-routeable network.
+ */
+ if (ctdb_tcp_get_address(ctdb, ctdb->address.address, &sock_in.sin_addr) != 0) {
+ return;
+ }
+ sock_in.sin_port = htons(0); /* INPORT_ANY is not always available */
+ sock_in.sin_family = PF_INET;
+ bind(tnode->fd, (struct sockaddr *)&sock_in, sizeof(sock_in));
+
if (connect(tnode->fd, (struct sockaddr *)&sock_out, sizeof(sock_out)) != 0 &&
errno != EINPROGRESS) {
/* try again once a second */
More information about the samba-cvs
mailing list