Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network module issue #208

Open
letkan opened this issue Jul 18, 2024 · 29 comments
Open

Network module issue #208

letkan opened this issue Jul 18, 2024 · 29 comments

Comments

@letkan
Copy link

letkan commented Jul 18, 2024

Arch Linux, Labwc, old Thinkpad.
Hi, when I first open the laptop the wifi icon is shown correctly, tooltip shows wifi info but after I close the lid and it goes to sleep and open it and it wakes up the icon is changed to wired network; tooltip shows no info although the laptop is reconnected to the internet. If I restart sfwbar after sleep the wifi icon/tooltip is back.

@LBCrion
Copy link
Owner

LBCrion commented Jul 19, 2024

What type of sleep mode does your laptop use? I.e. what do you have assigned to HandleLidSwitch in /etc/systemd/logind.conf (if you use systemd) and what does cat /proc/power/mem_sleep say?

Also, can you check if the following patch helps?

diff --git a/modules/network.c b/modules/network.c
index db89b20..1ba03be 100644
--- a/modules/network.c
+++ b/modules/network.c
@@ -314,7 +314,11 @@ static gboolean net_rt_parse (GIOChannel *chan, GIOCondition cond, gpointer d)
       if(ifmsg->ifi_change!=0)
         for(;rtl && RTA_OK(rta,rtl);rta=RTA_NEXT(rta,rtl))
           if(rta->rta_type==IFLA_WIRELESS)
+          {
             net_update_essid(if_indextoname(ifmsg->ifi_index,ifname));
+            g_main_context_invoke(NULL, (GSourceFunc)base_widget_emit_trigger,
+                (gpointer)g_intern_static_string("network"));
+          }
     }
     else if(hdr->nlmsg_type == RTM_NEWROUTE || hdr->nlmsg_type == RTM_DELROUTE)
     {

@letkan
Copy link
Author

letkan commented Jul 19, 2024

What type of sleep mode does your laptop use? I.e. what do you have assigned to HandleLidSwitch in /etc/systemd/logind.conf (if you use systemd)
HandleLidSwitch=suspend
and what does cat /proc/power/mem_sleep say?
cat: /proc/power/mem_sleep: No such file or directory

Also, can you check if the following patch helps?
I'll get back to you on this soon (I have to move from PC where I have account configured on github to laptop where I don't)

diff --git a/modules/network.c b/modules/network.c
index db89b20..1ba03be 100644
--- a/modules/network.c
+++ b/modules/network.c
@@ -314,7 +314,11 @@ static gboolean net_rt_parse (GIOChannel *chan, GIOCondition cond, gpointer d)
       if(ifmsg->ifi_change!=0)
         for(;rtl && RTA_OK(rta,rtl);rta=RTA_NEXT(rta,rtl))
           if(rta->rta_type==IFLA_WIRELESS)
+          {
             net_update_essid(if_indextoname(ifmsg->ifi_index,ifname));
+            g_main_context_invoke(NULL, (GSourceFunc)base_widget_emit_trigger,
+                (gpointer)g_intern_static_string("network"));
+          }
     }
     else if(hdr->nlmsg_type == RTM_NEWROUTE || hdr->nlmsg_type == RTM_DELROUTE)
     {

@letkan
Copy link
Author

letkan commented Jul 19, 2024

Sorry to say, the patch made no difference. Clicking the icon shows the correct info though.

@LBCrion
Copy link
Owner

LBCrion commented Jul 20, 2024

Clicking on the icon? This should popup the wifi window. Or do you mean the tooltip of the network widget contains the correct info?
If the tooltip contains the correct wifi network ESSID, but the icon remains that of a wired network, it's likely a trigger issue. If you can check that the tooltip contains the correct ESSID it would help a lot with debugging the issue.

@letkan
Copy link
Author

letkan commented Jul 20, 2024

Clicking means clicking, not hovering for tooltip. So, after opening the lid (back from sleep) when clicking the ethernet icon I get wifi window with the wifi networks which are correct. At the same time the tooltip has no info (ip address, etc.) as if I'm not connected to the internet.

I was wondering, is this issue specific to my setup, does this work properly for others?

1 similar comment
@letkan
Copy link
Author

letkan commented Jul 20, 2024

Clicking means clicking, not hovering for tooltip. So, after opening the lid (back from sleep) when clicking the ethernet icon I get wifi window with the wifi networks which are correct. At the same time the tooltip has no info (ip address, etc.) as if I'm not connected to the internet.

I was wondering, is this issue specific to my setup, does this work properly for others?

@letkan
Copy link
Author

letkan commented Jul 20, 2024

I just noticed that upon waking from sleep, on my PC which has exactly the same configuration with my laptop but is connected to ethernet, the tooltip info (ip address, interface, etc.) is blank, whereas before sleep it was populated.
If I restart sfwbar all is back to normal. I'm wondering if this is not a timing issue, if the reading of network state doesn't happen before it is available.

@LBCrion
Copy link
Owner

LBCrion commented Jul 20, 2024

Thank you, this is very useful! It looks like somewhere in the suspend/resume process netlink sends an RTM_DELADDR message for the interface containing the default gateway or an RTM_DELROUTE for the default gw. On resume it doesn't send RTM_NEWROUTE.

Can you try running the latest git version with sfwbar -d -g netinfo please?

@LBCrion
Copy link
Owner

LBCrion commented Jul 20, 2024

The wifi menu is handled by a different module than the network icon, so it's not surprising that it continues working. Also, on my machine, after resume from sleep, the icon does update to wifi, so I really would like to figure out what happens on your setup to see how we can fix it.

@letkan
Copy link
Author

letkan commented Jul 20, 2024 via email

@LBCrion
Copy link
Owner

LBCrion commented Jul 20, 2024 via email

@letkan
Copy link
Author

letkan commented Jul 20, 2024

The wifi menu is handled by a different module than the network icon, so it's not surprising that it continues working. Also, on my machine, after resume from sleep, the icon does update to wifi, so I really would like to figure out what happens on your setup to see how we can fix it.

Hey, I really appreciate you spend the time on this, my system is pretty much vanilla Arch Linux and a few changes to logind.conf for sleep via power button and lid, nothing fancy.

@letkan
Copy link
Author

letkan commented Jul 20, 2024 via email

@LBCrion
Copy link
Owner

LBCrion commented Jul 20, 2024

Interesting, that last route deletion message is odd. Would you mind updating to the latest git and running the same command again? I added a bit more routing info to the debug output.

@letkan
Copy link
Author

letkan commented Jul 20, 2024 via email

@letkan
Copy link
Author

letkan commented Jul 20, 2024 via email

@LBCrion
Copy link
Owner

LBCrion commented Jul 20, 2024

So, the above shows the information sfwbar gets from the kernel via a netlink interface. Going by the above, the default gateway is added to interface wlan0 and then deleted. The only way I can see this happening is if there is a secondary routing table in play here. Can I ask you to pull from git again and run the same command? (I added routing table ID to the debug output)

@letkan
Copy link
Author

letkan commented Jul 20, 2024 via email

@letkan
Copy link
Author

letkan commented Jul 20, 2024 via email

@LBCrion
Copy link
Owner

LBCrion commented Jul 20, 2024

Ok, I have a full picture now. Looks like we need to refcount the default gateway entry in the routing table. This may take me a bit of time, but I think I know what needs to be done.

@letkan
Copy link
Author

letkan commented Jul 20, 2024

Great. Just let me know when I can test it.

@LBCrion
Copy link
Owner

LBCrion commented Jul 20, 2024

I pushed a (somewhat naive) fix into git. Can you give it a try when you have a chance please?

@letkan
Copy link
Author

letkan commented Jul 20, 2024 via email

@LBCrion
Copy link
Owner

LBCrion commented Jul 20, 2024

Cool. Thank you for all the testing!

@letkan
Copy link
Author

letkan commented Jul 20, 2024 via email

@LBCrion
Copy link
Owner

LBCrion commented Jul 23, 2024

If you get a chance, can you try the latest git version please? This should contain a more proper fix. (the naive fix would report a stale default gateway in some cases).

@letkan
Copy link
Author

letkan commented Jul 23, 2024 via email

@LBCrion
Copy link
Owner

LBCrion commented Jul 23, 2024 via email

@letkan
Copy link
Author

letkan commented Jul 23, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants