From patchwork Thu May 24 02:13:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrell Ball X-Patchwork-Id: 919510 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="LiXcyQ8u"; 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 40rtHC2qWWz9s0q for ; Thu, 24 May 2018 12:14:13 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id C4F59EA7; Thu, 24 May 2018 02:14: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 974D6E9B for ; Thu, 24 May 2018 02:14:08 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl0-f67.google.com (mail-pl0-f67.google.com [209.85.160.67]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 56DEB674 for ; Thu, 24 May 2018 02:14:08 +0000 (UTC) Received: by mail-pl0-f67.google.com with SMTP id az12-v6so56363plb.8 for ; Wed, 23 May 2018 19:14:08 -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=7McP2k5Z3um7GzKKRwYiHt8P6RNmvEAf6ELXVqwd2ZI=; b=LiXcyQ8ut/0FNNayutyZxNBkshzC49Aa5B+eoToipIs4fW+8znwNLA9d7D/WKQTYPs +NtmNABMvjH2AMx3VxcWsCOnZuH24wKx3467yuz+IW/CMtYBAuOmGJ/+SANLJqSXkXRq a5FSta152Tptj2htVBTlO8j6zoU3J9r3h5jJnbwzx2HQVDWNZYi7j7V5+EzVS4o4k2GR inJhtKxVBfajq5soBwdVykr5gaKRPjfgPKGkW1mTh5wuewah3oLtlqAOOseqPNBGZ4FO rUtQ/MwDr/yK5qKR6WfQKaClgMF3L9rQCwKv1LGZv3EKPCJAXEBmuO4KqB+gRGzycMMd rFog== 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=7McP2k5Z3um7GzKKRwYiHt8P6RNmvEAf6ELXVqwd2ZI=; b=ANCme6LpH3FJwheLyJCvGyRkrTnEjpQ6C+hZePAtv5dRGeJ/HjZvoQ/zjzaeLj11n7 bCjkRe7MRjg2+zdlHvvAobdXA5RKiBKwa/7v+Tk9s8DB9GV5xMbF/pODR8Q7KZrKhWJN ErpHM5MPzEPx61d/roFWVwWwnLCdx0xlLwlkMU66mB/lGneAA2OVyvHtjItt1W7C1+u6 zdKPulZAb34h8RL9CiDIKzYigB/UpjT7/v60RJNCbKvHcaySmxxd6o+rhL06MrlVC28T 3ALAdgWZBHAyDDHDKM4cPH5zmP/AV8UFkbCr4/b3SzUXLn6ccnQG2mA0CjGCwU6taSpQ 8zZA== X-Gm-Message-State: ALKqPwf+hoojOeeZGkUBPnBf4zk4z6omR+6duW7U3VYWSxe4fiDFzUFW tFXVYWDdFidkv1fb+SdVsIE= X-Google-Smtp-Source: AB8JxZoJmCnDpnZ/JaQa3ffvw2XynuPE3FomPBnt7u/TWoGqxuELkMdwKfmN5WD4UULNkRi5c431WQ== X-Received: by 2002:a17:902:778a:: with SMTP id o10-v6mr5339667pll.214.1527128047934; Wed, 23 May 2018 19:14:07 -0700 (PDT) Received: from ubuntu.localdomain ([208.91.2.1]) by smtp.gmail.com with ESMTPSA id b89-v6sm49942198pfd.85.2018.05.23.19.14.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 May 2018 19:14:07 -0700 (PDT) From: Darrell Ball To: dlu998@gmail.com, dev@openvswitch.org Date: Wed, 23 May 2018 19:13:56 -0700 Message-Id: <1527128037-63000-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 v4 1/2] 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: William Tu Fixes: 068794b43f0e ("erspan: Add flow-based erspan options") Signed-off-by: Darrell Ball Acked-by: William Tu --- lib/netdev-native-tnl.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c index c97491e..a63fe24 100644 --- a/lib/netdev-native-tnl.c +++ b/lib/netdev-native-tnl.c @@ -653,23 +653,16 @@ 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); + uint32_t erspan_idx = (tnl_cfg->erspan_idx_flow + ? params->flow->tunnel.erspan_idx + : tnl_cfg->erspan_idx); put_16aligned_be32(ALIGNED_CAST(ovs_16aligned_be32 *, ersh + 1), - htonl(tnl_cfg->erspan_idx)); - - index = (ovs_be32 *)(ersh + 1); - - if (tnl_cfg->erspan_idx_flow) { - *index = htonl(params->flow->tunnel.erspan_idx); - } else { - *index = htonl(tnl_cfg->erspan_idx); - } + htonl(erspan_idx)); hlen = ERSPAN_GREHDR_LEN + sizeof *ersh + ERSPAN_V1_MDSIZE; } else if (erspan_ver == 2) { From patchwork Thu May 24 02:13:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrell Ball X-Patchwork-Id: 919512 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="DVQx4Uyh"; 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 40rtHk1RzSz9s0q for ; Thu, 24 May 2018 12:14:42 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id B8F1AEB7; Thu, 24 May 2018 02:14:12 +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 92381E9B for ; Thu, 24 May 2018 02:14:09 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl0-f52.google.com (mail-pl0-f52.google.com [209.85.160.52]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 3E5C8674 for ; Thu, 24 May 2018 02:14:09 +0000 (UTC) Received: by mail-pl0-f52.google.com with SMTP id ay10-v6so66382plb.1 for ; Wed, 23 May 2018 19:14:09 -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:in-reply-to:references; bh=X7duiDly1gYYpQI1JxK/av2PQsbM24fqvrmEQbiqtkE=; b=DVQx4UyhRMQY8jjX80MwXkdhZT2UmOKkFdl242dJP3q8a4nqBmnCeO87ehqHWuwk8F af8S+0+G0Jt6Vo/n9Vl7U540zca7NK2OrN3aOTFzncZfJ56TjMk2AAEU+2szKgLC4rMt P3D+e3+FYrLAbOAWgjUfCrsgEM/yjdKbOh5P3tgXHlTR0XAO5GabU05NZYisw/4/dleZ cVytlM8NKM8QRzGgfMhjmv6O0mYTyxdXdBQA+r2L+Yv68xot3tGoOQirt6T5+yRwu9Ku KG2T30nDyIJOe1b2i01aNLZlHkC0ZP9BAIJBaxdx7nnytte0iMV7H12lbyAdjreaSD5+ 1HgQ== 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=X7duiDly1gYYpQI1JxK/av2PQsbM24fqvrmEQbiqtkE=; b=nfeAniNR/nQq8h2/gHmzTMz8dmpk8TRdxe1TBsk2YKo42L6BrkDZgUFPYIkUmy+0gU lyzoWXodooboPRfsNJVaRfSCpzJrKE9QO2ttxxbCLUckkZJqkLtd9JJddG0khqyNpYqk qbutpM5cA3a0Sit1+5ZhYfzGQH+7SnFZ0MbVit5bV8bnN1KOXs+zwTrPxwwkbpbXyqM9 Obn6DPyYIQpiMAezUX/6ZYCsNIOa28eZKg/olwvYZW29CHyKB0y2Rafq/A0LF4bjXobA lCykgKRVnNeul9OAsab8hD6l054KYI65chtSUR873WOqh0gM72zhCExqLrAlcPS3pM1L CekQ== X-Gm-Message-State: ALKqPwfDhQcpDxekfn8EBou9K+MEifAxK0ZnJ+EncJ0475cP5iRu6gYA aA5VL1pYEuhYRZhQB7f0dGwrOQ== X-Google-Smtp-Source: AB8JxZqlCJUG1V3KwsMun/x3EETZCMgtwfan63yOC6KqfuKYji0aYVS4/5W5/35It/9nkzUl89KZHQ== X-Received: by 2002:a17:902:8303:: with SMTP id bd3-v6mr5225993plb.290.1527128048900; Wed, 23 May 2018 19:14:08 -0700 (PDT) Received: from ubuntu.localdomain ([208.91.2.1]) by smtp.gmail.com with ESMTPSA id b89-v6sm49942198pfd.85.2018.05.23.19.14.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 May 2018 19:14:08 -0700 (PDT) From: Darrell Ball To: dlu998@gmail.com, dev@openvswitch.org Date: Wed, 23 May 2018 19:13:57 -0700 Message-Id: <1527128037-63000-2-git-send-email-dlu998@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527128037-63000-1-git-send-email-dlu998@gmail.com> References: <1527128037-63000-1-git-send-email-dlu998@gmail.com> 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 v4 2/2] packets: ersapn_metadata header fixups. 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 struct erspan_metadata is updated to replace the 'version' placeholder with the erspan base hdr. Also, the erspan index is defined explicitly as ovs_16aligned_be32 to mirror its encoding. Changes to odp_util result from updating the erspan index type. CC: William Tu Fixes: 068794b43f0e ("erspan: Add flow-based erspan options") Signed-off-by: Darrell Ball --- lib/odp-util.c | 36 ++++++++++++++++++++---------------- lib/packets.h | 6 +++--- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/lib/odp-util.c b/lib/odp-util.c index 105ac80..767281f 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -2786,9 +2786,9 @@ odp_tun_key_from_attr__(const struct nlattr *attr, bool is_mask, memcpy(&opts, nl_attr_get(a), attr_len); - tun->erspan_ver = opts.version; + tun->erspan_ver = opts.bh.ver; if (tun->erspan_ver == 1) { - tun->erspan_idx = ntohl(opts.u.index); + tun->erspan_idx = ntohl(get_16aligned_be32(&opts.u.index)); } else if (tun->erspan_ver == 2) { tun->erspan_dir = opts.u.md2.dir; tun->erspan_hwid = get_hwid(&opts.u.md2); @@ -2890,10 +2890,11 @@ tun_key_to_attr(struct ofpbuf *a, const struct flow_tnl *tun_key, !strcmp(tnl_type, "ip6erspan")) && (tun_key->erspan_ver == 1 || tun_key->erspan_ver == 2)) { struct erspan_metadata opts; + memset(&opts, 0, sizeof opts); - opts.version = tun_key->erspan_ver; - if (opts.version == 1) { - opts.u.index = htonl(tun_key->erspan_idx); + opts.bh.ver = tun_key->erspan_ver; + if (opts.bh.ver == 1) { + put_16aligned_be32(&opts.u.index, htonl(tun_key->erspan_idx)); } else { opts.u.md2.dir = tun_key->erspan_dir; set_hwid(&opts.u.md2, tun_key->erspan_hwid); @@ -3368,22 +3369,23 @@ format_odp_tun_erspan_opt(const struct nlattr *attr, opts = nl_attr_get(attr); mask = mask_attr ? nl_attr_get(mask_attr) : NULL; - ver = (uint8_t)opts->version; + ver = opts->bh.ver; if (mask) { - ver_ma = (uint8_t)mask->version; + ver_ma = mask->bh.ver; } format_u8u(ds, "ver", ver, mask ? &ver_ma : NULL, verbose); - if (opts->version == 1) { + if (opts->bh.ver == 1) { if (mask) { ds_put_format(ds, "idx=%#"PRIx32"/%#"PRIx32",", - ntohl(opts->u.index), - ntohl(mask->u.index)); + ntohl(get_16aligned_be32(&opts->u.index)), + ntohl(get_16aligned_be32(&mask->u.index))); } else { - ds_put_format(ds, "idx=%#"PRIx32",", ntohl(opts->u.index)); + ds_put_format(ds, "idx=%#"PRIx32",", + ntohl(get_16aligned_be32(&opts->u.index))); } - } else if (opts->version == 2) { + } else if (opts->bh.ver == 2) { dir = opts->u.md2.dir; hwid = opts->u.md2.hwid; if (mask) { @@ -4859,10 +4861,11 @@ scan_erspan_metadata(const char *s, if (!strncmp(s, ")", 1)) { s += 1; - key->version = ver; - key->u.index = htonl(idx); + memset(&key->bh, 0, sizeof key->bh); + key->bh.ver = ver; + put_16aligned_be32(&key->u.index, htonl(idx)); if (mask) { - mask->u.index = htonl(idx_mask); + put_16aligned_be32(&mask->u.index, htonl(idx_mask)); } } return s - s_base; @@ -4882,7 +4885,8 @@ scan_erspan_metadata(const char *s, if (!strncmp(s, ")", 1)) { s += 1; - key->version = ver; + memset(&key->bh, 0, sizeof key->bh); + key->bh.ver = ver; key->u.md2.hwid = hwid; key->u.md2.dir = dir; if (mask) { diff --git a/lib/packets.h b/lib/packets.h index 7645a9d..5c013a3 100644 --- a/lib/packets.h +++ b/lib/packets.h @@ -1312,10 +1312,10 @@ struct erspan_md2 { }; struct erspan_metadata { - int version; + struct erspan_base_hdr bh; union { - ovs_be32 index; /* Version 1 (type II)*/ - struct erspan_md2 md2; /* Version 2 (type III) */ + ovs_16aligned_be32 index; /* Version 1 (type II). */ + struct erspan_md2 md2; /* Version 2 (type III). */ } u; };