CM4: Cannot send on eth0 with raw socket specified with both PACKET_TX_RING and PACKET_RX_RING

Open
#5,612 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
28/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
c, linux, raspberry-pi, ubuntu

Research direction

Start by building and running the linked gist on the Raspberry Pi CM4, comparing the PACKET_RX_RING-only and combined PACKET_TX_RING/PACKET_RX_RING cases. Trace Linux raw packet socket handling for eth0 and identify why send() succeeds without transmitting; done means the Tx-MMAP case sends and receives correctly on the reported kernel while Tx-Send still passes.

Written by the indexing model from the issue text.

Description

Describe the bug

On a Raspberry Pi CM4, when a raw socket is opened on eth0 with both PACKET_TX_RING and PACKET_RX_RING options, it is possible to read incoming packets, but it is not possible to send packets. The send() return value does not indicate a problem, but a packet never goes out the physical port.

Steps to reproduce the behaviour

It's easiest to reproduce the bug when attempting to communicate to an EtherCAT device since it will send the packet back to the Raspberry Pi.

The application at this gist tests whether an ethernet port can correctly send and receive
data with both PACKET_TX_RING and PACKET_RX_RING enabled.

The application uses EtherCAT packets and is intended to communicate with an EtherCAT slave device
connected to the eth0 port. This core problem looks to be unrelated to the use of EtherCAT; it's just
that communicating with a single device that echos (or almost echos) data is easier to write a test for.

The test contains 2 sub-tests:
(1) Send and receive data using PACKET_RX_RING but without PACKET_TX_RING. (named 'Tx-Send' in the test output)
(2) Send and receive data using both PACKET_RX_RING and PACKET_TX_RING. (named 'Tx-MMAP' in the test output)

On x86-64 machines with Ubuntu 23.04, the test generates the following output

using interface: eth0
Rx [30]:
Rx [60]:
OK w/Tx-Send
Rx [30]:
Rx [60]:
OK w/Tx-MMAP

The above is the expected output.

On a Raspberry Pi CM4 with Ubuntu 23.04, the test generates the following output

using interface: eth0
Rx [30]:
Rx [60]:
OK w/Tx-Send
Rx [30]:
Failed w/Tx-MMAP

On some EtherCAT device, the first run of this program will result in data not being sent back correctly
reporting that both Tx-Send and Tx-MMAP failed. Subsequent runs do show that Tx-Send succeeds but that Tx-MMAP fails.

Device (s)

Raspberry Pi CM4

System

Ubuntu 23.04 Desktop

vcgencmd version reported VCHI initialization failed

Linux kevin-desktop 6.2.0-1013-raspi #15-Ubuntu SMP PREEMPT Fri Sept 8 18:53:11 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux

Logs

No response

Additional context

No response

Dominant language
C
Stars
13.2k
Forks
5.5k
Avg merge
2d 21h
Merged PRs (30d)
21

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from raspberrypi/linux

All issues in raspberrypi/linux

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.