mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
netdev-linux: Cast policer rate to uint64_t to avoid overflow
tc_fill_rate() takes a 64bit int, casting kbits_rate from int to uint64_t avoids a possible overflow when translating from kbits to bytes. Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
@@ -4042,7 +4042,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 * 1000)/8, mtu);
|
||||
tc_fill_rate(&tc_police.rate, ((uint64_t) kbits_rate * 1000)/8, mtu);
|
||||
tc_police.burst = tc_bytes_to_ticks(tc_police.rate.rate,
|
||||
kbits_burst * 1024);
|
||||
|
||||
|
Reference in New Issue
Block a user