diff options
| author | Jon Maloy <jmaloy@redhat.com> | 2026-03-09 15:52:33 -0400 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2026-03-10 15:28:11 +0100 |
| commit | 251e676bd0bffe0c3b8bf0e925fbc87b6d4eeb6a (patch) | |
| tree | 9f9712de3e1877c1ac472a1420c9fe6b42b64dce | |
| parent | 045560c20a45a452ca1ed79b15fb01d9da5421e4 (diff) | |
| download | passt-251e676bd0bffe0c3b8bf0e925fbc87b6d4eeb6a.tar passt-251e676bd0bffe0c3b8bf0e925fbc87b6d4eeb6a.tar.gz passt-251e676bd0bffe0c3b8bf0e925fbc87b6d4eeb6a.tar.bz2 passt-251e676bd0bffe0c3b8bf0e925fbc87b6d4eeb6a.tar.lz passt-251e676bd0bffe0c3b8bf0e925fbc87b6d4eeb6a.tar.xz passt-251e676bd0bffe0c3b8bf0e925fbc87b6d4eeb6a.tar.zst passt-251e676bd0bffe0c3b8bf0e925fbc87b6d4eeb6a.zip | |
nl_addr_get() was not setting the prefix_len output parameter for
IPv6 addresses, only for IPv4. This meant callers always got 0 for
IPv6, forcing them to use a hardcoded default (64).
Fix by assigning *prefix_len even in the IPv6 case.
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
| -rw-r--r-- | netlink.c | 11 |
1 files changed, 3 insertions, 8 deletions
@@ -752,7 +752,7 @@ int nl_addr_set_ll_nodad(int s, unsigned int ifi) * @ifi: Interface index in outer network namespace * @af: Address family * @addr: Global address to fill - * @prefix_len: Mask or prefix length, to fill (for IPv4) + * @prefix_len: Mask or prefix length, to fill * @addr_l: Link-scoped address to fill (for IPv6) * * Return: 0 on success, negative error code on failure @@ -788,16 +788,11 @@ int nl_addr_get(int s, unsigned int ifi, sa_family_t af, (af == AF_INET6 && rta->rta_type != IFA_ADDRESS)) continue; - if (af == AF_INET && ifa->ifa_prefixlen > prefix_max) { + if (ifa->ifa_prefixlen > prefix_max && + (af == AF_INET || ifa->ifa_scope < RT_SCOPE_LINK)) { memcpy(addr, RTA_DATA(rta), RTA_PAYLOAD(rta)); prefix_max = *prefix_len = ifa->ifa_prefixlen; - } else if (af == AF_INET6 && addr && - ifa->ifa_scope < RT_SCOPE_LINK && - ifa->ifa_prefixlen > prefix_max) { - memcpy(addr, RTA_DATA(rta), RTA_PAYLOAD(rta)); - - prefix_max = ifa->ifa_prefixlen; } if (addr_l && |
