Skip to content

Commit a9020fd

Browse files
Pravin B Shelardavem330
authored andcommitted
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>
1 parent fb81139 commit a9020fd

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

net/openvswitch/vport-netdev.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,14 @@ static struct vport *netdev_create(const struct vport_parms *parms)
147147
return ovs_netdev_link(vport, parms->name);
148148
}
149149

150-
void ovs_vport_free_rcu(struct rcu_head *rcu)
150+
static void vport_netdev_free(struct rcu_head *rcu)
151151
{
152152
struct vport *vport = container_of(rcu, struct vport, rcu);
153153

154154
if (vport->dev)
155155
dev_put(vport->dev);
156156
ovs_vport_free(vport);
157157
}
158-
EXPORT_SYMBOL_GPL(ovs_vport_free_rcu);
159158

160159
void ovs_netdev_detach_dev(struct vport *vport)
161160
{
@@ -175,9 +174,25 @@ static void netdev_destroy(struct vport *vport)
175174
ovs_netdev_detach_dev(vport);
176175
rtnl_unlock();
177176

178-
call_rcu(&vport->rcu, ovs_vport_free_rcu);
177+
call_rcu(&vport->rcu, vport_netdev_free);
179178
}
180179

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+
181196
static unsigned int packet_length(const struct sk_buff *skb)
182197
{
183198
unsigned int length = skb->len - ETH_HLEN;

net/openvswitch/vport-netdev.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ struct vport *ovs_netdev_get_vport(struct net_device *dev);
2929
struct vport *ovs_netdev_link(struct vport *vport, const char *name);
3030
int ovs_netdev_send(struct vport *vport, struct sk_buff *skb);
3131
void ovs_netdev_detach_dev(struct vport *);
32-
void ovs_vport_free_rcu(struct rcu_head *);
3332

3433
int __init ovs_netdev_init(void);
3534
void ovs_netdev_exit(void);
3635

36+
void ovs_netdev_tunnel_destroy(struct vport *vport);
3737
#endif /* vport_netdev.h */

net/openvswitch/vport-vxlan.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,21 +146,6 @@ static struct vport *vxlan_create(const struct vport_parms *parms)
146146
return ovs_netdev_link(vport, parms->name);
147147
}
148148

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-
164149
static int vxlan_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,
165150
struct ip_tunnel_info *egress_tun_info)
166151
{
@@ -183,7 +168,7 @@ static int vxlan_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,
183168
static struct vport_ops ovs_vxlan_netdev_vport_ops = {
184169
.type = OVS_VPORT_TYPE_VXLAN,
185170
.create = vxlan_create,
186-
.destroy = vxlan_destroy,
171+
.destroy = ovs_netdev_tunnel_destroy,
187172
.get_options = vxlan_get_options,
188173
.send = ovs_netdev_send,
189174
.get_egress_tun_info = vxlan_get_egress_tun_info,

0 commit comments

Comments
 (0)