From patchwork Sun May 12 05:51:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1098492 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=mellanox.com 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 451tPZ23W3z9s9N for ; Sun, 12 May 2019 15:52:02 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 0914BD98; Sun, 12 May 2019 05:51:26 +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 BE1A9D7C for ; Sun, 12 May 2019 05:51:24 +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 A1BBEE6 for ; Sun, 12 May 2019 05:51:23 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE2 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 12 May 2019 08:51:20 +0300 Received: from dev-r-vrt-214.mtr.labs.mlnx. (dev-r-vrt-214.mtr.labs.mlnx [10.212.214.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x4C5pGtl024990; Sun, 12 May 2019 08:51:20 +0300 From: Eli Britstein To: dev@openvswitch.org, Ben Pfaff Date: Sun, 12 May 2019 05:51:00 +0000 Message-Id: <20190512055100.19524-3-elibr@mellanox.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190512055100.19524-1-elibr@mellanox.com> References: <20190512055100.19524-1-elibr@mellanox.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Eli Britstein Subject: [ovs-dev] [PATCH V2 2/2] ofproto-dpif-xlate: Add include mode to priority tags 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 Configure "include-non-zero" priority tags to retain the 802.1Q header when the VLAN ID is zero, except both the VLAN ID and priority are zero. Add a "include" configuration option to retain the 802.1Q header in such frames as well. Signed-off-by: Eli Britstein Reviewed-by: Roi Dayan --- NEWS | 4 ++++ ofproto/ofproto-dpif-xlate.c | 11 +++++++---- ofproto/ofproto.h | 1 + vswitchd/bridge.c | 2 ++ vswitchd/vswitch.xml | 7 ++++--- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 293531db0..7c5929fa6 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,10 @@ Post-v2.11.0 * New "ovs-appctl dpctl/ipf-get-status" command for userspace datapath conntrack fragmentation support. * New action "check_pkt_len". + * Changed options for "other-config:priority-tags" port configuration: + "false"/"true" changed to "omit"/"include-non-zero", and added a new + option "include" to always retain the 802.1Q header, for frames with + both the VLAN ID and priority are zero as well. - OVSDB: * OVSDB clients can now resynchronize with clustered servers much more quickly after a brief disconnection, saving bandwidth and CPU time. diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 4c1cdfa58..28897bf67 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -549,7 +549,8 @@ static void xvlan_copy(struct xvlan *dst, const struct xvlan *src); static void xvlan_pop(struct xvlan *src); static void xvlan_push_uninit(struct xvlan *src); static void xvlan_extract(const struct flow *, struct xvlan *); -static void xvlan_put(struct flow *, const struct xvlan *); +static void xvlan_put(struct flow *, const struct xvlan *, + enum port_priority_tags_mode); static void xvlan_input_translate(const struct xbundle *, const struct xvlan *in, struct xvlan *xvlan); @@ -2270,13 +2271,15 @@ xvlan_extract(const struct flow *flow, struct xvlan *xvlan) /* Put VLAN information (headers) to flow */ static void -xvlan_put(struct flow *flow, const struct xvlan *xvlan) +xvlan_put(struct flow *flow, const struct xvlan *xvlan, + enum port_priority_tags_mode use_priority_tags) { ovs_be16 tci; int i; for (i = 0; i < FLOW_MAX_VLAN_HEADERS; i++) { tci = htons(xvlan->v[i].vid | (xvlan->v[i].pcp & VLAN_PCP_MASK)); - if (tci) { + if (tci || ((use_priority_tags == PORT_PRIORITY_TAGS_INCLUDE) && + xvlan->v[i].tpid)) { tci |= htons(VLAN_CFI); flow->vlans[i].tpid = xvlan->v[i].tpid ? htons(xvlan->v[i].tpid) : @@ -2450,7 +2453,7 @@ output_normal(struct xlate_ctx *ctx, const struct xbundle *out_xbundle, } memcpy(&old_vlans, &ctx->xin->flow.vlans, sizeof(old_vlans)); - xvlan_put(&ctx->xin->flow, &out_xvlan); + xvlan_put(&ctx->xin->flow, &out_xvlan, out_xbundle->use_priority_tags); compose_output_action(ctx, xport->ofp_port, use_recirc ? &xr : NULL, false, false); diff --git a/ofproto/ofproto.h b/ofproto/ofproto.h index caf5e50b5..2f83ee077 100644 --- a/ofproto/ofproto.h +++ b/ofproto/ofproto.h @@ -420,6 +420,7 @@ enum port_vlan_mode { enum port_priority_tags_mode { PORT_PRIORITY_TAGS_OMIT = 0, PORT_PRIORITY_TAGS_INCLUDE_NON_ZERO, + PORT_PRIORITY_TAGS_INCLUDE, }; /* The behaviour of the port regarding priority tags */ diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 06c8bf4ca..930b66896 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -1026,6 +1026,8 @@ port_configure(struct port *port) const char *pt = smap_get_def(&cfg->other_config, "priority-tags", ""); if (!strcmp(pt, "include-non-zero") || !strcmp(pt, "true")) { s.use_priority_tags = PORT_PRIORITY_TAGS_INCLUDE_NON_ZERO; + } else if (!strcmp(pt, "include")) { + s.use_priority_tags = PORT_PRIORITY_TAGS_INCLUDE; } else { s.use_priority_tags = PORT_PRIORITY_TAGS_OMIT; } diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml index d5f2b0186..37785a385 100644 --- a/vswitchd/vswitch.xml +++ b/vswitchd/vswitch.xml @@ -1860,7 +1860,7 @@ + type='{"type": "string", "enum": ["set", ["omit", "include-non-zero", "include"]]}'>

An 802.1Q header contains two important pieces of information: a VLAN ID and a priority. A frame with a zero VLAN ID, called a @@ -1877,8 +1877,9 @@

- Regardless of this setting, Open vSwitch omits the 802.1Q header on - output if both the VLAN ID and priority would be zero. + For include-non-zero Open vSwitch omits the 802.1Q header on output + if both the VLAN ID and priority would be zero. Set to include + to retain the 802.1Q header in such frames as well.