mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 05:41:26 +02:00
MINOR: rhttp: large renaming to use rhttp prefix
Previous commit renames 'proto_reverse_connect' module to 'proto_rhttp'. This commits follows this by replacing various custom prefix by 'rhttp_' to make the code uniform. Note that 'reverse_' prefix was kept in connection module. This is because if a new reversable protocol not based on HTTP is implemented, it may be necessary to reused the same connection function which are protocol agnostic.
This commit is contained in:
parent
e09af499b4
commit
55e78ff7e1
@ -210,8 +210,8 @@ struct bind_conf {
|
|||||||
char *arg; /* argument passed to "bind" for better error reporting */
|
char *arg; /* argument passed to "bind" for better error reporting */
|
||||||
char *file; /* file where the section appears */
|
char *file; /* file where the section appears */
|
||||||
int line; /* line where the section appears */
|
int line; /* line where the section appears */
|
||||||
char *reverse_srvname; /* name of server when using "rhttp@" address */
|
char *rhttp_srvname; /* name of server when using "rhttp@" address */
|
||||||
int reverse_nbconn; /* count of connections to initiate in parallel */
|
int rhttp_nbconn; /* count of connections to initiate in parallel */
|
||||||
__decl_thread(HA_RWLOCK_T sni_lock); /* lock the SNI trees during add/del operations */
|
__decl_thread(HA_RWLOCK_T sni_lock); /* lock the SNI trees during add/del operations */
|
||||||
struct thread_set thread_set; /* entire set of the allowed threads (0=no restriction) */
|
struct thread_set thread_set; /* entire set of the allowed threads (0=no restriction) */
|
||||||
struct rx_settings settings; /* all the settings needed for the listening socket */
|
struct rx_settings settings; /* all the settings needed for the listening socket */
|
||||||
|
@ -5,17 +5,17 @@
|
|||||||
#include <haproxy/listener-t.h>
|
#include <haproxy/listener-t.h>
|
||||||
#include <haproxy/receiver-t.h>
|
#include <haproxy/receiver-t.h>
|
||||||
|
|
||||||
int rev_bind_receiver(struct receiver *rx, char **errmsg);
|
int rhttp_bind_receiver(struct receiver *rx, char **errmsg);
|
||||||
|
|
||||||
int rev_bind_listener(struct listener *listener, char *errmsg, int errlen);
|
int rhttp_bind_listener(struct listener *listener, char *errmsg, int errlen);
|
||||||
void rev_enable_listener(struct listener *l);
|
void rhttp_enable_listener(struct listener *l);
|
||||||
void rev_disable_listener(struct listener *l);
|
void rhttp_disable_listener(struct listener *l);
|
||||||
struct connection *rev_accept_conn(struct listener *l, int *status);
|
struct connection *rhttp_accept_conn(struct listener *l, int *status);
|
||||||
void rev_unbind_receiver(struct listener *l);
|
void rhttp_unbind_receiver(struct listener *l);
|
||||||
int rev_set_affinity(struct connection *conn, int new_tid);
|
int rhttp_set_affinity(struct connection *conn, int new_tid);
|
||||||
|
|
||||||
int rev_accepting_conn(const struct receiver *rx);
|
int rhttp_accepting_conn(const struct receiver *rx);
|
||||||
|
|
||||||
void rev_notify_preconn_err(struct listener *l);
|
void rhttp_notify_preconn_err(struct listener *l);
|
||||||
|
|
||||||
#endif /* _HAPROXY_PROTO_RHTTP_H */
|
#endif /* _HAPROXY_PROTO_RHTTP_H */
|
||||||
|
@ -39,7 +39,7 @@ struct connection;
|
|||||||
*/
|
*/
|
||||||
#define AF_CUST_EXISTING_FD (AF_MAX + 1)
|
#define AF_CUST_EXISTING_FD (AF_MAX + 1)
|
||||||
#define AF_CUST_SOCKPAIR (AF_MAX + 2)
|
#define AF_CUST_SOCKPAIR (AF_MAX + 2)
|
||||||
#define AF_CUST_REV_SRV (AF_MAX + 3)
|
#define AF_CUST_RHTTP_SRV (AF_MAX + 3)
|
||||||
#define AF_CUST_MAX (AF_MAX + 4)
|
#define AF_CUST_MAX (AF_MAX + 4)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -90,7 +90,7 @@ struct receiver {
|
|||||||
struct server *srv; /* Underlying server used to initiate reverse pre-connect. */
|
struct server *srv; /* Underlying server used to initiate reverse pre-connect. */
|
||||||
struct connection *pend_conn; /* Pending connection waiting to complete reversal before being accepted. */
|
struct connection *pend_conn; /* Pending connection waiting to complete reversal before being accepted. */
|
||||||
enum li_preconn_state state; /* State for transition logging. */
|
enum li_preconn_state state; /* State for transition logging. */
|
||||||
} reverse_connect;
|
} rhttp;
|
||||||
|
|
||||||
/* warning: this struct is huge, keep it at the bottom */
|
/* warning: this struct is huge, keep it at the bottom */
|
||||||
struct sockaddr_storage addr; /* the address the socket is bound to */
|
struct sockaddr_storage addr; /* the address the socket is bound to */
|
||||||
|
@ -142,7 +142,7 @@ enum srv_initaddr {
|
|||||||
#define SRV_F_NON_STICK 0x0004 /* never add connections allocated to this server to a stick table */
|
#define SRV_F_NON_STICK 0x0004 /* never add connections allocated to this server to a stick table */
|
||||||
#define SRV_F_USE_NS_FROM_PP 0x0008 /* use namespace associated with connection if present */
|
#define SRV_F_USE_NS_FROM_PP 0x0008 /* use namespace associated with connection if present */
|
||||||
#define SRV_F_FORCED_ID 0x0010 /* server's ID was forced in the configuration */
|
#define SRV_F_FORCED_ID 0x0010 /* server's ID was forced in the configuration */
|
||||||
#define SRV_F_REVERSE 0x0020 /* reverse connect server which requires idle connection for transfers */
|
#define SRV_F_RHTTP 0x0020 /* reverse HTTP server which requires idle connection for transfers */
|
||||||
#define SRV_F_AGENTPORT 0x0040 /* this server has a agent port configured */
|
#define SRV_F_AGENTPORT 0x0040 /* this server has a agent port configured */
|
||||||
#define SRV_F_AGENTADDR 0x0080 /* this server has a agent addr configured */
|
#define SRV_F_AGENTADDR 0x0080 /* this server has a agent addr configured */
|
||||||
#define SRV_F_COOKIESET 0x0100 /* this server has a cookie configured, so don't generate dynamic cookies */
|
#define SRV_F_COOKIESET 0x0100 /* this server has a cookie configured, so don't generate dynamic cookies */
|
||||||
|
@ -314,7 +314,7 @@ static inline int srv_is_transparent(const struct server *srv)
|
|||||||
/* A reverse server does not have any address but it is not used as a
|
/* A reverse server does not have any address but it is not used as a
|
||||||
* transparent one.
|
* transparent one.
|
||||||
*/
|
*/
|
||||||
return (!is_addr(&srv->addr) && !(srv->flags & SRV_F_REVERSE)) ||
|
return (!is_addr(&srv->addr) && !(srv->flags & SRV_F_RHTTP)) ||
|
||||||
(srv->flags & SRV_F_MAPPORTS);
|
(srv->flags & SRV_F_MAPPORTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1361,7 +1361,7 @@ static int connect_server(struct stream *s)
|
|||||||
srv = objt_server(s->target);
|
srv = objt_server(s->target);
|
||||||
|
|
||||||
/* Override reuse-mode if reverse-connect is used. */
|
/* Override reuse-mode if reverse-connect is used. */
|
||||||
if (srv && srv->flags & SRV_F_REVERSE)
|
if (srv && srv->flags & SRV_F_RHTTP)
|
||||||
reuse_mode = PR_O_REUSE_ALWS;
|
reuse_mode = PR_O_REUSE_ALWS;
|
||||||
|
|
||||||
err = alloc_dst_address(&s->scb->dst, srv, s);
|
err = alloc_dst_address(&s->scb->dst, srv, s);
|
||||||
@ -1596,7 +1596,7 @@ static int connect_server(struct stream *s)
|
|||||||
skip_reuse:
|
skip_reuse:
|
||||||
/* no reuse or failed to reuse the connection above, pick a new one */
|
/* no reuse or failed to reuse the connection above, pick a new one */
|
||||||
if (!srv_conn) {
|
if (!srv_conn) {
|
||||||
if (srv && (srv->flags & SRV_F_REVERSE)) {
|
if (srv && (srv->flags & SRV_F_RHTTP)) {
|
||||||
DBG_TRACE_USER("cannot open a new connection for reverse server", STRM_EV_STRM_PROC|STRM_EV_CS_ST, s);
|
DBG_TRACE_USER("cannot open a new connection for reverse server", STRM_EV_STRM_PROC|STRM_EV_CS_ST, s);
|
||||||
s->conn_err_type = STRM_ET_CONN_ERR;
|
s->conn_err_type = STRM_ET_CONN_ERR;
|
||||||
return SF_ERR_INTERNAL;
|
return SF_ERR_INTERNAL;
|
||||||
|
@ -162,7 +162,7 @@ int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf,
|
|||||||
if (!ss2)
|
if (!ss2)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (ss2->ss_family == AF_CUST_REV_SRV) {
|
if (ss2->ss_family == AF_CUST_RHTTP_SRV) {
|
||||||
/* Check if a previous non reverse HTTP present is
|
/* Check if a previous non reverse HTTP present is
|
||||||
* already defined. If DGRAM or STREAM is set, this
|
* already defined. If DGRAM or STREAM is set, this
|
||||||
* indicates that we are currently parsing the second
|
* indicates that we are currently parsing the second
|
||||||
@ -174,8 +174,8 @@ int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
bind_conf->reverse_srvname = strdup(str + strlen("rhttp@"));
|
bind_conf->rhttp_srvname = strdup(str + strlen("rhttp@"));
|
||||||
if (!bind_conf->reverse_srvname) {
|
if (!bind_conf->rhttp_srvname) {
|
||||||
memprintf(err, "Cannot allocate reverse HTTP bind.\n");
|
memprintf(err, "Cannot allocate reverse HTTP bind.\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@ -3889,8 +3889,8 @@ out_uri_auth_compat:
|
|||||||
if ((curproxy->mode != PR_MODE_HTTP) && (curproxy->options & PR_O_REUSE_MASK) != PR_O_REUSE_NEVR)
|
if ((curproxy->mode != PR_MODE_HTTP) && (curproxy->options & PR_O_REUSE_MASK) != PR_O_REUSE_NEVR)
|
||||||
curproxy->options &= ~PR_O_REUSE_MASK;
|
curproxy->options &= ~PR_O_REUSE_MASK;
|
||||||
|
|
||||||
if ((curproxy->mode != PR_MODE_HTTP) && newsrv->flags & SRV_F_REVERSE) {
|
if ((curproxy->mode != PR_MODE_HTTP) && newsrv->flags & SRV_F_RHTTP) {
|
||||||
ha_alert("%s '%s' : server %s uses reverse addressing which can only be used with HTTP mode.\n",
|
ha_alert("%s '%s' : server %s uses reverse HTTP addressing which can only be used with HTTP mode.\n",
|
||||||
proxy_type_str(curproxy), curproxy->id, newsrv->id);
|
proxy_type_str(curproxy), curproxy->id, newsrv->id);
|
||||||
cfgerr++;
|
cfgerr++;
|
||||||
err_code |= ERR_FATAL | ERR_ALERT;
|
err_code |= ERR_FATAL | ERR_ALERT;
|
||||||
|
@ -126,7 +126,7 @@ fail:
|
|||||||
|
|
||||||
/* If mux init failed, consider connection on error.
|
/* If mux init failed, consider connection on error.
|
||||||
* This is necessary to ensure connection is freed by
|
* This is necessary to ensure connection is freed by
|
||||||
* proto-reverse-connect receiver task.
|
* proto-rhttp receiver task.
|
||||||
*/
|
*/
|
||||||
if (!conn->mux)
|
if (!conn->mux)
|
||||||
conn->flags |= CO_FL_ERROR;
|
conn->flags |= CO_FL_ERROR;
|
||||||
@ -134,7 +134,7 @@ fail:
|
|||||||
/* If connection is interrupted without CO_FL_ERROR, receiver task won't free it. */
|
/* If connection is interrupted without CO_FL_ERROR, receiver task won't free it. */
|
||||||
BUG_ON(!(conn->flags & CO_FL_ERROR));
|
BUG_ON(!(conn->flags & CO_FL_ERROR));
|
||||||
|
|
||||||
task_wakeup(l->rx.reverse_connect.task, TASK_WOKEN_ANY);
|
task_wakeup(l->rx.rhttp.task, TASK_WOKEN_ANY);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
} else
|
} else
|
||||||
@ -591,7 +591,7 @@ void conn_free(struct connection *conn)
|
|||||||
|
|
||||||
if (conn_reverse_in_preconnect(conn)) {
|
if (conn_reverse_in_preconnect(conn)) {
|
||||||
struct listener *l = conn_active_reverse_listener(conn);
|
struct listener *l = conn_active_reverse_listener(conn);
|
||||||
rev_notify_preconn_err(l);
|
rhttp_notify_preconn_err(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
conn_force_unsubscribe(conn);
|
conn_force_unsubscribe(conn);
|
||||||
@ -2681,7 +2681,7 @@ int conn_reverse(struct connection *conn)
|
|||||||
|
|
||||||
conn->target = &l->obj_type;
|
conn->target = &l->obj_type;
|
||||||
conn->flags |= CO_FL_ACT_REVERSING;
|
conn->flags |= CO_FL_ACT_REVERSING;
|
||||||
task_wakeup(l->rx.reverse_connect.task, TASK_WOKEN_ANY);
|
task_wakeup(l->rx.rhttp.task, TASK_WOKEN_ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Invert source and destination addresses if already set. */
|
/* Invert source and destination addresses if already set. */
|
||||||
|
@ -289,13 +289,13 @@ void listener_set_state(struct listener *l, enum li_state st)
|
|||||||
_HA_ATOMIC_INC(&px->li_paused);
|
_HA_ATOMIC_INC(&px->li_paused);
|
||||||
break;
|
break;
|
||||||
case LI_LISTEN:
|
case LI_LISTEN:
|
||||||
BUG_ON(l->rx.fd == -1 && !l->rx.reverse_connect.task);
|
BUG_ON(l->rx.fd == -1 && !l->rx.rhttp.task);
|
||||||
_HA_ATOMIC_INC(&px->li_bound);
|
_HA_ATOMIC_INC(&px->li_bound);
|
||||||
break;
|
break;
|
||||||
case LI_READY:
|
case LI_READY:
|
||||||
case LI_FULL:
|
case LI_FULL:
|
||||||
case LI_LIMITED:
|
case LI_LIMITED:
|
||||||
BUG_ON(l->rx.fd == -1 && !l->rx.reverse_connect.task);
|
BUG_ON(l->rx.fd == -1 && !l->rx.rhttp.task);
|
||||||
_HA_ATOMIC_INC(&px->li_ready);
|
_HA_ATOMIC_INC(&px->li_ready);
|
||||||
l->flags |= LI_F_FINALIZED;
|
l->flags |= LI_F_FINALIZED;
|
||||||
break;
|
break;
|
||||||
@ -322,7 +322,7 @@ void enable_listener(struct listener *listener)
|
|||||||
do_unbind_listener(listener);
|
do_unbind_listener(listener);
|
||||||
|
|
||||||
if (listener->state == LI_LISTEN) {
|
if (listener->state == LI_LISTEN) {
|
||||||
BUG_ON(listener->rx.fd == -1 && !listener->rx.reverse_connect.task);
|
BUG_ON(listener->rx.fd == -1 && !listener->rx.rhttp.task);
|
||||||
if ((global.mode & (MODE_DAEMON | MODE_MWORKER)) &&
|
if ((global.mode & (MODE_DAEMON | MODE_MWORKER)) &&
|
||||||
(!!master != !!(listener->rx.flags & RX_F_MWORKER))) {
|
(!!master != !!(listener->rx.flags & RX_F_MWORKER))) {
|
||||||
/* we don't want to enable this listener and don't
|
/* we don't want to enable this listener and don't
|
||||||
@ -800,9 +800,9 @@ int create_listeners(struct bind_conf *bc, const struct sockaddr_storage *ss,
|
|||||||
l->rx.iocb = proto->default_iocb;
|
l->rx.iocb = proto->default_iocb;
|
||||||
l->rx.fd = fd;
|
l->rx.fd = fd;
|
||||||
|
|
||||||
l->rx.reverse_connect.task = NULL;
|
l->rx.rhttp.task = NULL;
|
||||||
l->rx.reverse_connect.srv = NULL;
|
l->rx.rhttp.srv = NULL;
|
||||||
l->rx.reverse_connect.pend_conn = NULL;
|
l->rx.rhttp.pend_conn = NULL;
|
||||||
|
|
||||||
memcpy(&l->rx.addr, ss, sizeof(*ss));
|
memcpy(&l->rx.addr, ss, sizeof(*ss));
|
||||||
if (proto->fam->set_port)
|
if (proto->fam->set_port)
|
||||||
@ -1959,7 +1959,7 @@ struct bind_conf *bind_conf_alloc(struct proxy *fe, const char *file,
|
|||||||
#endif
|
#endif
|
||||||
LIST_INIT(&bind_conf->listeners);
|
LIST_INIT(&bind_conf->listeners);
|
||||||
|
|
||||||
bind_conf->reverse_srvname = NULL;
|
bind_conf->rhttp_srvname = NULL;
|
||||||
|
|
||||||
return bind_conf;
|
return bind_conf;
|
||||||
|
|
||||||
@ -2260,7 +2260,7 @@ static int bind_parse_nbconn(char **args, int cur_arg, struct proxy *px, struct
|
|||||||
const struct listener *l;
|
const struct listener *l;
|
||||||
|
|
||||||
l = LIST_NEXT(&conf->listeners, struct listener *, by_bind);
|
l = LIST_NEXT(&conf->listeners, struct listener *, by_bind);
|
||||||
if (l->rx.addr.ss_family != AF_CUST_REV_SRV) {
|
if (l->rx.addr.ss_family != AF_CUST_RHTTP_SRV) {
|
||||||
memprintf(err, "'%s' : only valid for reverse HTTP listeners.", args[cur_arg]);
|
memprintf(err, "'%s' : only valid for reverse HTTP listeners.", args[cur_arg]);
|
||||||
return ERR_ALERT | ERR_FATAL;
|
return ERR_ALERT | ERR_FATAL;
|
||||||
}
|
}
|
||||||
@ -2276,7 +2276,7 @@ static int bind_parse_nbconn(char **args, int cur_arg, struct proxy *px, struct
|
|||||||
return ERR_ALERT | ERR_FATAL;
|
return ERR_ALERT | ERR_FATAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
conf->reverse_nbconn = val;
|
conf->rhttp_nbconn = val;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,35 +18,35 @@
|
|||||||
|
|
||||||
#include <haproxy/proto_rhttp.h>
|
#include <haproxy/proto_rhttp.h>
|
||||||
|
|
||||||
struct proto_fam proto_fam_reverse_connect = {
|
struct proto_fam proto_fam_rhttp = {
|
||||||
.name = "reverse_connect",
|
.name = "rhttp",
|
||||||
.sock_domain = AF_CUST_REV_SRV,
|
.sock_domain = AF_CUST_RHTTP_SRV,
|
||||||
.sock_family = AF_INET,
|
.sock_family = AF_INET,
|
||||||
.bind = rev_bind_receiver,
|
.bind = rhttp_bind_receiver,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct protocol proto_reverse_connect = {
|
struct protocol proto_rhttp = {
|
||||||
.name = "rev",
|
.name = "rev",
|
||||||
|
|
||||||
/* connection layer (no outgoing connection) */
|
/* connection layer (no outgoing connection) */
|
||||||
.listen = rev_bind_listener,
|
.listen = rhttp_bind_listener,
|
||||||
.enable = rev_enable_listener,
|
.enable = rhttp_enable_listener,
|
||||||
.disable = rev_disable_listener,
|
.disable = rhttp_disable_listener,
|
||||||
.add = default_add_listener,
|
.add = default_add_listener,
|
||||||
.unbind = rev_unbind_receiver,
|
.unbind = rhttp_unbind_receiver,
|
||||||
.resume = default_resume_listener,
|
.resume = default_resume_listener,
|
||||||
.accept_conn = rev_accept_conn,
|
.accept_conn = rhttp_accept_conn,
|
||||||
.set_affinity = rev_set_affinity,
|
.set_affinity = rhttp_set_affinity,
|
||||||
|
|
||||||
/* address family */
|
/* address family */
|
||||||
.fam = &proto_fam_reverse_connect,
|
.fam = &proto_fam_rhttp,
|
||||||
|
|
||||||
/* socket layer */
|
/* socket layer */
|
||||||
.proto_type = PROTO_TYPE_STREAM,
|
.proto_type = PROTO_TYPE_STREAM,
|
||||||
.sock_type = SOCK_STREAM,
|
.sock_type = SOCK_STREAM,
|
||||||
.sock_prot = IPPROTO_TCP,
|
.sock_prot = IPPROTO_TCP,
|
||||||
.rx_listening = rev_accepting_conn,
|
.rx_listening = rhttp_accepting_conn,
|
||||||
.receivers = LIST_HEAD_INIT(proto_reverse_connect.receivers),
|
.receivers = LIST_HEAD_INIT(proto_rhttp.receivers),
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct connection *new_reverse_conn(struct listener *l, struct server *srv)
|
static struct connection *new_reverse_conn(struct listener *l, struct server *srv)
|
||||||
@ -112,8 +112,7 @@ static struct connection *new_reverse_conn(struct listener *l, struct server *sr
|
|||||||
conn->destroy_cb(conn);
|
conn->destroy_cb(conn);
|
||||||
|
|
||||||
/* Mark connection as non-reversable. This prevents conn_free()
|
/* Mark connection as non-reversable. This prevents conn_free()
|
||||||
* to reschedule reverse_connect task on freeing a preconnect
|
* to reschedule rhttp task on freeing a preconnect connection.
|
||||||
* connection.
|
|
||||||
*/
|
*/
|
||||||
conn->reverse.target = NULL;
|
conn->reverse.target = NULL;
|
||||||
conn_free(conn);
|
conn_free(conn);
|
||||||
@ -126,33 +125,33 @@ static struct connection *new_reverse_conn(struct listener *l, struct server *sr
|
|||||||
* reversal is completed. This is used to cleanup any reference to the
|
* reversal is completed. This is used to cleanup any reference to the
|
||||||
* connection and rearm a new preconnect attempt.
|
* connection and rearm a new preconnect attempt.
|
||||||
*/
|
*/
|
||||||
void rev_notify_preconn_err(struct listener *l)
|
void rhttp_notify_preconn_err(struct listener *l)
|
||||||
{
|
{
|
||||||
/* For the moment reverse connection are bound only on first thread. */
|
/* For the moment reverse connection are bound only on first thread. */
|
||||||
BUG_ON(tid != 0);
|
BUG_ON(tid != 0);
|
||||||
|
|
||||||
/* Receiver must reference a reverse connection as pending. */
|
/* Receiver must reference a reverse connection as pending. */
|
||||||
BUG_ON(!l->rx.reverse_connect.pend_conn);
|
BUG_ON(!l->rx.rhttp.pend_conn);
|
||||||
|
|
||||||
/* Remove reference to the freed connection. */
|
/* Remove reference to the freed connection. */
|
||||||
l->rx.reverse_connect.pend_conn = NULL;
|
l->rx.rhttp.pend_conn = NULL;
|
||||||
|
|
||||||
if (l->rx.reverse_connect.state != LI_PRECONN_ST_ERR) {
|
if (l->rx.rhttp.state != LI_PRECONN_ST_ERR) {
|
||||||
send_log(l->bind_conf->frontend, LOG_ERR,
|
send_log(l->bind_conf->frontend, LOG_ERR,
|
||||||
"preconnect %s::%s: Error encountered.\n",
|
"preconnect %s::%s: Error encountered.\n",
|
||||||
l->bind_conf->frontend->id, l->bind_conf->reverse_srvname);
|
l->bind_conf->frontend->id, l->bind_conf->rhttp_srvname);
|
||||||
l->rx.reverse_connect.state = LI_PRECONN_ST_ERR;
|
l->rx.rhttp.state = LI_PRECONN_ST_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Rearm a new preconnect attempt. */
|
/* Rearm a new preconnect attempt. */
|
||||||
l->rx.reverse_connect.task->expire = MS_TO_TICKS(now_ms + 1000);
|
l->rx.rhttp.task->expire = MS_TO_TICKS(now_ms + 1000);
|
||||||
task_queue(l->rx.reverse_connect.task);
|
task_queue(l->rx.rhttp.task);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct task *rev_process(struct task *task, void *ctx, unsigned int state)
|
struct task *rhttp_process(struct task *task, void *ctx, unsigned int state)
|
||||||
{
|
{
|
||||||
struct listener *l = ctx;
|
struct listener *l = ctx;
|
||||||
struct connection *conn = l->rx.reverse_connect.pend_conn;
|
struct connection *conn = l->rx.rhttp.pend_conn;
|
||||||
|
|
||||||
if (conn) {
|
if (conn) {
|
||||||
/* Either connection is on error ot the connect timeout fired. */
|
/* Either connection is on error ot the connect timeout fired. */
|
||||||
@ -176,8 +175,8 @@ struct task *rev_process(struct task *task, void *ctx, unsigned int state)
|
|||||||
conn_free(conn);
|
conn_free(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* conn_free() must report preconnect failure using rev_notify_preconn_err(). */
|
/* conn_free() must report preconnect failure using rhttp_notify_preconn_err(). */
|
||||||
BUG_ON(l->rx.reverse_connect.pend_conn);
|
BUG_ON(l->rx.rhttp.pend_conn);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Spurious receiver task woken up despite pend_conn not ready/on error. */
|
/* Spurious receiver task woken up despite pend_conn not ready/on error. */
|
||||||
@ -185,21 +184,21 @@ struct task *rev_process(struct task *task, void *ctx, unsigned int state)
|
|||||||
|
|
||||||
/* A connection is ready to be accepted. */
|
/* A connection is ready to be accepted. */
|
||||||
listener_accept(l);
|
listener_accept(l);
|
||||||
l->rx.reverse_connect.task->expire = TICK_ETERNITY;
|
l->rx.rhttp.task->expire = TICK_ETERNITY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
struct server *srv = l->rx.reverse_connect.srv;
|
struct server *srv = l->rx.rhttp.srv;
|
||||||
|
|
||||||
/* No pending reverse connection, prepare a new one. Store it in the
|
/* No pending reverse connection, prepare a new one. Store it in the
|
||||||
* listener and return NULL. Connection will be returned later after
|
* listener and return NULL. Connection will be returned later after
|
||||||
* reversal is completed.
|
* reversal is completed.
|
||||||
*/
|
*/
|
||||||
conn = new_reverse_conn(l, srv);
|
conn = new_reverse_conn(l, srv);
|
||||||
l->rx.reverse_connect.pend_conn = conn;
|
l->rx.rhttp.pend_conn = conn;
|
||||||
|
|
||||||
/* On success task will be woken up by H2 mux after reversal. */
|
/* On success task will be woken up by H2 mux after reversal. */
|
||||||
l->rx.reverse_connect.task->expire = conn ?
|
l->rx.rhttp.task->expire = conn ?
|
||||||
tick_add_ifset(now_ms, srv->proxy->timeout.connect) :
|
tick_add_ifset(now_ms, srv->proxy->timeout.connect) :
|
||||||
MS_TO_TICKS(now_ms + 1000);
|
MS_TO_TICKS(now_ms + 1000);
|
||||||
}
|
}
|
||||||
@ -207,13 +206,13 @@ struct task *rev_process(struct task *task, void *ctx, unsigned int state)
|
|||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rev_bind_receiver(struct receiver *rx, char **errmsg)
|
int rhttp_bind_receiver(struct receiver *rx, char **errmsg)
|
||||||
{
|
{
|
||||||
rx->flags |= RX_F_BOUND;
|
rx->flags |= RX_F_BOUND;
|
||||||
return ERR_NONE;
|
return ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rev_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
int rhttp_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
||||||
{
|
{
|
||||||
struct task *task;
|
struct task *task;
|
||||||
struct proxy *be;
|
struct proxy *be;
|
||||||
@ -226,21 +225,21 @@ int rev_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
|||||||
snprintf(errmsg, errlen, "Out of memory.");
|
snprintf(errmsg, errlen, "Out of memory.");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
task->process = rev_process;
|
task->process = rhttp_process;
|
||||||
task->context = listener;
|
task->context = listener;
|
||||||
listener->rx.reverse_connect.task = task;
|
listener->rx.rhttp.task = task;
|
||||||
listener->rx.reverse_connect.state = LI_PRECONN_ST_STOP;
|
listener->rx.rhttp.state = LI_PRECONN_ST_STOP;
|
||||||
|
|
||||||
/* Set maxconn which is defined via the special kw nbconn for reverse
|
/* Set maxconn which is defined via the special kw nbconn for reverse
|
||||||
* connect. Use a default value of 1 if not set. This guarantees that
|
* connect. Use a default value of 1 if not set. This guarantees that
|
||||||
* listener will be automatically re-enable each time it fell back below
|
* listener will be automatically re-enable each time it fell back below
|
||||||
* it due to a connection error.
|
* it due to a connection error.
|
||||||
*/
|
*/
|
||||||
listener->bind_conf->maxconn = listener->bind_conf->reverse_nbconn;
|
listener->bind_conf->maxconn = listener->bind_conf->rhttp_nbconn;
|
||||||
if (!listener->bind_conf->maxconn)
|
if (!listener->bind_conf->maxconn)
|
||||||
listener->bind_conf->maxconn = 1;
|
listener->bind_conf->maxconn = 1;
|
||||||
|
|
||||||
name = strdup(listener->bind_conf->reverse_srvname);
|
name = strdup(listener->bind_conf->rhttp_srvname);
|
||||||
if (!name) {
|
if (!name) {
|
||||||
snprintf(errmsg, errlen, "Out of memory.");
|
snprintf(errmsg, errlen, "Out of memory.");
|
||||||
goto err;
|
goto err;
|
||||||
@ -262,8 +261,8 @@ int rev_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (srv->flags & SRV_F_REVERSE) {
|
if (srv->flags & SRV_F_RHTTP) {
|
||||||
snprintf(errmsg, errlen, "Cannot use reverse server '%s/%s' as target to a reverse bind.", ist0(be_name), ist0(sv_name));
|
snprintf(errmsg, errlen, "Cannot use reverse HTTP server '%s/%s' as target to a reverse bind.", ist0(be_name), ist0(sv_name));
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,7 +289,7 @@ int rev_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
|||||||
|
|
||||||
ha_free(&name);
|
ha_free(&name);
|
||||||
|
|
||||||
listener->rx.reverse_connect.srv = srv;
|
listener->rx.rhttp.srv = srv;
|
||||||
listener_set_state(listener, LI_LISTEN);
|
listener_set_state(listener, LI_LISTEN);
|
||||||
|
|
||||||
return ERR_NONE;
|
return ERR_NONE;
|
||||||
@ -300,32 +299,32 @@ int rev_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
|||||||
return ERR_ALERT | ERR_FATAL;
|
return ERR_ALERT | ERR_FATAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rev_enable_listener(struct listener *l)
|
void rhttp_enable_listener(struct listener *l)
|
||||||
{
|
{
|
||||||
if (l->rx.reverse_connect.state < LI_PRECONN_ST_INIT) {
|
if (l->rx.rhttp.state < LI_PRECONN_ST_INIT) {
|
||||||
send_log(l->bind_conf->frontend, LOG_INFO,
|
send_log(l->bind_conf->frontend, LOG_INFO,
|
||||||
"preconnect %s::%s: Initiating.\n",
|
"preconnect %s::%s: Initiating.\n",
|
||||||
l->bind_conf->frontend->id, l->bind_conf->reverse_srvname);
|
l->bind_conf->frontend->id, l->bind_conf->rhttp_srvname);
|
||||||
l->rx.reverse_connect.state = LI_PRECONN_ST_INIT;
|
l->rx.rhttp.state = LI_PRECONN_ST_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
task_wakeup(l->rx.reverse_connect.task, TASK_WOKEN_ANY);
|
task_wakeup(l->rx.rhttp.task, TASK_WOKEN_ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rev_disable_listener(struct listener *l)
|
void rhttp_disable_listener(struct listener *l)
|
||||||
{
|
{
|
||||||
if (l->rx.reverse_connect.state < LI_PRECONN_ST_FULL) {
|
if (l->rx.rhttp.state < LI_PRECONN_ST_FULL) {
|
||||||
send_log(l->bind_conf->frontend, LOG_INFO,
|
send_log(l->bind_conf->frontend, LOG_INFO,
|
||||||
"preconnect %s::%s: Running with nbconn %d reached.\n",
|
"preconnect %s::%s: Running with nbconn %d reached.\n",
|
||||||
l->bind_conf->frontend->id, l->bind_conf->reverse_srvname,
|
l->bind_conf->frontend->id, l->bind_conf->rhttp_srvname,
|
||||||
l->bind_conf->maxconn);
|
l->bind_conf->maxconn);
|
||||||
l->rx.reverse_connect.state = LI_PRECONN_ST_FULL;
|
l->rx.rhttp.state = LI_PRECONN_ST_FULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct connection *rev_accept_conn(struct listener *l, int *status)
|
struct connection *rhttp_accept_conn(struct listener *l, int *status)
|
||||||
{
|
{
|
||||||
struct connection *conn = l->rx.reverse_connect.pend_conn;
|
struct connection *conn = l->rx.rhttp.pend_conn;
|
||||||
|
|
||||||
if (!conn) {
|
if (!conn) {
|
||||||
/* Reverse connect listener must have an explicit maxconn set
|
/* Reverse connect listener must have an explicit maxconn set
|
||||||
@ -335,8 +334,8 @@ struct connection *rev_accept_conn(struct listener *l, int *status)
|
|||||||
|
|
||||||
/* Instantiate a new conn if maxconn not yet exceeded. */
|
/* Instantiate a new conn if maxconn not yet exceeded. */
|
||||||
if (l->nbconn <= l->bind_conf->maxconn) {
|
if (l->nbconn <= l->bind_conf->maxconn) {
|
||||||
l->rx.reverse_connect.pend_conn = new_reverse_conn(l, l->rx.reverse_connect.srv);
|
l->rx.rhttp.pend_conn = new_reverse_conn(l, l->rx.rhttp.srv);
|
||||||
if (!l->rx.reverse_connect.pend_conn) {
|
if (!l->rx.rhttp.pend_conn) {
|
||||||
*status = CO_AC_PAUSE;
|
*status = CO_AC_PAUSE;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -352,18 +351,18 @@ struct connection *rev_accept_conn(struct listener *l, int *status)
|
|||||||
conn->flags |= CO_FL_REVERSED;
|
conn->flags |= CO_FL_REVERSED;
|
||||||
conn->mux->ctl(conn, MUX_REVERSE_CONN, NULL);
|
conn->mux->ctl(conn, MUX_REVERSE_CONN, NULL);
|
||||||
|
|
||||||
l->rx.reverse_connect.pend_conn = NULL;
|
l->rx.rhttp.pend_conn = NULL;
|
||||||
*status = CO_AC_NONE;
|
*status = CO_AC_NONE;
|
||||||
|
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rev_unbind_receiver(struct listener *l)
|
void rhttp_unbind_receiver(struct listener *l)
|
||||||
{
|
{
|
||||||
l->rx.flags &= ~RX_F_BOUND;
|
l->rx.flags &= ~RX_F_BOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rev_set_affinity(struct connection *conn, int new_tid)
|
int rhttp_set_affinity(struct connection *conn, int new_tid)
|
||||||
{
|
{
|
||||||
/* TODO reversal conn rebinding after is disabled for the moment as we
|
/* TODO reversal conn rebinding after is disabled for the moment as we
|
||||||
* did not test possible race conditions.
|
* did not test possible race conditions.
|
||||||
@ -371,9 +370,9 @@ int rev_set_affinity(struct connection *conn, int new_tid)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rev_accepting_conn(const struct receiver *rx)
|
int rhttp_accepting_conn(const struct receiver *rx)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
INITCALL1(STG_REGISTER, protocol_register, &proto_reverse_connect);
|
INITCALL1(STG_REGISTER, protocol_register, &proto_rhttp);
|
||||||
|
@ -358,7 +358,7 @@ void free_proxy(struct proxy *p)
|
|||||||
free(l->name);
|
free(l->name);
|
||||||
free(l->per_thr);
|
free(l->per_thr);
|
||||||
free(l->counters);
|
free(l->counters);
|
||||||
task_destroy(l->rx.reverse_connect.task);
|
task_destroy(l->rx.rhttp.task);
|
||||||
|
|
||||||
EXTRA_COUNTERS_FREE(l->extra_counters);
|
EXTRA_COUNTERS_FREE(l->extra_counters);
|
||||||
free(l);
|
free(l);
|
||||||
@ -372,7 +372,7 @@ void free_proxy(struct proxy *p)
|
|||||||
free(bind_conf->arg);
|
free(bind_conf->arg);
|
||||||
free(bind_conf->settings.interface);
|
free(bind_conf->settings.interface);
|
||||||
LIST_DELETE(&bind_conf->by_fe);
|
LIST_DELETE(&bind_conf->by_fe);
|
||||||
free(bind_conf->reverse_srvname);
|
free(bind_conf->rhttp_srvname);
|
||||||
free(bind_conf);
|
free(bind_conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3009,12 +3009,12 @@ static int _srv_parse_init(struct server **srv, char **args, int *cur_arg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!port1 || !port2) {
|
if (!port1 || !port2) {
|
||||||
if (sk->ss_family != AF_CUST_REV_SRV) {
|
if (sk->ss_family != AF_CUST_RHTTP_SRV) {
|
||||||
/* no port specified, +offset, -offset */
|
/* no port specified, +offset, -offset */
|
||||||
newsrv->flags |= SRV_F_MAPPORTS;
|
newsrv->flags |= SRV_F_MAPPORTS;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
newsrv->flags |= SRV_F_REVERSE;
|
newsrv->flags |= SRV_F_RHTTP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1105,7 +1105,7 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
|
|||||||
}
|
}
|
||||||
else if (strncmp(str2, "rhttp@", 3) == 0) {
|
else if (strncmp(str2, "rhttp@", 3) == 0) {
|
||||||
str2 += 4;
|
str2 += 4;
|
||||||
ss.ss_family = AF_CUST_REV_SRV;
|
ss.ss_family = AF_CUST_RHTTP_SRV;
|
||||||
}
|
}
|
||||||
else if (*str2 == '/') {
|
else if (*str2 == '/') {
|
||||||
ss.ss_family = AF_UNIX;
|
ss.ss_family = AF_UNIX;
|
||||||
@ -1194,7 +1194,7 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
|
|||||||
memcpy(un->sun_path, pfx, prefix_path_len);
|
memcpy(un->sun_path, pfx, prefix_path_len);
|
||||||
memcpy(un->sun_path + prefix_path_len + abstract, str2, adr_len + 1 - abstract);
|
memcpy(un->sun_path + prefix_path_len + abstract, str2, adr_len + 1 - abstract);
|
||||||
}
|
}
|
||||||
else if (ss.ss_family == AF_CUST_REV_SRV) {
|
else if (ss.ss_family == AF_CUST_RHTTP_SRV) {
|
||||||
/* Nothing to do here. */
|
/* Nothing to do here. */
|
||||||
}
|
}
|
||||||
else { /* IPv4 and IPv6 */
|
else { /* IPv4 and IPv6 */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user