/*
- * Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
struct hmap flows; /* Contains 'netflow_flows'. */
- atomic_int ref_cnt;
+ struct ovs_refcount ref_cnt;
};
struct netflow_flow {
memset(&wc->masks.nw_proto, 0xff, sizeof wc->masks.nw_proto);
memset(&wc->masks.nw_src, 0xff, sizeof wc->masks.nw_src);
memset(&wc->masks.nw_dst, 0xff, sizeof wc->masks.nw_dst);
- memset(&wc->masks.tp_src, 0xff, sizeof wc->masks.tp_src);
- memset(&wc->masks.tp_dst, 0xff, sizeof wc->masks.tp_dst);
+ flow_unwildcard_tp_ports(flow, wc);
wc->masks.nw_tos |= IP_DSCP_MASK;
}
nf->add_id_to_iface = false;
nf->netflow_cnt = 0;
hmap_init(&nf->flows);
- atomic_init(&nf->ref_cnt, 1);
+ ovs_refcount_init(&nf->ref_cnt);
ofpbuf_init(&nf->packet, 1500);
atomic_add(&netflow_count, 1, &junk);
return nf;
{
struct netflow *nf = CONST_CAST(struct netflow *, nf_);
if (nf) {
- int orig;
- atomic_add(&nf->ref_cnt, 1, &orig);
- ovs_assert(orig > 0);
+ ovs_refcount_ref(&nf->ref_cnt);
}
return nf;
}
void
netflow_unref(struct netflow *nf)
{
- int orig;
-
- if (!nf) {
- return;
- }
+ if (nf && ovs_refcount_unref(&nf->ref_cnt) == 1) {
+ int orig;
- atomic_sub(&nf->ref_cnt, 1, &orig);
- ovs_assert(orig > 0);
- if (orig == 1) {
atomic_sub(&netflow_count, 1, &orig);
collectors_destroy(nf->collectors);
ofpbuf_uninit(&nf->packet);
+ ovs_refcount_destroy(&nf->ref_cnt);
free(nf);
}
}