From: Filippo Storniolo <fstornio@redhat.com>
To: Oliver Hartkopp <socketcan@hartkopp.net>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>,
Robin van der Gracht <robin@protonic.nl>,
Oleksij Rempel <o.rempel@pengutronix.de>,
kernel@pengutronix.de, "David S. Miller" <davem@davemloft.net>,
Urs Thuermann <urs.thuermann@volkswagen.de>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
linux-can@vger.kernel.org,
Stefano Garzarella <sgarzare@redhat.com>,
Radu Rendec <rrendec@redhat.com>,
Davide Caratti <dcaratti@redhat.com>
Subject: Re: [PATCH RFC can-next 3/3] can: add can diag interface
Date: Mon, 13 Apr 2026 20:04:49 +0200 [thread overview]
Message-ID: <ad0pIPrN77tBmXIr@storniolo-redhat> (raw)
In-Reply-To: <5e34096c-85af-4db3-a69e-cbbbc17068da@hartkopp.net>
On Wed, Apr 08, 2026 at 06:54:31PM +0200, Oliver Hartkopp wrote:
Hi Oliver,
>>>>+/* Response */
>>>>+struct can_diag_msg {
>>>>+ __u8 cdiag_family; /* AF_CAN */
>>>>+ __u8 cdiag_state;
>>>>+ __u16 cdiag_protocol;
>>>>+ __u16 cdiag_type;
>>>>+ __u16 pad16;
>>>>+ __u32 cdiag_ino;
>>>>+ canid_t cdiag_tx_id; /* meaningful only for ISO-TP */
>>>>+ canid_t cdiag_rx_id; /* meaningful only for ISO-TP */
>>>
>>>What about the J1939 addressing here which is part of the struct
>>>sockaddr_can too?
>>>
>>
>>Right, I missed this during implementation. I guess we can either
>>extend the structure so that it contains also the addressing
>>information of J1939 or add a new attribyte in the netlink message,
>>similar to what it has been done for the uid.
>>
>>IMHO, I think the second option is better, especially when
>>we dump information that are valid only for specific protocols.
>>Otherwise, we would have a bigger netlink message for every socket,
>>even if they do not need some fields.
>>
>>However, we can evaluate pros and cons and refine it.
>
>In sockaddr_can the ISO-TP and J1939 address information is placed in
>an union as they can not be valid at the same time and the
>cdiag_protocol also provides the information what kind of content we
>would have read, right?
>
Yes, you are right. To be more specific, my idea is to have the
can_diag_msg struct like the following:
/* Response */
struct can_diag_msg {
__u8 cdiag_family; /* AF_CAN */
__u8 cdiag_state;
__u16 cdiag_protocol;
__u16 cdiag_type;
__u16 pad16;
__u32 cdiag_ino;
__s32 cdiag_ifindex;
__u32 cdiag_cookie[2];
};
and then add the following structures in the uapi:
struct can_diag_isotp_id {
canid_t tx_id;
canid_t rx_id;
};
struct can_diag_j1939_id {
__u64 name;
__u32 pgn;
__u8 addr;
};
By defining two new attributes for j1939 and isotp,
we can fill the netlink response like this:
struct can_diag_isotp_id isotp_id;
isotp_id.tx_id = can_addr.can_addr.tp.tx_id;
isotp_id.rx_id = can_addr.can_addr.tp.rx_id;
rep->cdiag_rx_id = can_addr.can_addr.tp.rx_id;
if (sk->sk_protocol == CAN_ISOTP) {
nla_put(skb, CAN_DIAG_ISOTP_ID, sizeof(can_diag_isotp_id), &isotp_id);
}
and same for j1939.
This is useful because we don't have any un-needed fields
in the can_diag_msg structure, but we can still provide to the
userspace information relevant only for specific protocols.
Cheers,
Filippo
next prev parent reply other threads:[~2026-04-13 18:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2026-04-14 6:52 ` Oliver Hartkopp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ad0pIPrN77tBmXIr@storniolo-redhat \
--to=fstornio@redhat.com \
--cc=davem@davemloft.net \
--cc=dcaratti@redhat.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=o.rempel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=robin@protonic.nl \
--cc=rrendec@redhat.com \
--cc=sgarzare@redhat.com \
--cc=socketcan@hartkopp.net \
--cc=urs.thuermann@volkswagen.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox