Re: Chrony IPv6 sources offline after resume - dispatcher script runs before IPv6 is up



On Thu, 2021-08-12 at 21:03 +0300, Andrei Borzenkov via networkmanager-
list wrote:
Chrony comes with sample NetworkManager dispatcher script that offlines
NTP sources when interface goes down and onlines them when interface
comes up. Technically it runs "chronyc onoffline" which tries to
determine whether each source can be reached. This script is actually
installed by distributions (openSUSE and Ubuntu for sure).

When system goes to suspend NetworkManager offlines interfaces that
causes chrony to offline its sources. On resume chrony is expected to
online them again.

This works well for IPv4 sources but IPv6 sources remain offline. Like

$ chronyc -n sources
210 Number of sources = 8
MS Name/IP address         Stratum Poll Reach LastRx Last sample

=======================================================================
========
^? 2001:67c:1560:8003::c8        0   6     0     -     +0ns[   +0ns]
+/-
   0ns
^? 2001:67c:1560:8003::c7        0   6     0     -     +0ns[   +0ns]
+/-
   0ns
^- 91.189.89.199                 2   8   377   108  -2030us[-2209us]
+/-
  53ms
^- 91.189.94.4                   2   8   377    49  -2878us[-3067us]
+/-
  60ms
^+ 79.111.152.5                  1   8   377    51  -2960us[-3149us]
+/-
  18ms
^* 188.225.9.167                 2   8   377    49  -1819us[-2008us]
+/-
  15ms
^+ 85.21.78.91                   2   8   377   116  -3053us[-3230us]
+/-
  19ms
^+ 185.209.85.222                2   8   377    50  +6182us[+5993us] +/-
  23ms
$

The reason is - when ifup dispatcher script runs, IPv6 is not yet
configured. Here are route entries

default via 192.168.1.1 dev wlan0 proto dhcp metric 20600
169.254.0.0/16 dev wlan0 scope link metric 1000
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.6 metric
600
::1 dev lo proto kernel metric 256 pref medium
fe80::/64 dev wlan0 proto kernel metric 600 pref medium

So IPv4 is up and has default route but IPv6 still only link-local
address. Couple of seconds later

::1 dev lo proto kernel metric 256 pref medium
2a00:xxxx:yyyy:zzzz::/64 dev wlan0 proto ra metric 600 pref medium
fe80::/64 dev wlan0 proto kernel metric 600 pref medium
default via fe80::1 dev wlan0 proto ra metric 20600 pref medium

Is it possible to run dispatcher script after both IPv4 and IPv6 are
configured on interface? Or only IPv6 for that matter - it does not
matter if "chronyc onoffline" runs multiple times.

Both IPv4 and IPv6 are set to auto.


Hi,

there are several dispatcher events, documented at [1].

[1] https://networkmanager.dev/docs/api/1.32.8/NetworkManager-dispatcher.html

one of them is "dhcp6-change" change, but I guess that even should also
fire when we get new IPv6 addresses from a router. Or an alternative
event could be added. That probably does not happen (yet), which might
be a bug. It's also not entirely trivial, because probably that the
event should only be emitted after the IPv6 addresses pass DAD and are
no longer tentative.


Note that the "up" event gets invoked when the device is logically
connected. If you configure ipv6.may-fail=no, then that includes IPv6
to be ready (but it also makes it mandatory). There is also
ipv6.required-timeout, which means to wait for IPv6 this long. This
allows the user to better control what "up" means, but it's not a
general solution for your dispatcher script, because that should work
with any configuration.


best,
Thomas


 * 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]