On Thu, Dec 08, 2016 at 01:16:22PM +0100, Przemyslaw Lal wrote:
> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> index de78ddd..ef99eb3 100644
> --- a/lib/netdev-dpdk.c
> +++ b/lib/netdev-dpdk.c
> @@ -2075,7 +2075,13 @@ netdev_dpdk_get_ifindex(const struct netdev *netdev)
>      int ifindex;
>  
>      ovs_mutex_lock(&dev->mutex);
> -    ifindex = dev->port_id;
> +    /* Calculate hash from the netdev name using hash_bytes() function.
> +     * Because ifindex is declared as signed int in the kernel sources and
> +     * OVS follows this implementation right shift is needed to set sign bit
> +     * to 0 and then XOR to slightly improve collision rate.
> +     */
> +    uint32_t h = hash_bytes(netdev->name, strlen(netdev->name), 0);
> +    ifindex = (int)((h >> 1) ^ (h & 0x0FFFFFFF));

To hash a string, please use hash_string().

Daniele, are you planning to review this?
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to