From 779b5be2a5d096eff2db3313c4ee502a3b593db8 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Tue, 2 Dec 2025 20:19:54 +0000 Subject: T7973: do not disallow all-zero host part IPv6 host addresses since they are valid unicast addresses, unlike in IPv4 --- src/ipaddrcheck_functions.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'src/ipaddrcheck_functions.c') diff --git a/src/ipaddrcheck_functions.c b/src/ipaddrcheck_functions.c index fb0e654..75d8eec 100644 --- a/src/ipaddrcheck_functions.c +++ b/src/ipaddrcheck_functions.c @@ -2,7 +2,7 @@ * ipaddrcheck_functions.c: IPv4/IPv6 validation functions for ipaddrcheck * * Copyright (C) 2013 Daniil Baturin - * Copyright (C) 2018-2024 VyOS maintainers and contributors + * Copyright (C) 2018-2025 VyOS maintainers and contributors * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -325,29 +325,15 @@ int is_ipv6(CIDR *address) return(result); } -/* Is it a correct IPv6 host address? */ +/* Is it a correct IPv6 host address? + Everything except the unspecified address is. + */ int is_ipv6_host(CIDR *address) { int result; - /* We reuse the same logic that prevents IPv4 network addresses - from being assigned to interfaces (address == network_address), - but the reason is slightly differnt. - - As per https://www.rfc-editor.org/rfc/rfc4291 section 2.6.1, - >[Subnet-Router anycast address] is syntactically - >the same as a unicast address for an interface on the link with the - >interface identifier set to zero. - - So, the first address of the subnet must not be used for link addresses, - even if the semantic reason is different. - There's absolutely nothing wrong with assigning the last address, though, - since there's no broadcast in IPv6. - */ - if( (cidr_get_proto(address) == CIDR_IPV6) && - ((cidr_equals(address, cidr_addr_network(address)) < 0) || - (cidr_get_pflen(address) >= 127)) ) + (cidr_equals(address, cidr_from_str(IPV6_UNSPECIFIED)) != 0) ) { result = RESULT_SUCCESS; } -- cgit v1.2.3