projects
/
openvswitch
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
openflow-1.0: Rename ofp_match to ofp10_match, OFPFW_* to OFPFW10_*.
[openvswitch]
/
datapath
/
vport.c
diff --git
a/datapath/vport.c
b/datapath/vport.c
index 9881fb86f70597ca72d60e3aceff35ffc6cce817..172261aa58985b010142d17d6310bc142380d9c2 100644
(file)
--- a/
datapath/vport.c
+++ b/
datapath/vport.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 2007-201
1 Nicira Networks
.
+ * Copyright (c) 2007-201
2 Nicira, Inc
.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
@@
-16,10
+16,10
@@
* 02110-1301, USA
*/
* 02110-1301, USA
*/
-#include <linux/dcache.h>
#include <linux/etherdevice.h>
#include <linux/if.h>
#include <linux/if_vlan.h>
#include <linux/etherdevice.h>
#include <linux/if.h>
#include <linux/if_vlan.h>
+#include <linux/jhash.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/mutex.h>
@@
-28,7
+28,9
@@
#include <linux/rtnetlink.h>
#include <linux/compat.h>
#include <linux/version.h>
#include <linux/rtnetlink.h>
#include <linux/compat.h>
#include <linux/version.h>
+#include <net/net_namespace.h>
+#include "datapath.h"
#include "vport.h"
#include "vport-internal_dev.h"
#include "vport.h"
#include "vport-internal_dev.h"
@@
-119,9
+121,9
@@
void ovs_vport_exit(void)
kfree(dev_table);
}
kfree(dev_table);
}
-static struct hlist_head *hash_bucket(const char *name)
+static struct hlist_head *hash_bucket(
struct net *net,
const char *name)
{
{
- unsigned int hash =
full_name_hash(name, strlen(name)
);
+ unsigned int hash =
jhash(name, strlen(name), (unsigned long) net
);
return &dev_table[hash & (VPORT_HASH_BUCKETS - 1)];
}
return &dev_table[hash & (VPORT_HASH_BUCKETS - 1)];
}
@@
-132,14
+134,15
@@
static struct hlist_head *hash_bucket(const char *name)
*
* Must be called with RTNL or RCU read lock.
*/
*
* Must be called with RTNL or RCU read lock.
*/
-struct vport *ovs_vport_locate(const char *name)
+struct vport *ovs_vport_locate(
struct net *net,
const char *name)
{
{
- struct hlist_head *bucket = hash_bucket(name);
+ struct hlist_head *bucket = hash_bucket(n
et, n
ame);
struct vport *vport;
struct hlist_node *node;
hlist_for_each_entry_rcu(vport, node, bucket, hash_node)
struct vport *vport;
struct hlist_node *node;
hlist_for_each_entry_rcu(vport, node, bucket, hash_node)
- if (!strcmp(name, vport->ops->get_name(vport)))
+ if (!strcmp(name, vport->ops->get_name(vport)) &&
+ net_eq(ovs_dp_get_net(vport->dp), net))
return vport;
return NULL;
return vport;
return NULL;
@@
-189,6
+192,7
@@
struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops,
vport->port_no = parms->port_no;
vport->upcall_pid = parms->upcall_pid;
vport->ops = ops;
vport->port_no = parms->port_no;
vport->upcall_pid = parms->upcall_pid;
vport->ops = ops;
+ INIT_HLIST_NODE(&vport->dp_hash_node);
/* Initialize kobject for bridge. This will be added as
* /sys/class/net/<devname>/brport later, if sysfs is enabled. */
/* Initialize kobject for bridge. This will be added as
* /sys/class/net/<devname>/brport later, if sysfs is enabled. */
@@
-196,8
+200,10
@@
struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops,
kobject_init(&vport->kobj, &brport_ktype);
vport->percpu_stats = alloc_percpu(struct vport_percpu_stats);
kobject_init(&vport->kobj, &brport_ktype);
vport->percpu_stats = alloc_percpu(struct vport_percpu_stats);
- if (!vport->percpu_stats)
+ if (!vport->percpu_stats) {
+ kfree(vport);
return ERR_PTR(-ENOMEM);
return ERR_PTR(-ENOMEM);
+ }
spin_lock_init(&vport->stats_lock);
spin_lock_init(&vport->stats_lock);
@@
-239,14
+245,17
@@
struct vport *ovs_vport_add(const struct vport_parms *parms)
for (i = 0; i < n_vport_types; i++) {
if (vport_ops_list[i]->type == parms->type) {
for (i = 0; i < n_vport_types; i++) {
if (vport_ops_list[i]->type == parms->type) {
+ struct hlist_head *bucket;
+
vport = vport_ops_list[i]->create(parms);
if (IS_ERR(vport)) {
err = PTR_ERR(vport);
goto out;
}
vport = vport_ops_list[i]->create(parms);
if (IS_ERR(vport)) {
err = PTR_ERR(vport);
goto out;
}
- hlist_add_head_rcu(&vport->hash_node,
- hash_bucket(vport->ops->get_name(vport)));
+ bucket = hash_bucket(ovs_dp_get_net(vport->dp),
+ vport->ops->get_name(vport));
+ hlist_add_head_rcu(&vport->hash_node, bucket);
return vport;
}
}
return vport;
}
}