#include <linux/dcache.h>
#include <linux/kernel.h>
#include <linux/list.h>
+#include <linux/rtnetlink.h>
#include "datapath.h"
#include "vport.h"
};
struct patch_vport {
+ struct rcu_head rcu;
+
char name[IFNAMSIZ];
/* Protected by RTNL lock. */
char peer_name[IFNAMSIZ];
struct hlist_node hash_node;
- /* Protected by RCU. */
- struct vport *peer;
-
- /* Protected by RCU. */
- struct device_config *devconf;
+ struct vport __rcu *peer;
+ struct device_config __rcu *devconf;
};
/* Protected by RTNL lock. */
struct patch_vport *patch_vport = patch_vport_priv(vport);
struct device_config *old_config;
- old_config = rcu_dereference(patch_vport->devconf);
+ old_config = rtnl_dereference(patch_vport->devconf);
rcu_assign_pointer(patch_vport->devconf, new_config);
call_rcu(&old_config->rcu, free_config);
}
vport_gen_rand_ether_addr(patch_vport->devconf->eth_addr);
- /* Make the default MTU fairly large so that it doesn't become the
- * bottleneck on systems using jumbo frames. */
+ /* Make the default MTU fairly large so that it doesn't become the
+ * bottleneck on systems using jumbo frames. */
patch_vport->devconf->mtu = 65535;
hlist_add_head(&patch_vport->hash_node, hash_bucket(patch_vport->peer_name));
return err;
}
+static void free_port_rcu(struct rcu_head *rcu)
+{
+ struct patch_vport *patch_vport = container_of(rcu,
+ struct patch_vport, rcu);
+
+ kfree(patch_vport->devconf);
+ vport_free(vport_from_priv(patch_vport));
+}
+
static int patch_destroy(struct vport *vport)
{
struct patch_vport *patch_vport = patch_vport_priv(vport);
update_peers(patch_vport->name, NULL);
- rcu_assign_pointer(patch_vport->peer, NULL);
-
hlist_del(&patch_vport->hash_node);
-
- synchronize_rcu();
-
- kfree(patch_vport->devconf);
- vport_free(vport);
+ call_rcu(&patch_vport->rcu, free_port_rcu);
return 0;
}
static const unsigned char *patch_get_addr(const struct vport *vport)
{
const struct patch_vport *patch_vport = patch_vport_priv(vport);
- return rcu_dereference(patch_vport->devconf)->eth_addr;
+ return rcu_dereference_rtnl(patch_vport->devconf)->eth_addr;
}
static int patch_get_mtu(const struct vport *vport)
{
const struct patch_vport *patch_vport = patch_vport_priv(vport);
- return rcu_dereference(patch_vport->devconf)->mtu;
+ return rcu_dereference_rtnl(patch_vport->devconf)->mtu;
}
static int patch_send(struct vport *vport, struct sk_buff *skb)