Lines Matching refs:ifp
157 dhcp6_makevendor(struct dhcp6_option *o, const struct interface *ifp)
168 ifo = ifp->options;
185 logger(ifp->ctx, LOG_ERR,
186 "%s: DHCPv6 Vendor Class too big", ifp->name);
298 dhcp6_updateelapsed(struct interface *ifp, struct dhcp6_message *m, size_t len)
311 state = D6_STATE(ifp);
321 dhcp6_newxid(const struct interface *ifp, struct dhcp6_message *m)
325 if (ifp->options->options & DHCPCD_XID_HWADDR &&
326 ifp->hwlen >= sizeof(xid))
328 memcpy(&xid, (ifp->hwaddr + ifp->hwlen) - sizeof(xid),
339 dhcp6_findselfsla(struct interface *ifp, const uint8_t *iaid)
343 for (i = 0; i < ifp->options->ia_len; i++) {
345 memcmp(&ifp->options->ia[i].iaid, iaid,
346 sizeof(ifp->options->ia[i].iaid)) == 0)
348 for (j = 0; j < ifp->options->ia[i].sla_len; j++) {
349 if (strcmp(ifp->options->ia[i].sla[j].ifname,
350 ifp->name) == 0)
351 return &ifp->options->ia[i].sla[j];
393 dhcp6_delegateaddr(struct in6_addr *addr, struct interface *ifp,
401 state = D6_STATE(ifp);
403 ifp->if_data[IF_DATA_DHCP6] = calloc(1, sizeof(*state));
404 state = D6_STATE(ifp);
406 logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
416 asla.sla = ifp->index;
435 TAILQ_FOREACH(ifi, ifp->ctx->ifaces, next) {
436 if (ifi != ifp && ifi->index > sla_max)
471 logger(ifp->ctx, LOG_ERR,
473 ifp->name, sa, prefix->prefix_len,
483 logger(ifp->ctx, LOG_ERR,
485 ifp->name, sa, prefix->prefix_exclude_len);
493 dhcp6_has_public_addr(const struct interface *ifp)
495 const struct dhcp6_state *state = D6_CSTATE(ifp);
508 dhcp6_makemessage(struct interface *ifp)
529 state = D6_STATE(ifp);
535 ifo = ifp->options;
558 for (l = 0, opt = ifp->ctx->dhcp6_opts;
559 l < ifp->ctx->dhcp6_opts_len;
591 if (dhcp6_findselfsla(ifp, NULL)) {
607 len += sizeof(*o) + ifp->ctx->duid_len;
609 len += sizeof(*o) + dhcp6_makevendor(NULL, ifp);
679 !(ifp->ctx->options & DHCPCD_TEST) &&
730 logger(ifp->ctx, LOG_ERR,
731 "%s: dhcp_auth_encode: %m", ifp->name);
752 dhcp6_newxid(ifp, state->send);
756 o->len = htons((uint16_t)ifp->ctx->duid_len);
757 memcpy(D6_OPTION_DATA(o), ifp->ctx->duid, ifp->ctx->duid_len);
771 dhcp6_makevendor(o, ifp);
774 !(ifp->ctx->options & DHCPCD_TEST) &&
893 for (l = 0, opt = ifp->ctx->dhcp6_opts;
894 l < ifp->ctx->dhcp6_opts_len;
932 if (dhcp6_findselfsla(ifp, NULL)) {
964 dhcp6_freedrop_addrs(struct interface *ifp, int drop,
969 state = D6_STATE(ifp);
973 ipv6_buildroutes(ifp->ctx);
977 static void dhcp6_delete_delegates(struct interface *ifp)
981 if (ifp->ctx->ifaces) {
982 TAILQ_FOREACH(ifp0, ifp->ctx->ifaces, next) {
983 if (ifp0 != ifp)
984 dhcp6_freedrop_addrs(ifp0, 1, ifp);
990 dhcp6_update_auth(struct interface *ifp, struct dhcp6_message *m, size_t len)
1001 state = D6_STATE(ifp);
1003 return dhcp_auth_encode(&ifp->options->auth, state->auth.token,
1010 dhcp6_sendmessage(struct interface *ifp, void (*callback)(void *))
1031 state = D6_STATE(ifp);
1037 (!IN6_IS_ADDR_LINKLOCAL(&state->unicast) || !ipv6_linklocal(ifp))))
1047 logger(ifp->ctx, LOG_DEBUG,
1049 ifp->name,
1061 if (ifp->flags & IFF_POINTOPOINT)
1111 logger(ifp->ctx, LOG_DEBUG,
1114 ifp->name,
1125 eloop_timeout_add_tv(ifp->ctx->eloop,
1126 &state->RT, callback, ifp);
1132 dhcp6_updateelapsed(ifp, state->send, state->send_len);
1133 if (ifp->options->auth.options & DHCPCD_AUTH_SEND &&
1134 dhcp6_update_auth(ifp, state->send, state->send_len) == -1)
1136 logger(ifp->ctx, LOG_ERR,
1137 "%s: dhcp6_updateauth: %m", ifp->name);
1142 ctx = ifp->ctx->ipv6;
1143 dst.sin6_scope_id = ifp->index;
1156 pi.ipi6_ifindex = ifp->index;
1160 logger(ifp->ctx, LOG_ERR,
1161 "%s: %s: sendmsg: %m", ifp->name, __func__);
1162 ifp->options->options &= ~DHCPCD_IPV6;
1163 dhcp6_drop(ifp, "EXPIRE6");
1170 eloop_timeout_add_tv(ifp->ctx->eloop,
1171 &state->RT, callback, ifp);
1173 eloop_timeout_add_tv(ifp->ctx->eloop,
1174 &state->RT, state->MRCcallback, ifp);
1176 logger(ifp->ctx, LOG_WARNING,
1178 ifp->name, state->RTC);
1237 struct interface *ifp;
1240 ifp = arg;
1241 state = D6_STATE(ifp);
1249 if (dhcp6_makemessage(ifp) == -1)
1250 logger(ifp->ctx, LOG_ERR,
1251 "%s: dhcp6_makemessage: %m", ifp->name);
1253 dhcp6_sendrenew(ifp);
1257 dhcp6_dadcompleted(const struct interface *ifp)
1262 state = D6_CSTATE(ifp);
1275 struct interface *ifp;
1288 ifp = ap->iface;
1289 state = D6_STATE(ifp);
1306 "%s: DHCPv6 DAD completed", ifp->name);
1307 script_runreason(ifp,
1311 dhcpcd_daemonise(ifp->ctx);
1318 dhcp6_addrequestedaddrs(struct interface *ifp)
1327 state = D6_STATE(ifp);
1329 for (i = 0; i < ifp->options->ia_len; i++) {
1330 ia = &ifp->options->ia[i];
1336 logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
1340 a->iface = ifp;
1375 struct interface *ifp;
1379 ifp = arg;
1380 dhcp6_delete_delegates(ifp);
1381 logger(ifp->ctx, LOG_INFO, "%s: soliciting a DHCPv6 lease", ifp->name);
1382 state = D6_STATE(ifp);
1391 eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
1396 dhcp6_freedrop_addrs(ifp, 0, NULL);
1399 dhcp6_addrequestedaddrs(ifp);
1401 if (dhcp6_makemessage(ifp) == -1)
1402 logger(ifp->ctx, LOG_ERR,
1403 "%s: dhcp6_makemessage: %m", ifp->name);
1405 dhcp6_senddiscover(ifp);
1411 struct interface *ifp;
1413 ifp = arg;
1414 logger(ifp->ctx, LOG_ERR,
1415 "%s: failed to confirm prior address", ifp->name);
1419 dhcp6_startdiscover(ifp);
1425 struct interface *ifp;
1427 ifp = arg;
1428 logger(ifp->ctx, LOG_ERR, "%s: failed to request address", ifp->name);
1433 dhcp6_startdiscover(ifp);
1439 struct interface *ifp;
1441 ifp = arg;
1442 logger(ifp->ctx, LOG_ERR,
1443 "%s: failed to rebind prior delegation", ifp->name);
1444 dhcp6_delete_delegates(ifp);
1448 dhcp6_startdiscover(ifp);
1453 dhcp6_hasprefixdelegation(struct interface *ifp)
1458 if (ifp->options->options & DHCPCD_NOPFXDLG)
1462 for (i = 0; i < ifp->options->ia_len; i++) {
1463 if (t && t != ifp->options->ia[i].ia_type) {
1465 ifp->options->ia[i].ia_type == D6_OPTION_IA_PD)
1468 t = ifp->options->ia[i].ia_type;
1476 struct interface *ifp;
1481 ifp = arg;
1482 eloop_timeout_delete(ifp->ctx->eloop, dhcp6_sendrenew, ifp);
1483 state = D6_STATE(ifp);
1485 logger(ifp->ctx, LOG_WARNING,
1486 "%s: failed to renew DHCPv6, rebinding", ifp->name);
1488 logger(ifp->ctx, LOG_INFO,
1489 "%s: rebinding prior DHCPv6 lease", ifp->name);
1495 pd = dhcp6_hasprefixdelegation(ifp);
1505 if (dhcp6_makemessage(ifp) == -1)
1506 logger(ifp->ctx, LOG_ERR,
1507 "%s: dhcp6_makemessage: %m", ifp->name);
1509 dhcp6_sendrebind(ifp);
1513 eloop_timeout_add_sec(ifp->ctx->eloop,
1514 CNF_MAX_RD, dhcp6_failrebind, ifp);
1519 dhcp6_startrequest(struct interface *ifp)
1524 eloop_timeout_delete(ifp->ctx->eloop, dhcp6_senddiscover, ifp);
1525 state = D6_STATE(ifp);
1533 if (dhcp6_makemessage(ifp) == -1) {
1534 logger(ifp->ctx, LOG_ERR,
1535 "%s: dhcp6_makemessage: %m", ifp->name);
1539 dhcp6_sendrequest(ifp);
1543 dhcp6_startconfirm(struct interface *ifp)
1548 state = D6_STATE(ifp);
1557 logger(ifp->ctx, LOG_INFO,
1558 "%s: confirming prior DHCPv6 lease", ifp->name);
1559 if (dhcp6_makemessage(ifp) == -1) {
1560 logger(ifp->ctx, LOG_ERR,
1561 "%s: dhcp6_makemessage: %m", ifp->name);
1564 dhcp6_sendconfirm(ifp);
1565 eloop_timeout_add_sec(ifp->ctx->eloop,
1566 CNF_MAX_RD, dhcp6_failconfirm, ifp);
1572 struct interface *ifp;
1576 ifp = arg;
1577 state = D6_STATE(ifp);
1578 if (state->new == NULL || ifp->options->options & DHCPCD_DEBUG)
1579 logger(ifp->ctx, LOG_INFO,
1580 "%s: requesting DHCPv6 information", ifp->name);
1589 if (dhcp6_makemessage(ifp) == -1)
1590 logger(ifp->ctx, LOG_ERR,
1591 "%s: dhcp6_makemessage: %m", ifp->name);
1593 dhcp6_sendinform(ifp);
1599 struct interface *ifp;
1602 ifp = arg;
1603 eloop_timeout_delete(ifp->ctx->eloop, dhcp6_sendrebind, ifp);
1605 logger(ifp->ctx, LOG_ERR, "%s: DHCPv6 lease expired", ifp->name);
1606 dhcp6_freedrop_addrs(ifp, 1, NULL);
1607 dhcp6_delete_delegates(ifp);
1608 script_runreason(ifp, "EXPIRE6");
1609 if (ipv6nd_hasradhcp(ifp) || dhcp6_hasprefixdelegation(ifp))
1610 dhcp6_startdiscover(ifp);
1612 logger(ifp->ctx, LOG_WARNING,
1613 "%s: no advertising IPv6 router wants DHCP", ifp->name);
1617 dhcp6_startrelease(struct interface *ifp)
1621 state = D6_STATE(ifp);
1635 if (dhcp6_makemessage(ifp) == -1)
1636 logger(ifp->ctx, LOG_ERR,
1637 "%s: dhcp6_makemessage: %m", ifp->name);
1641 //dhcp6_sendrelease(ifp);
1642 dhcp6_sendmessage(ifp, NULL);
1646 dhcp6_checkstatusok(const struct interface *ifp,
1658 //logger(ifp->ctx, LOG_DEBUG, "%s: no status", ifp->name);
1664 logger(ifp->ctx, LOG_ERR, "%s: status truncated", ifp->name);
1687 logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
1693 logger(ifp->ctx, LOG_ERR, "%s: DHCPv6 REPLY: %s", ifp->name, status);
1699 dhcp6_iffindaddr(struct interface *ifp, const struct in6_addr *addr,
1705 state = D6_STATE(ifp);
1726 struct interface *ifp;
1729 TAILQ_FOREACH(ifp, ctx->ifaces, next) {
1730 ap = dhcp6_iffindaddr(ifp, addr, flags);
1738 dhcp6_findna(struct interface *ifp, uint16_t ot, const uint8_t *iaid,
1752 state = D6_STATE(ifp);
1762 logger(ifp->ctx, LOG_ERR,
1763 "%s: IA Address option truncated", ifp->name);
1767 a = dhcp6_iffindaddr(ifp, &iap->addr, 0);
1771 logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
1774 a->iface = ifp;
1819 dhcp6_findpd(struct interface *ifp, const uint8_t *iaid,
1835 state = D6_STATE(ifp);
1845 logger(ifp->ctx, LOG_ERR,
1846 "%s: IA Prefix option truncated", ifp->name);
1858 logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
1861 a->iface = ifp;
1914 logger(ifp->ctx, LOG_ERR,
1915 "%s: truncated PD Exclude", ifp->name);
1924 logger(ifp->ctx, LOG_ERR,
1925 "%s: PD Exclude length mismatch", ifp->name);
1945 dhcp6_findia(struct interface *ifp, const struct dhcp6_message *m, size_t l,
1967 ifo = ifp->options;
1969 state = D6_STATE(ifp);
1978 logger(ifp->ctx, LOG_ERR,
1979 "%s: option overflow", ifp->name);
1998 logger(ifp->ctx, LOG_ERR,
1999 "%s: IA option truncated", ifp->name);
2013 !(ifo->ia_len == 0 && ifp->ctx->options & DHCPCD_DUMPLEASE))
2015 logger(ifp->ctx, LOG_DEBUG,
2017 ifp->name,
2022 logger(ifp->ctx, LOG_ERR,
2024 ifp->name,
2040 if (dhcp6_checkstatusok(ifp, NULL, p, ol) == -1) {
2046 dhcp6_findpd(ifp, iaid, p, ol, acquired) == 0)
2048 logger(ifp->ctx, LOG_WARNING,
2050 ifp->name, sfrom);
2054 if (dhcp6_findna(ifp, code, iaid, p, ol, acquired) == 0)
2056 logger(ifp->ctx, LOG_WARNING,
2058 ifp->name, sfrom);
2065 logger(ifp->ctx, LOG_WARNING,
2067 ifp->name, renew, rebind, sfrom);
2082 eloop_q_timeout_delete(ifp->ctx->eloop, 0, NULL, ap);
2097 dhcp6_validatelease(struct interface *ifp,
2106 logger(ifp->ctx, LOG_ERR,
2107 "%s: DHCPv6 lease truncated", ifp->name);
2111 state = D6_STATE(ifp);
2112 if (dhcp6_checkstatusok(ifp, m, NULL, len) == -1)
2121 nia = dhcp6_findia(ifp, m, len, sfrom, acquired);
2123 logger(ifp->ctx, LOG_ERR,
2124 "%s: no useable IA found in lease", ifp->name);
2131 dhcp6_writelease(const struct interface *ifp)
2137 state = D6_CSTATE(ifp);
2138 logger(ifp->ctx, LOG_DEBUG,
2139 "%s: writing lease `%s'", ifp->name, state->leasefile);
2143 logger(ifp->ctx, LOG_ERR, "%s: dhcp6_writelease: %m", ifp->name);
2152 dhcp6_readlease(struct interface *ifp, int validate)
2163 state = D6_STATE(ifp);
2166 logger(ifp->ctx, LOG_DEBUG, "%s: reading lease `%s'",
2167 ifp->name, state->leasefile);
2197 fd = dhcp6_validatelease(ifp, state->new, state->new_len, NULL,
2202 if (!(ifp->ctx->options & DHCPCD_DUMPLEASE) &&
2206 logger(ifp->ctx,
2208 ifp->name);
2220 if (dhcp_auth_validate(&state->auth, &ifp->options->auth,
2224 logger(ifp->ctx, LOG_DEBUG,
2225 "%s: dhcp_auth_validate: %m", ifp->name);
2226 logger(ifp->ctx, LOG_ERR,
2227 "%s: authentication failed", ifp->name);
2231 logger(ifp->ctx, LOG_DEBUG,
2233 ifp->name, state->auth.token->secretid);
2235 logger(ifp->ctx, LOG_DEBUG,
2236 "%s: accepted reconfigure key", ifp->name);
2237 } else if (ifp->options->auth.options & DHCPCD_AUTH_REQUIRE) {
2238 logger(ifp->ctx, LOG_ERR,
2239 "%s: authentication now required", ifp->name);
2246 dhcp6_freedrop_addrs(ifp, 0, NULL);
2250 if (!(ifp->ctx->options & DHCPCD_DUMPLEASE))
2256 dhcp6_startinit(struct interface *ifp)
2263 state = D6_STATE(ifp);
2268 dhcp6_addrequestedaddrs(ifp);
2270 for (i = 0; i < ifp->options->ia_len; i++) {
2271 switch (ifp->options->ia[i].ia_type) {
2280 if (!(ifp->ctx->options & DHCPCD_TEST) &&
2282 ifp->options->reboot != 0)
2284 r = dhcp6_readlease(ifp, 1);
2287 logger(ifp->ctx, LOG_ERR,
2289 ifp->name, state->leasefile);
2292 if (dhcp6_hasprefixdelegation(ifp))
2293 dhcp6_startrebind(ifp);
2295 dhcp6_startconfirm(ifp);
2299 dhcp6_startdiscover(ifp);
2303 dhcp6_ifdelegateaddr(struct interface *ifp, struct ipv6_addr *prefix,
2314 if (strcmp(ifp->name, ifs->name) == 0) {
2318 logger(ifp->ctx, LOG_WARNING,
2321 ifp->name);
2326 } else if ((pfxlen = dhcp6_delegateaddr(&addr, ifp, prefix,
2333 logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
2336 a->iface = ifp;
2353 state = D6_STATE(ifp);
2373 dhcp6_script_try_run(struct interface *ifp, int delegated)
2379 state = D6_STATE(ifp);
2399 script_runreason(ifp, delegated ? "DELEGATED6" : state->reason);
2401 dhcpcd_daemonise(ifp->ctx);
2403 logger(ifp->ctx, LOG_DEBUG,
2404 "%s: waiting for DHCPv6 DAD to complete", ifp->name);
2408 dhcp6_delegate_prefix(struct interface *ifp)
2419 ifo = ifp->options;
2420 state = D6_STATE(ifp);
2431 if_find(ifp->ctx->ifaces, sla->ifname) == NULL)
2433 logger(ifp->ctx, LOG_INFO,
2435 if (dhcpcd_handleinterface(ifp->ctx, 2,
2437 logger(ifp->ctx, LOG_ERR,
2445 TAILQ_FOREACH(ifd, ifp->ctx->ifaces, next) {
2455 logger(ifp->ctx, LOG_DEBUG,
2457 ifp->name, ap->saddr);
2468 logger(ifp->ctx, LOG_DEBUG,
2476 NULL, ia, ifp))
2487 logger(ifp->ctx, LOG_DEBUG,
2495 sla, ia, ifp))
2521 dhcp6_find_delegates(struct interface *ifp)
2532 TAILQ_FOREACH(ifd, ifp->ctx->ifaces, next) {
2547 if (strcmp(ifp->name, sla->ifname))
2549 if (ipv6_linklocal(ifp) == NULL) {
2550 logger(ifp->ctx, LOG_DEBUG,
2554 ifp->name);
2555 ipv6_addlinklocalcallback(ifp,
2556 dhcp6_find_delegates1, ifp);
2559 if (dhcp6_ifdelegateaddr(ifp, ap,
2568 logger(ifp->ctx, LOG_INFO,
2569 "%s: adding delegated prefixes", ifp->name);
2570 state = D6_STATE(ifp);
2573 if_initrt6(ifp);
2574 ipv6_buildroutes(ifp->ctx);
2575 dhcp6_script_try_run(ifp, 1);
2581 dhcp6_findpfxdlgif(struct interface *ifp)
2585 if (ifp->options && ifp->options->options & DHCPCD_PFXDLGONLY)
2588 if (ifp->ctx && ifp->ctx->ifaces) {
2589 TAILQ_FOREACH(ifn, ifp->ctx->ifaces, next) {
2590 if (strcmp(ifn->name, ifp->name) == 0 &&
2608 struct interface *ifp, *ifpx;
2660 TAILQ_FOREACH(ifp, dctx->ifaces, next) {
2662 if (ifp->index == (unsigned int)pkt.ipi6_ifindex &&
2663 !(ifp->options->options & DHCPCD_PFXDLGONLY))
2666 if (ifp == NULL) {
2676 ifpx = dhcp6_findpfxdlgif(ifp);
2682 ifp = ifpx;
2685 state = D6_STATE(ifp);
2687 logger(ifp->ctx, LOG_DEBUG,
2688 "%s: DHCPv6 reply received but not running", ifp->name);
2697 logger(ifp->ctx, LOG_DEBUG,
2698 "%s: DHCPv6 reply received but already bound", ifp->name);
2710 ifp->name,
2719 logger(ifp->ctx, LOG_DEBUG, "%s: no DHCPv6 server ID from %s",
2720 ifp->name, ctx->sfrom);
2728 logger(ifp->ctx, LOG_DEBUG, "%s: incorrect client ID from %s",
2729 ifp->name, ctx->sfrom);
2733 ifo = ifp->options;
2741 logger(ifp->ctx, LOG_WARNING,
2743 ifp->name, opt->var, ctx->sfrom);
2749 logger(ifp->ctx, LOG_WARNING,
2751 ifp->name, opt->var, ctx->sfrom);
2763 logger(ifp->ctx, LOG_DEBUG, "dhcp_auth_validate: %m");
2764 logger(ifp->ctx, LOG_ERR,
2766 ifp->name, ctx->sfrom);
2770 logger(ifp->ctx, LOG_DEBUG,
2772 ifp->name, state->auth.token->secretid);
2774 logger(ifp->ctx, LOG_DEBUG,
2775 "%s: accepted reconfigure key", ifp->name);
2777 logger(ifp->ctx, LOG_ERR,
2778 "%s: no authentication from %s", ifp->name, ctx->sfrom);
2781 logger(ifp->ctx, LOG_WARNING,
2782 "%s: no authentication from %s", ifp->name, ctx->sfrom);
2789 if (dhcp6_checkstatusok(ifp, r, NULL, len) == -1)
2804 error = dhcp6_checkstatusok(ifp, r, NULL, len);
2811 dhcp6_validatelease(ifp, r, len,
2814 dhcp6_startdiscover(ifp);
2828 if (dhcp6_validatelease(ifp, r, len,
2834 if (dhcp6_hasprefixdelegation(ifp))
2835 dhcp6_startdiscover(ifp);
2854 logger(ifp->ctx, LOG_DEBUG,
2855 "%s: SOL_MAX_RT %llu -> %d", ifp->name,
2859 logger(ifp->ctx, LOG_ERR,
2861 ifp->name, u32);
2868 logger(ifp->ctx, LOG_DEBUG,
2870 ifp->name,
2874 logger(ifp->ctx, LOG_ERR,
2876 ifp->name, u32);
2878 if (dhcp6_validatelease(ifp, r, len, ctx->sfrom, NULL) == -1)
2883 logger(ifp->ctx, LOG_ERR,
2885 ifp->name, op, ctx->sfrom);
2888 logger(ifp->ctx, LOG_INFO, "%s: %s from %s",
2889 ifp->name, op, ctx->sfrom);
2892 logger(ifp->ctx, LOG_ERR,
2894 ifp->name);
2898 logger(ifp->ctx, LOG_ERR,
2899 "%s: missing Reconfigure Message type", ifp->name);
2905 logger(ifp->ctx, LOG_ERR,
2907 ifp->name, op);
2910 eloop_timeout_delete(ifp->ctx->eloop,
2911 dhcp6_startrenew, ifp);
2912 dhcp6_startrenew(ifp);
2916 logger(ifp->ctx, LOG_ERR,
2918 ifp->name, op);
2921 eloop_timeout_delete(ifp->ctx->eloop,
2922 dhcp6_sendinform, ifp);
2923 dhcp6_startinform(ifp);
2926 logger(ifp->ctx, LOG_ERR,
2928 ifp->name, op, *D6_COPTION_DATA(o));
2933 logger(ifp->ctx, LOG_ERR, "%s: invalid DHCP6 type %s (%d)",
2934 ifp->name, op, r->type);
2938 logger(ifp->ctx, LOG_WARNING,
2940 ifp->name, op, r->type);
2948 logger(ifp->ctx, LOG_ERR,
2949 "%s: malloc recv: %m", ifp->name);
2961 logger(ifp->ctx, LOG_INFO, "%s: ADV %s from %s",
2962 ifp->name, ap->saddr, ctx->sfrom);
2963 if (ifp->ctx->options & DHCPCD_TEST)
2965 dhcp6_startrequest(ifp);
2977 logger(ifp->ctx, has_new ? LOG_INFO : LOG_DEBUG,
2978 "%s: %s received from %s", ifp->name, op, ctx->sfrom);
2981 eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
3032 if (ifp->ctx->options & DHCPCD_TEST)
3033 script_runreason(ifp, "TEST");
3040 eloop_timeout_add_sec(ifp->ctx->eloop,
3043 dhcp6_startinform : dhcp6_startrenew, ifp);
3045 eloop_timeout_add_sec(ifp->ctx->eloop,
3046 (time_t)state->rebind, dhcp6_startrebind, ifp);
3048 eloop_timeout_add_sec(ifp->ctx->eloop,
3049 (time_t)state->expire, dhcp6_startexpire, ifp);
3052 ipv6nd_runignoredra(ifp);
3054 dhcp6_delegate_prefix(ifp);
3056 rpc_update_ipv6(ifp);
3060 logger(ifp->ctx, has_new ? LOG_INFO : LOG_DEBUG,
3062 ifp->name, state->renew);
3064 logger(ifp->ctx, has_new ? LOG_INFO : LOG_DEBUG,
3067 ifp->name, state->renew, state->rebind);
3069 logger(ifp->ctx, has_new ? LOG_INFO : LOG_DEBUG,
3070 "%s: will expire", ifp->name);
3071 if_initrt6(ifp);
3072 ipv6_buildroutes(ifp->ctx);
3073 dhcp6_writelease(ifp);
3074 dhcp6_script_try_run(ifp, 0);
3077 if (ifp->ctx->options & DHCPCD_TEST ||
3078 (ifp->options->options & DHCPCD_INFORM &&
3079 !(ifp->ctx->options & DHCPCD_MASTER)))
3081 eloop_exit(ifp->ctx->eloop, EXIT_SUCCESS);
3163 struct interface *ifp = arg;
3164 struct if_options *ifo = ifp->options;
3169 state = D6_STATE(ifp);
3188 if (dhcp6_findselfsla(ifp, NULL))
3193 dhcp6_hasprefixdelegation(ifp) > 1)
3195 const char * const argv[] = { ifp->name };
3199 ifn = dhcp6_findpfxdlgif(ifp);
3201 ifs = if_discover(ifp->ctx, -1, UNCONST(argv));
3205 logger(ifp->ctx, LOG_INFO,
3208 ifp->name);
3209 ifp->options->options |=
3217 ifp->lease_identifier,
3220 TAILQ_INSERT_AFTER(ifp->ctx->ifaces,
3221 ifp, ifn, next);
3224 eloop_timeout_add_sec(ifp->ctx->eloop,
3238 dhcp6_startinform(ifp);
3241 dhcp6_startinit(ifp);
3246 dhcp6_start(struct interface *ifp, enum DH6S init_state)
3250 state = D6_STATE(ifp);
3255 dhcp6_startinform(ifp);
3259 ifp->options->options & DHCPCD_DHCP6 &&
3272 if (!(ifp->options->options & DHCPCD_DHCP6))
3275 if (ifp->ctx->ipv6->dhcp_fd == -1 && dhcp6_open(ifp->ctx) == -1)
3278 ifp->if_data[IF_DATA_DHCP6] = calloc(1, sizeof(*state));
3279 state = D6_STATE(ifp);
3290 AF_INET6, ifp,
3291 ifp->options->options & DHCPCD_PFXDLGONLY ? ".pd" : "");
3292 if (ipv6_linklocal(ifp) == NULL) {
3293 logger(ifp->ctx, LOG_DEBUG,
3295 ifp->name);
3296 ipv6_addlinklocalcallback(ifp, dhcp6_start1, ifp);
3300 dhcp6_start1(ifp);
3305 dhcp6_reboot(struct interface *ifp)
3309 state = D6_STATE(ifp);
3313 dhcp6_startrebind(ifp);
3316 dhcp6_startinform(ifp);
3319 dhcp6_startdiscover(ifp);
3326 dhcp6_freedrop(struct interface *ifp, int drop, const char *reason)
3350 if (ifp->options)
3351 options = ifp->options->options;
3359 ifpx = dhcp6_findpfxdlgif(ifp);
3364 TAILQ_REMOVE(ifp->ctx->ifaces, ifpx, next);
3368 if (ifp->ctx->eloop)
3369 eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
3372 dhcp6_delete_delegates(ifp);
3374 state = D6_STATE(ifp);
3378 if (ifp->carrier == LINK_UP)
3379 dhcp6_startrelease(ifp);
3382 dhcp6_freedrop_addrs(ifp, drop, NULL);
3395 script_runreason(ifp, reason);
3401 ifp->if_data[IF_DATA_DHCP6] = NULL;
3406 ctx = ifp->ctx;
3408 TAILQ_FOREACH(ifp, ctx->ifaces, next) {
3409 if (D6_STATE(ifp))
3413 if (ifp == NULL && ctx->ipv6) {
3423 dhcp6_drop(struct interface *ifp, const char *reason)
3426 dhcp6_freedrop(ifp, 1, reason);
3430 dhcp6_free(struct interface *ifp)
3433 dhcp6_freedrop(ifp, 0, NULL);
3440 struct interface *ifp;
3446 TAILQ_FOREACH(ifp, ctx->ifaces, next) {
3447 state = D6_STATE(ifp);
3448 if (state == NULL || strcmp(ifp->name, ifname))
3456 dhcp6_env(char **env, const char *prefix, const struct interface *ifp,
3482 ifo = ifp->options;
3483 ctx = ifp->ctx;
3491 for (i = 0, opt = ifp->options->dhcp6_override;
3492 i < ifp->options->dhcp6_override_len;
3502 logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
3535 vo = vivso_find(en, ifp);
3548 n += dhcp_envoption(ifp->ctx,
3550 pfx, ifp->name,
3554 n += dhcp_envoption(ifp->ctx,
3556 pfx, ifp->name,
3566 state = D6_CSTATE(ifp);
3577 logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
3601 dhcp6_dump(struct interface *ifp)
3605 ifp->if_data[IF_DATA_DHCP6] = state = calloc(1, sizeof(*state));
3607 logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
3612 AF_INET6, ifp,
3613 ifp->options->options & DHCPCD_PFXDLGONLY ? ".pd" : "");
3614 if (dhcp6_readlease(ifp, 0) == -1) {
3615 logger(ifp->ctx, LOG_ERR, "%s: %s: %m",
3616 *ifp->name ? ifp->name : state->leasefile, __func__);
3620 return script_runreason(ifp, state->reason);