From patchwork Mon Jun 2 14:44:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alvaro Neira X-Patchwork-Id: 354950 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id F09911400DE for ; Tue, 3 Jun 2014 00:45:35 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754699AbaFBOpe (ORCPT ); Mon, 2 Jun 2014 10:45:34 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:54728 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754454AbaFBOpd (ORCPT ); Mon, 2 Jun 2014 10:45:33 -0400 Received: by mail-wi0-f174.google.com with SMTP id r20so4742093wiv.1 for ; Mon, 02 Jun 2014 07:45:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7G0WXZwQK4Ptcai4U/PvGEYyHbSXdRnRuI+2BF7PcP8=; b=A390Z6SBk8Qs9QjZJjBMyYV7f5bsSpt2WkkIUNaHws9yONAul5oY3eOavWpB8QJqZk FBXWI8vPZZF/jYuiInmu+X3thfZhOMn2naT1hUfB9cVt64QuxWKOPQPx4mYOVwhw1hvS VfTUAQtKGf2a/0mi9z/ohMk6rRr9LbbdBcprBg728nkPXOnWu3IXKcrB0AxooBN4TRsc ysi7eukoSvgMvghxzKwLH+gGNG5hh4gY27EzKf2rTg5ej6258GCdQocdNJV6ToYhwhXT s5REJydGRdbsWjsFumN8nWwjYFYIhdDULDGfE9bhl30lSoyBMPuGbvFbiOtqmRtFhvlk bu7g== X-Received: by 10.180.212.77 with SMTP id ni13mr22731614wic.5.1401720331468; Mon, 02 Jun 2014 07:45:31 -0700 (PDT) Received: from localhost.localdomain (85.136.70.56.dyn.user.ono.com. [85.136.70.56]) by mx.google.com with ESMTPSA id em5sm33112103wic.23.2014.06.02.07.45.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jun 2014 07:45:30 -0700 (PDT) From: Alvaro Neira Ayuso To: netfilter-devel@vger.kernel.org Cc: kaber@trash.net Subject: [nftables PATCH v3] payload: Update the context only in equality relations Date: Mon, 2 Jun 2014 16:44:11 +0200 Message-Id: <1401720251-9041-1-git-send-email-alvaroneay@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1401270454-11669-1-git-send-email-alvaroneay@gmail.com> References: <1401270454-11669-1-git-send-email-alvaroneay@gmail.com> Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org If we add this rule: sudo nft add rule ip test input ip protocol != icmp and we try to list the rules in the table test, nftables show this error: nft: src/payload.c:76: payload_expr_pctx_update: Assertion `expr->op == OP_EQ' failed. This patch change the function payload_match_postprocess for updating only the context in equality relations case. Signed-off-by: Alvaro Neira Ayuso --- [changes in v3] *Changed the patch for updating the context only in case of equality relations case and keep the assert without changes in the function payload_expr_pctx_update. src/netlink_delinearize.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c index 479c643..ea33308 100644 --- a/src/netlink_delinearize.c +++ b/src/netlink_delinearize.c @@ -644,7 +644,8 @@ static void payload_match_postprocess(struct rule_pp_ctx *ctx, nexpr = relational_expr_alloc(&expr->location, expr->op, left, tmp); - left->ops->pctx_update(&ctx->pctx, nexpr); + if (expr->op == OP_EQ) + left->ops->pctx_update(&ctx->pctx, nexpr); nstmt = expr_stmt_alloc(&stmt->location, nexpr); list_add_tail(&nstmt->list, &stmt->list);