]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: convert expr_rt byteorder when evaluating statment arg
authorFlorian Westphal <fw@strlen.de>
Sun, 27 Aug 2017 20:24:19 +0000 (22:24 +0200)
committerFlorian Westphal <fw@strlen.de>
Mon, 28 Aug 2017 15:56:58 +0000 (17:56 +0200)
expr_rt might write data in host byte order, so make sure to
convert if needed.

This makes 'tcp option maxseg size rt mtu' actually work, right now such rules
are no-ops because nft_exthdr never increases the mss.

While at it, extend the example to not bother testing non-syn packets.

Reported-by: Matteo Croce <technoboy85@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
doc/nft.xml
src/evaluate.c
tests/py/inet/rt.t.payload

index 4e2730f698cb8dc67ebeff194b2923255fed96bd..cf9334891cee8aefb28ddad0ab6a6004cf665647 100644 (file)
@@ -4274,9 +4274,9 @@ ip forward ip dscp set 42
                                <example>
                                        <title>change tcp mss</title>
                                        <programlisting>
-tcp option maxseg size set 1360
+tcp flags syn tcp option maxseg size set 1360
 # set a size based on route information:
-tcp option maxseg size set rt mtu
+tcp flags syn tcp option maxseg size set rt mtu
                                        </programlisting>
                                </example>
                        </para>
index f21ac1a0ab858393b9e92afa407fcbcf448f1ba5..9954d5c596229bc7f9a02da270af6ed8981a0442 100644 (file)
@@ -1799,6 +1799,8 @@ static int stmt_evaluate_arg(struct eval_ctx *ctx, struct stmt *stmt,
                return stmt_binary_error(ctx, *expr, stmt,
                                         "you cannot reference a set here, "
                                         "unknown value to use");
+       case EXPR_RT:
+               return byteorder_conversion(ctx, expr, byteorder);
        default:
                break;
        }
index 2f6265ed640a5dfa569fc384b477178f79c3d64b..928e0095faf507a0c167c6f21e8df56047df1e7c 100644 (file)
@@ -15,5 +15,6 @@ inet test-inet output
 # tcp option maxseg size set rt mtu
 inet test-inet output
   [ rt load tcpmss => reg 1 ]
+  [ byteorder reg 1 = hton(reg 1, 2, 2) ]
   [ exthdr write tcpopt reg 1 => 2b @ 2 + 2 ]