summaryrefslogtreecommitdiff
path: root/src/ipaddrcheck_functions.c
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2025-12-02 20:19:54 +0000
committerDaniil Baturin <daniil@baturin.org>2025-12-05 15:10:21 +0000
commit779b5be2a5d096eff2db3313c4ee502a3b593db8 (patch)
treee4366cdc7d5814bdc62bd5841f207b9fd77de7a3 /src/ipaddrcheck_functions.c
parentc34294b7a18072c7bd4eaf8ec0f433bb374fad5c (diff)
downloadipaddrcheck-779b5be2a5d096eff2db3313c4ee502a3b593db8.tar.gz
ipaddrcheck-779b5be2a5d096eff2db3313c4ee502a3b593db8.zip
T7973: do not disallow all-zero host part IPv6 host addresses
since they are valid unicast addresses, unlike in IPv4
Diffstat (limited to 'src/ipaddrcheck_functions.c')
-rw-r--r--src/ipaddrcheck_functions.c24
1 files changed, 5 insertions, 19 deletions
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;
}