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

Ben Pfaff blp at ovn.org
Mon Jun 4 20:42:10 UTC 2018


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 at aimvalley.nl>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2018-June/046864.html
Signed-off-by: Ben Pfaff <blp at ovn.org>
---
 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 at hpe.com
 Dave Walker                     DaveWalker at ubuntu.com
 David Evans                     davidjoshuaevans at gmail.com
 David Palma                     palma at onesource.pt
+David van Moolenbroek           dvmoolenbroek at aimvalley.nl
 Derek Cormier                   derek.cormier at lab.ntt.co.jp
 Dhaval Badiani                  dbadiani at vmware.com
 DK Moon                         dkmoon at 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;
-- 
2.16.1



More information about the dev mailing list