From: Willy Tarreau Date: Thu, 5 Apr 2012 19:18:22 +0000 (+0200) Subject: MEDIUM: log: add a new cookie flag 'U' to report situations where cookie is not used X-Git-Tag: v1.5-dev9~116 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c89ccb62211cc0b9cb7d1a62508077cc12b78085;p=thirdparty%2Fhaproxy.git MEDIUM: log: add a new cookie flag 'U' to report situations where cookie is not used This happens when a "use-server" rule sets the server instead. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index 337cfad8a2..de052e1d93 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -9184,6 +9184,10 @@ each of which has a special meaning : the cookie is consider too OLD and is ignored. The request will be redispatched just as if there was no cookie. + U : a cookie was present but was not used to select the server because + some other server selection mechanism was used instead (typically a + "use-server" rule). + - : does not apply (no cookie set in configuration). - the last character reports what operations were performed on the persistence diff --git a/include/types/proto_http.h b/include/types/proto_http.h index 51f321ece9..7a10f811d1 100644 --- a/include/types/proto_http.h +++ b/include/types/proto_http.h @@ -43,6 +43,7 @@ #define TX_CK_VALID 0x00000060 /* this session had cookie matching a valid server */ #define TX_CK_EXPIRED 0x00000080 /* this session had an expired cookie (idle for too long) */ #define TX_CK_OLD 0x000000A0 /* this session had too old a cookie (offered too long ago) */ +#define TX_CK_UNUSED 0x000000C0 /* this session had a cookie but it was not used (eg: use-server was preferred) */ #define TX_CK_MASK 0x000000E0 /* mask to get this session's cookie flags */ #define TX_CK_SHIFT 5 /* bit shift */ diff --git a/src/log.c b/src/log.c index 3b65c28fb8..9065a5b38c 100644 --- a/src/log.c +++ b/src/log.c @@ -688,7 +688,7 @@ extern fd_set hdr_encode_map[]; extern fd_set url_encode_map[]; -const char sess_cookie[8] = "NIDVEO67"; /* No cookie, Invalid cookie, cookie for a Down server, Valid cookie, Expired cookie, Old cookie, unknown */ +const char sess_cookie[8] = "NIDVEOU7"; /* No cookie, Invalid cookie, cookie for a Down server, Valid cookie, Expired cookie, Old cookie, Unused, unknown */ const char sess_set_cookie[8] = "NPDIRU67"; /* No set-cookie, Set-cookie found and left unchanged (passive), Set-cookie Deleted, Set-Cookie Inserted, Set-cookie Rewritten, Set-cookie Updated, unknown, unknown */ diff --git a/src/proto_http.c b/src/proto_http.c index 9af3f690b7..75c5488b87 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -6249,9 +6249,12 @@ void manage_client_side_cookies(struct session *t, struct buffer *req) } if (!srv && !(txn->flags & (TX_CK_DOWN|TX_CK_EXPIRED|TX_CK_OLD))) { - /* no server matched this cookie */ + /* no server matched this cookie or we deliberately skipped it */ txn->flags &= ~TX_CK_MASK; - txn->flags |= TX_CK_INVALID; + if ((t->flags & (SN_IGNORE_PRST | SN_ASSIGNED))) + txn->flags |= TX_CK_UNUSED; + else + txn->flags |= TX_CK_INVALID; } /* depending on the cookie mode, we may have to either :