Commit 2f8914a
feat(mld): IPv6 multicast source-filter handler core (R4 P3)
Adds the 'mc6_*' reception-state machinery to the packet handler — the
IPv6 (MLDv2) analogue of the shipped IGMPv3 source-filter core, mirroring
the fully-evolved v4 machinery rather than the intermediate Phase-1 form.
New '_Ip6GroupMembership' (operator hold + token-keyed per-socket
'socket_filters' + 'contributors()'). The handler now keeps a materialized
'_ip6_multicast_filters: dict[Ip6Address, Ip6MulticastFilter]' as the
per-interface reception source of truth (including the permanent all-nodes
group ff02::1 and the solicited-node groups); '_ip6_multicast' becomes a
derived read-only property over its keys, so the RX accept / TX source /
MLD report paths are unchanged. '_ip6_multicast_refs' holds the
contributors; '_ip6_multicast_filter_for' merges them (RFC 3810 §4.2), or
returns the EXCLUDE{} any-source default for a directly-assigned group.
The six 'mc6_*' methods (mc6_is_joined / _mc6_recompute / mc6_ref_acquire
/ mc6_ref_release / mc6_set_socket_filter / mc6_clear_socket_filter) drive
the join / leave edge off the merged filter's reception state, exempting
the permanent all-nodes group ff02::1 (the v6 analogue of 224.0.0.1).
The IPv6 multicast reception state moved from '_lock__addr_config' to
'_lock__multicast' (one lock domain, matching v4), so
'L2/L3.assign/remove_ip6_multicast' now materialize the filter map under
'_lock__multicast' and the address-config callers take '_lock__addr_config'
THEN '_lock__multicast'. The move keeps '_mc6_recompute' (which holds the
multicast lock) from having to reach for the address-config lock on its
join edge — the no-GIL lock-ordering hazard the single-domain design
avoids.
P3 is behaviour-preserving: every contributor is still EXCLUDE{}
any-source, so the same MLD Reports fire on join / leave. The
'_mc6_recompute' mid-membership filter-delta branch is a '# P4:'
placeholder (current-state Report) until '_send_mld_state_change' emits
the MLDv2 ALLOW / BLOCK / CHANGE_TO_* source records. The socket
'MCAST_JOIN_SOURCE_GROUP' options (P2), the source-delta TX records (P4),
and the RX source-delivery gate (P5) land next; the RFC 3810 §4.2 / §5.2
adherence flip waits for those (as the v4 §3.2 flip waited for Phase 5).
Tests-first: 'test__icmp6__mld__source_filter_model.py' drives the model
end-to-end through the handler (materialization, derived view, INCLUDE
join, merge-holds-reception-until-last-ref, operator hold, all-nodes
exemption). The NetworkTestCase harness seeds '_ip6_multicast_filters'
(dict) instead of the list; the addr-config thread-safety test now tracks
'_lock__multicast'; the ICMPv6 RX/TX and ND-DAD tests seed the filter map
directly.
Lint clean, 13506 passing, 0 skipped.
Reference: RFC 3810 §4.2 (deriving per-interface state from per-socket state).
Reference: RFC 3810 §4.1 (per-socket filter mode + source list).
Reference: RFC 3810 §6 (the all-nodes group ff02::1 is never MLD-managed).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent dfcb0b4 commit 2f8914a
12 files changed
Lines changed: 657 additions & 76 deletions
File tree
- docs/refactor
- packages/pytcp/pytcp
- runtime/packet_handler
- tests
- integration/protocols
- icmp6
- nd
- ip6
- lib
- unit/stack
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
79 | 94 | | |
80 | 95 | | |
81 | 96 | | |
| |||
176 | 191 | | |
177 | 192 | | |
178 | 193 | | |
179 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
180 | 214 | | |
181 | 215 | | |
182 | 216 | | |
| |||
191 | 225 | | |
192 | 226 | | |
193 | 227 | | |
194 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
195 | 236 | | |
196 | 237 | | |
197 | | - | |
| 238 | + | |
198 | 239 | | |
199 | 240 | | |
200 | 241 | | |
| |||
0 commit comments