NetworkManager autoconnects to wired profiles in reverse order

Bug #1613729 reported by Simon Wydooghe
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
network-manager (Ubuntu)
Invalid
Undecided
Unassigned
Trusty
New
High
Unassigned

Bug Description

When I select a wired profile manually and reboot, NetworkManager instead connects to the profile that has the oldest timestamp. So it's not connecting to the last used profile, which is troublesome.

On all of our machines (about 500), we define three wired network profiles, one DHCP and two static. We're migrating from Debian to Ubuntu, so this bug has only surfaced now for us.

This can be reproduced by creating a couple of network profiles on the same wired interface and then rebooting or restarting network-manager. It will loop through the network profiles in the same order always. So it's doing the exact reverse of what's supposed to happen.

I did some digging and I applied a simple patch to the source code. This seems to have fixed the issue. I posted my patch for verification on the networkmanager mailing list and it was verified as being correct by Beniamino Galvani, one of the developers.

Here is the link to the network-manager topic: https://mail.gnome.org/archives/networkmanager-list/2016-August/msg00053.html

This is the patch (also included as attachment):

--- nm-device.c 2016-08-16 15:37:50.000000000 +0200
+++ nm-device_patched.c 2016-08-16 15:44:08.308729955 +0200
@@ -1267,7 +1267,7 @@
                s_con = nm_connection_get_setting_connection (connection);
                g_assert (s_con);
                if (nm_setting_connection_get_autoconnect (s_con))
- available_conns = g_slist_prepend (available_conns, connection);
+ available_conns = g_slist_append (available_conns, connection);
        }

        if (!available_conns)

I hope to get this patch included in the trusty package, so somebody else can benefit from this.

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: network-manager 0.9.8.8-0ubuntu7.3
ProcVersionSignature: Ubuntu 4.4.0-34.53~14.04.1-generic 4.4.15
Uname: Linux 4.4.0-34-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.21
Architecture: amd64
CRDA: Error: [Errno 2] Bestand of map bestaat niet: 'iw'
CurrentDesktop: Unity
Date: Tue Aug 16 15:23:17 2016
IfupdownConfig:
 auto lo
 iface lo inet loopback
IpRoute:
 default via 10.30.6.1 dev em1 proto static
 10.30.6.0/24 dev em1 proto kernel scope link src 10.30.6.204 metric 1
 10.40.8.0/21 dev tun0 proto kernel scope link src 10.40.8.31
IwConfig:
 tun0 no wireless extensions.

 em1 no wireless extensions.

 lo no wireless extensions.
NetworkManager.state:
 [main]
 NetworkingEnabled=true
 WirelessEnabled=true
 WWANEnabled=true
 WimaxEnabled=true
ProcEnviron:
 LANGUAGE=nl_BE:
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=nl_BE
 SHELL=/bin/bash
RfKill:

SourcePackage: network-manager
UpgradeStatus: No upgrade log present (probably fresh install)
WifiSyslog:

nmcli-con:
 NAME UUID TYPE TIMESTAMP TIMESTAMP-REAL AUTOCONNECT READONLY DBUS-PATH
 DHCP 702624f9-f052-473a-b131-acd2045e6ec2 802-3-ethernet 1471353746 di 16 aug 2016 15:22:26 CEST yes no /org/freedesktop/NetworkManager/Settings/1
 Proximus 7a9a5bc2-d51a-46b4-b721-050a607951bc 802-3-ethernet 1471353744 di 16 aug 2016 15:22:24 CEST yes no /org/freedesktop/NetworkManager/Settings/0
nmcli-dev:
 DEVICE TYPE STATE DBUS-PATH
 em1 802-3-ethernet connected /org/freedesktop/NetworkManager/Devices/0
nmcli-nm:
 RUNNING VERSION STATE NET-ENABLED WIFI-HARDWARE WIFI WWAN-HARDWARE WWAN
 running 0.9.8.8 connected enabled enabled enabled enabled disabled

Revision history for this message
Simon Wydooghe (wydooghe-simon) wrote :
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "Patch to fix this" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Brian Murray (brian-murray) wrote :

From what I can tell it looks like this patch is only needed for Trusty, Ubuntu 14.04. It'd be helpful if you could write a Test Case following the procedure documented at http://wiki.ubuntu.com/StableReleaseUpdates so that we know how to test the issue and fix. Thanks!

Changed in network-manager (Ubuntu Trusty):
importance: Undecided → High
Changed in network-manager (Ubuntu):
status: New → Invalid
Revision history for this message
Simon Wydooghe (wydooghe-simon) wrote :

Sure! I'll simply provide the NetworkManager connections as they are in use by us. So /etc/NetworkManager/system-connections should look like this:

root@id-00000015695:/etc/NetworkManager/system-connections# ls -l
totaal 12
-rw------- 1 root root 125 aug 11 11:28 dhcp
-rw------- 1 root root 191 aug 11 11:28 manual1
-rw------- 1 root root 194 aug 11 14:31 manual2

The 'dhcp' profile is a DHCP profile and 'manual1' and 'manual2' are both static profiles.

This is the 'dhcp' profile:

[connection]
id=DHCP
uuid=702624f9-f052-473a-b131-acd2045e6ec2
type=802-3-ethernet

[ipv4]
method=auto

[ipv6]
method=ignore

This is the 'manual1' profile:

[connection]
id=Manual1
uuid=e77a459e-6242-4e7d-ba95-371f27592526
type=802-3-ethernet

[ipv4]
method=manual
address1=10.45.67.5/24,10.45.76.1
dns=10.45.70.1;10.45.70.2;

[ipv6]
method=ignore

This is the 'manual2' profile:

[connection]
id=Manual2
uuid=7a9a5bc2-d51a-46b4-b721-050a607951bc
type=802-3-ethernet

[ipv4]
method=manual
address1=10.110.110.111/24,10.110.110.110
dns=8.8.8.8;8.8.4.4;

[ipv6]
method=ignore

Place all these profiles in system-connections. Select DHCP using NetworkManager. Then reboot or restart NetworkManager service. A different profile (manual1 or manual2) will be selected instead of dhcp. If you repeat this again, the last profile (the one which hasn't been selected yet) will be chosen. Another repeat will bring the selection back to DHCP. With every repeat it should continue in the same order, iterating through all three profiles.

Revision history for this message
Brian Murray (brian-murray) wrote :

Wow, I'm sorry I totally forget about this. Are you still interested in seeing this fixed in the Ubuntu archive?

Revision history for this message
Simon Wydooghe (wydooghe-simon) wrote :

I'm no longer working there so it's not very important to me anymore. I suppose if somebody still needed this fix they would have made a comment here by now... With 18.04 around the corner I imagine desktop usage of 14.04 isn't very applicable anymore.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.