]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9600 Support closing connections on request
authorOndřej Kuzník <okuznik@symas.com>
Thu, 22 Apr 2021 12:35:17 +0000 (13:35 +0100)
committerOndřej Kuzník <okuznik@symas.com>
Fri, 13 Aug 2021 09:57:14 +0000 (10:57 +0100)
doc/man/man8/lloadd.8
servers/lloadd/monitor.c
tests/data/slapd-lload.conf

index af112b8d391baf297b223380e7cbb8eaea3ed36f..3b48a8b4cb600f2c0561dcf4799c223011059dde 100644 (file)
@@ -263,6 +263,35 @@ client traffic does not propagate to the
 .B lloadd
 backend servers in any way.
 
+.SH CN=MONITOR INTERFACE
+As part of
+.BR lloadd 's
+.B cn=monitor
+interface it is possible to close a client connection it manages by writing to
+the corresponding entry,
+.B replacing
+the
+.B olmConnectionState
+attribute with the value
+.BR closing .
+This is subject to ACLs configured on the monitor database. The server will
+send a
+.B Notice of Disconnection
+to the client, refuse any new operations and once all pending operations have
+finished, close the connection.
+
+For example, to close connection number 42:
+
+.LP
+.nf
+.ft tt
+    dn: cn=connection 42,cn=incoming connections,cn=load balancer,cn=backends,cn=monitor
+    changetype: modify
+    replace: olmConnectionState
+    olmConnectionState: closing
+.ft
+.fi
+
 .SH EXAMPLES
 To start
 .I lloadd
index a7304f1917f8d89ada546c02d03b309fd3c14b67..ac486f5aa1daf91b07ce4fb68803acc010f81d8e 100644 (file)
@@ -531,6 +531,31 @@ done:
     return rc;
 }
 
+static int
+lload_monitor_conn_modify( Operation *op, SlapReply *rs, Entry *e, void *priv )
+{
+    Modifications *m;
+    LloadConnection *c = priv;
+
+    for ( m = op->orm_modlist; m; m = m->sml_next ) {
+        struct berval closing = BER_BVC("closing");
+        int gentle = 1;
+
+        if ( m->sml_flags & SLAP_MOD_INTERNAL ) continue;
+
+        if ( m->sml_desc != ad_olmConnectionState ||
+                m->sml_op != LDAP_MOD_REPLACE || m->sml_numvals != 1 ||
+                ber_bvcmp( &m->sml_nvalues[0], &closing ) ) {
+            return LDAP_OTHER;
+        }
+
+        if ( lload_connection_close( c, &gentle ) ) {
+            return LDAP_OTHER;
+        }
+    }
+    return SLAP_CB_CONTINUE;
+}
+
 /*
  * Monitor cache is locked, the connection cannot be unlinked and freed under us.
  * That also means we need to unlock and finish as soon as possible.
@@ -701,6 +726,7 @@ lload_monitor_conn_entry_create( LloadConnection *c, monitor_subsys_t *ms )
 
     cb = ch_calloc( sizeof(monitor_callback_t), 1 );
     cb->mc_update = lload_monitor_conn_update;
+    cb->mc_modify = lload_monitor_conn_modify;
     cb->mc_private = c;
 
     attr_merge_one( e, ad_olmConnectionType, &value, NULL );
index 50543f8fe37316eecda313f78f708ded26d8ce09..244556e3ca6a12f28b8cc2b92f898bce120be6f4 100644 (file)
@@ -38,4 +38,6 @@ database config
 include                @TESTDIR@/configpw.conf
 
 database       monitor
-access to * by * read
+access to *
+       by users write
+       by * read