On Thu, 15 Apr 2021 at 10:32, Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> wrote: > > On 14.04.2021 21:22:50, Erik Flodin wrote: > > I've been using a raw CAN socket with RECV_OWN_MSGS enabled to get a > > transmission confirmation when a frame has been sent. Today when I > > tried to enable filters to limit what I receive to only those frames > > that I'm interested in I noticed that the filters also affected > > reception of my own frames. So in order to receive all frames that I > > send I must also add a filter that matches all frames that I send. > > > > Is this the expected behavior? > > At least it's implemented this way. > > On TX complete of a CAN frame it's pushed into the RX path of the > networking stack, along with the information of the originating socket. > > Then the CAN frame is delivered into AF_CAN, where it is passed on to > all registered receivers depending on filters. One receiver is the > sending socket in CAN_RAW. Then in CAN_RAW the it is checked if the > sending socket has RECV_OWN_MSGS enabled. Thanks for the explanation. I've sent a patch to clarify in the documentation that the socket's own frames are also subject to filtering. > I don't think there's a way to do that without modifying the kernel > code. One option is to add a new sockopt RECV_OWN_MSGS_ALL or > RECV_OWN_MSGS_UNFILTERED. The CAN_RAW can then register another receiver > at AF_CAN for own messages only. I'll see if I can figure something out. Unless someone beats me to it :) // Erik