| 1 |
/* back-asyncmeta.h - main header file for back-asyncmeta module */ |
| 2 |
/* $OpenLDAP$ */ |
| 3 |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
| 4 |
* |
| 5 |
* Copyright 2016-2024 The OpenLDAP Foundation. |
| 6 |
* Portions Copyright 2016 Symas Corporation. |
| 7 |
* All rights reserved. |
| 8 |
* |
| 9 |
* Redistribution and use in source and binary forms, with or without |
| 10 |
* modification, are permitted only as authorized by the OpenLDAP |
| 11 |
* Public License. |
| 12 |
* |
| 13 |
* A copy of this license is available in the file LICENSE in the |
| 14 |
* top-level directory of the distribution or, alternatively, at |
| 15 |
* <http://www.OpenLDAP.org/license.html>. |
| 16 |
*/ |
| 17 |
|
| 18 |
/* ACKNOWLEDGEMENTS: |
| 19 |
* This work was developed by Symas Corporation |
| 20 |
* based on back-meta module for inclusion in OpenLDAP Software. |
| 21 |
* This work was sponsored by Ericsson. */ |
| 22 |
|
| 23 |
#ifndef SLAPD_LDAP_H |
| 24 |
#error "include servers/slapd/back-ldap/back-ldap.h before this file!" |
| 25 |
#endif /* SLAPD_LDAP_H */ |
| 26 |
|
| 27 |
#ifndef SLAPD_ASYNCMETA_H |
| 28 |
#define SLAPD_ASYNCMETA_H |
| 29 |
|
| 30 |
#ifdef LDAP_DEVEL |
| 31 |
#define SLAPD_META_CLIENT_PR 1 |
| 32 |
#endif /* LDAP_DEVEL */ |
| 33 |
|
| 34 |
#include "proto-asyncmeta.h" |
| 35 |
|
| 36 |
#include "ldap_rq.h" |
| 37 |
|
| 38 |
LDAP_BEGIN_DECL |
| 39 |
|
| 40 |
/* |
| 41 |
* Set META_BACK_PRINT_CONNTREE larger than 0 to dump the connection tree (debug only) |
| 42 |
*/ |
| 43 |
#ifndef META_BACK_PRINT_CONNTREE |
| 44 |
#define META_BACK_PRINT_CONNTREE 0 |
| 45 |
#endif /* !META_BACK_PRINT_CONNTREE */ |
| 46 |
|
| 47 |
/* |
| 48 |
* A a_metasingleconn_t can be in the following, mutually exclusive states: |
| 49 |
* |
| 50 |
* - none (0x0U) |
| 51 |
* - creating META_BACK_FCONN_CREATING |
| 52 |
* - initialized META_BACK_FCONN_INITED |
| 53 |
* - binding LDAP_BACK_FCONN_BINDING |
| 54 |
* - bound/anonymous LDAP_BACK_FCONN_ISBOUND/LDAP_BACK_FCONN_ISANON |
| 55 |
* |
| 56 |
* possible modifiers are: |
| 57 |
* |
| 58 |
* - privileged LDAP_BACK_FCONN_ISPRIV |
| 59 |
* - privileged, TLS LDAP_BACK_FCONN_ISTLS |
| 60 |
* - subjected to idassert LDAP_BACK_FCONN_ISIDASR |
| 61 |
* - tainted LDAP_BACK_FCONN_TAINTED |
| 62 |
*/ |
| 63 |
|
| 64 |
#define META_BACK_FCONN_INITED (0x00100000U) |
| 65 |
#define META_BACK_FCONN_CREATING (0x00200000U) |
| 66 |
#define META_BACK_FCONN_INVALID (0x00400000U) |
| 67 |
|
| 68 |
#define META_BACK_CONN_INITED(lc) LDAP_BACK_CONN_ISSET((lc), META_BACK_FCONN_INITED) |
| 69 |
#define META_BACK_CONN_INITED_SET(lc) LDAP_BACK_CONN_SET((lc), META_BACK_FCONN_INITED) |
| 70 |
#define META_BACK_CONN_INITED_CLEAR(lc) LDAP_BACK_CONN_CLEAR((lc), META_BACK_FCONN_INITED) |
| 71 |
#define META_BACK_CONN_INITED_CPY(lc, mlc) LDAP_BACK_CONN_CPY((lc), META_BACK_FCONN_INITED, (mlc)) |
| 72 |
#define META_BACK_CONN_CREATING(lc) LDAP_BACK_CONN_ISSET((lc), META_BACK_FCONN_CREATING) |
| 73 |
#define META_BACK_CONN_CREATING_SET(lc) LDAP_BACK_CONN_SET((lc), META_BACK_FCONN_CREATING) |
| 74 |
#define META_BACK_CONN_CREATING_CLEAR(lc) LDAP_BACK_CONN_CLEAR((lc), META_BACK_FCONN_CREATING) |
| 75 |
#define META_BACK_CONN_CREATING_CPY(lc, mlc) LDAP_BACK_CONN_CPY((lc), META_BACK_FCONN_CREATING, (mlc)) |
| 76 |
#define META_BACK_CONN_INVALID(lc) LDAP_BACK_CONN_ISSET((lc), META_BACK_FCONN_INVALID) |
| 77 |
#define META_BACK_CONN_INVALID_SET(lc) LDAP_BACK_CONN_SET((lc), META_BACK_FCONN_INVALID) |
| 78 |
#define META_BACK_CONN_INVALID_CLEAR(lc) LDAP_BACK_CONN_CLEAR((lc), META_BACK_FCONN_INVALID) |
| 79 |
|
| 80 |
struct a_metainfo_t; |
| 81 |
struct a_metaconn_t; |
| 82 |
struct a_metatarget_t; |
| 83 |
#define META_NOT_CANDIDATE ((ber_tag_t)0x0) |
| 84 |
#define META_CANDIDATE ((ber_tag_t)0x1) |
| 85 |
#define META_BINDING ((ber_tag_t)0x2) |
| 86 |
#define META_RETRYING ((ber_tag_t)0x4) |
| 87 |
|
| 88 |
typedef struct bm_context_t { |
| 89 |
LDAP_STAILQ_ENTRY(bm_context_t) bc_next; |
| 90 |
struct a_metaconn_t *bc_mc; |
| 91 |
time_t timeout; |
| 92 |
time_t stoptime; |
| 93 |
ldap_back_send_t sendok; |
| 94 |
ldap_back_send_t retrying; |
| 95 |
int candidate_match; |
| 96 |
volatile int bc_active; |
| 97 |
int searchtime; /* stoptime is a search timelimit */ |
| 98 |
int is_ok; |
| 99 |
int is_root; |
| 100 |
volatile sig_atomic_t bc_invalid; |
| 101 |
SlapReply rs; |
| 102 |
Operation *op; |
| 103 |
Operation copy_op; |
| 104 |
LDAPControl **ctrls; |
| 105 |
int *msgids; |
| 106 |
int *nretries; /* number of times to retry a failed send on an msc */ |
| 107 |
struct berval c_peer_name; /* peer name of original op->o_conn*/ |
| 108 |
SlapReply *candidates; |
| 109 |
} bm_context_t; |
| 110 |
|
| 111 |
typedef struct a_metasingleconn_t { |
| 112 |
#define META_CND_ISSET(rs,f) ( ( (rs)->sr_tag & (f) ) == (f) ) |
| 113 |
#define META_CND_SET(rs,f) ( (rs)->sr_tag |= (f) ) |
| 114 |
#define META_CND_CLEAR(rs,f) ( (rs)->sr_tag &= ~(f) ) |
| 115 |
|
| 116 |
#define META_CANDIDATE_RESET(rs) ( (rs)->sr_tag = 0 ) |
| 117 |
#define META_IS_CANDIDATE(rs) META_CND_ISSET( (rs), META_CANDIDATE ) |
| 118 |
#define META_CANDIDATE_SET(rs) META_CND_SET( (rs), META_CANDIDATE ) |
| 119 |
#define META_CANDIDATE_CLEAR(rs) META_CND_CLEAR( (rs), META_CANDIDATE ) |
| 120 |
#define META_IS_BINDING(rs) META_CND_ISSET( (rs), META_BINDING ) |
| 121 |
#define META_BINDING_SET(rs) META_CND_SET( (rs), META_BINDING ) |
| 122 |
#define META_BINDING_CLEAR(rs) META_CND_CLEAR( (rs), META_BINDING ) |
| 123 |
#define META_IS_RETRYING(rs) META_CND_ISSET( (rs), META_RETRYING ) |
| 124 |
#define META_RETRYING_SET(rs) META_CND_SET( (rs), META_RETRYING ) |
| 125 |
#define META_RETRYING_CLEAR(rs) META_CND_CLEAR( (rs), META_RETRYING ) |
| 126 |
|
| 127 |
LDAP *msc_ld; |
| 128 |
LDAP *msc_ldr; |
| 129 |
time_t msc_time; |
| 130 |
time_t msc_binding_time; |
| 131 |
time_t msc_result_time; |
| 132 |
struct berval msc_bound_ndn; |
| 133 |
struct berval msc_cred; |
| 134 |
unsigned msc_mscflags; |
| 135 |
|
| 136 |
/* NOTE: lc_lcflags is redefined to msc_mscflags to reuse the macros |
| 137 |
* defined for back-ldap */ |
| 138 |
#define lc_lcflags msc_mscflags |
| 139 |
volatile int msc_active; |
| 140 |
/* Connection for the select */ |
| 141 |
Connection *conn; |
| 142 |
} a_metasingleconn_t; |
| 143 |
|
| 144 |
typedef struct a_metaconn_t { |
| 145 |
ldapconn_base_t lc_base; |
| 146 |
#define mc_base lc_base |
| 147 |
//#define mc_conn mc_base.lcb_conn |
| 148 |
//#define mc_local_ndn mc_base.lcb_local_ndn |
| 149 |
//#define mc_refcnt mc_base.lcb_refcnt |
| 150 |
//#define mc_create_time mc_base.lcb_create_time |
| 151 |
//#define mc_time mc_base.lcb_time |
| 152 |
|
| 153 |
LDAP_TAILQ_ENTRY(a_metaconn_t) mc_q; |
| 154 |
|
| 155 |
/* NOTE: msc_mscflags is used to recycle the #define |
| 156 |
* in metasingleconn_t */ |
| 157 |
unsigned msc_mscflags; |
| 158 |
int mc_active; |
| 159 |
|
| 160 |
/* |
| 161 |
* means that the connection is bound; |
| 162 |
* of course only one target actually is ... |
| 163 |
*/ |
| 164 |
int mc_authz_target; |
| 165 |
#define META_BOUND_NONE (-1) |
| 166 |
#define META_BOUND_ALL (-2) |
| 167 |
|
| 168 |
struct a_metainfo_t *mc_info; |
| 169 |
|
| 170 |
int pending_ops; |
| 171 |
ldap_pvt_thread_mutex_t mc_om_mutex; |
| 172 |
/* queue for pending operations */ |
| 173 |
LDAP_STAILQ_HEAD(BCList, bm_context_t) mc_om_list; |
| 174 |
/* supersedes the connection stuff */ |
| 175 |
a_metasingleconn_t *mc_conns; |
| 176 |
} a_metaconn_t; |
| 177 |
|
| 178 |
typedef enum meta_st_t { |
| 179 |
#if 0 /* todo */ |
| 180 |
META_ST_EXACT = LDAP_SCOPE_BASE, |
| 181 |
#endif |
| 182 |
META_ST_SUBTREE = LDAP_SCOPE_SUBTREE, |
| 183 |
META_ST_SUBORDINATE = LDAP_SCOPE_SUBORDINATE, |
| 184 |
META_ST_REGEX /* last + 1 */ |
| 185 |
} meta_st_t; |
| 186 |
|
| 187 |
typedef struct a_metasubtree_t { |
| 188 |
meta_st_t ms_type; |
| 189 |
union { |
| 190 |
struct berval msu_dn; |
| 191 |
struct { |
| 192 |
struct berval msr_regex_pattern; |
| 193 |
regex_t msr_regex; |
| 194 |
} msu_regex; |
| 195 |
} ms_un; |
| 196 |
#define ms_dn ms_un.msu_dn |
| 197 |
#define ms_regex ms_un.msu_regex.msr_regex |
| 198 |
#define ms_regex_pattern ms_un.msu_regex.msr_regex_pattern |
| 199 |
|
| 200 |
struct a_metasubtree_t *ms_next; |
| 201 |
} a_metasubtree_t; |
| 202 |
|
| 203 |
typedef struct metafilter_t { |
| 204 |
struct metafilter_t *mf_next; |
| 205 |
struct berval mf_regex_pattern; |
| 206 |
regex_t mf_regex; |
| 207 |
} metafilter_t; |
| 208 |
|
| 209 |
typedef struct a_metacommon_t { |
| 210 |
int mc_version; |
| 211 |
int mc_nretries; |
| 212 |
#define META_RETRY_UNDEFINED (-2) |
| 213 |
#define META_RETRY_FOREVER (-1) |
| 214 |
#define META_RETRY_NEVER (0) |
| 215 |
#define META_RETRY_DEFAULT (2) |
| 216 |
|
| 217 |
unsigned mc_flags; |
| 218 |
#define META_BACK_CMN_ISSET(mc,f) ( ( (mc)->mc_flags & (f) ) == (f) ) |
| 219 |
#define META_BACK_CMN_QUARANTINE(mc) META_BACK_CMN_ISSET( (mc), LDAP_BACK_F_QUARANTINE ) |
| 220 |
#define META_BACK_CMN_CHASE_REFERRALS(mc) META_BACK_CMN_ISSET( (mc), LDAP_BACK_F_CHASE_REFERRALS ) |
| 221 |
#define META_BACK_CMN_NOREFS(mc) META_BACK_CMN_ISSET( (mc), LDAP_BACK_F_NOREFS ) |
| 222 |
#define META_BACK_CMN_NOUNDEFFILTER(mc) META_BACK_CMN_ISSET( (mc), LDAP_BACK_F_NOUNDEFFILTER ) |
| 223 |
#define META_BACK_CMN_SAVECRED(mc) META_BACK_CMN_ISSET( (mc), LDAP_BACK_F_SAVECRED ) |
| 224 |
#define META_BACK_CMN_ST_REQUEST(mc) META_BACK_CMN_ISSET( (mc), LDAP_BACK_F_ST_REQUEST ) |
| 225 |
|
| 226 |
#ifdef SLAPD_META_CLIENT_PR |
| 227 |
/* |
| 228 |
* client-side paged results: |
| 229 |
* -1: accept unsolicited paged results responses |
| 230 |
* 0: off |
| 231 |
* >0: always request paged results with size == mt_ps |
| 232 |
*/ |
| 233 |
#define META_CLIENT_PR_DISABLE (0) |
| 234 |
#define META_CLIENT_PR_ACCEPT_UNSOLICITED (-1) |
| 235 |
ber_int_t mc_ps; |
| 236 |
#endif /* SLAPD_META_CLIENT_PR */ |
| 237 |
|
| 238 |
slap_retry_info_t mc_quarantine; |
| 239 |
time_t mc_network_timeout; |
| 240 |
struct timeval mc_bind_timeout; |
| 241 |
#define META_BIND_TIMEOUT LDAP_BACK_RESULT_UTIMEOUT |
| 242 |
time_t mc_timeout[ SLAP_OP_LAST ]; |
| 243 |
} a_metacommon_t; |
| 244 |
|
| 245 |
typedef struct a_metatarget_t { |
| 246 |
char *mt_uri; |
| 247 |
ldap_pvt_thread_mutex_t mt_uri_mutex; |
| 248 |
|
| 249 |
/* TODO: we might want to enable different strategies |
| 250 |
* for different targets */ |
| 251 |
LDAP_REBIND_PROC *mt_rebind_f; |
| 252 |
LDAP_URLLIST_PROC *mt_urllist_f; |
| 253 |
void *mt_urllist_p; |
| 254 |
|
| 255 |
metafilter_t *mt_filter; |
| 256 |
a_metasubtree_t *mt_subtree; |
| 257 |
/* F: subtree-include; T: subtree-exclude */ |
| 258 |
int mt_subtree_exclude; |
| 259 |
|
| 260 |
int mt_scope; |
| 261 |
|
| 262 |
struct berval mt_psuffix; /* pretty suffix */ |
| 263 |
struct berval mt_nsuffix; /* normalized suffix */ |
| 264 |
|
| 265 |
struct berval mt_lsuffixm; /* local suffix for massage */ |
| 266 |
struct berval mt_rsuffixm; /* remote suffix for massage */ |
| 267 |
|
| 268 |
struct berval mt_binddn; |
| 269 |
struct berval mt_bindpw; |
| 270 |
|
| 271 |
/* we only care about the TLS options here */ |
| 272 |
slap_bindconf mt_tls; |
| 273 |
|
| 274 |
slap_idassert_t mt_idassert; |
| 275 |
#define mt_idassert_mode mt_idassert.si_mode |
| 276 |
#define mt_idassert_authcID mt_idassert.si_bc.sb_authcId |
| 277 |
#define mt_idassert_authcDN mt_idassert.si_bc.sb_binddn |
| 278 |
#define mt_idassert_passwd mt_idassert.si_bc.sb_cred |
| 279 |
#define mt_idassert_authzID mt_idassert.si_bc.sb_authzId |
| 280 |
#define mt_idassert_authmethod mt_idassert.si_bc.sb_method |
| 281 |
#define mt_idassert_sasl_mech mt_idassert.si_bc.sb_saslmech |
| 282 |
#define mt_idassert_sasl_realm mt_idassert.si_bc.sb_realm |
| 283 |
#define mt_idassert_secprops mt_idassert.si_bc.sb_secprops |
| 284 |
#define mt_idassert_tls mt_idassert.si_bc.sb_tls |
| 285 |
#define mt_idassert_flags mt_idassert.si_flags |
| 286 |
#define mt_idassert_authz mt_idassert.si_authz |
| 287 |
|
| 288 |
sig_atomic_t mt_isquarantined; |
| 289 |
ldap_pvt_thread_mutex_t mt_quarantine_mutex; |
| 290 |
|
| 291 |
a_metacommon_t mt_mc; |
| 292 |
#define mt_nretries mt_mc.mc_nretries |
| 293 |
#define mt_flags mt_mc.mc_flags |
| 294 |
#define mt_version mt_mc.mc_version |
| 295 |
#define mt_ps mt_mc.mc_ps |
| 296 |
#define mt_network_timeout mt_mc.mc_network_timeout |
| 297 |
#define mt_bind_timeout mt_mc.mc_bind_timeout |
| 298 |
#define mt_timeout mt_mc.mc_timeout |
| 299 |
#define mt_quarantine mt_mc.mc_quarantine |
| 300 |
|
| 301 |
#define META_BACK_TGT_ISSET(mt,f) ( ( (mt)->mt_flags & (f) ) == (f) ) |
| 302 |
#define META_BACK_TGT_ISMASK(mt,m,f) ( ( (mt)->mt_flags & (m) ) == (f) ) |
| 303 |
|
| 304 |
#define META_BACK_TGT_SAVECRED(mt) META_BACK_TGT_ISSET( (mt), LDAP_BACK_F_SAVECRED ) |
| 305 |
|
| 306 |
#define META_BACK_TGT_USE_TLS(mt) META_BACK_TGT_ISSET( (mt), LDAP_BACK_F_USE_TLS ) |
| 307 |
#define META_BACK_TGT_PROPAGATE_TLS(mt) META_BACK_TGT_ISSET( (mt), LDAP_BACK_F_PROPAGATE_TLS ) |
| 308 |
#define META_BACK_TGT_TLS_CRITICAL(mt) META_BACK_TGT_ISSET( (mt), LDAP_BACK_F_TLS_CRITICAL ) |
| 309 |
|
| 310 |
#define META_BACK_TGT_CHASE_REFERRALS(mt) META_BACK_TGT_ISSET( (mt), LDAP_BACK_F_CHASE_REFERRALS ) |
| 311 |
|
| 312 |
#define META_BACK_TGT_T_F(mt) META_BACK_TGT_ISMASK( (mt), LDAP_BACK_F_T_F_MASK, LDAP_BACK_F_T_F ) |
| 313 |
#define META_BACK_TGT_T_F_DISCOVER(mt) META_BACK_TGT_ISMASK( (mt), LDAP_BACK_F_T_F_MASK2, LDAP_BACK_F_T_F_DISCOVER ) |
| 314 |
|
| 315 |
#define META_BACK_TGT_ABANDON(mt) META_BACK_TGT_ISMASK( (mt), LDAP_BACK_F_CANCEL_MASK, LDAP_BACK_F_CANCEL_ABANDON ) |
| 316 |
#define META_BACK_TGT_IGNORE(mt) META_BACK_TGT_ISMASK( (mt), LDAP_BACK_F_CANCEL_MASK, LDAP_BACK_F_CANCEL_IGNORE ) |
| 317 |
#define META_BACK_TGT_CANCEL(mt) META_BACK_TGT_ISMASK( (mt), LDAP_BACK_F_CANCEL_MASK, LDAP_BACK_F_CANCEL_EXOP ) |
| 318 |
#define META_BACK_TGT_CANCEL_DISCOVER(mt) META_BACK_TGT_ISMASK( (mt), LDAP_BACK_F_CANCEL_MASK2, LDAP_BACK_F_CANCEL_EXOP_DISCOVER ) |
| 319 |
#define META_BACK_TGT_QUARANTINE(mt) META_BACK_TGT_ISSET( (mt), LDAP_BACK_F_QUARANTINE ) |
| 320 |
|
| 321 |
#ifdef SLAP_CONTROL_X_SESSION_TRACKING |
| 322 |
#define META_BACK_TGT_ST_REQUEST(mt) META_BACK_TGT_ISSET( (mt), LDAP_BACK_F_ST_REQUEST ) |
| 323 |
#define META_BACK_TGT_ST_RESPONSE(mt) META_BACK_TGT_ISSET( (mt), LDAP_BACK_F_ST_RESPONSE ) |
| 324 |
#endif /* SLAP_CONTROL_X_SESSION_TRACKING */ |
| 325 |
|
| 326 |
#define META_BACK_TGT_NOREFS(mt) META_BACK_TGT_ISSET( (mt), LDAP_BACK_F_NOREFS ) |
| 327 |
#define META_BACK_TGT_NOUNDEFFILTER(mt) META_BACK_TGT_ISSET( (mt), LDAP_BACK_F_NOUNDEFFILTER ) |
| 328 |
|
| 329 |
#define META_BACK_CFG_MAX_PENDING_OPS 0x80 |
| 330 |
#define META_BACK_CFG_MAX_TARGET_CONNS 0xFF |
| 331 |
#define META_BACK_CFG_DEFAULT_OPS_TIMEOUT 0x02 |
| 332 |
|
| 333 |
/* the interval of the timeout checking loop in microseconds |
| 334 |
* possibly make this configurable? */ |
| 335 |
#define META_BACK_CFG_MAX_TIMEOUT_LOOP 0x70000 |
| 336 |
slap_mask_t mt_rep_flags; |
| 337 |
int mt_timeout_ops; |
| 338 |
} a_metatarget_t; |
| 339 |
|
| 340 |
typedef struct a_metadncache_t { |
| 341 |
ldap_pvt_thread_mutex_t mutex; |
| 342 |
Avlnode *tree; |
| 343 |
|
| 344 |
#define META_DNCACHE_DISABLED (0) |
| 345 |
#define META_DNCACHE_FOREVER ((time_t)(-1)) |
| 346 |
time_t ttl; /* seconds; 0: no cache, -1: no expiry */ |
| 347 |
} a_metadncache_t; |
| 348 |
|
| 349 |
typedef struct a_metacandidates_t { |
| 350 |
int mc_ntargets; |
| 351 |
SlapReply *mc_candidates; |
| 352 |
} a_metacandidates_t; |
| 353 |
|
| 354 |
/* |
| 355 |
* Hook to allow mucking with a_metainfo_t/a_metatarget_t when quarantine is over |
| 356 |
*/ |
| 357 |
typedef int (*asyncmeta_quarantine_f)( struct a_metainfo_t *, int target, void * ); |
| 358 |
|
| 359 |
struct meta_out_message_t; |
| 360 |
|
| 361 |
typedef struct a_metainfo_t { |
| 362 |
int mi_ntargets; |
| 363 |
int mi_defaulttarget; |
| 364 |
#define META_DEFAULT_TARGET_NONE (-1) |
| 365 |
|
| 366 |
#define mi_nretries mi_mc.mc_nretries |
| 367 |
#define mi_flags mi_mc.mc_flags |
| 368 |
#define mi_version mi_mc.mc_version |
| 369 |
#define mi_ps mi_mc.mc_ps |
| 370 |
#define mi_network_timeout mi_mc.mc_network_timeout |
| 371 |
#define mi_bind_timeout mi_mc.mc_bind_timeout |
| 372 |
#define mi_timeout mi_mc.mc_timeout |
| 373 |
#define mi_quarantine mi_mc.mc_quarantine |
| 374 |
|
| 375 |
a_metatarget_t **mi_targets; |
| 376 |
a_metacandidates_t *mi_candidates; |
| 377 |
|
| 378 |
LDAP_REBIND_PROC *mi_rebind_f; |
| 379 |
LDAP_URLLIST_PROC *mi_urllist_f; |
| 380 |
|
| 381 |
a_metadncache_t mi_cache; |
| 382 |
|
| 383 |
struct { |
| 384 |
int mic_num; |
| 385 |
LDAP_TAILQ_HEAD(mc_conn_priv_q, a_metaconn_t) mic_priv; |
| 386 |
} mi_conn_priv[ LDAP_BACK_PCONN_LAST ]; |
| 387 |
int mi_conn_priv_max; |
| 388 |
|
| 389 |
/* NOTE: quarantine uses the connection mutex */ |
| 390 |
asyncmeta_quarantine_f mi_quarantine_f; |
| 391 |
void *mi_quarantine_p; |
| 392 |
|
| 393 |
#define li_flags mi_flags |
| 394 |
/* uses flags as defined in <back-ldap/back-ldap.h> */ |
| 395 |
#define META_BACK_F_ONERR_STOP LDAP_BACK_F_ONERR_STOP |
| 396 |
#define META_BACK_F_ONERR_REPORT (0x02000000U) |
| 397 |
#define META_BACK_F_ONERR_MASK (META_BACK_F_ONERR_STOP|META_BACK_F_ONERR_REPORT) |
| 398 |
#define META_BACK_F_DEFER_ROOTDN_BIND (0x04000000U) |
| 399 |
#define META_BACK_F_PROXYAUTHZ_ALWAYS (0x08000000U) /* users always proxyauthz */ |
| 400 |
#define META_BACK_F_PROXYAUTHZ_ANON (0x10000000U) /* anonymous always proxyauthz */ |
| 401 |
#define META_BACK_F_PROXYAUTHZ_NOANON (0x20000000U) /* anonymous remains anonymous */ |
| 402 |
|
| 403 |
#define META_BACK_ONERR_STOP(mi) LDAP_BACK_ISSET( (mi), META_BACK_F_ONERR_STOP ) |
| 404 |
#define META_BACK_ONERR_REPORT(mi) LDAP_BACK_ISSET( (mi), META_BACK_F_ONERR_REPORT ) |
| 405 |
#define META_BACK_ONERR_CONTINUE(mi) ( !LDAP_BACK_ISSET( (mi), META_BACK_F_ONERR_MASK ) ) |
| 406 |
|
| 407 |
#define META_BACK_DEFER_ROOTDN_BIND(mi) LDAP_BACK_ISSET( (mi), META_BACK_F_DEFER_ROOTDN_BIND ) |
| 408 |
#define META_BACK_PROXYAUTHZ_ALWAYS(mi) LDAP_BACK_ISSET( (mi), META_BACK_F_PROXYAUTHZ_ALWAYS ) |
| 409 |
#define META_BACK_PROXYAUTHZ_ANON(mi) LDAP_BACK_ISSET( (mi), META_BACK_F_PROXYAUTHZ_ANON ) |
| 410 |
#define META_BACK_PROXYAUTHZ_NOANON(mi) LDAP_BACK_ISSET( (mi), META_BACK_F_PROXYAUTHZ_NOANON ) |
| 411 |
|
| 412 |
#define META_BACK_QUARANTINE(mi) LDAP_BACK_ISSET( (mi), LDAP_BACK_F_QUARANTINE ) |
| 413 |
|
| 414 |
time_t mi_idle_timeout; |
| 415 |
struct re_s *mi_task; |
| 416 |
|
| 417 |
a_metacommon_t mi_mc; |
| 418 |
ldap_extra_t *mi_ldap_extra; |
| 419 |
|
| 420 |
int mi_max_timeout_ops; |
| 421 |
int mi_max_pending_ops; |
| 422 |
int mi_max_target_conns; |
| 423 |
/* mutex for access to the connection structures */ |
| 424 |
ldap_pvt_thread_mutex_t mi_mc_mutex; |
| 425 |
int mi_num_conns; |
| 426 |
int mi_next_conn; |
| 427 |
a_metaconn_t *mi_conns; |
| 428 |
|
| 429 |
struct berval mi_suffix; |
| 430 |
volatile int mi_disabled; |
| 431 |
} a_metainfo_t; |
| 432 |
|
| 433 |
typedef enum meta_op_type { |
| 434 |
META_OP_ALLOW_MULTIPLE = 0, |
| 435 |
META_OP_REQUIRE_SINGLE, |
| 436 |
META_OP_REQUIRE_ALL |
| 437 |
} meta_op_type; |
| 438 |
|
| 439 |
/* Whatever context asyncmeta_dn_massage needs... */ |
| 440 |
typedef struct a_dncookie { |
| 441 |
Operation *op; |
| 442 |
struct a_metatarget_t *target; |
| 443 |
void *memctx; |
| 444 |
int to_from; |
| 445 |
} a_dncookie; |
| 446 |
|
| 447 |
|
| 448 |
#define MASSAGE_REQ 0 |
| 449 |
#define MASSAGE_REP 1 |
| 450 |
|
| 451 |
extern void |
| 452 |
asyncmeta_dn_massage(a_dncookie *dc, struct berval *dn, |
| 453 |
struct berval *res); |
| 454 |
|
| 455 |
extern void |
| 456 |
asyncmeta_filter_map_rewrite( |
| 457 |
a_dncookie *dc, |
| 458 |
Filter *f, |
| 459 |
struct berval *fstr ); |
| 460 |
|
| 461 |
extern void |
| 462 |
asyncmeta_back_referral_result_rewrite( |
| 463 |
a_dncookie *dc, |
| 464 |
BerVarray a_vals ); |
| 465 |
|
| 466 |
extern a_metaconn_t * |
| 467 |
asyncmeta_getconn( |
| 468 |
Operation *op, |
| 469 |
SlapReply *rs, |
| 470 |
SlapReply *candidates, |
| 471 |
int *candidate, |
| 472 |
ldap_back_send_t sendok, |
| 473 |
int alloc_new); |
| 474 |
|
| 475 |
|
| 476 |
extern int |
| 477 |
asyncmeta_init_one_conn( |
| 478 |
Operation *op, |
| 479 |
SlapReply *rs, |
| 480 |
a_metaconn_t *mc, |
| 481 |
int candidate, |
| 482 |
int ispriv, |
| 483 |
ldap_back_send_t sendok, |
| 484 |
int dolock ); |
| 485 |
|
| 486 |
extern void |
| 487 |
asyncmeta_quarantine( |
| 488 |
Operation *op, |
| 489 |
a_metainfo_t *mi, |
| 490 |
SlapReply *rs, |
| 491 |
int candidate ); |
| 492 |
|
| 493 |
extern int |
| 494 |
asyncmeta_proxy_authz_cred( |
| 495 |
a_metaconn_t *mc, |
| 496 |
int candidate, |
| 497 |
Operation *op, |
| 498 |
SlapReply *rs, |
| 499 |
ldap_back_send_t sendok, |
| 500 |
struct berval *binddn, |
| 501 |
struct berval *bindcred, |
| 502 |
int *method ); |
| 503 |
|
| 504 |
extern int |
| 505 |
asyncmeta_controls_add( |
| 506 |
Operation *op, |
| 507 |
SlapReply *rs, |
| 508 |
a_metaconn_t *mc, |
| 509 |
int candidate, |
| 510 |
int isroot, |
| 511 |
LDAPControl ***pctrls ); |
| 512 |
|
| 513 |
extern int |
| 514 |
asyncmeta_LTX_init_module( |
| 515 |
int argc, |
| 516 |
char *argv[] ); |
| 517 |
|
| 518 |
/* |
| 519 |
* Candidate stuff |
| 520 |
*/ |
| 521 |
extern int |
| 522 |
asyncmeta_is_candidate( |
| 523 |
a_metatarget_t *mt, |
| 524 |
struct berval *ndn, |
| 525 |
int scope ); |
| 526 |
|
| 527 |
extern int |
| 528 |
asyncmeta_select_unique_candidate( |
| 529 |
a_metainfo_t *mi, |
| 530 |
struct berval *ndn ); |
| 531 |
|
| 532 |
extern int |
| 533 |
asyncmeta_clear_unused_candidates( |
| 534 |
Operation *op, |
| 535 |
int candidate, |
| 536 |
a_metaconn_t *mc, |
| 537 |
SlapReply *candidates); |
| 538 |
|
| 539 |
/* |
| 540 |
* Dn cache stuff (experimental) |
| 541 |
*/ |
| 542 |
extern int |
| 543 |
asyncmeta_dncache_cmp( |
| 544 |
const void *c1, |
| 545 |
const void *c2 ); |
| 546 |
|
| 547 |
extern int |
| 548 |
asyncmeta_dncache_dup( |
| 549 |
void *c1, |
| 550 |
void *c2 ); |
| 551 |
|
| 552 |
#define META_TARGET_NONE (-1) |
| 553 |
#define META_TARGET_MULTIPLE (-2) |
| 554 |
extern int |
| 555 |
asyncmeta_dncache_get_target( |
| 556 |
a_metadncache_t *cache, |
| 557 |
struct berval *ndn ); |
| 558 |
|
| 559 |
extern int |
| 560 |
meta_dncache_update_entry( |
| 561 |
a_metadncache_t *cache, |
| 562 |
struct berval *ndn, |
| 563 |
int target ); |
| 564 |
|
| 565 |
extern int |
| 566 |
asyncmeta_dncache_delete_entry( |
| 567 |
a_metadncache_t *cache, |
| 568 |
struct berval *ndn ); |
| 569 |
|
| 570 |
extern void |
| 571 |
asyncmeta_dncache_free( void *entry ); |
| 572 |
|
| 573 |
extern int |
| 574 |
asyncmeta_subtree_destroy( a_metasubtree_t *ms ); |
| 575 |
|
| 576 |
extern void |
| 577 |
asyncmeta_filter_destroy( metafilter_t *mf ); |
| 578 |
|
| 579 |
extern int |
| 580 |
asyncmeta_target_finish( a_metainfo_t *mi, a_metatarget_t *mt, |
| 581 |
const char *log, char *msg, size_t msize |
| 582 |
); |
| 583 |
|
| 584 |
|
| 585 |
extern LDAP_REBIND_PROC asyncmeta_back_default_rebind; |
| 586 |
extern LDAP_URLLIST_PROC asyncmeta_back_default_urllist; |
| 587 |
|
| 588 |
/* IGNORE means that target does not (no longer) participate |
| 589 |
* in the search; |
| 590 |
* NOTREADY means the search on that target has not been initialized yet |
| 591 |
*/ |
| 592 |
#define META_MSGID_IGNORE (-1) |
| 593 |
#define META_MSGID_NEED_BIND (-2) |
| 594 |
#define META_MSGID_CONNECTING (-3) |
| 595 |
#define META_MSGID_UNDEFINED (-4) |
| 596 |
#define META_MSGID_GOT_BIND (-5) |
| 597 |
|
| 598 |
typedef enum meta_search_candidate_t { |
| 599 |
META_SEARCH_UNDEFINED = -2, |
| 600 |
META_SEARCH_ERR = -1, |
| 601 |
META_SEARCH_NOT_CANDIDATE, |
| 602 |
META_SEARCH_CANDIDATE, |
| 603 |
META_SEARCH_BINDING, |
| 604 |
META_SEARCH_NEED_BIND, |
| 605 |
META_SEARCH_CONNECTING |
| 606 |
} meta_search_candidate_t; |
| 607 |
|
| 608 |
Operation* asyncmeta_copy_op(Operation *op); |
| 609 |
void asyncmeta_clear_bm_context(bm_context_t *bc); |
| 610 |
|
| 611 |
int asyncmeta_add_message_queue(a_metaconn_t *mc, bm_context_t *bc); |
| 612 |
void asyncmeta_drop_bc(a_metaconn_t *mc, bm_context_t *bc); |
| 613 |
void asyncmeta_drop_bc_from_fconn(bm_context_t *bc); |
| 614 |
|
| 615 |
bm_context_t * |
| 616 |
asyncmeta_find_message(ber_int_t msgid, a_metaconn_t *mc, int candidate); |
| 617 |
|
| 618 |
void* asyncmeta_op_handle_result(void *ctx, void *arg); |
| 619 |
int asyncmeta_back_cleanup( Operation *op, SlapReply *rs, bm_context_t *bm ); |
| 620 |
|
| 621 |
int |
| 622 |
asyncmeta_clear_one_msc( |
| 623 |
Operation *op, |
| 624 |
a_metaconn_t *msc, |
| 625 |
int candidate, |
| 626 |
int unbind, |
| 627 |
const char * caller); |
| 628 |
|
| 629 |
a_metaconn_t * |
| 630 |
asyncmeta_get_next_mc( a_metainfo_t *mi ); |
| 631 |
|
| 632 |
void* asyncmeta_timeout_loop(void *ctx, void *arg); |
| 633 |
|
| 634 |
int |
| 635 |
asyncmeta_start_timeout_loop(a_metatarget_t *mt, a_metainfo_t *mi); |
| 636 |
|
| 637 |
void asyncmeta_set_msc_time(a_metasingleconn_t *msc); |
| 638 |
|
| 639 |
int asyncmeta_back_cancel( |
| 640 |
a_metaconn_t *mc, |
| 641 |
Operation *op, |
| 642 |
ber_int_t msgid, |
| 643 |
int candidate ); |
| 644 |
|
| 645 |
void |
| 646 |
asyncmeta_send_result(bm_context_t* bc, int error, char *text); |
| 647 |
|
| 648 |
int asyncmeta_new_bm_context(Operation *op, |
| 649 |
SlapReply *rs, |
| 650 |
bm_context_t **new_bc, |
| 651 |
int ntargets, |
| 652 |
a_metainfo_t *mi); |
| 653 |
|
| 654 |
int asyncmeta_start_listeners(a_metaconn_t *mc, SlapReply *candidates, bm_context_t *bc); |
| 655 |
int asyncmeta_start_one_listener(a_metaconn_t *mc, SlapReply *candidates, bm_context_t *bc, int candidate); |
| 656 |
|
| 657 |
meta_search_candidate_t |
| 658 |
asyncmeta_back_search_start( |
| 659 |
Operation *op, |
| 660 |
SlapReply *rs, |
| 661 |
a_metaconn_t *mc, |
| 662 |
bm_context_t *bc, |
| 663 |
int candidate, |
| 664 |
struct berval *prcookie, |
| 665 |
ber_int_t prsize, |
| 666 |
int do_lock); |
| 667 |
|
| 668 |
meta_search_candidate_t |
| 669 |
asyncmeta_dobind_init( |
| 670 |
Operation *op, |
| 671 |
SlapReply *rs, |
| 672 |
bm_context_t *bc, |
| 673 |
a_metaconn_t *mc, |
| 674 |
int candidate); |
| 675 |
|
| 676 |
meta_search_candidate_t |
| 677 |
asyncmeta_dobind_init_with_retry( |
| 678 |
Operation *op, |
| 679 |
SlapReply *rs, |
| 680 |
bm_context_t *bc, |
| 681 |
a_metaconn_t *mc, |
| 682 |
int candidate); |
| 683 |
|
| 684 |
meta_search_candidate_t |
| 685 |
asyncmeta_back_add_start(Operation *op, |
| 686 |
SlapReply *rs, |
| 687 |
a_metaconn_t *mc, |
| 688 |
bm_context_t *bc, |
| 689 |
int candidate, |
| 690 |
int do_lock); |
| 691 |
meta_search_candidate_t |
| 692 |
asyncmeta_back_modify_start(Operation *op, |
| 693 |
SlapReply *rs, |
| 694 |
a_metaconn_t *mc, |
| 695 |
bm_context_t *bc, |
| 696 |
int candidate, |
| 697 |
int do_lock); |
| 698 |
|
| 699 |
meta_search_candidate_t |
| 700 |
asyncmeta_back_modrdn_start(Operation *op, |
| 701 |
SlapReply *rs, |
| 702 |
a_metaconn_t *mc, |
| 703 |
bm_context_t *bc, |
| 704 |
int candidate, |
| 705 |
int do_lock); |
| 706 |
meta_search_candidate_t |
| 707 |
asyncmeta_back_delete_start(Operation *op, |
| 708 |
SlapReply *rs, |
| 709 |
a_metaconn_t *mc, |
| 710 |
bm_context_t *bc, |
| 711 |
int candidate, |
| 712 |
int do_lock); |
| 713 |
|
| 714 |
meta_search_candidate_t |
| 715 |
asyncmeta_back_compare_start(Operation *op, |
| 716 |
SlapReply *rs, |
| 717 |
a_metaconn_t *mc, |
| 718 |
bm_context_t *bc, |
| 719 |
int candidate, |
| 720 |
int do_lock); |
| 721 |
|
| 722 |
bm_context_t * |
| 723 |
asyncmeta_bc_in_queue(a_metaconn_t *mc, |
| 724 |
bm_context_t *bc); |
| 725 |
|
| 726 |
int |
| 727 |
asyncmeta_error_cleanup(Operation *op, |
| 728 |
SlapReply *rs, |
| 729 |
bm_context_t *bc, |
| 730 |
a_metaconn_t *mc, |
| 731 |
int candidate); |
| 732 |
|
| 733 |
int |
| 734 |
asyncmeta_reset_msc(Operation *op, |
| 735 |
a_metaconn_t *mc, |
| 736 |
int candidate, |
| 737 |
int unbind, |
| 738 |
const char *caller); |
| 739 |
|
| 740 |
|
| 741 |
void |
| 742 |
asyncmeta_back_conn_free( |
| 743 |
void *v_mc ); |
| 744 |
|
| 745 |
void asyncmeta_log_msc(a_metasingleconn_t *msc); |
| 746 |
void asyncmeta_log_conns(a_metainfo_t *mi); |
| 747 |
|
| 748 |
void asyncmeta_get_timestamp(char *buf); |
| 749 |
|
| 750 |
int |
| 751 |
asyncmeta_dncache_update_entry(a_metadncache_t *cache, |
| 752 |
struct berval *ndn, |
| 753 |
int target ); |
| 754 |
|
| 755 |
void |
| 756 |
asyncmeta_dnattr_result_rewrite(a_dncookie *dc, |
| 757 |
BerVarray a_vals); |
| 758 |
|
| 759 |
void |
| 760 |
asyncmeta_referral_result_rewrite(a_dncookie *dc, |
| 761 |
BerVarray a_vals); |
| 762 |
|
| 763 |
meta_search_candidate_t |
| 764 |
asyncmeta_send_all_pending_ops(a_metaconn_t *mc, |
| 765 |
int candidate, |
| 766 |
void *ctx, |
| 767 |
int dolock); |
| 768 |
meta_search_candidate_t |
| 769 |
asyncmeta_return_bind_errors(a_metaconn_t *mc, |
| 770 |
int candidate, |
| 771 |
SlapReply *bind_result, |
| 772 |
void *ctx, |
| 773 |
int dolock); |
| 774 |
|
| 775 |
int |
| 776 |
asyncmeta_db_has_pending_ops(a_metainfo_t *mi); |
| 777 |
|
| 778 |
int |
| 779 |
asyncmeta_db_has_mscs(a_metainfo_t *mi); |
| 780 |
|
| 781 |
void |
| 782 |
asyncmeta_target_free(a_metatarget_t *mt); |
| 783 |
|
| 784 |
void |
| 785 |
asyncmeta_back_clear_miconns(a_metainfo_t *mi); |
| 786 |
|
| 787 |
/* The the maximum time in seconds after a result has been received on a connection, |
| 788 |
* after which it can be reset if a sender error occurs. Should this be configurable? */ |
| 789 |
#define META_BACK_RESULT_INTERVAL (2) |
| 790 |
|
| 791 |
extern int asyncmeta_debug; |
| 792 |
|
| 793 |
LDAP_END_DECL |
| 794 |
|
| 795 |
#endif /* SLAPD_ASYNCMETA_H */ |