]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Print out when a SSL * is bound and unbound
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 15 Feb 2022 03:34:55 +0000 (22:34 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 15 Feb 2022 03:34:55 +0000 (22:34 -0500)
src/lib/tls/session.h

index 478864a6bc3a208554074bc376f867c4918d8c96..d809042e2f475d1d8a22e4ad350a8c401d95d153 100644 (file)
@@ -164,17 +164,35 @@ static inline fr_tls_session_t *fr_tls_session(SSL *ssl)
        return talloc_get_type_abort(SSL_get_ex_data(ssl, FR_TLS_EX_INDEX_TLS_SESSION), fr_tls_session_t);
 }
 
-/** Place a request pointer in the SSL * for retrieval by callbacks
+/** Check to see if a request is bound to a session
  *
- * @note A request must not already be bound to the SSL *
+ * @param[in] ssl      session to check for requests.
+ * @return
+ *     - true if a request is bound to this session.
+ *     - false if a request is not bound to this session.
+ */
+static inline CC_HINT(nonnull) bool fr_tls_session_request_bound(SSL *ssl)
+{
+       return (SSL_get_ex_data(ssl, FR_TLS_EX_INDEX_REQUEST) != NULL);
+}
+
+/** Return the request associated with a ssl session
  *
- * @param[in] ssl              to be bound.
- * @param[in] request          to bind to the tls_session.
+ * @param[in] ssl      session to retrieve the configuration from.
+ * @return #request associated with the session.
  */
-static inline CC_HINT(nonnull) void fr_tls_session_request_bind(SSL *ssl, request_t *request)
+static inline request_t *fr_tls_session_request(SSL const *ssl)
+{
+       return talloc_get_type_abort(SSL_get_ex_data(ssl, FR_TLS_EX_INDEX_REQUEST), request_t);
+}
+
+static inline CC_HINT(nonnull) void _fr_tls_session_request_bind(char const *file, int line,
+                                                                SSL *ssl, request_t *request)
 {
        int ret;
 
+       RDEBUG3("%s[%u] - Binding SSL * (%p) to request (%p)", file, line, ssl, request);
+
 #ifndef NDEBUG
        request_t *old;
        old = SSL_get_ex_data(ssl, FR_TLS_EX_INDEX_REQUEST);
@@ -189,48 +207,38 @@ static inline CC_HINT(nonnull) void fr_tls_session_request_bind(SSL *ssl, reques
                return;
        }
 }
-
-/** Remove a request pointer from the tls_session
+/** Place a request pointer in the SSL * for retrieval by callbacks
  *
- * @note A request must be bound to the tls_session
+ * @note A request must not already be bound to the SSL *
  *
- * @param[in] ssl      session containing the request pointer.
+ * @param[in] ssl              to be bound.
+ * @param[in] request          to bind to the tls_session.
  */
-static inline CC_HINT(nonnull) void fr_tls_session_request_unbind(SSL *ssl)
+ #define fr_tls_session_request_bind(_ssl, _request) _fr_tls_session_request_bind(__FILE__, __LINE__, _ssl, _request)
+
+static inline CC_HINT(nonnull) void _fr_tls_session_request_unbind(char const *file, int line, SSL *ssl)
 {
-       int ret;
+       request_t       *request = fr_tls_session_request(ssl);
+       int             ret;
 
 #ifndef NDEBUG
-       (void)talloc_get_type_abort(SSL_get_ex_data(ssl, FR_TLS_EX_INDEX_REQUEST), request_t);
+       (void)talloc_get_type_abort(request, request_t);
 #endif
+
+       RDEBUG3("%s[%u] - Unbinding SSL * (%p) from request (%p)", file, line, ssl, request);
        ret = SSL_set_ex_data(ssl, FR_TLS_EX_INDEX_REQUEST, NULL);
        if (unlikely(ret == 0)) {
                fr_assert(0);
                return;
        }
 }
-
-/** Check to see if a request is bound to a session
+/** Remove a request pointer from the tls_session
  *
- * @param[in] ssl      session to check for requests.
- * @return
- *      - true if a request is bound to this session.
- *     - false if a request is not bound to this session.
- */
-static inline CC_HINT(nonnull) bool fr_tls_session_request_bound(SSL *ssl)
-{
-       return (SSL_get_ex_data(ssl, FR_TLS_EX_INDEX_REQUEST) != NULL);
-}
-
-/** Return the request associated with a ssl session
+ * @note A request must be bound to the tls_session
  *
- * @param[in] ssl      session to retrieve the configuration from.
- * @return #request associated with the session.
+ * @param[in] ssl      session containing the request pointer.
  */
-static inline request_t *fr_tls_session_request(SSL const *ssl)
-{
-       return talloc_get_type_abort(SSL_get_ex_data(ssl, FR_TLS_EX_INDEX_REQUEST), request_t);
-}
+#define fr_tls_session_request_unbind(_ssl) _fr_tls_session_request_unbind(__LINE__, __FILE__, _ssl);
 
 /** Add extra pairs to the temporary subrequests
  *