Skip to content

Add common packet filtering and use it in the STM32 interface - #1366

Open
HTRamsey wants to merge 2 commits into
FreeRTOS:mainfrom
HTRamsey:feat/common-packet-filter
Open

HTRamsey wants to merge 2 commits into
FreeRTOS:mainfrom
HTRamsey:feat/common-packet-filter

Conversation

@HTRamsey

@HTRamsey HTRamsey commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Description

When ipconfigETHERNET_DRIVER_FILTERS_PACKETS is enabled, network drivers must perform IP admission checks before handing packets to the IP task. The STM32 interface currently contains an unimplemented packet-filter hook.

Add eConsiderPacketForProcessing() to validate received descriptors and dispatch shared IPv4/IPv6 header and address checks. Extract those rules from the existing IP-task paths so fixes apply consistently to both filtering configurations, while preserving their existing loopback behavior. Checksum and transport processing remain in their existing paths.

Update STM32 to call the helper after the completed descriptor has its received length and matching endpoint. Remove its placeholder protocol checks, require fixed protocol headers before endpoint lookup, and avoid posting an empty RX event when every packet in a batch is rejected.

Test Steps

  • Added dispatcher unit tests for invalid descriptors, truncated headers, address-family mismatches, ARP/custom frames, and IPv4/IPv6 policy delegation.
  • Passed six unit suites: FreeRTOS_IP_DiffConfig3, FreeRTOS_IPv4, FreeRTOS_IPv4_DiffConfig, FreeRTOS_IPv4_DiffConfig1, FreeRTOS_IPv6, and FreeRTOS_IPv6_ConfigDriverCheckChecksum.
  • Passed eight CMake build configurations: ENABLE_ALL, ENABLE_ALL_IPV4, ENABLE_ALL_IPV6, ENABLE_ALL_IPV4_TCP, ENABLE_ALL_IPV6_TCP, ENABLE_ALL_IPV4_IPV6, DISABLE_ALL, and DEFAULT_CONF, using the host loopback interface.
  • Compiled STM32 F4/F7/H5/H7 receive integration with packet filtering and linked RX messages independently enabled/disabled (16 combinations). Existing unused-parameter/variable warnings were suppressed.
  • Supplemental temporary host checks passed RX callback/input ordering, rejected-buffer release, empty-batch handling, and minimum header lengths in all four filtering/linked-RX configurations.
  • git diff --check passed. STM32 hardware validation was not performed.

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

No linked issue.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Add eConsiderPacketForProcessing and share IPv4/IPv6 admission rules with IP-task processing while preserving existing loopback behavior. Document the driver helper and cover framing, endpoint selection, and policy delegation in unit tests.
Filter completed RX descriptors after assigning their matching endpoint. Replace placeholder protocol checks, validate fixed header lengths before endpoint lookup, and avoid empty events when all received packets are rejected.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant