Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

udhcpc hook creates duplicate routes #57

Open
reinierjh opened this issue Feb 2, 2022 · 5 comments
Open

udhcpc hook creates duplicate routes #57

reinierjh opened this issue Feb 2, 2022 · 5 comments
Labels
kind/bug Something isn't working

Comments

@reinierjh
Copy link
Contributor

I'm not sure if this problem is caused by my own change (restart service when failed) but.
After a few days, ip ro shows the routes to the IPTV interface multiple times.
In the script you check is the NAT rules are already there, but not for the routes.
10.10.0.33 via 10.10.56.1 dev iptv metric 305
10.10.0.33 via 10.10.56.1 dev iptv metric 306
10.10.0.33 via 10.10.56.1 dev iptv metric 307
185.24.175.0/24 via 10.10.56.1 dev iptv metric 305
185.41.48.0/24 via 10.10.56.1 dev iptv metric 305
185.41.48.0/24 via 10.10.56.1 dev iptv metric 306
Restarting the service removes the extra routes, but after a while they reappear.
Probably this is caused by the DHCP renewal.

@fabianishere
Copy link
Owner

It seems some routes are duplicated with different metrics. This could happen when the ifindex of an interface changes.
To test this hypothesis, in /usr/lib/udm-iptv/udhcpc.hook, could you add the following:

export PATH=/usr/bin:/bin:/usr/sbin:/sbin

# Use busybox if iproute2 is not installed
if ! command -v ip > /dev/null 2>&1; then
    alias ip="busybox ip"
fi

+export IF_METRIC=200

That should resolve the issue if my hypothesis is true.

@fabianishere fabianishere added the kind/bug Something isn't working label Feb 2, 2022
@reinierjh
Copy link
Contributor Author

reinierjh commented Feb 3, 2022

I tried the suggested change, and although the metric started again at 200, it just keeps adding duplicate routes.
10.10.0.33 via 10.10.56.1 dev iptv metric 200
10.10.0.33 via 10.10.56.1 dev iptv metric 201
10.10.0.33 via 10.10.56.1 dev iptv metric 202
185.24.175.0/24 via 10.10.56.1 dev iptv metric 200
185.41.48.0/24 via 10.10.56.1 dev iptv metric 200
185.41.48.0/24 via 10.10.56.1 dev iptv metric 201

@reinierjh
Copy link
Contributor Author

Almost 24 hours later, and this is stil the case. but because we start at 200 everytime the above stays the same 6 rows.
I try not to touch the router to see if something happens.

@fabianishere
Copy link
Owner

I guess your ISP sends the routes in different order when renewing the lease, causing a different metric in turn.

See

route_add $dest $gw $num && num=$(($num + 1))

@reinierjh
Copy link
Contributor Author

As far as i can see the routes only doulble. so no more than 2 routes to the same address exists.
When look in the .hook file:
for i in $router; do
if ! ip -4 route show | grep ^default | grep $i; then
routes
This should only execute route when the route is not found.
On my machine ip -4 route show | grep ^default returns nothing.
Although the routes are already there.

@fabianishere fabianishere changed the title Double routes are created after running the service for a while udhcpc hook creates duplicate routes Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants