Skip to content

IPv6 Gateway MAC Address Always Returns Zero on macOS #177

Description

@Sean-Bartie

Summary

On macOS, the netdev crate retrieves IPv6 gateway addresses correctly but always returns MacAddr(0,0,0,0,0,0) for the gateway's MAC address, even when the neighbor is actively resolved in the system's neighbor discovery (NDP) cache.

Environment

  • OS: macOS
  • netdev version: 0.45.0
  • Rust version: 1.82+

Expected Behavior

The gateway MAC address should be populated with the resolved neighbor's MAC address from the system's neighbor discovery table, matching what ndp -a reports.

Actual Behavior

The gateway MAC address is always MacAddr(0,0,0,0,0,0) regardless of whether the neighbor has been resolved.

Root Cause

The netdev crate queries the routing table for gateway information but does not query the neighbor discovery (NDP) cache. On macOS, the routing table contains gateway IP addresses but not their associated MAC addresses. The MAC addresses are maintained separately in the kernel's neighbor cache and are accessible via the ndp command-line tool.

Proposed Solution

Query the neighbor discovery (NDP) cache to populate the gateway MAC address using the same sysctl() mechanism used for IPv4 ARP queries. For NDP use the IPv6 address family (AF_INET6) instead of IPv4 address family (AF_INET).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions