1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

Merge pull request #29981 from yuwata/network-dhcp6-pd-without-address

network: fix DHCPv6-PD without addressing
This commit is contained in:
Luca Boccassi 2023-11-10 22:04:25 +00:00 committed by GitHub
commit efe4303b5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 19 deletions

View File

@ -665,7 +665,8 @@ static int dhcp_request_unreachable_route(
NetworkConfigSource source,
const union in_addr_union *server_address,
unsigned *counter,
route_netlink_handler_t callback) {
route_netlink_handler_t callback,
bool *configured) {
_cleanup_(route_freep) Route *route = NULL;
Route *existing;
@ -677,6 +678,7 @@ static int dhcp_request_unreachable_route(
assert(server_address);
assert(counter);
assert(callback);
assert(configured);
if (prefixlen >= 64) {
log_link_debug(link, "Not adding a blocking route for DHCP delegated prefix %s since the prefix has length >= 64.",
@ -699,7 +701,7 @@ static int dhcp_request_unreachable_route(
route->lifetime_usec = lifetime_usec;
if (route_get(link->manager, NULL, route, &existing) < 0)
link->dhcp6_configured = false;
*configured = false;
else
route_unmark(existing);
@ -720,7 +722,8 @@ static int dhcp4_request_unreachable_route(
return dhcp_request_unreachable_route(link, addr, prefixlen, lifetime_usec,
NETWORK_CONFIG_SOURCE_DHCP4, server_address,
&link->dhcp4_messages, dhcp4_unreachable_route_handler);
&link->dhcp4_messages, dhcp4_unreachable_route_handler,
&link->dhcp4_configured);
}
static int dhcp6_request_unreachable_route(
@ -732,7 +735,8 @@ static int dhcp6_request_unreachable_route(
return dhcp_request_unreachable_route(link, addr, prefixlen, lifetime_usec,
NETWORK_CONFIG_SOURCE_DHCP6, server_address,
&link->dhcp6_messages, dhcp6_unreachable_route_handler);
&link->dhcp6_messages, dhcp6_unreachable_route_handler,
&link->dhcp6_configured);
}
static int dhcp_pd_prefix_add(Link *link, const struct in6_addr *prefix, uint8_t prefixlen) {

View File

@ -96,27 +96,20 @@ static int dhcp6_address_ready_callback(Address *address) {
}
int dhcp6_check_ready(Link *link) {
bool has_ready = false;
Address *address;
int r;
assert(link);
assert(link->network);
if (link->dhcp6_messages > 0) {
log_link_debug(link, "%s(): DHCPv6 addresses and routes are not set.", __func__);
return 0;
}
SET_FOREACH(address, link->addresses) {
if (address->source != NETWORK_CONFIG_SOURCE_DHCP6)
continue;
if (address_is_ready(address)) {
has_ready = true;
break;
}
}
if (link->network->dhcp6_use_address &&
!link_check_addresses_ready(link, NETWORK_CONFIG_SOURCE_DHCP6)) {
Address *address;
if (!has_ready) {
SET_FOREACH(address, link->addresses)
if (address->source == NETWORK_CONFIG_SOURCE_DHCP6)
address->callback = dhcp6_address_ready_callback;

View File

@ -127,7 +127,7 @@ typedef struct Link {
sd_dhcp_lease *dhcp_lease;
char *lease_file;
unsigned dhcp4_messages;
bool dhcp4_configured:1;
bool dhcp4_configured;
char *dhcp4_6rd_tunnel_name;
Hashmap *ipv4acd_by_address;

View File

@ -10,6 +10,7 @@ DHCPPrefixDelegation=yes
[DHCPv6]
WithoutRA=solicit
UseAddress=no
[DHCPPrefixDelegation]
UplinkInterface=:self
@ -17,3 +18,4 @@ SubnetId=10
Announce=no
Token=eui64
Token=::1a:2b:3c:4d
Assign=no

View File

@ -0,0 +1,6 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[DHCPv6]
UseAddress=yes
[DHCPPrefixDelegation]
Assign=yes

View File

@ -6086,7 +6086,8 @@ class NetworkdDHCPPDTests(unittest.TestCase, Utilities):
'11-dummy.netdev', '25-dhcp-pd-downstream-test1.network',
'25-dhcp-pd-downstream-dummy97.network',
'12-dummy.netdev', '25-dhcp-pd-downstream-dummy98.network',
'13-dummy.netdev', '25-dhcp-pd-downstream-dummy99.network')
'13-dummy.netdev', '25-dhcp-pd-downstream-dummy99.network',
copy_dropins=False)
self.setup_nftset('addr6', 'ipv6_addr')
self.setup_nftset('network6', 'ipv6_addr', 'flags interval;')
@ -6095,8 +6096,14 @@ class NetworkdDHCPPDTests(unittest.TestCase, Utilities):
start_networkd()
self.wait_online(['veth-peer:routable'])
start_isc_dhcpd(conf_file='isc-dhcpd-dhcp6pd.conf', ipv='-6')
self.wait_online(['veth99:routable', 'test1:routable', 'dummy98:routable', 'dummy99:degraded',
'veth97:routable', 'veth97-peer:routable', 'veth98:routable', 'veth98-peer:routable'])
self.wait_online(['veth99:degraded'])
# First, test UseAddress=no and Assign=no (issue #29979).
# Note, due to the bug #29701, this test must be done at first.
print('### ip -6 address show dev veth99 scope global')
output = check_output('ip -6 address show dev veth99 scope global')
print(output)
self.assertNotIn('inet6 3ffe:501:ffff', output)
# Check DBus assigned prefix information to veth99
prefixInfo = get_dhcp6_prefix('veth99')
@ -6114,6 +6121,11 @@ class NetworkdDHCPPDTests(unittest.TestCase, Utilities):
self.assertGreater(prefixInfo['PreferredLifetimeUSec'], 0)
self.assertGreater(prefixInfo['ValidLifetimeUSec'], 0)
copy_network_unit('25-dhcp6pd-upstream.network.d/with-address.conf')
networkctl_reload()
self.wait_online(['veth99:routable', 'test1:routable', 'dummy98:routable', 'dummy99:degraded',
'veth97:routable', 'veth97-peer:routable', 'veth98:routable', 'veth98-peer:routable'])
print('### ip -6 address show dev veth-peer scope global')
output = check_output('ip -6 address show dev veth-peer scope global')
print(output)