Re: [PATCH] Enable set-dst and set-dst-port at tcp-request content layer

2019-04-19 Thread Willy Tarreau
Hi Baptiste,

On Fri, Apr 19, 2019 at 10:26:09AM +0200, Baptiste wrote:
> For some reasons, 'tcp-request content' can't execute set-dst and
> set-dst-port.
> This patch fixes this issue.
> Note that this patch will be useful for the do-resolve action.

I was initially wondering when that could be useful but indeed there
are some cases where it can make sense. Same with variables in general
or content extraction. I've applied it (and fixed alphabetical ordering
of the keyword :-)).

Thanks!
Willy



[PATCH] Enable set-dst and set-dst-port at tcp-request content layer

2019-04-19 Thread Baptiste
Hi,

For some reasons, 'tcp-request content' can't execute set-dst and
set-dst-port.
This patch fixes this issue.
Note that this patch will be useful for the do-resolve action.

Baptiste
From c384d381dbbfa0adae04137238b4fd11593bd2bf Mon Sep 17 00:00:00 2001
From: Baptiste Assmann 
Date: Thu, 18 Apr 2019 16:21:13 +0200
Subject: [PATCH] MINOR: proto_tcp: tcp-request content: enable set-dst and
 set-dst-var

The set-dst and set dst-var are available at both 'tcp-request
connection' and 'http-request' but not at the layer in the middle.
This patch fixes this miss and enables both set-dst and set-dst-var at
'tcp-request content' layer.
---
 doc/configuration.txt | 5 +
 src/proto_tcp.c   | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/doc/configuration.txt b/doc/configuration.txt
index c07961a..47edf38 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -9745,6 +9745,8 @@ tcp-request content  [{if | unless} ]
 - sc-inc-gpc0()
 - sc-inc-gpc1()
 - sc-set-gpt0() 
+- set-dst 
+- set-dst-port 
 - set-var() 
 - unset-var()
 - silent-drop
@@ -9778,6 +9780,9 @@ tcp-request content  [{if | unless} ]
   wait until the inspect delay expires when the data to be tracked is not yet
   available.
 
+  The "set-dst" and "set-dst-port" are used to set respectively the destination
+  IP and port. More information on how to use it at "http-request set-dst".
+
   The "set-var" is used to set the content of a variable. The variable is
   declared inline. For "tcp-request session" rules, only session-level
   variables can be used, without any layer7 contents.
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 6a5fdef..cb895a2 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -2008,7 +2008,9 @@ static struct action_kw_list tcp_req_sess_actions = {ILH, {
 INITCALL1(STG_REGISTER, tcp_req_sess_keywords_register, &tcp_req_sess_actions);
 
 static struct action_kw_list tcp_req_cont_actions = {ILH, {
-	{ "silent-drop", tcp_parse_silent_drop },
+	{ "silent-drop",  tcp_parse_silent_drop },
+	{ "set-dst" , tcp_parse_set_src_dst },
+	{ "set-dst-port", tcp_parse_set_src_dst },
 	{ /* END */ }
 }};
 
-- 
2.7.4