[ovs-dev] rstp: Eliminate BPDU padding and uninitialized bytes.

Message ID 20180604204210.4773-1-blp@ovn.org
State Accepted
Headers show
Series
  • [ovs-dev] rstp: Eliminate BPDU padding and uninitialized bytes.
Related show

Commit Message

Ben Pfaff June 4, 2018, 8:42 p.m.
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 <dvmoolenbroek@aimvalley.nl>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2018-June/046864.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 AUTHORS.rst               | 1 +
 lib/rstp-common.h         | 1 -
 lib/rstp-state-machines.c | 2 ++
 3 files changed, 3 insertions(+), 1 deletion(-)

Patch

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;