subnet's gateway ip can be unset while attached to router
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
neutron |
Fix Released
|
Medium
|
Rodolfo Alonso |
Bug Description
Hello
There's a weird issue with a subnet's gateway ip when it's attached to a router.
Normally, when you try to attach a subnet to a router, this subnet needs to have a gateway ip set. Otherwise the attachment will fail.
So we expect the subnet attached to a router to always have a gateway ip - this is used for creating the router interface after all.
However, when you attach a subnet with a gateway ip to a router and then attempt to unset this gateway ip... you can do that. There's no error, there's no connectivity lost, nothing is deleted. The router interface is still listed under "router show", the port exists, the connectivity is still working fine, as if nothing happened. But when you "subnet show", you can see the gateway ip is None.
This will result in error logs whenever the code tries to process certain things related to the router. Restarting the L3 agent will result in these errors, for example.
file: neutron/
method: get_subnet_
file: neutron/
method: _bind_centraliz
A user shouldn't be allowed to unset the gateway ip from a subnet that's already attached to a router. If they can't add a gateway-less subnet to a router, they shouldn't be allowed to unset it after the fact as well.
Tested on Stein and quickly checked if the behaviour still exists on Master.
To reproduce:
- Create a router
openstack router create r1
- Create a network with a subnet with gateway ip set (default behaviour)
openstack network create n1
openstack subnet create --subnet-range <blabla> --network n1 s1
- Add subnet to the router
openstack router add subnet r1 s1
- Unset the gateway ip from the subnet
openstack subnet set --gateway None s1
The gateway ip on the subnet will be listed as None, the router will still have the interface existing, the port will stil exist, all connectivity will remain intact, certain actions and agent restarts will trigger error logs.
tags: |
added: l3-dvr-backlog removed: gateway gateway-ip router subnet unset |
So there are a couple of things here.
1) Changing the gateway_ip of a subnet to None is valid as far as I know, it looks like the second sentence in the API doc is just a copy from the POST section, so should be removed.
"Gateway IP of this subnet. If the value is null that implies no gateway is associated with the subnet. If the gateway_ip is not specified, OpenStack Networking allocates an address from the CIDR for the gateway for the subnet by default."
And any instance booted that received DHCP info with that router as the gateway should continue to function.
2) Setting the gateway_ip to None won't remove the router interface, since in theory you could just be changing it to the interface of another router.
3) I didn't see the error/warning you mentioned in my quick testing when I restarted the l3-agent, so some more help would be required.
This isn't to say there's not a bug here, just that initial triage didn't reproduce it.