Skip to content

Commit eb88531

Browse files
vincent-mailholmarckleinebudde
authored andcommitted
can: raw: add missing error queue support
Error queue are not yet implemented in CAN-raw sockets. The problem: a userland call to recvmsg(soc, msg, MSG_ERRQUEUE) on a CAN-raw socket would unqueue messages from the normal queue without any kind of error or warning. As such, it prevented CAN drivers from using the functionalities that relies on the error queue such as skb_tx_timestamp(). SCM_CAN_RAW_ERRQUEUE is defined as the type for the CAN raw error queue. SCM stands for "Socket control messages". The name is inspired from SCM_J1939_ERRQUEUE of include/uapi/linux/can/j1939.h. Signed-off-by: Vincent Mailhol <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: Oliver Hartkopp <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent d61469d commit eb88531

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

include/uapi/linux/can/raw.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
#include <linux/can.h>
5050

5151
#define SOL_CAN_RAW (SOL_CAN_BASE + CAN_RAW)
52+
enum {
53+
SCM_CAN_RAW_ERRQUEUE = 1,
54+
};
5255

5356
/* for socket options affecting the socket (not the global system) */
5457

net/can/raw.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,10 @@ static int raw_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
804804
noblock = flags & MSG_DONTWAIT;
805805
flags &= ~MSG_DONTWAIT;
806806

807+
if (flags & MSG_ERRQUEUE)
808+
return sock_recv_errqueue(sk, msg, size,
809+
SOL_CAN_RAW, SCM_CAN_RAW_ERRQUEUE);
810+
807811
skb = skb_recv_datagram(sk, flags, noblock, &err);
808812
if (!skb)
809813
return err;

0 commit comments

Comments
 (0)