From patchwork Thu Aug 2 00:35:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi-Hung Wei X-Patchwork-Id: 952495 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FBRZwUzp"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41grz71nWtz9s3q for ; Thu, 2 Aug 2018 10:44:19 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 82ACDE5E; Thu, 2 Aug 2018 00:41:14 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id BB3D5E57 for ; Thu, 2 Aug 2018 00:41:12 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 762AC7B3 for ; Thu, 2 Aug 2018 00:41:12 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id b11-v6so268858pfo.3 for ; Wed, 01 Aug 2018 17:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5SjpOG5oj8Qm102LKxolDNMEi680Z2PRlcjd646zCEw=; b=FBRZwUzpq9iACyreSrTGp26RwCgqGodn8yZmi5D1WP90d6o4qkHeBNrvx0xok4yoEu xUkA7Cu6cMOeUS/GXW+bwb5fR+FSJjG7oYLd6EmV2ufOC8Nb/DdydRc+j+Ppr2U/CGOX heYK8kcY+GAGEUqgDW0gtfbEIesLnKMLQ2HFMimu2k69j3RWS2rRwtkTTqV7JeTEar2V a/uywQbG7wRI3qZBjXNRZAtrWqp50ED3KQL/hz0aOWutPFkfPx93gY6YzD6/TliriYKE YUVLwpnIJg3aP5aDB6gLXRHy/xgvdlTOcv+OWUgVAMD/7pSuAAhdURI42IOqiU0kjLfE pTjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5SjpOG5oj8Qm102LKxolDNMEi680Z2PRlcjd646zCEw=; b=klwKE24B25XzEdUbdVjNihlrPB/1SajqDNTtaUN0vWhcVAHWIDBUi4tKfjdkJEVvmC 5WQ83LRWFzlYK0rgoOZvkFyWCSMxP1KdlJ+AhVgVPPlFPq5FVyYVl4DiIzBM5bN6Ezwr 7WQwCOa8gFQQhcb9VujJ/YGcc6l2xSA67W3Lg/d4d00fvfDRaODxsRmt5oGq3MF/nqyT AyAXncB8c9TB4AgzWm/RgrZmpg/1GYLwiC+yHscgs2d7rSjtkIbHkVcUL3ZPf2laCcfq kJ0e4HYAT96ree3BqVug73/JkhgT3fa4iClfIxNStma+Ad5anx4fVAwWdRde4oOyXC5/ 7y6Q== X-Gm-Message-State: AOUpUlGCcoNvpNuqAItQgUN+Lva0XyKLEmt9OF428Ac+09RkC0lbuL4n 344GqA8F7JYpnMknk2VLiObp02zn X-Google-Smtp-Source: AAOMgpchQn6rti2cdv1irUVrzegtk09AzvNhCUxEks1QMi3NETg7Mm7g6tN/z/IZqM2FVOiQfpSfuA== X-Received: by 2002:a63:8c0b:: with SMTP id m11-v6mr535002pgd.372.1533170471636; Wed, 01 Aug 2018 17:41:11 -0700 (PDT) Received: from Husky.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id s73-v6sm328627pfi.154.2018.08.01.17.41.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Aug 2018 17:41:10 -0700 (PDT) From: Yi-Hung Wei To: dev@openvswitch.org Date: Wed, 1 Aug 2018 17:35:52 -0700 Message-Id: <1533170156-769-8-git-send-email-yihung.wei@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533170156-769-1-git-send-email-yihung.wei@gmail.com> References: <1533170156-769-1-git-send-email-yihung.wei@gmail.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 07/11] ct-dpif: Helper functions for conntrack zone limit X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org This patch implments some helper function for conntrack zone limit. It will be useful for the following patches. Signed-off-by: Yi-Hung Wei --- lib/ct-dpif.c | 32 ++++++++++++++++++++++++++++++++ lib/ct-dpif.h | 4 ++++ 2 files changed, 36 insertions(+) diff --git a/lib/ct-dpif.c b/lib/ct-dpif.c index d1e8a6b8b4a9..a772799fe347 100644 --- a/lib/ct-dpif.c +++ b/lib/ct-dpif.c @@ -597,3 +597,35 @@ error: free(copy); return false; } + +void +ct_dpif_push_zone_limit(struct ovs_list *zone_limits, uint16_t zone, + uint32_t limit, uint32_t count) +{ + struct ct_dpif_zone_limit *zone_limit = xmalloc(sizeof *zone_limit); + zone_limit->zone = zone; + zone_limit->limit = limit; + zone_limit->count = count; + ovs_list_push_back(zone_limits, &zone_limit->node); +} + +/* The caller takes ownership of 'struct ct_dpif_zone_limit *', and is + * responsible to free that struct. */ +struct ct_dpif_zone_limit * +ct_dpif_pop_zone_limit(struct ovs_list *zone_limits) +{ + struct ct_dpif_zone_limit *zone_limit; + LIST_FOR_EACH_POP (zone_limit, node, zone_limits) { + return zone_limit; + } + OVS_NOT_REACHED(); +} + +void +ct_dpif_free_zone_limits(struct ovs_list *zone_limits) +{ + while (!ovs_list_is_empty(zone_limits)) { + struct ct_dpif_zone_limit *p = ct_dpif_pop_zone_limit(zone_limits); + free(p); + } +} diff --git a/lib/ct-dpif.h b/lib/ct-dpif.h index 4e83bc555e03..c80e18b72b56 100644 --- a/lib/ct-dpif.h +++ b/lib/ct-dpif.h @@ -219,5 +219,9 @@ void ct_dpif_format_tuple(struct ds *, const struct ct_dpif_tuple *); uint8_t ct_dpif_coalesce_tcp_state(uint8_t state); void ct_dpif_format_tcp_stat(struct ds *, int, int); bool ct_dpif_parse_tuple(struct ct_dpif_tuple *, const char *s, struct ds *); +void ct_dpif_push_zone_limit(struct ovs_list *, uint16_t zone, uint32_t limit, + uint32_t count); +struct ct_dpif_zone_limit * ct_dpif_pop_zone_limit(struct ovs_list *); +void ct_dpif_free_zone_limits(struct ovs_list *); #endif /* CT_DPIF_H */