Incorrectly passing ext_ips as gw_ips after creating router gateway

Bug #1796629 reported by ChenjieXu
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Medium
ChenjieXu

Bug Description

In neutron/db/l3_db.py, function _create_gw_port will send an event after creating router gateway as following:

registry.notify(resources.ROUTER_GATEWAY,
                events.AFTER_CREATE,
                self._create_gw_port,
                context=context,
                gw_ips=ext_ips,
                network_id=new_network_id,
                router_id=router_id)

However the ext_ips is sent out while gw_ips is expected.

ext_ips: external_fixed_ips
gw_ips: gateway_ips
(Ps: gw_ips = [x['ip_address'] for x in router.gw_port.fixed_ips])
Example:
ext_ips = [{"subnet_id": "966eff11-909d-4b6c-8d5f-4505e8a8c15f",
            "ip_address": "192.168.1.200"},
           {"subnet_id": "f2dee576-7535-40ee-a5ba-d5dae8e1f600",
            "ip_address": "2001:db8::d"}]
gw_ips = ['192.168.1.200', '2001:db8::d']

bgp_plugin(neutron_dynamic_routing\services\bgp\bgp_plugin.py) in the project neutron-dynamic-routing will subscribe the topic and process the event. Function _register_callbacks in bgp_plugin will subscribe the topic after creating router gateway as following:

registry.subscribe(self.router_gateway_callback,
                           resources.ROUTER_GATEWAY,
                           events.AFTER_CREATE)

Function _next_hops_from_gateway_ips in bgp_plugin will process the gw_ips finally as following:

if gw_ips:
    return {IPAddress(ip).version: ip for ip in gw_ips}
return {}

If the ext_ips are sent as gw_ips, then function _next_hops_from_gateway_ips can’t process it. “TypeError: unhashable type: 'dict'” will occur.
Remember that ext_ips and gw_ips looks like following:
ext_ips = [{"subnet_id": "966eff11-909d-4b6c-8d5f-4505e8a8c15f",
            "ip_address": "192.168.1.200"},
           {"subnet_id": "f2dee576-7535-40ee-a5ba-d5dae8e1f600",
            "ip_address": "2001:db8::d"}]
gw_ips = ['192.168.1.200', '2001:db8::d']

ChenjieXu (midone)
Changed in neutron:
assignee: nobody → ChenjieXu (midone)
Changed in neutron:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

Fix proposed to branch: master
Review: https://review.openstack.org/608608

Changed in neutron:
status: Confirmed → In Progress
Revision history for this message
Ryan Tidwell (ryan-tidwell) wrote :

I'm trying to reproduce this behavior so I can test with and without the proposed fix and can't seem to reproduce. I also don't see these error messages showing up in logs for CI jobs like I would expect to. Do you have a sequence of operations you perform with neutron-dynamic-routing that reproduces the behavior reported here? I'm surprised this is just now being reported and changed.

Revision history for this message
Ryan Tidwell (ryan-tidwell) wrote :

I figured out why I'm not able to reproduce this. After inserting some debug statements in the BGP callback handlers, I found that setting the gateway on a router results in a notification payload that has an empty gw_ips list for some reason. *If* I was to be getting some actual values for a payload I would have seen the TypeError reported here. I'm still curious about the sequence of operations that massages out the TypeError being reported. The question of the empty gw_ips is still a mystery, but not one caused by this.

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

Reviewed: https://review.openstack.org/608608
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=221f386029faf499c5a445374685cba5b67df31e
Submitter: Zuul
Branch: master

commit 221f386029faf499c5a445374685cba5b67df31e
Author: mid_one <email address hidden>
Date: Tue Oct 9 01:19:51 2018 +0800

    Fix incorrectly passing ext_ips as gateway ips

    An event will be sent out after creating
    router gateway. Within the event, ext_ips
    is sent incorrectly while gw_ips is expected.
    Project neutron-dynamic-routing subscribes
    the topic and will process the event. But
    it can't process ext_ips.

    This commit gets the gw_ips through the
    ext_ips and sends gw_ips out.

    Co-Authored-By: Allain Legacy<email address hidden>

    Change-Id: I9b67b58e87faa9cbb8ed4cd03c74f467ca20d73f
    Closes-Bug: #1796629

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

This issue was fixed in the openstack/neutron 14.0.0.0b1 development milestone.

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.