-
Notifications
You must be signed in to change notification settings - Fork 155
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
network: use pyroute2 to manage default routes #1569
network: use pyroute2 to manage default routes #1569
Conversation
c0297fa
to
9c185bd
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.
One more thing i think we should consider.
subiquitycore/controllers/network.py
Outdated
|
||
def _analyze_routes(self, routes): | ||
return any(route['table'] == 254 and not route['dst'] | ||
for route in routes) |
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 we should consider rejecting routes with metrics > 20000 here, to filter out connections that have not passed NM's connectivity check (unless there is a expectation that such routes might be created by some other mechanism? It seems very unlikely in the context of subiquity though?)
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 we should, yes. These high-metric routes can stick around. I think it sensible to filter them. Implemented.
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.
LGTM.
Can we reword the update_default_routes
function without breaking the world? It feels weird to me that it takes a boolean value.
9c185bd
to
e36fedd
Compare
Sure, we are already changing the type so I think changing the name is appropriate. Implemented. |
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 is pedantry to a possibly unhelpful level but this is a bit inconsistent about "has_default_route" vs "has_default_routes". Other than that it looks great!
The existing event based method of watching for has_network has a flaw. The incoming route_change events from probert do not distinguish routes on the same interface but a different metric, so if 2 routes on one interface appear, we only get one event. Then if one of those routes is removed, we will inappropriately remove this route from the default_routes list. Aside from the code watching the event stream, the set of default routes is an elaborate boolean value. Simplify the code by passing around a boolean, and when we get a route_change event, use that to go looking again at the list of default routes. LP: #2004659
Network manager can create routes at metric aka priority above 20000. These can stick around if they are not the best choice, or they may disappear quickly. Do not consider one of these routes as a valid default route for has_network purposes.
e36fedd
to
69bb830
Compare
@@ -246,8 +246,7 @@ async def apply_autoinstall_config(self, context): | |||
self.apply_config(context) | |||
with context.child("wait_for_apply"): | |||
await self.apply_config_task.wait() | |||
self.model.has_network = bool( | |||
self.network_event_receiver.default_routes) | |||
self.model.has_network = self.network_event_receiver.has_default_route |
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.
100% nothing to do with this branch but I think this line is pointless given that configured does the same and is called immediately after apply_autoinstall_config?
The existing event based method of watching for has_network has a flaw.
The incoming route_change events from probert do not distinguish routes on the same interface but a different metric, so if 2 routes on one interface appear, we only get one event. Then if one of those routes is removed, we will inappropriately remove this route from the default_routes list.
Aside from the code watching the event stream, the set of default routes is an elaborate boolean value.
Simplify the code by passing around a boolean, and when we get a route_change event, use that to go looking again at the list of default routes.
LP: #2004659