openinfrastructure / terraform-google-multinic

Connect two VPC networks with an auto-healing, auto-scaling group of IP router instances.
Apache License 2.0
10 stars 5 forks source link

Fix Error: Invalid prefix for given prefix length #36

Closed jeffmccune closed 3 years ago

jeffmccune commented 3 years ago

This patch fixes the error caused by using the IP address instead of the network address when replacing routes. The error doesn't affect the behavior of the system, but it is confusing and a red-herring when troubleshooting other issues. The set -x is intentionally left in to help troubleshoot any future issues, the commands are displayed in the console and journal in-line with the commands generating the output.

See: Issue 28 for more details and debug logs.

Resolves: #28

jeffmccune commented 3 years ago

This fixes it:

Correct behavior (3.2.1)

[jeff@multinic-g67p ~]$ sudo journalctl -xu policy-routing.service
-- Logs begin at Thu 2020-12-24 02:52:39 UTC, end at Thu 2020-12-24 02:56:47 UTC. --
Dec 24 02:52:58 multinic-g67p systemd[1]: Starting Configure Policy Routing to behave as a virtual wire...
-- Subject: Unit policy-routing.service has begun start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit policy-routing.service has begun starting up.
Dec 24 02:52:59 multinic-g67p policy-routing[1672]: + ip route replace default via 10.33.0.1 dev eth0 proto static table viaeth0
Dec 24 02:52:59 multinic-g67p policy-routing[1672]: + ip route replace 10.33.0.1 dev eth0 proto static scope link table viaeth0
Dec 24 02:52:59 multinic-g67p policy-routing[1672]: + ip route replace 10.37.0.1 dev eth1 proto static scope link table viaeth0
Dec 24 02:52:59 multinic-g67p policy-routing[1672]: + ip route replace 10.33.0.0/20 via 10.33.0.1 dev eth0 proto static table viaeth0
Dec 24 02:52:59 multinic-g67p policy-routing[1672]: + ip route replace 10.37.0.0/20 via 10.37.0.1 dev eth1 proto static table viaeth0
Dec 24 02:52:59 multinic-g67p policy-routing[1672]: + ip route replace default via 10.37.0.1 dev eth1 proto static table viaeth1
Dec 24 02:52:59 multinic-g67p policy-routing[1672]: + ip route replace 10.33.0.1 dev eth0 proto static scope link table viaeth1
Dec 24 02:52:59 multinic-g67p policy-routing[1672]: + ip route replace 10.37.0.1 dev eth1 proto static scope link table viaeth1
Dec 24 02:52:59 multinic-g67p policy-routing[1672]: + ip route replace 10.33.0.0/20 via 10.33.0.1 dev eth0 proto static table viaeth1
Dec 24 02:52:59 multinic-g67p policy-routing[1672]: + ip route replace 10.37.0.0/20 via 10.37.0.1 dev eth1 proto static table viaeth1
Dec 24 02:52:59 multinic-g67p policy-routing[1672]: + ip rule add priority 1000 from 10.33.0.0/20 iif lo table viaeth0
Dec 24 02:52:59 multinic-g67p policy-routing[1672]: + ip rule add priority 1001 from 10.37.0.0/20 iif lo table viaeth1
Dec 24 02:52:59 multinic-g67p policy-routing[1672]: + ip rule add priority 1002 iif eth0 table viaeth1
Dec 24 02:52:59 multinic-g67p policy-routing[1672]: + ip rule add priority 1003 iif eth1 table viaeth0
Dec 24 02:52:59 multinic-g67p policy-routing[1672]: + ip route flush cache
Dec 24 02:52:59 multinic-g67p systemd[1]: Started Configure Policy Routing to behave as a virtual wire.
-- Subject: Unit policy-routing.service has finished start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit policy-routing.service has finished starting up.
--
-- The start-up result is done.

Incorrect behavior (3.2.0)

[jeff@multinic-phk3 ~]$ sudo journalctl -xu policy-routing
-- Logs begin at Thu 2020-12-24 02:35:17 UTC, end at Thu 2020-12-24 02:36:12 UTC. --
Dec 24 02:35:36 multinic-phk3 systemd[1]: Starting Configure Policy Routing to behave as a virtual wire...
-- Subject: Unit policy-routing.service has begun start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit policy-routing.service has begun starting up.
Dec 24 02:35:36 multinic-phk3 policy-routing[1635]: + grep -qx '10 viaeth0' /etc/iproute2/rt_tables
Dec 24 02:35:36 multinic-phk3 policy-routing[1635]: + echo '10 viaeth0'
Dec 24 02:35:36 multinic-phk3 policy-routing[1635]: + grep -qx '11 viaeth1' /etc/iproute2/rt_tables
Dec 24 02:35:36 multinic-phk3 policy-routing[1635]: + echo '11 viaeth1'
Dec 24 02:35:36 multinic-phk3 policy-routing[1635]: + ip route replace default via 10.33.0.1 dev eth0 proto static table viaeth0
Dec 24 02:35:37 multinic-phk3 policy-routing[1635]: + ip route replace 10.33.0.1 dev eth0 proto static scope link table viaeth0
Dec 24 02:35:37 multinic-phk3 policy-routing[1635]: + ip route replace 10.37.0.1 dev eth1 proto static scope link table viaeth0
Dec 24 02:35:37 multinic-phk3 policy-routing[1635]: + ip route replace 10.33.0.25/20 via 10.33.0.1 dev eth0 proto static table viaeth0
Dec 24 02:35:37 multinic-phk3 policy-routing[1635]: Error: Invalid prefix for given prefix length.
Dec 24 02:35:37 multinic-phk3 policy-routing[1635]: + ip route replace 10.37.0.25/20 via 10.37.0.1 dev eth1 proto static table viaeth0
Dec 24 02:35:37 multinic-phk3 policy-routing[1635]: Error: Invalid prefix for given prefix length.
Dec 24 02:35:37 multinic-phk3 policy-routing[1635]: + ip route replace default via 10.37.0.1 dev eth1 proto static table viaeth1
Dec 24 02:35:37 multinic-phk3 policy-routing[1635]: + ip route replace 10.33.0.1 dev eth0 proto static scope link table viaeth1
Dec 24 02:35:37 multinic-phk3 policy-routing[1635]: + ip route replace 10.37.0.1 dev eth1 proto static scope link table viaeth1
Dec 24 02:35:37 multinic-phk3 policy-routing[1635]: + ip route replace 10.33.0.25/20 via 10.33.0.1 dev eth0 proto static table viaeth1
Dec 24 02:35:37 multinic-phk3 policy-routing[1635]: Error: Invalid prefix for given prefix length.
Dec 24 02:35:37 multinic-phk3 policy-routing[1635]: + ip route replace 10.37.0.25/20 via 10.37.0.1 dev eth1 proto static table viaeth1
Dec 24 02:35:37 multinic-phk3 policy-routing[1635]: Error: Invalid prefix for given prefix length.
Dec 24 02:35:37 multinic-phk3 policy-routing[1635]: + ip rule add priority 1000 from 10.33.0.25/20 iif lo table viaeth0
Dec 24 02:35:37 multinic-phk3 policy-routing[1635]: + ip rule add priority 1001 from 10.37.0.25/20 iif lo table viaeth1
Dec 24 02:35:37 multinic-phk3 policy-routing[1635]: + ip rule add priority 1002 iif eth0 table viaeth1
Dec 24 02:35:37 multinic-phk3 policy-routing[1635]: + ip rule add priority 1003 iif eth1 table viaeth0
Dec 24 02:35:37 multinic-phk3 policy-routing[1635]: + ip route flush cache
Dec 24 02:35:37 multinic-phk3 systemd[1]: Started Configure Policy Routing to behave as a virtual wire.
-- Subject: Unit policy-routing.service has finished start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit policy-routing.service has finished starting up.
--
-- The start-up result is done.