From patchwork Wed May 16 21:03:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pablo Neira Ayuso X-Patchwork-Id: 914943 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=netfilter.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40mRkY2lMGz9s1d for ; Thu, 17 May 2018 07:04:05 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751293AbeEPVED (ORCPT ); Wed, 16 May 2018 17:04:03 -0400 Received: from mail.us.es ([193.147.175.20]:45172 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752066AbeEPVEA (ORCPT ); Wed, 16 May 2018 17:04:00 -0400 Received: from antivirus1-rhel7.int (unknown [192.168.2.11]) by mail.us.es (Postfix) with ESMTP id 2264D3EBA80 for ; Wed, 16 May 2018 23:03:02 +0200 (CEST) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id 10E56DA80B for ; Wed, 16 May 2018 23:03:02 +0200 (CEST) Received: by antivirus1-rhel7.int (Postfix, from userid 99) id 06507DA737; Wed, 16 May 2018 23:03:02 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on antivirus1-rhel7.int X-Spam-Level: X-Spam-Status: No, score=-108.2 required=7.5 tests=ALL_TRUSTED,BAYES_50, SMTPAUTH_US2,USER_IN_WHITELIST autolearn=disabled version=3.4.1 Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id ED423DA7FA for ; Wed, 16 May 2018 23:02:59 +0200 (CEST) Received: from 192.168.1.97 (192.168.1.97) by antivirus1-rhel7.int (F-Secure/fsigk_smtp/550/antivirus1-rhel7.int); Wed, 16 May 2018 23:02:59 +0200 (CEST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/antivirus1-rhel7.int) Received: from salvia.here (sys.soleta.eu [212.170.55.40]) (Authenticated sender: pneira@us.es) by entrada.int (Postfix) with ESMTPA id D7DFB403DF83 for ; Wed, 16 May 2018 23:02:59 +0200 (CEST) X-SMTPAUTHUS: auth mail.us.es From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Subject: [PATCH nft 2/2] segtree: add timeout for range and prefix expressions in sets Date: Wed, 16 May 2018 23:03:51 +0200 Message-Id: <20180516210351.29050-2-pablo@netfilter.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180516210351.29050-1-pablo@netfilter.org> References: <20180516210351.29050-1-pablo@netfilter.org> X-Virus-Scanned: ClamAV using ClamSMTP Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org # nft add table x # nft add set x y { type ipv4_addr\; flags timeout,interval\; } # nft add element x y { 7.4.4.5-8.8.8.8 comment "good guy" timeout 30s} # nft list ruleset table ip x { set y { type ipv4_addr flags interval,timeout elements = { 7.4.4.5-8.8.8.8 timeout 30s expires 27s956ms comment "good guy" } } } Signed-off-by: Pablo Neira Ayuso --- src/segtree.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/segtree.c b/src/segtree.c index 7a443632ece5..28d45c920c3c 100644 --- a/src/segtree.c +++ b/src/segtree.c @@ -542,6 +542,8 @@ static void set_insert_interval(struct expr *set, struct seg_tree *tree, if (ei->expr != NULL) { if (ei->expr->comment) expr->comment = xstrdup(ei->expr->comment); + if (ei->expr->timeout) + expr->timeout = ei->expr->timeout; if (ei->expr->ops->type == EXPR_MAPPING) expr = mapping_expr_alloc(&ei->expr->location, expr, expr_get(ei->expr->right)); @@ -831,6 +833,10 @@ void interval_map_decompose(struct expr *set) tmp = set_elem_expr_alloc(&low->location, tmp); if (low->comment) tmp->comment = xstrdup(low->comment); + if (low->timeout) + tmp->timeout = low->timeout; + if (low->expiration) + tmp->expiration = low->expiration; if (low->ops->type == EXPR_MAPPING) tmp = mapping_expr_alloc(&tmp->location, tmp, low->right); @@ -848,6 +854,10 @@ void interval_map_decompose(struct expr *set) prefix = set_elem_expr_alloc(&low->location, prefix); if (low->comment) prefix->comment = xstrdup(low->comment); + if (low->timeout) + prefix->timeout = low->timeout; + if (low->expiration) + prefix->expiration = low->expiration; if (low->ops->type == EXPR_MAPPING) prefix = mapping_expr_alloc(&low->location, prefix,