apply: bring "lo" back up if it's managed by NM (LP# 2034595)#408
apply: bring "lo" back up if it's managed by NM (LP# 2034595)#408slyon merged 2 commits intocanonical:mainfrom
Conversation
NM is not bringing it back automatically after we flush its addresses. It's not clear if it's a bug or intended behavior.
66cc492 to
d58570f
Compare
slyon
left a comment
There was a problem hiding this comment.
Thank you for the very clean reproducer!
I think this workaround is acceptable, but I'd like to give two additional ideas for consideration:
Instead of flushing the IPs, we could consider dropping just any additional IPs from the loopback interfaces (ip addr del), additional IPs being the ones which are not from the loopback range (127.0.0.0/8 and ::/128), or alternatively remember and add back IPs from that address range on the loopback interface manually (ip addr add ... dev lo) after flushing.
This is because when I install network-manager I cann see the loopback interface is managed externally (just tracked by NM) (nmcli d output):
lo loopback connected (externally) lo
After modifications through nmcli/netplan it's fully managed by NM:
lo loopback connected lo
When using nmcli con up lo it stays fully managed by NM:
lo loopback connected lo
When adding loopback IPs manually (ip addr add ...) it says externally managed:
lo loopback connected (externally) lo
The latter case resembles the initial scenario (without modification to that proflie) more closely, so maybe that's the cleaner alternative?
That being said, I think all solutions/workarounds will provide the desired outcome of lo being UP and having the relevant IPs assigned.
WDYT?
netplan_cli/cli/commands/apply.py
Outdated
| # connection with nmcli for example, NM will create a persistent nmconnection file and emit a YAML for it. | ||
| if 'lo' in nm_interfaces: | ||
| cmd = ['nmcli', 'con', 'up', 'lo'] | ||
| subprocess.call(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) |
There was a problem hiding this comment.
nitpick: We should consider using the utils.nmcli() helper here. Especially due to #336 (although, I think the implemented solution for PATH should work with the individual subprocess calls, too).
There was a problem hiding this comment.
utils.nmcli() calls check_call, which will throw an exception if nmcli fails for some reason, maybe we should use call to avoid breaking apply (or to avoid a try-except here...).
|
After some more digging, there are few more issues to consider: Consider this scenario:
The call to Skipping the So far the only two solutions I see are manually bringing lo back or don't disconnect it and don't remove the state file linked to |
|
While we don't find a better solution, I changed the patch to take into account cases where the loopback connection is not called "lo". In fact it can have any name. |
9321f4c to
4c2a877
Compare
It might have any name, so we need to get the connection name dynamically.
4c2a877 to
9228b67
Compare
|
I think this is a good workaround for the issue we face, so let's cherry-pick it into the package: https://salsa.debian.org/debian/netplan.io/-/commit/5b2eeb4 Still keeping it open here, waiting if we can get some input from NM upstream to see if this behavior is intentional or should rather be fixed in NetworkManager itself. |
|
Quoting We had the patch in Ubuntu Mantic & Noble and Debian testing & unstable since almost 3 months without any issues. Let's merge it. |
NM is not bringing it back automatically after we flush its addresses. It's not clear if it's a bug or intended behavior.
It's bad because we have services listening on the loopback interface, such as resolved.
How to reproduce:
nmcli con mod lo mtu 1500netplan applyAs an alternative (was my original patch) we could just stop flushing 'lo', but that might be what the user want to do, because they can add extra addresses to it for example.
This might actually be a bug in NM and if it's fixed in the future we could drop this change.
Description
Checklist
make checksuccessfully.make check-coverage).