All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft 5/7] src: implement shortcut for tcp mss size mangling
Date: Mon, 21 Aug 2017 16:12:01 +0200	[thread overview]
Message-ID: <20170821141201.GD6076@salvia> (raw)
In-Reply-To: <20170819231413.15164-6-fw@strlen.de>

On Sun, Aug 20, 2017 at 01:14:11AM +0200, Florian Westphal wrote:
> short-hand version of tcp option maxseg size 1:
> tcp option mss set 1
> 
> Reverse also prints the more compact representation.

Why not just keep with the shortcut (more compact) representation?

> Signed-off-by: Florian Westphal <fw@strlen.de>
> ---
>  src/exthdr.c       |  1 +
>  src/parser_bison.y |  7 +++++++
>  src/scanner.l      |  1 +
>  src/tcpopt.c       | 11 +++++++++--
>  4 files changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/src/exthdr.c b/src/exthdr.c
> index 7d13c83c9943..a4d4fa5b0864 100644
> --- a/src/exthdr.c
> +++ b/src/exthdr.c
> @@ -20,6 +20,7 @@
>  
>  #include <utils.h>
>  #include <headers.h>
> +#include <tcpopt.h>
>  #include <expression.h>
>  #include <statement.h>
>  
> diff --git a/src/parser_bison.y b/src/parser_bison.y
> index 7898ea3fe7bc..533347264729 100644
> --- a/src/parser_bison.y
> +++ b/src/parser_bison.y
> @@ -334,6 +334,7 @@ static void location_update(struct location *loc, struct location *rhs, int n)
>  %token RIGHT			"right"
>  %token TSVAL			"tsval"
>  %token TSECR			"tsecr"
> +%token MSS			"mss"
>  
>  %token DCCP			"dccp"
>  
> @@ -3214,6 +3215,12 @@ payload_stmt		:	payload_expr		SET	expr
>  				else
>  					$$ = payload_stmt_alloc(&@$, $1, $3);
>  			}
> +			|	TCP	OPTION	MSS	SET	expr
> +			{
> +				$$ = exthdr_stmt_alloc(&@$,
> +							tcpopt_expr_alloc(&@$, TCPOPTHDR_MAXSEG, TCPOPTHDR_FIELD_SIZE),
> +							$5);
> +			}
>  			;
>  
>  payload_expr		:	payload_raw_expr
> diff --git a/src/scanner.l b/src/scanner.l
> index b6ba32d88f4a..ede6ed73e5df 100644
> --- a/src/scanner.l
> +++ b/src/scanner.l
> @@ -433,6 +433,7 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
>  "window"		{ return WINDOW; }
>  "urgptr"		{ return URGPTR; }
>  "option"		{ return OPTION; }
> +"mss"			{ return MSS; }
>  
>  "dccp"			{ return DCCP; }
>  
> diff --git a/src/tcpopt.c b/src/tcpopt.c
> index 63f0c236c9cf..c0540b7a31b2 100644
> --- a/src/tcpopt.c
> +++ b/src/tcpopt.c
> @@ -249,8 +249,15 @@ void tcpopt_expr_print(const struct expr *expr, struct output_ctx *octx)
>  
>  void tcpopt_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
>  {
> -	tcpopt_expr_print(stmt->exthdr.expr, octx);
> -	printf(" set ");
> +	if (stmt->exthdr.expr->exthdr.desc->type == TCPOPT_MAXSEG &&
> +	    stmt->exthdr.expr->exthdr.tmpl ==
> +	    &stmt->exthdr.expr->exthdr.desc->templates[TCPOPTHDR_FIELD_SIZE]) {
> +		printf("tcp option mss set ");
> +	} else {
> +		tcpopt_expr_print(stmt->exthdr.expr, octx);
> +		printf(" set ");
> +	}
> +
>  	expr_print(stmt->exthdr.val, octx);
>  }
>  
> -- 
> 2.13.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2017-08-21 14:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-19 23:14 [PATCH nft 0/7] tcp mss mangling support Florian Westphal
2017-08-19 23:14 ` [PATCH libnftnl 1/7] exthdr: tcp option set support Florian Westphal
2017-08-21 14:07   ` Pablo Neira Ayuso
2017-08-19 23:14 ` [PATCH libnftnl 2/7] rt: tcpmss get support Florian Westphal
2017-08-21 14:08   ` Pablo Neira Ayuso
2017-08-19 23:14 ` [PATCH nft 3/7] exthdr: move print of tcp options to tcpopt.c Florian Westphal
2017-08-19 23:14 ` [PATCH nft 4/7] src: add tcp options set support Florian Westphal
2017-08-21 14:09   ` Pablo Neira Ayuso
2017-08-19 23:14 ` [PATCH nft 5/7] src: implement shortcut for tcp mss size mangling Florian Westphal
2017-08-21 14:12   ` Pablo Neira Ayuso [this message]
2017-08-21 14:23     ` Florian Westphal
2017-08-19 23:14 ` [PATCH nft 6/7] rt: add path mss support Florian Westphal
2017-08-21 14:12   ` Pablo Neira Ayuso
2017-08-19 23:14 ` [PATCH nft 7/7] tests: add tcp option set support / tcp mss mangling test cases Florian Westphal
2017-08-21 14:14   ` Pablo Neira Ayuso
2017-08-21 14:28     ` Florian Westphal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170821141201.GD6076@salvia \
    --to=pablo@netfilter.org \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.