From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Ico Doornekamp <ico@pruts.nl>
Cc: "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>
Subject: Re: CAN libpcap capture endianess
Date: Wed, 11 May 2016 10:17:13 +0200 [thread overview]
Message-ID: <5732EA89.5060303@hartkopp.net> (raw)
In-Reply-To: <1462952665-sup-1016@pruts.nl>
Hello Ico,
On 05/11/2016 09:48 AM, Ico Doornekamp wrote:
> * On 2016-05-11 09:40:41 +0200, Oliver Hartkopp wrote:
>
>> usually the CAN subsystem has no problems with host/network byte order:
>> The struct can_frame contains the CAN ID which is set into the CAN
>> controller registers inside the CAN driver.
>>
>> As wireshark uses the PF_PACKET socket to read the CAN frames it might
>> make assumptions about the byte order of read elements.
>>
>> Can you check the output from tst-packet on vcan0 / slcan0:
>>
>> ./tst-packet -i vcan0
>
> Yes, this gives the expected result for both vcan and slcan:
>
> $ sudo ./tst-packet
> 123 [4] 00 00 00 00
> 123 [4] 00 00 00 00
>
> Still it makes no sense to me that wireshark does seem to make a
> difference when sniffing on vcan and slcan:
That's strange indeed.
Both interfaces do not support IFF_ECHO (echo of sent CAN frames on
driver level) so both should trigger this shortcut in af_can.c:
http://lxr.free-electrons.com/source/net/can/af_can.c#L284
Can you send the output of
ip -details link show vcan0
ip -details link show slcan0
??
>
> 1 0.000000 -> CAN 12 STD: 0x00000123 00 00 00 00
> 1 0.000000 -> CAN 16 ERR: 0x03010000 00 00 00 00
At least the CAN ID is 'AND'ed with CAN_ERR_MASK 0x1FFFFFFF :-)
That's the reason for the missing '2' due to CAN_ERR_FLAG.
>
> I'll try to find the time to dig in the kernel and wireshark code to
> find out what causes the difference.
Btw, can you check if this patch fixes the issue:
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
index 9a3f15c..58ba098 100644
--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -202,16 +202,19 @@ static void slc_bump(struct slcan *sl)
}
}
- skb = dev_alloc_skb(sizeof(struct can_frame) +
- sizeof(struct can_skb_priv));
- if (!skb)
+ skb = netdev_alloc_skb(sl->dev, sizeof(struct can_skb_priv) +
+ sizeof(struct can_frame));
+ if (unlikely(!skb))
return;
- skb->dev = sl->dev;
skb->protocol = htons(ETH_P_CAN);
skb->pkt_type = PACKET_BROADCAST;
skb->ip_summed = CHECKSUM_UNNECESSARY;
+ skb_reset_mac_header(skb);
+ skb_reset_network_header(skb);
+ skb_reset_transport_header(skb);
+
can_skb_reserve(skb);
can_skb_prv(skb)->ifindex = sl->dev->ifindex;
can_skb_prv(skb)->skbcnt = 0;
I posted this patch in February 2015
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=969439016d2cf61fef53a973d7e6d2061c3793b1
and obviously forgot slcan.c ...
Thanks,
Oliver
next prev parent reply other threads:[~2016-05-11 8:17 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-11 17:42 CAN libpcap capture endianess Ico
2013-09-11 18:22 ` Marc Kleine-Budde
2013-09-11 18:30 ` Ico Doornekamp
2013-09-11 18:38 ` Marc Kleine-Budde
2013-09-11 18:53 ` Ico Doornekamp
2013-09-11 19:22 ` Oliver Hartkopp
2013-09-11 19:17 ` Oliver Hartkopp
2013-09-11 19:34 ` Marc Kleine-Budde
2013-09-11 19:37 ` Marc Kleine-Budde
2013-09-11 20:05 ` Ico Doornekamp
2013-09-11 20:11 ` Marc Kleine-Budde
2013-09-12 6:52 ` Ico Doornekamp
2013-09-12 8:00 ` Marc Kleine-Budde
2013-09-12 8:47 ` Ico Doornekamp
2013-09-12 8:52 ` Marc Kleine-Budde
2013-09-12 9:09 ` Ico Doornekamp
2013-09-12 9:13 ` Marc Kleine-Budde
2013-09-12 9:31 ` Ico Doornekamp
2016-05-10 19:25 ` Ico Doornekamp
2016-05-11 7:40 ` Oliver Hartkopp
[not found] ` <1462952665-sup-1016@pruts.nl>
2016-05-11 8:17 ` Oliver Hartkopp [this message]
2016-05-11 12:28 ` Ico Doornekamp
2016-05-11 13:25 ` Oliver Hartkopp
2016-05-11 17:01 ` Ico Doornekamp
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=5732EA89.5060303@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=ico@pruts.nl \
--cc=linux-can@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.