diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-02-21 06:08:57 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-04-22 11:41:37 +0200 |
commit | 59d475ba4088beea4c0c7fce30e2af85904443af (patch) | |
tree | 86b34877f2ba47635b2a55c8d0ad3507291eac1a | |
parent | sd-radv: allow to configure reachable time in RA header (diff) | |
download | systemd-59d475ba4088beea4c0c7fce30e2af85904443af.tar.xz systemd-59d475ba4088beea4c0c7fce30e2af85904443af.zip |
network/radv: introduce ReachableTimeSec= setting
To make the reachable time in the RA header sent by networkd
configurable.
-rw-r--r-- | man/systemd.network.xml | 13 | ||||
-rw-r--r-- | src/libsystemd-network/radv-internal.h | 6 | ||||
-rw-r--r-- | src/network/networkd-network-gperf.gperf | 3 | ||||
-rw-r--r-- | src/network/networkd-network.h | 1 | ||||
-rw-r--r-- | src/network/networkd-radv.c | 14 | ||||
-rw-r--r-- | src/network/networkd-radv.h | 2 |
6 files changed, 30 insertions, 9 deletions
diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 916eb5bffe..8d7aa2127a 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -4018,6 +4018,19 @@ ServerAddress=192.168.0.1/24</programlisting> </varlistentry> <varlistentry> + <term><varname>ReachableTimeSec=</varname></term> + + <listitem> + <para>Configures the time, used in the Neighbor Unreachability Detection algorithm, for which + clients can assume a neighbor is reachable after having received a reachability confirmation. Takes + a time span in the range 0…4294967295 ms. When 0, clients will handle it as if the value wasn't + specified. Defaults to 0.</para> + + <xi:include href="version-info.xml" xpointer="v256"/> + </listitem> + </varlistentry> + + <varlistentry> <term><varname>RetransmitSec=</varname></term> <listitem><para>Takes a timespan. Configures the retransmit time, used by clients to retransmit Neighbor diff --git a/src/libsystemd-network/radv-internal.h b/src/libsystemd-network/radv-internal.h index cc64630d2e..0a535ddf4b 100644 --- a/src/libsystemd-network/radv-internal.h +++ b/src/libsystemd-network/radv-internal.h @@ -43,9 +43,11 @@ #define RADV_MAX_ROUTER_LIFETIME_USEC (9000 * USEC_PER_SEC) #define RADV_DEFAULT_ROUTER_LIFETIME_USEC (3 * RADV_DEFAULT_MAX_TIMEOUT_USEC) /* RFC 4861 section 4.2. - * Retrans Timer + * Reachable Time and Retrans Timer * 32-bit unsigned integer. The time, in milliseconds. */ -#define RADV_MAX_RETRANSMIT_USEC (UINT32_MAX * USEC_PER_MSEC) +#define RADV_MAX_UINT32_MSEC_USEC (UINT32_MAX * USEC_PER_MSEC) +#define RADV_MAX_REACHABLE_TIME_USEC RADV_MAX_UINT32_MSEC_USEC +#define RADV_MAX_RETRANSMIT_USEC RADV_MAX_UINT32_MSEC_USEC /* draft-ietf-6man-slaac-renum-02 section 4.1.1. * AdvPreferredLifetime: max(AdvDefaultLifetime, 3 * MaxRtrAdvInterval) * AdvValidLifetime: 2 * AdvPreferredLifetime */ diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 62f11c5c5c..4124b3270f 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -393,7 +393,8 @@ DHCPPrefixDelegation.RouteMetric, config_parse_uint32, DHCPPrefixDelegation.NetLabel, config_parse_string, CONFIG_PARSE_STRING_SAFE, offsetof(Network, dhcp_pd_netlabel) DHCPPrefixDelegation.NFTSet, config_parse_nft_set, NFT_SET_PARSE_NETWORK, offsetof(Network, dhcp_pd_nft_set_context) IPv6SendRA.RouterLifetimeSec, config_parse_router_lifetime, 0, offsetof(Network, router_lifetime_usec) -IPv6SendRA.RetransmitSec, config_parse_router_retransmit, 0, offsetof(Network, router_retransmit_usec) +IPv6SendRA.ReachableTimeSec, config_parse_router_uint32_msec_usec, 0, offsetof(Network, router_reachable_usec) +IPv6SendRA.RetransmitSec, config_parse_router_uint32_msec_usec, 0, offsetof(Network, router_retransmit_usec) IPv6SendRA.Managed, config_parse_bool, 0, offsetof(Network, router_managed) IPv6SendRA.OtherInformation, config_parse_bool, 0, offsetof(Network, router_other_information) IPv6SendRA.RouterPreference, config_parse_router_preference, 0, 0 diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h index c8573e0973..92d367eccf 100644 --- a/src/network/networkd-network.h +++ b/src/network/networkd-network.h @@ -246,6 +246,7 @@ struct Network { RADVPrefixDelegation router_prefix_delegation; usec_t router_lifetime_usec; uint8_t router_preference; + usec_t router_reachable_usec; usec_t router_retransmit_usec; uint8_t router_hop_limit; bool router_managed; diff --git a/src/network/networkd-radv.c b/src/network/networkd-radv.c index fa5884a6c3..0f0f3a34ce 100644 --- a/src/network/networkd-radv.c +++ b/src/network/networkd-radv.c @@ -577,6 +577,10 @@ static int radv_configure(Link *link) { return r; } + r = sd_radv_set_reachable_time(link->radv, link->network->router_reachable_usec); + if (r < 0) + return r; + if (link->network->router_retransmit_usec > 0) { r = sd_radv_set_retransmit(link->radv, link->network->router_retransmit_usec); if (r < 0) @@ -1496,7 +1500,7 @@ int config_parse_router_lifetime( return 0; } -int config_parse_router_retransmit( +int config_parse_router_uint32_msec_usec( const char *unit, const char *filename, unsigned line, @@ -1508,7 +1512,7 @@ int config_parse_router_retransmit( void *data, void *userdata) { - usec_t usec, *router_retransmit_usec = ASSERT_PTR(data); + usec_t usec, *router_usec = ASSERT_PTR(data); int r; assert(filename); @@ -1517,7 +1521,7 @@ int config_parse_router_retransmit( assert(rvalue); if (isempty(rvalue)) { - *router_retransmit_usec = 0; + *router_usec = 0; return 0; } @@ -1529,13 +1533,13 @@ int config_parse_router_retransmit( } if (usec != USEC_INFINITY && - usec > RADV_MAX_RETRANSMIT_USEC) { + usec > RADV_MAX_UINT32_MSEC_USEC) { log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid [%s] %s=, ignoring assignment: %s", section, lvalue, rvalue); return 0; } - *router_retransmit_usec = usec; + *router_usec = usec; return 0; } diff --git a/src/network/networkd-radv.h b/src/network/networkd-radv.h index 94834e77a8..dcb8cfb304 100644 --- a/src/network/networkd-radv.h +++ b/src/network/networkd-radv.h @@ -86,7 +86,7 @@ RADVPrefixDelegation radv_prefix_delegation_from_string(const char *s) _pure_; CONFIG_PARSER_PROTOTYPE(config_parse_router_prefix_delegation); CONFIG_PARSER_PROTOTYPE(config_parse_router_lifetime); -CONFIG_PARSER_PROTOTYPE(config_parse_router_retransmit); +CONFIG_PARSER_PROTOTYPE(config_parse_router_uint32_msec_usec); CONFIG_PARSER_PROTOTYPE(config_parse_router_preference); CONFIG_PARSER_PROTOTYPE(config_parse_prefix); CONFIG_PARSER_PROTOTYPE(config_parse_prefix_boolean); |