With neutron port-update command, port-security can be disabled for a specific VMI. If there is an AAP (allowed-address-pair) still attached to this VMI, the AAP must be detached from the VMI first. However, sometimes neutron port-update can fail to disable port-security even after the AAP is removed.
Check port with neutron command. AAP is configured, and port-security is enabled:
user@test:~# neutron port-show 6fa6e520-c4a1-4701-bca0-50432b4ad618 +-----------------------+------------------------------------------------------------------------------------+ | Field | Value | +-----------------------+------------------------------------------------------------------------------------+ | admin_state_up | True | | allowed_address_pairs | {"ip_address": "192.168.0.254", "mac_address": null} | | binding:host_id | | | binding:vif_details | {"port_filter": true} | | binding:vif_type | vrouter | | binding:vnic_type | normal | | created_at | 2021-04-27T22:21:47.683413 | | device_id | | | device_owner | | | fixed_ips | {"subnet_id": "8ce06d86-5c3d-4dd4-b2f2-4962ed265ec6", "ip_address": "192.168.0.3"} | | id | 6fa6e520-c4a1-4701-bca0-50432b4ad618 | | mac_address | 02:6f:a6:e5:20:c4 | | name | demo-port | | network_id | 19a47c0e-6b40-4ff6-9e1a-8c7c21af4c8e | | port_security_enabled | True | | security_groups | d9f27355-0605-4570-a0ea-7f2840dde954 | | status | DOWN | | tenant_id | 82bef8d1534142c881563fc1a5362f7a | | updated_at | 2021-05-07T14:54:06.215001 | +-----------------------+------------------------------------------------------------------------------------+
Disable AAP and remove SG, no error reported:
root@c3215aio250:~# neutron port-update 6fa6e520-c4a1-4701-bca0-50432b4ad618 --no-allowed-address-pairs --no-security-groups Updated port: 6fa6e520-c4a1-4701-bca0-50432b4ad618
Check VMI again to confirm:
root@c3215aio250:~# neutron port-show 6fa6e520-c4a1-4701-bca0-50432b4ad618 +-----------------------+------------------------------------------------------------------------------------+ | Field | Value | +-----------------------+------------------------------------------------------------------------------------+ | admin_state_up | True | | allowed_address_pairs | | | binding:host_id | | | binding:vif_details | {"port_filter": true} | | binding:vif_type | vrouter | | binding:vnic_type | normal | | created_at | 2021-04-27T22:21:47.683413 | | device_id | | | device_owner | | | fixed_ips | {"subnet_id": "8ce06d86-5c3d-4dd4-b2f2-4962ed265ec6", "ip_address": "192.168.0.3"} | | id | 6fa6e520-c4a1-4701-bca0-50432b4ad618 | | mac_address | 02:6f:a6:e5:20:c4 | | name | demo-port | | network_id | 19a47c0e-6b40-4ff6-9e1a-8c7c21af4c8e | | port_security_enabled | True | | security_groups | | | status | DOWN | | tenant_id | 82bef8d1534142c881563fc1a5362f7a | | updated_at | 2021-05-07T14:54:57.774838 | +-----------------------+------------------------------------------------------------------------------------+
Disable port-security. It failed due to AAP even after AAP has been removed:
root@c3215aio250:~# neutron port-update 6fa6e520-c4a1-4701-bca0-50432b4ad618 --port_security_enabled=False Port Security must be enabled in order to have allowed address pairs on a port. Neutron server returns request_ids: ['req-4393a08a-98b3-49f4-b7b8-420adb96b00c']
The issue is caused by:
When neutron command with --no--allowed-address-pairs parameter is used to remove AAP, the neutron will send a request with field "allow_address_pairs: []" in its JSON data, then config API will set AAP field in VMI object as an empty list.
--no--allowed-address-pairs
"allow_address_pairs: []"
"virtual_machine_interface_allowed_address_pairs": { "allowed_address_pair": [] }
When Contrail GUI is used to remove AAP from VMI, Contrail Web UI will send a request with field "virtual_machine_interface_allowed_address_pairs : {}" in its JSON data, then config API will clear AAP list field in VMI object.
"virtual_machine_interface_allowed_address_pairs : {}"
"virtual_machine_interface_allowed_address_pairs": { }
Later, when "neutron port-update 6fa6e520-c4a1-4701-bca0-50432b4ad618 --port_security_enabled=False" command is executed, config API will check AAP list. Here, it only checked whether the AAP list exists but did not consider it could have an empty value. Thus, it will fail the request. Then Contrail API returns a 400 error to neutron.
"neutron port-update 6fa6e520-c4a1-4701-bca0-50432b4ad618 --port_security_enabled=False"
EäY@@É+ °ú °ú#ÙçÛpxa* ¾S¾OHTTP/1.1 400 Bad Request Content-Length: 51 Content-Type: text/html; charset=UTF-8 Date: Tue, 27 Apr 2021 22:44:40 GMT {"exception": "AddressPairAndPortSecurityRequired"}
The workaround to this issue is to remove AAP from contrail WebUI again. Then the neutron command will be executed successfully.