From patchwork Wed May 8 07:39:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1096795 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 44zT2r6q78z9s4V for ; Wed, 8 May 2019 17:42:28 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 3B2D7FF9; Wed, 8 May 2019 07:41:56 +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 7D544FE6 for ; Wed, 8 May 2019 07:41:54 +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 BD4E7831 for ; Wed, 8 May 2019 07:41:52 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE2 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 May 2019 10:40:10 +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 x487e8m9017243; Wed, 8 May 2019 10:40:09 +0300 From: Eli Britstein To: dev@openvswitch.org, Ben Pfaff Date: Wed, 8 May 2019 07:39:58 +0000 Message-Id: <20190508073959.2364-2-elibr@mellanox.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190508073959.2364-1-elibr@mellanox.com> References: <20190508073959.2364-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 1/2] ofproto-dpif-xlate: Change priority tags from boolean to enum 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 Priority tags is a port configuration to determine how the port treats priority tags, e.g. zero VLAN ID. Change the type from boolean to enum as a pre-step towards introducing additional modes. The new options are "omit", equivalent to previously "false", and "include-non-zero", equivalent to previously "true". "true" is still supported for backwards compatibility. Signed-off-by: Eli Britstein Reviewed-by: Roi Dayan --- ofproto/ofproto-dpif-xlate.c | 9 +++++---- ofproto/ofproto-dpif-xlate.h | 2 +- ofproto/ofproto-dpif.c | 3 ++- ofproto/ofproto.h | 10 +++++++++- tests/ofproto-dpif.at | 6 +++--- vswitchd/bridge.c | 8 ++++++-- vswitchd/vswitch.xml | 4 ++-- 7 files changed, 28 insertions(+), 14 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 5cee37f7b..4c1cdfa58 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -149,7 +149,8 @@ struct xbundle { * NULL if all VLANs are trunked. */ unsigned long *cvlans; /* Bitmap of allowed customer vlans, * NULL if all VLANs are allowed */ - bool use_priority_tags; /* Use 802.1p tag for frames in VLAN 0? */ + enum port_priority_tags_mode use_priority_tags; + /* Use 802.1p tag for frames in VLAN 0? */ bool floodable; /* No port has OFPUTIL_PC_NO_FLOOD set? */ bool protected; /* Protected port mode */ }; @@ -604,7 +605,7 @@ static void xlate_xbundle_set(struct xbundle *xbundle, enum port_vlan_mode vlan_mode, uint16_t qinq_ethtype, int vlan, unsigned long *trunks, unsigned long *cvlans, - bool use_priority_tags, + enum port_priority_tags_mode use_priority_tags, const struct bond *bond, const struct lacp *lacp, bool floodable, bool protected); static void xlate_xport_set(struct xport *xport, odp_port_t odp_port, @@ -999,7 +1000,7 @@ static void xlate_xbundle_set(struct xbundle *xbundle, enum port_vlan_mode vlan_mode, uint16_t qinq_ethtype, int vlan, unsigned long *trunks, unsigned long *cvlans, - bool use_priority_tags, + enum port_priority_tags_mode use_priority_tags, const struct bond *bond, const struct lacp *lacp, bool floodable, bool protected) { @@ -1316,7 +1317,7 @@ xlate_bundle_set(struct ofproto_dpif *ofproto, struct ofbundle *ofbundle, const char *name, enum port_vlan_mode vlan_mode, uint16_t qinq_ethtype, int vlan, unsigned long *trunks, unsigned long *cvlans, - bool use_priority_tags, + enum port_priority_tags_mode use_priority_tags, const struct bond *bond, const struct lacp *lacp, bool floodable, bool protected) { diff --git a/ofproto/ofproto-dpif-xlate.h b/ofproto/ofproto-dpif-xlate.h index 5a51d7b30..c947bd801 100644 --- a/ofproto/ofproto-dpif-xlate.h +++ b/ofproto/ofproto-dpif-xlate.h @@ -181,7 +181,7 @@ void xlate_bundle_set(struct ofproto_dpif *, struct ofbundle *, const char *name, enum port_vlan_mode, uint16_t qinq_ethtype, int vlan, unsigned long *trunks, unsigned long *cvlans, - bool use_priority_tags, + enum port_priority_tags_mode use_priority_tags, const struct bond *, const struct lacp *, bool floodable, bool protected); void xlate_bundle_remove(struct ofbundle *); diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index db461ac07..3db97ca37 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -101,7 +101,8 @@ struct ofbundle { unsigned long *cvlans; struct lacp *lacp; /* LACP if LACP is enabled, otherwise NULL. */ struct bond *bond; /* Nonnull iff more than one port. */ - bool use_priority_tags; /* Use 802.1p tag for frames in VLAN 0? */ + enum port_priority_tags_mode use_priority_tags; + /* Use 802.1p tag for frames in VLAN 0? */ bool protected; /* Protected port mode */ diff --git a/ofproto/ofproto.h b/ofproto/ofproto.h index 510ace103..caf5e50b5 100644 --- a/ofproto/ofproto.h +++ b/ofproto/ofproto.h @@ -416,6 +416,13 @@ enum port_vlan_mode { PORT_VLAN_DOT1Q_TUNNEL }; +/* The behaviour of the port regarding priority tags */ +enum port_priority_tags_mode { + PORT_PRIORITY_TAGS_OMIT = 0, + PORT_PRIORITY_TAGS_INCLUDE_NON_ZERO, +}; + +/* The behaviour of the port regarding priority tags */ /* Configuration of bundles. */ struct ofproto_bundle_settings { char *name; /* For use in log messages. */ @@ -428,7 +435,8 @@ struct ofproto_bundle_settings { int vlan; /* VLAN VID, except for PORT_VLAN_TRUNK. */ unsigned long *trunks; /* vlan_bitmap, except for PORT_VLAN_ACCESS. */ unsigned long *cvlans; - bool use_priority_tags; /* Use 802.1p tag for frames in VLAN 0? */ + enum port_priority_tags_mode use_priority_tags; + /* Use 802.1p tag for frames in VLAN 0? */ struct bond_settings *bond; /* Must be nonnull iff if n_slaves > 1. */ diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at index 9b0231b88..73242b1f6 100644 --- a/tests/ofproto-dpif.at +++ b/tests/ofproto-dpif.at @@ -3467,18 +3467,18 @@ OVS_VSWITCHD_START( add-port br0 p1 trunks=10,12 -- \ add-port br0 p2 tag=10 -- \ add-port br0 p3 tag=12 \ - other-config:priority-tags=true -- \ + other-config:priority-tags=include-non-zero -- \ add-port br0 p4 tag=12 -- \ add-port br0 p5 vlan_mode=native-tagged tag=10 -- \ add-port br0 p6 vlan_mode=native-tagged tag=10 trunks=10,12 -- \ add-port br0 p7 vlan_mode=native-untagged tag=12 -- \ add-port br0 p8 vlan_mode=native-untagged tag=12 trunks=10,12 \ - other-config:priority-tags=true -- \ + other-config:priority-tags=include-non-zero -- \ add-port br0 p9 vlan_mode=dot1q-tunnel tag=10 other-config:qinq-ethtype=802.1q -- \ add-port br0 p10 vlan_mode=dot1q-tunnel tag=10 cvlans=10,12 other-config:qinq-ethtype=802.1q -- \ add-port br0 p11 vlan_mode=dot1q-tunnel tag=12 other-config:qinq-ethtype=802.1q -- \ add-port br0 p12 vlan_mode=dot1q-tunnel tag=12 other-config:qinq-ethtype=802.1q \ - other-config:priority-tags=true -- \ + other-config:priority-tags=include-non-zero -- \ set Interface p1 type=dummy -- \ set Interface p2 type=dummy -- \ set Interface p3 type=dummy -- \ diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 48d8c4de1..06c8bf4ca 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -1023,8 +1023,12 @@ port_configure(struct port *port) ? ETH_TYPE_VLAN_8021Q : ETH_TYPE_VLAN_8021AD); - s.use_priority_tags = smap_get_bool(&cfg->other_config, "priority-tags", - false); + 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 { + s.use_priority_tags = PORT_PRIORITY_TAGS_OMIT; + } /* Get LACP settings. */ s.lacp = port_configure_lacp(port, &lacp_settings); diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml index 08001dbce..d5f2b0186 100644 --- a/vswitchd/vswitch.xml +++ b/vswitchd/vswitch.xml @@ -1860,7 +1860,7 @@ + type='{"type": "string", "enum": ["set", ["omit", "include-non-zero"]]}'>

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 @@ -1873,7 +1873,7 @@ header at all, even when the VLAN ID is zero. Therefore, by default Open vSwitch does not output priority-tagged frames, instead omitting the 802.1Q header entirely if the VLAN ID is zero. Set this key to - true to enable priority-tagged frames on a port. + include-non-zero to enable priority-tagged frames on a port.

From patchwork Wed May 8 07:39:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1096796 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 44zT3P54qmz9s4V for ; Wed, 8 May 2019 17:42:57 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 113E4FF6; Wed, 8 May 2019 07:41:57 +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 2C3F0FEC for ; Wed, 8 May 2019 07:41:55 +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 254151FB for ; Wed, 8 May 2019 07:41:53 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE2 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 May 2019 10:40:11 +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 x487e8mA017243; Wed, 8 May 2019 10:40:11 +0300 From: Eli Britstein To: dev@openvswitch.org, Ben Pfaff Date: Wed, 8 May 2019 07:39:59 +0000 Message-Id: <20190508073959.2364-3-elibr@mellanox.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190508073959.2364-1-elibr@mellanox.com> References: <20190508073959.2364-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 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 keep 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 keep it for such frames as well. Signed-off-by: Eli Britstein Reviewed-by: Roi Dayan --- ofproto/ofproto-dpif-xlate.c | 11 +++++++---- ofproto/ofproto.h | 1 + vswitchd/bridge.c | 2 ++ vswitchd/vswitch.xml | 7 ++++--- 4 files changed, 14 insertions(+), 7 deletions(-) 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..0115aa579 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 keep such frames as well.