Re: [TCP/IPv4] Sending out Ethernet packets appear to have issues


Paul Sokolovsky
 

Hello,

Well, so this turned out to be the same issue reported among the first
by Rohit. I either forgot details or mixed it up - I thought that if it
involved uIP context set to NULL, it would end in crash, but it indeed
actually picks up random memory value from an address like 0x4 to use
for MSS, etc. The fix is literally one-line, please review:
https://gerrit.zephyrproject.org/r/#/c/4888/


Thanks,
Paul


On Tue, 20 Sep 2016 01:03:42 +0300
Paul Sokolovsky <Paul.Sokolovsky(a)linaro.org> wrote:

Hello,

I'm continuing testing of Marcus Shawcroft's FRDM-K64F Ethernet
driver: https://gerrit.zephyrproject.org/r/#/c/4446 . Initial testing
using echo_server seems to be ok, but trying to initiate connection
from device has issues. Specifically, of "GET /foo HTTP/1.0\r\n\r\n"
request I use, only "GE" is being send out.

One thing I noticed is that eth_ksdk.c uses uip_len(buf) for packet
length, while net_driver_ethernet_send() which calls it, dumps
buf->len. Usage of uip_len(buf) comes from reference driver eth_dw.c
(I assume).

I dumped both lengths and here's how it looks:

net: net_driver_ethernet_send (0x200150d4): Sending 54 bytes
uip_len=44 Smashed net_buf with ARP request
net: net_driver_ethernet_send (0x200150d4): Really sending 54 bytes
eth: sending 42 bytes (buf->len=54)
net_context_tcp_init()=0
waiting to connect: -119
net: net_driver_ethernet_send (0x200178d4): Sending 54 bytes
uip_len=44 Didn't smash net_buf with ARP request
net: net_driver_ethernet_send (0x200178d4): Really sending 54 bytes
eth: sending 58 bytes (buf->len=54)
net: net_rx_fiber (0x200170d4): Received buf 0x20001bc0
s.write("GET /foo HTTP/1.0\r\n\r\n")
socket_write(2000d1d0, 2000d430, 21)
net: net_send (0x200150d4): context 0x2000c8b8 buf 0x20007304 status 0
net: net_tx_fiber (0x200174d4): Sending (buf 0x20007304, len 75) to
IP stack net: net_driver_ethernet_send (0x200174d4): Sending 75 bytes
uip_len=42 Didn't smash net_buf with ARP request
net: net_driver_ethernet_send (0x200174d4): Really sending 75 bytes
eth: sending 56 bytes (buf->len=75)

So, one can say that uip_len(buf) and buf->len isn't well
synchronized. With the last packet, which contains user data, if
buf->len was used, then all data probably would have been sent.
However before, there can be seen can when len->buf is 54, but
uip_len(58).

All that stuff works now pretty well with QEMU/SLIP. So, my plan is to
see what SLIP driver does and try to do the same. Of course, the issue
may be more complicated, like both Z and uIP trying to add Ethernet
header, in different combinations for different packet types.


--
Best Regards,
Paul

Linaro.org | Open source software for ARM SoCs
Follow Linaro: http://www.facebook.com/pages/Linaro
http://twitter.com/#!/linaroorg - http://www.linaro.org/linaro-blog

Join devel@lists.zephyrproject.org to automatically receive all group messages.