mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-24 12:20:59 +01:00
MEDIUM: sessions: Introduce session flags.
Add session flags, and add a new flag, SESS_FL_PREFER_LAST, to be set when we use NTLM authentication, and we should reuse the last connection. This should fix using NTLM with HTX. This totally replaces TX_PREFER_LAST. This should be backported to 1.9.
This commit is contained in:
parent
1146f975a9
commit
250031e444
@ -275,7 +275,6 @@ void show_txn_flags(unsigned int f)
|
|||||||
SHOW_FLAG(f, TX_HDR_CONN_PRS);
|
SHOW_FLAG(f, TX_HDR_CONN_PRS);
|
||||||
SHOW_FLAG(f, TX_WAIT_NEXT_RQ);
|
SHOW_FLAG(f, TX_WAIT_NEXT_RQ);
|
||||||
SHOW_FLAG(f, TX_HDR_CONN_UPG);
|
SHOW_FLAG(f, TX_HDR_CONN_UPG);
|
||||||
SHOW_FLAG(f, TX_PREFER_LAST);
|
|
||||||
SHOW_FLAG(f, TX_CON_KAL_SET);
|
SHOW_FLAG(f, TX_CON_KAL_SET);
|
||||||
SHOW_FLAG(f, TX_CON_CLO_SET);
|
SHOW_FLAG(f, TX_CON_CLO_SET);
|
||||||
|
|
||||||
|
|||||||
@ -94,7 +94,7 @@
|
|||||||
#define TX_CON_CLO_SET 0x00400000 /* "connection: close" is now set */
|
#define TX_CON_CLO_SET 0x00400000 /* "connection: close" is now set */
|
||||||
#define TX_CON_KAL_SET 0x00800000 /* "connection: keep-alive" is now set */
|
#define TX_CON_KAL_SET 0x00800000 /* "connection: keep-alive" is now set */
|
||||||
|
|
||||||
#define TX_PREFER_LAST 0x01000000 /* try to stay on same server if possible (eg: after 401) */
|
/* unused: 0x01000000 */
|
||||||
|
|
||||||
#define TX_HDR_CONN_UPG 0x02000000 /* The "Upgrade" token was found in the "Connection" header */
|
#define TX_HDR_CONN_UPG 0x02000000 /* The "Upgrade" token was found in the "Connection" header */
|
||||||
#define TX_WAIT_NEXT_RQ 0x04000000 /* waiting for the second request to start, use keep-alive timeout */
|
#define TX_WAIT_NEXT_RQ 0x04000000 /* waiting for the second request to start, use keep-alive timeout */
|
||||||
|
|||||||
@ -45,6 +45,12 @@ struct sess_srv_list {
|
|||||||
|
|
||||||
#define MAX_SRV_LIST 5
|
#define MAX_SRV_LIST 5
|
||||||
|
|
||||||
|
/* session flags */
|
||||||
|
enum {
|
||||||
|
SESS_FL_NONE = 0x00000000, /* nothing */
|
||||||
|
SESS_FL_PREFER_LAST = 0x00000001, /* NTML authent, we should reuse last conn */
|
||||||
|
};
|
||||||
|
|
||||||
struct session {
|
struct session {
|
||||||
struct proxy *fe; /* the proxy this session depends on for the client side */
|
struct proxy *fe; /* the proxy this session depends on for the client side */
|
||||||
struct listener *listener; /* the listener by which the request arrived */
|
struct listener *listener; /* the listener by which the request arrived */
|
||||||
@ -57,6 +63,7 @@ struct session {
|
|||||||
long t_handshake; /* handshake duration, -1 = not completed */
|
long t_handshake; /* handshake duration, -1 = not completed */
|
||||||
int idle_conns; /* Number of connections we're currently responsible for that we are not using */
|
int idle_conns; /* Number of connections we're currently responsible for that we are not using */
|
||||||
struct list srv_list; /* List of servers and the connections the session is currently responsible for */
|
struct list srv_list; /* List of servers and the connections the session is currently responsible for */
|
||||||
|
unsigned int flags; /* session flags, SESS_FL_* */
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _TYPES_SESSION_H */
|
#endif /* _TYPES_SESSION_H */
|
||||||
|
|||||||
@ -647,14 +647,14 @@ int assign_server(struct stream *s)
|
|||||||
s->target = NULL;
|
s->target = NULL;
|
||||||
|
|
||||||
if ((s->be->lbprm.algo & BE_LB_KIND) != BE_LB_KIND_HI &&
|
if ((s->be->lbprm.algo & BE_LB_KIND) != BE_LB_KIND_HI &&
|
||||||
((s->txn && s->txn->flags & TX_PREFER_LAST) ||
|
((s->sess->flags & SESS_FL_PREFER_LAST) ||
|
||||||
(s->be->options & PR_O_PREF_LAST))) {
|
(s->be->options & PR_O_PREF_LAST))) {
|
||||||
struct sess_srv_list *srv_list;
|
struct sess_srv_list *srv_list;
|
||||||
list_for_each_entry(srv_list, &s->sess->srv_list, srv_list) {
|
list_for_each_entry(srv_list, &s->sess->srv_list, srv_list) {
|
||||||
struct server *tmpsrv = objt_server(srv_list->target);
|
struct server *tmpsrv = objt_server(srv_list->target);
|
||||||
|
|
||||||
if (tmpsrv && tmpsrv->proxy == s->be &&
|
if (tmpsrv && tmpsrv->proxy == s->be &&
|
||||||
((s->txn && s->txn->flags & TX_PREFER_LAST) ||
|
((s->sess->flags & SESS_FL_PREFER_LAST) ||
|
||||||
(!s->be->max_ka_queue ||
|
(!s->be->max_ka_queue ||
|
||||||
server_has_room(tmpsrv) || (
|
server_has_room(tmpsrv) || (
|
||||||
tmpsrv->nbpend + 1 < s->be->max_ka_queue))) &&
|
tmpsrv->nbpend + 1 < s->be->max_ka_queue))) &&
|
||||||
|
|||||||
@ -3542,7 +3542,7 @@ void http_end_txn_clean_session(struct stream *s)
|
|||||||
* it's better to do it (at least it helps with debugging), at
|
* it's better to do it (at least it helps with debugging), at
|
||||||
* least for non-deterministic load balancing algorithms.
|
* least for non-deterministic load balancing algorithms.
|
||||||
*/
|
*/
|
||||||
s->txn->flags |= TX_PREFER_LAST;
|
s->sess->flags |= SESS_FL_PREFER_LAST;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Never ever allow to reuse a connection from a non-reuse backend */
|
/* Never ever allow to reuse a connection from a non-reuse backend */
|
||||||
|
|||||||
@ -1777,8 +1777,10 @@ int htx_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
|||||||
ctx.blk = NULL;
|
ctx.blk = NULL;
|
||||||
while (http_find_header(htx, hdr, &ctx, 0)) {
|
while (http_find_header(htx, hdr, &ctx, 0)) {
|
||||||
if ((ctx.value.len >= 9 && word_match(ctx.value.ptr, ctx.value.len, "Negotiate", 9)) ||
|
if ((ctx.value.len >= 9 && word_match(ctx.value.ptr, ctx.value.len, "Negotiate", 9)) ||
|
||||||
(ctx.value.len >= 4 && word_match(ctx.value.ptr, ctx.value.len, "NTLM", 4)))
|
(ctx.value.len >= 4 && word_match(ctx.value.ptr, ctx.value.len, "NTLM", 4))) {
|
||||||
|
sess->flags |= SESS_FL_PREFER_LAST;
|
||||||
srv_conn->flags |= CO_FL_PRIVATE;
|
srv_conn->flags |= CO_FL_PRIVATE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -59,6 +59,7 @@ struct session *session_new(struct proxy *fe, struct listener *li, enum obj_type
|
|||||||
_HA_ATOMIC_ADD(&jobs, 1);
|
_HA_ATOMIC_ADD(&jobs, 1);
|
||||||
LIST_INIT(&sess->srv_list);
|
LIST_INIT(&sess->srv_list);
|
||||||
sess->idle_conns = 0;
|
sess->idle_conns = 0;
|
||||||
|
sess->flags = SESS_FL_NONE;
|
||||||
}
|
}
|
||||||
return sess;
|
return sess;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user