]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
geneve: rely on rtnl lock in geneve_offload_rx_ports
authorStanislav Fomichev <stfomichev@gmail.com>
Mon, 16 Jun 2025 16:21:12 +0000 (09:21 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 19 Jun 2025 01:53:51 +0000 (18:53 -0700)
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>
drivers/net/geneve.c

index f6bd155aae7fe839afb8cbea1ccc1a757315ae99..54384f9b387273af5ad3f5f9c9868d7f853d1797 100644 (file)
@@ -41,6 +41,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
 /* per-network namespace private data for this module */
 struct geneve_net {
        struct list_head        geneve_list;
+       /* sock_list is protected by rtnl lock */
        struct list_head        sock_list;
 };
 
@@ -1180,8 +1181,9 @@ static void geneve_offload_rx_ports(struct net_device *dev, bool push)
        struct geneve_net *gn = net_generic(net, geneve_net_id);
        struct geneve_sock *gs;
 
-       rcu_read_lock();
-       list_for_each_entry_rcu(gs, &gn->sock_list, list) {
+       ASSERT_RTNL();
+
+       list_for_each_entry(gs, &gn->sock_list, list) {
                if (push) {
                        udp_tunnel_push_rx_port(dev, gs->sock,
                                                UDP_TUNNEL_TYPE_GENEVE);
@@ -1190,7 +1192,6 @@ static void geneve_offload_rx_ports(struct net_device *dev, bool push)
                                                UDP_TUNNEL_TYPE_GENEVE);
                }
        }
-       rcu_read_unlock();
 }
 
 /* Initialize the device structure. */