Re: [PATCH can-next v2 2/3] af_can: store socket pointers in struct netns_can
Marc Kleine-Budde <[email protected]>
| Newsgroups | org.kernel.vger.linux-can |
|---|---|
| Message-ID | <[email protected]> |
On 06.08.2026 15:14:14, Filippo Storniolo wrote: > AF_CAN sockets need to be stored in the netns_can structure > in order to be retrieved by the CAN diagnostic module when > a netlink request message is issued by the userspace. > > On socket creation (`can_create()`), add the pointer to the > new socket to `netns_can::sk_list`. During socket release > (`isotp_release()`, `raw_release()`, `j1939_release()`, > `bcm_release()`), remove the corresponding pointer from > this list. > > Since this is a prerequisite of the CAN diagnostic module, > deletes and insert operations are conditioned by > IS_ENABLED(CONFIG_CAN_DIAG). > > Signed-off-by: Filippo Storniolo <[email protected]> > --- > include/linux/can/core.h | 11 +++++++++++ > include/net/netns/can.h | 6 ++++++ > net/can/af_can.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ > net/can/bcm.c | 2 ++ > net/can/isotp.c | 2 ++ > net/can/j1939/socket.c | 2 ++ > net/can/raw.c | 2 ++ > 7 files changed, 75 insertions(+) > > diff --git a/include/linux/can/core.h b/include/linux/can/core.h > index 3287232e3cad..5132f5c89b7c 100644 > --- a/include/linux/can/core.h > +++ b/include/linux/can/core.h > @@ -61,4 +61,15 @@ extern int can_send(struct sk_buff *skb, int loop); > void can_set_skb_uid(struct sk_buff *skb); > void can_sock_destruct(struct sock *sk); > > +/* function prototypes for the CAN diag module */ > +#if IS_ENABLED(CONFIG_CAN_DIAG) > +void lock_can_diag_mutex(struct net *net); > +void unlock_can_diag_mutex(struct net *net); > +void can_add_sock_sklist(struct sock *sk); > +void can_remove_sock_sklist(struct sock *sk); > +#else > +#define can_add_sock_sklist(sk) > +#define can_remove_sock_sklist(sk) Please add static inline functions for these. > +#endif > + > #endif /* !_CAN_CORE_H */ > diff --git a/include/net/netns/can.h b/include/net/netns/can.h > index 48b79f7e6236..bcafff5e6669 100644 > --- a/include/net/netns/can.h > +++ b/include/net/netns/can.h > @@ -36,6 +36,12 @@ struct netns_can { > > /* CAN GW per-net gateway jobs */ > struct hlist_head cgw_list; > + > +#if IS_ENABLED(CONFIG_CAN_DIAG) > + /* CAN diag support */ > + struct mutex sklist_lock; > + struct hlist_head sklist; nitpick: Please indent with only 1 space as in the rest of this struct. regards, Marc -- Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
signature.asc
(application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQSl+MghEFFAdY3pYJLMOmT6rpmt0gUCanSXWAAKCRDMOmT6rpmt 0hQjAQCJhEjsuZcTcgzk5bRgS0V5eBRy+s9YDprESRz4MDnhygD9E2BdJA/IH9cl MAo6UndQ9CHuW26dAi3oKvFQ2AFhpAk= =qOvT -----END PGP SIGNATURE-----