fix(routes): give an FRR host route without a length /128 for IPv6

The FRR enrichment in get_route_to completed every prefix without a
length with /32. An IPv6 host route became a different, much larger
/32 prefix, so it missed the kernel's /128 entry for the same host
(stored that way since #6) and added a bogus one instead.

with_length() in _routes.py completes a prefix by its family, /32 or
/128. The protocol attributes move onto IpRoute, which keeps the import
in linux.py on one line; get_route_to shrinks and the baseline records
it.

Closes #64
This commit is contained in:
Christian Manivong committed 2026-11-02 08:48:39 +01:00
1 parent a1e8ec78c3
commit 9089429c2d
5 files changed
+62 -12

No files matched your search

+3 -5
View File
@@ -75,7 +75,7 @@ from napalm_linux._dpkg import DPKG_QUERY_COMMAND, parse_dpkg_query
from napalm_linux._hostname import HostnameMixin
from napalm_linux._local_accounts import LinuxLocalAccountsMixin
from napalm_linux._ping import parse_ping, ping_command
from napalm_linux._routes import IP_ROUTE_COMMANDS, IpRoute, parse_ip_route, route_attributes
from napalm_linux._routes import IP_ROUTE_COMMANDS, IpRoute, parse_ip_route, with_length
from napalm_linux._shell import expect_for, prepare_shell, sudo_without_password
from napalm_linux._sudo_history import LinuxSudoHistoryMixin
@@ -955,7 +955,7 @@ class LinuxDriver(
if protocol and mapped != protocol.lower():
return
entry = _make_entry(mapped, route.nexthop, route.iface, route.metric, route.network)
entry["protocol_attributes"] = route_attributes(route.route_type)
entry["protocol_attributes"] = route.attributes
routes.setdefault(route.network, []).append(entry)
for family, command in IP_ROUTE_COMMANDS.items():
@@ -989,12 +989,10 @@ class LinuxDriver(
if not vm:
continue
code = vm.group(1)
prefix = vm.group(2)
prefix = with_length(vm.group(2))
metric = int(vm.group(4))
nexthop = vm.group(5) or ""
iface = (vm.group(6) or "").rstrip(",")
if "/" not in prefix:
prefix += "/32"
mapped_proto = _frr_code.get(code, code.lower())
if prefix in routes:
for entry in routes[prefix]: