From: Austin Hendrix <namniart@gmail.com>
To: Oliver Hartkopp <socketcan@hartkopp.net>,
Brian Silverman <brian@peloton-tech.com>
Cc: linux-can@vger.kernel.org
Subject: Re: Count dropped frames on CAN socket
Date: Wed, 16 Nov 2016 09:13:59 -0800 [thread overview]
Message-ID: <deb20a42-ad75-18ea-f796-01bbd27c930f@gmail.com> (raw)
In-Reply-To: <ec9b7a5b-e587-ef2a-d3ab-47929795799e@hartkopp.net>
Awesome, that's exactly what I was looking for.
Thanks!
-Austin
On 11/16/2016 01:57 AM, Oliver Hartkopp wrote:
> And here is how the dropcount stuff has been integrated in candump:
>
> https://github.com/linux-can/can-utils/commit/3c019ea61169d7f08d10d1fece95433c629eb4a6
>
>
> Regards,
> Oliver
>
>
> On 11/16/2016 01:08 AM, Brian Silverman wrote:
>> Hi Austin,
>>
>> If you enable the (SOL_SOCKET, SO_RX_OVFL) option with setsockopt on a
>> CAN socket, you'll get a corresponding (cmsg_level == SOL_SOCKET,
>> cmsg_type == SO_RXQ_OVFL) piece of ancillary data from recvmsg. The
>> value is a uint32_t containing that exact sk_drops value. The
>> semantics for this value documented in socket(7) are wrong, but the
>> commit message adding it (3b885787ea41) gives a reasonable
>> description. In particular, the message doesn't show up at all until
>> at least one frame is dropped, and it's a total counter not a delta.
>>
>> Brian
>>
>> On Tue, Nov 15, 2016 at 6:32 PM, Austin Hendrix <namniart@gmail.com>
>> wrote:
>>> Hi linux-can,
>>>
>>> I'm writing a program which receives CAN frames over SocketCAN. I've
>>> found
>>> on a couple of occasions that my program has had bugs that cause it
>>> not to
>>> empty the CAN socket receive buffer, and the kernel has dropped
>>> incoming CAN
>>> frames.
>>>
>>> I had a look through the kernel source code, and found that the
>>> kernel's
>>> socket framework keeps track of dropped frames in the sk_drops field
>>> of the
>>> sock struct. Is there a way to retrieve that dropped frame counter
>>> from my
>>> program, so that it's easier for me to detect problems like this in the
>>> future? (I've looked in the docs and in /proc and haven't been able
>>> to find
>>> a way to retrieve the sk_drops counter, but it's quite possible that I
>>> missed something)
>>>
>>>
>>> Thanks,
>>>
>>> -Austin
>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-can" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-can" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
prev parent reply other threads:[~2016-11-16 17:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-15 23:32 Count dropped frames on CAN socket Austin Hendrix
2016-11-16 0:08 ` Brian Silverman
2016-11-16 9:57 ` Oliver Hartkopp
2016-11-16 17:13 ` Austin Hendrix [this message]
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=deb20a42-ad75-18ea-f796-01bbd27c930f@gmail.com \
--to=namniart@gmail.com \
--cc=brian@peloton-tech.com \
--cc=linux-can@vger.kernel.org \
--cc=socketcan@hartkopp.net \
/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