[PATCH] linux: check the prefix 'wlan' for WiFi device as the last fallback
https://bugzilla.gnome.org/show_bug.cgi?id=767317 Signed-off-by: Shih-Yuan Lee (FourDollars) --- src/platform/wifi/wifi-utils.c | 9 + 1 file changed, 9 insertions(+) diff --git a/src/platform/wifi/wifi-utils.c b/src/platform/wifi/wifi-utils.c index de858e4..95aae81 100644 --- a/src/platform/wifi/wifi-utils.c +++ b/src/platform/wifi/wifi-utils.c @@ -200,6 +200,15 @@ wifi_utils_is_wifi (const char *iface) return TRUE; #endif + /* The sysfs path may not exist due to race conditions while accessing sysfs. +* It's better to check the prefix 'wlan' as the last fallback method. +* +* For example, 'wlan0' has been renamed to 'wlp1s0', but it's still checking +* 'wlan0' above so it will always fail. +*/ + if (g_str_has_prefix (iface, "wlan")) + return TRUE; + return FALSE; } -- 2.7.4 ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
[PATCH] linux: check the prefix 'wlan' for WiFi device as the last fallback method
The sysfs path may not exist due to race conditions while accessing sysfs. It's better to check the prefix 'wlan' as the last fallback method. For example, 'wlan0' has been renamed to 'wlp1s0', but it's still checking 'wlan0' above so it will always fail. You can see this problem below. Nov 28 06:22:36 u-Precision-5520 kernel: ath10k_pci :01:00.0 wlp1s0: renamed from wlan0 Nov 28 06:22:36 u-Precision-5520 NetworkManager[772]: [1480332156.5568] platform-linux: event-notification: NEWLINK, seq 0: 2: wlan0 mtu 1500 arp 1 ethernet? not-init addrgenmode eui64 addr 40:49:0F:8A:E5:97 Nov 28 06:22:36 u-Precision-5520 NetworkManager[772]: [1480332156.5568] platform: signal: link added: 2: wlan0 mtu 1500 arp 1 ethernet? not-init addrgenmode eui64 addr 40:49:0F:8A:E5:97 driver unknown Nov 28 06:22:36 u-Precision-5520 NetworkManager[772]: [1480332156.5569] device (wlan0): failed to find device 2 'wlan0' with udev Nov 28 06:22:36 u-Precision-5520 NetworkManager[772]: [1480332156.5569] device (wlan0): driver '(null)' does not support carrier detection. Nov 28 06:22:36 u-Precision-5520 NetworkManager[772]: [1480332156.5569] device[0xab4b80] (wlan0): constructed (NMDeviceEthernet) Nov 28 06:22:36 u-Precision-5520 NetworkManager[772]: [1480332156.5569] device[0xab4b80] (wlan0): start setup of NMDeviceEthernet, kernel ifindex 2 Nov 28 06:22:36 u-Precision-5520 NetworkManager[772]: [1480332156.5570] platform-linux: error reading /sys/class/net/wlan0/phys_port_id: Failed to open file '/sys/class/net/wlan0/phys_port_id': No such file or directory Nov 28 06:22:36 u-Precision-5520 NetworkManager[772]: [1480332156.5570] platform-linux: error reading /sys/class/net/wlan0/dev_id: Failed to open file '/sys/class/net/wlan0/dev_id': No such file or directory After the device type is decided as NM_LINK_TYPE_ETHERNET, there is no way back unless NetworkManager will check all device types again, but it won't do that. Shih-Yuan Lee (FourDollars) (1): linux: check the prefix 'wlan' for WiFi device as the last fallback src/platform/wifi/wifi-utils.c | 9 + 1 file changed, 9 insertions(+) -- 2.7.4 ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
[PATCH] libnm: Warning if private data is NULL
Check the priv pointer before loop traverse. Warning this instead of leaving the program crash directly. --- libnm/nm-manager.c | 5 + 1 file changed, 5 insertions(+) diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c index a6c1f3f..7d86a51 100644 --- a/libnm/nm-manager.c +++ b/libnm/nm-manager.c @@ -816,6 +816,11 @@ recheck_pending_activations (NMManager *self) const GPtrArray *devices; NMDevice *device; + if (!priv) { + g_warning ("%s: private data should not be NULL", __func__); + return; + } + /* For each pending activation, look for an active connection that has the * pending activation's object path, where the active connection and its * device have both updated their properties to point to each other, and -- 2.7.4 ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
[PATCH] device: Remove unnecessary object reference operations
Since commit 0175056a6d70bafdaf1042eb8f5e1ef57484a3f2, it is unnecessary to operate object reference when invoking g_idle_add so it is unnecessary to operate object reference in GSourceFunc too. --- src/devices/nm-device.c | 5 - 1 file changed, 5 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index bf4b92d..8e15e1e 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -9096,9 +9096,7 @@ queued_ip4_config_change (gpointer user_data) return TRUE; priv->queued_ip4_config_id = 0; - g_object_ref (self); update_ip4_config (self, FALSE); - g_object_unref (self); set_unmanaged_external_down (self, TRUE); @@ -9122,7 +9120,6 @@ queued_ip6_config_change (gpointer user_data) return TRUE; priv->queued_ip6_config_id = 0; - g_object_ref (self); update_ip6_config (self, FALSE); if ( nm_platform_link_get (NM_PLATFORM_GET, priv->ifindex) @@ -9158,8 +9155,6 @@ queued_ip6_config_change (gpointer user_data) g_slist_free_full (priv->dad6_failed_addrs, g_free); priv->dad6_failed_addrs = NULL; - g_object_unref (self); - set_unmanaged_external_down (self, TRUE); return FALSE; -- 2.7.4 ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: [PATCH] libnm: Check the priv pointer before loop traverse.
On Thu, May 5, 2016 at 4:33 PM, Thomas Haller wrote: > On Wed, 2016-05-04 at 16:09 +0800, Shih-Yuan Lee (FourDollars) wrote: > > When we used WWAN and enabled the PIN on SIM, we encountered the > > following > > crash during the stress suspend&resume test. > > > > This patch can avoid this crash. > > > > GNU gdb (Ubuntu 7.11-0ubuntu1) 7.11 > > Copyright (C) 2016 Free Software Foundation, Inc. > > License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/g > > pl.html> > > This is free software: you are free to change and redistribute it. > > There is NO WARRANTY, to the extent permitted by law. Type "show > > copying" > > and "show warranty" for details. > > This GDB was configured as "x86_64-linux-gnu". > > Type "show configuration" for configuration details. > > For bug reporting instructions, please see: > > <http://www.gnu.org/software/gdb/bugs/>. > > Find the GDB manual and other documentation resources online at: > > <http://www.gnu.org/software/gdb/documentation/>. > > For help, type "help". > > Type "apropos word" to search for commands related to "word". > > Reading symbols from /usr/bin/nm-connection-editor...(no debugging > > symbols found)...done. > > warning: core file may not match specified executable file. > > [New LWP 1895] > > [New LWP 1896] > > [New LWP 1898] > > [New LWP 1897] > > [New LWP 1899] > > warning: Could not load shared library symbols for 2 libraries, e.g. > > /usr/lib/x86_64-linux-gnu/liblttng-ust-tracepoint.so.0. > > Use the "info sharedlibrary" command to see the complete listing. > > Do you need "set solib-search-path" or "set sysroot"? > > [Thread debugging using libthread_db enabled] > > Using host libthread_db library "/lib/x86_64-linux- > > gnu/libthread_db.so.1". > > Core was generated by `/usr/bin/nm-connection-editor'. > > Program terminated with signal SIGSEGV, Segmentation fault. > > #0 recheck_pending_activations (self=0x193d220) at nm-manager.c:824 > > warning: Source file is more recent than executable. > > 824 for (iter = priv->devices; iter; iter = iter- > > >next) { > > [Current thread is 1 (Thread 0x7f3c4197fa80 (LWP 1895))] > > (gdb) bt > > #0 recheck_pending_activations (self=0x193d220) at nm-manager.c:824 > > #1 0x7f3c400cbfa5 in g_closure_invoke () from /usr/lib/x86_64- > > linux-gnu/libgobject-2.0.so.0 > > #2 0x7f3c400ddfc1 in ?? () from /usr/lib/x86_64-linux- > > gnu/libgobject-2.0.so.0 > > #3 0x7f3c400e6d5c in g_signal_emit_valist () from > > /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 > > #4 0x7f3c400e708f in g_signal_emit () from /usr/lib/x86_64- > > linux-gnu/libgobject-2.0.so.0 > > #5 0x7f3c400d04d4 in ?? () from /usr/lib/x86_64-linux- > > gnu/libgobject-2.0.so.0 > > #6 0x7f3c400d2961 in g_object_notify () from /usr/lib/x86_64- > > linux-gnu/libgobject-2.0.so.0 > > #7 0x7f3c406e3e63 in deferred_notify_cb (data=) > > at nm-object.c:252 > > #8 0x7f3c3fdf4fda in g_main_context_dispatch () from > > /lib/x86_64-linux-gnu/libglib-2.0.so.0 > > #9 0x7f3c3fdf5380 in ?? () from /lib/x86_64-linux-gnu/libglib- > > 2.0.so.0 > > #10 0x7f3c3fdf56a2 in g_main_loop_run () from /lib/x86_64-linux- > > gnu/libglib-2.0.so.0 > > #11 0x00414e81 in main () > > (gdb) l > > 819 if (!nm_settings_get_startup_complete (priv- > > >settings)) { > > 820 _LOGD (LOGD_CORE, > > "check_if_startup_complete returns FALSE because of NMSettings"); > > 821 return; > > 822 } > > 823 > > 824 for (iter = priv->devices; iter; iter = iter- > > >next) { > > 825 NMDevice *dev = iter->data; > > 826 > > 827 if (nm_device_has_pending_action (dev)) { > > 828 _LOGD (LOGD_CORE, > > "check_if_startup_complete returns FALSE because of %s", > > (gdb) print priv > > $1 = (NMManagerPrivate *) 0x0 > > > > Shih-Yuan Lee (FourDollars) (1): > > libnm: Check the priv pointer before loop traverse. > > > > libnm/nm-manager.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > > Sidenote: > > The "l" command shows code from src/nm-manager.c:824, instead it should > show libnm/nm-manager.c:824. Something is wrong with the paths for the > source files and the debug information. > > Note that core daemon (src/nm-manager.c) does not ues libnm (libnm/nm- > manager.c). So, these two should not be in the same backtrace. > > Anyway, that is not really the issue here, just a bit confusing at > first. The backtrace is still helpful... > > > Thomas > Sorry, this is my fault. i didn't notice that I associated it with the wrong nm-manager.c. -- Shih-Yuan Lee (FourDollars) | Software Engineer | Commercial Engineering - PC & Core Taipei | Ubuntu Engineering and Services | Canonical ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: [PATCH] libnm: Check the priv pointer before loop traverse.
I see. Thx for your review. On Thu, May 5, 2016 at 4:11 PM, Thomas Haller wrote: > On Wed, 2016-05-04 at 16:09 +0800, Shih-Yuan Lee (FourDollars) wrote: > > --- > > libnm/nm-manager.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c > > index a6c1f3f..9316fdb 100644 > > --- a/libnm/nm-manager.c > > +++ b/libnm/nm-manager.c > > @@ -816,6 +816,8 @@ recheck_pending_activations (NMManager *self) > > const GPtrArray *devices; > > NMDevice *device; > > > > + g_return_if_fail (priv); > > + > > /* For each pending activation, look for an active > > connection that has the > >* pending activation's object path, where the active > > connection and its > >* device have both updated their properties to point to > > each other, and > > > Hi, > > > This patch is not correct for two reasons: > > - g_return_if_fail() and similar macros are assertions. They must never > be used for valid control flow. > > - @priv at this place can only be NULL/invalid, if @self was > NULL/invalid. From the backtrace you see, that @self is not NULL. You > canot inspect a dangling, invalid pointer to decide that it is invalid. > > The patch might accidentally avoid the crash, but it doesn't fix the > bug. > > > Thomas -- Shih-Yuan Lee (FourDollars) | Software Engineer | Commercial Engineering - PC & Core Taipei | Ubuntu Engineering and Services | Canonical ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
[PATCH] device: increase object ref count before invoking g_idle_add
--- src/devices/nm-device.c | 25 + 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index ad6f835..77f8874 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1990,8 +1990,8 @@ realize_start_setup (NMDevice *self, const NMPlatformLink *plink) } /* trigger initial ip config change to initialize ip-config */ - priv->queued_ip4_config_id = g_idle_add (queued_ip4_config_change, self); - priv->queued_ip6_config_id = g_idle_add (queued_ip6_config_change, self); + priv->queued_ip4_config_id = g_idle_add (queued_ip4_config_change, g_object_ref (self)); + priv->queued_ip6_config_id = g_idle_add (queued_ip6_config_change, g_object_ref (self)); nm_device_update_hw_address (self); nm_device_update_initial_hw_address (self); @@ -6982,6 +6982,7 @@ queued_ip4_config_change_clear (NMDevice *self) _LOGD (LOGD_DEVICE, "clearing queued IP4 config change"); g_source_remove (priv->queued_ip4_config_id); priv->queued_ip4_config_id = 0; + g_object_unref (self); } } @@ -6994,6 +6995,7 @@ queued_ip6_config_change_clear (NMDevice *self) _LOGD (LOGD_DEVICE, "clearing queued IP6 config change"); g_source_remove (priv->queued_ip6_config_id); priv->queued_ip6_config_id = 0; + g_object_unref (self); } } @@ -8942,7 +8944,11 @@ update_ip4_config (NMDevice *self, gboolean initial) if (activation_source_is_scheduled (self, activate_stage5_ip4_config_commit, AF_INET)) { - priv->queued_ip4_config_id = g_idle_add (queued_ip4_config_change, self); + if (priv->queued_ip4_config_id) { + g_source_remove (priv->queued_ip4_config_id); + g_object_unref (self); + } + priv->queued_ip4_config_id = g_idle_add (queued_ip4_config_change, g_object_ref (self)); _LOGT (LOGD_DEVICE, "IP4 update was postponed"); return; } @@ -9031,7 +9037,11 @@ update_ip6_config (NMDevice *self, gboolean initial) if (activation_source_is_scheduled (self, activate_stage5_ip6_config_commit, AF_INET6)) { - priv->queued_ip6_config_id = g_idle_add (queued_ip6_config_change, self); + if (priv->queued_ip6_config_id) { + g_source_remove (priv->queued_ip6_config_id); + g_object_unref (self); + } + priv->queued_ip6_config_id = g_idle_add (queued_ip6_config_change, g_object_ref (self)); _LOGT (LOGD_DEVICE, "IP6 update was postponed"); return; } @@ -9109,8 +9119,8 @@ queued_ip4_config_change (gpointer user_data) return TRUE; priv->queued_ip4_config_id = 0; - g_object_ref (self); update_ip4_config (self, FALSE); + g_object_unref (self); set_unmanaged_external_down (self, TRUE); @@ -9131,7 +9141,6 @@ queued_ip6_config_change (gpointer user_data) return TRUE; priv->queued_ip6_config_id = 0; - g_object_ref (self); update_ip6_config (self, FALSE); if ( nm_platform_link_get (NM_PLATFORM_GET, priv->ifindex) @@ -9194,7 +9203,7 @@ device_ipx_changed (NMPlatform *platform, case NMP_OBJECT_TYPE_IP4_ADDRESS: case NMP_OBJECT_TYPE_IP4_ROUTE: if (!priv->queued_ip4_config_id) { - priv->queued_ip4_config_id = g_idle_add (queued_ip4_config_change, self); + priv->queued_ip4_config_id = g_idle_add (queued_ip4_config_change, g_object_ref (self)); _LOGD (LOGD_DEVICE, "queued IP4 config change"); } break; @@ -9211,7 +9220,7 @@ device_ipx_changed (NMPlatform *platform, /* fallthrough */ case NMP_OBJECT_TYPE_IP6_ROUTE: if (!priv->queued_ip6_config_id) { - priv->queued_ip6_config_id = g_idle_add (queued_ip6_config_change, self); + priv->queued_ip6_config_id = g_idle_add (queued_ip6_config_change, g_object_ref (self)); _LOGD (LOGD_DEVICE, "queued IP6 config change"); } break; -- 2.7.4 ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
[PATCH] device: increase object ref count before invoking g_idle_add
04777e0 <+0>: push %rbx 0x004777e1 <+1>: mov %rdi,%rbx 0x004777e4 <+4>: callq 0x45fae0 0x004777e9 <+9>: mov%rbx,%rdi 0x004777ec <+12>:mov%rax,%rsi 0x004777ef <+15>:callq 0x43fc60 => 0x004777f4 <+20>:mov0x20(%rax),%rdx 0x004777f8 <+24>:mov0x1c(%rdx),%ecx 0x004777fb <+27>:test %ecx,%ecx 0x004777fd <+29>:je 0x477810 ... Shih-Yuan Lee (FourDollars) (1): device: increase object ref count before invoking g_idle_add src/devices/nm-device.c | 25 + 1 file changed, 17 insertions(+), 8 deletions(-) -- 2.7.4 ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
[PATCH] libnm: Check the priv pointer before loop traverse.
--- libnm/nm-manager.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c index a6c1f3f..9316fdb 100644 --- a/libnm/nm-manager.c +++ b/libnm/nm-manager.c @@ -816,6 +816,8 @@ recheck_pending_activations (NMManager *self) const GPtrArray *devices; NMDevice *device; + g_return_if_fail (priv); + /* For each pending activation, look for an active connection that has the * pending activation's object path, where the active connection and its * device have both updated their properties to point to each other, and -- 2.7.4 ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
[PATCH] libnm: Check the priv pointer before loop traverse.
When we used WWAN and enabled the PIN on SIM, we encountered the following crash during the stress suspend&resume test. This patch can avoid this crash. GNU gdb (Ubuntu 7.11-0ubuntu1) 7.11 Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word". Reading symbols from /usr/bin/nm-connection-editor...(no debugging symbols found)...done. warning: core file may not match specified executable file. [New LWP 1895] [New LWP 1896] [New LWP 1898] [New LWP 1897] [New LWP 1899] warning: Could not load shared library symbols for 2 libraries, e.g. /usr/lib/x86_64-linux-gnu/liblttng-ust-tracepoint.so.0. Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"? [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `/usr/bin/nm-connection-editor'. Program terminated with signal SIGSEGV, Segmentation fault. #0 recheck_pending_activations (self=0x193d220) at nm-manager.c:824 warning: Source file is more recent than executable. 824 for (iter = priv->devices; iter; iter = iter->next) { [Current thread is 1 (Thread 0x7f3c4197fa80 (LWP 1895))] (gdb) bt #0 recheck_pending_activations (self=0x193d220) at nm-manager.c:824 #1 0x7f3c400cbfa5 in g_closure_invoke () from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 #2 0x7f3c400ddfc1 in ?? () from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 #3 0x7f3c400e6d5c in g_signal_emit_valist () from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 #4 0x7f3c400e708f in g_signal_emit () from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 #5 0x7f3c400d04d4 in ?? () from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 #6 0x7f3c400d2961 in g_object_notify () from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 #7 0x7f3c406e3e63 in deferred_notify_cb (data=) at nm-object.c:252 #8 0x7f3c3fdf4fda in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #9 0x7f3c3fdf5380 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #10 0x7f3c3fdf56a2 in g_main_loop_run () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #11 0x00414e81 in main () (gdb) l 819 if (!nm_settings_get_startup_complete (priv->settings)) { 820 _LOGD (LOGD_CORE, "check_if_startup_complete returns FALSE because of NMSettings"); 821 return; 822 } 823 824 for (iter = priv->devices; iter; iter = iter->next) { 825 NMDevice *dev = iter->data; 826 827 if (nm_device_has_pending_action (dev)) { 828 _LOGD (LOGD_CORE, "check_if_startup_complete returns FALSE because of %s", (gdb) print priv $1 = (NMManagerPrivate *) 0x0 Shih-Yuan Lee (FourDollars) (1): libnm: Check the priv pointer before loop traverse. libnm/nm-manager.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.7.4 ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list