From 8dc31ec5f2db6e6ff5b2b4d4a27c239de5e12cfb Mon Sep 17 00:00:00 2001 From: LIU Yulong Date: Fri, 26 Oct 2018 19:40:15 +0800 Subject: [PATCH] Disable port number 0 for floating IP port_forwarding Floating IP port forwarding internal or external port number should not allow 0, otherwise you will get some ValueError exception in neutron server. Directly modify the floating-ip-port-forwarding extension to change the external_port and internal_port minimum value. Change-Id: Icb177932f6cf1262757b29cb9b997321704616b7 Closes-Bug: #1799150 --- .../api/definitions/floating_ip_port_forwarding.py | 6 ++++-- .../notes/disable-port-number-zero-2fb484a802f099a7.yaml | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/disable-port-number-zero-2fb484a802f099a7.yaml diff --git a/neutron_lib/api/definitions/floating_ip_port_forwarding.py b/neutron_lib/api/definitions/floating_ip_port_forwarding.py index cefc8ffd4..4ba6116b8 100644 --- a/neutron_lib/api/definitions/floating_ip_port_forwarding.py +++ b/neutron_lib/api/definitions/floating_ip_port_forwarding.py @@ -91,13 +91,15 @@ SUB_RESOURCE_ATTRIBUTE_MAP = { 'is_visible': False}, EXTERNAL_PORT: { 'allow_post': True, 'allow_put': True, - 'validate': {'type:port_range': None}, + 'convert_to': converters.convert_to_int, + 'validate': {'type:range': [1, 65535]}, 'is_visible': True, 'is_sort_key': True, 'is_filter': True}, INTERNAL_PORT: { 'allow_post': True, 'allow_put': True, - 'validate': {'type:port_range': None}, + 'convert_to': converters.convert_to_int, + 'validate': {'type:range': [1, 65535]}, 'is_visible': True}, INTERNAL_IP_ADDRESS: {'allow_post': True, 'allow_put': True, diff --git a/releasenotes/notes/disable-port-number-zero-2fb484a802f099a7.yaml b/releasenotes/notes/disable-port-number-zero-2fb484a802f099a7.yaml new file mode 100644 index 000000000..3e6a8f73b --- /dev/null +++ b/releasenotes/notes/disable-port-number-zero-2fb484a802f099a7.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + Neutron API should not allow user to set zero for floating IP port + forwarding internal or external port number. Directly modify the + floating-ip-port-forwarding extension to change external_port and + internal_port minimum value to 1. Then API and port forwarding object + will make consistent for these attributes.