[ovs-dev] [PATCH] netdev-dpdk: use 64-bit arithmetic when converting rates

Darrell Ball dball at vmware.com
Fri Aug 25 22:02:02 UTC 2017


I applied the patch to dpdk_merge here

https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_darball_ovs_commits_dpdk-5Fmerge&d=DwIGaQ&c=uilaK90D4TOVoH58JNXRgQ&r=BVhFA09CGX7JQ5Ih-uZnsw&m=A2_FCacqbp2moAo3HGFlTuxsjONUGhlN42OBcAuQQ6w&s=b6btPKhgvOFr2GOUYvktND6kaC6jc3fXI-mXfvNgXOU&e=

This looks like it could go back as far as 2.6.


On 8/24/17, 6:16 AM, "ovs-dev-bounces at openvswitch.org on behalf of Lance Richardson" <ovs-dev-bounces at openvswitch.org on behalf of lrichard at redhat.com> wrote:

    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 at jd.com>
    Fixes: 9509913aa722 ("netdev-dpdk.c: Add ingress-policing functionality.")
    Signed-off-by: Lance Richardson <lrichard at redhat.com>
    ---
    Note: Found by inspection, untested.
    
     lib/netdev-dpdk.c | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
    index 1aaf6f7e2..4e8aaa3d8 100644
    --- a/lib/netdev-dpdk.c
    +++ b/lib/netdev-dpdk.c
    @@ -2229,8 +2229,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;
    -- 
    2.13.4
    
    _______________________________________________
    dev mailing list
    dev at openvswitch.org
    https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.openvswitch.org_mailman_listinfo_ovs-2Ddev&d=DwIGaQ&c=uilaK90D4TOVoH58JNXRgQ&r=BVhFA09CGX7JQ5Ih-uZnsw&m=iazIwQBuiSqzVKtRDEW1WScuv043H7CJeF9RmwU9SA4&s=Eo5tR-W5L7RCCoJLUTEIvo3UaqihU1thE1jB95icvNA&e= 
    





More information about the dev mailing list