Skip to content

Commit 5533e5d

Browse files
strssndktnBrian Maly
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. Orabug: 29755932 Signed-off-by: Hannes Frederic Sowa <[email protected]> Signed-off-by: David S. Miller <[email protected]> (cherry picked from commit 544a773) Reviewed-by: Rama Nichanamatlu <[email protected]> Signed-off-by: Venkat Venkatsubra <[email protected]> Signed-off-by: Brian Maly <[email protected]>
1 parent 5928f9d commit 5533e5d

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
@@ -1025,31 +1025,43 @@ static bool vxlan_group_used(struct vxlan_net *vn, struct vxlan_dev *dev)
10251025
return false;
10261026
}
10271027

1028-
static void __vxlan_sock_release(struct vxlan_sock *vs)
1028+
static bool __vxlan_sock_release_prep(struct vxlan_sock *vs)
10291029
{
10301030
struct vxlan_net *vn;
10311031

10321032
if (!vs)
1033-
return;
1033+
return false;
10341034
if (!atomic_dec_and_test(&vs->refcnt))
1035-
return;
1035+
return false;
10361036

10371037
vn = net_generic(sock_net(vs->sock->sk), vxlan_net_id);
10381038
spin_lock(&vn->sock_lock);
10391039
hlist_del_rcu(&vs->hlist);
10401040
vxlan_notify_del_rx_port(vs);
10411041
spin_unlock(&vn->sock_lock);
10421042

1043-
synchronize_net();
1044-
udp_tunnel_sock_release(vs->sock);
1045-
kfree(vs);
1043+
return true;
10461044
}
10471045

10481046
static void vxlan_sock_release(struct vxlan_dev *vxlan)
10491047
{
1050-
__vxlan_sock_release(vxlan->vn4_sock);
1048+
bool ipv4 = __vxlan_sock_release_prep(vxlan->vn4_sock);
1049+
#if IS_ENABLED(CONFIG_IPV6)
1050+
bool ipv6 = __vxlan_sock_release_prep(vxlan->vn6_sock);
1051+
#endif
1052+
1053+
synchronize_net();
1054+
1055+
if (ipv4) {
1056+
udp_tunnel_sock_release(vxlan->vn4_sock->sock);
1057+
kfree(vxlan->vn4_sock);
1058+
}
1059+
10511060
#if IS_ENABLED(CONFIG_IPV6)
1052-
__vxlan_sock_release(vxlan->vn6_sock);
1061+
if (ipv6) {
1062+
udp_tunnel_sock_release(vxlan->vn6_sock->sock);
1063+
kfree(vxlan->vn6_sock);
1064+
}
10531065
#endif
10541066
}
10551067

0 commit comments

Comments
 (0)