From patchwork Fri Aug 30 00:09:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrell Ball X-Patchwork-Id: 1155572 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="fZY4SS+i"; 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 46KKf93x04z9sN4 for ; Fri, 30 Aug 2019 10:11:44 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E230A59E2; Fri, 30 Aug 2019 00:11:40 +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 798E655D4 for ; Fri, 30 Aug 2019 00:10:09 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id B35B2F1 for ; Fri, 30 Aug 2019 00:10:04 +0000 (UTC) Received: by mail-pf1-f173.google.com with SMTP id c81so3246329pfc.11 for ; Thu, 29 Aug 2019 17:10:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=l9kjxgwB6US33416zdPAjAG/G4Ga7MwL1iZGRf/QEGo=; b=fZY4SS+ireepaWbKp0PT2k7tf4BS+A28lM1X6TuLwsQZA8snBJ7i8/4nxnW/StqYXQ FIT19AhlAruEHslBQgBcmqUtO8vCsNlU+QGwaxbvXKfpjWZc3/qv/GrSFmGzOHaD7a6I 0J0Y9epS34ykOjkpzHFAJs/eb4GjM6jKbtqZ4tW/6JeCPSq4txqBn0BdteeD7/JYkh5r TziHJ1k1/+FvcmVFPEqqIeH/L/cmVgsBLG50DimyA5rHKSFIMYXDlEhNEd10+U6pHpL5 /EbrVTcfJG7mU0waTtPz/MJTrmZC2gx1yie/Wu32duFAJ3G/aUcLBEARUWCXlKnVXzbG U8Aw== 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; bh=l9kjxgwB6US33416zdPAjAG/G4Ga7MwL1iZGRf/QEGo=; b=i6R7oXhTcHzCbYp3GXmWqFoIebOCX9tK36xK9OnaHKhM+urN2vhHpthgZddEnu+SPC iuG9aBPlaB6S6BH8yOLqoNiIxfsPNEMGQ+Dlstol8YYBpeHSUJYZS/EZW0vaUrHFIipA mZ8gP9Tt9BiAniIZ/WKNjQMlmwNzkR1DIDfs3CUIfGNEPXRtThnc5mfWDt2KM2I6KI5F jKKVFPoLwCEB2cBK3Ccu0tWlAs6gYqmhRu0Fr2MjA7dbylPKndO3b0sIZZZF++pbMID0 VvErVye+wvXHnaGQvnw+Mz4h6Z0ZQW0H/Q4G9RpUQ6EMQ7w3LNxtNFsLIlXeoqdhocV8 uFoQ== X-Gm-Message-State: APjAAAWYLqP0UhxBR8VU6qDEx9SD1JKRz0uSM4pM7SlaYfoAJsedoOvH O/sfICnW25FQWlmYpN1tLMU= X-Google-Smtp-Source: APXvYqzreC/2Fwpx3M+mSJzQ5tNh43K9VdTxrlBgUUOdFQaGAjX2I1Li2cIlgXd3vGfFneHeqr3T8w== X-Received: by 2002:a17:90a:37d1:: with SMTP id v75mr1020622pjb.33.1567123804115; Thu, 29 Aug 2019 17:10:04 -0700 (PDT) Received: from ubuntu.localdomain ([66.170.99.2]) by smtp.gmail.com with ESMTPSA id g11sm8726575pfk.187.2019.08.29.17.10.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Aug 2019 17:10:03 -0700 (PDT) From: Darrell Ball To: dlu998@gmail.com, dev@openvswitch.org Date: Thu, 29 Aug 2019 17:09:38 -0700 Message-Id: <1567123778-88385-1-git-send-email-dlu998@gmail.com> X-Mailer: git-send-email 1.9.1 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 v1] conntrack: Fix 'reverse_nat_packet()' variable datatype. 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 The datatype 'pad' in the function 'reverse_nat_packet()' was incorrectly declared as 'char' instead of 'uint8_t'. This can affect reverse natting of icmpX packets with padding > 127 bytes. At the same time, add some comments regarding 'extract_l3_ipvX' usage in this function. Found by inspection. Fixes: edd1bef468c0 ("dpdk: Add more ICMP Related NAT support.") Signed-off-by: Darrell Ball --- lib/conntrack.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/conntrack.c b/lib/conntrack.c index e5266e5..79d2711 100644 --- a/lib/conntrack.c +++ b/lib/conntrack.c @@ -688,7 +688,7 @@ static void reverse_nat_packet(struct dp_packet *pkt, const struct conn *conn) { char *tail = dp_packet_tail(pkt); - char pad = dp_packet_l2_pad_size(pkt); + uint8_t pad = dp_packet_l2_pad_size(pkt); struct conn_key inner_key; const char *inner_l4 = NULL; uint16_t orig_l3_ofs = pkt->l3_ofs; @@ -698,6 +698,7 @@ reverse_nat_packet(struct dp_packet *pkt, const struct conn *conn) struct ip_header *nh = dp_packet_l3(pkt); struct icmp_header *icmp = dp_packet_l4(pkt); struct ip_header *inner_l3 = (struct ip_header *) (icmp + 1); + /* conn_key_extract() usage already verified extraction success. */ extract_l3_ipv4(&inner_key, inner_l3, tail - ((char *)inner_l3) - pad, &inner_l4, false); pkt->l3_ofs += (char *) inner_l3 - (char *) nh; @@ -719,6 +720,7 @@ reverse_nat_packet(struct dp_packet *pkt, const struct conn *conn) struct icmp6_error_header *icmp6 = dp_packet_l4(pkt); struct ovs_16aligned_ip6_hdr *inner_l3_6 = (struct ovs_16aligned_ip6_hdr *) (icmp6 + 1); + /* conn_key_extract() usage already verified extraction success. */ extract_l3_ipv6(&inner_key, inner_l3_6, tail - ((char *)inner_l3_6) - pad, &inner_l4);