Re: [patch net-next v4 5/9] genetlink: introduce per-sock family private pointer storage

Jakub Kicinski
2023-11-29T15:01:59Z

On Wed, 29 Nov 2023 14:59:31 +0100 Jiri Pirko wrote:
> Tue, Nov 28, 2023 at 05:36:05PM CET, kuba@kernel.org wrote:
> >No, you can do exact same thing, just instead of putting the string
> >directly into the xarray you put a struct which points to the string.
>
> I'm lost. What "string" are you talking about exactly? I'm not putting
> any string to xarray.
>
> In the existing implementation, I have following struct:
> struct devlink_obj_desc {
> struct rcu_head rcu;
> const char *bus_name;
> const char *dev_name;
> unsigned int port_index;
> bool port_index_valid;
> long data[];
> };
>
> This is the struct put pointer to into the xarray. Pointer to this
> struct is dereferenced under rcu in notification code and the struct
> is freed by kfree_rcu().

Sorry I was looking at patch 8 which has only:

+struct devlink_obj_desc {
+ struct rcu_head rcu;
+ const char *bus_name;
+ const char *dev_name;
+ long data[];
+};

that's basically a string and an rcu_head, that's what I meant.

> >Core still does the kfree of the container (struct devlink_sk_priv).
> >But what's inside the container struct (string pointer) has to be
> >handled by the destructor.
> >
> >Feels like you focus on how to prove me wrong more than on
> >understanding what I'm saying :|
>
> Not at all, I have no reason for it. I just want to get my job done
> and I am having very hard time to understand what you want exactly.

Sockets may want to hold state for more than filtering.
Try to look past your singular use case.