Re: autoconnect in Network manager



Thanks Jirka,

I used the command "nmcli -f all con list" to list all the saved connections.
I used nm-applet to connect to network A and then to network B. I get the following.

NAME   UUID   TYPE              TIMESTAMP    TIMESTAMP-REAL               AUTOCONNECT READONLY DBUS-PATH
Auto A   d***2   802-11-wireless 1291058354   Mon 29 Nov 2010 11:19:14 AM PST    yes           no               /org/freedesktop/NetworkManagerSettings/0
Auto B   3***9   802-11-wireless 1291058380   Mon 29 Nov 2010 11:19:40 AM PST    yes           no               /org/freedesktop/NetworkManagerSettings/1

The next time I restart nm-applet it automatically reconnects to network A and not to network B eventhough network B has latest timestamp. At first I though it was issue with my application, but nm-applet also behaves the same way. Is this a known issue?

Thanks,
Pan



On Thu, Nov 25, 2010 at 4:51 AM, Jirka Klimes <jklimes redhat com> wrote:
On Wednesday 24 of November 2010 03:57:09 pan son wrote:
> Hi,
>
> I am writing my own client to NetworkManager and wanted to know how
> NetworkManager selects a network to connect to.
>
> I am maintaining the connection parameters using gconf, and I see that the
> NetworkManager always connects to the very first network I connected to,
> even-though I am updating the connection for the connected AP, periodically
> same as nm-applet does.
>
> What prompts the NetworkManager to connect to the most recent network?
>
> Thanks,
> Pan

NetworkManager sorts the connection list according the timestamps and then
selects the first connection that matches the device (i.e. last used).
See connections_to_slist() and connection_sort() in src/nm-manager.c

activating:
-> src/nm-policy.c:auto_activate_device()
 -> src/nm-device.c:nm_device_get_best_auto_connection()
   -> get_best_auto_connection, which is src/nm-device-wifi.c:
real_get_best_auto_connection() (in case of wireless)

I suggest you check you've stored and updated timestamps correctly:
e.g.
$ nmcli -f all con list

Jirka



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]