[master] 8816c6f9d dump move info about our client connection to panic output
Dridi Boukelmoune
dridi at varni.sh
Mon Oct 5 12:05:14 UTC 2020
On Mon, Oct 5, 2020 at 11:49 AM Nils Goroll <nils.goroll at uplex.de> wrote:
>
>
> commit 8816c6f9df513ba90ec60712ba629c78fa75ec9c
> Author: Nils Goroll <nils.goroll at uplex.de>
> Date: Mon Oct 5 13:46:55 2020 +0200
>
> dump move info about our client connection to panic output
>
> motivated by #3415
>
> diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
> index fa1ff00d4..7364bfdf7 100644
> --- a/bin/varnishd/cache/cache_panic.c
> +++ b/bin/varnishd/cache/cache_panic.c
> @@ -52,6 +52,7 @@
> #include "vcli_serve.h"
> #include "vtim.h"
> #include "vcs.h"
> +#include "vtcp.h"
>
> /*
> * The panic string is constructed in a VSB, then copied to the
> @@ -533,6 +534,16 @@ pan_req(struct vsb *vsb, const struct req *req)
>
> /*--------------------------------------------------------------------*/
>
> +#define pan_addr(vsb, sp, field) do { \
> + struct suckaddr *sa; \
> + char h[VTCP_ADDRBUFSIZE]; \
> + char p[VTCP_PORTBUFSIZE]; \
> + \
> + (void) SES_Get_##field##_addr((sp), &sa); \
> + VTCP_name(sa, h, sizeof h, p, sizeof p); \
Not sure how safe this is, the two lines above can panic so I'd rather
avoid dumping addresses from cache_panic.c to mitigate the risk of a
truncated output.
> + VSB_printf((vsb), "%s.ip = %s:%s,\n", #field, h, p); \
> + } while (0)
> +
> static void
> pan_sess(struct vsb *vsb, const struct sess *sp)
> {
> @@ -561,6 +572,7 @@ pan_sess(struct vsb *vsb, const struct sess *sp)
> VSB_cat(vsb, "}");
> }
> VSB_cat(vsb, "\n");
> + // duplicated below, remove ?
> ci = SES_Get_String_Attr(sp, SA_CLIENT_IP);
> cp = SES_Get_String_Attr(sp, SA_CLIENT_PORT);
> if (VALID_OBJ(sp->listen_sock, LISTEN_SOCK_MAGIC))
> @@ -569,6 +581,17 @@ pan_sess(struct vsb *vsb, const struct sess *sp)
> else
> VSB_printf(vsb, "client = %s %s <unknown>\n", ci, cp);
>
> + if (VALID_OBJ(sp->listen_sock, LISTEN_SOCK_MAGIC)) {
> + VSB_printf(vsb, "local.endpoint = %s,\n",
> + sp->listen_sock->endpoint);
> + VSB_printf(vsb, "local.socket = %s,\n",
> + sp->listen_sock->name);
> + }
> + pan_addr(vsb, sp, local);
> + pan_addr(vsb, sp, remote);
> + pan_addr(vsb, sp, server);
> + pan_addr(vsb, sp, client);
> +
> VSB_indent(vsb, -2);
> VSB_cat(vsb, "},\n");
> }
> _______________________________________________
> varnish-commit mailing list
> varnish-commit at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit
More information about the varnish-commit
mailing list