Skip to content

Commit

Permalink
can: raw: add missing error queue support
Browse files Browse the repository at this point in the history
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 <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/r/20200926162527.270030-1-mailhol.vincent@wanadoo.fr
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Vincent Mailhol authored and Marc Kleine-Budde committed Oct 6, 2020
1 parent d61469d commit eb88531
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/uapi/linux/can/raw.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
#include <linux/can.h>

#define SOL_CAN_RAW (SOL_CAN_BASE + CAN_RAW)
enum {
SCM_CAN_RAW_ERRQUEUE = 1,
};

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

Expand Down
4 changes: 4 additions & 0 deletions net/can/raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,10 @@ static int raw_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
noblock = flags & MSG_DONTWAIT;
flags &= ~MSG_DONTWAIT;

if (flags & MSG_ERRQUEUE)
return sock_recv_errqueue(sk, msg, size,
SOL_CAN_RAW, SCM_CAN_RAW_ERRQUEUE);

skb = skb_recv_datagram(sk, flags, noblock, &err);
if (!skb)
return err;
Expand Down

0 comments on commit eb88531

Please sign in to comment.