]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: ssl/server: move ssl_sock_set_srv() to srv_set_ssl() in server.c
authorWilly Tarreau <w@1wt.eu>
Wed, 6 Oct 2021 09:48:34 +0000 (11:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 6 Oct 2021 23:41:06 +0000 (01:41 +0200)
This one has nothing to do with ssl_sock as it manipulates the struct
server only. Let's move it to server.c and remove unneeded dependencies
on ssl_sock.h. This further reduces by 10% the number of includes of
opensslconf.h and by 0.5% the number of compiled lines.

include/haproxy/server.h
include/haproxy/ssl_sock.h
src/server.c
src/server_state.c
src/ssl_sock.c

index 99d26ba0ddcffe22ba32e5f3198c4f2ef1d4cfa7..b7195cbd2d1b68dc241660287d48beea44aa9d28 100644 (file)
@@ -62,6 +62,7 @@ struct server *new_server(struct proxy *proxy);
 void srv_take(struct server *srv);
 struct server *srv_drop(struct server *srv);
 int srv_init_per_thr(struct server *srv);
+void srv_set_ssl(struct server *s, int use_ssl);
 
 /* functions related to server name resolution */
 int srv_prepare_for_resolution(struct server *srv, const char *hostname);
index f3afe617b595341ae776b5364057879792f9daf2..2fdf8e2268a4edc609aff7adaefd0abd58b0de16 100644 (file)
@@ -73,7 +73,6 @@ const char *ssl_sock_get_proto_version(struct connection *conn);
 int ssl_sock_parse_alpn(char *arg, char **alpn_str, int *alpn_len, char **err);
 void ssl_sock_set_alpn(struct connection *conn, const unsigned char *, int);
 void ssl_sock_set_servername(struct connection *conn, const char *hostname);
-void ssl_sock_set_srv(struct server *s, signed char use_ssl);
 
 int ssl_sock_get_cert_used_sess(struct connection *conn);
 int ssl_sock_get_cert_used_conn(struct connection *conn);
index 5d6e4b1389cde4a882407d447595d66758c7713b..73454bc4fcc41950ea86bf2765ad7c56257cd217 100644 (file)
@@ -36,7 +36,6 @@
 #include <haproxy/resolvers.h>
 #include <haproxy/sample.h>
 #include <haproxy/server.h>
-#include <haproxy/ssl_sock.h>
 #include <haproxy/stats.h>
 #include <haproxy/stream.h>
 #include <haproxy/stream_interface.h>
@@ -1977,7 +1976,25 @@ static void srv_ssl_settings_cpy(struct server *srv, struct server *src)
                }
        }
 }
-#endif
+
+/* Activate ssl on server <s>.
+ * do nothing if there is no change to apply
+ *
+ * Must be called with the server lock held.
+ */
+void srv_set_ssl(struct server *s, int use_ssl)
+{
+       if (s->use_ssl == use_ssl)
+               return;
+
+       s->use_ssl = use_ssl;
+       if (s->use_ssl)
+               s->xprt = xprt_get(XPRT_SSL);
+       else
+               s->xprt = s->check.xprt = s->agent.xprt = xprt_get(XPRT_RAW);
+}
+
+#endif /* USE_OPENSSL */
 
 /*
  * Prepare <srv> for hostname resolution.
@@ -4144,9 +4161,9 @@ static int cli_parse_set_server(char **args, char *payload, struct appctx *appct
 
                HA_SPIN_LOCK(SERVER_LOCK, &sv->lock);
                if (strcmp(args[4], "on") == 0) {
-                       ssl_sock_set_srv(sv, 1);
+                       srv_set_ssl(sv, 1);
                } else if (strcmp(args[4], "off") == 0) {
-                       ssl_sock_set_srv(sv, 0);
+                       srv_set_ssl(sv, 0);
                } else {
                        HA_SPIN_UNLOCK(SERVER_LOCK, &sv->lock);
                        cli_err(appctx, "'set server <srv> ssl' expects 'on' or 'off'.\n");
index b9ae9edac693616d6cbde28e282742662de5598a..a831d571002c5847f82c6e2ea40f7b5b30f4bdfe 100644 (file)
@@ -26,7 +26,6 @@
 #include <haproxy/proxy.h>
 #include <haproxy/resolvers.h>
 #include <haproxy/server.h>
-#include <haproxy/ssl_sock.h>
 #include <haproxy/tools.h>
 #include <haproxy/xxhash.h>
 
@@ -447,7 +446,7 @@ static void srv_state_srv_update(struct server *srv, int version, char **params)
 
                /* configure ssl if connection has been initiated at startup */
                if (srv->ssl_ctx.ctx != NULL)
-                       ssl_sock_set_srv(srv, use_ssl);
+                       srv_set_ssl(srv, use_ssl);
 #endif
        }
 
index 8f7000d07dd19accfa9a2715914f45b84f88c765..ae28bca0d210105d45c4486a70bfed217b094522 100644 (file)
@@ -7696,22 +7696,6 @@ static void __ssl_sock_deinit(void)
        BIO_meth_free(ha_meth);
 }
 
-/* Activate ssl on server <s>.
- * do nothing if there is no change to apply
- *
- * Must be called with the server lock held.
- */
-void ssl_sock_set_srv(struct server *s, signed char use_ssl)
-{
-       if (s->use_ssl == use_ssl)
-               return;
-
-       s->use_ssl = use_ssl;
-       if (s->use_ssl == 1)
-               s->xprt = &ssl_sock;
-       else
-               s->xprt = s->check.xprt = s->agent.xprt = xprt_get(XPRT_RAW);
-}
 
 /*
  * Local variables: