Skip to content

Commit

Permalink
lib/rstp: More robust thread safety.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Daniele Venturino <[email protected]>
  • Loading branch information
Jarno Rajahalme committed Sep 9, 2014
1 parent 8fb76a0 commit f025bcb
Show file tree
Hide file tree
Showing 10 changed files with 956 additions and 640 deletions.
202 changes: 102 additions & 100 deletions lib/rstp-common.h

Large diffs are not rendered by default.

111 changes: 85 additions & 26 deletions lib/rstp-state-machines.c

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions lib/rstp-state-machines.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@
#include "rstp-common.h"

/* Methods called by the Forwarding Layer, through functions of rstp.h. */
int move_rstp(struct rstp *);
void decrease_rstp_port_timers(struct rstp *);
void process_received_bpdu(struct rstp_port *, const void *, size_t);
int move_rstp__(struct rstp *)
OVS_REQUIRES(rstp_mutex);
void decrease_rstp_port_timers__(struct rstp *)
OVS_REQUIRES(rstp_mutex);
void process_received_bpdu__(struct rstp_port *, const void *, size_t)
OVS_REQUIRES(rstp_mutex);

void updt_roles_tree(struct rstp *);
void updt_roles_tree__(struct rstp *)
OVS_REQUIRES(rstp_mutex);

#endif /* rstp-state-machines.h */
Loading

0 comments on commit f025bcb

Please sign in to comment.