Skip to content

Commit

Permalink
netdev-dpdk: use 64-bit arithmetic when converting rates.
Browse files Browse the repository at this point in the history
Force 64-bit arithmetic to be used when converting uint32_t rate
and burst parameters from kilobits per second to bytes per second,
avoiding incorrect behavior for rates exceeding UINT_MAX bits
per second.

Reported-by: "王志克" <wangzhike@jd.com>
Fixes: 9509913 ("netdev-dpdk.c: Add ingress-policing functionality.")
Signed-off-by: Lance Richardson <lrichard@redhat.com>
Acked-By: Mark Michelson <mmichels@redhat.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Darrell Ball <dlu998@gmail.com>
  • Loading branch information
hlrichardson authored and blp committed Aug 29, 2017
1 parent 965a8a6 commit 5820afe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/netdev-dpdk.c
Expand Up @@ -2148,8 +2148,8 @@ netdev_dpdk_policer_construct(uint32_t rate, uint32_t burst)
rte_spinlock_init(&policer->policer_lock);

/* rte_meter requires bytes so convert kbits rate and burst to bytes. */
rate_bytes = rate * 1000/8;
burst_bytes = burst * 1000/8;
rate_bytes = rate * 1000ULL / 8;
burst_bytes = burst * 1000ULL / 8;

policer->app_srtcm_params.cir = rate_bytes;
policer->app_srtcm_params.cbs = burst_bytes;
Expand Down

0 comments on commit 5820afe

Please sign in to comment.