Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

geneve: rely on rtnl lock in geneve_offload_rx_ports

udp_tunnel_push_rx_port will grab mutex in the next patch so
we can't use rcu. geneve_offload_rx_ports is called
from geneve_netdevice_event for NETDEV_UDP_TUNNEL_PUSH_INFO and
NETDEV_UDP_TUNNEL_DROP_INFO which both have ASSERT_RTNL.
Entries are added to and removed from the sock_list under rtnl
lock as well (when adding or removing a tunneling device).

Signed-off-by: Stanislav Fomichev <stfomichev@gmail.com>
Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://patch.msgid.link/20250616162117.287806-2-stfomichev@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Stanislav Fomichev and committed by
Jakub Kicinski
3e14960f a3355694

+4 -3
+4 -3
drivers/net/geneve.c
··· 41 41 /* per-network namespace private data for this module */ 42 42 struct geneve_net { 43 43 struct list_head geneve_list; 44 + /* sock_list is protected by rtnl lock */ 44 45 struct list_head sock_list; 45 46 }; 46 47 ··· 1181 1180 struct geneve_net *gn = net_generic(net, geneve_net_id); 1182 1181 struct geneve_sock *gs; 1183 1182 1184 - rcu_read_lock(); 1185 - list_for_each_entry_rcu(gs, &gn->sock_list, list) { 1183 + ASSERT_RTNL(); 1184 + 1185 + list_for_each_entry(gs, &gn->sock_list, list) { 1186 1186 if (push) { 1187 1187 udp_tunnel_push_rx_port(dev, gs->sock, 1188 1188 UDP_TUNNEL_TYPE_GENEVE); ··· 1192 1190 UDP_TUNNEL_TYPE_GENEVE); 1193 1191 } 1194 1192 } 1195 - rcu_read_unlock(); 1196 1193 } 1197 1194 1198 1195 /* Initialize the device structure. */