NM creates new 'Wired Connection' when interface is already configured
On Fedora 33 / NM 1.26.6-1.fc33, I'm using dracut-sshd to ssh during early boot and unlock my luks partition, This means that when NetworkManager starts, the interface (ens3 here) is already up and with an ipv4 configured by dhcp. Because the interface is already configured, NM creates a new 'Wired Connection' instead of using the matching profile
# nmcli con
NAME UUID TYPE DEVICE
Wired Connection a62d588a-e48b-450c-b080-98d17a99b300 ethernet ens3
ens3 e8214164-be0c-4e5c-86af-83d0f7d93ab5 ethernet --
I've tried with configuration stored in keyfile or ifcfg, tried to install NetworkManager-config-server but NM always recreates a new 'Wired Connection' profile, which was pretty surprising to me.
The workaround I found for now is to unconfigure the interface before NM starts
# cat /etc/systemd/system/flush-ens3.service
[Unit]
Description=Flush ens3 to make NM happy
Before=network-pre.target
Wants=network-pre.target
[Service]
Type=oneshot
ExecStart=/usr/sbin/ip addr flush dev ens3
ExecStop=
[Install]
WantedBy=multi-user.target
Here the ens3 profile
# cat /etc/NetworkManager/system-connections/ens3.nmconnection
[connection]
id=ens3
uuid=SOMEUUID
type=ethernet
interface-name=ens3
permissions=
timestamp=1615928710
[ethernet]
mac-address-blacklist=
[ipv4]
dns-search=
method=auto
[ipv6]
addr-gen-mode=eui64
address1=MYIPv6/128,MYIPv6GW
dns-search=
method=manual
[proxy]
Should NetworkManager support such use case ? I'm asking because I'm not sure how complicated it is to unconfigure the interface when we are done in initramfs, and why unconfigure to reconfigure seconds after ;)
I can provide full trace logs / detailed repro steps if you feel it's needed