Skip to content

Commit 69c37b2

Browse files
authored
Merge pull request #29873 from yuwata/network-revert-hop-limit
network: several follow-ups for IPv6 hop limit
2 parents a4a047c + 986e182 commit 69c37b2

File tree

7 files changed

+9
-17
lines changed

7 files changed

+9
-17
lines changed

man/systemd.network.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -864,9 +864,9 @@ Table=1234</programlisting></para>
864864
<varlistentry>
865865
<term><varname>IPv6HopLimit=</varname></term>
866866
<listitem>
867-
<para>Configures IPv6 Hop Limit. For each router that forwards the packet, the hop limit is
868-
decremented by 1. When the hop limit field reaches zero, the packet is discarded. When unset,
869-
the kernel's default will be used.</para>
867+
<para>Configures IPv6 Hop Limit. Takes an integer in the range 1…255. For each router that
868+
forwards the packet, the hop limit is decremented by 1. When the hop limit field reaches zero, the
869+
packet is discarded. When unset, the kernel's default will be used.</para>
870870

871871
<xi:include href="version-info.xml" xpointer="v228"/>
872872
</listitem>

src/network/networkd-ndisc.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,11 @@ static int ndisc_request_route(Route *in, Link *link, sd_ndisc_router *rt) {
195195
return log_link_warning_errno(link, r, "Failed to get default router MTU from RA: %m");
196196
}
197197

198-
if (link->network->ipv6_accept_ra_use_hop_limit) {
198+
if (link->network->ipv6_accept_ra_use_hop_limit) {
199199
r = sd_ndisc_router_get_hop_limit(rt, &hop_limit);
200200
if (r < 0 && r != -ENODATA)
201201
return log_link_warning_errno(link, r, "Failed to get default router hop limit from RA: %m");
202-
203-
link->network->ipv6_hop_limit = hop_limit;
204-
r = link_set_ipv6_hop_limit(link);
205-
if (r < 0)
206-
log_link_warning_errno(link, r, "Cannot set IPv6 hop limit for interface, ignoring: %m");
207-
}
202+
}
208203

209204
route->source = NETWORK_CONFIG_SOURCE_NDISC;
210205
route->provider.in6 = router;
@@ -217,7 +212,6 @@ static int ndisc_request_route(Route *in, Link *link, sd_ndisc_router *rt) {
217212
route->quickack = link->network->ipv6_accept_ra_quickack;
218213
if (route->mtu == 0)
219214
route->mtu = mtu;
220-
221215
if (route->hop_limit == 0)
222216
route->hop_limit = hop_limit;
223217

src/network/networkd-network-gperf.gperf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Network.IPv6PrivacyExtensions, config_parse_ipv6_privacy_extension
130130
Network.IPv6AcceptRA, config_parse_tristate, 0, offsetof(Network, ipv6_accept_ra)
131131
Network.IPv6AcceptRouterAdvertisements, config_parse_tristate, 0, offsetof(Network, ipv6_accept_ra)
132132
Network.IPv6DuplicateAddressDetection, config_parse_int, 0, offsetof(Network, ipv6_dad_transmits)
133-
Network.IPv6HopLimit, config_parse_int, 0, offsetof(Network, ipv6_hop_limit)
133+
Network.IPv6HopLimit, config_parse_uint8, 0, offsetof(Network, ipv6_hop_limit)
134134
Network.IPv6ProxyNDP, config_parse_tristate, 0, offsetof(Network, ipv6_proxy_ndp)
135135
Network.IPv6MTUBytes, config_parse_mtu, AF_INET6, offsetof(Network, ipv6_mtu)
136136
Network.IPv4AcceptLocal, config_parse_tristate, 0, offsetof(Network, ipv4_accept_local)

src/network/networkd-network.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,6 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
466466
.ipv4_route_localnet = -1,
467467
.ipv6_privacy_extensions = _IPV6_PRIVACY_EXTENSIONS_INVALID,
468468
.ipv6_dad_transmits = -1,
469-
.ipv6_hop_limit = -1,
470469
.ipv6_proxy_ndp = -1,
471470
.proxy_arp = -1,
472471
.ipv4_rp_filter = _IP_REVERSE_PATH_FILTER_INVALID,

src/network/networkd-network.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ struct Network {
323323
int ipv4_accept_local;
324324
int ipv4_route_localnet;
325325
int ipv6_dad_transmits;
326-
int ipv6_hop_limit;
326+
uint8_t ipv6_hop_limit;
327327
int proxy_arp;
328328
uint32_t ipv6_mtu;
329329
IPv6PrivacyExtensions ipv6_privacy_extensions;

src/network/networkd-sysctl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static int link_set_ipv6_dad_transmits(Link *link) {
165165
return sysctl_write_ip_property_int(AF_INET6, link->ifname, "dad_transmits", link->network->ipv6_dad_transmits);
166166
}
167167

168-
int link_set_ipv6_hop_limit(Link *link) {
168+
static int link_set_ipv6_hop_limit(Link *link) {
169169
assert(link);
170170

171171
/* Make this a NOP if IPv6 is not available */
@@ -178,7 +178,7 @@ int link_set_ipv6_hop_limit(Link *link) {
178178
if (!link->network)
179179
return 0;
180180

181-
if (link->network->ipv6_hop_limit < 0)
181+
if (link->network->ipv6_hop_limit <= 0)
182182
return 0;
183183

184184
return sysctl_write_ip_property_int(AF_INET6, link->ifname, "hop_limit", link->network->ipv6_hop_limit);

src/network/networkd-sysctl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ typedef enum IPReversePathFilter {
2828

2929
int link_set_sysctl(Link *link);
3030
int link_set_ipv6_mtu(Link *link);
31-
int link_set_ipv6_hop_limit(Link *link);
3231

3332
const char* ipv6_privacy_extensions_to_string(IPv6PrivacyExtensions i) _const_;
3433
IPv6PrivacyExtensions ipv6_privacy_extensions_from_string(const char *s) _pure_;

0 commit comments

Comments
 (0)