struct auth_serversupplied_info **server_info)
{
NTSTATUS status;
- uint32_t *winbind_servers;
+ struct server_id *winbind_servers;
struct winbind_check_password_state *s;
const struct auth_usersupplied_info *user_info_new;
struct netr_IdentityInfo *identity_info;
winbind_servers = irpc_servers_byname(ctx->auth_ctx->msg_ctx, "winbind_server");
- if ((winbind_servers == NULL) || (winbind_servers[0] == 0)) {
+ if ((winbind_servers == NULL) || (winbind_servers[0].id == 0)) {
DEBUG(0, ("Winbind authentication for [%s]\\[%s] failed, "
"no winbind_server running!\n",
user_info->client.domain_name, user_info->client.account_name));
DB_WRAP \
NDR_IRPC \
UNIX_PRIVS \
- UTIL_TDB
+ UTIL_TDB \
+ CLUSTER
# End SUBSYSTEM MESSAGING
################################################
an incoming irpc message
*/
struct irpc_message {
- uint32_t from;
+ struct server_id from;
void *private;
struct irpc_header header;
struct ndr_pull *ndr;
};
typedef void (*msg_callback_t)(struct messaging_context *msg, void *private,
- uint32_t msg_type, uint32_t server_id, DATA_BLOB *data);
+ uint32_t msg_type,
+ struct server_id server_id, DATA_BLOB *data);
-struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, uint32_t server_id,
+struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
+ struct server_id server_id,
struct event_context *ev);
-NTSTATUS messaging_send(struct messaging_context *msg, uint32_t server,
+NTSTATUS messaging_send(struct messaging_context *msg, struct server_id server,
uint32_t msg_type, DATA_BLOB *data);
NTSTATUS messaging_register(struct messaging_context *msg, void *private,
uint32_t msg_type,
msg_callback_t fn);
NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private,
msg_callback_t fn, uint32_t *msg_type);
-struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, uint32_t server_id,
+struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
+ struct server_id server_id,
struct event_context *ev);
struct messaging_context *messaging_client_init(TALLOC_CTX *mem_ctx,
struct event_context *ev);
-NTSTATUS messaging_send_ptr(struct messaging_context *msg, uint32_t server,
+NTSTATUS messaging_send_ptr(struct messaging_context *msg, struct server_id server,
uint32_t msg_type, void *ptr);
void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void *private);
const struct dcerpc_interface_table *table,
int call, irpc_function_t fn, void *private);
struct irpc_request *irpc_call_send(struct messaging_context *msg_ctx,
- uint32_t server_id,
+ struct server_id server_id,
const struct dcerpc_interface_table *table,
int callnum, void *r, TALLOC_CTX *ctx);
NTSTATUS irpc_call_recv(struct irpc_request *irpc);
NTSTATUS irpc_call(struct messaging_context *msg_ctx,
- uint32_t server_id,
+ struct server_id server_id,
const struct dcerpc_interface_table *table,
int callnum, void *r, TALLOC_CTX *ctx);
NTSTATUS irpc_add_name(struct messaging_context *msg_ctx, const char *name);
-uint32_t *irpc_servers_byname(struct messaging_context *msg_ctx, const char *name);
+struct server_id *irpc_servers_byname(struct messaging_context *msg_ctx, const char *name);
void irpc_remove_name(struct messaging_context *msg_ctx, const char *name);
NTSTATUS irpc_send_reply(struct irpc_message *m, NTSTATUS status);
#include "librpc/rpc/dcerpc.h"
#include "lib/tdb/include/tdb.h"
#include "lib/util/util_tdb.h"
+#include "lib/util/util_tdb.h"
+#include "cluster/cluster.h"
/* change the message version with any incompatible changes in the protocol */
#define MESSAGING_VERSION 1
struct messaging_context {
- uint32_t server_id;
+ struct server_id server_id;
struct socket_context *sock;
const char *base_path;
const char *path;
struct messaging_header {
uint32_t version;
uint32_t msg_type;
- uint32_t from;
- uint32_t to;
+ struct server_id from;
+ struct server_id to;
uint32_t length;
} *header;
static void irpc_handler(struct messaging_context *, void *,
- uint32_t, uint32_t, DATA_BLOB *);
+ uint32_t, struct server_id, DATA_BLOB *);
/*
A useful function for testing the message system.
*/
static void ping_message(struct messaging_context *msg, void *private,
- uint32_t msg_type, uint32_t src, DATA_BLOB *data)
+ uint32_t msg_type, struct server_id src, DATA_BLOB *data)
{
- DEBUG(1,("INFO: Received PING message from server %u [%.*s]\n",
- (uint_t)src, (int)data->length,
+ DEBUG(1,("INFO: Received PING message from server %u.%u [%.*s]\n",
+ (uint_t)src.node, (uint_t)src.id, (int)data->length,
data->data?(const char *)data->data:""));
messaging_send(msg, src, MSG_PONG, data);
}
/*
return the path to a messaging socket
*/
-static char *messaging_path(struct messaging_context *msg, uint32_t server_id)
+static char *messaging_path(struct messaging_context *msg, struct server_id server_id)
{
- return talloc_asprintf(msg, "%s/msg.%u", msg->base_path, (unsigned)server_id);
+ return talloc_asprintf(msg, "%s/msg.%u.%u", msg->base_path,
+ (unsigned)server_id.node, (unsigned)server_id.id);
}
/*
}
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1,("messaging: Lost message from %u to %u of type %u - %s\n",
- rec->header->from, rec->header->to, rec->header->msg_type,
+ rec->header->from.id, rec->header->to.id, rec->header->msg_type,
nt_errstr(status)));
}
DLIST_REMOVE(msg->pending, rec);
/*
Send a message to a particular server
*/
-NTSTATUS messaging_send(struct messaging_context *msg, uint32_t server,
+NTSTATUS messaging_send(struct messaging_context *msg, struct server_id server,
uint32_t msg_type, DATA_BLOB *data)
{
struct messaging_rec *rec;
/*
Send a message to a particular server, with the message containing a single pointer
*/
-NTSTATUS messaging_send_ptr(struct messaging_context *msg, uint32_t server,
+NTSTATUS messaging_send_ptr(struct messaging_context *msg, struct server_id server,
uint32_t msg_type, void *ptr)
{
DATA_BLOB blob;
/*
create the listening socket and setup the dispatcher
*/
-struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, uint32_t server_id,
+struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
+ struct server_id server_id,
struct event_context *ev)
{
struct messaging_context *msg;
struct messaging_context *messaging_client_init(TALLOC_CTX *mem_ctx,
struct event_context *ev)
{
- return messaging_init(mem_ctx, random() % 0x10000000, ev);
+ struct server_id id;
+ ZERO_STRUCT(id);
+ id.id = random() % 0x10000000;
+ return messaging_init(mem_ctx, id, ev);
}
/*
a list of registered irpc server functions
handle an incoming irpc message
*/
static void irpc_handler(struct messaging_context *msg_ctx, void *private,
- uint32_t msg_type, uint32_t src, DATA_BLOB *packet)
+ uint32_t msg_type, struct server_id src, DATA_BLOB *packet)
{
struct irpc_message *m;
NTSTATUS status;
make a irpc call - async send
*/
struct irpc_request *irpc_call_send(struct messaging_context *msg_ctx,
- uint32_t server_id,
+ struct server_id server_id,
const struct dcerpc_interface_table *table,
int callnum, void *r, TALLOC_CTX *ctx)
{
perform a synchronous irpc request
*/
NTSTATUS irpc_call(struct messaging_context *msg_ctx,
- uint32_t server_id,
+ struct server_id server_id,
const struct dcerpc_interface_table *table,
int callnum, void *r,
TALLOC_CTX *mem_ctx)
return NT_STATUS_LOCK_NOT_GRANTED;
}
rec = tdb_fetch_bystring(t->tdb, name);
- count = rec.dsize / sizeof(uint32_t);
- rec.dptr = (unsigned char *)realloc_p(rec.dptr, uint32_t, count+1);
- rec.dsize += sizeof(uint32_t);
+ count = rec.dsize / sizeof(struct server_id);
+ rec.dptr = (unsigned char *)realloc_p(rec.dptr, struct server_id, count+1);
+ rec.dsize += sizeof(struct server_id);
if (rec.dptr == NULL) {
tdb_unlock_bystring(t->tdb, name);
talloc_free(t);
return NT_STATUS_NO_MEMORY;
}
- ((uint32_t *)rec.dptr)[count] = msg_ctx->server_id;
+ ((struct server_id *)rec.dptr)[count] = msg_ctx->server_id;
if (tdb_store_bystring(t->tdb, name, rec, 0) != 0) {
status = NT_STATUS_INTERNAL_ERROR;
}
/*
return a list of server ids for a server name
*/
-uint32_t *irpc_servers_byname(struct messaging_context *msg_ctx, const char *name)
+struct server_id *irpc_servers_byname(struct messaging_context *msg_ctx,
+ const char *name)
{
struct tdb_wrap *t;
TDB_DATA rec;
int count, i;
- uint32_t *ret;
+ struct server_id *ret;
t = irpc_namedb_open(msg_ctx);
if (t == NULL) {
talloc_free(t);
return NULL;
}
- count = rec.dsize / sizeof(uint32_t);
- ret = talloc_array(msg_ctx, uint32_t, count+1);
+ count = rec.dsize / sizeof(struct server_id);
+ ret = talloc_array(msg_ctx, struct server_id, count+1);
if (ret == NULL) {
tdb_unlock_bystring(t->tdb, name);
talloc_free(t);
return NULL;
}
for (i=0;i<count;i++) {
- ret[i] = ((uint32_t *)rec.dptr)[i];
+ ret[i] = ((struct server_id *)rec.dptr)[i];
}
- ret[i] = 0;
+ ret[i] = cluster_id(0);
free(rec.dptr);
tdb_unlock_bystring(t->tdb, name);
talloc_free(t);
struct tdb_wrap *t;
TDB_DATA rec;
int count, i;
- uint32_t *ids;
+ struct server_id *ids;
str_list_remove(msg_ctx->names, name);
return;
}
rec = tdb_fetch_bystring(t->tdb, name);
- count = rec.dsize / sizeof(uint32_t);
+ count = rec.dsize / sizeof(struct server_id);
if (count == 0) {
tdb_unlock_bystring(t->tdb, name);
talloc_free(t);
return;
}
- ids = (uint32_t *)rec.dptr;
+ ids = (struct server_id *)rec.dptr;
for (i=0;i<count;i++) {
- if (ids[i] == msg_ctx->server_id) {
+ if (cluster_id_equal(&ids[i], &msg_ctx->server_id)) {
if (i < count-1) {
- memmove(ids+i, ids+i+1, count-(i+1));
+ memmove(ids+i, ids+i+1,
+ sizeof(struct server_id) * (count-(i+1)));
}
- rec.dsize -= sizeof(uint32_t);
+ rec.dsize -= sizeof(struct server_id);
break;
}
}
struct finddcs_state *state =
talloc_get_type(ctx->async.private_data, struct finddcs_state);
struct irpc_request *ireq;
- uint32_t *nbt_servers;
+ struct server_id *nbt_servers;
const char *address;
state->ctx->status = resolve_name_recv(ctx, state, &address);
}
nbt_servers = irpc_servers_byname(state->msg_ctx, "nbt_server");
- if ((nbt_servers == NULL) || (nbt_servers[0] == 0)) {
+ if ((nbt_servers == NULL) || (nbt_servers[0].id == 0)) {
fallback_node_status(state);
return;
}
SAMR_REJECT_COMPLEXITY = 5
} samr_RejectReason;
-
+ /* id used to identify a endpoint, possibly in a cluster */
+ typedef [public] struct {
+ uint32 id;
+ uint32 node;
+ } server_id;
}
/* structure used in the notify database */
typedef [public] struct {
- uint32 server;
+ server_id server;
uint32 filter; /* filter to apply in this directory */
uint32 subdir_filter; /* filter to apply in child directories */
utf8string path;
ntvfs/common/opendb.c
*/
+import "misc.idl";
+
[
pointer_default(unique)
]
interface opendb
{
typedef struct {
- uint32 server;
+ server_id server;
uint32 stream_id;
uint32 share_access;
uint32 access_mask;
} opendb_entry;
typedef struct {
- uint32 server;
+ server_id server;
pointer notify_ptr;
} opendb_pending;
include dsdb/config.mk
include gtk/config.mk
include smbd/config.mk
+include cluster/config.mk
include smbd/process_model.mk
include libnet/config.mk
include auth/config.mk
lock is the same as another lock
*/
struct lock_context {
- uint32_t server;
+ struct server_id server;
uint16_t smbpid;
struct brl_context *ctx;
};
/* this struct is typicaly attached to tcon */
struct brl_context {
struct tdb_wrap *w;
- uint32_t server;
+ struct server_id server;
struct messaging_context *messaging_ctx;
};
talloc_free(). We need the messaging_ctx to allow for
pending lock notifications.
*/
-struct brl_context *brl_init(TALLOC_CTX *mem_ctx, uint32_t server,
+struct brl_context *brl_init(TALLOC_CTX *mem_ctx, struct server_id server,
struct messaging_context *messaging_ctx)
{
char *path;
*/
static BOOL brl_same_context(struct lock_context *ctx1, struct lock_context *ctx2)
{
- return (ctx1->server == ctx2->server &&
+ return (cluster_id_equal(&ctx1->server, &ctx2->server) &&
ctx1->smbpid == ctx2->smbpid &&
ctx1->ctx == ctx2->ctx);
}
* if the current lock matches the last failed lock on the file handle
* and starts at the same offset, then FILE_LOCK_CONFLICT should be returned
*/
- if (lock->context.server == brlh->last_lock.context.server &&
+ if (cluster_id_equal(&lock->context.server, &brlh->last_lock.context.server) &&
lock->context.ctx == brlh->last_lock.context.ctx &&
lock->ntvfs == brlh->last_lock.ntvfs &&
lock->start == brlh->last_lock.start) {
if (lock->lock_type >= PENDING_READ_LOCK &&
lock->notify_ptr == notify_ptr &&
- lock->context.server == brl->server) {
+ cluster_id_equal(&lock->context.server, &brl->server)) {
/* found it - delete it */
if (count == 1) {
if (tdb_delete(brl->w->tdb, kbuf) != 0) {
struct lock_struct *lock = &locks[i];
if (lock->context.ctx == brl &&
- lock->context.server == brl->server &&
+ cluster_id_equal(&lock->context.server, &brl->server) &&
lock->ntvfs == brlh->ntvfs) {
/* found it - delete it */
if (count > 1 && i < count-1) {
struct notify_context {
struct tdb_wrap *w;
- uint32_t server;
+ struct server_id server;
struct messaging_context *messaging_ctx;
struct notify_list *list;
struct notify_array *array;
static NTSTATUS notify_remove_all(struct notify_context *notify);
static void notify_handler(struct messaging_context *msg_ctx, void *private,
- uint32_t msg_type, uint32_t server_id, DATA_BLOB *data);
+ uint32_t msg_type, struct server_id server_id, DATA_BLOB *data);
/*
destroy the notify context
talloc_free(). We need the messaging_ctx to allow for notifications
via internal messages
*/
-struct notify_context *notify_init(TALLOC_CTX *mem_ctx, uint32_t server,
+struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
struct messaging_context *messaging_ctx,
struct event_context *ev,
struct share_config *scfg)
handle incoming notify messages
*/
static void notify_handler(struct messaging_context *msg_ctx, void *private,
- uint32_t msg_type, uint32_t server_id, DATA_BLOB *data)
+ uint32_t msg_type, struct server_id server_id, DATA_BLOB *data)
{
struct notify_context *notify = talloc_get_type(private, struct notify_context);
NTSTATUS status;
for (i=0;i<d->num_entries;i++) {
if (private == d->entries[i].private &&
- notify->server == d->entries[i].server) {
+ cluster_id_equal(¬ify->server, &d->entries[i].server)) {
break;
}
}
for (depth=0;depth<notify->array->num_depths;depth++) {
struct notify_depth *d = ¬ify->array->depth[depth];
for (i=0;i<d->num_entries;i++) {
- if (notify->server == d->entries[i].server) {
+ if (cluster_id_equal(¬ify->server, &d->entries[i].server)) {
if (i < d->num_entries-1) {
memmove(&d->entries[i], &d->entries[i+1],
sizeof(d->entries[i])*(d->num_entries-(i+1)));
/* find the entry, and delete it */
for (i=0;i<file.num_entries;i++) {
if (file_handle == file.entries[i].file_handle &&
- odb->ntvfs_ctx->server_id == file.entries[i].server) {
+ cluster_id_equal(&odb->ntvfs_ctx->server_id, &file.entries[i].server)) {
if (file.entries[i].delete_on_close) {
file.delete_on_close = True;
}
/* find the entry, and delete it */
for (i=0;i<file.num_pending;i++) {
if (private == file.pending[i].notify_ptr &&
- odb->ntvfs_ctx->server_id == file.pending[i].server) {
+ cluster_id_equal(&odb->ntvfs_ctx->server_id, &file.pending[i].server)) {
if (i < file.num_pending-1) {
memmove(file.pending+i, file.pending+i+1,
(file.num_pending - (i+1)) *
struct share_config *config;
- uint32_t server_id;
+ struct server_id server_id;
struct event_context *event_ctx;
struct messaging_context *msg_ctx;
NTSTATUS ntvfs_init_connection(TALLOC_CTX *mem_ctx, struct share_config *scfg, enum ntvfs_type type,
enum protocol_types protocol,
struct event_context *ev, struct messaging_context *msg,
- uint32_t server_id, struct ntvfs_context **_ctx)
+ struct server_id server_id, struct ntvfs_context **_ctx)
{
const char **handlers = share_string_list_option(mem_ctx, scfg, SHARE_NTVFS_HANDLER);
int i;
receive a completion message for a wait
*/
static void pvfs_wait_dispatch(struct messaging_context *msg, void *private, uint32_t msg_type,
- uint32_t src, DATA_BLOB *data)
+ struct server_id src, DATA_BLOB *data)
{
struct pvfs_wait *pwait = private;
struct ntvfs_request *req;
struct auth_session_info *session_info,
struct event_context *event_ctx,
struct messaging_context *msg_ctx,
- uint32_t server_id,
+ struct server_id server_id,
uint32_t state_flags,
struct dcesrv_connection **_p)
{
struct auth_session_info *session_info,
struct event_context *event_ctx,
struct messaging_context *msg_ctx,
- uint32_t server_id,
+ struct server_id server_id,
uint32_t state_flags,
struct dcesrv_connection **dce_conn_p)
{
struct messaging_context *msg_ctx;
/* the server_id that will be used for this connection */
- uint32_t server_id;
+ struct server_id server_id;
/* the transport level session key */
DATA_BLOB transport_session_key;
#include "librpc/rpc/dcerpc_table.h"
#include "auth/credentials/credentials.h"
#include "librpc/rpc/dcerpc.h"
+#include "cluster/cluster.h"
/*
state of a irpc 'connection'
*/
struct ejs_irpc_connection {
const char *server_name;
- uint32_t *dest_ids;
+ struct server_id *dest_ids;
struct messaging_context *msg_ctx;
};
/* create a messaging context, looping as we have no way to
allocate temporary server ids automatically */
for (i=0;i<10000;i++) {
- p->msg_ctx = messaging_init(p, EJS_ID_BASE + i, ev);
+ p->msg_ctx = messaging_init(p, cluster_id(EJS_ID_BASE + i), ev);
if (p->msg_ctx) break;
}
if (p->msg_ctx == NULL) {
}
p->dest_ids = irpc_servers_byname(p->msg_ctx, p->server_name);
- if (p->dest_ids == NULL || p->dest_ids[0] == 0) {
+ if (p->dest_ids == NULL || p->dest_ids[0].id == 0) {
talloc_free(p);
status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
} else {
goto done;
}
- for (count=0;p->dest_ids[count];count++) /* noop */ ;
+ for (count=0;p->dest_ids[count].id;count++) /* noop */ ;
/* we need to make a call per server */
reqs = talloc_array(ejs, struct irpc_request *, count);
SSVAL(req->out.vwv, VWV(3), lp_maxmux());
SSVAL(req->out.vwv, VWV(4), 1);
SSVAL(req->out.vwv, VWV(5), raw);
- SIVAL(req->out.vwv, VWV(6), req->smb_conn->connection->server_id);
+ SIVAL(req->out.vwv, VWV(6), req->smb_conn->connection->server_id.id);
srv_push_dos_date(req->smb_conn, req->out.vwv, VWV(8), t);
SSVAL(req->out.vwv, VWV(10), req->smb_conn->negotiate.zone_offset/60);
SIVAL(req->out.vwv, VWV(11), 0); /* reserved */
SSVAL(req->out.vwv, VWV(3), lp_maxmux());
SSVAL(req->out.vwv, VWV(4), 1);
SSVAL(req->out.vwv, VWV(5), raw);
- SIVAL(req->out.vwv, VWV(6), req->smb_conn->connection->server_id);
+ SIVAL(req->out.vwv, VWV(6), req->smb_conn->connection->server_id.id);
srv_push_dos_date(req->smb_conn, req->out.vwv, VWV(8), t);
SSVAL(req->out.vwv, VWV(10), req->smb_conn->negotiate.zone_offset/60);
SIVAL(req->out.vwv, VWV(11), 0);
SSVAL(req->out.vwv+1, VWV(2), 1); /* num vcs */
SIVAL(req->out.vwv+1, VWV(3), req->smb_conn->negotiate.max_recv);
SIVAL(req->out.vwv+1, VWV(5), 0x10000); /* raw size. full 64k */
- SIVAL(req->out.vwv+1, VWV(7), req->smb_conn->connection->server_id); /* session key */
+ SIVAL(req->out.vwv+1, VWV(7), req->smb_conn->connection->server_id.id); /* session key */
SIVAL(req->out.vwv+1, VWV(9), capabilities);
push_nttime(req->out.vwv+1, VWV(11), nttime);
SSVALS(req->out.vwv+1,VWV(15), req->smb_conn->negotiate.zone_offset/60);
#define __PROCESS_MODEL_H__
#include "lib/socket/socket.h"
+#include "smbd/service_task.h"
/* modules can use the following to determine if the interface has changed
* please increment the version number after each interface change
/* function to accept new connection */
void (*accept_connection)(struct event_context *, struct socket_context *,
void (*)(struct event_context *, struct socket_context *,
- uint32_t , void *),
+ struct server_id , void *),
void *);
/* function to create a task */
void (*new_task)(struct event_context *,
- void (*)(struct event_context *, uint32_t, void *),
+ void (*)(struct event_context *, struct server_id, void *),
void *);
/* function to terminate a connection or task */
#include "includes.h"
#include "smbd/process_model.h"
#include "system/filesys.h"
+#include "cluster/cluster.h"
/*
called when the process model is selected
static void single_accept_connection(struct event_context *ev,
struct socket_context *sock,
void (*new_conn)(struct event_context *, struct socket_context *,
- uint32_t , void *),
+ struct server_id , void *),
void *private)
{
NTSTATUS status;
talloc_steal(private, sock);
- new_conn(ev, sock2, socket_get_fd(sock2), private);
+ new_conn(ev, sock2, cluster_id(socket_get_fd(sock2)), private);
}
/*
called to startup a new task
*/
static void single_new_task(struct event_context *ev,
- void (*new_task)(struct event_context *, uint32_t, void *),
+ void (*new_task)(struct event_context *, struct server_id, void *),
void *private)
{
static uint32_t taskid = 0x10000000;
- new_task(ev, taskid++, private);
+ new_task(ev, cluster_id(taskid++), private);
}
#include "lib/socket/socket.h"
#include "smbd/process_model.h"
#include "param/secrets.h"
-
#include "system/filesys.h"
+#include "cluster/cluster.h"
#ifdef HAVE_SETPROCTITLE
#ifdef HAVE_SETPROCTITLE_H
static void standard_accept_connection(struct event_context *ev,
struct socket_context *sock,
void (*new_conn)(struct event_context *, struct socket_context *,
- uint32_t , void *),
+ struct server_id , void *),
void *private)
{
NTSTATUS status;
talloc_free(s);
/* setup this new connection */
- new_conn(ev2, sock2, pid, private);
+ new_conn(ev2, sock2, cluster_id(pid), private);
/* we can't return to the top level here, as that event context is gone,
so we now process events in the new event context until there are no
called to create a new server task
*/
static void standard_new_task(struct event_context *ev,
- void (*new_task)(struct event_context *, uint32_t , void *),
+ void (*new_task)(struct event_context *, struct server_id , void *),
void *private)
{
pid_t pid;
setproctitle("task server_id[%d]", pid);
/* setup this new connection */
- new_task(ev2, pid, private);
+ new_task(ev2, cluster_id(pid), private);
/* we can't return to the top level here, as that event context is gone,
so we now process events in the new event context until there are no
#include "smbd/service.h"
#include "smbd/service_stream.h"
#include "lib/messaging/irpc.h"
+#include "cluster/cluster.h"
/* the range of ports to try for dcerpc over tcp endpoints */
#define SERVER_TCP_LOW_PORT 1024
srv_conn->private = private_data;
srv_conn->model_ops = model_ops;
srv_conn->socket = sock;
- srv_conn->server_id = 0;
+ srv_conn->server_id = cluster_id(0);
srv_conn->ops = stream_ops;
srv_conn->msg_ctx = msg_ctx;
srv_conn->event.ctx = ev;
*/
static void stream_new_connection(struct event_context *ev,
struct socket_context *sock,
- uint32_t server_id, void *private)
+ struct server_id server_id, void *private)
{
struct stream_socket *stream_socket = talloc_get_type(private, struct stream_socket);
struct stream_connection *srv_conn;
s = socket_get_my_addr(sock, ev);
if (s && c) {
const char *title;
- title = talloc_asprintf(s, "conn[%s] c[%s:%u] s[%s:%u] server_id[%d]",
+ title = talloc_asprintf(s, "conn[%s] c[%s:%u] s[%s:%u] server_id[%s]",
stream_socket->ops->name,
c->addr, c->port, s->addr, s->port,
- server_id);
+ cluster_id_string(s, server_id));
if (title) {
stream_connection_set_title(srv_conn, title);
}
struct stream_connection {
const struct stream_server_ops *ops;
const struct model_ops *model_ops;
- uint32_t server_id;
+ struct server_id server_id;
void *private;
struct {
called by the process model code when the new task starts up. This then calls
the server specific startup code
*/
-static void task_server_callback(struct event_context *event_ctx, uint32_t server_id, void *private)
+static void task_server_callback(struct event_context *event_ctx,
+ struct server_id server_id, void *private)
{
struct task_state *state = talloc_get_type(private, struct task_state);
struct task_server *task;
struct event_context *event_ctx;
const struct model_ops *model_ops;
struct messaging_context *msg_ctx;
- uint32_t server_id;
+ struct server_id server_id;
void *private;
};
+
+
#endif /* __SERVICE_TASK_H__ */
r.in.in_data = value;
test_debug = True;
- status = IRPC_CALL(data->msg_ctx1, MSG_ID2, rpcecho, ECHO_ADDONE, &r, test);
+ status = IRPC_CALL(data->msg_ctx1, cluster_id(MSG_ID2),
+ rpcecho, ECHO_ADDONE, &r, test);
test_debug = False;
torture_assert_ntstatus_ok(test, status, "AddOne failed");
r.in.in_data = (unsigned char *)talloc_strdup(mem_ctx, "0123456789");
r.in.len = strlen((char *)r.in.in_data);
- status = IRPC_CALL(data->msg_ctx1, MSG_ID2, rpcecho, ECHO_ECHODATA, &r,
- mem_ctx);
+ status = IRPC_CALL(data->msg_ctx1, cluster_id(MSG_ID2),
+ rpcecho, ECHO_ECHODATA, &r,
+ mem_ctx);
torture_assert_ntstatus_ok(tctx, status, "EchoData failed");
/* check the answer */
while (timeval_elapsed(&tv) < timelimit) {
struct irpc_request *irpc;
- irpc = IRPC_CALL_SEND(data->msg_ctx1, MSG_ID2, rpcecho, ECHO_ADDONE,
- &r, mem_ctx);
+ irpc = IRPC_CALL_SEND(data->msg_ctx1, cluster_id(MSG_ID2),
+ rpcecho, ECHO_ADDONE,
+ &r, mem_ctx);
torture_assert(tctx, irpc != NULL, "AddOne send failed");
irpc->async.fn = irpc_callback;
lp_set_cmdline("lock dir", "lockdir.tmp");
data->ev = event_context_init(tctx);
- torture_assert(tctx, data->msg_ctx1 = messaging_init(tctx, MSG_ID1, data->ev),
- "Failed to init first messaging context");
-
- torture_assert(tctx, data->msg_ctx2 = messaging_init(tctx, MSG_ID2, data->ev),
- "Failed to init second messaging context");
+ torture_assert(tctx, data->msg_ctx1 =
+ messaging_init(tctx,
+ cluster_id(MSG_ID1), data->ev),
+ "Failed to init first messaging context");
+
+ torture_assert(tctx, data->msg_ctx2 =
+ messaging_init(tctx,
+ cluster_id(MSG_ID2), data->ev),
+ "Failed to init second messaging context");
/* register the server side function */
IRPC_REGISTER(data->msg_ctx1, rpcecho, ECHO_ADDONE, irpc_AddOne, NULL);
static uint32_t msg_pong;
static void ping_message(struct messaging_context *msg, void *private,
- uint32_t msg_type, uint32_t src, DATA_BLOB *data)
+ uint32_t msg_type, struct server_id src, DATA_BLOB *data)
{
NTSTATUS status;
status = messaging_send(msg, src, msg_pong, data);
}
static void pong_message(struct messaging_context *msg, void *private,
- uint32_t msg_type, uint32_t src, DATA_BLOB *data)
+ uint32_t msg_type, struct server_id src, DATA_BLOB *data)
{
int *count = private;
(*count)++;
}
static void exit_message(struct messaging_context *msg, void *private,
- uint32_t msg_type, uint32_t src, DATA_BLOB *data)
+ uint32_t msg_type, struct server_id src, DATA_BLOB *data)
{
talloc_free(private);
exit(0);
ev = event_context_init(mem_ctx);
- msg_server_ctx = messaging_init(mem_ctx, 1, ev);
+ msg_server_ctx = messaging_init(mem_ctx, cluster_id(1), ev);
torture_assert(tctx, msg_server_ctx != NULL, "Failed to init ping messaging context");
messaging_register_tmp(msg_server_ctx, NULL, ping_message, &msg_ping);
messaging_register_tmp(msg_server_ctx, mem_ctx, exit_message, &msg_exit);
- msg_client_ctx = messaging_init(mem_ctx, 2, ev);
+ msg_client_ctx = messaging_init(mem_ctx, cluster_id(2), ev);
torture_assert(tctx, msg_client_ctx != NULL, "msg_client_ctx messaging_init() failed");
data.data = discard_const_p(uint8_t, "testing");
data.length = strlen((const char *)data.data);
- status1 = messaging_send(msg_client_ctx, 1, msg_ping, &data);
- status2 = messaging_send(msg_client_ctx, 1, msg_ping, NULL);
+ status1 = messaging_send(msg_client_ctx, cluster_id(1), msg_ping, &data);
+ status2 = messaging_send(msg_client_ctx, cluster_id(1), msg_ping, NULL);
torture_assert_ntstatus_ok(tctx, status1, "msg1 failed");
ping_count++;
}
torture_comment(tctx, "sending exit");
- messaging_send(msg_client_ctx, 1, msg_exit, NULL);
+ messaging_send(msg_client_ctx, cluster_id(1), msg_exit, NULL);
torture_assert_int_equal(tctx, ping_count, pong_count, "ping test failed");
struct get_dom_info_state *state =
talloc_get_type(ctx->async.private_data,
struct get_dom_info_state);
- uint32_t *nbt_servers;
+ struct server_id *nbt_servers;
struct irpc_request *ireq;
state->ctx->status = resolve_name_recv(ctx, state->info,
nbt_servers = irpc_servers_byname(state->service->task->msg_ctx,
"nbt_server");
- if ((nbt_servers == NULL) || (nbt_servers[0] == 0)) {
+ if ((nbt_servers == NULL) || (nbt_servers[0].id == 0)) {
composite_error(state->ctx, NT_STATUS_NO_LOGON_SERVERS);
return;
}
static NTSTATUS r_do_late_release_demand(struct r_do_challenge_state *state)
{
struct irpc_request *ireq;
- uint32_t *nbt_servers;
+ struct server_id *nbt_servers;
struct nbtd_proxy_wins_release_demand r;
uint32_t i;
nbt_name_string(state, &state->replica.name)));
nbt_servers = irpc_servers_byname(state->msg_ctx, "nbt_server");
- if ((nbt_servers == NULL) || (nbt_servers[0] == 0)) {
+ if ((nbt_servers == NULL) || (nbt_servers[0].id == 0)) {
return NT_STATUS_INTERNAL_ERROR;
}
{
struct irpc_request *ireq;
struct r_do_challenge_state *state;
- uint32_t *nbt_servers;
+ struct server_id *nbt_servers;
const char **addrs;
uint32_t i;
talloc_steal(state, replica->addresses);
nbt_servers = irpc_servers_byname(state->msg_ctx, "nbt_server");
- if ((nbt_servers == NULL) || (nbt_servers[0] == 0)) {
+ if ((nbt_servers == NULL) || (nbt_servers[0].id == 0)) {
return NT_STATUS_INTERNAL_ERROR;
}
{
NTSTATUS status;
struct irpc_request *ireq;
- uint32_t *nbt_servers;
+ struct server_id *nbt_servers;
const char **addrs;
struct winsdb_addr **addresses;
struct nbtd_proxy_wins_release_demand r;
nbt_name_string(mem_ctx, &replica->name)));
nbt_servers = irpc_servers_byname(partner->service->task->msg_ctx, "nbt_server");
- if ((nbt_servers == NULL) || (nbt_servers[0] == 0)) {
+ if ((nbt_servers == NULL) || (nbt_servers[0].id == 0)) {
return NT_STATUS_INTERNAL_ERROR;
}
const char *now_timestr;
struct irpc_request *ireq;
struct verify_state *s;
- uint32_t *nbt_servers;
+ struct server_id *nbt_servers;
nbt_servers = irpc_servers_byname(service->task->msg_ctx, "nbt_server");
- if ((nbt_servers == NULL) || (nbt_servers[0] == 0)) {
+ if ((nbt_servers == NULL) || (nbt_servers[0].id == 0)) {
return NT_STATUS_INTERNAL_ERROR;
}