From patchwork Mon Jun 4 20:42:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 925221 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=ovn.org 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 4106Lj1FBkz9rvt for ; Tue, 5 Jun 2018 06:42:21 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 5D71CE52; Mon, 4 Jun 2018 20:42:19 +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 128DE35C for ; Mon, 4 Jun 2018 20:42:18 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id E40BC6DB for ; Mon, 4 Jun 2018 20:42:16 +0000 (UTC) Received: from sigabrt.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 8CDD4100004; Mon, 4 Jun 2018 22:42:12 +0200 (CEST) From: Ben Pfaff To: dev@openvswitch.org Date: Mon, 4 Jun 2018 13:42:10 -0700 Message-Id: <20180604204210.4773-1-blp@ovn.org> X-Mailer: git-send-email 2.16.1 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff , David van Moolenbroek Subject: [ovs-dev] [PATCH] rstp: Eliminate BPDU padding and uninitialized bytes. 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 When the RSTP implementation sent BPDUs, it failed to initialize some of their bytes. None of the code initialized an array of 7 padding bytes, and some of it also failed to initialize the version1_length field. In addition, the padding bytes confused some implementations that did not correctly ignore extra bytes. This commit fixes both problems, by removing the padding bytes and initializing every byte in outgoing messages. Reported-by: David van Moolenbroek Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2018-June/046864.html Signed-off-by: Ben Pfaff --- AUTHORS.rst | 1 + lib/rstp-common.h | 1 - lib/rstp-state-machines.c | 2 ++ 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index 9c81ad8b5d2d..1166a12820eb 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -430,6 +430,7 @@ Darragh O'Reilly darragh.oreilly@hpe.com Dave Walker DaveWalker@ubuntu.com David Evans davidjoshuaevans@gmail.com David Palma palma@onesource.pt +David van Moolenbroek dvmoolenbroek@aimvalley.nl Derek Cormier derek.cormier@lab.ntt.co.jp Dhaval Badiani dbadiani@vmware.com DK Moon dkmoon@nicira.com diff --git a/lib/rstp-common.h b/lib/rstp-common.h index c1082323ca18..7948842f4d3a 100644 --- a/lib/rstp-common.h +++ b/lib/rstp-common.h @@ -238,7 +238,6 @@ struct rstp_bpdu { ovs_be16 hello_time; ovs_be16 forward_delay; uint8_t version1_length; - uint8_t padding[7]; }); enum rstp_info_is { diff --git a/lib/rstp-state-machines.c b/lib/rstp-state-machines.c index 7d677d7a2401..7bd1f80c41a6 100644 --- a/lib/rstp-state-machines.c +++ b/lib/rstp-state-machines.c @@ -838,6 +838,7 @@ tx_config(struct rstp_port *p) { struct rstp_bpdu bpdu; + memset(&bpdu, 0, sizeof bpdu); bpdu.protocol_identifier = htons(0); bpdu.protocol_version_identifier = 0; bpdu.bpdu_type = CONFIGURATION_BPDU; @@ -868,6 +869,7 @@ tx_rstp(struct rstp_port *p) { struct rstp_bpdu bpdu; + memset(&bpdu, 0, sizeof bpdu); bpdu.protocol_identifier = htons(0); bpdu.protocol_version_identifier = 2; bpdu.bpdu_type = RAPID_SPANNING_TREE_BPDU;