git://git.onelab.eu
/
sliver-openvswitch.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Prepare for post-2.2.0 (2.2.90).
[sliver-openvswitch.git]
/
lib
/
lacp.c
diff --git
a/lib/lacp.c
b/lib/lacp.c
index
07f1e10
..
4aee64f
100644
(file)
--- a/
lib/lacp.c
+++ b/
lib/lacp.c
@@
-1,4
+1,4
@@
-/* Copyright (c) 2011, 2012, 2013 Nicira, Inc.
+/* Copyright (c) 2011, 2012, 2013
, 2014
Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-106,7
+106,7
@@
struct lacp {
bool update; /* True if lacp_update() needs to be called. */
bool fallback_ab; /* True if fallback to active-backup on LACP failure. */
bool update; /* True if lacp_update() needs to be called. */
bool fallback_ab; /* True if fallback to active-backup on LACP failure. */
-
atomic_i
nt ref_cnt;
+
struct ovs_refcou
nt ref_cnt;
};
struct slave {
};
struct slave {
@@
-181,7
+181,8
@@
parse_lacp_packet(const struct ofpbuf *b)
{
const struct lacp_pdu *pdu;
{
const struct lacp_pdu *pdu;
- pdu = ofpbuf_at(b, (uint8_t *)b->l3 - (uint8_t *)b->data, LACP_PDU_LEN);
+ pdu = ofpbuf_at(b, (uint8_t *)ofpbuf_l3(b) - (uint8_t *)ofpbuf_data(b),
+ LACP_PDU_LEN);
if (pdu && pdu->subtype == 1
&& pdu->actor_type == 1 && pdu->actor_len == 20
if (pdu && pdu->subtype == 1
&& pdu->actor_type == 1 && pdu->actor_len == 20
@@
-216,7
+217,7
@@
lacp_create(void) OVS_EXCLUDED(mutex)
lacp = xzalloc(sizeof *lacp);
hmap_init(&lacp->slaves);
lacp = xzalloc(sizeof *lacp);
hmap_init(&lacp->slaves);
-
atomic_init(&lacp->ref_cnt, 1
);
+
ovs_refcount_init(&lacp->ref_cnt
);
ovs_mutex_lock(&mutex);
list_push_back(all_lacps, &lacp->node);
ovs_mutex_lock(&mutex);
list_push_back(all_lacps, &lacp->node);
@@
-229,9
+230,7
@@
lacp_ref(const struct lacp *lacp_)
{
struct lacp *lacp = CONST_CAST(struct lacp *, lacp_);
if (lacp) {
{
struct lacp *lacp = CONST_CAST(struct lacp *, lacp_);
if (lacp) {
- int orig;
- atomic_add(&lacp->ref_cnt, 1, &orig);
- ovs_assert(orig > 0);
+ ovs_refcount_ref(&lacp->ref_cnt);
}
return lacp;
}
}
return lacp;
}
@@
-240,15
+239,7
@@
lacp_ref(const struct lacp *lacp_)
void
lacp_unref(struct lacp *lacp) OVS_EXCLUDED(mutex)
{
void
lacp_unref(struct lacp *lacp) OVS_EXCLUDED(mutex)
{
- int orig;
-
- if (!lacp) {
- return;
- }
-
- atomic_sub(&lacp->ref_cnt, 1, &orig);
- ovs_assert(orig > 0);
- if (orig == 1) {
+ if (lacp && ovs_refcount_unref(&lacp->ref_cnt) == 1) {
struct slave *slave, *next;
ovs_mutex_lock(&mutex);
struct slave *slave, *next;
ovs_mutex_lock(&mutex);
@@
-905,7
+896,7
@@
lacp_print_details(struct ds *ds, struct lacp *lacp) OVS_REQUIRES(mutex)
status = "defaulted";
break;
default:
status = "defaulted";
break;
default:
- NOT_REACHED();
+
OVS_
NOT_REACHED();
}
ds_put_format(ds, "\nslave: %s: %s %s\n", slave->name, status,
}
ds_put_format(ds, "\nslave: %s: %s %s\n", slave->name, status,