From patchwork Thu Feb 14 23:16:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li,Rongqing via dev" X-Patchwork-Id: 1042499 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=none (p=none dis=none) header.from=openvswitch.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=neratec.com header.i=@neratec.com header.b="PIOPsoJV"; 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 440sj539jnz9sCh for ; Fri, 15 Feb 2019 10:16:41 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id C4F25B0B; Thu, 14 Feb 2019 23:16:38 +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 C3657AF7 for ; Thu, 14 Feb 2019 23:16:37 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from prognostix.neratec.com (prognostix.neratec.com [46.235.145.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 6F749FE for ; Thu, 14 Feb 2019 23:16:36 +0000 (UTC) Received: from mail.neratec.com (mail.neratec.com [46.140.151.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by prognostix.neratec.com (Postfix) with ESMTPS id B0C5C7CB7E2 for ; Fri, 15 Feb 2019 00:16:34 +0100 (CET) Received: from localhost (mail.neratec.com [127.0.0.1]) by mail.neratec.com (Postfix) with ESMTP id 32F84CE02F3; Fri, 15 Feb 2019 00:16:34 +0100 (CET) Authentication-Results: mail.neratec.com (amavisd-new); dkim=neutral reason="invalid (public key: not available)" header.d=neratec.com Received: from mail.neratec.com ([127.0.0.1]) by localhost (mail.neratec.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id bxPrWtUSP8sw; Fri, 15 Feb 2019 00:16:34 +0100 (CET) Received: from localhost (mail.neratec.com [127.0.0.1]) by mail.neratec.com (Postfix) with ESMTP id 0B4E8CE02F4; Fri, 15 Feb 2019 00:16:34 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.neratec.com 0B4E8CE02F4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=neratec.com; s=9F5C293A-195B-11E9-BBA5-B4F3B9D999CA; t=1550186194; bh=fjE/KD+uw2HAQ78lj1owBC+sVvDpXC1QuAyBWKjLpt0=; h=From:To:Date:Message-Id:MIME-Version; b=PIOPsoJVUdLImg5AHRa5q7d6WdzPa5+R4JewvN1DFndB0WdA8E/QqvHgGcMklUBxI mVlW6zmSmxSGKO34EDu37CUSebe0X3YvM7/orzl6HYXunyQhT3RLVMNhvdzji8+ccg RIx6h1jgaySz+gbsU1SIJgmdronIyUpubcfyautzcER2R7LeOl7GCMjhTVU5jjU61F zo/8VqYIpjh2aU96ZeSu/GRQzvyBBpjjmVbuWDmzEULNm/6Ee9n982jSySKpywRZdu EQsqwuYG3Mt9FHw0sfhh1vz2YSBXy9PF+8u32OpIE4YPeVFgqsQFA6jQV2f32OTYYi 2xEPBiZ07LLbA== X-Virus-Scanned: amavisd-new at neratec.com Received: from mail.neratec.com ([127.0.0.1]) by localhost (mail.neratec.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id MmWlBBP4oR9a; Fri, 15 Feb 2019 00:16:33 +0100 (CET) Received: from CHD500279.lan.neratec.com. (CHD500279.lan.neratec.com [172.29.100.110]) by mail.neratec.com (Postfix) with ESMTPSA id DE4BDCE02F3; Fri, 15 Feb 2019 00:16:33 +0100 (CET) To: dev@openvswitch.org Date: Fri, 15 Feb 2019 00:16:14 +0100 Message-Id: <20190214231614.24662-1-matthias.may@neratec.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2] rstp: add ability to receive VLAN-tagged BPDUs 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: , X-Patchwork-Original-From: Matthias May via dev From: "Li,Rongqing via dev" Reply-To: Matthias May Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org There are switches which allow to transmit their BPDUs VLAN-tagged. With this change OVS is able to receive VLAN-tagged BPDUs, but still transmits its own BPDUs untagged. This was tested against Westermo RFI-207-F4G-T3G. v2: Send patch to different address of mailing list according to suggestion of Flavio Leitner. Signed-off-by: Matthias May Signed-off-by: Matthias May Signed-off-by: Ben Pfaff --- ofproto/ofproto-dpif-xlate.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index acd4817c2..7830fee2e 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -1771,9 +1771,12 @@ xport_rstp_should_manage_bpdu(const struct xport *xport) return rstp_should_manage_bpdu(xport_get_rstp_port_state(xport)); } +#define LEN_WITHOUT_VLAN (ETH_HEADER_LEN + LLC_HEADER_LEN) +#define LEN_WITH_VLAN (VLAN_HEADER_LEN + LEN_WITHOUT_VLAN) static void rstp_process_packet(const struct xport *xport, const struct dp_packet *packet) { + int len; struct dp_packet payload = *packet; struct eth_header *eth = dp_packet_data(&payload); @@ -1787,7 +1790,9 @@ rstp_process_packet(const struct xport *xport, const struct dp_packet *packet) dp_packet_set_size(&payload, ntohs(eth->eth_type) + ETH_HEADER_LEN); } - if (dp_packet_try_pull(&payload, ETH_HEADER_LEN + LLC_HEADER_LEN)) { + /* Pull a bit less payload when the BPDU is enveloped in a VLAN header */ + len = (ntohs(eth->eth_type) == 0x8100) ? LEN_WITH_VLAN : LEN_WITHOUT_VLAN; + if (dp_packet_try_pull(&payload, len)) { rstp_port_received_bpdu(xport->rstp_port, dp_packet_data(&payload), dp_packet_size(&payload)); }