Skip to content

Commit 2e23899

Browse files
committed
[SR-IOV] The port status=DOWN has precedence in the VF link status
If a ML2/SR-IOV port is disabled (status=DOWN), it will have precedence on the VF link state value over the "auto" value. That will stop any transmission from the VF. Closes-Bug: #2078789 Change-Id: I11d973d245dd391623e501aa14b470daa780b4db (cherry picked from commit 8211c29)
1 parent 33f1d27 commit 2e23899

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

neutron/plugins/ml2/drivers/mech_sriov/agent/pci_lib.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,14 @@ def set_vf_state(self, vf_index, state, auto=False):
7373
@param auto: set link_state to auto (0)
7474
"""
7575
ip = self.device(self.dev_name)
76-
if auto:
76+
# NOTE(ralonsoh): the state=False --> "disable" (2) has precedence over
77+
# "auto" (0) and "enable" (1).
78+
if state is False:
79+
link_state = 2
80+
elif auto:
7781
link_state = 0
7882
else:
79-
link_state = 1 if state else 2
83+
link_state = 1
8084
vf_config = {'vf': vf_index, 'link_state': link_state}
8185
ip.link.set_vf_feature(vf_config)
8286

neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/test_pci_lib.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,29 @@ def test_get_vf_state_not_present(self):
6767
self.assertEqual(pci_lib.LinkState.disable.name, result)
6868

6969
def test_set_vf_state(self):
70+
# state=True, auto=False --> link_state=enable
7071
self.pci_wrapper.set_vf_state(self.VF_INDEX, True)
7172
vf = {'vf': self.VF_INDEX, 'link_state': 1}
7273
self.mock_ip_device.link.set_vf_feature.assert_called_once_with(vf)
7374

75+
# state=False, auto=False --> link_state=disable
7476
self.mock_ip_device.link.set_vf_feature.reset_mock()
7577
self.pci_wrapper.set_vf_state(self.VF_INDEX, False)
7678
vf = {'vf': self.VF_INDEX, 'link_state': 2}
7779
self.mock_ip_device.link.set_vf_feature.assert_called_once_with(vf)
7880

81+
# state=True, auto=True --> link_state=auto
7982
self.mock_ip_device.link.set_vf_feature.reset_mock()
80-
self.pci_wrapper.set_vf_state(self.VF_INDEX, False, auto=True)
83+
self.pci_wrapper.set_vf_state(self.VF_INDEX, True, auto=True)
8184
vf = {'vf': self.VF_INDEX, 'link_state': 0}
8285
self.mock_ip_device.link.set_vf_feature.assert_called_once_with(vf)
8386

87+
# state=False, auto=True --> link_state=disable
88+
self.mock_ip_device.link.set_vf_feature.reset_mock()
89+
self.pci_wrapper.set_vf_state(self.VF_INDEX, False, auto=True)
90+
vf = {'vf': self.VF_INDEX, 'link_state': 2}
91+
self.mock_ip_device.link.set_vf_feature.assert_called_once_with(vf)
92+
8493
def test_set_vf_spoofcheck(self):
8594
self.pci_wrapper.set_vf_spoofcheck(self.VF_INDEX, True)
8695
vf = {'vf': self.VF_INDEX, 'spoofchk': 1}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
security:
3+
- |
4+
A ML2/SR-IOV port with status=DOWN will always set the VF link state to
5+
"disable", regardless of the ``propagate_uplink_status`` port field value.
6+
The port disabling, to stop any transmission, has precedence over the
7+
link state "auto" value.

0 commit comments

Comments
 (0)