/* The following definitions come from libsmb/conncache.c */
-NTSTATUS check_negative_conn_cache( const char *domain, const char *server);
+bool has_negative_conn_cache_entry( const char *domain, const char *server);
void add_failed_connection_entry(const char *domain, const char *server, NTSTATUS result) ;
void flush_negative_conn_cache_for_domain(const char *domain);
cldap_reply = &responses[i]->data.nt5_ex;
if (cldap_reply->pdc_dns_name != NULL) {
- status = check_negative_conn_cache(
+ bool has_entry = has_negative_conn_cache_entry(
realm,
cldap_reply->pdc_dns_name);
- if (!NT_STATUS_IS_OK(status)) {
+ if (has_entry) {
/* propagate blacklisting from name to ip */
add_failed_connection_entry(realm, addr, status);
continue;
for (i = 0; i < count; i++) {
char server[INET6_ADDRSTRLEN];
+ bool has_entry = false;
int ret;
if (is_zero_addr(&sa_list[i].u.ss)) {
print_sockaddr(server, sizeof(server), &sa_list[i].u.ss);
- status = check_negative_conn_cache(domain, server);
- if (!NT_STATUS_IS_OK(status)) {
+ has_entry = has_negative_conn_cache_entry(domain, server);
+ if (has_entry) {
continue;
}
cldap_reply = &responses[i]->data.nt5_ex;
if (cldap_reply->pdc_dns_name != NULL) {
- status = check_negative_conn_cache(
+ bool has_entry = has_negative_conn_cache_entry(
domain,
cldap_reply->pdc_dns_name);
- if (!NT_STATUS_IS_OK(status)) {
+ if (has_entry) {
/*
* only use the server if it's not black listed
* by name
if (*realm) {
for (i = 0; i < count; ++i) {
char server[INET6_ADDRSTRLEN];
+ bool has_entry;
print_sockaddr(server, sizeof(server), &sa_list[i].u.ss);
- if(!NT_STATUS_IS_OK(
- check_negative_conn_cache(realm, server))) {
+ has_entry = has_negative_conn_cache_entry(
+ realm,
+ server);
+ if (has_entry) {
/* Ensure we add the workgroup name for this
IP address as negative too. */
add_failed_connection_entry(
#include "includes.h"
#include "lib/gencache.h"
+#include "ntstatus.h"
/**
* @file
*
* @param[in] domain
* @param[in] server may be either a FQDN or an IP address
- * @return The cached failure status
- * @retval NT_STATUS_OK returned if no record is found or an error occurs
+ *
+ * @retval true if there is an entry, false otherwise
*/
-NTSTATUS check_negative_conn_cache( const char *domain, const char *server)
+bool has_negative_conn_cache_entry(const char *domain, const char *server)
{
- NTSTATUS result = NT_STATUS_OK;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+ bool has_entry = false;
char *key = NULL;
char *value = NULL;
if (key == NULL)
goto done;
- if (gencache_get(key, talloc_tos(), &value, NULL))
+ if (gencache_get(key, talloc_tos(), &value, NULL)) {
+ /* result is the NTSTATUS value from the failed connection */
result = negative_conn_cache_valuedecode(value);
- done:
- DBG_PREFIX(NT_STATUS_IS_OK(result) ? DBGLVL_DEBUG : DBGLVL_INFO,
- ("returning result %s for domain %s "
- "server %s\n", nt_errstr(result), domain, server));
+ has_entry = !NT_STATUS_IS_OK(result);
+ }
+
+done:
+ if (has_entry) {
+ DBG_INFO("Found negative entry for domain %s and server %s - "
+ "reason: %s",
+ domain,
+ server,
+ nt_errstr(result));
+ } else {
+ DBG_DEBUG("No negative entry for domain %s and server %s\n",
+ domain,
+ server);
+ }
+
TALLOC_FREE(key);
TALLOC_FREE(value);
- return result;
+
+ return has_entry;
}
/**
for(i = 0; i < numdcs; i++) {
/* Copy all the IP addresses from the SRV response */
size_t j;
+ bool has_entry = false;
- status = check_negative_conn_cache(name, dcs[i].hostname);
- if (!NT_STATUS_IS_OK(status)) {
+ has_entry = has_negative_conn_cache_entry(name,
+ dcs[i].hostname);
+ if (has_entry) {
DBG_DEBUG("Skipping blacklisted server [%s] "
"for domain [%s]", dcs[i].hostname, name);
continue;
DBG_DEBUG("SRV lookup %s got IP[%zu] %s\n",
name, j, addr);
- status = check_negative_conn_cache(name, addr);
- if (!NT_STATUS_IS_OK(status)) {
+ has_entry = has_negative_conn_cache_entry(name, addr);
+ if (has_entry) {
DBG_DEBUG("Skipping blacklisted server [%s] "
"for domain [%s]", addr, name);
continue;
size_t j;
for (j=0; j<auto_count; j++) {
char addr[INET6_ADDRSTRLEN];
+ bool has_entry;
+
print_sockaddr(addr,
sizeof(addr),
&auto_sa_list[j].u.ss);
/* Check for and don't copy any
* known bad DC IP's. */
- if(!NT_STATUS_IS_OK(check_negative_conn_cache(
+ has_entry = has_negative_conn_cache_entry(
domain,
- addr))) {
+ addr);
+ if (has_entry) {
DEBUG(5,("get_dc_list: "
"negative entry %s removed "
"from DC list\n",
* handle names & IP addresses */
if (resolve_name(name, &name_sa.u.ss, 0x20, true)) {
char addr[INET6_ADDRSTRLEN];
+ bool has_entry;
bool ok;
/*
&name_sa.u.ss);
/* Check for and don't copy any known bad DC IP's. */
- if( !NT_STATUS_IS_OK(check_negative_conn_cache(domain,
- addr)) ) {
+ has_entry = has_negative_conn_cache_entry(
+ domain,
+ addr);
+ if (has_entry) {
DEBUG(5,("get_dc_list: negative entry %s "
"removed from DC list\n",
name ));
continue;
if (name_status_find(domain, 0x1c, 0x20, &sa_list[i].u.ss, srv_name)) {
- result = check_negative_conn_cache( domain, srv_name );
- if ( NT_STATUS_IS_OK(result) ) {
+ bool has_entry = has_negative_conn_cache_entry(domain,
+ srv_name);
+ if (!has_entry) {
dc_ss = sa_list[i].u.ss;
goto done;
}
struct dc_name_ip **dcs, int *num)
{
int i = 0;
+ bool has_entry;
- if (!NT_STATUS_IS_OK(check_negative_conn_cache(domain_name, dcname))) {
+ has_entry = has_negative_conn_cache_entry(domain_name, dcname);
+ if (has_entry) {
DEBUG(10, ("DC %s was in the negative conn cache\n", dcname));
return False;
}
lp_client_smb_transports());
struct loadparm_context *lp_ctx = NULL;
NTSTATUS status;
+ bool has_entry;
bool ok;
/*
* down may have triggered the reconnection.
*/
if (saf_servername != NULL) {
- status = check_negative_conn_cache(domain->name,
- saf_servername);
- if (!NT_STATUS_IS_OK(status)) {
+ has_entry = has_negative_conn_cache_entry(domain->name,
+ saf_servername);
+ if (has_entry) {
saf_servername = NULL;
}
}
return false;
}
- status = check_negative_conn_cache(domain->name, domain->dcname);
- if (!NT_STATUS_IS_OK(status)) {
+ has_entry = has_negative_conn_cache_entry(domain->name, domain->dcname);
+ if (has_entry) {
return false;
}