Issue with getting routes via DHCP

Today i decided to update my tl-wdr4300 from an old build (version 17 something) to a more recent one. When updating I reset the configs as usual. After the update finished I setup the wan mac address and was surprised when I got no internet connection.
The router did get an IP and dns from the isp, but every attempt to make connections resulted in "host unreachable". I checked the routing table and discovered that the default route was missing. Firstly I attempted to manually add the route via the 'route add', but was met with "network unreachable" even though the gateway that i specified was in fact reachable and in the same subnet as the router's wan address.
After some hours of trying to figure out what was different between the versions I found that the older versions didn't just add the default route, but also the route to the gateway. Trying that manually confirmed that that was the issue.
After digging some more i found commit 012d20eebe3aec0818aa949eb7b14754640df797 on the openwrt repo to the dhcp script. Reverting the changes and rebooting fixed the issue.

Currently my router works perfectly, but I still have several questions:

1.Why did the 'route add' command say that the network was unreachable when router's ip was in the same subnet as the gateway?
2.What is the purpose of the change in that commit? Yes I've read the commit description, but I still don't really get it.
3.What can be done to avoid this issue in the future?

Some information about my network:

Router is connected to the isp's switch via a cat5 cable
Routing table right after the install (edited for privacy)
My ip is x.y.252.167 (public ip that i get via dhcp) , so it is in the same subnet as the gateway (x.y.252.129)
Routing table after I reverted the dhcp.script changes

One more thing is that the traceroute to the gateway returns a local ip. Probably something related to my issue:

traceroute to x.y.252.129 (x.y.252.129), 30 hops max, 38 byte packets
 1  0.763 ms