blob: d4fb8620d41240851bc99415f01f85af2f851530 [file] [log] [blame]
Frédéric Lécailledd51e532018-08-31 11:05:39 +02001# commit 3e60b11
2# BUG/MEDIUM: stick-tables: Decrement ref_cnt in table_* converters
3#
4# When using table_* converters ref_cnt was incremented
5# and never decremented causing entries to not expire.
6#
7# The root cause appears to be that stktable_lookup_key()
8# was called within all sample_conv_table_* functions which was
9# incrementing ref_cnt and not decrementing after completion.
10#
11# Added stktable_release() to the end of each sample_conv_table_*
12# function and reworked the end logic to ensure that ref_cnt is
13# always decremented after use.
14#
15# This should be backported to 1.8
16
Frédéric Lécailledc1a3bd2019-03-29 15:07:24 +010017#REGTEST_TYPE=bug
18
Frédéric Lécailledd51e532018-08-31 11:05:39 +020019varnishtest "stick-tables: Test expirations when used with table_*"
20
21# As some macros for haproxy are used in this file, this line is mandatory.
22feature ignore_unknown_macro
23
24# Do nothing.
25server s1 {
26} -start
27
28haproxy h1 -conf {
29 # Configuration file of 'h1' haproxy instance.
30 defaults
31 mode http
Christopher Faulet8f161482018-12-19 11:49:39 +010032 ${no-htx} option http-use-htx
Frédéric Lécailledd51e532018-08-31 11:05:39 +020033 timeout connect 5s
34 timeout server 30s
35 timeout client 30s
36
37 frontend http1
38 bind "fd@${my_frontend_fd}"
39 stick-table size 1k expire 1ms type ip store conn_rate(10s),http_req_cnt,http_err_cnt,http_req_rate(10s),http_err_rate(10s),gpc0,gpc0_rate(10s),gpt0
40 http-request track-sc0 req.hdr(X-Forwarded-For)
41 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_req_cnt(http1) -m int lt 0 }
42 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_trackers(http1) -m int lt 0 }
43 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),in_table(http1) -m int lt 0 }
44 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_bytes_in_rate(http1) -m int lt 0 }
45 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_bytes_out_rate(http1) -m int lt 0 }
46 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_conn_cnt(http1) -m int lt 0 }
47 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_conn_cur(http1) -m int lt 0 }
48 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_conn_rate(http1) -m int lt 0 }
49 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_gpt0(http1) -m int lt 0 }
50 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_gpc0(http1) -m int lt 0 }
51 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_gpc0_rate(http1) -m int lt 0 }
52 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_err_cnt(http1) -m int lt 0 }
53 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_err_rate(http1) -m int lt 0 }
54 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_req_cnt(http1) -m int lt 0 }
55 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_http_req_rate(http1) -m int lt 0 }
56 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_kbytes_in(http1) -m int lt 0 }
57 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_kbytes_out(http1) -m int lt 0 }
58 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_server_id(http1) -m int lt 0 }
59 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_sess_cnt(http1) -m int lt 0 }
60 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_sess_rate(http1) -m int lt 0 }
61 http-request redirect location https://${s1_addr}:${s1_port}/ if { req.hdr(X-Forwarded-For),table_trackers(http1) -m int lt 0 }
62 } -start
63
64client c1 -connect ${h1_my_frontend_fd_sock} {
65 txreq -url "/" -hdr "X-Forwarded-For: 127.0.0.1"
66 rxresp
67 expect resp.status == 503
68} -run
69
70haproxy h1 -cli {
71 send "show table http1"
72 expect ~ "table: http1, type: ip, size:1024, used:(0|1\\n0x[0-9a-f]*: key=127\\.0\\.0\\.1 use=0 exp=[0-9]* gpt0=0 gpc0=0 gpc0_rate\\(10000\\)=0 conn_rate\\(10000\\)=1 http_req_cnt=1 http_req_rate\\(10000\\)=1 http_err_cnt=0 http_err_rate\\(10000\\)=0)\\n$"
73} -wait