From patchwork Mon Jan 28 12:29:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pieter Jansen van Vuuren X-Patchwork-Id: 1031890 X-Patchwork-Delegate: horms@verge.net.au 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=none (p=none dis=none) header.from=netronome.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="JwU4oI13"; 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 43p8FV4lrhz9s3q for ; Mon, 28 Jan 2019 23:34:06 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id F30DC221D; Mon, 28 Jan 2019 12:33:09 +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 2162D1EC0 for ; Mon, 28 Jan 2019 12:29:50 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id E4A7E711 for ; Mon, 28 Jan 2019 12:29:48 +0000 (UTC) Received: by mail-wr1-f42.google.com with SMTP id q18so17818348wrx.9 for ; Mon, 28 Jan 2019 04:29:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=J7k+R/ddQAk05jfsv6R728uGSnE7Y+/J5Sbu4rG3q5c=; b=JwU4oI135uYmslR629hAaAKG8i05Tny26xu/OstngeTTgAMVHrNgWJGzsj7+ZAOnQj ZmNenJsnQNg/waT3BURB8MRPS/c31bNxYgb56eeGoaHuKHPekKejP/rNEcYf2QiwPEK4 oNa5eyGql+yRPmvlTEUB4uWc1vjjeUcQnTwd3ww3NW3PGbhbuAw6KmSIpDm8arCL1tzI 00xhbFSbQRz9hBIGCLGFZEKOjtuOc1HL51sQo0dC+WJ4hU9hy/OITT78eXW1b4AoRWrC 6/MDGUkLUGjURikWr/vcpen9te/hY4Hv6gpZmjjL6c+wM68rfai4SXMoxe/8xxACQPxJ Efeg== 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=J7k+R/ddQAk05jfsv6R728uGSnE7Y+/J5Sbu4rG3q5c=; b=KyjbyYysi8h8+J1Q/bseSFz+R1OcbhK4oKmqQaz3F1C7BanVmLmnuDJY2RKAJ9LEWM /naa+KYP2k7l0EeIdZQj5sCag1FbfojTVZVcoGYS43KFuxV2AyLf/AIM1AdMy3YSroYQ Ic6zKmcPs0S+QC2Fc85qpokjqKmaUx9VhUzCYr/jdChXoWc0h7Ej+3Uenr0W0kaSX4pq d3XMyBdKv0XLZzXt8hlHSU7W17cHZlXppvhFxgHzxJYmrHyBv4SJEW0G7s/P8y1ibVOY 26g7Z1h21KBnmmfKa+K13ZbP0cl/ONRdSdxRTSx0Aa1GG/ckcahRPUlsVVZz2QkLVx6f 0YyQ== X-Gm-Message-State: AJcUukd16CgvJXIq8OUEUCI2/24zhE0Sohmxd8cZER3EdiPnmv/y5eTL ChPMg3IGawd5HHpN0g6KqfXSca9adYc= X-Google-Smtp-Source: ALg8bN4PB0qTUYKtijTLQDw2X1tQZOlKKhZoECwe6zUmEy40TzOvrNGenLwQ8+8rQHSLhs0ypA3srA== X-Received: by 2002:a5d:6889:: with SMTP id h9mr21435366wru.222.1548678587304; Mon, 28 Jan 2019 04:29:47 -0800 (PST) Received: from pieter-Netronome.netronome.com ([217.38.71.146]) by smtp.gmail.com with ESMTPSA id x186sm94367285wmg.41.2019.01.28.04.29.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Jan 2019 04:29:46 -0800 (PST) From: Pieter Jansen van Vuuren To: dev@openvswitch.org Date: Mon, 28 Jan 2019 12:29:08 +0000 Message-Id: <1548678550-6661-3-git-send-email-pieter.jansenvanvuuren@netronome.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1548678550-6661-1-git-send-email-pieter.jansenvanvuuren@netronome.com> References: <1548678550-6661-1-git-send-email-pieter.jansenvanvuuren@netronome.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 Cc: simon.horman@netronome.com, Pieter Jansen van Vuuren Subject: [ovs-dev] [RFC v3 2/4] lib/tc: fix 32 bits shift for pedit offset calculation 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 pedit allows setting entire words with an optional mask and OVS makes use of such masks to allow setting fields that do not span entire words. One mask for leading bytes that should not be updated and another mask for trailing bytes that should not be updated. The masks are created using bit shifts. In the case of the mask to omit trailing bytes a right bit shift is used. Currently the code can produce shifts of 1, 2, 3 or 4 bytes (8, 16, 24 or 32 bits) based on the alignment of the end of field being set. However, a shift of 32 bits on a 32bit value is undefined. As it stands the code relies on the result of UINT32_MAX >> 32 being UINT32_MAX. Or in other words a mask that results in the pedit action setting all bytes of the word under operation. This patch adjusts the code to use a shift of 0 for this case, which gives the same result as the undefined behaviour that was relied on, and appears logically correct as the desire is for no trailing bytes (or bits!) to be omitted from the set action. Signed-off-by: Pieter Jansen van Vuuren Reviewed-by: Simon Horman --- lib/tc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tc.c b/lib/tc.c index ae5017c17..953fffd01 100644 --- a/lib/tc.c +++ b/lib/tc.c @@ -1737,7 +1737,7 @@ calc_offsets(struct tc_flower *flower, struct flower_key_to_pedit *m, start_offset = ROUND_DOWN(m->offset, 4); diff = m->offset - start_offset; total_size = max_offset - start_offset; - right_zero_bits = 8 * (4 - (max_offset % 4)); + right_zero_bits = 8 * (4 - ((max_offset % 4) ? : 4)); left_zero_bits = 8 * (m->offset - start_offset); *cur_offset = start_offset;