X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=datapath%2Fvport-patch.c;h=4fdbcf5278d6558f7f75519b0f96687d9e1554cf;hb=d2bb2799e1b7cf2177140cf4ca8a60312c87625a;hp=b0ae3a070f6713c38c3761d1a65bc73653bda191;hpb=7237e4f4b6155eb4854cebc0a45fe845f0950b40;p=openvswitch diff --git a/datapath/vport-patch.c b/datapath/vport-patch.c index b0ae3a07..4fdbcf52 100644 --- a/datapath/vport-patch.c +++ b/datapath/vport-patch.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "datapath.h" #include "vport.h" @@ -22,17 +23,16 @@ struct device_config { }; 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. */ @@ -59,7 +59,7 @@ static void assign_config_rcu(struct vport *vport, 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); } @@ -128,8 +128,8 @@ static struct vport *patch_create(const struct vport_parms *parms) 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)); @@ -158,19 +158,22 @@ static int patch_modify(struct vport *vport, struct odp_port *port) 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; } @@ -226,13 +229,13 @@ static const char *patch_get_name(const struct vport *vport) 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)