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 337cfad..de052e1 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -9184,6 +9184,10 @@
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 51f321e..7a10f81 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 3b65c28..9065a5b 100644
--- a/src/log.c
+++ b/src/log.c
@@ -688,7 +688,7 @@
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 9af3f69..75c5488 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -6249,9 +6249,12 @@
}
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 :