-
Notifications
You must be signed in to change notification settings - Fork 20
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
new connections are blocked when popup is running #79
Comments
That's the real bottleneck. We're only using one NFQUEUE queue, so all the output packets pass through a single point. Obviously workers concurrency helps a bit, but we should have more queues as explained here:
and suggested by the libnetfilter_queue docs:
|
Thank you for the links. My initial impression was that there was a mistaken assumption that the workers process the queue in parallel. I got this impression because right now when a new popup comes up asking to make a decision, Maybe we should move that connection which is awaiting the user decision onto a different queue, so that normal internet activity is not hindered? |
Yes, that behaviour annoys me quite a bit, because with some VPN clients it interrupts the connection, usually disconnecting it.
I think it would be easier to modify the protocol, and make the query asynchronous: ui.proto: I made an attempt to change it a few weeks ago, but I haven't had time to look into it again. |
Correct me if Im wrong, but even if you make it async, you still have to do something with the queued packet in order not to hold up the queue. |
Yes, that's it. It's a different problem, the bottleneck is still the single NFQUEUE queue. But making this call asynchronous would not stop queue processing, so we wouldn't need to move the connection to a different queue as you said before. |
Oh, let me see if I got it right this time. (nfq works in such a manner that unless we pass a verdict on the packet, the next packet will not get processed by nfq) I'm wondering when we invoke the gui in an async manner and the onPacket() function runs to its end without returning any verdict on the packet, what will happen to the packet? I guess some netfilter exception will be raised because it requires a verdict to be passed on each packet. |
Yeah, sorry, it's a bit complicated topic, probably I'm not explaining it well:
Yes, or the Default Action configured.
We would process the packet applying the Default Action configured, but only to that packet (Default Action: once). If the user allows the packet and the app retries the connection, then it would apply the rule defined by the user. If you hold up the connection until the connection is allowed or denied, you'll probably end up triggering the app timeout for that connection. Right now the connection flow is as follow:
Invoking the GUI asynchronously would change the flow like this:
Anyway, this is something that the users asked for long time ago, be able to choose if display a connection pop-up or apply a default action and later edit the rule using the GUI. |
Now it makes sense, thanks. |
oh, I've just remembered what happened when I implemented this working method. If the Default Duration is "once", the daemon sends the request to allow or deny the connection to the GUI. However, as soon as the packet is dropped (if that's the Default Action configured) and a new packet arrives (a connection retry), the daemon send the request again until the app give up. If I'll look into this again I'll have it into account. |
Regarding the bottleneck of a single NFQUEUE queue, I've been playing a bit: main.go
in main():
start opensnitch and add 2 iptables rules (UDP packets to queue 0 and TCP packets to queue 1):
It seems to work, I haven't run it through the race detector though. Each packet type goes to its assigned queue. However the |
I've pushed a branch with these changes just in case you want to give it a try: ./opensnitchd -rules-path /etc/opensnitchd/rules/ --queue-numbers 10 I don't know if it makes any difference. Web navigation seems to be a bit more reactive and with 10 nfqueues I don't see the usual "unknown connections" using transmission.
|
Thank you for the branch. It was supposed to fix the unknown connections? I guess you posted it in the wrong issue. |
we started talking about workers concurrency, but well, nevermind.
|
@gustavo-iniguez-goya , do you have any code for Invoking the GUI asynchronously as discussed here.
If the popup is already running and a new allow/deny request arrives, the GUI should simply ignore it until the action on the currently displayed popup is taken. |
nope, not anymore.
Do you mean discard the request on the GUI side? I think that it should be done on the daemon, otherwise the connections will still be blocked. Maybe something like:
If uiClient.Ask() is not asynchronous I think it still blocks the main thread. But I don't know for sure, implement it as best as you can and we keep working from there. |
@gustavo-iniguez-goya Does this make sense? |
The only problem I see is that we may end up spawning too many goroutines if there's no control on the daemon. |
From my experience, all the packets in the nfq are processed sequentially. Until a verdict is passed for a packet, the next one will not be processed.
So, opensnitchd's workers are not concurrent. If one of them blocks, then the whole queue will be blocked.
Just something to keep in mind when making future design decisions.
The text was updated successfully, but these errors were encountered: