From patchwork Wed Feb 20 06:57:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrell Ball X-Patchwork-Id: 1045155 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="pRp5Kzd4"; 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 4447qH3LPCz9s2R for ; Wed, 20 Feb 2019 18:03:23 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 759C32491; Wed, 20 Feb 2019 07:02:42 +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 67D0022FD for ; Wed, 20 Feb 2019 07:00:05 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 2BD7379 for ; Wed, 20 Feb 2019 07:00:05 +0000 (UTC) Received: by mail-pg1-f169.google.com with SMTP id y1so11373229pgk.11 for ; Tue, 19 Feb 2019 23:00:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=wNGCNctH9ykIHrzDBHn0D+xwdNnWPzLj4Gi183rCeOU=; b=pRp5Kzd45e3JBXp0ipTqYejrEFdVYMy1MQ03CgX4aP1gLlk40XTO9OV40Wn/OUMRM+ cWxavmXnnN/H/21e7CTAIzMGSKZ9p/W+AkcLxRZvqupDwznqRYQHW8D0xM5PgV8519o+ Ynxl5xa4vSULyszgka97GQv4Gfz0uRQUGuXo4RUCmqFMf2OmwhzxBXmXyH5bYkpcGLw2 2aeHieeVcs+2j2UFKlZHVOvhgjXn8n/7vd3mR8p6J5EXVajTJrPCQlSlXINQaKwBRwHL HVsLIv4RDGGq1cY5/173u3yw0pXqkydcrc4z717FXIwZirh6CspLVxjjfn0KhTDUDSBs c3yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=wNGCNctH9ykIHrzDBHn0D+xwdNnWPzLj4Gi183rCeOU=; b=EEANhxsvoPP4s1X0TAZqwO3A3pmMLxvMtoiAeyFkegyH1tCVzDnGYU55iNEwLwq9II dNgGucm4s3xmiPmOmJvQOVBAYHelM9SF5MUDT17RBvxIDeqBP8QUyIQgs1ICX9b7LGKJ KSuCC5wj6ji1cPzRhX1mxOhK8HZTORU7cWtEv/CTfDiB84ttxp2X9vac93R+vX3760Y2 0CTELx9584/U9rA6umjMjjwGQeH914TaonQ5NIHRu9xyypRPaIuurOM0fSfgWjgGT8of MIpX7rf+X6fGHS29RFVpVQPrn/WlVYifj7b53SIpTufE0FpLahnaGSagLntMnmOezHYp zQVw== X-Gm-Message-State: AHQUAuYn+FPR6xrjvTLJ3hAKtTvKmyopgu5ifrPq2HLFh3xmXWqePxB1 EcIF+oeJstiM+SoB3jIow3wYh/3/ X-Google-Smtp-Source: AHgI3IagqTWLP6Bu5TXXOKOAAsnMuhVH+0dRUYYnnoA7v9XJXnkfuexmrMrlvYuc0Xm6fDzPzajbew== X-Received: by 2002:a62:3a89:: with SMTP id v9mr33297418pfj.26.1550646004783; Tue, 19 Feb 2019 23:00:04 -0800 (PST) Received: from ubuntu.localdomain (c-76-102-76-212.hsd1.ca.comcast.net. [76.102.76.212]) by smtp.gmail.com with ESMTPSA id x23sm43321773pfe.0.2019.02.19.23.00.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Feb 2019 23:00:04 -0800 (PST) From: Darrell Ball To: dlu998@gmail.com, dev@openvswitch.org Date: Tue, 19 Feb 2019 22:57:14 -0800 Message-Id: <1550645838-417-2-git-send-email-dlu998@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1550645838-417-1-git-send-email-dlu998@gmail.com> References: <1550645838-417-1-git-send-email-dlu998@gmail.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=no 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 2/6] ipf: Do not preallocate more than needed. 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 ipf_reassemble_v4_frags() and ipf_reassemble_v6_frags() are preallocating more than needed for the reassembled packet. Signed-off-by: Darrell Ball --- lib/ipf.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/ipf.c b/lib/ipf.c index 125a815..a4608af 100644 --- a/lib/ipf.c +++ b/lib/ipf.c @@ -420,15 +420,16 @@ ipf_reassemble_v4_frags(struct ipf_list *ipf_list) return NULL; } - dp_packet_prealloc_tailroom(pkt, len + rest_len); + dp_packet_prealloc_tailroom(pkt, rest_len); for (int i = 1; i <= ipf_list->last_inuse_idx; i++) { size_t add_len = frag_list[i].end_data_byte - frag_list[i].start_data_byte + 1; - len += add_len; const char *l4 = dp_packet_l4(frag_list[i].pkt); dp_packet_put(pkt, l4, add_len); } + + len += rest_len; l3 = dp_packet_l3(pkt); ovs_be16 new_ip_frag_off = l3->ip_frag_off & ~htons(IP_MORE_FRAGMENTS); l3->ip_csum = recalc_csum16(l3->ip_csum, l3->ip_frag_off, @@ -463,16 +464,16 @@ ipf_reassemble_v6_frags(struct ipf_list *ipf_list) return NULL; } - dp_packet_prealloc_tailroom(pkt, pl + rest_len); + dp_packet_prealloc_tailroom(pkt, rest_len); for (int i = 1; i <= ipf_list->last_inuse_idx; i++) { size_t add_len = frag_list[i].end_data_byte - frag_list[i].start_data_byte + 1; - pl += add_len; const char *l4 = dp_packet_l4(frag_list[i].pkt); dp_packet_put(pkt, l4, add_len); } + pl += rest_len; l3 = dp_packet_l3(pkt); uint8_t nw_proto = l3->ip6_nxt;