creating ipv6 subnet with invalid gateway results in HttpException: 500

Bug #1807394 reported by Vlad Gridin
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Low
Vlad Gridin

Bug Description

[description]

Attempt to create an ipv6 subnet with a gateway address including prefix
results in 500 error returned by API.
Neutron-lib convert_ip_to_canonical_format [1] does not handle ValueError from netaddr.IPAddress

https://github.com/openstack/neutron-lib/blob/master/neutron_lib/api/converters.py#L214

[reproduceable]

always

[environment]

devstack all-in-one

[reproduction steps]

1. create a network
~/devstack$ openstack network create net1
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-12-07T13:10:55Z |
| description | |
| dns_domain | None |
| id | 47660b84-2511-4817-b08c-74a89e7ef3c9 |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| location | None |
| mtu | 1450 |
| name | net1 |
| port_security_enabled | True |
| project_id | d6023de2edcd48608cf040993889e26c |
| provider:network_type | vxlan |
| provider:physical_network | None |
| provider:segmentation_id | 61 |
| qos_policy_id | None |
| revision_number | 1 |
| router:external | Internal |
| segments | None |
| shared | False |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2018-12-07T13:10:56Z |
+---------------------------+--------------------------------------+

2. create a subnet

~/devstack$ openstack subnet create --network net1 --ip-version 6 --subnet-range 2001:db8:0:1::/64 --gateway 2001:db8:0:1:1:1:1:1/128 subnet1
HttpException: 500: Server Error for url: https://10.30.19.81:9696/v2.0/subnets, Request Failed: internal server error while processing your request.

[expected result]

BadRequest Exception

[perceived severity]

low

Changed in neutron:
assignee: nobody → Vlad Gridin (vladyslav-gridin)
status: New → In Progress
Revision history for this message
Vlad Gridin (vladyslav-gridin) wrote :
Revision history for this message
Rodolfo Alonso (rodolfo-alonso-hernandez) wrote :

Hello Vlad:

I don't think this is a CLI error, but a user input error. If you review the documentation [1], three options are available for "gateway" parameter:
- IP address.
- "auto".
- "none".

A CIDR is not a valid input as a gateway parameter.

[1] https://docs.openstack.org/python-openstackclient/rocky/cli/command-objects/subnet.html

Revision history for this message
Bence Romsics (bence-romsics) wrote :

Rodolfo: As I read Vlad's report (especially the expected result part) I think he wants to see a 400 Bad Request instead of a 500 Internal Server Error. That seems valid to me.

Changed in neutron:
status: In Progress → Confirmed
importance: Undecided → Low
Revision history for this message
Vlad Gridin (vladyslav-gridin) wrote :

Exactly, I do realize it is a invalid input. Returning Internal Server Error
by API is the part i am not happy with.

Revision history for this message
Vlad Gridin (vladyslav-gridin) wrote :

fwiw, same request with the fix above applied produces:

$ openstack subnet create --network net1 --ip-version 6 --subnet-range 2001:db8:0:1::/64 --gateway 2001:db8:0:1:1:1:1:1/128 subnet1
BadRequestException: 400: Client Error for url: https://10.30.19.81:9696/v2.0/subnets, Invalid input for gateway_ip. Reason: '2001:db8:0:1:1:1:1:1/128' is not a valid IP address.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to neutron (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/623573

Changed in neutron:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron-lib (master)

Reviewed: https://review.openstack.org/623498
Committed: https://git.openstack.org/cgit/openstack/neutron-lib/commit/?id=532b398b90fff1b224086b4eb52ac9ef7412a0f4
Submitter: Zuul
Branch: master

commit 532b398b90fff1b224086b4eb52ac9ef7412a0f4
Author: Vlad Gridin <email address hidden>
Date: Fri Dec 7 15:20:44 2018 +0100

    Handle ValueError in canonical address convertion

    netaddr.IPAddress raises ValueError for some unsupported
    address formats. This patch will catch this exception
    in addition to AddrFormatError.

    Closes-Bug: 1807394

    Change-Id: I06eea42906f1fe4443fa4959e79a1993a9664efe

Changed in neutron:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron-lib 1.22.0

This issue was fixed in the openstack/neutron-lib 1.22.0 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to neutron (master)

Reviewed: https://review.openstack.org/623573
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=98ef2ac8d6e75c56512d11377e3b9f9cadf7fe53
Submitter: Zuul
Branch: master

commit 98ef2ac8d6e75c56512d11377e3b9f9cadf7fe53
Author: Brian Haley <email address hidden>
Date: Fri Dec 7 15:01:00 2018 -0500

    Add some create subnet negative tests

    There were some edge cases that were untested that generate
    500 errors instead of 401's.

    Will need a neutron-lib version with
    https://review.openstack.org/#/c/623498/ in order to pass.

    Change-Id: I925476bc2515a1755364d92ab8d622d747a4a0fb
    Related-bug: #1807394

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.