Skip to content

Commit 10eef09

Browse files
Stanislav Fomichevkuba-moo
Stanislav Fomichev
authored andcommitted
net: add granular lock for the netdev netlink socket
As we move away from rtnl_lock for queue ops, introduce per-netdev_nl_sock lock. Signed-off-by: Stanislav Fomichev <[email protected]> Reviewed-by: Mina Almasry <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b6b6714 commit 10eef09

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

include/net/netdev_netlink.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <linux/list.h>
66

77
struct netdev_nl_sock {
8+
struct mutex lock;
89
struct list_head bindings;
910
};
1011

net/core/netdev-genl.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,7 @@ int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info)
859859
goto err_genlmsg_free;
860860
}
861861

862+
mutex_lock(&priv->lock);
862863
rtnl_lock();
863864

864865
netdev = __dev_get_by_index(genl_info_net(info), ifindex);
@@ -918,13 +919,15 @@ int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info)
918919
goto err_unbind;
919920

920921
rtnl_unlock();
922+
mutex_unlock(&priv->lock);
921923

922924
return 0;
923925

924926
err_unbind:
925927
net_devmem_unbind_dmabuf(binding);
926928
err_unlock:
927929
rtnl_unlock();
930+
mutex_unlock(&priv->lock);
928931
err_genlmsg_free:
929932
nlmsg_free(rsp);
930933
return err;
@@ -933,18 +936,21 @@ int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info)
933936
void netdev_nl_sock_priv_init(struct netdev_nl_sock *priv)
934937
{
935938
INIT_LIST_HEAD(&priv->bindings);
939+
mutex_init(&priv->lock);
936940
}
937941

938942
void netdev_nl_sock_priv_destroy(struct netdev_nl_sock *priv)
939943
{
940944
struct net_devmem_dmabuf_binding *binding;
941945
struct net_devmem_dmabuf_binding *temp;
942946

947+
mutex_lock(&priv->lock);
943948
list_for_each_entry_safe(binding, temp, &priv->bindings, list) {
944949
rtnl_lock();
945950
net_devmem_unbind_dmabuf(binding);
946951
rtnl_unlock();
947952
}
953+
mutex_unlock(&priv->lock);
948954
}
949955

950956
static int netdev_genl_netdevice_event(struct notifier_block *nb,

0 commit comments

Comments
 (0)