Lines Matching refs:ifp
228 ipv6nd_makersprobe(struct interface *ifp) in ipv6nd_makersprobe() argument
234 state = RS_STATE(ifp); in ipv6nd_makersprobe()
236 state->rslen = sizeof(*rs) + (size_t)ROUNDUP8(ifp->hwlen + 2); in ipv6nd_makersprobe()
247 nd->nd_opt_len = (uint8_t)((ROUNDUP8(ifp->hwlen + 2)) >> 3); in ipv6nd_makersprobe()
248 memcpy(nd + 1, ifp->hwaddr, ifp->hwlen); in ipv6nd_makersprobe()
255 struct interface *ifp = arg; in ipv6nd_sendrsprobe() local
262 if (ipv6_linklocal(ifp) == NULL) { in ipv6nd_sendrsprobe()
263 logger(ifp->ctx, LOG_DEBUG, in ipv6nd_sendrsprobe()
265 ifp->name); in ipv6nd_sendrsprobe()
266 ipv6_addlinklocalcallback(ifp, ipv6nd_sendrsprobe, ifp); in ipv6nd_sendrsprobe()
275 dst.sin6_scope_id = ifp->index; in ipv6nd_sendrsprobe()
277 logger(ifp->ctx, LOG_ERR, "%s: %m", __func__); in ipv6nd_sendrsprobe()
281 state = RS_STATE(ifp); in ipv6nd_sendrsprobe()
282 ctx = ifp->ctx->ipv6; in ipv6nd_sendrsprobe()
295 pi.ipi6_ifindex = ifp->index; in ipv6nd_sendrsprobe()
298 logger(ifp->ctx, LOG_DEBUG, in ipv6nd_sendrsprobe()
299 "%s: sending Router Solicitation", ifp->name); in ipv6nd_sendrsprobe()
301 logger(ifp->ctx, LOG_ERR, in ipv6nd_sendrsprobe()
302 "%s: %s: sendmsg: %m", ifp->name, __func__); in ipv6nd_sendrsprobe()
303 ipv6nd_drop(ifp); in ipv6nd_sendrsprobe()
304 ifp->options->options &= ~(DHCPCD_IPV6 | DHCPCD_IPV6RS); in ipv6nd_sendrsprobe()
309 eloop_timeout_add_sec(ifp->ctx->eloop, in ipv6nd_sendrsprobe()
310 RTR_SOLICITATION_INTERVAL, ipv6nd_sendrsprobe, ifp); in ipv6nd_sendrsprobe()
312 logger(ifp->ctx, LOG_WARNING, in ipv6nd_sendrsprobe()
313 "%s: no IPv6 Routers available", ifp->name); in ipv6nd_sendrsprobe()
314 ipv6nd_drop(ifp); in ipv6nd_sendrsprobe()
315 dhcp6_drop(ifp, "EXPIRE6"); in ipv6nd_sendrsprobe()
320 ipv6nd_expire(struct interface *ifp, uint32_t seconds) in ipv6nd_expire() argument
327 TAILQ_FOREACH(rap, ifp->ctx->ipv6->ra_routers, next) { in ipv6nd_expire()
328 if (rap->iface == ifp) { in ipv6nd_expire()
350 ipv6nd_expirera(ifp); in ipv6nd_expire()
352 ipv6_buildroutes(ifp->ctx); in ipv6nd_expire()
449 ipv6nd_free(struct interface *ifp) in ipv6nd_free() argument
456 state = RS_STATE(ifp); in ipv6nd_free()
462 ifp->if_data[IF_DATA_IPV6ND] = NULL; in ipv6nd_free()
464 TAILQ_FOREACH_SAFE(rap, ifp->ctx->ipv6->ra_routers, next, ran) { in ipv6nd_free()
465 if (rap->iface == ifp) { in ipv6nd_free()
473 ctx = ifp->ctx; in ipv6nd_free()
474 TAILQ_FOREACH(ifp, ctx->ifaces, next) { in ipv6nd_free()
475 if (RS_STATE(ifp)) in ipv6nd_free()
478 if (ifp == NULL) { in ipv6nd_free()
580 ifp->name); in ipv6nd_scriptrun()
595 ipv6nd_dadcompleted(const struct interface *ifp) in ipv6nd_dadcompleted() argument
600 TAILQ_FOREACH(rap, ifp->ctx->ipv6->ra_routers, next) { in ipv6nd_dadcompleted()
601 if (rap->iface != ifp) in ipv6nd_dadcompleted()
617 struct interface *ifp; in ipv6nd_dadcallback() local
625 ifp = ap->iface; in ipv6nd_dadcallback()
630 logger(ifp->ctx, LOG_WARNING, "%s: DAD detected %s", in ipv6nd_dadcallback()
631 ifp->name, ap->saddr); in ipv6nd_dadcallback()
637 if (ifp->options->options & DHCPCD_SLAACPRIVATE) { in ipv6nd_dadcallback()
639 logger(ifp->ctx, LOG_ERR, in ipv6nd_dadcallback()
642 ifp->name); in ipv6nd_dadcallback()
645 logger(ifp->ctx, LOG_INFO, "%s: deleting address %s", in ipv6nd_dadcallback()
646 ifp->name, ap->saddr); in ipv6nd_dadcallback()
649 logger(ifp->ctx, LOG_ERR, "if_deladdress6: %m"); in ipv6nd_dadcallback()
653 ifp, &dadcounter) == -1) in ipv6nd_dadcallback()
655 logger(ifp->ctx, LOG_ERR, in ipv6nd_dadcallback()
657 ifp->name); in ipv6nd_dadcallback()
675 eloop_timeout_add_tv(ifp->ctx->eloop, &tv, in ipv6nd_dadcallback()
683 TAILQ_FOREACH(rap, ifp->ctx->ipv6->ra_routers, next) { in ipv6nd_dadcallback()
684 if (rap->iface != ifp) in ipv6nd_dadcallback()
725 ipv6nd_handlera(struct dhcpcd_ctx *dctx, struct interface *ifp, in ipv6nd_handlera() argument
764 if (ifp == NULL) { in ipv6nd_handlera()
771 if (!(ifp->options->options & DHCPCD_IPV6RS)) { in ipv6nd_handlera()
773 logger(ifp->ctx, LOG_DEBUG, "%s: unexpected RA from %s", in ipv6nd_handlera()
774 ifp->name, ctx->sfrom); in ipv6nd_handlera()
780 if (ipv6_linklocal(ifp) == NULL) { in ipv6nd_handlera()
782 logger(ifp->ctx, LOG_DEBUG, in ipv6nd_handlera()
784 ifp->name, ctx->sfrom); in ipv6nd_handlera()
789 if (ipv6_iffindaddr(ifp, &ctx->from.sin6_addr)) { in ipv6nd_handlera()
790 logger(ifp->ctx, LOG_DEBUG, in ipv6nd_handlera()
791 "%s: ignoring RA from ourself %s", ifp->name, ctx->sfrom); in ipv6nd_handlera()
796 if (ifp == rap->iface && in ipv6nd_handlera()
816 if (new_data || ifp->options->options & DHCPCD_DEBUG) in ipv6nd_handlera()
817 logger(ifp->ctx, LOG_INFO, "%s: Router Advertisement from %s", in ipv6nd_handlera()
818 ifp->name, ctx->sfrom); in ipv6nd_handlera()
823 logger(ifp->ctx, LOG_ERR, "%s: %m", __func__); in ipv6nd_handlera()
826 rap->iface = ifp; in ipv6nd_handlera()
837 logger(ifp->ctx, LOG_ERR, "%s: %m", __func__); in ipv6nd_handlera()
849 logger(ifp->ctx, LOG_WARNING, "%s: %s router available", in ipv6nd_handlera()
850 ifp->name, rap->sfrom); in ipv6nd_handlera()
862 ipv6_settempstale(ifp); in ipv6nd_handlera()
872 logger(ifp->ctx, LOG_ERR, in ipv6nd_handlera()
873 "%s: short option", ifp->name); in ipv6nd_handlera()
879 logger(ifp->ctx, LOG_ERR, in ipv6nd_handlera()
880 "%s: zero length option", ifp->name); in ipv6nd_handlera()
884 logger(ifp->ctx, LOG_ERR, in ipv6nd_handlera()
885 "%s: option length exceeds message", ifp->name); in ipv6nd_handlera()
894 logger(ifp->ctx, new_data ? LOG_ERR : LOG_DEBUG, in ipv6nd_handlera()
896 ifp->name); in ipv6nd_handlera()
900 logger(ifp->ctx, new_data ? LOG_ERR : LOG_DEBUG, in ipv6nd_handlera()
902 ifp->name); in ipv6nd_handlera()
908 logger(ifp->ctx, new_data ? LOG_ERR : LOG_DEBUG, in ipv6nd_handlera()
909 "%s: invalid prefix in RA", ifp->name); in ipv6nd_handlera()
915 logger(ifp->ctx, new_data ? LOG_ERR : LOG_DEBUG, in ipv6nd_handlera()
916 "%s: pltime > vltime", ifp->name); in ipv6nd_handlera()
944 ipv6_makeaddr(&ap->addr, ifp, in ipv6nd_handlera()
975 if (ipv6_iffindaddr(ifp, &ap->addr) && in ipv6nd_handlera()
1033 logger(ifp->ctx, LOG_ERR, "%s: invalid MTU %d", in ipv6nd_handlera()
1034 ifp->name, mtuv); in ipv6nd_handlera()
1053 r = ipv6_printaddr(NULL, 0, op, ifp->name); in ipv6nd_handlera()
1068 ifp->name); in ipv6nd_handlera()
1090 logger(ifp->ctx, new_data ? LOG_ERR : LOG_DEBUG, in ipv6nd_handlera()
1092 ifp->name); in ipv6nd_handlera()
1110 logger(ifp->ctx, LOG_ERR, in ipv6nd_handlera()
1122 logger(ifp->ctx, LOG_ERR, "%s: %m", __func__); in ipv6nd_handlera()
1147 logger(ifp->ctx, LOG_ERR, "%s: %m", __func__); in ipv6nd_handlera()
1171 add_router(ifp->ctx->ipv6, rap); in ipv6nd_handlera()
1185 if (ifp->ctx->options & DHCPCD_TEST) { in ipv6nd_handlera()
1186 script_runreason(ifp, "TEST"); in ipv6nd_handlera()
1191 ipv6_addtempaddrs(ifp, &rap->received); in ipv6nd_handlera()
1197 if_initrt6(ifp); in ipv6nd_handlera()
1199 ipv6_buildroutes(ifp->ctx); in ipv6nd_handlera()
1203 eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); in ipv6nd_handlera()
1204 eloop_timeout_delete(ifp->ctx->eloop, NULL, rap); /* reachable timer */ in ipv6nd_handlera()
1207 if (!(ifp->options->options & DHCPCD_DHCP6)) in ipv6nd_handlera()
1210 if (new_data && dhcp6_start(ifp, DH6S_INIT) == -1) in ipv6nd_handlera()
1211 logger(ifp->ctx, LOG_ERR, in ipv6nd_handlera()
1212 "dhcp6_start: %s: %m", ifp->name); in ipv6nd_handlera()
1214 if (new_data && dhcp6_start(ifp, DH6S_INFORM) == -1) in ipv6nd_handlera()
1215 logger(ifp->ctx, LOG_ERR, in ipv6nd_handlera()
1216 "dhcp6_start: %s: %m", ifp->name); in ipv6nd_handlera()
1219 logger(ifp->ctx, LOG_DEBUG, in ipv6nd_handlera()
1220 "%s: No DHCPv6 instruction in RA", ifp->name); in ipv6nd_handlera()
1222 if (ifp->ctx->options & DHCPCD_TEST) { in ipv6nd_handlera()
1223 eloop_exit(ifp->ctx->eloop, EXIT_SUCCESS); in ipv6nd_handlera()
1229 ipv6nd_expirera(ifp); in ipv6nd_handlera()
1235 ipv6nd_runignoredra(struct interface *ifp) in ipv6nd_runignoredra() argument
1239 TAILQ_FOREACH(rap, ifp->ctx->ipv6->ra_routers, next) { in ipv6nd_runignoredra()
1240 if (rap->iface == ifp && in ipv6nd_runignoredra()
1248 if (ifp->ctx->options & DHCPCD_TEST) { in ipv6nd_runignoredra()
1249 script_runreason(ifp, "TEST"); in ipv6nd_runignoredra()
1254 eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); in ipv6nd_runignoredra()
1255 eloop_timeout_delete(ifp->ctx->eloop, NULL, rap); in ipv6nd_runignoredra()
1261 ipv6nd_hasra(const struct interface *ifp) in ipv6nd_hasra() argument
1265 if (ifp->ctx->ipv6) { in ipv6nd_hasra()
1266 TAILQ_FOREACH(rap, ifp->ctx->ipv6->ra_routers, next) in ipv6nd_hasra()
1267 if (rap->iface == ifp && !rap->expired) in ipv6nd_hasra()
1274 ipv6nd_hasradhcp(const struct interface *ifp) in ipv6nd_hasradhcp() argument
1278 if (ifp->ctx->ipv6) { in ipv6nd_hasradhcp()
1279 TAILQ_FOREACH(rap, ifp->ctx->ipv6->ra_routers, next) { in ipv6nd_hasradhcp()
1280 if (rap->iface == ifp && in ipv6nd_hasradhcp()
1290 ipv6nd_env(char **env, const char *prefix, const struct interface *ifp) in ipv6nd_env() argument
1300 TAILQ_FOREACH(rap, ifp->ctx->ipv6->ra_routers, next) { in ipv6nd_env()
1301 if (rap->iface != ifp) in ipv6nd_env()
1307 setvar(ifp->ctx, &env, prefix, buffer, rap->sfrom); in ipv6nd_env()
1349 logger(ifp->ctx, LOG_ERR, in ipv6nd_env()
1371 logger(ifp->ctx, in ipv6nd_env()
1385 logger(ifp->ctx, LOG_ERR, in ipv6nd_env()
1392 setvar(ifp->ctx, &env, in ipv6nd_env()
1399 setvard(ifp->ctx, &env, prefix, "ra_count", i); in ipv6nd_env()
1422 struct interface *ifp; in ipv6nd_expirera() local
1428 ifp = arg; in ipv6nd_expirera()
1434 TAILQ_FOREACH_SAFE(rap, ifp->ctx->ipv6->ra_routers, next, ran) { in ipv6nd_expirera()
1435 if (rap->iface != ifp) in ipv6nd_expirera()
1445 logger(ifp->ctx, LOG_WARNING, in ipv6nd_expirera()
1447 ifp->name, rap->sfrom); in ipv6nd_expirera()
1483 logger(ifp->ctx, LOG_WARNING, in ipv6nd_expirera()
1485 ifp->name, rap->sfrom, rao->type); in ipv6nd_expirera()
1507 eloop_timeout_add_tv(ifp->ctx->eloop, in ipv6nd_expirera()
1508 &next, ipv6nd_expirera, ifp); in ipv6nd_expirera()
1510 ipv6_buildroutes(ifp->ctx); in ipv6nd_expirera()
1511 script_runreason(ifp, "ROUTERADVERT"); in ipv6nd_expirera()
1516 dhcp6_drop(ifp, "EXPIRE6"); in ipv6nd_expirera()
1520 ipv6nd_drop(struct interface *ifp) in ipv6nd_drop() argument
1526 if (ifp->ctx->ipv6 == NULL) in ipv6nd_drop()
1529 eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); in ipv6nd_drop()
1531 TAILQ_FOREACH(rap, ifp->ctx->ipv6->ra_routers, next) { in ipv6nd_drop()
1532 if (rap->iface == ifp) { in ipv6nd_drop()
1534 TAILQ_REMOVE(ifp->ctx->ipv6->ra_routers, rap, next); in ipv6nd_drop()
1543 ipv6_buildroutes(ifp->ctx); in ipv6nd_drop()
1544 if ((ifp->options->options & in ipv6nd_drop()
1547 script_runreason(ifp, "ROUTERADVERT"); in ipv6nd_drop()
1552 ipv6nd_handlena(struct dhcpcd_ctx *dctx, struct interface *ifp, in ipv6nd_handlena() argument
1562 if (ifp == NULL) { in ipv6nd_handlena()
1571 logger(ifp->ctx, LOG_ERR, "%s: IPv6 NA too short from %s", in ipv6nd_handlena()
1572 ifp->name, ctx->sfrom); in ipv6nd_handlena()
1583 logger(ifp->ctx, LOG_ERR, "%s: NA multicast address %s (%s)", in ipv6nd_handlena()
1584 ifp->name, taddr, ctx->sfrom); in ipv6nd_handlena()
1589 if (rap->iface == ifp && in ipv6nd_handlena()
1595 logger(ifp->ctx, LOG_DEBUG, "%s: unexpected NA from %s for %s", in ipv6nd_handlena()
1596 ifp->name, ctx->sfrom, taddr); in ipv6nd_handlena()
1602 logger(ifp->ctx, LOG_DEBUG, "%s: %sNA for %s from %s", in ipv6nd_handlena()
1603 ifp->name, is_solicited ? "solicited " : "", taddr, ctx->sfrom); in ipv6nd_handlena()
1608 logger(ifp->ctx, LOG_INFO, "%s: %s not a router (%s)", in ipv6nd_handlena()
1609 ifp->name, taddr, ctx->sfrom); in ipv6nd_handlena()
1611 ipv6_buildroutes(ifp->ctx); in ipv6nd_handlena()
1612 script_runreason(ifp, "ROUTERADVERT"); in ipv6nd_handlena()
1619 logger(ifp->ctx, LOG_INFO, "%s: %s reachable (%s)", in ipv6nd_handlena()
1620 ifp->name, taddr, ctx->sfrom); in ipv6nd_handlena()
1621 ipv6_buildroutes(ifp->ctx); in ipv6nd_handlena()
1637 struct interface *ifp; in ipv6nd_handledata() local
1686 TAILQ_FOREACH(ifp, dctx->ifaces, next) { in ipv6nd_handledata()
1687 if (ifp->index == (unsigned int)pkt.ipi6_ifindex && in ipv6nd_handledata()
1688 !(ifp->options->options & DHCPCD_PFXDLGONLY)) in ipv6nd_handledata()
1690 if (!(ifp->options->options & DHCPCD_IPV6)) in ipv6nd_handledata()
1700 ipv6nd_handlena(dctx, ifp, icp, (size_t)len); in ipv6nd_handledata()
1703 ipv6nd_handlera(dctx, ifp, icp, (size_t)len); in ipv6nd_handledata()
1715 struct interface *ifp = arg; in ipv6nd_startrs1() local
1718 logger(ifp->ctx, LOG_INFO, "%s: soliciting an IPv6 router", ifp->name); in ipv6nd_startrs1()
1719 if (ipv6nd_open(ifp->ctx) == -1) { in ipv6nd_startrs1()
1720 logger(ifp->ctx, LOG_ERR, "%s: ipv6nd_open: %m", __func__); in ipv6nd_startrs1()
1724 state = RS_STATE(ifp); in ipv6nd_startrs1()
1726 ifp->if_data[IF_DATA_IPV6ND] = calloc(1, sizeof(*state)); in ipv6nd_startrs1()
1727 state = RS_STATE(ifp); in ipv6nd_startrs1()
1729 logger(ifp->ctx, LOG_ERR, "%s: %m", __func__); in ipv6nd_startrs1()
1736 ipv6nd_makersprobe(ifp); in ipv6nd_startrs1()
1738 logger(ifp->ctx, LOG_ERR, in ipv6nd_startrs1()
1744 ipv6nd_sendrsprobe(ifp); in ipv6nd_startrs1()
1748 ipv6nd_startrs(struct interface *ifp) in ipv6nd_startrs() argument
1752 eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); in ipv6nd_startrs()
1757 logger(ifp->ctx, LOG_DEBUG, in ipv6nd_startrs()
1759 ifp->name, timespec_to_double(&tv)); in ipv6nd_startrs()
1760 eloop_timeout_add_tv(ifp->ctx->eloop, &tv, ipv6nd_startrs1, ifp); in ipv6nd_startrs()