Fix nexthop error when adding route to PUBLIC_SUBNET_IP

The `stack` script has been consistently failing with:

```
Error: Nexthop has invalid gateway.
```

when it comes time to add a route to $PUBLIC_SUBNET_IP [1].

One solution to this is to add the `onlink` flag [2] to the link
mentioned above:

```
onlink pretend that the nexthop is directly attached to
       this link, even if it does not match any interface
       prefix.
```

[1] daf856cd2d/devstack/lib/ironic (L2583)
[2] https://man7.org/linux/man-pages/man8/ip-route.8.html

Change-Id: Ia6363e6b68de344dd82106077efff86143e63d39
Signed-off-by: Luan Utimura <luan.utimura@luizalabs.com>
This commit is contained in:
Luan Utimura
2025-09-09 13:44:38 -03:00
parent 5a33e8dbe7
commit 9375f3bd6c

View File

@@ -2580,7 +2580,8 @@ SUBSHELL
# behind it, should also just generally work.
PUBLIC_SUBNET_ID=$(openstack router show $Q_ROUTER_NAME -c external_gateway_info -f json | jq -r .external_gateway_info.external_fixed_ips[0].subnet_id)
# Add a route for dhcp-less return path traffic
sudo ip route add 10.0.6.0/24 via $PUBLIC_SUBNET_IP
PUBLIC_SUBNET_DEV=$(ip -j route get $PUBLIC_SUBNET_IP | jq -r '.[0].dev')
sudo ip route add 10.0.6.0/24 via $PUBLIC_SUBNET_IP dev $PUBLIC_SUBNET_DEV onlink
if [[ "${IRONIC_NETWORK_SIMULATOR:-ovs}" != "ovs" ]]; then
create_network_simulator