haitomatic commented on PR #17161:
URL: https://github.com/apache/nuttx/pull/17161#issuecomment-3467690126
I converted to use net subsys loggers.
I also , i added some debug check for these 2 corrupted CAN IDs in the
upperhalf at
```
ros@haito-ThinkPad-P14s:/workspaces/ros2-devcontainer-vscode_driver_dev/src/nuttx$
diff drivers/net/netdev_upperhalf.c /workspaces/ros2-
devcontainer-vscode_driver_dev/src/px4-firmware/platforms/nuttx/Nutt
X/nuttx/drivers/net/netdev_upperhalf.c
151a152,178
> /* Debug: Check for corrupted CAN frames at upper half input */
> if (dev->d_lltype == NET_LL_CAN && pkt != NULL)
> {
> FAR struct can_frame *frame = (FAR struct can_frame *)IOB_DATA(pkt);
> if (frame != NULL && pkt->io_len >= sizeof(struct can_frame))
> {
> /* Check for specific corruption patterns */
> if (frame->can_id == 0x0 || frame->can_id == 0xC2008020)
> {
> printf("UPPER_HALF_CORRUPTION: Suspicious CAN ID detected:
0x%X, DLC: %d\n",
> frame->can_id, frame->can_dlc);
> }
>
> if (frame->can_dlc == 0 && frame->can_id != 0)
> {
> printf("UPPER_HALF_CORRUPTION: Zero DLC with non-zero ID:
0x%X\n", frame->can_id);
> }
>
> /* Check for general corruption indicators */
> if (frame->can_dlc > 8)
> {
> printf("UPPER_HALF_CORRUPTION: Invalid DLC: %d, ID: 0x%X\n",
> frame->can_dlc, frame->can_id);
> }
> }
> }
>
184a212,238
> /* Debug: Check for corrupted CAN frames being put into upper half */
> if (dev->d_lltype == NET_LL_CAN && pkt != NULL)
> {
> FAR struct can_frame *frame = (FAR struct can_frame *)IOB_DATA(pkt);
> if (frame != NULL && pkt->io_len >= sizeof(struct can_frame))
> {
> /* Check for specific corruption patterns */
> if (frame->can_id == 0x0 || frame->can_id == 0xC2008020)
> {
> printf("UPPER_HALF_PUT_CORRUPTION: Suspicious CAN ID
detected: 0x%X, DLC: %d\n",
> frame->can_id, frame->can_dlc);
> }
>
> if (frame->can_dlc == 0 && frame->can_id != 0)
> {
> printf("UPPER_HALF_PUT_CORRUPTION: Zero DLC with non-zero
ID: 0x%X\n", frame->can_id);
> }
>
> /* Check for general corruption indicators */
> if (frame->can_dlc > 8)
> {
> printf("UPPER_HALF_PUT_CORRUPTION: Invalid DLC: %d, ID:
0x%X\n",
> frame->can_dlc, frame->can_id);
> }
> }
> }
>
294a349,375
> /* Debug: Check for corrupted CAN frames before transmission */
> if (upper->lower->netdev.d_lltype == NET_LL_CAN && pkt != NULL)
> {
> FAR struct can_frame *frame = (FAR struct can_frame *)IOB_DATA(pkt);
> if (frame != NULL && pkt->io_len >= sizeof(struct can_frame))
> {
> /* Check for specific corruption patterns */
> if (frame->can_id == 0x0 || frame->can_id == 0xC2008020)
> {
> printf("UPPER_HALF_TX_CORRUPTION: Suspicious CAN ID before
TX: 0x%X, DLC: %d\n",
> frame->can_id, frame->can_dlc);
> }
>
> if (frame->can_dlc == 0 && frame->can_id != 0)
> {
> printf("UPPER_HALF_TX_CORRUPTION: Zero DLC with non-zero ID
before TX: 0x%X\n", frame->can_id);
> }
>
> /* Check for general corruption indicators */
> if (frame->can_dlc > 8)
> {
> printf("UPPER_HALF_TX_CORRUPTION: Invalid DLC before TX: %d,
ID: 0x%X\n",
> frame->can_dlc, frame->can_id);
> }
> }
> }
>
610a692,718
> /* Debug: Check for corrupted CAN frames immediately after receive
from lower half */
> if (dev->d_lltype == NET_LL_CAN && pkt != NULL)
> {
> FAR struct can_frame *frame = (FAR struct can_frame
*)IOB_DATA(pkt);
> if (frame != NULL && pkt->io_len >= sizeof(struct can_frame))
> {
> /* Check for specific corruption patterns */
> if (frame->can_id == 0x0 || frame->can_id == 0xC2008020)
> {
> printf("UPPER_HALF_RX_CORRUPTION: Suspicious CAN ID from
lower half: 0x%X, DLC: %d\n",
> frame->can_id, frame->can_dlc);
> }
>
> if (frame->can_dlc == 0 && frame->can_id != 0)
> {
> printf("UPPER_HALF_RX_CORRUPTION: Zero DLC with non-zero
ID from lower half: 0x%X\n", frame->can_id);
> }
>
> /* Check for general corruption indicators */
> if (frame->can_dlc > 8)
> {
> printf("UPPER_HALF_RX_CORRUPTION: Invalid DLC from lower
half: %d, ID: 0x%X\n",
> frame->can_dlc, frame->can_id);
> }
> }
> }
>
1403a1512,1514
>
> /* Clear the buffer to help detect corruption */
> memset(pkt->io_data, 0, CONFIG_IOB_BUFSIZE);
```
And the result indicate that the pkt at `pkt = netpkt_get(dev, NETPKT_TX);`
is already corrupted
```
saluki> cansend can1 123#deadbeef
UPPER_HALF_CORRUPTION: Suspicious CAN ID detected: 0x0, DLC: 0
UPPER_HALF_TX_CORRUPTION: Suspicious CAN ID before TX: 0x0, DLC: 0
TX Frame: ID=0x0, DLC=0
saluki> cansend can1 123#deadbeef
TX Frame: ID=0x123, DLC=4
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]