[ovs-dev] [PATCH 03/17] rstp-state-machines: Fix reception of BPDUs conveying an unknown port role.
Daniele Venturino
daniele.venturino at m3s.it
Fri Nov 14 17:04:03 UTC 2014
The commit message and your modifications look good to me.
Daniele
2014-11-14 0:19 GMT+01:00 Jarno Rajahalme <jrajahalme at nicira.com>:
> Assuming this is a good commit message:
>
> “If the Unknown value of the Port Role parameter is received, the
> state machines should treat the RST BPDU as if it were a
> Configuration BPDU.”
>
> Also, I think this is more readable with this incremental:
>
> diff --git a/lib/rstp-state-machines.c b/lib/rstp-state-machines.c
> index ade2d61..f702d53 100644
> --- a/lib/rstp-state-machines.c
> +++ b/lib/rstp-state-machines.c
> @@ -105,11 +105,12 @@ static int topology_change_sm(struct rstp_port *)
> /* port_timers_sm() not defined as a state machine */
>
> void
> -process_received_bpdu__(struct rstp_port *p, const void *bpdu,
> +process_received_bpdu__(struct rstp_port *p, const void *bpdu_,
> size_t bpdu_size)
> OVS_REQUIRES(rstp_mutex)
> {
> - struct rstp *rstp = p->rstp;
> + struct rstp *rstp = p->rstp;
> + struct rstp_bpdu *bpdu = (struct rstp_bpdu *)bpdu_;
>
> if (!p->port_enabled) {
> return;
> @@ -117,18 +118,20 @@ process_received_bpdu__(struct rstp_port *p, const
> void *bpdu,
> if (p->rcvd_bpdu) {
> return;
> }
> +
> /* [9.2.9 Encoding of Port Role values]
> - * NOTE.If the Unknown value of the Port Role parameter is received,
> the
> + * NOTE. If the Unknown value of the Port Role parameter is received,
> the
> * state machines will effectively treat the RST BPDU as if it were a
> * Configuration BPDU.
> */
> - uint8_t role = ((((struct rstp_bpdu *)bpdu)->flags) & ROLE_FLAG_MASK)
> - >> ROLE_FLAG_SHIFT;
> - if (role == PORT_UNKN &&
> - ((struct rstp_bpdu *)bpdu)->bpdu_type ==
> RAPID_SPANNING_TREE_BPDU)
> - {
> - ((struct rstp_bpdu *)bpdu)->bpdu_type = CONFIGURATION_BPDU;
> + if (bpdu->bpdu_type == RAPID_SPANNING_TREE_BPDU) {
> + uint8_t role = (bpdu->flags & ROLE_FLAG_MASK) >> ROLE_FLAG_SHIFT;
> +
> + if (role == PORT_UNKN) {
> + bpdu->bpdu_type = CONFIGURATION_BPDU;
> + }
> }
> +
> if (validate_received_bpdu(p, bpdu, bpdu_size) == 0) {
> p->rcvd_bpdu = true;
> p->rx_rstp_bpdu_cnt++;
>
>
> Acked-by: Jarno Rajahalme <jrajahalme at nicira.com>
>
> On Nov 6, 2014, at 7:31 AM, Daniele Venturino <daniele.venturino at m3s.it>
> wrote:
>
> > Signed-off-by: Daniele Venturino <daniele.venturino at m3s.it>
> > ---
> > lib/rstp-state-machines.c | 12 ++++++++++++
> > 1 file changed, 12 insertions(+)
> >
> > diff --git a/lib/rstp-state-machines.c b/lib/rstp-state-machines.c
> > index e03f720..ade2d61 100644
> > --- a/lib/rstp-state-machines.c
> > +++ b/lib/rstp-state-machines.c
> > @@ -117,6 +117,18 @@ process_received_bpdu__(struct rstp_port *p, const
> void *bpdu,
> > if (p->rcvd_bpdu) {
> > return;
> > }
> > + /* [9.2.9 Encoding of Port Role values]
> > + * NOTE.If the Unknown value of the Port Role parameter is
> received, the
> > + * state machines will effectively treat the RST BPDU as if it were
> a
> > + * Configuration BPDU.
> > + */
> > + uint8_t role = ((((struct rstp_bpdu *)bpdu)->flags) &
> ROLE_FLAG_MASK)
> > + >> ROLE_FLAG_SHIFT;
> > + if (role == PORT_UNKN &&
> > + ((struct rstp_bpdu *)bpdu)->bpdu_type ==
> RAPID_SPANNING_TREE_BPDU)
> > + {
> > + ((struct rstp_bpdu *)bpdu)->bpdu_type = CONFIGURATION_BPDU;
> > + }
> > if (validate_received_bpdu(p, bpdu, bpdu_size) == 0) {
> > p->rcvd_bpdu = true;
> > p->rx_rstp_bpdu_cnt++;
> > --
> > 1.8.1.2
> >
>
>
More information about the dev
mailing list