-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make upnp lease duration configurable #868
base: main
Are you sure you want to change the base?
Conversation
366199d
to
0bb3037
Compare
@@ -36,7 +36,7 @@ const GET_INTERFACE_TIMEOUT_S: Duration = Duration::from_secs(2); | |||
|
|||
const EPHEMERAL_PORT_RANGE: std::ops::RangeInclusive<u16> = 49152..=65535; | |||
|
|||
const DEFAULT_LEASE_DURATION_S: u32 = 600; | |||
const LEASE_RENEWAL_LIMIT_S: u32 = 600; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this const controll, we have what we set as wanted, but i don't entirely get there this comes from.
At what poin we should update lease ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have FeaturesUPnP::lease_duration_s
which sets the actual lease duration for the UPnP port mappings. This LEASE_RENEWAL_LIMIT_S
is the value which when the lease duration falls below it, we should renew the mappings by sending a new mapping request to the UPnP device.
E.g: We set the mappings lease duration to 3600s, when we check the lease duration left - every upnp_interval tick time - and there's less than 600s left for them to expire, we simple renew the lease for another FeaturesUPnP::lease_duration_s
which is 3600s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking this better, maybe this const can be correlated with the FeaturesUPnP::lease_duration_s
, something like 1/5 of FeaturesUPnP::lease_duration_s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh, that was what i was thinking also, maybe min(1/10, 1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has to be higher than the tick time (upnp_interval
) though, otherwise it will get expired. I'll try to come up with something.
telio_log_info!("Error validating endpoint: {}", e); | ||
|
||
telio_log_info!("Deleting an old Upnp endpoint"); | ||
let detete = self.igd_gw.delete_endpoint_routes( | ||
telio_log_info!("Dropping Upnp endpoint"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- seems to me this should be
telio_log_error!
- is there a reason not to merge those two logs into one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- It was already
telio_log_info
and I've questioned myself the same, but when there's an error validating the endpoint I consider not critical enough to be an error regarding the library runtime, and it can be easily recovered from. - I think we can, it will just result in a somewhat long log. But I can merge it, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- in that case this sounds like it should be
telio_log_warn!
. - imo, lets merge it
) | ||
.await | ||
{ | ||
telio_log_info!("Error dropping Upnp endpoint: {}", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it should be an error log, not info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error could be simply the mappings that were already dropped by the UPnP device, as the comment above, I don't consider it worth to be logged as a error, as the runtime is not affected and the mappings won't exist anyway.
Let me know if you disagree, this is something I've also questined myself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, in that case it sounds like a telio_log_warn!
.
src/device.rs
Outdated
@@ -1352,6 +1352,7 @@ impl Runtime { | |||
|
|||
// Create Upnp Endpoint Provider | |||
let upnp_endpoint_provider = if has_provider(Upnp) { | |||
let direct_features = self.features.direct.clone().unwrap_or_default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is no need for direct_features
since direct
variable is already in scope here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, I missed that
In that case, when is the good time to review the commit history? |
I'd say after every issue is resolved and +2 acquired. Then commit history is cleaned and approval by the reviewers unlocked. |
I don't think we agreed to this way of working - I would like to see a clean git history (in the state you intend to merge it) before I add any points. |
I understand your POV. I propose once the review is done I would clean git history and then get the eventual reviewer points. |
19047e2
to
f8e2b04
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
it looks like the test is flaky, I have to investigate it and probably make some changes |
f8e2b04
to
a47c919
Compare
test is fixed, I've had to adjust endpoint time variables on the test itself. |
Problem
User is not able to set a custom UPnP lease duration.
Solution
This PR adds a UPnP telio feature with lease duration field.
☑️ Definition of Done checklist