Proxy protocol v1 client port fix

Federico Schwindt fgsch at lodoss.net
Sat Nov 7 19:47:31 CET 2015


Committed. Thank for the patch.

On Fri, Nov 6, 2015 at 10:40 AM, Rafael Zalamena <rafaelfz at taghos.com.br>
wrote:

> After giving the proxy feature a try I noticed the client port collected
> in the vpx_proto1() function is wrong. I read the code and noticed it
> splits the proxy line in tokens and then when reading the client port it
> picks the wrong token.
>
>       0          1       2       3       4
> PROXY PROTO_IPVX SRCADDR DSTADDR SRCPORT DSTPORT\r\n
>
> The code is partially working because when it resolves the address it uses
> the right token:
> cache_proxy_proto.c:line 110
> i = getaddrinfo(fld[1], fld[3], &hints, &res);
>
> The proxy version 2 part seems to be working correctly.
>
> The diff below fixes the problem I just reported.
>
> diff --git a/bin/varnishd/proxy/cache_proxy_proto.c
> b/bin/varnishd/proxy/cache_proxy_proto.c
> index 604d796..6f64f3a 100644
> --- a/bin/varnishd/proxy/cache_proxy_proto.c
> +++ b/bin/varnishd/proxy/cache_proxy_proto.c
> @@ -125,7 +125,7 @@ vpx_proto1(const struct worker *wrk, struct req *req)
>         SES_Reserve_client_addr(req->sp, &sa);
>         AN(VSA_Build(sa, res->ai_addr, res->ai_addrlen));
>         SES_Set_String_Attr(req->sp, SA_CLIENT_IP, fld[1]);
> -       SES_Set_String_Attr(req->sp, SA_CLIENT_PORT, fld[2]);
> +       SES_Set_String_Attr(req->sp, SA_CLIENT_PORT, fld[3]);
>         freeaddrinfo(res);
>
>         i = getaddrinfo(fld[2], fld[4], &hints, &res);
>
> _______________________________________________
> varnish-dev mailing list
> varnish-dev at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20151107/34e60d82/attachment.html>


More information about the varnish-dev mailing list