summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJarno Rajahalme <jrajahalme@nicira.com>2014-08-22 09:01:35 -0700
committerJarno Rajahalme <jrajahalme@nicira.com>2014-09-09 11:45:44 -0700
commit6b90bc57e7a23b89a594ceb857f8267c8b4026df (patch)
tree21d0871d4fe09948f6e6f421d858d4c8500e2b66 /lib
parentf025bcb7eabbb5598d2cb1f4cdd429b47a3743dc (diff)
downloadopenvswitch-6b90bc57e7a23b89a594ceb857f8267c8b4026df.tar.gz
lib/rstp: Remove lock recursion.
Change the RSTP send_bpdu interface so that a recursive mutex is not needed. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Daniele Venturino <daniele.venturino@m3s.it>
Diffstat (limited to 'lib')
-rw-r--r--lib/rstp-common.h2
-rw-r--r--lib/rstp-state-machines.c2
-rw-r--r--lib/rstp.c7
-rw-r--r--lib/rstp.h5
4 files changed, 7 insertions, 9 deletions
diff --git a/lib/rstp-common.h b/lib/rstp-common.h
index c3d61f454..d4d7feb7f 100644
--- a/lib/rstp-common.h
+++ b/lib/rstp-common.h
@@ -872,7 +872,7 @@ struct rstp {
struct ovs_refcount ref_cnt;
/* Interface to client. */
- void (*send_bpdu)(struct ofpbuf *bpdu, int port_no, void *aux);
+ void (*send_bpdu)(struct ofpbuf *bpdu, void *port_aux, void *rstp_aux);
void *aux;
};
diff --git a/lib/rstp-state-machines.c b/lib/rstp-state-machines.c
index 8556cdfa5..0485db21a 100644
--- a/lib/rstp-state-machines.c
+++ b/lib/rstp-state-machines.c
@@ -678,7 +678,7 @@ rstp_send_bpdu(struct rstp_port *p, const void *bpdu, size_t bpdu_size)
llc->llc_dsap = STP_LLC_DSAP;
llc->llc_ssap = STP_LLC_SSAP;
llc->llc_cntl = STP_LLC_CNTL;
- p->rstp->send_bpdu(pkt, p->port_number, p->rstp->aux);
+ p->rstp->send_bpdu(pkt, p->aux, p->rstp->aux);
}
static void
diff --git a/lib/rstp.c b/lib/rstp.c
index 1295182b4..511bb83ca 100644
--- a/lib/rstp.c
+++ b/lib/rstp.c
@@ -48,7 +48,7 @@
VLOG_DEFINE_THIS_MODULE(rstp);
-struct ovs_mutex rstp_mutex;
+struct ovs_mutex rstp_mutex = OVS_MUTEX_INITIALIZER;
static struct list all_rstps__ = LIST_INITIALIZER(&all_rstps__);
static struct list *const all_rstps OVS_GUARDED_BY(rstp_mutex) = &all_rstps__;
@@ -232,8 +232,6 @@ void
rstp_init(void)
OVS_EXCLUDED(rstp_mutex)
{
- ovs_mutex_init_recursive(&rstp_mutex);
-
unixctl_command_register("rstp/tcn", "[bridge]", 0, 1, rstp_unixctl_tcn,
NULL);
}
@@ -241,7 +239,8 @@ rstp_init(void)
/* Creates and returns a new RSTP instance that initially has no ports. */
struct rstp *
rstp_create(const char *name, rstp_identifier bridge_address,
- void (*send_bpdu)(struct ofpbuf *bpdu, int port_no, void *aux),
+ void (*send_bpdu)(struct ofpbuf *bpdu, void *port_aux,
+ void *rstp_aux),
void *aux)
OVS_EXCLUDED(rstp_mutex)
{
diff --git a/lib/rstp.h b/lib/rstp.h
index c6c4a716c..364a181f0 100644
--- a/lib/rstp.h
+++ b/lib/rstp.h
@@ -130,13 +130,12 @@ static inline bool rstp_forward_in_state(enum rstp_state);
static inline bool rstp_learn_in_state(enum rstp_state);
static inline bool rstp_should_manage_bpdu(enum rstp_state state);
-/* Must be called before any other rstp function is called. */
void rstp_init(void)
OVS_EXCLUDED(rstp_mutex);
struct rstp * rstp_create(const char *, rstp_identifier bridge_id,
- void (*send_bpdu)(struct ofpbuf *, int port_no,
- void *aux),
+ void (*send_bpdu)(struct ofpbuf *, void *port_aux,
+ void *rstp_aux),
void *aux)
OVS_EXCLUDED(rstp_mutex);