From patchwork Fri Aug 30 16:13:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrell Ball X-Patchwork-Id: 1155980 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="nqEDAKgR"; 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 46Kl1Z40lgz9sMr for ; Sat, 31 Aug 2019 02:14:57 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id CF1EE62F1; Fri, 30 Aug 2019 16:14:54 +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 A420662C8 for ; Fri, 30 Aug 2019 16:13:46 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 5A7F0EC for ; Fri, 30 Aug 2019 16:13:46 +0000 (UTC) Received: by mail-pg1-f173.google.com with SMTP id x15so3770321pgg.8 for ; Fri, 30 Aug 2019 09:13:46 -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=YFKtARccwcLpoGkj3WdyMuYutK6AmTgYOxIr1gkE3lU=; b=nqEDAKgRbhOHzgKeavj9Mrkc8RTPYvagZ9SQMgJMg3CV6iMi/67M8hTqaQuPEXz7p/ CM8gRbyiIncFvfE+LzTvJgdd+YoCL0HthUd2F+1LMXad/JydNN3O3/lvn5/bhzYFoJJT ezaQuUO6neM+FAF8go4pXi/eFBPHu61C+OU9SnXl4OGqWVoNpq1svtxHhxGVCFhhp2E8 GMExhVx5Wr363DeYXjXkHjo+V/moU6Vu1lNwTqMfjevM625jeaGWhjp7WQ/jjUmvuQXs QVqcdgHUqQJD8w/C7u1AVHzyKlgNO3mhqq2OEZUgSahCSuH36IoyOh0k0vG0OMLXSLGE o6OA== 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=YFKtARccwcLpoGkj3WdyMuYutK6AmTgYOxIr1gkE3lU=; b=PqGcWkNfd1pntNKwvDxf3AmVKOs/nFVkS5zdIMoZ0Qh7gAuOR8D1SOpBN5GT5i8dXh r7O2WZ5+heMwphKD8IEh+2UDMDYkf8TyxxXar0/g/62GqlTB8LW2MQeNn6cb9NPca6JQ HTCpUD+6LEuJYscAKdvYPZonq7u1Khlxg+F2fjfHmjPx3SPKqK6ZMfRbLjkMnIL5wGZX BBym/ZdMJMit3jQf7jqzgOktb4E2KURJefZSKco+3OxYfTqFQk/6nCWavyRPtJh1EOyo SivLzlRmVYfI11SYlXds0OXLB+LIRkOUU3L6k2EwM8tfL8wqjWE/OXFhs8XFT3o5rppt oAmg== X-Gm-Message-State: APjAAAXxGNQ2+PyA9nbs9gDlDdHNELp/DiiAeimTnY66x0hqjMUzgjHb miPt5jmesNmi6/TB/Fo2+uE= X-Google-Smtp-Source: APXvYqwGeerTvUWJF652uNAgGdn6NkWPT/nPGsNxROUMsYxCt9ySgCxBde483f6s+KJiXptsfQheVg== X-Received: by 2002:aa7:809a:: with SMTP id v26mr19235804pff.82.1567181625833; Fri, 30 Aug 2019 09:13:45 -0700 (PDT) Received: from ubuntu.localdomain (c-76-102-76-212.hsd1.ca.comcast.net. [76.102.76.212]) by smtp.gmail.com with ESMTPSA id z16sm5159368pgi.8.2019.08.30.09.13.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 Aug 2019 09:13:45 -0700 (PDT) From: Darrell Ball To: dlu998@gmail.com, dev@openvswitch.org Date: Fri, 30 Aug 2019 09:13:19 -0700 Message-Id: <1567181599-92090-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 v2] 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 --- v2: Elaborate added comments. lib/conntrack.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/conntrack.c b/lib/conntrack.c index e5266e5..6452d82 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,8 @@ 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); + /* This call is already verified to succeed during the code path from + * 'conn_key_extract()' which calls 'extract_l4_icmp()'. */ 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 +721,8 @@ 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); + /* This call is already verified to succeed during the code path from + * 'conn_key_extract()' which calls 'extract_l4_icmp6()'. */ extract_l3_ipv6(&inner_key, inner_l3_6, tail - ((char *)inner_l3_6) - pad, &inner_l4);