-
Notifications
You must be signed in to change notification settings - Fork 103
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
wsdd 0.6.3 no longer functional on FreeBSD #80
Comments
The number of commits between 0.6.2 and 0.6.3 were so few, I was able to track it down quickly: The issue was introduced in 1ed74fe / #72. Reverting this commit restores proper functionality. Quick revert diff (since diff --git a/src/wsdd.py b/src/wsdd.py
index f5a6e50..57069e5 100755
--- a/src/wsdd.py
+++ b/src/wsdd.py
@@ -183,16 +183,6 @@ class MulticastHandler:
for handler in self.message_handlers[s]:
handler.handle_request(msg, address)
- def send(self, msg, addr):
- # Request from a client must be answered from a socket that is bound
- # to the WSD port, i.e. the recv_socket. Messages to multicast
- # addresses are sent over the dedicated send socket.
- if addr == self.multicast_address:
- self.send_socket.sendto(msg, addr)
- else:
- self.recv_socket.sendto(msg, addr)
-
-
# constants for WSD XML/SOAP parsing
WSA_URI = 'http://schemas.xmlsoap.org/ws/2004/08/addressing'
WSD_URI = 'http://schemas.xmlsoap.org/ws/2005/04/discovery'
@@ -1549,7 +1539,7 @@ def send_outstanding_messages(block=False):
addr = send_queue[-1][2]
msg = send_queue[-1][3]
try:
- mch.send(msg, addr)
+ mch.send_socket.sendto(msg, addr)
except Exception as e:
logger.error('error while sending packet on {}: {}'.format(
mch.interface.name, e)) I don't know if it matters -- I strongly doubt it -- but FreeBSD 11.4-STABLE (where this is being tested) uses Python 3.7.9. The system in question has no firewall, is IPv4-only, etc.. It's the same box (and client) described in #49. Daemon is launched with flags I don't know where the bug lies, and I would rather not have to go through another ktrace analysis like last time if I can avoid it (it's very time-consuming). :) But best I can tell based on the above code, the If running the daemon with |
I just fired up my 12.2-RELEASE machine. The host appears automatically upon boot and also if I start the daemon manually from the command line (without any arguments). The machine uses vanilla v0.6.3 (manually installed, not from ports). However, a manual refresh in Explorer causes an As you pointed out, the issue really comes from the commit for solving #72. Formally, the requirement is that answers to multicast requests are answered from a fixed port. This was the reason for the patch you quoted above. On Linux, it's ok to use This finally means the code needs to be adjusted properly instead of using the hacky way with the Until there is a proper fix, you might consider to replace Lines 190 to 193 in cf87b9a
Although it does not comply 100% with the standard, it restores functionality. |
Thanks for the analysis! Very interesting how substantially different FreeBSD and Linux are in this regard and how this manifests. Can this not be achieved with an |
Yes, but I'd like to have a solution that works both on Linux and FreeBSD without such |
I recently also upgraded from an old wsdd version to 0.6.3 and ecnountered a weird thing that made no sense to me and then i read this issue and found a "solution" to that. Turns out the that " self.recv_socket.sendto(msg, addr) " on line 193 is just weird as I had to make a new iptables rule that was INCOMING (server) from the RECEIVING end (client) but was routed through the OUTGOING (server iptables) table on the server. Replacing the "recv" with "send" now has made actual sense in terms of firewall rules. "-A WSD-OUT -o eth2 -p udp -m udp -s 172.16.0.5-d 172.16.0.10 --sport 3702 --dport 49152:65535 -j ACCEPT" "DENY-Server-OUTPUT IN= OUT=eth2 SRC=172.16.0.5 DST=172.16.0.10 LEN=1275 TOS=0x00 PREC=0x00 TTL=64 ID=50660 DF PROTO=UDP SPT=3702 DPT=58534 LEN=1255" |
True, this looks strange but it was required to solve #72 and make the message to come the intended source addresses. Now, I changed to the code to use dedicated sockets for the different types of traffic (see issue-80 branch). This works both on FreeBSD and Linux based on my testing. I would highly appreciate if you could check if the daemon works in your environments as well. |
I tried it out and it's the same behaviour, still need the new iptables rule. |
Compared to v0.6.3 the behavior of the code in the issue's branch concerning ports is/should be the same. This is intended. The current usage of ports complies to what is documented here: https://docs.microsoft.com/en-us/windows/win32/wsdapi/discovery-and-metadata-exchange-message-patterns Before v0.6.3 the behavior was actually wrong.
I do not understand why you have to open the firewall for traffic on ephemeral ports. For a WSD host, you could just check for the source port of the outgoing traffic being 3702. Actually, before v0.6.3 it appeared to be even more difficult to get a proper firewall setup, at least according to the original post in #72. For me, this minimal ruleset works to get wsdd to run (with DROP policy):
|
It was actually easier, the simplest ruleset I got away with was:
Server was visible and accessible from every computer in the same network. Now, if I did it a little more restrictive I would add the ephemeral ports range of Win10 "49152:65535", just because I like to understand how it all works and reducing it to allow only what is actually needed for a service. EDIT: Nevermind most of what I wrote! New rule I changed/added: |
Checking commit
And found this error:
|
@Izorkin based on the log, you are using wsdd now in the discovery mode (client) while the original error was related to the normal (host) operation mode. So this is completely unrelated. In addition, the timeout is not really a fault of wsdd and it is not an error per se. Two possibilities:
For the first point, you might check if the default timeout of 2.0 seconds could be increased and a higher values resolves the issue: Line 672 in ee8783c
If this really turns out to be a problem, please open a new issue or a PR, if you have a patch. For the second point, please check your firewall rules, but a discussion of the ruleset might be out of scope... at least for this issue. |
@christgau resolved this error with timeout of 5.0 seconds. Thanks. |
@koitsu have you been able to check whether the issue branch solved the problem for you on FreeBSD? Would be nice to see if it works for you in order to prepare a new release |
Sorry Steffan, I haven't. I've been running with a local copy of wsdd with 1ed74fe reverted. I was not aware of the issue-80 branch until your above comment. (The instance I saw Linux iptables and iptables log output being discussed in a FreeBSD ticket, I wasn't sure what to think.) I'll switch to that branch and report back here. |
I can confirm branch issue-80 fixes the original problem I reported here. If a new release is made, please let me know here so that I can update FreeBSD PR 252742 and advise the port maintainer to simply update to the newer version, rather than run with a unique patch. |
Great. Thanks for testing and yeah, the this was definitely not the best place to bring up the Linux firewall discussion, although it appeared to be related it a first glance. I'll prepare a new release in the next few days (if not today). |
Sorry about that, thought it was related and didn't want to open a new issue, when this seemed very similiar. |
@koitsu v0.6.4 is out which finally solved the issue |
FreeBSD port maintainers recently upgraded from 0.6.2 to 0.6.3 and PR 252742 and now the daemon no longer functions (meaning: Network Neighbourhood no longer shows the machine where wsdd is running).
It will take me some time to figure out why (I'll end up using
git bisect
to figure out what commit broke things), and I probably won't have time to do the analysis until this weekend.I at least wanted to report it first.
The text was updated successfully, but these errors were encountered: