Fix for https://bugs.launchpad.net/neutron/+bug/1338447. Back port of patch https://review.openstack.org/#/c/108892/ to stable/icehouse branch.