networkd-ndisc.c revision 7a695d8e1fda59857c4c23bcb50cd1e0aaf4a854
a13c50e7a33e2b8e0481f725c6272142e6f71751Tom Gundersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
a13c50e7a33e2b8e0481f725c6272142e6f71751Tom Gundersen This file is part of systemd.
a13c50e7a33e2b8e0481f725c6272142e6f71751Tom Gundersen Copyright (C) 2014 Intel Corporation. All rights reserved.
a13c50e7a33e2b8e0481f725c6272142e6f71751Tom Gundersen systemd is free software; you can redistribute it and/or modify it
a13c50e7a33e2b8e0481f725c6272142e6f71751Tom Gundersen under the terms of the GNU Lesser General Public License as published by
a13c50e7a33e2b8e0481f725c6272142e6f71751Tom Gundersen the Free Software Foundation; either version 2.1 of the License, or
a13c50e7a33e2b8e0481f725c6272142e6f71751Tom Gundersen (at your option) any later version.
a13c50e7a33e2b8e0481f725c6272142e6f71751Tom Gundersen systemd is distributed in the hope that it will be useful, but
a13c50e7a33e2b8e0481f725c6272142e6f71751Tom Gundersen WITHOUT ANY WARRANTY; without even the implied warranty of
a13c50e7a33e2b8e0481f725c6272142e6f71751Tom Gundersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a13c50e7a33e2b8e0481f725c6272142e6f71751Tom Gundersen Lesser General Public License for more details.
a13c50e7a33e2b8e0481f725c6272142e6f71751Tom Gundersen You should have received a copy of the GNU Lesser General Public License
a13c50e7a33e2b8e0481f725c6272142e6f71751Tom Gundersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
9d96e6c3efbe5ef52b2855612d51db52c469beb2Tom Gundersenstatic void ndisc_router_handler(sd_ndisc *nd, uint8_t flags, const struct in6_addr *gateway, unsigned lifetime, int pref, void *userdata) {
a13c50e7a33e2b8e0481f725c6272142e6f71751Tom Gundersen if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER))
7a695d8e1fda59857c4c23bcb50cd1e0aaf4a854Tom Gundersen if (flags & (ND_RA_FLAG_MANAGED | ND_RA_FLAG_OTHER)) {
7a695d8e1fda59857c4c23bcb50cd1e0aaf4a854Tom Gundersen r = sd_dhcp6_client_start(link->dhcp6_client);
7a695d8e1fda59857c4c23bcb50cd1e0aaf4a854Tom Gundersen if (r < 0 && r != -EBUSY)
7a695d8e1fda59857c4c23bcb50cd1e0aaf4a854Tom Gundersen log_link_warning_errno(link, r, "Starting DHCPv6 client on NDisc request failed: %m");
9d96e6c3efbe5ef52b2855612d51db52c469beb2Tom Gundersenstatic void ndisc_handler(sd_ndisc *nd, int event, void *userdata) {
9d96e6c3efbe5ef52b2855612d51db52c469beb2Tom Gundersen if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER))
7a695d8e1fda59857c4c23bcb50cd1e0aaf4a854Tom Gundersen r = sd_dhcp6_client_start(link->dhcp6_client);
7a695d8e1fda59857c4c23bcb50cd1e0aaf4a854Tom Gundersen if (r < 0 && r != -EBUSY)
7a695d8e1fda59857c4c23bcb50cd1e0aaf4a854Tom Gundersen log_link_warning_errno(link, r, "Starting DHCPv6 client after NDisc timeout failed: %m");
9d96e6c3efbe5ef52b2855612d51db52c469beb2Tom Gundersen log_link_warning(link, "IPv6 Neighbor Discovery unknown event: %d", event);
a13c50e7a33e2b8e0481f725c6272142e6f71751Tom Gundersen r = sd_ndisc_new(&link->ndisc_router_discovery);
a13c50e7a33e2b8e0481f725c6272142e6f71751Tom Gundersen r = sd_ndisc_attach_event(link->ndisc_router_discovery, NULL, 0);
a13c50e7a33e2b8e0481f725c6272142e6f71751Tom Gundersen r = sd_ndisc_set_mac(link->ndisc_router_discovery, &link->mac);
a13c50e7a33e2b8e0481f725c6272142e6f71751Tom Gundersen r = sd_ndisc_set_index(link->ndisc_router_discovery, link->ifindex);