View previous topic :: View next topic |
Author |
Message |
Palhoto Tux's lil' helper
Joined: 27 Feb 2003 Posts: 111 Location: Iberian Peninsula
|
Posted: Tue Mar 17, 2020 6:31 pm Post subject: Throttle Emerge Fetch? |
|
|
For some odd reason, when emerge is fetching packages, my ISP's router flips out and I have to reset it. Is there a way to throttle emerge fetch, by bandwidth and/or number of simultaneous connections? |
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Tue Mar 17, 2020 6:37 pm Post subject: |
|
|
Check `emerge --info --verbose` for $FETCHCOMMAND (and $RESUMECOMMAND), you can tweak it in make.conf. |
|
Back to top |
|
|
Palhoto Tux's lil' helper
Joined: 27 Feb 2003 Posts: 111 Location: Iberian Peninsula
|
Posted: Tue Mar 17, 2020 7:36 pm Post subject: |
|
|
Ant P. wrote: | Check `emerge --info --verbose` for $FETCHCOMMAND (and $RESUMECOMMAND), you can tweak it in make.conf. |
Thanks Ant P., that is useful. From the current configuration, could be due to passive FTP being selected. In the meantime I also found out that my clock is skewed several hours; possibly a Hyper-V issue, I'm not sure if it is related. I'll still have to check that issue first. |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3131
|
Posted: Wed Mar 18, 2020 8:29 pm Post subject: |
|
|
Yeah, you can set limit via wget params.
However, there is a really neat trick using firewall rules... Leveraging the fact that portage fetches sources using portage user.
The magic goes like this:
Code: | # Generated by iptables-save v1.6.1 on Wed Mar 18 21:21:52 2020
*mangle
:PREROUTING ACCEPT [54239:30201618]
:INPUT ACCEPT [31895:11202941]
:FORWARD ACCEPT [18191:13048228]
:OUTPUT ACCEPT [32740:10673359]
:POSTROUTING ACCEPT [51471:23761339]
:PORTAGE - [0:0]
-A INPUT -j CONNMARK --restore-mark --nfmask 0xffffffff --ctmask 0xffffffff
-A INPUT -m mark --mark 0xfa -j PORTAGE
-A OUTPUT -m owner --uid-owner 250 -j MARK --set-xmark 0xfa/0xffffffff
-A OUTPUT -j CONNMARK --save-mark --nfmask 0xffffffff --ctmask 0xffffffff
-A PORTAGE -m limit --limit 30/sec -j ACCEPT
-A PORTAGE -j DROP
COMMIT
|
So, we mark connections initiated by user "portage" (in my case: uid 250), then mark the whole connection, and then restore mark on incoming packets within the same connection and then limit the number of packets accepted. Dropping the excess packets informs the sender that your connection is saturated and it should slow down.
Good stuff
Obviously, this trick is absolutely generic, so it can be used with any service running on top of TCP. |
|
Back to top |
|
|
|