diff options
author | Pravin B Shelar <pshelar@nicira.com> | 2015-08-08 02:51:33 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-08-10 17:03:54 -0400 |
commit | a9020fde67a6eb77f8130feff633189f99264db1 (patch) | |
tree | 4e911a8b9b4a774ba145f1d049df6e417863f902 | |
parent | fb811395cd5a71b9e94a068f524a6f4a21b67bdb (diff) |
openvswitch: Move tunnel destroy function to oppenvswitch module.
This function will be used in gre and geneve vport implementations.
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/openvswitch/vport-netdev.c | 21 | ||||
-rw-r--r-- | net/openvswitch/vport-netdev.h | 2 | ||||
-rw-r--r-- | net/openvswitch/vport-vxlan.c | 17 |
3 files changed, 20 insertions, 20 deletions
diff --git a/net/openvswitch/vport-netdev.c b/net/openvswitch/vport-netdev.c index cddb7069b11b..4b70aaa4a746 100644 --- a/net/openvswitch/vport-netdev.c +++ b/net/openvswitch/vport-netdev.c | |||
@@ -147,7 +147,7 @@ static struct vport *netdev_create(const struct vport_parms *parms) | |||
147 | return ovs_netdev_link(vport, parms->name); | 147 | return ovs_netdev_link(vport, parms->name); |
148 | } | 148 | } |
149 | 149 | ||
150 | void ovs_vport_free_rcu(struct rcu_head *rcu) | 150 | static void vport_netdev_free(struct rcu_head *rcu) |
151 | { | 151 | { |
152 | struct vport *vport = container_of(rcu, struct vport, rcu); | 152 | struct vport *vport = container_of(rcu, struct vport, rcu); |
153 | 153 | ||
@@ -155,7 +155,6 @@ void ovs_vport_free_rcu(struct rcu_head *rcu) | |||
155 | dev_put(vport->dev); | 155 | dev_put(vport->dev); |
156 | ovs_vport_free(vport); | 156 | ovs_vport_free(vport); |
157 | } | 157 | } |
158 | EXPORT_SYMBOL_GPL(ovs_vport_free_rcu); | ||
159 | 158 | ||
160 | void ovs_netdev_detach_dev(struct vport *vport) | 159 | void ovs_netdev_detach_dev(struct vport *vport) |
161 | { | 160 | { |
@@ -175,9 +174,25 @@ static void netdev_destroy(struct vport *vport) | |||
175 | ovs_netdev_detach_dev(vport); | 174 | ovs_netdev_detach_dev(vport); |
176 | rtnl_unlock(); | 175 | rtnl_unlock(); |
177 | 176 | ||
178 | call_rcu(&vport->rcu, ovs_vport_free_rcu); | 177 | call_rcu(&vport->rcu, vport_netdev_free); |
179 | } | 178 | } |
180 | 179 | ||
180 | void ovs_netdev_tunnel_destroy(struct vport *vport) | ||
181 | { | ||
182 | rtnl_lock(); | ||
183 | if (vport->dev->priv_flags & IFF_OVS_DATAPATH) | ||
184 | ovs_netdev_detach_dev(vport); | ||
185 | |||
186 | /* Early release so we can unregister the device */ | ||
187 | dev_put(vport->dev); | ||
188 | rtnl_delete_link(vport->dev); | ||
189 | vport->dev = NULL; | ||
190 | rtnl_unlock(); | ||
191 | |||
192 | call_rcu(&vport->rcu, vport_netdev_free); | ||
193 | } | ||
194 | EXPORT_SYMBOL_GPL(ovs_netdev_tunnel_destroy); | ||
195 | |||
181 | static unsigned int packet_length(const struct sk_buff *skb) | 196 | static unsigned int packet_length(const struct sk_buff *skb) |
182 | { | 197 | { |
183 | unsigned int length = skb->len - ETH_HLEN; | 198 | unsigned int length = skb->len - ETH_HLEN; |
diff --git a/net/openvswitch/vport-netdev.h b/net/openvswitch/vport-netdev.h index 804412697a90..497cc81f1aca 100644 --- a/net/openvswitch/vport-netdev.h +++ b/net/openvswitch/vport-netdev.h | |||
@@ -29,9 +29,9 @@ struct vport *ovs_netdev_get_vport(struct net_device *dev); | |||
29 | struct vport *ovs_netdev_link(struct vport *vport, const char *name); | 29 | struct vport *ovs_netdev_link(struct vport *vport, const char *name); |
30 | int ovs_netdev_send(struct vport *vport, struct sk_buff *skb); | 30 | int ovs_netdev_send(struct vport *vport, struct sk_buff *skb); |
31 | void ovs_netdev_detach_dev(struct vport *); | 31 | void ovs_netdev_detach_dev(struct vport *); |
32 | void ovs_vport_free_rcu(struct rcu_head *); | ||
33 | 32 | ||
34 | int __init ovs_netdev_init(void); | 33 | int __init ovs_netdev_init(void); |
35 | void ovs_netdev_exit(void); | 34 | void ovs_netdev_exit(void); |
36 | 35 | ||
36 | void ovs_netdev_tunnel_destroy(struct vport *vport); | ||
37 | #endif /* vport_netdev.h */ | 37 | #endif /* vport_netdev.h */ |
diff --git a/net/openvswitch/vport-vxlan.c b/net/openvswitch/vport-vxlan.c index c6e937e36f8b..1e8b00a23a23 100644 --- a/net/openvswitch/vport-vxlan.c +++ b/net/openvswitch/vport-vxlan.c | |||
@@ -146,21 +146,6 @@ static struct vport *vxlan_create(const struct vport_parms *parms) | |||
146 | return ovs_netdev_link(vport, parms->name); | 146 | return ovs_netdev_link(vport, parms->name); |
147 | } | 147 | } |
148 | 148 | ||
149 | static void vxlan_destroy(struct vport *vport) | ||
150 | { | ||
151 | rtnl_lock(); | ||
152 | if (vport->dev->priv_flags & IFF_OVS_DATAPATH) | ||
153 | ovs_netdev_detach_dev(vport); | ||
154 | |||
155 | /* Early release so we can unregister the device */ | ||
156 | dev_put(vport->dev); | ||
157 | rtnl_delete_link(vport->dev); | ||
158 | vport->dev = NULL; | ||
159 | rtnl_unlock(); | ||
160 | |||
161 | call_rcu(&vport->rcu, ovs_vport_free_rcu); | ||
162 | } | ||
163 | |||
164 | static int vxlan_get_egress_tun_info(struct vport *vport, struct sk_buff *skb, | 149 | static int vxlan_get_egress_tun_info(struct vport *vport, struct sk_buff *skb, |
165 | struct ip_tunnel_info *egress_tun_info) | 150 | struct ip_tunnel_info *egress_tun_info) |
166 | { | 151 | { |
@@ -183,7 +168,7 @@ static int vxlan_get_egress_tun_info(struct vport *vport, struct sk_buff *skb, | |||
183 | static struct vport_ops ovs_vxlan_netdev_vport_ops = { | 168 | static struct vport_ops ovs_vxlan_netdev_vport_ops = { |
184 | .type = OVS_VPORT_TYPE_VXLAN, | 169 | .type = OVS_VPORT_TYPE_VXLAN, |
185 | .create = vxlan_create, | 170 | .create = vxlan_create, |
186 | .destroy = vxlan_destroy, | 171 | .destroy = ovs_netdev_tunnel_destroy, |
187 | .get_options = vxlan_get_options, | 172 | .get_options = vxlan_get_options, |
188 | .send = ovs_netdev_send, | 173 | .send = ovs_netdev_send, |
189 | .get_egress_tun_info = vxlan_get_egress_tun_info, | 174 | .get_egress_tun_info = vxlan_get_egress_tun_info, |