1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

ctdbd_conn: Move release_ip handling into process.c

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Jul 14 09:56:25 CEST 2015 on sn-devel-104
This commit is contained in:
Volker Lendecke 2015-06-23 19:07:44 +02:00
parent 55233940c6
commit 539125c99d
4 changed files with 32 additions and 63 deletions

View File

@ -75,8 +75,10 @@ NTSTATUS ctdbd_traverse(uint32_t db_id,
NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
const struct sockaddr_storage *server,
const struct sockaddr_storage *client,
bool (*release_ip_handler)(const char *ip_addr,
void *private_data),
int (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
uint64_t dst_srvid,
const uint8_t *msg, size_t msglen,
void *private_data),
void *private_data);
NTSTATUS ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode,

View File

@ -49,8 +49,10 @@ NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
const struct sockaddr_storage *_server,
const struct sockaddr_storage *_client,
bool (*release_ip_handler)(const char *ip_addr,
void *private_data),
int (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
uint64_t dst_srvid,
const uint8_t *msg, size_t msglen,
void *private_data),
void *private_data)
{
return NT_STATUS_NOT_IMPLEMENTED;

View File

@ -50,9 +50,6 @@ struct ctdbd_connection {
struct ctdbd_srvid_cb *callbacks;
int fd;
struct tevent_fd *fde;
bool (*release_ip_handler)(const char *ip_addr, void *private_data);
void *release_ip_priv;
};
static uint32_t ctdbd_next_reqid(struct ctdbd_connection *conn)
@ -399,30 +396,6 @@ static int ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid,
goto next_pkt;
}
if ((conn->release_ip_handler != NULL)
&& (msg->srvid == CTDB_SRVID_RELEASE_IP)) {
bool ok;
/* must be dispatched immediately */
DEBUG(10, ("received CTDB_SRVID_RELEASE_IP\n"));
ok = conn->release_ip_handler((const char *)msg->data,
conn->release_ip_priv);
TALLOC_FREE(hdr);
if (ok) {
/*
* We need to release the ip,
* so return an error to the upper layers.
*
* We make sure we don't trigger this again.
*/
conn->release_ip_handler = NULL;
conn->release_ip_priv = NULL;
return EADDRNOTAVAIL;
}
goto next_pkt;
}
ret = ctdbd_msg_call_back(conn, msg);
if (ret != 0) {
TALLOC_FREE(hdr);
@ -562,26 +535,6 @@ static int ctdb_handle_message(struct ctdbd_connection *conn,
msg = (struct ctdb_req_message *)hdr;
if ((conn->release_ip_handler != NULL)
&& (msg->srvid == CTDB_SRVID_RELEASE_IP)) {
bool ret;
/* must be dispatched immediately */
DEBUG(10, ("received CTDB_SRVID_RELEASE_IP\n"));
ret = conn->release_ip_handler((const char *)msg->data,
conn->release_ip_priv);
if (ret) {
/*
* We need to release the ip.
*
* We make sure we don't trigger this again.
*/
conn->release_ip_handler = NULL;
conn->release_ip_priv = NULL;
}
return 0;
}
ctdbd_msg_call_back(conn, msg);
return 0;
@ -1499,8 +1452,10 @@ static void smbd_ctdb_canonicalize_ip(const struct sockaddr_storage *in,
NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
const struct sockaddr_storage *_server,
const struct sockaddr_storage *_client,
bool (*release_ip_handler)(const char *ip_addr,
void *private_data),
int (*cb)(uint32_t src_vnn, uint32_t dst_vnn,
uint64_t dst_srvid,
const uint8_t *msg, size_t msglen,
void *private_data),
void *private_data)
{
struct ctdb_control_tcp_addr p;
@ -1512,7 +1467,6 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
/*
* Only one connection so far
*/
SMB_ASSERT(conn->release_ip_handler == NULL);
smbd_ctdb_canonicalize_ip(_client, &client);
smbd_ctdb_canonicalize_ip(_server, &server);
@ -1530,14 +1484,12 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
return NT_STATUS_INTERNAL_ERROR;
}
conn->release_ip_handler = release_ip_handler;
conn->release_ip_priv = private_data;
/*
* We want to be told about IP releases
*/
status = register_with_ctdbd(conn, CTDB_SRVID_RELEASE_IP, NULL, NULL);
status = register_with_ctdbd(conn, CTDB_SRVID_RELEASE_IP,
cb, private_data);
if (!NT_STATUS_IS_OK(status)) {
return status;
}

View File

@ -2616,18 +2616,31 @@ static void smbd_release_ip_immediate(struct tevent_context *ctx,
/****************************************************************************
received when we should release a specific IP
****************************************************************************/
static bool release_ip(const char *ip, void *priv)
static int release_ip(uint32_t src_vnn, uint32_t dst_vnn,
uint64_t dst_srvid,
const uint8_t *msg, size_t msglen,
void *private_data)
{
struct smbd_release_ip_state *state =
talloc_get_type_abort(priv,
talloc_get_type_abort(private_data,
struct smbd_release_ip_state);
struct smbXsrv_connection *xconn = state->xconn;
const char *ip;
const char *addr = state->addr;
const char *p = addr;
if (msglen == 0) {
return 0;
}
if (msg[msglen-1] != '\0') {
return 0;
}
ip = (const char *)msg;
if (!NT_STATUS_IS_OK(xconn->transport.status)) {
/* avoid recursion */
return false;
return 0;
}
if (strncmp("::ffff:", addr, 7) == 0) {
@ -2668,10 +2681,10 @@ static bool release_ip(const char *ip, void *priv)
* Make sure we don't get any io on the connection.
*/
xconn->transport.status = NT_STATUS_ADDRESS_CLOSED;
return true;
return EADDRNOTAVAIL;
}
return false;
return 0;
}
static NTSTATUS smbd_register_ips(struct smbXsrv_connection *xconn,