]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #32195 from yuwata/network-ndisc-mtu
authorLuca Boccassi <bluca@debian.org>
Wed, 10 Apr 2024 22:12:21 +0000 (23:12 +0100)
committerGitHub <noreply@github.com>
Wed, 10 Apr 2024 22:12:21 +0000 (23:12 +0100)
network: several cleanups for IPv6 MTU

1  2 
src/network/networkd-ndisc.c
test/test-network/systemd-networkd-tests.py

index 2b039bed968c2d16e7831a34936946dde8dcde79,2c21a1ce6c6100835b448fb96161a4644907fd8f..7473a926d43ffd83b167bc2995c3cc57ac9ac30f
@@@ -1048,9 -1027,41 +1048,40 @@@ static int ndisc_router_process_hop_lim
          return 0;
  }
  
+ static int ndisc_router_process_mtu(Link *link, sd_ndisc_router *rt) {
+         uint32_t mtu;
+         int r;
+         assert(link);
+         assert(link->network);
+         assert(rt);
+         if (!link->network->ndisc_use_mtu)
+                 return 0;
+         /* Ignore the MTU option if the lifetime is zero. */
+         r = sd_ndisc_router_get_lifetime(rt, NULL);
+         if (r <= 0)
+                 return r;
+         r = sd_ndisc_router_get_mtu(rt, &mtu);
+         if (r == -ENODATA)
+                 return 0;
+         if (r < 0)
+                 return log_link_warning_errno(link, r, "Failed to get MTU from RA: %m");
+         link->ndisc_mtu = mtu;
+         r = link_set_ipv6_mtu(link, LOG_DEBUG);
+         if (r < 0)
+                 log_link_warning_errno(link, r, "Failed to apply IPv6 MTU (%"PRIu32"), ignoring: %m", mtu);
+         return 0;
+ }
  static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *rt) {
          usec_t lifetime_valid_usec, lifetime_preferred_usec;
 -        _cleanup_set_free_ Set *addresses = NULL;
 -        struct in6_addr prefix, *a;
 +        struct in6_addr prefix;
          uint8_t prefixlen;
          int r;