Trickle is a command-line tool to throttle network bandwidth of other applications. You use it on the command-line to start the application. It uses LD_PRELOAD
to override network-related calls. As a result, using it with containerized apps, like Flatpak, does not work out of the box.
To get trickle to function with a Flatpak application, the preloaded library needs to be available in the container. And it needs to be compatible with the software in the container (notably, a glibc version that is compatible).
- Install
trickle
on your (host) system, on Debian/Ubuntu that would beapt install trickle
. - Make sure you have the flatpak application installed. I'm using
com.slack.Slack
as an example here. - Run the flatpak application with trickle
trickle -s -d 250 -u 250 flatpak run com.slack.Slack
- Find out it doesn't work. Error message:
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/trickle/trickle-overload.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
- (as above)
- (as above)
- Find out what runtime the flatpak application uses.
flatpak info com.slack.Slack
, e.g.org.freedesktop.Platform/x86_64/21.08
- Copy the trickle library to the runtime
RUNTIME=`flatpak info com.slack.Slack | sed 's/^\s*Runtime:\s*//p;d'` cd "/var/lib/flatpak/runtime/$RUNTIME/active/files/lib/x86_64-linux-gnu" sudo mkdir trickle sudo ln /usr/lib/x86_64-linux-gnu/trickle/trickle-overload.so trickle # use cp on different filesystem
- Run the flatpak with trickle (as above)
- Find out it still doesn't work
/bin/sh: /usr/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /usr/lib/x86_64-linux-gnu/trickle/trickle-overload.so)
You can find out which GLIBC version a library needs using objdump -T
. Running it on the system's trickle library, we find
$ objdump -T /usr/lib/x86_64-linux-gnu/trickle/trickle-overload.so | grep GLIBC
0000000000000000 DF *UND* 0000000000000000 (GLIBC_2.2.5) getenv
0000000000000000 DF *UND* 0000000000000000 (GLIBC_2.3.4) __snprintf_chk
...
0000000000000000 DF *UND* 0000000000000000 (GLIBC_2.4) __stack_chk_fail
0000000000000000 DF *UND* 0000000000000000 (GLIBC_2.15) __fdelt_chk
...
0000000000000000 DF *UND* 0000000000000000 (GLIBC_2.34) dlsym
0000000000000000 DF *UND* 0000000000000000 (GLIBC_2.2.5) exit
You see that there is one external symbol that needs glibc 2.34, hence the requirement or this minimum version.
- (as above)
- (as above)
- Download a binary package of trickle for an older operating system. Debian stretch will do here (package). Extract the library.
wget http://ftp.de.debian.org/debian/pool/main/t/trickle/trickle_1.07-10+b1_amd64.deb mkdir trickle-stretch dpkg-deb -x trickle_1.07-10+b1_amd64.deb trickle-stretch sudo cp trickle-stretch/usr/lib/trickle/trickle-overload.so /tmp
- Copy the older library to the flatpak runtime
RUNTIME=`flatpak info com.slack.Slack | sed 's/^\s*Runtime:\s*//p;d'` cd "/var/lib/flatpak/runtime/$RUNTIME/active/files/lib/x86_64-linux-gnu" sudo mkdir -p trickle sudo cp /tmp/trickle-overload.so trickle/
- Run the flatpak application with trickle
trickle -s -d 250 -u 250 flatpak run com.slack.Slack
- Finally it runs.