14
14
15
15
typedef struct {
16
16
time_t last_refresh_time ;
17
+ uint32_t seq_after_ps ;
17
18
uint32_t sec_auth_checked :1 ;
18
19
uint32_t sec_auth_not_yet_done :1 ;
19
20
uint32_t first_auth_sent :1 ;
@@ -389,6 +390,13 @@ check_pack_needed_for_recons(tc_sess_t *s, tc_iph_t *ip, tc_tcph_t *tcp)
389
390
tc_mysql_session * mysql_sess ;
390
391
mysql_table_item_t * item ;
391
392
393
+ mysql_sess = s -> data ;
394
+
395
+ if (s -> sm .fake_syn ) {
396
+ if (before (ntohl (tcp -> seq ), mysql_sess -> seq_after_ps )) {
397
+ return false;
398
+ }
399
+ }
392
400
393
401
if (s -> cur_pack .cont_len > 0 ) {
394
402
@@ -402,8 +410,6 @@ check_pack_needed_for_recons(tc_sess_t *s, tc_iph_t *ip, tc_tcph_t *tcp)
402
410
403
411
if (command != COM_STMT_PREPARE ) {
404
412
405
- mysql_sess = s -> data ;
406
-
407
413
diff = tc_time () - mysql_sess -> last_refresh_time ;
408
414
409
415
if (diff >= MAX_RETHRESH_TIME ) {
@@ -495,16 +501,26 @@ mysql_dispose_auth(tc_sess_t *s, tc_iph_t *ip, tc_tcph_t *tcp)
495
501
496
502
mysql_sess -> first_auth_sent = 1 ;
497
503
498
- release_resources (s -> hash_key );
499
-
500
- value = (void * ) cp_fr_ip_pack (ctx .fir_auth_pool , ip );
501
- hash_add (ctx .fir_auth_table , ctx .fir_auth_pool , s -> hash_key , value );
502
- mysql_sess -> last_refresh_time = tc_time ();
504
+ if (!s -> sm .fake_syn ) {
505
+ release_resources (s -> hash_key );
506
+
507
+ value = (void * ) cp_fr_ip_pack (ctx .fir_auth_pool , ip );
508
+ hash_add (ctx .fir_auth_table , ctx .fir_auth_pool , s -> hash_key , value );
509
+ mysql_sess -> last_refresh_time = tc_time ();
503
510
504
511
#if (TC_DETECT_MEMORY )
505
- tc_log_info (LOG_INFO , 0 , "s:%p,hash add fir auth:%llu,value:%p, p:%u" ,
506
- s , s -> hash_key , value , ntohs (s -> src_port ));
512
+ tc_log_info (LOG_INFO , 0 , "s:%p,hash add fir auth:%llu,value:%p, p:%u" ,
513
+ s , s -> hash_key , value , ntohs (s -> src_port ));
507
514
#endif
515
+ } else {
516
+ hash_node * hn = hash_find_node (ctx .fir_auth_table , s -> hash_key );
517
+ if (hn != NULL ) {
518
+ mysql_sess -> last_refresh_time = hn -> create_time ;
519
+ } else {
520
+ tc_log_info (LOG_WARN , 0 , "hash node for key:%llu is nil" ,
521
+ s -> hash_key );
522
+ }
523
+ }
508
524
509
525
} else if (mysql_sess -> first_auth_sent && mysql_sess -> sec_auth_not_yet_done )
510
526
{
@@ -519,8 +535,10 @@ mysql_dispose_auth(tc_sess_t *s, tc_iph_t *ip, tc_tcph_t *tcp)
519
535
change_clt_second_auth_content (payload , cont_len , encryption );
520
536
mysql_sess -> sec_auth_not_yet_done = 0 ;
521
537
522
- value = (void * ) cp_fr_ip_pack (ctx .sec_auth_pool , ip );
523
- hash_add (ctx .sec_auth_table , ctx .sec_auth_pool , s -> hash_key , value );
538
+ if (!s -> sm .fake_syn ) {
539
+ value = (void * ) cp_fr_ip_pack (ctx .sec_auth_pool , ip );
540
+ hash_add (ctx .sec_auth_table , ctx .sec_auth_pool , s -> hash_key , value );
541
+ }
524
542
}
525
543
526
544
return TC_OK ;
@@ -588,6 +606,8 @@ prepare_for_renew_session(tc_sess_t *s, tc_iph_t *ip, tc_tcph_t *tcp)
588
606
tc_log_debug2 (LOG_INFO , 0 , "total len subtracted:%u,p:%u" , tot_clen ,
589
607
ntohs (s -> src_port ));
590
608
609
+ mysql_sess -> seq_after_ps = ntohl (tcp -> seq );
610
+
591
611
tcp -> seq = htonl (ntohl (tcp -> seq ) - tot_clen );
592
612
fir_tcp -> seq = htonl (ntohl (tcp -> seq ) + 1 );
593
613
tc_save_pack (s , s -> slide_win_packs , fir_ip , fir_tcp );
0 commit comments