@@ -207,6 +207,7 @@ tfw_http_sticky_get_req(TfwHttpReq *req, TfwStr *cookie_val)
207207 TfwStr * hdr , * end , * dup ;
208208 int r = 0 ;
209209
210+ pr_notice ("tfw_http_sticky_get_req\n" );
210211 /*
211212 * Find a 'Cookie:' header field in the request. Then search for
212213 * Tempesta sticky cookie within the field. In HTTP/1.x requests
@@ -498,6 +499,7 @@ tfw_http_sticky_verify(TfwHttpReq *req, TfwStr *value, StickyVal *sv)
498499 TfwStr * c , * end ;
499500 TfwStickyCookie * sticky = req -> vhost -> cookie ;
500501
502+ pr_notice ("tfw_http_sticky_verify\n" );
501503 T_DBG ("Sticky cookie found: \"%.*s\" = \"%.*s\"%s\n" ,
502504 PR_TFW_STR (& sticky -> name ),
503505 TFW_STR_PLAIN (value ) ?
@@ -508,8 +510,10 @@ tfw_http_sticky_verify(TfwHttpReq *req, TfwStr *value, StickyVal *sv)
508510 value -> chunks -> data ,
509511 TFW_STR_PLAIN (value ) ? "" : "<truncated>" );
510512
511- if (sticky -> learn )
513+ if (sticky -> learn ) {
514+ pr_notice ("sticky->learn\n" );
512515 return TFW_HTTP_SESS_SUCCESS ;
516+ }
513517
514518 if (value -> len != sizeof (StickyVal ) * 2 ) {
515519 sess_warn ("bad sticky cookie length" , addr , " %lu(%lu)\n" ,
@@ -530,6 +534,11 @@ tfw_http_sticky_verify(TfwHttpReq *req, TfwStr *value, StickyVal *sv)
530534 return r ;
531535
532536 /* The cookie is valid but already expired, reject it. */
537+ pr_notice ("jiffies=%lu sv->ts=%lu sticky->sess_lifetime * HZ=%lu sticky->sess_lifetime=%i" ,
538+ jiffies ,
539+ sv -> ts ,
540+ (unsigned long )sticky -> sess_lifetime * HZ , sticky -> sess_lifetime );
541+
533542 if (jiffies > sv -> ts + (unsigned long )sticky -> sess_lifetime * HZ ) {
534543 sess_warn ("sticky cookie value expired" , addr ,
535544 " (issued=%lu lifetime=%lu now=%lu)\n" , sv -> ts ,
@@ -539,6 +548,7 @@ tfw_http_sticky_verify(TfwHttpReq *req, TfwStr *value, StickyVal *sv)
539548
540549 /* Sticky cookie is found and verified, now we can set the flag. */
541550 __set_bit (TFW_HTTP_B_HAS_STICKY , req -> flags );
551+ pr_notice ("TFW_HTTP_B_HAS_STICKY\n" );
542552
543553 return r ;
544554}
@@ -551,20 +561,25 @@ tfw_http_sticky_req_process(TfwHttpReq *req, StickyVal *sv, TfwStr *cookie_val)
551561{
552562 int r ;
553563
564+ pr_notice ("tfw_http_sticky_req_process\n" );
554565 /*
555566 * See if the Tempesta sticky cookie is present in the request,
556567 * and act depending on the result.
557568 */
558569 r = tfw_http_sticky_get_req (req , cookie_val );
570+
571+ pr_notice ("tfw_http_sticky_get_req result =%i\n" , r );
559572 if (r < 0 )
560573 return r ;
561574 if (r == 0 ) {
562575 return !req -> vhost -> cookie -> enforce ?
563576 TFW_HTTP_SESS_SUCCESS : TFW_HTTP_SESS_COOKIE_NOT_FOUND ;
564577 }
565578 if (r == 1 ) {
566- if ((r = tfw_http_sticky_verify (req , cookie_val , sv )))
579+ if ((r = tfw_http_sticky_verify (req , cookie_val , sv ))) {
580+ pr_notice ("tfw_http_sticky_verify result =%i\n" , r );
567581 return r ;
582+ }
568583
569584 return TFW_HTTP_SESS_SUCCESS ;
570585 }
@@ -590,17 +605,20 @@ tfw_http_sess_resp_process(TfwHttpResp *resp, bool cache,
590605 {
591606 return 0 ;
592607 }
593- BUG_ON (!req -> sess );
608+ if (req -> need_jsch ) {
609+ BUG_ON (!req -> sess );
594610
595- /*
596- * RFC 6265 4.1.1 and 4.1.2 says that we should not set session cookie
597- * if it's not necessary. Since client didn't send up the cookie and
598- * it seems that we don't enforce them, we can just set the cookie in
599- * each response forwarded to the client.
600- */
601- if (test_bit (TFW_HTTP_B_HAS_STICKY , req -> flags ))
602- return 0 ;
603- return tfw_http_sticky_add (resp , cache , stream_id );
611+ /*
612+ * RFC 6265 4.1.1 and 4.1.2 says that we should not set session cookie
613+ * if it's not necessary. Since client didn't send up the cookie and
614+ * it seems that we don't enforce them, we can just set the cookie in
615+ * each response forwarded to the client.
616+ */
617+ if (test_bit (TFW_HTTP_B_HAS_STICKY , req -> flags ))
618+ return 0 ;
619+ return tfw_http_sticky_add (resp , cache , stream_id );
620+ }
621+ return 0 ;
604622}
605623
606624/**
@@ -623,6 +641,7 @@ tfw_http_sess_unpin_srv(TfwHttpSess *sess)
623641static inline void
624642tfw_http_sess_set_expired (TfwHttpSess * sess )
625643{
644+ pr_notice ("tfw_http_sess_set_expired\n" );
626645 atomic64_set (& sess -> expires , 0 );
627646}
628647
@@ -631,6 +650,7 @@ tfw_http_sess_prolong(TfwHttpSess *sess, TfwStickyCookie *sticky)
631650{
632651 if (!sticky -> learn )
633652 return ;
653+ pr_notice ("tfw_http_sess_prolong\n" );
634654 atomic64_set (& sess -> expires ,
635655 jiffies + (unsigned long )sticky -> sess_lifetime * HZ );
636656}
@@ -668,6 +688,8 @@ tfw_http_sess_check_jsch(StickyVal *sv, TfwHttpReq* req)
668688{
669689 unsigned long min_time ;
670690 TfwCfgJsCh * js_ch = req -> vhost -> cookie -> js_challenge ;
691+ if (!req -> need_jsch )
692+ return 0 ;
671693
672694 if (!js_ch )
673695 return 0 ;
@@ -701,6 +723,7 @@ tfw_http_sess_eq(TdbRec *rec, void *data)
701723 * Expired or invalid session is not usable, leave it for garbage
702724 * collector.
703725 */
726+ pr_notice ("tfw_http_sess_eq\n" );
704727 if (((unsigned long )atomic64_read (& sess -> expires ) < jiffies )
705728 || !sess -> vhost )
706729 {
@@ -793,6 +816,7 @@ tfw_sess_ent_init(TdbRec *rec, void *data)
793816 sess -> ts = ctx -> sv .ts ;
794817 }
795818
819+ pr_notice ("tfw_sess_ent_init\n" );
796820 atomic_set (& sess -> users , 1 );
797821 atomic64_set (& sess -> expires ,
798822 sess -> ts + (unsigned long )sticky -> sess_lifetime * HZ );
@@ -825,6 +849,7 @@ tfw_http_sess_obtain(TfwHttpReq *req)
825849 TdbRec * rec ;
826850 TdbGetAllocCtx tdb_ctx = { 0 };
827851
852+ pr_notice ("tfw_http_sess_obtain\n" );
828853 /*
829854 * If vhost is not known, then request is to be dropped. Don't save the
830855 * session even if the client has passed a cookie challenge.
@@ -845,20 +870,22 @@ tfw_http_sess_obtain(TfwHttpReq *req)
845870 * We leave this for administrator decision or more progressive DDoS
846871 * mitigation techniques.
847872 */
848- r = tfw_http_sticky_req_process (req , sv , c_val );
849- switch (r ) {
850- case TFW_HTTP_SESS_SUCCESS :
851- break ;
852- case TFW_HTTP_SESS_FAILURE :
853- return r ;
854- default :
855- /*
856- * Any js challenge processing error: cookie not found
857- * or invalid or request comes not in time. We increment
858- * max_misses and restart js challenge.
859- */
860- BUG_ON (r < __TFW_HTTP_SESS_PUB_CODE_MAX );
861- return tfw_http_sticky_challenge_start (req );
873+ if (req -> need_jsch ) {
874+ r = tfw_http_sticky_req_process (req , sv , c_val );
875+ switch (r ) {
876+ case TFW_HTTP_SESS_SUCCESS :
877+ break ;
878+ case TFW_HTTP_SESS_FAILURE :
879+ return r ;
880+ default :
881+ /*
882+ * Any js challenge processing error: cookie not found
883+ * or invalid or request comes not in time. We increment
884+ * max_misses and restart js challenge.
885+ */
886+ BUG_ON (r < __TFW_HTTP_SESS_PUB_CODE_MAX );
887+ return tfw_http_sticky_challenge_start (req );
888+ }
862889 }
863890
864891 if (req -> vhost -> cookie -> learn ) {
0 commit comments