coova / coova-chilli

CoovaChilli is an open-source software access controller for captive portal hotspots.
Other
518 stars 260 forks source link

Upload/download bandwidth handling error? #427

Open knumat opened 6 years ago

knumat commented 6 years ago

Looking through src/chilli.c, it appears that there is a mismatch between the way that the upload and download bandwidth limits are handled. The download version is as follows: https://github.com/coova/coova-chilli/blob/master/src/chilli.c#L2737

  if (_options.scalewin && appconn && appconn->s_state.bucketdownsize) {
    uint16_t win = appconn->s_state.bucketdownsize -
        appconn->s_state.bucketdown;

The upload version is similar, but the if statement checks s_state.bucketup instead of s_state.bucketupsize: https://github.com/coova/coova-chilli/blob/master/src/chilli.c#L5638

  if (_options.scalewin && appconn && appconn->s_state.bucketup) {
    uint16_t win = appconn->s_state.bucketupsize -
        appconn->s_state.bucketup;

My guess is that the download version is correct and the upload version is wrong, but I'm not familiar enough with this code to be sure.

jobezic commented 6 years ago

Hi knumat, I think it is possible because the upload limit doesn't work fine. Would you like to make a PR?

lsoltero commented 6 years ago

the upload bandwidth throttling has been broken since version 1.3 or before. It would be relay great if this could be addressed.

i just changed the code and replaced the bucketup to bucketupsize and tested and made no difference in 1.4. The downloads speed is throttled but the upload is not.

sjbeskur commented 6 years ago

Have you tried to disable GRO GSO using ethtool ?

eg ethtool -K eth0 gro off

There was an issues related to this several years ago. It seems that the leaky bucket algorithm does not rate limit properly if offloading is configured. I think that gro (receive offloading) is all that matters but you can shut off gso and test.

eg ethtool -K eth0 gro off gso off

vesl commented 6 years ago

Hi, We have same problem. Maybe I can add some details, in our case :

lsoltero commented 6 years ago

using ethtool on my AMD/X86_64 system did not work. disabling gro and gso had no effect. Any other thoughts as to why the upload bandwidth limit works for some and not others?

vesl commented 6 years ago

I have some news. chilli[32]: leaky_bucket(666): Leaky bucket dropping upload overflow from XX-XX-XX-XX-XX-XX Chilli tell packets are dropped.

chilli[32]: leaky_bucket(704): Leaky bucket: bucketup: 518231/524288, bucketdown: 52/524288, up: 0/(4941), down: 52/(4941)
chilli[32]: leaky_bucket(704): Leaky bucket: bucketup: 517660/524288, bucketdown: 0/524288, up: 1500/(2071), down: 0/(2071)
chilli[32]: leaky_bucket(704): Leaky bucket: bucketup: 518759/524288, bucketdown: 0/524288, up: 1500/(401), down: 0/(401)

The bucket never overflow, but the packets are not dropped. Assuming this we cant forgive gro problems. I still not understand all the code, I dont know how the packets should be dropped.