When adding or changing routes, always supply IFP and IFA so we match

kernel messages 100%.
Restore purging kernel IPv6 routers.
This commit is contained in:
Roy Marples 2013-06-19 09:36:52 +00:00
parent 779ffd439d
commit af63ad90d6
3 changed files with 31 additions and 18 deletions

View File

@ -283,7 +283,13 @@ if_route(const struct rt *rt, int action)
if (rtm.hdr.rtm_addrs & RTA_NETMASK)
ADDADDR(&rt->net);
/* IFP here if we need it */
if (rtm.hdr.rtm_addrs & RTA_IFP) {
/* Make us a link layer socket for the host gateway */
memset(&su, 0, sizeof(su));
su.sdl.sdl_len = sizeof(struct sockaddr_dl);
link_addr(rt->iface->name, &su.sdl);
ADDSU;
}
if (rtm.hdr.rtm_addrs & RTA_IFA)
ADDADDR(&state->addr);
@ -412,8 +418,8 @@ if_route6(const struct rt6 *rt, int action)
#endif
rtm.hdr.rtm_addrs = RTA_DST | RTA_GATEWAY | RTA_NETMASK;
// if (action >= 0)
// rtm.hdr.rtm_addrs |= RTA_IFA;
if (action >= 0)
rtm.hdr.rtm_addrs |= RTA_IFP | RTA_IFA;
ADDADDR(&rt->dest);
if (!(rtm.hdr.rtm_flags & RTF_GATEWAY)) {
@ -421,8 +427,10 @@ if_route6(const struct rt6 *rt, int action)
if (lla == NULL) /* unlikely as we need a LL to get here */
return -1;
ADDADDRS(&lla->addr, rt->iface->index);
} else
} else {
lla = NULL;
ADDADDRS(&rt->gate, rt->iface->index);
}
if (rtm.hdr.rtm_addrs & RTA_NETMASK) {
if (rtm.hdr.rtm_flags & RTF_GATEWAY) {
@ -433,8 +441,22 @@ if_route6(const struct rt6 *rt, int action)
ADDADDR(&rt->net);
}
/* IFP here if we need it */
/* IFA here if we need it */
if (rtm.hdr.rtm_addrs & RTA_IFP) {
/* Make us a link layer socket for the host gateway */
memset(&su, 0, sizeof(su));
su.sdl.sdl_len = sizeof(struct sockaddr_dl);
link_addr(rt->iface->name, &su.sdl);
ADDSU;
}
if (rtm.hdr.rtm_addrs & RTA_IFA) {
if (lla == NULL) {
lla = ipv6_linklocal(rt->iface);
if (lla == NULL) /* unlikely */
return -1;
}
ADDADDRS(&lla->addr, rt->iface->index);
}
#undef ADDADDR
#undef ADDSU

4
ipv6.c
View File

@ -418,11 +418,9 @@ ipv6_addaddr(struct ipv6_addr *ap)
ap->flags |= IPV6_AF_ADDED;
if (ap->delegating_iface)
ap->flags |= IPV6_AF_DELEGATED;
#if HAVE_ROUTE_METRIC
if (ap->iface->options->options & DHCPCD_IPV6RA_OWN &&
ipv6_removesubnet(ap->iface, ap) == -1)
syslog(LOG_ERR,"ipv6_removesubnet %m");
#endif
if (ap->prefix_pltime == ND6_INFINITE_LIFETIME &&
ap->prefix_vltime == ND6_INFINITE_LIFETIME)
syslog(LOG_DEBUG,
@ -842,7 +840,6 @@ make_router(const struct ra *rap)
return r;
}
#if HAVE_ROUTE_METRIC
int
ipv6_removesubnet(const struct interface *ifp, struct ipv6_addr *addr)
{
@ -881,7 +878,6 @@ ipv6_removesubnet(const struct interface *ifp, struct ipv6_addr *addr)
}
return r;
}
#endif
#define RT_IS_DEFAULT(rtp) \
(IN6_ARE_ADDR_EQUAL(&((rtp)->dest), &in6addr_any) && \

View File

@ -99,7 +99,6 @@ restore_kernel_ra(void)
syslog(LOG_ERR, "IPV6CTL_ACCEPT_RTADV: %m");
}
#if 0
static int
ipv6_ra_flush(void)
{
@ -112,12 +111,11 @@ ipv6_ra_flush(void)
strcpy(dummy, "lo0");
if (ioctl(s, SIOCSRTRFLUSH_IN6, (caddr_t)&dummy) == -1)
syslog(LOG_ERR, "SIOSRTRFLUSH_IN6: %m");
if (ioctl(s, SIOCSPFXFLUSH_IN6, (caddr_t)&dummy) == -1)
syslog(LOG_ERR, "SIOSPFXFLUSH_IN6: %m");
// if (ioctl(s, SIOCSPFXFLUSH_IN6, (caddr_t)&dummy) == -1)
// syslog(LOG_ERR, "SIOSPFXFLUSH_IN6: %m");
close(s);
return 0;
}
#endif
int
check_ipv6(const char *ifname)
@ -162,11 +160,8 @@ check_ipv6(const char *ifname)
return 0;
}
#if 0
/* I am not convinced this is right as it sometimes makes our own
* added routes disappear. */
/* Flush the kernel knowledge of advertised routers */
ipv6_ra_flush();
#endif
return 1;
}