* Count dropped frames on CAN socket @ 2016-11-15 23:32 Austin Hendrix 2016-11-16 0:08 ` Brian Silverman 0 siblings, 1 reply; 4+ messages in thread From: Austin Hendrix @ 2016-11-15 23:32 UTC (permalink / raw) To: linux-can 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Count dropped frames on CAN socket 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 0 siblings, 1 reply; 4+ messages in thread From: Brian Silverman @ 2016-11-16 0:08 UTC (permalink / raw) To: Austin Hendrix; +Cc: linux-can 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Count dropped frames on CAN socket 2016-11-16 0:08 ` Brian Silverman @ 2016-11-16 9:57 ` Oliver Hartkopp 2016-11-16 17:13 ` Austin Hendrix 0 siblings, 1 reply; 4+ messages in thread From: Oliver Hartkopp @ 2016-11-16 9:57 UTC (permalink / raw) To: Brian Silverman, Austin Hendrix; +Cc: linux-can 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 > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Count dropped frames on CAN socket 2016-11-16 9:57 ` Oliver Hartkopp @ 2016-11-16 17:13 ` Austin Hendrix 0 siblings, 0 replies; 4+ messages in thread From: Austin Hendrix @ 2016-11-16 17:13 UTC (permalink / raw) To: Oliver Hartkopp, Brian Silverman; +Cc: linux-can 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 >> ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-11-16 17:14 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox