networkd-manager: Fix route removals on shutdown
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Wed, 19 Sep 2018 00:32:30 +0000 (18:32 -0600)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Wed, 19 Sep 2018 19:45:18 +0000 (13:45 -0600)
commit65dd5e310582954be0fd99edb5aabaac38e6c1ef
tree4524c38ff1e966bc95e70e2d2927726bc1f8605d
parente1d737ef9d68287e396bb0756cdd5abca34850a1
networkd-manager: Fix route removals on shutdown

In order to shut down networkd properly, the delegated routes added
need to be removed properly, and as error reporting is wanted, the
network link is needed in the debug output.

Solve this by calling manager_dhcp6_prefix_remove_all(), which will
remove each prefix stored in the Manager structure, and while doing
that reference each link so that it isn't freed before the route
removal callback is called. This in turn causes the network link to
be referenced once more, and an explicit hashmap_remove() must be
called to remove the network link from the m->links hashmap.

Also, since the registered callback is not called when the DHCPv6
client is stopped with sd_dhcp6_client_stop(), an explicit call
to dhcp6_lease_pd_prefix_lost() needs to be made to clean up any
unreachable routes set up for the delegated prefixes.
src/network/networkd-dhcp6.c
src/network/networkd-link.h
src/network/networkd-manager.c