mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-30 23:26:46 +00:00
CLEANUP: connection: remove all direct references to raw_sock and ssl_sock
Now we exclusively use xprt_get(XPRT_RAW) instead of &raw_sock or xprt_get(XPRT_SSL) for &ssl_sock. This removes a bunch of #ifdef and include spread over a number of location including backend, cfgparse, checks, cli, hlua, log, server and session.
This commit is contained in:
parent
13e1410f8a
commit
a261e9b094
@ -51,7 +51,6 @@
|
||||
#include <proto/sample.h>
|
||||
#include <proto/server.h>
|
||||
#include <proto/stream.h>
|
||||
#include <proto/raw_sock.h>
|
||||
#include <proto/stream_interface.h>
|
||||
#include <proto/task.h>
|
||||
|
||||
@ -1150,7 +1149,7 @@ int connect_server(struct stream *s)
|
||||
}
|
||||
else if (obj_type(s->target) == OBJ_TYPE_PROXY) {
|
||||
/* proxies exclusively run on raw_sock right now */
|
||||
conn_prepare(srv_conn, protocol_by_family(srv_conn->addr.to.ss_family), &raw_sock);
|
||||
conn_prepare(srv_conn, protocol_by_family(srv_conn->addr.to.ss_family), xprt_get(XPRT_RAW));
|
||||
if (!objt_conn(s->si[1].end) || !objt_conn(s->si[1].end)->ctrl)
|
||||
return SF_ERR_INTERNAL;
|
||||
}
|
||||
|
@ -80,7 +80,6 @@
|
||||
#include <proto/session.h>
|
||||
#include <proto/server.h>
|
||||
#include <proto/stream.h>
|
||||
#include <proto/raw_sock.h>
|
||||
#include <proto/stick_table.h>
|
||||
#include <proto/task.h>
|
||||
#include <proto/tcp_rules.h>
|
||||
@ -2009,7 +2008,7 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
|
||||
|
||||
newpeer->addr = *sk;
|
||||
newpeer->proto = proto;
|
||||
newpeer->xprt = &raw_sock;
|
||||
newpeer->xprt = xprt_get(XPRT_RAW);
|
||||
newpeer->sock_init_arg = NULL;
|
||||
|
||||
if (strcmp(newpeer->id, localpeer) == 0) {
|
||||
@ -2031,7 +2030,7 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
|
||||
curpeers->peers_fe->conf.args.line = curpeers->peers_fe->conf.line = linenum;
|
||||
peers_setup_frontend(curpeers->peers_fe);
|
||||
|
||||
bind_conf = bind_conf_alloc(curpeers->peers_fe, file, linenum, args[2], &raw_sock);
|
||||
bind_conf = bind_conf_alloc(curpeers->peers_fe, file, linenum, args[2], xprt_get(XPRT_RAW));
|
||||
|
||||
if (!str2listener(args[2], curpeers->peers_fe, bind_conf, file, linenum, &errmsg)) {
|
||||
if (errmsg && *errmsg) {
|
||||
@ -2439,7 +2438,7 @@ int cfg_parse_mailers(const char *file, int linenum, char **args, int kwm)
|
||||
|
||||
newmailer->addr = *sk;
|
||||
newmailer->proto = proto;
|
||||
newmailer->xprt = &raw_sock;
|
||||
newmailer->xprt = xprt_get(XPRT_RAW);
|
||||
newmailer->sock_init_arg = NULL;
|
||||
}
|
||||
else if (strcmp(args[0], "timeout") == 0) {
|
||||
@ -2880,7 +2879,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
goto out;
|
||||
}
|
||||
|
||||
bind_conf = bind_conf_alloc(curproxy, file, linenum, args[1], &raw_sock);
|
||||
bind_conf = bind_conf_alloc(curproxy, file, linenum, args[1], xprt_get(XPRT_RAW));
|
||||
|
||||
/* use default settings for unix sockets */
|
||||
bind_conf->ux.uid = global.unix_bind.ux.uid;
|
||||
|
14
src/checks.c
14
src/checks.c
@ -41,11 +41,6 @@
|
||||
#include <types/dns.h>
|
||||
#include <types/stats.h>
|
||||
|
||||
#ifdef USE_OPENSSL
|
||||
#include <types/ssl_sock.h>
|
||||
#include <proto/ssl_sock.h>
|
||||
#endif /* USE_OPENSSL */
|
||||
|
||||
#include <proto/backend.h>
|
||||
#include <proto/checks.h>
|
||||
#include <proto/stats.h>
|
||||
@ -57,7 +52,6 @@
|
||||
#include <proto/proto_tcp.h>
|
||||
#include <proto/protocol.h>
|
||||
#include <proto/proxy.h>
|
||||
#include <proto/raw_sock.h>
|
||||
#include <proto/server.h>
|
||||
#include <proto/signal.h>
|
||||
#include <proto/stream_interface.h>
|
||||
@ -2738,16 +2732,12 @@ static void tcpcheck_main(struct connection *conn)
|
||||
else if (check->port)
|
||||
set_host_port(&conn->addr.to, check->port);
|
||||
|
||||
#ifdef USE_OPENSSL
|
||||
if (check->current_step->conn_opts & TCPCHK_OPT_SSL) {
|
||||
xprt = &ssl_sock;
|
||||
xprt = xprt_get(XPRT_SSL);
|
||||
}
|
||||
else {
|
||||
xprt = &raw_sock;
|
||||
xprt = xprt_get(XPRT_RAW);
|
||||
}
|
||||
#else /* USE_OPENSSL */
|
||||
xprt = &raw_sock;
|
||||
#endif /* USE_OPENSSL */
|
||||
conn_prepare(conn, proto, xprt);
|
||||
|
||||
ret = SF_ERR_INTERNAL;
|
||||
|
@ -62,7 +62,6 @@
|
||||
#include <proto/session.h>
|
||||
#include <proto/stream.h>
|
||||
#include <proto/server.h>
|
||||
#include <proto/raw_sock.h>
|
||||
#include <proto/stream_interface.h>
|
||||
#include <proto/task.h>
|
||||
|
||||
@ -215,7 +214,7 @@ static int stats_parse_global(char **args, int section_type, struct proxy *curpx
|
||||
}
|
||||
}
|
||||
|
||||
bind_conf = bind_conf_alloc(global.stats_fe, file, line, args[2], &raw_sock);
|
||||
bind_conf = bind_conf_alloc(global.stats_fe, file, line, args[2], xprt_get(XPRT_RAW));
|
||||
bind_conf->level = ACCESS_LVL_OPER; /* default access level */
|
||||
|
||||
if (!str2listener(args[2], global.stats_fe, bind_conf, file, line, err)) {
|
||||
|
@ -44,7 +44,6 @@
|
||||
#include <proto/pattern.h>
|
||||
#include <proto/payload.h>
|
||||
#include <proto/proto_http.h>
|
||||
#include <proto/raw_sock.h>
|
||||
#include <proto/sample.h>
|
||||
#include <proto/server.h>
|
||||
#include <proto/session.h>
|
||||
@ -7629,7 +7628,7 @@ void hlua_init(void)
|
||||
socket_tcp.agent.health = socket_tcp.agent.rise; /* socket, but will fall down at first failure */
|
||||
socket_tcp.agent.server = &socket_tcp;
|
||||
|
||||
socket_tcp.xprt = &raw_sock;
|
||||
socket_tcp.xprt = xprt_get(XPRT_RAW);
|
||||
|
||||
#ifdef USE_OPENSSL
|
||||
/* Init TCP server: unchanged parameters */
|
||||
@ -7676,7 +7675,7 @@ void hlua_init(void)
|
||||
socket_ssl.agent.server = &socket_ssl;
|
||||
|
||||
socket_ssl.use_ssl = 1;
|
||||
socket_ssl.xprt = &ssl_sock;
|
||||
socket_ssl.xprt = xprt_get(XPRT_SSL);
|
||||
|
||||
for (idx = 0; args[idx] != NULL; idx++) {
|
||||
if ((kw = srv_find_kw(args[idx])) != NULL) { /* Maybe it's registered server keyword */
|
||||
|
@ -1629,10 +1629,8 @@ int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list
|
||||
if (iret == 0)
|
||||
goto out;
|
||||
tmplog += iret;
|
||||
#ifdef USE_OPENSSL
|
||||
if (sess->listener->bind_conf->xprt == &ssl_sock)
|
||||
if (sess->listener->bind_conf->xprt == xprt_get(XPRT_SSL))
|
||||
LOGCHAR('~');
|
||||
#endif
|
||||
if (tmp->options & LOG_OPT_QUOTE)
|
||||
LOGCHAR('"');
|
||||
last_isspace = 0;
|
||||
@ -1642,7 +1640,7 @@ int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list
|
||||
src = NULL;
|
||||
conn = objt_conn(sess->origin);
|
||||
if (conn) {
|
||||
if (sess->listener->bind_conf->xprt == &ssl_sock)
|
||||
if (sess->listener->bind_conf->xprt == xprt_get(XPRT_SSL))
|
||||
src = ssl_sock_get_cipher_name(conn);
|
||||
}
|
||||
ret = lf_text(tmplog, src, dst + maxsize - tmplog, tmp);
|
||||
@ -1656,7 +1654,7 @@ int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list
|
||||
src = NULL;
|
||||
conn = objt_conn(sess->origin);
|
||||
if (conn) {
|
||||
if (sess->listener->bind_conf->xprt == &ssl_sock)
|
||||
if (sess->listener->bind_conf->xprt == xprt_get(XPRT_SSL))
|
||||
src = ssl_sock_get_proto_version(conn);
|
||||
}
|
||||
ret = lf_text(tmplog, src, dst + maxsize - tmplog, tmp);
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include <proto/port_range.h>
|
||||
#include <proto/protocol.h>
|
||||
#include <proto/queue.h>
|
||||
#include <proto/raw_sock.h>
|
||||
#include <proto/server.h>
|
||||
#include <proto/stream.h>
|
||||
#include <proto/stream_interface.h>
|
||||
@ -1063,7 +1062,7 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr
|
||||
|
||||
skip_name_resolution:
|
||||
newsrv->addr = *sk;
|
||||
newsrv->xprt = newsrv->check.xprt = newsrv->agent.xprt = &raw_sock;
|
||||
newsrv->xprt = newsrv->check.xprt = newsrv->agent.xprt = xprt_get(XPRT_RAW);
|
||||
|
||||
if (!protocol_by_family(newsrv->addr.ss_family)) {
|
||||
Alert("parsing [%s:%d] : Unknown protocol family %d '%s'\n",
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <proto/log.h>
|
||||
#include <proto/proto_http.h>
|
||||
#include <proto/proxy.h>
|
||||
#include <proto/raw_sock.h>
|
||||
#include <proto/session.h>
|
||||
#include <proto/stream.h>
|
||||
#include <proto/tcp_rules.h>
|
||||
@ -292,7 +291,7 @@ int session_accept_fd(struct listener *l, int cfd, struct sockaddr_storage *addr
|
||||
conn_xprt_close(cli_conn);
|
||||
conn_free(cli_conn);
|
||||
out_close:
|
||||
if (ret < 0 && l->bind_conf->xprt == &raw_sock && p->mode == PR_MODE_HTTP) {
|
||||
if (ret < 0 && l->bind_conf->xprt == xprt_get(XPRT_RAW) && p->mode == PR_MODE_HTTP) {
|
||||
/* critical error, no more memory, try to emit a 500 response */
|
||||
struct chunk *err_msg = &p->errmsg[HTTP_ERR_500];
|
||||
if (!err_msg->str)
|
||||
|
Loading…
Reference in New Issue
Block a user