Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sockets: Fix IPv6 raw packet checksum in IPv6-only configuration #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Sep 30, 2024

  1. sockets: Fix IPv6 raw packet checksum in IPv6-only configuration

    Issue:
    In an IPv6-only setup, raw IPv6 packets were being sent with an incorrect checksum,
    whereas they worked correctly in a dual-stack configuration (both IPv4 and IPv6).
    
    Analysis:
    * The checksum is calculated in `raw.c` when the `pcb->chksum_reqd` flag is set.
    * This flag is enabled for all IPv6 raw pcbs in `api_msg.c`, but only when
      `NETCONNTYPE_ISIPV6(msg->conn->type)` evaluates to true.
    * The issue arises because the macro `NETCONNTYPE_ISIPV6()` checks if
      the `NETCONN_TYPE_IPV6` flag is set in the netconn type. This flag wasn’t being
      set when creating the socket, as the `DOMAIN_TO_NETCONN_TYPE()` macro returned
      the original type without adding the IPv6 flag.
    
    Fix:
    * Made enum netconn_type reflect protocol family also in IPv6-only configs,
    updating the macro DOMAIN_TO_NETCONN_TYPE() to set the NETCONN_TYPE_IPV6 flag.
    
    Alternative Approach:
    * Another potential solution would be to modify the `enum netconn_type` to reflect
    both the connection type and protocol family (as of now) in a dual-stack setup,
    while reflect connection type only in a single-stack setup (IPv4 only or
    IPv6 only)
    david-cermak committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    0d14a11 View commit details
    Browse the repository at this point in the history