mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
netdev-dpdk: fix ifindex assignment for DPDK ports
In current implementation port_id is used as an ifindex for all netdev-dpdk interfaces. For physical DPDK interfaces using port_id as ifindex causes that '0' is set as ifindex for 'dpdk0' interface, '1' for 'dpdk1' and so on. For the DPDK vHost interfaces ifindexes are not even assigned (0 is used by default) due to the fact that vHost ports don't use port_id field from the DPDK library. This causes multiple negative side-effects. First of all 0 is an invalid ifindex value. The other issue is possible overlapping of 'dpdkX' interfaces ifindex values with the ifindexes of kernel space interfaces which may cause problems in any external tools that use those values. Neither 'dpdk0', nor any DPDK vHost interfaces are visible in sFlow collector tools, as all interfaces with ifindexes smaller than 1 are ignored. Proposed solution to these issues is to calculate a hash of interface's name and use calculated value as an ifindex. This way interfaces keep their ifindexes during OVS-DPDK restarts, ports re-initialization events, etc., show up in sFlow collectors and meet RFC 2863 specification regarding re-using ifindex values by the same virtual interfaces and maximum ifindex value. Signed-off-by: Przemyslaw Lal <przemyslawx.lal@intel.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked by: Darrell Ball <dlu998@gmail.com>
This commit is contained in:
committed by
Ben Pfaff
parent
ce8d95546e
commit
12d0d1242c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2015, 2016 Nicira, Inc.
|
||||
* Copyright (c) 2014, 2015, 2016, 2017 Nicira, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -2213,10 +2213,12 @@ static int
|
||||
netdev_dpdk_get_ifindex(const struct netdev *netdev)
|
||||
{
|
||||
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
|
||||
int ifindex;
|
||||
|
||||
ovs_mutex_lock(&dev->mutex);
|
||||
ifindex = dev->port_id;
|
||||
/* Calculate hash from the netdev name. Ensure that ifindex is a 24-bit
|
||||
* postive integer to meet RFC 2863 recommendations.
|
||||
*/
|
||||
int ifindex = hash_string(netdev->name, 0) % 0xfffffe + 1;
|
||||
ovs_mutex_unlock(&dev->mutex);
|
||||
|
||||
return ifindex;
|
||||
|
Reference in New Issue
Block a user