-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
qBittorrent not using the interface ip the routing decides to use. #13094
Comments
Both deluge and qBittorrent use the same libtorrent: https://github.com/arvidn/libtorrent (also known as libtorrent-rasterbar). The thing is, on your system, qBittorrent is using libtorrent >1.2.6, and deluge is using 1.1.x (which I think is what In libtorrent 1.2.x, there were important changes made to multihoming support. If you are using "any interface"/"any address", libtorrent will try establish connections from all endpoints. So it is not sufficient to set one route with a higher priority to guarantee that libtorrent will only use a certain endpoint - you have to actively force it to do so. This can be done 2 ways:
Related discussion: arvidn/libtorrent#4803 (arvidn/libtorrent#4803 (comment), in particular). |
Good issue and this points a problem I often saw on trackers recently. I think for usability reasons qbittorrent/libtorrent (not sure where the problem is located) should default choose the correct interface for outgoing connections. A lot of people doesn't know something about the advanced settings and won't notice that their real ip address is announced to trackers. |
It is impossible to "guess" what the user wants.
As mentioned in arvidn/libtorrent#4803 (comment), the onus is on software such as "VPN apps" (or ultimately, on the users) to not assume "one computer == one IP", and to correctly configure their network facing system settings/software. As a file-transfer piece of software, I think libtorrent does the correct thing by using all interfaces by default, since this maximizes connectivity by default. At most, qBittorrent could show a notice (like the one about copyright law it currently shows on first startup), urging users to double-check their configurations. |
Thanks for clarifying this @FranciscoPombal! |
Yes, this currently is my workaround binding to - say eth2 with it's ip 2.3.4.5. Say you use bittorrent to distribute a new software-release to hundrerds of servers. It even does not work if you've your "normal" home setup with eth0 beeing some public/routeable address and your ultra-default 192.168.0/24 on eth1.
it's not higher priority (like in metric) and neither "more specific"s, it's just routing and the normale "most specific" lookup the kernel does. /0 goes to eth0 but 192.168.0/24 goes to eth1 'caus 24 > 0. and to make things worse, let's talk ecmp 'caus it's really easy with the effort cumulus put in the kernel.
I'll try to understand that. But aren't we at least on the same boat that forcing packets with the wrong src address on an interface is wrong? |
I want normal routing.
that would be fine, but again... i dont think this'll work if it's putting - in my case - its iscsi-only-vlan ip as the src-address when sending to some tracker... which the first well configured router will drop anyway. I'm totally fine that you really have to somehow tell |
I just skimmed over that. the comment explicitely talks about metrics, but "more specific" routing should always win (and it still does), it's just that unconditially providing the (wrong) src address is... some .. kind ... of protection but maybe done at the wrong level / layer. I know it's pretty unusual for a bittorrent client to run on a fulltable (bgp) router with thousands of vlans and in a "default free zone" but at least connecting somewhere should use the correct address. Which address to put in an announcement is - to be left to the application or "layer8". and maybe another comment on "It is impossible to "guess" what the user wants." I think the user wants for it to "just work", even if he's not the default user (possibly >99% of all users) with just one interface and just one route (which is rare or even not existing anymore, all have at least one /31 link, a /32 route to it's p2p-link (point2point, not peer2peer or, maybe again >99%: one default route and one /24 route on the lan) |
digging trough libtorrent srccode i found this comment
One of my first thoughts was, that this applies only to udp only anywas (my scenario and my tcpdump) Is this normal behavior to try udp anyways first when contacting a peer for the first time, even if mode is set to tcp only? |
Hmm...
looks something like a most_specific "routing" without all the patricia-trie bells and whistels and would explain the random behaviour of rotating trough all available ips... |
I think you know much more about this than I do, I think this discussion is becoming out of reach for me. But if I understand at least the basics correctly, your problem is not simply "I would like to be able to configure qBittorrent to use multiple, but not all of the machine's interfaces/IPs". Your issue is more with what libtorrent is doing behind the scenes, right? If so, for convenience, and to isolate as many variables as possible, you may want to use libtorrent's @arvidn ping, you may want to take a look at this. |
@toasta great report, thanks! I notice in your dump you only have UDP packets. and the reason you didn't see the source IP in I can see this being a problem with UDP if libtorrent fails to interpret the routing table (or if it changes after listen sockets and UDP sockets have been set up) where the wrong UDP socket can be chosen for a remote peer. if you disable utp, and only use TCP connections, does everything work as expected? |
@toasta you're right about that piece of code being the one picking which UDP socket is used for a uTP connection, given a target address. Do you have any specific suggestions of how to improve that selection? The source hint should be taken into account, and also the metric. Do you know what would make it work in your case? |
Hi @arvidn, btw... should we move this to libtorrent instead of qBittorrent?
k... have to go back about that a little... I had serious performance problems or "weirdness" happening on my 14.04 and i thought instead of debugging this i could just get away with updating to 20.04 and be fine. Then some other weirdness started. I finally found that deluge is willing to accept libtorrent settings from a file and disabled udp. and the socketstuff should've shown up in strace when i was filtering for %net events.
hmm.. I think it should still respect the fib.
I thought so... yes, but now deluge starts to do weird stuff even with tcp. Even after a restart (so no fib/routingtable changes after starting the client) it still tries the ip of
this time it seems to respect the routing-table (at least). i disabled ecmp for easier debugging... root@X:~# tcpdump -ni tun0 "host XXXXX" root@X:~# ip r get YYYY.105 telnet on the host to YYYY.105 works fine; kernel selects route and uses ip-address from tun0. note that this is still
1.1.x as it's deluge, so this should be before changes to multihomed, ...
what i find most interesting is that it's using the ip of a "DOWN"-interface:
i'll split this into multiple comments... seems already to long.... |
k... so for "asking for routing from a c++ app" i googled https://trustica.cz/en/2016/03/22/linux-routing-api-no-abi-maybe-why/
that should already be better (and faster) than using the src-ip of the interface for routing decisions (which here is binding?) I can see this is way more work to make it work on non unices.... anywho... there seems to be something wrong on a lower layer, as it's affecting tcp with unchanged fib. I'm happy to help debug/code/resolve this but i'll have a lot of stupid questions so this'll require lots of patience from you :) |
I think we should move here: arvidn/libtorrent#4850 |
keeping this open to track it more easily until the libtorrent part is resolved. |
Please provide the following information
qBittorrent version and Operating System
Version: 1:4.2.5.99~202004250117-7015-2c65b79~ubuntu20.04.1
20.04
If on linux, libtorrent-rasterbar and Qt version
1.2.6+git20200425.a9968916ca-1ppa1~20.04
Package: libqt5core5a
Version: 5.12.8+dfsg-0ubuntu1
(hope that's the one you ment, but shouldnt apply to this issue)
What is the problem
This is only for outgoing connections.
qBittorrent is using the wrong src-ip for outgoing requests, not honoring
the interfaces address the kernel-routing decides to use.
What is the expected behavior
Outgoing packets should use the ip of the interface the kernel decides to route over,
not one of the other interfaces qbittorrent is listening on.
Steps to reproduce
hope that works for you, still trying to find a mwe.
-- no additional routes set on this interface
-- set "Network interface" to "Any interface"
-- set "Optional Ip Address to bind to (requires restart)" to "All addresses"
Extra info(if any)
if i do the "Steps to reproduce", qbittorrent sends request over interfaces with the wrong src-ip set.
this is especially annoying when using ecmp (granted, this is a corner case) or the normal behaviour of say openvpn which sets two /1 routes to be more specific than the /0 route and you want to route 128/1 over another tunnel for load-"balancing"
if i do the above tcpdump (note that eth0 has the 1.2.3.4)
and dump on eth1 (which in my case has 10.8.8.27)
i would expect that i see no other src-ip than 10.8.8.27 when i originate packets.
to faster demonstrate that, i manually add peers to a torrent.
(
seq 0 255 | while read a; do echo "2.3.4.$a:12500"; done
-- and paste that into the "manually add peer" txtbox)so for whatever reason, qtbittorent is asking the kernel for routing (i wouldnt know how to do that differently), but uses the ip it bound to for another interface instead of leaving it empty and letting the kernel figure out what src-ip to use.
it doesnt seem to happen if you've only a /0 route.
but finally, i wouldnt expect any packets showing up on eth1 with a src-address other than the ip of eth1 if originating traffic from the local machine (yes, if this would be a router than this is expected, but not for traffic originating from the machine itself with src-ip set null in connect() .
i'm kinda stuck with debugging here as i was expecting to see the src-ip set in the connect() syscall but strace says:
normal telnet on the machine to those ips works fine (routing and selection of src-ip-wise)
deluge does not have this problem. it seems to be using another libtorrent trough it's libtorrent-python-bindings tough.
deluge:
qbittorrent:
The text was updated successfully, but these errors were encountered: