Commit 72d35747 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Log SessionOpen with VSL() so we can be sure it is always the first

VSL record for a session.

Make $log_local_address default to on.
parent e0273885
...@@ -149,18 +149,20 @@ ses_pool_task(struct worker *wrk, void *arg) ...@@ -149,18 +149,20 @@ ses_pool_task(struct worker *wrk, void *arg)
} }
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
* VSL log the endpoints of the TCP connection.
*
* We use VSL() to get the sessions vxid and to make sure tha this
* VSL comes before anything else for this session.
*/ */
static void static void
ses_vsl_socket(struct req *req, const char *lsockname) ses_vsl_socket(struct sess *sp, const char *lsockname)
{ {
char laddr[ADDR_BUFSIZE]; char laddr[ADDR_BUFSIZE];
char lport[PORT_BUFSIZE]; char lport[PORT_BUFSIZE];
struct sess *sp;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
AN(lsockname);
sp = req->sp;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
AN(lsockname);
VTCP_name(&sp->sockaddr, sp->sockaddrlen, VTCP_name(&sp->sockaddr, sp->sockaddrlen,
sp->addr, sizeof sp->addr, sp->port, sizeof sp->port); sp->addr, sizeof sp->addr, sp->port, sizeof sp->port);
...@@ -169,14 +171,12 @@ ses_vsl_socket(struct req *req, const char *lsockname) ...@@ -169,14 +171,12 @@ ses_vsl_socket(struct req *req, const char *lsockname)
&sp->mysockaddrlen)); &sp->mysockaddrlen));
VTCP_name(&sp->mysockaddr, sp->mysockaddrlen, VTCP_name(&sp->mysockaddr, sp->mysockaddrlen,
laddr, sizeof laddr, lport, sizeof lport); laddr, sizeof laddr, lport, sizeof lport);
/* XXX: have no req yet */
VSLb(req->vsl, SLT_SessionOpen, "%s %s %s %s %s",
sp->addr, sp->port, lsockname, laddr, lport);
} else { } else {
/* XXX: have no req yet */ strcpy(laddr, "-");
VSLb(req->vsl, SLT_SessionOpen, "%s %s %s - -", strcpy(lport, "-");
sp->addr, sp->port, lsockname);
} }
VSL(SLT_SessionOpen, sp->vxid, "%s %s %s %s %s",
sp->addr, sp->port, lsockname, laddr, lport);
} }
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
...@@ -210,13 +210,13 @@ SES_pool_accept_task(struct worker *wrk, void *arg) ...@@ -210,13 +210,13 @@ SES_pool_accept_task(struct worker *wrk, void *arg)
sp->vxid = VXID_Get(&wrk->vxid_pool); sp->vxid = VXID_Get(&wrk->vxid_pool);
lsockname = VCA_SetupSess(wrk, sp); lsockname = VCA_SetupSess(wrk, sp);
ses_vsl_socket(sp, lsockname);
req = ses_GetReq(sp); req = ses_GetReq(sp);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
req->vxid = VXID_Get(&wrk->vxid_pool); req->vxid = VXID_Get(&wrk->vxid_pool);
ses_vsl_socket(req, lsockname);
wrk->acct_tmp.sess++; wrk->acct_tmp.sess++;
......
...@@ -1047,9 +1047,11 @@ static const struct parspec input_parspec[] = { ...@@ -1047,9 +1047,11 @@ static const struct parspec input_parspec[] = {
"on", "bool" }, "on", "bool" },
{ "log_local_address", tweak_bool, &mgt_param.log_local_addr, 0, 0, { "log_local_address", tweak_bool, &mgt_param.log_local_addr, 0, 0,
"Log the local address on the TCP connection in the " "Log the local address on the TCP connection in the "
"SessionOpen shared memory record.\n", "SessionOpen VSL record.\n"
"Disabling this saves a getsockname(2) system call "
"per TCP connection.\n",
0, 0,
"off", "bool" }, "on", "bool" },
{ "waiter", tweak_waiter, NULL, 0, 0, { "waiter", tweak_waiter, NULL, 0, 0,
"Select the waiter kernel interface.\n", "Select the waiter kernel interface.\n",
WIZARD | MUST_RESTART, WIZARD | MUST_RESTART,
......
...@@ -8,6 +8,7 @@ server s1 { ...@@ -8,6 +8,7 @@ server s1 {
# This requires non-local binds to be disabled. If you see this fail # This requires non-local binds to be disabled. If you see this fail
# and are on Linux, ensure /proc/net/ipv4/ip_nonlocal_bind is set to 0. # and are on Linux, ensure /proc/net/ipv4/ip_nonlocal_bind is set to 0.
varnish v1 -cliok "param.set listen_address ${bad_ip}:0" varnish v1 -cliok "param.set listen_address ${bad_ip}:0"
varnish v1 -cliok "param.set log_local_address off"
varnish v1 -vcl+backend {} -clierr 300 start varnish v1 -vcl+backend {} -clierr 300 start
varnish v1 -cliok "param.set listen_address 127.0.0.1:0,${bad_ip}:9082" varnish v1 -cliok "param.set listen_address 127.0.0.1:0,${bad_ip}:9082"
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* *
* Arguments: * Arguments:
* Tag-Name * Tag-Name
* Short Description (1 line, max ?? chars) * Short Description (1 line, max ? chars)
* Long Description (in RST "definition list" format) * Long Description (in RST "definition list" format)
*/ */
...@@ -69,9 +69,9 @@ SLTM(SessionOpen, "Client connection opened", ...@@ -69,9 +69,9 @@ SLTM(SessionOpen, "Client connection opened",
"socket-endpoints of the connection.\n\n" "socket-endpoints of the connection.\n\n"
"caddr\n Client IPv4/6 address\n\n" "caddr\n Client IPv4/6 address\n\n"
"cport\n Client TCP port\n\n" "cport\n Client TCP port\n\n"
"lsock\n Listen socket name\n\n" "lsock\n Listen socket\n\n"
"laddr\n Local IPv4/6 address ('-' if $log_local_addr not set)\n\n" "laddr\n Local IPv4/6 address ('-' if !$log_local_addr)\n\n"
"lport\n Local TCP port ('-' if $log_local_addr not set)\n\n" "lport\n Local TCP port ('-' if !$log_local_addr)\n\n"
) )
SLTM(SessionClose, "Client connection closed", SLTM(SessionClose, "Client connection closed",
...@@ -81,11 +81,11 @@ SLTM(SessionClose, "Client connection closed", ...@@ -81,11 +81,11 @@ SLTM(SessionClose, "Client connection closed",
"'Connection: close' - The client specifed that keepalive should " "'Connection: close' - The client specifed that keepalive should "
"be disabled by sending a 'Connection: close' header. " "be disabled by sending a 'Connection: close' header. "
"'no request' - No initial request was received within sess_timeout. " "'no request' - No initial request was received within sess_timeout. "
"'EOF' - ??? " "'EOF' - ? "
"'remote closed' - ??? " "'remote closed' - ? "
"'error' - Processing reached vcl_error even if the status code " "'error' - Processing reached vcl_error even if the status code "
"indicates success. " "indicates success. "
"' blast' - ???" "' blast' - ?"
) )
SLTM(BackendOpen, "Backend connection opened", "") SLTM(BackendOpen, "Backend connection opened", "")
SLTM(BackendXID, "The unique ID of the backend transaction", "") SLTM(BackendXID, "The unique ID of the backend transaction", "")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment