All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH nftables] src: json: support json restore for "th" pseudoheader
@ 2019-08-14 11:34 Florian Westphal
  2019-08-14 13:25 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2019-08-14 11:34 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Florian Westphal

Json output could not be restored back by nft because it did
not recognize the new "th" pseudoheader.

Fixes: a43a696443a150f44 ("proto: add pseudo th protocol to match d/sport in generic way")
Signed-off-by: Florian Westphal <fw@strlen.de>
---
 src/parser_json.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/parser_json.c b/src/parser_json.c
index 956233b92b92..d42bab704f7c 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -503,7 +503,8 @@ static const struct proto_desc *proto_lookup_byname(const char *name)
 		&proto_udplite,
 		&proto_tcp,
 		&proto_dccp,
-		&proto_sctp
+		&proto_sctp,
+		&proto_th,
 	};
 	unsigned int i;
 
@@ -519,11 +520,10 @@ static struct expr *json_parse_payload_expr(struct json_ctx *ctx,
 {
 	const char *protocol, *field, *base;
 	int offset, len, val;
+	struct expr *expr;
 
 	if (!json_unpack(root, "{s:s, s:i, s:i}",
 			 "base", &base, "offset", &offset, "len", &len)) {
-		struct expr *expr;
-
 		if (!strcmp(base, "ll")) {
 			val = PROTO_BASE_LL_HDR;
 		} else if (!strcmp(base, "nh")) {
@@ -553,7 +553,12 @@ static struct expr *json_parse_payload_expr(struct json_ctx *ctx,
 				   protocol, field);
 			return NULL;
 		}
-		return payload_expr_alloc(int_loc, proto, val);
+		expr = payload_expr_alloc(int_loc, proto, val);
+
+		if (proto == &proto_th)
+			expr->payload.is_raw = true;
+
+		return expr;
 	}
 	json_error(ctx, "Invalid payload expression properties.");
 	return NULL;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH nftables] src: json: support json restore for "th" pseudoheader
  2019-08-14 11:34 [PATCH nftables] src: json: support json restore for "th" pseudoheader Florian Westphal
@ 2019-08-14 13:25 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2019-08-14 13:25 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netfilter-devel

On Wed, Aug 14, 2019 at 01:34:52PM +0200, Florian Westphal wrote:
> Json output could not be restored back by nft because it did
> not recognize the new "th" pseudoheader.
> 
> Fixes: a43a696443a150f44 ("proto: add pseudo th protocol to match d/sport in generic way")
> Signed-off-by: Florian Westphal <fw@strlen.de>

Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-14 13:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-14 11:34 [PATCH nftables] src: json: support json restore for "th" pseudoheader Florian Westphal
2019-08-14 13:25 ` Pablo Neira Ayuso

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.