Skip to content

Conversation

@wrangelvid
Copy link
Contributor

Add the ability to register IP addresses with the router after Start() has been called.

For the vnet test in pion/webrtc#3323 we need to test gathering new ice candiates. We could do this by adding new interfaces on the fly, but I figured it might be easier to just change the address like dhcp.

@wrangelvid wrangelvid self-assigned this Dec 25, 2025
@wrangelvid wrangelvid requested a review from JoTurk December 25, 2025 23:40
@codecov
Copy link

codecov bot commented Dec 25, 2025

Codecov Report

❌ Patch coverage is 88.88889% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.34%. Comparing base (4f3e204) to head (37ee413).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
vnet/net.go 79.16% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #370      +/-   ##
==========================================
+ Coverage   84.28%   84.34%   +0.06%     
==========================================
  Files          41       41              
  Lines        3149     3194      +45     
==========================================
+ Hits         2654     2694      +40     
- Misses        356      359       +3     
- Partials      139      141       +2     
Flag Coverage Δ
go 84.34% <88.88%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

vnet/router.go Outdated
Comment on lines 383 to 393
func (r *Router) AddIPToNIC(nic NIC, ip net.IP) error {
r.mutex.Lock()
defer r.mutex.Unlock()

if !r.ipv4Net.Contains(ip) {
return fmt.Errorf("%w: %s", errStaticIPisBeyondSubnet, r.ipv4Net.String())
}
r.nics[ip.String()] = nic

return nil
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a useful feature to add. but i don't think router is the right layer, In vnet's design addresses belong to the interface/net and the router should drive that from that state.

We also need clear semantics around: collision/overwrite behavior, or whether move ip vs alias. Also should this be called before or after start? and how the state will update or state consistent.

I think it should be somewhere in interface, with add / remove API. and update the child routers somehow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point, just pushed a change that allows the addresses to be added through net which adds it to the nic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JoTurk Just following up. Anything else we need to do here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry i didn't notice that you updated the PR, i'll check when i wake up.

@wrangelvid wrangelvid changed the title Add Router.AddIPToNIC for dynamic IP registration Support dynamic IP registration Jan 1, 2026
Copy link
Member

@JoTurk JoTurk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

@JoTurk JoTurk mentioned this pull request Jan 8, 2026
@JoTurk JoTurk merged commit 37ee413 into pion:master Jan 8, 2026
34 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants