]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: log: add a new cookie flag 'U' to report situations where cookie is not used
authorWilly Tarreau <w@1wt.eu>
Thu, 5 Apr 2012 19:18:22 +0000 (21:18 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 5 Apr 2012 19:18:22 +0000 (21:18 +0200)
This happens when a "use-server" rule sets the server instead.

doc/configuration.txt
include/types/proto_http.h
src/log.c
src/proto_http.c

index 337cfad8a29bc00c4aa1bef619940d3e4d180f6d..de052e1d93649f45f994e0245062c169063f4fe4 100644 (file)
@@ -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
index 51f321ece9481b2624406b4f20b8159bf94001e3..7a10f811d161d36ca20776d121479dd773209a4e 100644 (file)
@@ -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 */
 
index 3b65c28fb81308abb5c02b47a12279152f9c43d1..9065a5b38c3fa4c92ccf534e731903f8921dc89a 100644 (file)
--- 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 */
index 9af3f690b7f0ded8ef82076870388a370a2f396b..75c5488b87234968f8299f3630d85ab2d3526024 100644 (file)
@@ -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 :