state->raw_fd = -1;
/* Now is a good time to find IPv4 routes */
- if_initrt(ifp);
+ if_initrt(ifp->ctx);
}
state->state = DHS_INIT;
if (k && !carrier_warned) {
ifd_state = D6_STATE(ifd);
ipv6_addaddrs(&ifd_state->addrs);
- if_initrt6(ifd);
+ if_initrt(ifd->ctx);
ipv6_buildroutes(ifd->ctx);
dhcp6_script_try_run(ifd, 1);
}
state = D6_STATE(ifp);
state->state = DH6S_DELEGATED;
ipv6_addaddrs(&state->addrs);
- if_initrt6(ifp);
+ if_initrt6(ifp->ctx);
ipv6_buildroutes(ifp->ctx);
dhcp6_script_try_run(ifp, 1);
}
else if (state->expire == 0)
logger(ifp->ctx, has_new ? LOG_INFO : LOG_DEBUG,
"%s: will expire", ifp->name);
- if_initrt6(ifp);
+ if_initrt6(ifp->ctx);
ipv6_buildroutes(ifp->ctx);
dhcp6_writelease(ifp);
dhcp6_delegate_prefix(ifp);
}
int
-if_initrt(struct interface *ifp)
+if_initrt(struct dhcpcd_ctx *ctx)
{
struct rt_msghdr *rtm;
int mib[6];
char *buf, *p, *end;
struct rt rt;
- ipv4_freerts(ifp->ctx->ipv4_kroutes);
+ ipv4_freerts(ctx->ipv4_kroutes);
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
end = buf + needed;
for (p = buf; p < end; p += rtm->rtm_msglen) {
rtm = (void *)p;
- if (if_copyrt(ifp->ctx, &rt, rtm) == 0)
- ipv4_handlert(ifp->ctx, RTM_ADD, &rt, 1);
+ if (if_copyrt(ctx, &rt, rtm) == 0)
+ ipv4_handlert(ctx, RTM_ADD, &rt, 1);
}
free(buf);
return 0;
}
int
-if_initrt6(struct interface *ifp)
+if_initrt6(struct dhcpcd_ctx *ctx)
{
struct rt_msghdr *rtm;
int mib[6];
char *buf, *p, *end;
struct rt6 rt;
- ipv6_freerts(&ifp->ctx->ipv6->kroutes);
+ ipv6_freerts(&ctx->ipv6->kroutes);
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
end = buf + needed;
for (p = buf; p < end; p += rtm->rtm_msglen) {
rtm = (void *)p;
- if (if_copyrt6(ifp->ctx, &rt, rtm) == 0)
- ipv6_handlert(ifp->ctx, RTM_ADD, &rt);
+ if (if_copyrt6(ctx, &rt, rtm) == 0)
+ ipv6_handlert(ctx, RTM_ADD, &rt);
}
free(buf);
return 0;
}
int
-if_initrt(struct interface *ifp)
+if_initrt(struct dhcpcd_ctx *ctx)
{
struct nlmr nlm;
- ipv4_freerts(ifp->ctx->ipv4_kroutes);
+ ipv4_freerts(ctx->ipv4_kroutes);
memset(&nlm, 0, sizeof(nlm));
nlm.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
nlm.hdr.nlmsg_flags |= NLM_F_REQUEST;
nlm.rt.rtm_family = AF_INET;
nlm.rt.rtm_table = RT_TABLE_MAIN;
- add_attr_32(&nlm.hdr, sizeof(nlm), RTA_OIF, ifp->index);
- return send_netlink(ifp->ctx, ifp,
- NETLINK_ROUTE, &nlm.hdr, &_if_initrt);
+ return send_netlink(ctx, NULL, NETLINK_ROUTE, &nlm.hdr, &_if_initrt);
}
int
}
int
-if_initrt6(struct interface *ifp)
+if_initrt6(struct dhcpcd_ctx *ctx)
{
struct nlmr nlm;
- ipv6_freerts(&ifp->ctx->ipv6->kroutes);
+ ipv6_freerts(&ctx->ipv6->kroutes);
memset(&nlm, 0, sizeof(nlm));
nlm.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
nlm.hdr.nlmsg_flags |= NLM_F_REQUEST;
nlm.rt.rtm_family = AF_INET6;
nlm.rt.rtm_table = RT_TABLE_MAIN;
- add_attr_32(&nlm.hdr, sizeof(nlm), RTA_OIF, ifp->index);
- return send_netlink(ifp->ctx, ifp,
- NETLINK_ROUTE, &nlm.hdr, &_if_initrt6);
+ return send_netlink(ctx, NULL, NETLINK_ROUTE, &nlm.hdr, &_if_initrt6);
}
int
int if_addrflags(const struct in_addr *, const struct interface *);
int if_route(unsigned char, const struct rt *rt);
-int if_initrt(struct interface *);
+int if_initrt(struct dhcpcd_ctx *);
#endif
#ifdef INET6
int if_getlifetime6(struct ipv6_addr *);
int if_route6(unsigned char, const struct rt6 *rt);
-int if_initrt6(struct interface *);
+int if_initrt6(struct dhcpcd_ctx *);
#else
#define if_checkipv6(a, b, c) (-1)
#endif
/* Find any freshly added routes, such as the subnet route.
* We do this because we cannot rely on recieving the kernel
* notification right now via our link socket. */
- if_initrt(ifp);
+ if_initrt(ifp->ctx);
ipv4_buildroutes(ifp->ctx);
/* Announce the address */
if (ifo->options & DHCPCD_ARP) {
return;
}
timespecclear(&state->defend);
- if_initrt(ifp);
+ if_initrt(ifp->ctx);
ipv4_buildroutes(ifp->ctx);
arp_announce(astate);
script_runreason(ifp, "IPV4LL");
/* If any interface is running IPv4LL, rebuild our routing table. */
TAILQ_FOREACH(ifp, ctx->ifaces, next) {
- if (IPV4LL_STATE_RUNNING(ifp))
+ if (IPV4LL_STATE_RUNNING(ifp)) {
+ if_initrt(ifp->ctx);
+ ipv4_buildroutes(ifp->ctx);
break;
- }
- if (ifp != NULL) {
- if_initrt(ifp);
- ipv4_buildroutes(ctx);
+ }
}
return 0;
ia->prefix_pltime = ND6_INFINITE_LIFETIME;
ia->dadcallback = ipv6_staticdadcallback;
ipv6_addaddr(ia, NULL);
- if_initrt6(ifp);
+ if_initrt6(ifp->ctx);
ipv6_buildroutes(ifp->ctx);
if (run_script)
script_runreason(ifp, "STATIC6");
}
/* Load existing routes */
- if_initrt6(ifp);
+ if_initrt6(ifp->ctx);
if (!IN6_IS_ADDR_UNSPECIFIED(&ifp->options->req_addr6))
ipv6_buildroutes(ifp->ctx);
return 0;
ipv6_freedrop_addrs(&state->addrs, drop ? 2 : 0, NULL);
if (drop) {
if (ifp->ctx->ipv6 != NULL) {
- if_initrt6(ifp);
+ if_initrt6(ifp->ctx);
ipv6_buildroutes(ifp->ctx);
}
} else {
/* Find any freshly added routes, such as the subnet route.
* We do this because we cannot rely on recieving the kernel
* notification right now via our link socket. */
- if_initrt6(ifp);
+ if_initrt6(ifp->ctx);
ipv6_buildroutes(ifp->ctx);
if (ipv6nd_scriptrun(rap))