Skip to content

IPv6 scope ids and IPV6_PKTINFO ifindex survive interface slot reuse #51

Closed

Description

@tinic

Same stale-slot pattern as #42. IPv6 scope ids and the sticky IPV6_PKTINFO ifindex are stored as raw slot+1 at connect/bind/setsockopt (src/bsdsocket/socket.c:1440, :1451, :2432, :2455, :2506; src/bsdsocket/cmsg.c:641) and re-checked on each send only against nx_interface_valid (socket.c:2040-2066, cmsg.c:474-478); receive filtering compares the number only (src/bsdsocket/transfer.c:993-999).

Repro: UDP socket connect()s to fe80::1%k (or sets sticky IPV6_PKTINFO{ifindex=k}); RemoveNetInterface k; AddNetInterface another device into slot k; send() leaves by the new link to its fe80::1, and that router's datagrams are accepted. Expected: EADDRNOTAVAIL / ENETUNREACH.

Also, low: an IPv4 per-datagram IP_PKTINFO ifindex naming an empty slot is returned without a validity check (cmsg.c:515-521); the datagram is dropped later instead of failing with EADDRNOTAVAIL.

Fix after #48 lands: record netstack_interface_epoch() with the stored index and treat a changed epoch as gone. Test: emulator run modelled on run-mcastepoch.sh expecting the error after slot reuse.

🤖 Generated with Claude Code

Activity

  1. tinic commented on Sep 26, 2026

    @tinic
    OwnerAuthor

    Follow-up on main a213cfc: the connected peer's zone was still read before the NetX bracket in send/sendto/sendmsg, so a slot removed and reattached in that window was missed. It is now resolved inside the bracket, and the connected address, port and zone are copied together there (dfb64a3, 5d67ec9; tests 84b558f, d1d70cd, covering UDP and raw with a peer change during the allocate wait). The host32 test_transfer/test_cork link break from #83 is fixed in the same branch. CI 36241074109 green.

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

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