summaryrefslogtreecommitdiff
path: root/net/devlink/dev.c
diff options
context:
space:
mode:
authorJiri Pirko <jiri@nvidia.com>2023-09-13 09:12:38 +0200
committerDavid S. Miller <davem@davemloft.net>2023-09-17 14:01:47 +0100
commitc137743bce02b18c1537d4681aa515f7b80bf0a8 (patch)
treed0a623cd24c25f48e8d9b8b4c4387897aab29230 /net/devlink/dev.c
parent1c2197c47a93d0ea36e73e437271c7cbcc0e1ceb (diff)
devlink: introduce object and nested devlink relationship infra
It is a bit tricky to maintain relationship between devlink objects and nested devlink instances due to following aspects: 1) Locking. It is necessary to lock the devlink instance that contains the object first, only after that to lock the nested instance. 2) Lifetimes. Objects (e.g devlink port) may be removed before the nested devlink instance. 3) Notifications. If nested instance changes (e.g. gets registered/unregistered) the nested-in object needs to send appropriate notifications. Resolve this by introducing an xarray that holds 1:1 relationships between devlink object and related nested devlink instance. Use that xarray index to get the object/nested devlink instance on the other side. Provide necessary helpers: devlink_rel_nested_in_add/clear() to add and clear the relationship. devlink_rel_nested_in_notify() to call the nested-in object to send notifications during nested instance register/unregister/netns change. devlink_rel_devlink_handle_put() to be used by nested-in object fill function to fill the nested handle. Signed-off-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/devlink/dev.c')
-rw-r--r--net/devlink/dev.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/net/devlink/dev.c b/net/devlink/dev.c
index bba4ace7d22b..3ae26d9088ab 100644
--- a/net/devlink/dev.c
+++ b/net/devlink/dev.c
@@ -372,6 +372,7 @@ static void devlink_reload_netns_change(struct devlink *devlink,
devlink_notify_unregister(devlink);
write_pnet(&devlink->_net, dest_net);
devlink_notify_register(devlink);
+ devlink_rel_nested_in_notify(devlink);
}
int devlink_reload(struct devlink *devlink, struct net *dest_net,