Frédéric Lécaille | 9b53b4c | 2018-06-20 07:26:44 +0200 | [diff] [blame] | 1 | # commit d02286d |
| 2 | # BUG/MINOR: log: pin the front connection when front ip/ports are logged |
| 3 | # |
| 4 | # Mathias Weiersmueller reported an interesting issue with logs which Lukas |
| 5 | # diagnosed as dating back from commit 9b061e332 (1.5-dev9). When front |
| 6 | # connection information (ip, port) are logged in TCP mode and the log is |
| 7 | # emitted at the end of the connection (eg: because %B or any log tag |
| 8 | # requiring LW_BYTES is set), the log is emitted after the connection is |
| 9 | # closed, so the address and ports cannot be retrieved anymore. |
| 10 | # |
| 11 | # It could be argued that we'd make a special case of these to immediatly |
| 12 | # retrieve the source and destination addresses from the connection, but it |
| 13 | # seems cleaner to simply pin the front connection, marking it "tracked" by |
| 14 | # adding the LW_XPRT flag to mention that we'll need some of these elements |
| 15 | # at the last moment. Only LW_FRTIP and LW_CLIP are affected. Note that after |
| 16 | # this change, LW_FRTIP could simply be removed as it's not used anywhere. |
| 17 | # |
| 18 | # Note that the problem doesn't happen when using %[src] or %[dst] since |
| 19 | # all sample expressions set LW_XPRT. |
| 20 | |
| 21 | varnishtest "Wrong ip/port logging" |
| 22 | feature ignore_unknown_macro |
| 23 | |
| 24 | server s1 { |
| 25 | rxreq |
| 26 | txresp |
| 27 | } -start |
| 28 | |
| 29 | syslog Slg_1 -level notice { |
| 30 | recv |
| 31 | recv |
| 32 | recv info |
| 33 | expect ~ \"dip\":\"${h1_fe_1_addr}\",\"dport\":\"${h1_fe_1_port}.*\"ts\":\"cD\",\" |
| 34 | } -start |
| 35 | |
| 36 | haproxy h1 -conf { |
| 37 | global |
| 38 | log ${Slg_1_addr}:${Slg_1_port} local0 |
| 39 | |
| 40 | defaults |
| 41 | log global |
| 42 | timeout connect 3000 |
| 43 | timeout client 5 |
| 44 | timeout server 10000 |
| 45 | |
| 46 | frontend fe1 |
| 47 | bind "fd@${fe_1}" |
| 48 | mode tcp |
| 49 | log-format {\"dip\":\"%fi\",\"dport\":\"%fp\",\"c_ip\":\"%ci\",\"c_port\":\"%cp\",\"fe_name\":\"%ft\",\"be_name\":\"%b\",\"s_name\":\"%s\",\"ts\":\"%ts\",\"bytes_read\":\"%B\"} |
| 50 | default_backend be_app |
| 51 | |
| 52 | backend be_app |
| 53 | server app1 ${s1_addr}:${s1_port} check |
| 54 | } -start |
| 55 | |
| 56 | client c1 -connect ${h1_fe_1_sock} { |
| 57 | txreq -url "/" |
| 58 | delay 0.02 |
| 59 | } -run |
| 60 | |
| 61 | syslog Slg_1 -wait |
| 62 | |