summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Boccassi <bluca@debian.org>2023-11-06 11:00:46 +0100
committerGitHub <noreply@github.com>2023-11-06 11:00:46 +0100
commit69c37b26a4743261d1bf0639bb03fa85ee7a5c38 (patch)
treebb871e242312b237f87456b8d0f7f6c4a4f8624f
parentNEWS: mention new rpm macros (diff)
parentnetwork: do not try to set invalid value for IPv6 hop limit (diff)
downloadsystemd-69c37b26a4743261d1bf0639bb03fa85ee7a5c38.tar.xz
systemd-69c37b26a4743261d1bf0639bb03fa85ee7a5c38.zip
Merge pull request #29873 from yuwata/network-revert-hop-limit
network: several follow-ups for IPv6 hop limit
-rw-r--r--man/systemd.network.xml6
-rw-r--r--src/network/networkd-ndisc.c10
-rw-r--r--src/network/networkd-network-gperf.gperf2
-rw-r--r--src/network/networkd-network.c1
-rw-r--r--src/network/networkd-network.h2
-rw-r--r--src/network/networkd-sysctl.c4
-rw-r--r--src/network/networkd-sysctl.h1
7 files changed, 9 insertions, 17 deletions
diff --git a/man/systemd.network.xml b/man/systemd.network.xml
index ece60926c7..f065cfcafa 100644
--- a/man/systemd.network.xml
+++ b/man/systemd.network.xml
@@ -864,9 +864,9 @@ Table=1234</programlisting></para>
<varlistentry>
<term><varname>IPv6HopLimit=</varname></term>
<listitem>
- <para>Configures IPv6 Hop Limit. For each router that forwards the packet, the hop limit is
- decremented by 1. When the hop limit field reaches zero, the packet is discarded. When unset,
- the kernel's default will be used.</para>
+ <para>Configures IPv6 Hop Limit. Takes an integer in the range 1…255. For each router that
+ forwards the packet, the hop limit is decremented by 1. When the hop limit field reaches zero, the
+ packet is discarded. When unset, the kernel's default will be used.</para>
<xi:include href="version-info.xml" xpointer="v228"/>
</listitem>
diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c
index f4f662cf96..ab9eeb13a5 100644
--- a/src/network/networkd-ndisc.c
+++ b/src/network/networkd-ndisc.c
@@ -195,16 +195,11 @@ static int ndisc_request_route(Route *in, Link *link, sd_ndisc_router *rt) {
return log_link_warning_errno(link, r, "Failed to get default router MTU from RA: %m");
}
- if (link->network->ipv6_accept_ra_use_hop_limit) {
+ if (link->network->ipv6_accept_ra_use_hop_limit) {
r = sd_ndisc_router_get_hop_limit(rt, &hop_limit);
if (r < 0 && r != -ENODATA)
return log_link_warning_errno(link, r, "Failed to get default router hop limit from RA: %m");
-
- link->network->ipv6_hop_limit = hop_limit;
- r = link_set_ipv6_hop_limit(link);
- if (r < 0)
- log_link_warning_errno(link, r, "Cannot set IPv6 hop limit for interface, ignoring: %m");
- }
+ }
route->source = NETWORK_CONFIG_SOURCE_NDISC;
route->provider.in6 = router;
@@ -217,7 +212,6 @@ static int ndisc_request_route(Route *in, Link *link, sd_ndisc_router *rt) {
route->quickack = link->network->ipv6_accept_ra_quickack;
if (route->mtu == 0)
route->mtu = mtu;
-
if (route->hop_limit == 0)
route->hop_limit = hop_limit;
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
index 6323f6b212..080f72dc2c 100644
--- a/src/network/networkd-network-gperf.gperf
+++ b/src/network/networkd-network-gperf.gperf
@@ -130,7 +130,7 @@ Network.IPv6PrivacyExtensions, config_parse_ipv6_privacy_extension
Network.IPv6AcceptRA, config_parse_tristate, 0, offsetof(Network, ipv6_accept_ra)
Network.IPv6AcceptRouterAdvertisements, config_parse_tristate, 0, offsetof(Network, ipv6_accept_ra)
Network.IPv6DuplicateAddressDetection, config_parse_int, 0, offsetof(Network, ipv6_dad_transmits)
-Network.IPv6HopLimit, config_parse_int, 0, offsetof(Network, ipv6_hop_limit)
+Network.IPv6HopLimit, config_parse_uint8, 0, offsetof(Network, ipv6_hop_limit)
Network.IPv6ProxyNDP, config_parse_tristate, 0, offsetof(Network, ipv6_proxy_ndp)
Network.IPv6MTUBytes, config_parse_mtu, AF_INET6, offsetof(Network, ipv6_mtu)
Network.IPv4AcceptLocal, config_parse_tristate, 0, offsetof(Network, ipv4_accept_local)
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 9ef28d283b..fbda52f8f3 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -466,7 +466,6 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
.ipv4_route_localnet = -1,
.ipv6_privacy_extensions = _IPV6_PRIVACY_EXTENSIONS_INVALID,
.ipv6_dad_transmits = -1,
- .ipv6_hop_limit = -1,
.ipv6_proxy_ndp = -1,
.proxy_arp = -1,
.ipv4_rp_filter = _IP_REVERSE_PATH_FILTER_INVALID,
diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h
index 00a6b50310..021e7f9182 100644
--- a/src/network/networkd-network.h
+++ b/src/network/networkd-network.h
@@ -323,7 +323,7 @@ struct Network {
int ipv4_accept_local;
int ipv4_route_localnet;
int ipv6_dad_transmits;
- int ipv6_hop_limit;
+ uint8_t ipv6_hop_limit;
int proxy_arp;
uint32_t ipv6_mtu;
IPv6PrivacyExtensions ipv6_privacy_extensions;
diff --git a/src/network/networkd-sysctl.c b/src/network/networkd-sysctl.c
index 1a5dffe6f5..2ac6c3527b 100644
--- a/src/network/networkd-sysctl.c
+++ b/src/network/networkd-sysctl.c
@@ -165,7 +165,7 @@ static int link_set_ipv6_dad_transmits(Link *link) {
return sysctl_write_ip_property_int(AF_INET6, link->ifname, "dad_transmits", link->network->ipv6_dad_transmits);
}
-int link_set_ipv6_hop_limit(Link *link) {
+static int link_set_ipv6_hop_limit(Link *link) {
assert(link);
/* Make this a NOP if IPv6 is not available */
@@ -178,7 +178,7 @@ int link_set_ipv6_hop_limit(Link *link) {
if (!link->network)
return 0;
- if (link->network->ipv6_hop_limit < 0)
+ if (link->network->ipv6_hop_limit <= 0)
return 0;
return sysctl_write_ip_property_int(AF_INET6, link->ifname, "hop_limit", link->network->ipv6_hop_limit);
diff --git a/src/network/networkd-sysctl.h b/src/network/networkd-sysctl.h
index 99243f7a25..064438462c 100644
--- a/src/network/networkd-sysctl.h
+++ b/src/network/networkd-sysctl.h
@@ -28,7 +28,6 @@ typedef enum IPReversePathFilter {
int link_set_sysctl(Link *link);
int link_set_ipv6_mtu(Link *link);
-int link_set_ipv6_hop_limit(Link *link);
const char* ipv6_privacy_extensions_to_string(IPv6PrivacyExtensions i) _const_;
IPv6PrivacyExtensions ipv6_privacy_extensions_from_string(const char *s) _pure_;