Skip to content

Commit

Permalink
linux: Increase accuracy of ingress_policing_rate at low rates
Browse files Browse the repository at this point in the history
The current method of calculating the ingress policer rate
can lead to inaccuracy if ingress_policing_rate is set to
a smallish values because the rate is divided by 8 first
which causes rounding errors.

Signed-off-by: Thomas Graf <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
Thomas Graf authored and blp committed Jan 25, 2013
1 parent 8d675c5 commit e5c0801
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/netdev-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -3730,7 +3730,7 @@ tc_add_policer(struct netdev *netdev, int kbits_rate, int kbits_burst)
memset(&tc_police, 0, sizeof tc_police);
tc_police.action = TC_POLICE_SHOT;
tc_police.mtu = mtu;
tc_fill_rate(&tc_police.rate, kbits_rate/8 * 1000, mtu);
tc_fill_rate(&tc_police.rate, (kbits_rate * 1000)/8, mtu);
tc_police.burst = tc_bytes_to_ticks(tc_police.rate.rate,
kbits_burst * 1024);

Expand Down

0 comments on commit e5c0801

Please sign in to comment.