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

error in main loop #45

Closed
mrplumber opened this issue Jun 6, 2020 · 3 comments
Closed

error in main loop #45

mrplumber opened this issue Jun 6, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@mrplumber
Copy link

Hi, using latest git version (0.6) of wsdd, I'm getting errors (see below, please) although it still works.

# uname -a
Linux geras 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2 (2020-04-29) x86_64 GNU/Linux
# cat /etc/debian_version
10.4
# /usr/local/bin/wsdd --verbose --interface br0 --chroot /run/wsdd/chroot/ -u nobody:nogroup
2020-06-06 18:47:09,950:wsdd INFO(pid 9265): using pre-defined UUID c4424de1-fe72-51b7-b552-adb441448b53
2020-06-06 18:47:09,961:wsdd INFO(pid 9265): chrooted successfully to /run/wsdd/chroot/
2020-06-06 18:47:09,961:wsdd INFO(pid 9265): running as nobody:nogroup (65534:65534)
2020-06-06 18:47:09,962:wsdd INFO(pid 9265): joined multicast group ('239.255.255.250', 3702) on 192.168.118.1%br0
2020-06-06 18:47:09,965:wsdd ERROR(pid 9265): error in main loop
Traceback (most recent call last):
  File "/usr/local/bin/wsdd", line 1626, in main
  File "/usr/local/bin/wsdd", line 1195, in handle_request
KeyError: 3
2020-06-06 18:47:09,974:wsdd INFO(pid 9265): 192.168.118.143 - - "POST /c4424de1-fe72-51b7-b552-adb441448b53 HTTP/1.1" 200 -
2020-06-06 18:47:09,977:wsdd INFO(pid 9265): 192.168.118.143 - - "POST /c4424de1-fe72-51b7-b552-adb441448b53 HTTP/1.1" 200 -
2020-06-06 18:47:10,016:wsdd INFO(pid 9265): 192.168.118.114 - - "POST /c4424de1-fe72-51b7-b552-adb441448b53 HTTP/1.1" 200 -

After refreshing 'Network' window on Windows 10 machine:

2020-06-06 18:49:10,784:wsdd INFO(pid 9265): 192.168.118.143:60472(br0) - - "Probe urn:uuid:31f774e8-bb70-47eb-8aa0-ec5157dfdb53 UDP" - -
2020-06-06 18:49:10,831:wsdd INFO(pid 9265): 192.168.118.143:60474(br0) - - "Resolve urn:uuid:85046a4f-62e6-4337-829b-2183943dea7d UDP" - -
2020-06-06 18:49:10,843:wsdd INFO(pid 9265): 192.168.118.143 - - "POST /c4424de1-fe72-51b7-b552-adb441448b53 HTTP/1.1" 200 -
2020-06-06 18:49:11,503:wsdd INFO(pid 9265): 192.168.118.143:60474(br0) - - "Resolve urn:uuid:3f737d43-1ffc-46f6-bf73-714c1de7d468 UDP" - -
2020-06-06 18:49:11,504:wsdd WARNING(pid 9265): invalid resolve request: address (urn:uuid:de8a0699-ffe6-593c-9964-c867d65adce0) does not match own one (urn:uuid:c4424de1-fe72-51b7-b552-adb441448b53)
@christgau
Copy link
Owner

Yeah, there is an apparently wrong assumption in the code that the interface (name) is always known before the index is used. I'll fix that. Although is it strange that the kernel provides information that refers to another information not yet provided...

@maxfield-allison
Copy link

@christgau are you currently aware of a temp workaround?

@christgau
Copy link
Owner

@christgau are you currently aware of a temp workaround?

Yes. The following should solve the problem.

diff --git a/src/wsdd.py b/src/wsdd.py
index c91eaa3..71e90f1 100755
--- a/src/wsdd.py
+++ b/src/wsdd.py
@@ -1192,11 +1192,14 @@ class NetlinkAddressMonitor(NetworkAddressMonitor):
                 offset += ((msg_len + 1) // NLM_HDR_ALIGNTO) * NLM_HDR_ALIGNTO
                 continue
 
-            iface = self.interfaces[ifa_idx]
-            if h_type == self.RTM_NEWADDR:
-                self.handle_new_address(addr, ifa_family, iface)
-            elif h_type == self.RTM_DELADDR:
-                self.handle_deleted_address(addr, ifa_family, iface)
+            if ifa_idx in self.interfaces:
+                iface = self.interfaces[ifa_idx]
+                if h_type == self.RTM_NEWADDR:
+                    self.handle_new_address(addr, ifa_family, iface)
+                elif h_type == self.RTM_DELADDR:
+                    self.handle_deleted_address(addr, ifa_family, iface)
+            else:
+                logger.debug('unknown interface index: {}'.format(ifa_idx))
 
             offset += ((msg_len + 1) // NLM_HDR_ALIGNTO) * NLM_HDR_ALIGNTO

@christgau christgau added the bug Something isn't working label Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants