From: Stefan Metzmacher Date: Thu, 25 Jun 2020 13:59:42 +0000 (+0200) Subject: s3:smbd: disconnect the all client connections if a ctdb public ip dropped X-Git-Tag: samba-4.13.0rc1~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79eaa196dc8549ac4676ac055543bf0bfa542264;p=thirdparty%2Fsamba.git s3:smbd: disconnect the all client connections if a ctdb public ip dropped For now we keep it simple and any disconnect on a connection that used a ctdb public address, will disconnect all other remaining connections. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11898 Signed-off-by: Stefan Metzmacher Reviewed-by: Günther Deschner --- diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 968a6a5cab8..fcf33a699c6 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -361,6 +361,7 @@ struct smbXsrv_connection { const struct tsocket_address *local_address; const struct tsocket_address *remote_address; const char *remote_hostname; + bool has_ctdb_public_ip; enum protocol_types protocol; diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 011d8702291..2bff5bf5a8f 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -2802,6 +2802,25 @@ static NTSTATUS smbd_register_ips(struct smbXsrv_connection *xconn, return NT_STATUS_NO_MEMORY; } + if (xconn->client->server_multi_channel_enabled) { + struct ctdb_public_ip_list_old *ips = NULL; + + ret = ctdbd_control_get_public_ips(cconn, + 0, /* flags */ + state, + &ips); + if (ret != 0) { + return NT_STATUS_INTERNAL_ERROR; + } + + xconn->has_ctdb_public_ip = ctdbd_find_in_public_ips(ips, srv); + TALLOC_FREE(ips); + if (xconn->has_ctdb_public_ip) { + DBG_DEBUG("CTDB public ip on %s\n", + smbXsrv_connection_dbg(xconn)); + } + } + ret = ctdbd_register_ips(cconn, srv, clnt, release_ip, state); if (ret != 0) { return map_nt_error_from_unix(ret); diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c index 20ac3da34c6..cf9de185c1f 100644 --- a/source3/smbd/smb2_server.c +++ b/source3/smbd/smb2_server.c @@ -1635,6 +1635,22 @@ void smbd_server_connection_terminate_ex(struct smbXsrv_connection *xconn, smbXsrv_connection_dbg(xconn), num_ok, reason, location); + if (xconn->has_ctdb_public_ip) { + /* + * If the connection has a ctdb public address + * we disconnect all client connections, + * as the public address might be moved to + * a different node. + * + * In future we may recheck which node currently + * holds this address, but for now we keep it simple. + */ + smbd_server_disconnect_client_ex(xconn->client, + reason, + location); + return; + } + if (num_ok != 0) { struct tevent_req *subreq = NULL;