From patchwork Sun Sep 10 05:00:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roi Dayan X-Patchwork-Id: 812035 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=) 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 3xqf565Mpcz9sDB for ; Sun, 10 Sep 2017 15:00:23 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 0EC0440F; Sun, 10 Sep 2017 05:00:17 +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 4F30D258 for ; Sun, 10 Sep 2017 05:00:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id 43AF5E7 for ; Sun, 10 Sep 2017 05:00:15 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from roid@mellanox.com) with ESMTPS (AES256-SHA encrypted); 10 Sep 2017 08:00:10 +0300 Received: from dev-r-vrt-189.mtr.labs.mlnx (dev-r-vrt-189.mtr.labs.mlnx [10.212.189.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v8A509LD024019; Sun, 10 Sep 2017 08:00:10 +0300 From: Roi Dayan To: dev@openvswitch.org Date: Sun, 10 Sep 2017 08:00:06 +0300 Message-Id: <1505019607-63461-2-git-send-email-roid@mellanox.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1505019607-63461-1-git-send-email-roid@mellanox.com> References: <1505019607-63461-1-git-send-email-roid@mellanox.com> X-Spam-Status: No, score=0.0 required=5.0 tests=RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Simon Horman Subject: [ovs-dev] [PATCH V2 1/2] lib/odp: Fix handling of set masked action in parse_odp_action 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 From: Paul Blakey If we find that we need to change from a SET to SET_MASKED action, then we write the mask to the actions opfbuf. But if there was netlink pad added to the buffer when writing the key, mask won't follow the key data as per SET_MASKED spec. Fix that by removing the padding before writing the mask, and readding it if needed for alignment. Fixes: 6d670e7f0d45 ("lib/odp: Masked set action execution and printing.") Signed-off-by: Paul Blakey Reviewed-by: Roi Dayan Acked-by: Simon Horman --- lib/odp-util.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/odp-util.c b/lib/odp-util.c index 4f1499e..6304b3d 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -1990,8 +1990,17 @@ parse_odp_action(const char *s, const struct simap *port_names, if (size == nl_attr_get_size(key)) { /* Change to masked set action if not fully masked. */ if (!is_all_ones(mask + 1, size)) { + /* Remove padding of eariler key payload */ + actions->size -= NLA_ALIGN(key->nla_len) - key->nla_len; + + /* Put mask payload right after key payload */ key->nla_len += size; ofpbuf_put(actions, mask + 1, size); + + /* Add new padding as needed */ + ofpbuf_put_zeros(actions, NLA_ALIGN(key->nla_len) - + key->nla_len); + /* 'actions' may have been reallocated by ofpbuf_put(). */ nested = ofpbuf_at_assert(actions, start_ofs, sizeof *nested); nested->nla_type = OVS_ACTION_ATTR_SET_MASKED;