F-Stack / f-stack

F-Stack is an user space network development kit with high performance based on DPDK, FreeBSD TCP/IP stack and coroutine API.
http://www.f-stack.org
Other
3.81k stars 890 forks source link

Padding bytes not removed from the ethernet frame #481

Open freak82 opened 4 years ago

freak82 commented 4 years ago

Hi there,

I'm playing with F-stack and DPDK. It seems to me that the DPDK driver (igb_uio) doesn't strip the ethernet padding bytes when they are present. The F-stack glue code also doesn't seem to strip them. As a result the FreeBSD stack "thinks" that it receives data and reports them to the application layer. Just for a context: The padding bytes are needed when the ethernet frame is smaller than 64 bytes (https://wiki.wireshark.org/Ethernet).

Here is an example which happens to me:

  1. I'm running F-stack epoll based server.
  2. The client is running on Linux machine but with all TCP options turned off. Most importantly the TCP timestamps are turned off. This important for the situation to be reproduced because this way the packets become with the smallest possible size.
  3. The clients sends request to the server and receives the response. So far so good. The size of the pure TCP ACK packets is smaller than the minumum ethernet size but due to the specific code in freebsd/netinet/tcp_input.c the padding bytes don't cause problems.
  4. However when the client closes the connection it sends FIN+ACK packet. This packet looks in the following way <Ethernet header 14 bytes><IP header 20 bytes><TCP header 20 bytes><Ethernet padding bytes 6 bytes> and the FreeBSD stack "sees" m->m_len equal to 6 bytes after all headers are stripped and appends these bytes as received data and reports them to the application layer.

I'm not sure where is the best place these bytes to be stripped. Probably somewhere in ff_dpdk_if.c or ff_veth.c before the packet is given to the FreeBSD stack. What do you think?

Regards, Pavel.

jfb8856606 commented 4 years ago

Got it, thanks for your detailed report. We will esearch it.