lib/rstp: More robust thread safety.
authorJarno Rajahalme <jrajahalme@nicira.com>
Tue, 9 Sep 2014 18:11:18 +0000 (11:11 -0700)
committerJarno Rajahalme <jrajahalme@nicira.com>
Tue, 9 Sep 2014 18:45:44 +0000 (11:45 -0700)
commitf025bcb7eabbb5598d2cb1f4cdd429b47a3743dc
tree5183f457c49af7636cbd1ef288afe819ff545cf9
parent8fb76a0b7b821a74cca8d43a262e714a4148fd0e
lib/rstp: More robust thread safety.

Current code expects there to be a single thread that is responsible
for creating rstp and creating and deleting rstp_port objects.  rstp
objects are also deleted from other threads, as managed by reference
counting.

rstp port objects are not reference counted, which means that
references to rstp ports may only be held while holding the rstp
mutex, or by the thread that creates and deletes them.

This patch adds reference counting to RSTP ports, which allows ports
to be passed from ofproto-dpif to ofproto-dpif-xlate without using the
RSTP port number.  This simplifies RSTP port reconfiguration, as the
port need not be resynchronized with xlate if just the port number
changes.  This also avoids lookups on the processing of RSTP BPDUs.

This patch also:

1. Exposes the rstp mutex so that related thread safety annotations
   can be used also within rstp-state-machines.c.

2. Internal variants of most setter an getter functions are defined,
   suffixed with two underscores.  These are annotated to be callable
   only when the mutex is held.

3. Port setters were only called in a specific pattern.  The new external
   port setter combines them in a single rspt_port_set() function.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Daniele Venturino <daniele.venturino@m3s.it>
lib/rstp-common.h
lib/rstp-state-machines.c
lib/rstp-state-machines.h
lib/rstp.c
lib/rstp.h
ofproto/ofproto-dpif-xlate.c
ofproto/ofproto-dpif-xlate.h
ofproto/ofproto-dpif.c
tests/rstp.at
tests/test-rstp.c