COVERAGE_DEFINE(facet_unexpected);
COVERAGE_DEFINE(facet_suppress);
COVERAGE_DEFINE(subfacet_install_fail);
+COVERAGE_DEFINE(flow_mod_overflow);
/* Number of implemented OpenFlow tables. */
enum { N_TABLES = 255 };
int vid;
};
-static bool vsp_adjust_flow(const struct ofproto_dpif *, struct flow *);
static void vsp_remove(struct ofport_dpif *);
static void vsp_add(struct ofport_dpif *, ofp_port_t realdev_ofp_port, int vid);
static int set_cfm(struct ofport *, const struct cfm_settings *);
static void ofport_update_peer(struct ofport_dpif *);
static void run_fast_rl(void);
+static int run_fast(struct ofproto *);
struct dpif_completion {
struct list list_node;
int refcount;
struct dpif *dpif;
struct timer next_expiration;
- struct hmap odp_to_ofport_map; /* ODP port to ofport mapping. */
+
+ struct ovs_rwlock odp_to_ofport_lock;
+ struct hmap odp_to_ofport_map OVS_GUARDED; /* ODP port to ofport map. */
struct simap tnl_backers; /* Set of dpif ports backing tunnels. */
static struct shash all_dpif_backers = SHASH_INITIALIZER(&all_dpif_backers);
static void drop_key_clear(struct dpif_backer *);
-static struct ofport_dpif *
-odp_port_to_ofport(const struct dpif_backer *, odp_port_t odp_port);
static void update_moving_averages(struct dpif_backer *backer);
struct ofproto_dpif {
long long int stp_last_tick;
/* VLAN splinters. */
- struct hmap realdev_vid_map; /* (realdev,vid) -> vlandev. */
- struct hmap vlandev_map; /* vlandev -> (realdev,vid). */
+ struct ovs_mutex vsp_mutex;
+ struct hmap realdev_vid_map OVS_GUARDED; /* (realdev,vid) -> vlandev. */
+ struct hmap vlandev_map OVS_GUARDED; /* vlandev -> (realdev,vid). */
/* Ports. */
struct sset ports; /* Set of standard port names. */
/* Per ofproto's dpif stats. */
uint64_t n_hit;
uint64_t n_missed;
+
+ /* Work queues. */
+ struct ovs_mutex flow_mod_mutex;
+ struct list flow_mods OVS_GUARDED;
+ size_t n_flow_mods OVS_GUARDED;
};
/* Defer flow mod completion until "ovs-appctl ofproto/unclog"? (Useful only
static struct ofport_dpif *get_ofp_port(const struct ofproto_dpif *ofproto,
ofp_port_t ofp_port);
+static void ofproto_trace(struct ofproto_dpif *, const struct flow *,
+ const struct ofpbuf *packet, struct ds *);
/* Upcalls. */
#define FLOW_MISS_MAX_BATCH 50
/* Initial mappings of port to bridge mappings. */
static struct shash init_ofp_ports = SHASH_INITIALIZER(&init_ofp_ports);
-int
+/* Executes and takes ownership of 'fm'. */
+void
ofproto_dpif_flow_mod(struct ofproto_dpif *ofproto,
struct ofputil_flow_mod *fm)
{
- return ofproto_flow_mod(&ofproto->up, fm);
+ ovs_mutex_lock(&ofproto->flow_mod_mutex);
+ if (ofproto->n_flow_mods > 1024) {
+ ovs_mutex_unlock(&ofproto->flow_mod_mutex);
+ COVERAGE_INC(flow_mod_overflow);
+ free(fm->ofpacts);
+ free(fm);
+ return;
+ }
+
+ list_push_back(&ofproto->flow_mods, &fm->list_node);
+ ofproto->n_flow_mods++;
+ ovs_mutex_unlock(&ofproto->flow_mod_mutex);
}
void
continue;
}
- xlate_ofproto_set(ofproto, ofproto->up.name, ofproto->ml,
+ xlate_ofproto_set(ofproto, ofproto->up.name,
+ ofproto->backer->dpif, ofproto->ml,
ofproto->stp, ofproto->mbridge,
ofproto->sflow, ofproto->ipfix,
ofproto->up.frag_handling,
/* 'ofport''s datapath port number has changed from
* 'ofport->odp_port' to 'port.port_no'. Update our internal data
* structures to match. */
+ ovs_rwlock_wrlock(&backer->odp_to_ofport_lock);
hmap_remove(&backer->odp_to_ofport_map, &ofport->odp_port_node);
ofport->odp_port = port.port_no;
hmap_insert(&backer->odp_to_ofport_map, &ofport->odp_port_node,
hash_odp_port(port.port_no));
+ ovs_rwlock_unlock(&backer->odp_to_ofport_lock);
backer->need_revalidate = REV_RECONFIGURE;
}
}
if (time_msec() >= port_rl) {
struct ofproto_dpif *ofproto;
- struct ofport_dpif *ofport;
HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_node, &all_ofproto_dpifs) {
-
- HMAP_FOR_EACH (ofport, up.hmap_node, &ofproto->up.ports) {
- port_run_fast(ofport);
- }
+ run_fast(&ofproto->up);
}
port_rl = time_msec() + 200;
}
hmap_destroy(&backer->drop_keys);
simap_destroy(&backer->tnl_backers);
+ ovs_rwlock_destroy(&backer->odp_to_ofport_lock);
hmap_destroy(&backer->odp_to_ofport_map);
node = shash_find(&all_dpif_backers, backer->type);
free(backer->type);
backer->governor = NULL;
backer->refcount = 1;
hmap_init(&backer->odp_to_ofport_map);
+ ovs_rwlock_init(&backer->odp_to_ofport_lock);
hmap_init(&backer->drop_keys);
hmap_init(&backer->subfacets);
timer_set_duration(&backer->next_expiration, 1000);
ofproto->ml = mac_learning_create(MAC_ENTRY_DEFAULT_IDLE_TIME);
ofproto->mbridge = mbridge_create();
ofproto->has_bonded_bundles = false;
+ ovs_mutex_init(&ofproto->vsp_mutex, PTHREAD_MUTEX_NORMAL);
classifier_init(&ofproto->facets);
ofproto->consistency_rl = LLONG_MIN;
list_init(&ofproto->completions);
+ ovs_mutex_init(&ofproto->flow_mod_mutex, PTHREAD_MUTEX_NORMAL);
+ ovs_mutex_lock(&ofproto->flow_mod_mutex);
+ list_init(&ofproto->flow_mods);
+ ofproto->n_flow_mods = 0;
+ ovs_mutex_unlock(&ofproto->flow_mod_mutex);
+
ofproto_dpif_unixctl_init();
hmap_init(&ofproto->vlandev_map);
{
struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
struct rule_dpif *rule, *next_rule;
+ struct ofputil_flow_mod *fm, *next_fm;
struct oftable *table;
ofproto->backer->need_revalidate = REV_RECONFIGURE;
}
}
+ ovs_mutex_lock(&ofproto->flow_mod_mutex);
+ LIST_FOR_EACH_SAFE (fm, next_fm, list_node, &ofproto->flow_mods) {
+ list_remove(&fm->list_node);
+ ofproto->n_flow_mods--;
+ free(fm->ofpacts);
+ free(fm);
+ }
+ ovs_mutex_unlock(&ofproto->flow_mod_mutex);
+ ovs_mutex_destroy(&ofproto->flow_mod_mutex);
+
mbridge_unref(ofproto->mbridge);
netflow_destroy(ofproto->netflow);
sset_destroy(&ofproto->ghost_ports);
sset_destroy(&ofproto->port_poll_set);
+ ovs_mutex_destroy(&ofproto->vsp_mutex);
+
close_dpif_backer(ofproto->backer);
}
run_fast(struct ofproto *ofproto_)
{
struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
+ struct ofputil_flow_mod *fm, *next;
struct ofport_dpif *ofport;
+ struct list flow_mods;
/* Do not perform any periodic activity required by 'ofproto' while
* waiting for flow restore to complete. */
return 0;
}
+ ovs_mutex_lock(&ofproto->flow_mod_mutex);
+ if (ofproto->n_flow_mods) {
+ flow_mods = ofproto->flow_mods;
+ list_moved(&flow_mods);
+ list_init(&ofproto->flow_mods);
+ ofproto->n_flow_mods = 0;
+ } else {
+ list_init(&flow_mods);
+ }
+ ovs_mutex_unlock(&ofproto->flow_mod_mutex);
+
+ LIST_FOR_EACH_SAFE (fm, next, list_node, &flow_mods) {
+ int error = ofproto_flow_mod(&ofproto->up, fm);
+ if (error && !VLOG_DROP_WARN(&rl)) {
+ VLOG_WARN("learning action failed to modify flow table (%s)",
+ ofperr_get_name(error));
+ }
+
+ list_remove(&fm->list_node);
+ free(fm->ofpacts);
+ free(fm);
+ }
+
HMAP_FOR_EACH (ofport, up.hmap_node, &ofproto->up.ports) {
port_run_fast(ofport);
}
return EBUSY;
}
+ ovs_rwlock_wrlock(&ofproto->backer->odp_to_ofport_lock);
hmap_insert(&ofproto->backer->odp_to_ofport_map, &port->odp_port_node,
hash_odp_port(port->odp_port));
+ ovs_rwlock_unlock(&ofproto->backer->odp_to_ofport_lock);
}
dpif_port_destroy(&dpif_port);
}
if (port->odp_port != ODPP_NONE && !port->is_tunnel) {
+ ovs_rwlock_wrlock(&ofproto->backer->odp_to_ofport_lock);
hmap_remove(&ofproto->backer->odp_to_ofport_map, &port->odp_port_node);
+ ovs_rwlock_unlock(&ofproto->backer->odp_to_ofport_lock);
}
tnl_port_del(port);
}
}
\f
-int
-ofproto_dpif_queue_to_priority(const struct ofproto_dpif *ofproto,
- uint32_t queue_id, uint32_t *priority)
-{
- return dpif_queue_to_priority(ofproto->backer->dpif, queue_id, priority);
-}
-
static int
set_queues(struct ofport *ofport_, const struct ofproto_port_queue *qdscp,
size_t n_qdscp)
subfacet_update_stats(subfacet, stats);
}
- if (miss->upcall_type == DPIF_UC_MISS || subfacet->path != want_path) {
+ if (subfacet->path != want_path) {
struct flow_miss_op *op = &ops[(*n_ops)++];
struct dpif_flow_put *put = &op->dpif_op.u.flow_put;
}
}
-/* Given a datpath, packet, and flow metadata ('backer', 'packet', and 'key'
- * respectively), populates 'flow' with the result of odp_flow_key_to_flow().
- * Optionally, if nonnull, populates 'fitnessp' with the fitness of 'flow' as
- * returned by odp_flow_key_to_flow(). Also, optionally populates 'ofproto'
- * with the ofproto_dpif, and 'odp_in_port' with the datapath in_port, that
- * 'packet' ingressed.
- *
- * If 'ofproto' is nonnull, requires 'flow''s in_port to exist. Otherwise sets
- * 'flow''s in_port to OFPP_NONE.
- *
- * This function does post-processing on data returned from
- * odp_flow_key_to_flow() to help make VLAN splinters transparent to the rest
- * of the upcall processing logic. In particular, if the extracted in_port is
- * a VLAN splinter port, it replaces flow->in_port by the "real" port, sets
- * flow->vlan_tci correctly for the VLAN of the VLAN splinter port, and pushes
- * a VLAN header onto 'packet' (if it is nonnull).
- *
- * Similarly, this function also includes some logic to help with tunnels. It
- * may modify 'flow' as necessary to make the tunneling implementation
- * transparent to the upcall processing logic.
- *
- * Returns 0 if successful, ENODEV if the parsed flow has no associated ofport,
- * or some other positive errno if there are other problems. */
-static int
-ofproto_receive(const struct dpif_backer *backer, struct ofpbuf *packet,
- const struct nlattr *key, size_t key_len,
- struct flow *flow, enum odp_key_fitness *fitnessp,
- struct ofproto_dpif **ofproto, odp_port_t *odp_in_port)
-{
- const struct ofport_dpif *port;
- enum odp_key_fitness fitness;
- int error = ENODEV;
-
- fitness = odp_flow_key_to_flow(key, key_len, flow);
- if (fitness == ODP_FIT_ERROR) {
- error = EINVAL;
- goto exit;
- }
-
- if (odp_in_port) {
- *odp_in_port = flow->in_port.odp_port;
- }
-
- port = (tnl_port_should_receive(flow)
- ? tnl_port_receive(flow)
- : odp_port_to_ofport(backer, flow->in_port.odp_port));
- flow->in_port.ofp_port = port ? port->up.ofp_port : OFPP_NONE;
- if (!port) {
- goto exit;
- }
-
- /* XXX: Since the tunnel module is not scoped per backer, for a tunnel port
- * it's theoretically possible that we'll receive an ofport belonging to an
- * entirely different datapath. In practice, this can't happen because no
- * platforms has two separate datapaths which each support tunneling. */
- ovs_assert(ofproto_dpif_cast(port->up.ofproto)->backer == backer);
-
- if (vsp_adjust_flow(ofproto_dpif_cast(port->up.ofproto), flow)) {
- if (packet) {
- /* Make the packet resemble the flow, so that it gets sent to
- * an OpenFlow controller properly, so that it looks correct
- * for sFlow, and so that flow_extract() will get the correct
- * vlan_tci if it is called on 'packet'.
- *
- * The allocated space inside 'packet' probably also contains
- * 'key', that is, both 'packet' and 'key' are probably part of
- * a struct dpif_upcall (see the large comment on that
- * structure definition), so pushing data on 'packet' is in
- * general not a good idea since it could overwrite 'key' or
- * free it as a side effect. However, it's OK in this special
- * case because we know that 'packet' is inside a Netlink
- * attribute: pushing 4 bytes will just overwrite the 4-byte
- * "struct nlattr", which is fine since we don't need that
- * header anymore. */
- eth_push_vlan(packet, flow->vlan_tci);
- }
- /* We can't reproduce 'key' from 'flow'. */
- fitness = fitness == ODP_FIT_PERFECT ? ODP_FIT_TOO_MUCH : fitness;
- }
- error = 0;
-
- if (ofproto) {
- *ofproto = ofproto_dpif_cast(port->up.ofproto);
- }
-
-exit:
- if (fitnessp) {
- *fitnessp = fitness;
- }
- return error;
-}
-
static void
handle_miss_upcalls(struct dpif_backer *backer, struct dpif_upcall *upcalls,
size_t n_upcalls)
uint32_t hash;
int error;
- error = ofproto_receive(backer, upcall->packet, upcall->key,
- upcall->key_len, &flow, &miss->key_fitness,
- &ofproto, &odp_in_port);
+ error = xlate_receive(backer, upcall->packet, upcall->key,
+ upcall->key_len, &flow, &miss->key_fitness,
+ &ofproto, &odp_in_port);
if (error == ENODEV) {
struct drop_key *drop_key;
struct flow flow;
odp_port_t odp_in_port;
- if (ofproto_receive(backer, upcall->packet, upcall->key, upcall->key_len,
- &flow, NULL, &ofproto, &odp_in_port)
+ if (xlate_receive(backer, upcall->packet, upcall->key, upcall->key_len,
+ &flow, NULL, &ofproto, &odp_in_port)
|| !ofproto->sflow) {
return;
}
union user_action_cookie cookie;
struct flow flow;
- if (ofproto_receive(backer, upcall->packet, upcall->key, upcall->key_len,
- &flow, NULL, &ofproto, NULL)
+ if (xlate_receive(backer, upcall->packet, upcall->key, upcall->key_len,
+ &flow, NULL, &ofproto, NULL)
|| !ofproto->ipfix) {
return;
}
struct ofproto_dpif *ofproto;
struct flow flow;
- if (ofproto_receive(backer, upcall->packet, upcall->key, upcall->key_len,
- &flow, NULL, &ofproto, NULL)
+ if (xlate_receive(backer, upcall->packet, upcall->key, upcall->key_len,
+ &flow, NULL, &ofproto, NULL)
|| !ofproto->ipfix) {
return;
}
* where it is and recompiles its actions anyway.
*
* - If any of 'facet''s subfacets correspond to a new flow according to
- * ofproto_receive(), 'facet' is removed.
+ * xlate_receive(), 'facet' is removed.
*
* Returns true if 'facet' is still valid. False if 'facet' was removed. */
static bool
struct flow recv_flow;
int error;
- error = ofproto_receive(ofproto->backer, NULL, subfacet->key,
- subfacet->key_len, &recv_flow, NULL,
- &recv_ofproto, NULL);
+ error = xlate_receive(ofproto->backer, NULL, subfacet->key,
+ subfacet->key_len, &recv_flow, NULL,
+ &recv_ofproto, NULL);
if (error
|| recv_ofproto != ofproto
|| facet != facet_find(ofproto, &recv_flow)) {
void
rule_credit_stats(struct rule_dpif *rule, const struct dpif_flow_stats *stats)
{
+ ovs_mutex_lock(&rule->stats_mutex);
rule->packet_count += stats->n_packets;
rule->byte_count += stats->n_bytes;
ofproto_rule_update_used(&rule->up, stats->used);
+ ovs_mutex_unlock(&rule->stats_mutex);
}
\f
/* Subfacets. */
rule_construct(struct rule *rule_)
{
struct rule_dpif *rule = rule_dpif_cast(rule_);
+ ovs_mutex_init(&rule->stats_mutex, PTHREAD_MUTEX_NORMAL);
+ ovs_mutex_lock(&rule->stats_mutex);
rule->packet_count = 0;
rule->byte_count = 0;
+ ovs_mutex_unlock(&rule->stats_mutex);
complete_operation(rule);
return 0;
}
static void
-rule_destruct(struct rule *rule)
+rule_destruct(struct rule *rule_)
{
- complete_operation(rule_dpif_cast(rule));
+ struct rule_dpif *rule = rule_dpif_cast(rule_);
+ complete_operation(rule);
+ ovs_mutex_destroy(&rule->stats_mutex);
}
static void
/* Start from historical data for 'rule' itself that are no longer tracked
* in facets. This counts, for example, facets that have expired. */
+ ovs_mutex_lock(&rule->stats_mutex);
*packets = rule->packet_count;
*bytes = rule->byte_count;
+ ovs_mutex_unlock(&rule->stats_mutex);
}
static void
ODPP_NONE);
odp_put_userspace_action(pid, &cookie, sizeof cookie.slow_path, &buf);
} else {
- put_userspace_action(ofproto, &buf, flow, &cookie,
- sizeof cookie.slow_path);
+ odp_port_t odp_port;
+ uint32_t pid;
+
+ odp_port = ofp_port_to_odp_port(ofproto, flow->in_port.ofp_port);
+ pid = dpif_port_get_pid(ofproto->backer->dpif, odp_port);
+ odp_put_userspace_action(pid, &cookie, sizeof cookie.slow_path, &buf);
}
*actionsp = buf.data;
*actions_lenp = buf.size;
}
-
-size_t
-put_userspace_action(const struct ofproto_dpif *ofproto,
- struct ofpbuf *odp_actions,
- const struct flow *flow,
- const union user_action_cookie *cookie,
- const size_t cookie_size)
-{
- uint32_t pid;
-
- pid = dpif_port_get_pid(ofproto->backer->dpif,
- ofp_port_to_odp_port(ofproto,
- flow->in_port.ofp_port));
-
- return odp_put_userspace_action(pid, cookie, cookie_size, odp_actions);
-}
\f
static bool
set_frag_handling(struct ofproto *ofproto_,
backer = node->data;
}
- /* Extract the ofproto_dpif object from the ofproto_receive()
- * function. */
- if (ofproto_receive(backer, NULL, odp_key.data,
- odp_key.size, &flow, NULL, &ofproto, NULL)) {
+ if (xlate_receive(backer, NULL, odp_key.data, odp_key.size, &flow,
+ NULL, &ofproto, NULL)) {
unixctl_command_reply_error(conn, "Invalid datapath flow");
goto exit;
}
ofpbuf_uninit(&odp_mask);
}
-void
+static void
ofproto_trace(struct ofproto_dpif *ofproto, const struct flow *flow,
const struct ofpbuf *packet, struct ds *ds)
{
}
odp_flow_format(subfacet->key, subfacet->key_len,
- mask.data, mask.size, &ds);
+ mask.data, mask.size, &ds, false);
ds_put_format(&ds, ", packets:%"PRIu64", bytes:%"PRIu64", used:",
subfacet->dp_packet_count, subfacet->dp_byte_count);
bool
ofproto_has_vlan_splinters(const struct ofproto_dpif *ofproto)
+ OVS_EXCLUDED(ofproto->vsp_mutex)
{
- return !hmap_is_empty(&ofproto->realdev_vid_map);
+ bool ret;
+
+ ovs_mutex_lock(&ofproto->vsp_mutex);
+ ret = !hmap_is_empty(&ofproto->realdev_vid_map);
+ ovs_mutex_unlock(&ofproto->vsp_mutex);
+ return ret;
}
-/* Returns the OFP port number of the Linux VLAN device that corresponds to
- * 'vlan_tci' on the network device with port number 'realdev_ofp_port' in
- * 'struct ofport_dpif'. For example, given 'realdev_ofp_port' of eth0 and
- * 'vlan_tci' 9, it would return the port number of eth0.9.
- *
- * Unless VLAN splinters are enabled for port 'realdev_ofp_port', this
- * function just returns its 'realdev_ofp_port' argument. */
-ofp_port_t
-vsp_realdev_to_vlandev(const struct ofproto_dpif *ofproto,
- ofp_port_t realdev_ofp_port, ovs_be16 vlan_tci)
+static ofp_port_t
+vsp_realdev_to_vlandev__(const struct ofproto_dpif *ofproto,
+ ofp_port_t realdev_ofp_port, ovs_be16 vlan_tci)
+ OVS_REQUIRES(ofproto->vsp_mutex)
{
if (!hmap_is_empty(&ofproto->realdev_vid_map)) {
int vid = vlan_tci_to_vid(vlan_tci);
return realdev_ofp_port;
}
+/* Returns the OFP port number of the Linux VLAN device that corresponds to
+ * 'vlan_tci' on the network device with port number 'realdev_ofp_port' in
+ * 'struct ofport_dpif'. For example, given 'realdev_ofp_port' of eth0 and
+ * 'vlan_tci' 9, it would return the port number of eth0.9.
+ *
+ * Unless VLAN splinters are enabled for port 'realdev_ofp_port', this
+ * function just returns its 'realdev_ofp_port' argument. */
+ofp_port_t
+vsp_realdev_to_vlandev(const struct ofproto_dpif *ofproto,
+ ofp_port_t realdev_ofp_port, ovs_be16 vlan_tci)
+ OVS_EXCLUDED(ofproto->vsp_mutex)
+{
+ ofp_port_t ret;
+
+ ovs_mutex_lock(&ofproto->vsp_mutex);
+ ret = vsp_realdev_to_vlandev__(ofproto, realdev_ofp_port, vlan_tci);
+ ovs_mutex_unlock(&ofproto->vsp_mutex);
+ return ret;
+}
+
static struct vlan_splinter *
vlandev_find(const struct ofproto_dpif *ofproto, ofp_port_t vlandev_ofp_port)
{
static ofp_port_t
vsp_vlandev_to_realdev(const struct ofproto_dpif *ofproto,
ofp_port_t vlandev_ofp_port, int *vid)
+ OVS_REQ_WRLOCK(ofproto->vsp_mutex)
{
if (!hmap_is_empty(&ofproto->vlandev_map)) {
const struct vlan_splinter *vsp;
* 'flow->vlan_tci' to the VLAN VID, and returns true. Otherwise (which is
* always the case unless VLAN splinters are enabled), returns false without
* making any changes. */
-static bool
+bool
vsp_adjust_flow(const struct ofproto_dpif *ofproto, struct flow *flow)
+ OVS_EXCLUDED(ofproto->vsp_mutex)
{
ofp_port_t realdev;
int vid;
+ ovs_mutex_lock(&ofproto->vsp_mutex);
realdev = vsp_vlandev_to_realdev(ofproto, flow->in_port.ofp_port, &vid);
+ ovs_mutex_unlock(&ofproto->vsp_mutex);
if (!realdev) {
return false;
}
struct ofproto_dpif *ofproto = ofproto_dpif_cast(port->up.ofproto);
struct vlan_splinter *vsp;
+ ovs_mutex_lock(&ofproto->vsp_mutex);
vsp = vlandev_find(ofproto, port->up.ofp_port);
if (vsp) {
hmap_remove(&ofproto->vlandev_map, &vsp->vlandev_node);
} else {
VLOG_ERR("missing vlan device record");
}
+ ovs_mutex_unlock(&ofproto->vsp_mutex);
}
static void
{
struct ofproto_dpif *ofproto = ofproto_dpif_cast(port->up.ofproto);
+ ovs_mutex_lock(&ofproto->vsp_mutex);
if (!vsp_vlandev_to_realdev(ofproto, port->up.ofp_port, NULL)
- && (vsp_realdev_to_vlandev(ofproto, realdev_ofp_port, htons(vid))
+ && (vsp_realdev_to_vlandev__(ofproto, realdev_ofp_port, htons(vid))
== realdev_ofp_port)) {
struct vlan_splinter *vsp;
vsp = xmalloc(sizeof *vsp);
- hmap_insert(&ofproto->vlandev_map, &vsp->vlandev_node,
- hash_ofp_port(port->up.ofp_port));
- hmap_insert(&ofproto->realdev_vid_map, &vsp->realdev_vid_node,
- hash_realdev_vid(realdev_ofp_port, vid));
vsp->realdev_ofp_port = realdev_ofp_port;
vsp->vlandev_ofp_port = port->up.ofp_port;
vsp->vid = vid;
port->realdev_ofp_port = realdev_ofp_port;
+
+ hmap_insert(&ofproto->vlandev_map, &vsp->vlandev_node,
+ hash_ofp_port(port->up.ofp_port));
+ hmap_insert(&ofproto->realdev_vid_map, &vsp->realdev_vid_node,
+ hash_realdev_vid(realdev_ofp_port, vid));
} else {
VLOG_ERR("duplicate vlan device record");
}
+ ovs_mutex_unlock(&ofproto->vsp_mutex);
}
static odp_port_t
return ofport ? ofport->odp_port : ODPP_NONE;
}
-static struct ofport_dpif *
+struct ofport_dpif *
odp_port_to_ofport(const struct dpif_backer *backer, odp_port_t odp_port)
{
struct ofport_dpif *port;
+ ovs_rwlock_rdlock(&backer->odp_to_ofport_lock);
HMAP_FOR_EACH_IN_BUCKET (port, odp_port_node, hash_odp_port(odp_port),
&backer->odp_to_ofport_map) {
if (port->odp_port == odp_port) {
+ ovs_rwlock_unlock(&backer->odp_to_ofport_lock);
return port;
}
}
+ ovs_rwlock_unlock(&backer->odp_to_ofport_lock);
return NULL;
}