Commit Graph

27 Commits

Author SHA1 Message Date
Rodolfo Alonso Hernandez 77ac42d2ee SR-IOV agent can handle ports with same MAC addresses
SR-IOV agent can handle ports with same MAC address (located in
different networks). The agent can retrieve, from the system, the
MAC address and the PCI slot; because the PCI slot is unique per
port in the same host, this parameter is used to match with the
Neutron port ID stored in the database (published via RPC).

RPC API bumped to version 1.9.

Closes-Bug: #1791159

Change-Id: Id8c3e0485bebc55c778ecaadaabca1c28ec56205
2021-06-03 16:02:18 +00:00
Rodolfo Alonso Hernandez c5d8fd6329 Use pyroute2 for SRIOV VF commands
Recent changes in some versions of iproute2 CLI output (v4.18),
have invalidated the regular expression used to parse the
"ip link" output.

To solve this problem and avoid future ones, pyroute2 is used to
retrieve the virtual functions information and set the VF attributes
(spoofcheck, min_tx_rate, max_tx_rate and link_state).

pyroute2 extended the "ip link" support to retrieve this information,
adding "ext_mask=1" in the get command. If no virtual functions are
present in this particular network interface, the added method,
"get_link_vfs",  will return an empty list.

The set commands can return a "InterfaceOperationNotSupported" in
case the operation is not supported. For min_tx_rate, if the driver
does not support to set a minimum bandwidth, an "InvalidArgument"
(from a pyroute2.NetlinkError(22)) exception will be raised.

Change-Id: I680da4f64bd114f1caecaaeedbf8a4b1915a0849
Closes-Bug: #1878042
2020-05-27 16:58:02 +00:00
Brian Haley 7594bb0627 Remove the dependency on the "mock" package
Now that we are python3 only, we should move to using the built
in version of mock that supports all of our testing needs and
remove the dependency on the "mock" package.

This patch moves all references to "import mock" to
"from unittest import mock". It also cleans up some new line
inconsistency.

Fixed an inconsistency in the OVSBridge.deferred() definition
as it needs to also have an *args argument.

Fixed an issue where an l3-agent test was mocking
functools.partial, causing a python3.8 failure.

Unit tests only, removing from tests/base.py affects
functional tests which need additional work.

Change-Id: I40e8a8410840c3774c72ae1a8054574445d66ece
2020-04-28 18:05:37 -04:00
Adrian Chiris 6f7b88d080 Use effective MAC address for macvtap assigned VFs
This commit modifies the way sriov agent retrieves mac
addresses for macvtap assigned VFs to use the effective
mac taken from the macvtap net device instead of the
administrative mac set on the PF.

This commit rids sriov agent from depending on hypervisor/nova
to set both administrative and effective mac for macvtap ports.

Related-Bug: #1841067

Change-Id: Id499bcc49d27f13f7f03481922a3383b4a255da1
2020-01-07 17:22:21 +02:00
Bence Romsics 258eebea71 Locate RP-tree parent by hypervisor name
Previously we assumed that we can look up the resource provider (created
by nova) to be used as the parent of the agent and physical NIC resource
provider tree by the name set in the config option DEFAULT.host. This
assumption was wrong.

While nova-compute's DEFAULT.host and neutron-agent's DEFAULT.host
must match for port binding to work, the root resource provider created
by nova does not belong to the compute host (where nova-compute runs)
but it belongs to the compute nodes (i.e. hypervisors). Actually there
may be multiple compute nodes managed by a single nova-compute (think
of ironic). Plus the value of DEFAULT.host and the compute node's ID
may be different even when nova-compute manages a hypervisor on the
same host because of various deployment considerations. For example
when tripleo does not manage the undercloud (so a libvirt hypervisor
returns the plain hostname), but the same tripleo enforces it's host
naming conventions in nova's and neutron's DEFAULT.host settings.

This change enables neutron to use the hypervisor name to locate the
root of the resource provider tree.

We introduce a new configuration option for

(1) ovs-agent: resource_provider_hypervisors, for example:

[ovs]
bridge_mappings = physnet0:br-physnet0,...
resource_provider_bandwidths = br-physnet0:10000000:10000000,...
resource_provider_hypervisors = br-physnet0:hypervisor0,...

(2) sriov-agent: resource_provider_hypervisors, for example:

[sriov_nic]
bridge_mappings = physnet1:ens5,...
resource_provider_bandwidths = ens5:10000000:10000000,...
resource_provider_hypervisors = ens5:hypervisor1,...

For both agents 'resource_provider_hypervisors' values default to
socket.gethostname() for each key in resource_provider_bandwidths.

We try to not block later developments in which one neutron
agent may manage devices on multiple hosts. That's why we allow
the each physdev to be associated with a different hypervisor.

But here we do not try to solve the problem that the natural physdev
identifiers may not be unique accross multiple hosts. We leave solving
this problem to whoever wants to implement an agent handling devices of
multiple hosts.

(3) We extend report_state message's configurations field alike:

{
'bridge_mappings': {'physnet0': 'br-physnet0'},
'resource_provider_bandwidths': {
    'br-physnet0': {'egress': 10000000, 'ingress': 10000000}},
'resource_provider_hypervisors': {'br-physnet0': 'hypervisor0'},
...
}

(4) In neutron-server we use
report_state.configurations.resource_provider_hypervisors.PHYSDEV
when selecting parent resource provider for agent and physdev
RP-tree. When not available in the message we fall back to using
report_state.host as before.

Since we only changed the free-format configurations field of the
report_state message rpc version is not bumped and we expect this
change to be backported to stein and train.

Change-Id: I9b08a3a9c20b702b745b41d4885fb5120fd665ce
Closes-Bug: #1853840
2019-12-10 10:21:53 +01:00
Boden R 9bbe9911c4 remove neutron.common.constants
All of the externally consumed variables from neutron.common.constants
now live in neutron-lib. This patch removes neutron.common.constants
and switches all uses over to lib.

NeutronLibImpact

Depends-On: https://review.openstack.org/#/c/647836/
Change-Id: I3c2f28ecd18996a1cee1ae3af399166defe9da87
2019-04-04 14:10:26 -06:00
Adrian Chiris a05e1369b0 Add support for binding activate and deactivate
Add support for binding activate and deactivate callbacks
in SR-IOV mechanism driver agent.

this work item is required for supporting VM live-migration
with SR-IOV in nova with libvirt as hypervisor.

This commits implemets the following:
- Implement binding_activate() and binding_deactivate() methods in agent.
- Configure agent to listen on the relevant topics.
- RPC version bump on agend side.
- When processing an activated binding treat it as a newly added port.
- Deactivated binding will trigger a NO-OP as once a binding is
  deactivated it will be removed by Hypervisor.

Closes-Bug: #1815361

Change-Id: I6b7195e08ed8932cfc2785b66627de2854ead85d
2019-02-20 19:39:18 +02:00
Hongbin Lu f0678b9b09 Add propagate_uplink_status to port
Introduce an attribute 'propagate_uplink_status' to port.
This attribute can be implemented for VF port to indicate if the VF
link state should follow the state of the PF.

Note: ML2 extension driver loaded on request via configuration:

  [ml2]
  extension_drivers = uplink_status_propagation

Other related patches:
* neutron-lib: https://review.openstack.org/#/c/571821/
* tempest test: https://review.openstack.org/#/c/586719/
* OSC: https://review.openstack.org/#/c/586684/
* neutronclient: https://review.openstack.org/#/c/586712/

APIImpact Add 'propagate_uplink_status' attribute to 'port' resource

Change-Id: Ie8260c332e24c1880f9f82e6b6dacca8415be842
Close-Bug: #1722720
2018-11-29 19:33:16 +00:00
Bence Romsics d7d433f729 sriov-agent: Report resource info in heartbeat
Example config for sriov-agent:

sriov_agent.ini:
[sriov_nic]
physical_device_mappings = physnet0:ens5,physnet0:ens6
resource_provider_bandwidths = ens5:100000:100000,ens6:100000:100000

Agent configurations now includes 'resource_provider_bandwidths' and
'resource_provider_inventory_defaults'.

Change-Id: I1af798d404ed94cd30da3f92734bea911bbc3ac7
Co-Authored-By: Lajos Katona <lajos.katona@ericsson.com>
Depends-On: https://review.openstack.org/577220
Partial-Bug: #1578989
See-Also: https://review.openstack.org/502306 (nova spec)
See-Also: https://review.openstack.org/508149 (neutron spec)
2018-10-11 11:15:06 +02:00
Brian Haley eea5aaac4f Fix corner case in failure assigning MAC to SR-IOV NIC
Sometimes due to NIC driver incorrect behavior, VFs might be
missing in 'ip link show' output.  This may lead to a VM boot
failure as agent will just skip such missing devices.

Make the agent do a resync in case a newly added device
'disappears' during processing, which should cause a MAC to
get assigned.

Co-authored-by: Oleg Bondarev <obondarev@mirantis.com>

Change-Id: I148b5a025fc388821fd1269d02908cc8ce1882fe
Closes-bug: #1784484
2018-10-03 19:32:12 +00:00
Oleg Bondarev 6402cd37c9 SR-IOV agent should specify host when requesting devices info
Otherwise neutron server may set BUILD status for ports not bound
to agent's host.

Closes-Bug: #1702635
Change-Id: Ic0aa2b5d8fb5ad682293ce2b8e44606ef862a62d
2017-07-06 15:44:57 +04:00
Jenkins 9d8e28f2ea Merge "Reduce rpc calls in SR-IOV agent" 2017-04-18 12:55:18 +00:00
Edan David 02c16a0e60 Reduce rpc calls in SR-IOV agent
Use one update_port_list rpc call instead of
update_port_up/update_port_down for each device separately.

Closes-Bug: #1682979
Change-Id: I0a367712ff9410c2376b5b70c76806391bed3707
2017-04-15 01:24:49 +00:00
Boden R 7bd521e7ce use neutron_lib's portbindings api-def
Neutron-lib 1.1.0 is now out and contains the portbindings
API definition (as per commit [1]). This patch moves neutron
references over to the neutron-lib version.

NeutronLibImpact
- Consumers using the public constants within neutron's
portbindings API extension must now use the values
from neutron-lib.

[1] 87e42f993c07ae320159d5123662ee9f3bd4d903

Change-Id: I669af9b4c712877772d91a03857ab108714001d4
2017-03-31 09:16:22 -06:00
Kevin Benton 1a2a71baf3 SRIOV: don't block report_state with device count
The device count process can be quite slow on a system with
lots of interfaces. Doing this during report_state can block
it long enough that the agent will be reported as dead and
bindings will fail.

This adjusts the logic to only update the configuration during
the normal device retrieval for the scan loop. This will leave
the report_state loop unblocked by the operation so the agent
doesn't get reported as dead (which blocks port binding).

Closes-Bug: #1648206
Change-Id: Iff45fb6617974b1eceeed238a8d9e958f874f12b
2016-12-07 12:01:43 -08:00
Nate Johnston 01a6c9c426 Generalize agent extension mechanism
This change generalizes agent extension code so that all agents can take
advantage of a common mechanism.

Co-Authored-By: Margaret Frances <margaret_frances@cable.comcast.com>

Partially-Implements: blueprint l3-agent-extensions

Change-Id: I9380343c09d28eec67077c9e6d77c33a195e516b
2016-07-19 13:45:22 +00:00
Yalei Wang 7084fa8a17 Add network_update RPC into SR-IOV agent
SR-IOV agent doesn't listen for network_update notification, but it's
desired in QOS when network updated with a new QOS policy. This patch
adds it into this agent.

Change-Id: I06a7ca411da31bccabddec9c0adca6b8e6eab7cc
Closes-Bug: #1504166
2016-01-21 00:43:02 +08:00
Gary Kotton 49d25b3992 portbindings: use constants for extension keys
Use the constants defined in the portbindings extension.

TrivialFix

Change-Id: I90c3deeae9018d4e5b23283f64657d9f5d5723c7
2016-01-10 00:42:53 -08:00
Moshe Levi 66a91c6c38 SR-IOV agent: display loaded extensions
The SR-IOV agent support l2 agent extension due to
this patch https://review.openstack.org/#/c/210483/

This patch allow to show the loaded l2 agent extensions
when executing neutron agent-show <SR-IOV agent id>

Closes-Bug: #1527307
DocImpact update the agent configuration to show
          l2 agent extensions
Change-Id: I5dcb79ef539e4f18693e4a8eff03fff40873d3fa
2016-01-06 10:45:09 +02:00
Brent Eagles 2c60278992 Adding a VNIC type for physical functions
This change adds a new VNIC type to distinguish between virtual and
physical functions in SR-IOV.

The new VNIC type 'direct-physical' deviates from the behavior of
'direct' VNICs for virtual functions. While neutron tracks the resource
as a port, it does not currently perform any management functions.
Future changes may extend the segment mapping functionality that is
currently based on agent configuration to include direct types.
However, the direct-physical VNICs will not have functional parity with
the other SR-IOV VNIC types in that quality of service and port security
functionality is not available.

APIImpact
DocImpact: Add description for new 'direct-physical' VNIC type.

Closes-Bug: #1500993

Change-Id: If1ab969c2002c649a3d51635ca2765c262e2d37f
2015-12-14 10:02:40 -03:30
Jenkins d8cfee987d Merge "sriov: update port state even if ip link fails" 2015-09-09 18:16:31 +00:00
Moshe Levi 13901bdf69 Qos SR-IOV: Refactor extension delete to get mac and pci slot
When calling delete we need the pci slot details to reset the VF rate. The problem
is that when the VM is deleted libvirt return the VF to the hypervisor and eswitch
manager will mark the pci_slot as unassigned so can't know from the mac which pci slot (VF)
to reset. Also newer libvirt version reset the mac when deleteing VM, so than it is
not possible at all.
The solution is to keep pci slot details locally in the agent since upon removal event
you cannot get pci_slot from the neutron server as it is for create/update since port
is already removed from neutron.

This patch pairs the mac and pci_slot for a device (VF) so when calling the extension
port delete api we can have the pci_slot and reset the VF rate.

It is also add a mapping between mac to port_id so we can pass the port_id
when calling the extention port delete api.

Partially-Implements: blueprint ml2-sriov-qos-with-bwlimiting
Closes-Bug: #1492909
Change-Id: Icc3a9599c6d7a4de9c56b452dfab7909c8d0a576
2015-09-07 09:27:40 +03:00
Roman Bogorodskiy 9c466f4d0e sriov: update port state even if ip link fails
Some SRIOV drivers/devices don't support link state setting,
meaning that 'ip link' fails like this when trying to set state:

 # ip l set dev p2p1 vf 6 state disable
 RTNETLINK answers: Operation not supported

The sriov-nic-agent tries to do that in
SriovNicSwitchAgent.treat_device() and fails because of non-zero
exit status from 'ip link' and, therefore, doesn't reach the code
that updates the actual port status, so port could hang in a BUILD
state even if binding was successful.

This patch fixes problem of nova not being able to successfully bind
or cleanup such a port. It does not fix a case when user manually
updates admin_state_up for a port via API, it's subject to a separate
fix.

Also, replace LOG.exception with LOG.warning for set_device_state()
as the exception would be logged by PciDeviceIPWrapper.set_vf_state()
anyway.

Closes-bug: #1468332
Change-Id: Ifa7c128d369ced60b5986aa0ed92527868f7efab
2015-09-03 19:35:41 +02:00
Moshe Levi 995c35221b SR-IOV: Add Agent QoS driver to support bandwidth limit
This patch adds SR-IOV agent driver which uses eswitch manager to set VF
rate limit. It also updates the agent to call port_delete api of the
extension manager to cleanup when port is deleted.

Partially-Implements: blueprint ml2-sriov-qos-with-bwlimiting
Change-Id: I364fc8158e502d4dcc3510d6157f12969961a11d
2015-08-12 09:37:02 +00:00
Roman Bogorodskiy aa2236a8bf sriov: implement spoofchecking configuration
- Make sriov agent to set the spoofchecking on VFs
  according to port_security_enabled attribute of the port.
- Extend vf management sanity check to probe spoof checking
  capability

Implements: blueprint sriov-spoofchk
Change-Id: I4d1060be26ee6cbd7d766c2bde364f694533de69
2015-07-29 19:38:25 +02:00
Elena Ezhova 6e693fc91d Switch to oslo.service
oslo.service has graduated, so neutron should consume it.

Closes-Bug: #1466851
Depends-On: Ie0fd63f969f954029c3c3cf31337fbe38f59331a
Depends-On: I2093b37d411df9a26958fa50ff523c258bbe06ec
Depends-On: I4823d344878fc97e66ddd8fdae25c13a34dede40
Change-Id: I0155b3d8b72f6d031bf6f855488f80acebfc25d4
2015-06-29 13:20:55 +03:00
Kyle Mestery f242b171e9 Consolidate sriov agent and driver code
In preparation for decomposing the built-in reference implementation,
this commits consolidates the sriov agent and driver code into a
coherent place for it's life in the new repository. I've also given
the unit tests a new home.

DocImpact
UpgradeImpact

Partially-Implements: blueprint reference-implementation-split
Partial-Bug: #1468433
Closes-Bug: #1427317

Change-Id: Ic8b5215de76e191030228bc28773cd6535e889d8
Signed-off-by: Kyle Mestery <mestery@mestery.com>
2015-06-26 19:51:58 +00:00