From 090466c91a902ba25f0eb8ea6d61abc726d9b5e8 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 7 Sep 2009 11:51:47 +0200 Subject: [PATCH] [MINOR] add new tproxy flags for dynamic source address binding This patch adds a new TPROXY bind type, TPROXY_DYN, to indicate to the TCP connect function that we want to bind to the address passed in argument. --- include/types/proxy.h | 9 +++++---- include/types/server.h | 3 ++- src/proto_tcp.c | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/types/proxy.h b/include/types/proxy.h index 13b5f2a52..cc2311781 100644 --- a/include/types/proxy.h +++ b/include/types/proxy.h @@ -96,10 +96,11 @@ #define PR_O_ABRT_CLOSE 0x00800000 /* immediately abort request when client closes */ /* TPXY: exclusive values */ -#define PR_O_TPXY_ADDR 0x02000000 /* bind to this non-local address when connect()ing */ -#define PR_O_TPXY_CIP 0x04000000 /* bind to the client's IP address when connect()ing */ -#define PR_O_TPXY_CLI 0x06000000 /* bind to the client's IP+port when connect()ing */ -#define PR_O_TPXY_MASK 0x06000000 /* bind to a non-local address when connect()ing */ +#define PR_O_TPXY_ADDR 0x01000000 /* bind to this non-local address when connect()ing */ +#define PR_O_TPXY_CIP 0x02000000 /* bind to the client's IP address when connect()ing */ +#define PR_O_TPXY_CLI 0x03000000 /* bind to the client's IP+port when connect()ing */ +#define PR_O_TPXY_DYN 0x04000000 /* bind to a dynamically computed non-local address */ +#define PR_O_TPXY_MASK 0x07000000 /* bind to a non-local address when connect()ing */ #define PR_O_SERVER_CLO 0x08000000 /* option http-server-close */ #define PR_O_CONTSTATS 0x10000000 /* continous counters */ diff --git a/include/types/server.h b/include/types/server.h index ac94460dc..bf3d6b01e 100644 --- a/include/types/server.h +++ b/include/types/server.h @@ -51,7 +51,8 @@ #define SRV_TPROXY_ADDR 0x0100 /* bind to this non-local address to reach this server */ #define SRV_TPROXY_CIP 0x0200 /* bind to the client's IP address to reach this server */ #define SRV_TPROXY_CLI 0x0300 /* bind to the client's IP+port to reach this server */ -#define SRV_TPROXY_MASK 0x0300 /* bind to a non-local address to reach this server */ +#define SRV_TPROXY_DYN 0x0400 /* bind to a dynamically computed non-local address */ +#define SRV_TPROXY_MASK 0x0700 /* bind to a non-local address to reach this server */ /* function which act on servers need to return various errors */ #define SRV_STATUS_OK 0 /* everything is OK. */ diff --git a/src/proto_tcp.c b/src/proto_tcp.c index 50ab08170..6494db7a5 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -254,6 +254,7 @@ int tcpv4_connect_server(struct stream_interface *si, flags = 3; break; case SRV_TPROXY_CIP: + case SRV_TPROXY_DYN: flags = 1; break; } @@ -326,6 +327,7 @@ int tcpv4_connect_server(struct stream_interface *si, flags = 3; break; case PR_O_TPXY_CIP: + case PR_O_TPXY_DYN: flags = 1; break; }