[P1][bug] 같은 identity 재등록 시 UDP/TCP port reuse 또는 rollback 처리 #29

Closed
opened 2026-05-02 04:34:06 +00:00 by boxqkrtm · 1 comment

문제

LeaseRegistry::register()에서 기존 lease를 교체할 때 새 UDP/TCP port를 먼저 allocate하고 기존 record의 port는 나중에 release하는 구조로 보입니다.

관련 후보:

  • crates/portal-relay/src/relay/leases.rs
  • crates/portal-relay/src/relay/udp_datagram.rs
  • crates/portal-relay/src/relay/tcp_port.rs

영향

port range가 1개뿐이면 같은 identity가 재등록하더라도 기존 port가 아직 in_use 상태이므로 UdpPortExhausted 또는 TcpPortExhausted가 발생할 수 있습니다. runtime 생성 실패 시 state/port allocator rollback도 어려워집니다.

제안

  • 같은 identity 기존 record를 먼저 확인
  • 동일 transport/protocol이면 기존 port 재사용
  • 또는 old record를 임시 release한 뒤 새 runtime 생성 실패 시 rollback
  • port allocation과 lease state mutation을 transaction처럼 다루기

완료 기준

  • port range가 1개여도 같은 identity renew/re-register가 성공
  • 새 runtime 생성 실패 시 기존 lease/port state가 일관되게 유지
  • same identity UDP/TCP re-register 테스트 추가

검토 기준: 업로드된 Rust portal-relay 코드 정적 리뷰. 리뷰 환경에서는 cargo check/test/clippy를 실행하지 못했습니다.

## 문제 `LeaseRegistry::register()`에서 기존 lease를 교체할 때 새 UDP/TCP port를 먼저 allocate하고 기존 record의 port는 나중에 release하는 구조로 보입니다. 관련 후보: - `crates/portal-relay/src/relay/leases.rs` - `crates/portal-relay/src/relay/udp_datagram.rs` - `crates/portal-relay/src/relay/tcp_port.rs` ## 영향 port range가 1개뿐이면 같은 identity가 재등록하더라도 기존 port가 아직 `in_use` 상태이므로 `UdpPortExhausted` 또는 `TcpPortExhausted`가 발생할 수 있습니다. runtime 생성 실패 시 state/port allocator rollback도 어려워집니다. ## 제안 - 같은 identity 기존 record를 먼저 확인 - 동일 transport/protocol이면 기존 port 재사용 - 또는 old record를 임시 release한 뒤 새 runtime 생성 실패 시 rollback - port allocation과 lease state mutation을 transaction처럼 다루기 ## 완료 기준 - port range가 1개여도 같은 identity renew/re-register가 성공 - 새 runtime 생성 실패 시 기존 lease/port state가 일관되게 유지 - same identity UDP/TCP re-register 테스트 추가 --- 검토 기준: 업로드된 Rust `portal-relay` 코드 정적 리뷰. 리뷰 환경에서는 `cargo check/test/clippy`를 실행하지 못했습니다.
Owner

수용했습니다. PR #62에서 같은 identity 재등록 시 기존 UDP/TCP runtime/port를 재사용하고, 교체되는 stream/port는 필요한 경우에만 정리하도록 변경했습니다. 단일 port range에서도 동일 identity 갱신이 실패하지 않도록 했습니다. 검증: cargo test --locked, cargo clippy --locked --all-targets -- -D warnings.

수용했습니다. PR #62에서 같은 identity 재등록 시 기존 UDP/TCP runtime/port를 재사용하고, 교체되는 stream/port는 필요한 경우에만 정리하도록 변경했습니다. 단일 port range에서도 동일 identity 갱신이 실패하지 않도록 했습니다. 검증: cargo test --locked, cargo clippy --locked --all-targets -- -D warnings.
gofix closed this issue 2026-05-03 18:58:38 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
gofix/portal-tunnel-rs#29
No description provided.