Hi Nick,

thanks to your diags and detailed reports, I found the bug and I
have the fix. We were using the port from the wrong side's address
when mapping was used. This explains why the resulting port was
twice the incoming one.

Since we moved to full-ipv6, we don't need the addr.s/addr.c tricks,
we have sockaddr_storage everywhere, so I'll remove that and it will
be both cleaner and less error-prone.

I'm attaching the patch that I have already pushed upstream.

Cheers,
Willy

commit dd164d0240b0fc1030044d7b1bfad93401959eea
Author: Willy Tarreau <w...@1wt.eu>
Date:   Fri Sep 23 10:27:12 2011 +0200

    BUG/MINOR: don't use a wrong port when connecting to a server with mapped 
ports
    
    Nick Chalk reported that a connection to a server which has no port 
specified
    used twice the port number. The reason is that the port number was taken 
from
    the wrong part of the address, the client's destination address was used as 
the
    base port instead of the server's configured address.
    
    Thanks to Nick for his helpful diagnostic.

diff --git a/src/backend.c b/src/backend.c
index d850ebf..0fa28f0 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -703,7 +703,7 @@ int assign_server_address(struct session *s)
                        base_port = get_host_port(&s->req->prod->addr.c.to);
 
                        /* Second, assign the outgoing connection's port */
-                       base_port += get_host_port(&s->req->prod->addr.s.to);
+                       base_port += get_host_port(&s->req->cons->addr.s.to);
                        set_host_port(&s->req->cons->addr.s.to, base_port);
                }
        }

Reply via email to