public inbox for linux-can@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC can-next 0/3] Introduce diag support for CAN
@ 2026-04-02 10:54 Filippo Storniolo
  2026-04-02 10:54 ` [PATCH RFC can-next 1/3] af_can: ensure sk_protocol is always set on socket creation Filippo Storniolo
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Filippo Storniolo @ 2026-04-02 10:54 UTC (permalink / raw)
  To: Oliver Hartkopp, Marc Kleine-Budde, Robin van der Gracht,
	Oleksij Rempel, kernel, David S. Miller, Urs Thuermann,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman
  Cc: linux-can, Stefano Garzarella, Radu Rendec, Davide Caratti,
	Filippo Storniolo

In the current state of the art, it is not possible for userspace to use
tool like ss(8) to query open AF_CAN sockets.

This patch series adds the netlink can_diag interface for AF_CAN. Userspace
is  now able to send a netlink request to request information about open
AF_CAN sockets that are retrieved by the can-diag.ko module.

Patch 1 is a fix that is mandatory to the correct behaviour of the diag
module: the field sk_protocol is not assigned during `can_create()` instead
of being assigned only in case the CAN socket belong to the j1939 transport
protocol. This is needed to the correct filtering of the can diag module.

Patch 2 introduces a list per network namespace containing open CAN sockets.
The list is protected by a mutex.
CAN sockets are added in `can_create()` to the list and removed from it
in the `release()` calls defined for each transport protocol.

Patch 3 is the core patch that introduces the userspace structures to query
and receive netlink messages for CAN sockets and the actual CAN diag module.
The latter will use the userspace structures defined in <linux/can_diag.h>
to filter and retrieve open CAN sockets.

In the current implementation, every CAN sockets in the list is
returned to the userspace, however a filtering could be implemented:
Userspace could possibly request only bound CAN sockets or CAN sockets
belonging to a specific transport protocol (raw, iso-tp, j1939, bcm)
and so on.

Signed-off-by: Filippo Storniolo <fstornio@redhat.com>
---
Davide Caratti (1):
      af_can: ensure sk_protocol is always set on socket creation

Filippo Storniolo (2):
      af_can: store socket pointers in struct netns_can
      can: add can diag interface

 MAINTAINERS                   |   1 +
 include/linux/can/core.h      |   9 +++
 include/net/netns/can.h       |   6 ++
 include/uapi/linux/can_diag.h |  43 ++++++++++++
 net/can/Kconfig               |  10 +++
 net/can/Makefile              |   2 +
 net/can/af_can.c              |  38 +++++++++++
 net/can/bcm.c                 |   2 +
 net/can/can-diag.c            | 153 ++++++++++++++++++++++++++++++++++++++++++
 net/can/isotp.c               |   2 +
 net/can/j1939/socket.c        |   3 +-
 net/can/raw.c                 |   2 +
 12 files changed, 270 insertions(+), 1 deletion(-)
---
base-commit: f1359c240191e686614847905fc861cbda480b47
change-id: 20260401-feat-can-diag-b082b4f75b27

Best regards,
-- 
Filippo Storniolo <fstornio@redhat.com>


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-04-14  6:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-02 10:54 [PATCH RFC can-next 0/3] Introduce diag support for CAN Filippo Storniolo
2026-04-02 10:54 ` [PATCH RFC can-next 1/3] af_can: ensure sk_protocol is always set on socket creation Filippo Storniolo
2026-04-02 10:54 ` [PATCH RFC can-next 2/3] af_can: store socket pointers in struct netns_can Filippo Storniolo
2026-04-02 10:54 ` [PATCH RFC can-next 3/3] can: add can diag interface Filippo Storniolo
2026-04-02 13:07   ` Oliver Hartkopp
2026-04-02 16:24     ` Davide Caratti
2026-04-08 17:15       ` Oliver Hartkopp
2026-04-02 18:13     ` Filippo Storniolo
2026-04-08 16:54       ` Oliver Hartkopp
2026-04-13 18:04         ` Filippo Storniolo
2026-04-14  6:52           ` Oliver Hartkopp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox