]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: do not try to set invalid value for IPv6 hop limit 29873/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 6 Nov 2023 06:46:39 +0000 (15:46 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 6 Nov 2023 06:53:25 +0000 (15:53 +0900)
man/systemd.network.xml
src/network/networkd-network-gperf.gperf
src/network/networkd-network.c
src/network/networkd-network.h
src/network/networkd-sysctl.c

index ece60926c7e1fd0dd7bd4ca3c894349082d69b8d..f065cfcafa71d7f23d1f9d37767b71805f9c17bc 100644 (file)
@@ -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>
index 6323f6b212809e0d64d43c5f561489786bc7fc43..080f72dc2cde8ef77eecd2cd0320ee3c02a0597f 100644 (file)
@@ -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)
index 9ef28d283b71a13a52135f471127eea59fa25410..fbda52f8f318269663c1a1e038b37a457fe2056e 100644 (file)
@@ -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,
index 00a6b50310f018f5e8585ca41de35ce40fd6561c..021e7f9182b6c6334afa33147b8838a5bfd27c73 100644 (file)
@@ -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;
index 0b8169a0176626ae0322bf589dbea7c574391657..2ac6c3527bc288f882a81e167e95a405d0da729e 100644 (file)
@@ -178,7 +178,7 @@ static 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);