longest prefix match
termnetworking
The routing rule that the most specific matching prefix wins: /32 beats /24 beats /0, regardless of protocol or metric.
The reason a leaked /25 can hijack traffic away from the legitimate /24.
When several routes could carry a packet, the router uses the most specific one, meaning the entry with the longest matching prefix regardless of the order rules appear or which protocol supplied them. That single rule is what makes a default route and a specific exception coexist without any explicit priority.
It is also the mechanism behind prefix hijacking. An autonomous system announcing a longer prefix than the legitimate holder wins on every router that accepts the announcement, because specificity beats legitimacy in the forwarding decision. Nothing in the algorithm asks whether the announcer is entitled to the address space, which is exactly the gap RPKI was built to close.