Skip to content

Commit 544a773

Browse files
strssndktndavem330
authored andcommitted
vxlan: reduce usage of synchronize_net in ndo_stop
We only need to do the synchronize_net dance once for both, ipv4 and ipv6 sockets, thus removing one synchronize_net in case both sockets get dismantled. Signed-off-by: Hannes Frederic Sowa <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0412bd9 commit 544a773

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

drivers/net/vxlan.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,31 +1037,43 @@ static bool vxlan_group_used(struct vxlan_net *vn, struct vxlan_dev *dev)
10371037
return false;
10381038
}
10391039

1040-
static void __vxlan_sock_release(struct vxlan_sock *vs)
1040+
static bool __vxlan_sock_release_prep(struct vxlan_sock *vs)
10411041
{
10421042
struct vxlan_net *vn;
10431043

10441044
if (!vs)
1045-
return;
1045+
return false;
10461046
if (!atomic_dec_and_test(&vs->refcnt))
1047-
return;
1047+
return false;
10481048

10491049
vn = net_generic(sock_net(vs->sock->sk), vxlan_net_id);
10501050
spin_lock(&vn->sock_lock);
10511051
hlist_del_rcu(&vs->hlist);
10521052
vxlan_notify_del_rx_port(vs);
10531053
spin_unlock(&vn->sock_lock);
10541054

1055-
synchronize_net();
1056-
udp_tunnel_sock_release(vs->sock);
1057-
kfree(vs);
1055+
return true;
10581056
}
10591057

10601058
static void vxlan_sock_release(struct vxlan_dev *vxlan)
10611059
{
1062-
__vxlan_sock_release(vxlan->vn4_sock);
1060+
bool ipv4 = __vxlan_sock_release_prep(vxlan->vn4_sock);
10631061
#if IS_ENABLED(CONFIG_IPV6)
1064-
__vxlan_sock_release(vxlan->vn6_sock);
1062+
bool ipv6 = __vxlan_sock_release_prep(vxlan->vn6_sock);
1063+
#endif
1064+
1065+
synchronize_net();
1066+
1067+
if (ipv4) {
1068+
udp_tunnel_sock_release(vxlan->vn4_sock->sock);
1069+
kfree(vxlan->vn4_sock);
1070+
}
1071+
1072+
#if IS_ENABLED(CONFIG_IPV6)
1073+
if (ipv6) {
1074+
udp_tunnel_sock_release(vxlan->vn6_sock->sock);
1075+
kfree(vxlan->vn6_sock);
1076+
}
10651077
#endif
10661078
}
10671079

0 commit comments

Comments
 (0)