From patchwork Tue May 22 17:58:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrell Ball X-Patchwork-Id: 918506 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="SiQOff/g"; 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 40r3Kq3s0Sz9s16 for ; Wed, 23 May 2018 03:58:38 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 77C631595; Tue, 22 May 2018 17:58:36 +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 CFF2A158C for ; Tue, 22 May 2018 17:58:35 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 95ABD6C6 for ; Tue, 22 May 2018 17:58:35 +0000 (UTC) Received: by mail-pf0-f194.google.com with SMTP id q22-v6so9139760pff.11 for ; Tue, 22 May 2018 10:58:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=14q1EFdmoz2f0z+M5DqhcWJZyfNo89UYXe6a4/wY558=; b=SiQOff/gh1cu0y1gaDAR4hJmsFdYDY/AjnWrbIOGRs3uywUNZlCgStqOJ7bSnLdlHH fLGndHsfXQnQy4Iw+83zkKiINhzppvvyEmT4covT+8TC7StZ4CMUzpvCj1QE8+v70bTb gBtfZIFnU4W4y9ryR1unXa7LPzV4q+tvGr8cPtueInKoROAf2/EcENoa2H1MkBuJ0OiN HXmhnWEGdxIP+sZ/hgOYg8iEG4Qi4LfZM0PQgBOmlBQ1eRXoUmPuS91VrunIVZLjtVZP gJSVVpwLUK1aYuFyT1aZ/lbxoKiCW0NauPlSMJ77h7JTNDs+HXjqerOTdg9+itEFaWOS mPyQ== 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; bh=14q1EFdmoz2f0z+M5DqhcWJZyfNo89UYXe6a4/wY558=; b=E0Gr1v5DBO7xfvLJrgEcbL1WV+CN/nlD3vqUOnWj4j60Z0B8tgsQWKOSdw/Y2vUHn/ B0/hOx7b5jaMUHPkPo9ygfcsLp6iydxpmwt2pVV9vgfG4Brd5wyuph5myQOtCN2Y0VIw C4GyvG733oV6rbpgQOwAmjxx6FN5ivfS7OVTeH8+sbhtZR67IrMwx/UUt8LIO1rRidFq kr0dFgoxkBnrDBvkd5lf13thF0gKFfhSxDYk7jKcutekRCKJJLcRL9drXaaLKlIVcQKc sFzyNkTHTBWQMmoFdSr7DBR7XV3tPvRaxTEVQMqjQJ9g/HwsUdUEhpbC2yHYn2ZeIQs/ S5Jg== X-Gm-Message-State: ALKqPwfS3M3QDSAz25w/Fame4ZcI9+tHdQU3zxqeMEJAK4NwMPHzv9C1 yIYe44eo/Ag6F0p2nJMkN64= X-Google-Smtp-Source: AB8JxZqTJ+5l5TRCNA0eRKkL29WEKPpucCIp04N5pSOkPf6+85y2fAApzTOg9P2T1xWnR9uq534mMw== X-Received: by 2002:a63:740c:: with SMTP id p12-v6mr19778811pgc.259.1527011915078; Tue, 22 May 2018 10:58:35 -0700 (PDT) Received: from ubuntu.localdomain (c-73-162-236-45.hsd1.ca.comcast.net. [73.162.236.45]) by smtp.gmail.com with ESMTPSA id b29-v6sm32267406pfh.155.2018.05.22.10.58.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 May 2018 10:58:34 -0700 (PDT) From: Darrell Ball To: dlu998@gmail.com, dev@openvswitch.org Date: Tue, 22 May 2018 10:58:24 -0700 Message-Id: <1527011904-100961-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 v3] netdev-native-tnl: Fix alignment for erspan index. 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 Flagged by clang. CC: Greg Rose Fixes: 068794b43f0e ("erspan: Add flow-based erspan options") Signed-off-by: Darrell Ball --- lib/netdev-native-tnl.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c index c97491e..dd36695 100644 --- a/lib/netdev-native-tnl.c +++ b/lib/netdev-native-tnl.c @@ -653,24 +653,21 @@ netdev_erspan_build_header(const struct netdev *netdev, } if (erspan_ver == 1) { - ovs_be32 *index; - greh->protocol = htons(ETH_TYPE_ERSPAN1); greh->flags = htons(GRE_SEQ); ersh->ver = 1; set_sid(ersh, sid); - put_16aligned_be32(ALIGNED_CAST(ovs_16aligned_be32 *, ersh + 1), - htonl(tnl_cfg->erspan_idx)); - - index = (ovs_be32 *)(ersh + 1); - + void *erspan_hdr_idx = ersh + 1; + ovs_be32 erspan_idx; if (tnl_cfg->erspan_idx_flow) { - *index = htonl(params->flow->tunnel.erspan_idx); + erspan_idx = htonl(params->flow->tunnel.erspan_idx); } else { - *index = htonl(tnl_cfg->erspan_idx); + erspan_idx = htonl(tnl_cfg->erspan_idx); } + memcpy(erspan_hdr_idx, &erspan_idx, sizeof erspan_idx); + hlen = ERSPAN_GREHDR_LEN + sizeof *ersh + ERSPAN_V1_MDSIZE; } else if (erspan_ver == 2) { struct erspan_md2 *md2 = ALIGNED_CAST(struct erspan_md2 *, ersh + 1);