Specify the gateway address when updating the MTU and send/recv pipe
sizes on a route. IMHO this shouldn't be necessary (the destination & mask/prefixlen should be enough), but without it, the default route update under OpenBSD will fail. Thanks to: Russell T Hunt <alaric@MIT.EDU>
This commit is contained in:
parent
6de54bbe7a
commit
5ae083292b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=81739
@ -659,8 +659,14 @@ ipcp_SetIPaddress(struct ipcp *ipcp, struct in_addr myaddr,
|
||||
{
|
||||
struct bundle *bundle = ipcp->fsm.bundle;
|
||||
struct ncpaddr myncpaddr, hisncpaddr;
|
||||
struct ncprange myrange, dst;
|
||||
struct ncprange myrange;
|
||||
struct in_addr mask;
|
||||
struct sockaddr_storage ssdst, ssgw, ssmask;
|
||||
struct sockaddr *sadst, *sagw, *samask;
|
||||
|
||||
sadst = (struct sockaddr *)&ssdst;
|
||||
sagw = (struct sockaddr *)&ssgw;
|
||||
samask = (struct sockaddr *)&ssmask;
|
||||
|
||||
ncpaddr_setip4(&hisncpaddr, hisaddr);
|
||||
ncpaddr_setip4(&myncpaddr, myaddr);
|
||||
@ -681,8 +687,9 @@ ipcp_SetIPaddress(struct ipcp *ipcp, struct in_addr myaddr,
|
||||
IFACE_CLEAR_ALIASES|IFACE_SYSTEM);
|
||||
|
||||
if (bundle->ncp.cfg.sendpipe > 0 || bundle->ncp.cfg.recvpipe > 0) {
|
||||
ncprange_sethost(&dst, &hisncpaddr);
|
||||
rt_Update(bundle, &dst);
|
||||
ncprange_getsa(&myrange, &ssgw, &ssmask);
|
||||
ncpaddr_getsa(&hisncpaddr, &ssdst);
|
||||
rt_Update(bundle, sadst, sagw, samask);
|
||||
}
|
||||
|
||||
if (Enabled(bundle, OPT_SROUTES))
|
||||
|
@ -115,7 +115,13 @@ ipcp_SetIPv6address(struct ipv6cp *ipv6cp, u_int32_t mytok, u_int32_t histok)
|
||||
{
|
||||
struct bundle *bundle = ipv6cp->fsm.bundle;
|
||||
struct in6_addr myaddr, hisaddr;
|
||||
struct ncprange myrange, dst;
|
||||
struct ncprange myrange;
|
||||
struct sockaddr_storage ssdst, ssgw, ssmask;
|
||||
struct sockaddr *sadst, *sagw, *samask;
|
||||
|
||||
sadst = (struct sockaddr *)&ssdst;
|
||||
sagw = (struct sockaddr *)&ssgw;
|
||||
samask = (struct sockaddr *)&ssmask;
|
||||
|
||||
memset(&myaddr, '\0', sizeof myaddr);
|
||||
memset(&hisaddr, '\0', sizeof hisaddr);
|
||||
@ -141,8 +147,12 @@ ipcp_SetIPv6address(struct ipv6cp *ipv6cp, u_int32_t mytok, u_int32_t histok)
|
||||
IFACE_CLEAR_ALIASES|IFACE_SYSTEM);
|
||||
|
||||
if (bundle->ncp.cfg.sendpipe > 0 || bundle->ncp.cfg.recvpipe > 0) {
|
||||
ncprange_sethost(&dst, &ipv6cp->hisaddr);
|
||||
rt_Update(bundle, &dst);
|
||||
ncprange_getsa(&myrange, &ssgw, &ssmask);
|
||||
if (ncpaddr_isset(&ipv6cp->hisaddr))
|
||||
ncpaddr_getsa(&ipv6cp->hisaddr, &ssdst);
|
||||
else
|
||||
sadst = NULL;
|
||||
rt_Update(bundle, sadst, sagw, samask);
|
||||
}
|
||||
|
||||
if (Enabled(bundle, OPT_SROUTES))
|
||||
|
@ -184,6 +184,12 @@ ncpaddr_init(struct ncpaddr *addr)
|
||||
addr->ncpaddr_family = AF_UNSPEC;
|
||||
}
|
||||
|
||||
int
|
||||
ncpaddr_isset(const struct ncpaddr *addr)
|
||||
{
|
||||
return addr->ncpaddr_family != AF_UNSPEC;
|
||||
}
|
||||
|
||||
int
|
||||
ncpaddr_isdefault(const struct ncpaddr *addr)
|
||||
{
|
||||
|
@ -59,6 +59,7 @@ struct ncpaddr {
|
||||
struct ncp;
|
||||
|
||||
extern void ncpaddr_init(struct ncpaddr *);
|
||||
extern int ncpaddr_isset(const struct ncpaddr *);
|
||||
extern int ncpaddr_isdefault(const struct ncpaddr *);
|
||||
extern int ncpaddr_equal(const struct ncpaddr *, const struct ncpaddr *);
|
||||
extern void ncpaddr_copy(struct ncpaddr *, const struct ncpaddr *);
|
||||
|
@ -504,17 +504,19 @@ route_UpdateMTU(struct bundle *bundle)
|
||||
for (cp = sp; cp < ep; cp += rtm->rtm_msglen) {
|
||||
rtm = (struct rt_msghdr *)cp;
|
||||
route_ParseHdr(rtm, sa);
|
||||
if (sa[RTAX_DST] && sa[RTAX_DST]->sa_family == AF_INET &&
|
||||
sa[RTAX_GATEWAY] && /* sa[RTAX_NETMASK] && */
|
||||
rtm->rtm_index == bundle->iface->index &&
|
||||
(sa[RTAX_GATEWAY]->sa_family == AF_INET ||
|
||||
sa[RTAX_GATEWAY]->sa_family == AF_LINK)) {
|
||||
log_Printf(LogTCPIP, "route_UpdateMTU: Netif: %d (%s), dst %s, mtu %d\n",
|
||||
rtm->rtm_index, Index2Nam(rtm->rtm_index),
|
||||
inet_ntoa(((struct sockaddr_in *)sa[RTAX_DST])->sin_addr),
|
||||
bundle->iface->mtu);
|
||||
ncprange_setsa(&dst, sa[RTAX_DST], sa[RTAX_NETMASK]);
|
||||
rt_Update(bundle, &dst);
|
||||
if (sa[RTAX_DST] && (sa[RTAX_DST]->sa_family == AF_INET ||
|
||||
#ifndef NOINET6
|
||||
sa[RTAX_DST]->sa_family == AF_INET6
|
||||
#endif
|
||||
) &&
|
||||
sa[RTAX_GATEWAY] && rtm->rtm_index == bundle->iface->index) {
|
||||
if (log_IsKept(LogTCPIP)) {
|
||||
ncprange_setsa(&dst, sa[RTAX_DST], sa[RTAX_NETMASK]);
|
||||
log_Printf(LogTCPIP, "route_UpdateMTU: Netif: %d (%s), dst %s,"
|
||||
" mtu %d\n", rtm->rtm_index, Index2Nam(rtm->rtm_index),
|
||||
ncprange_ntoa(&dst), bundle->iface->mtu);
|
||||
}
|
||||
rt_Update(bundle, sa[RTAX_DST], sa[RTAX_GATEWAY], sa[RTAX_NETMASK]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -819,11 +821,13 @@ rt_Set(struct bundle *bundle, int cmd, const struct ncprange *dst,
|
||||
}
|
||||
|
||||
void
|
||||
rt_Update(struct bundle *bundle, const struct ncprange *dst)
|
||||
rt_Update(struct bundle *bundle, const struct sockaddr *dst,
|
||||
const struct sockaddr *gw, const struct sockaddr *mask)
|
||||
{
|
||||
struct ncprange ncpdst;
|
||||
struct rtmsg rtmes;
|
||||
char *p;
|
||||
int s, wb;
|
||||
struct sockaddr_storage sadst, samask;
|
||||
|
||||
s = ID0socket(PF_ROUTE, SOCK_RAW, 0);
|
||||
if (s < 0) {
|
||||
@ -834,7 +838,7 @@ rt_Update(struct bundle *bundle, const struct ncprange *dst)
|
||||
memset(&rtmes, '\0', sizeof rtmes);
|
||||
rtmes.m_rtm.rtm_version = RTM_VERSION;
|
||||
rtmes.m_rtm.rtm_type = RTM_CHANGE;
|
||||
rtmes.m_rtm.rtm_addrs = RTA_DST;
|
||||
rtmes.m_rtm.rtm_addrs = RTA_GATEWAY;
|
||||
rtmes.m_rtm.rtm_seq = ++bundle->routing_seq;
|
||||
rtmes.m_rtm.rtm_pid = getpid();
|
||||
rtmes.m_rtm.rtm_flags = RTF_UP | RTF_GATEWAY | RTF_STATIC;
|
||||
@ -851,27 +855,36 @@ rt_Update(struct bundle *bundle, const struct ncprange *dst)
|
||||
|
||||
rtmes.m_rtm.rtm_rmx.rmx_mtu = bundle->iface->mtu;
|
||||
rtmes.m_rtm.rtm_inits |= RTV_MTU;
|
||||
p = rtmes.m_space;
|
||||
|
||||
ncprange_getsa(dst, &sadst, &samask);
|
||||
if (dst) {
|
||||
rtmes.m_rtm.rtm_addrs |= RTA_DST;
|
||||
memcpy(p, dst, dst->sa_len);
|
||||
p += dst->sa_len;
|
||||
}
|
||||
memcpy(p, gw, gw->sa_len);
|
||||
p += gw->sa_len;
|
||||
if (mask) {
|
||||
rtmes.m_rtm.rtm_addrs |= RTA_NETMASK;
|
||||
memcpy(p, mask, mask->sa_len);
|
||||
p += mask->sa_len;
|
||||
}
|
||||
|
||||
memcpy(rtmes.m_space, &sadst, sadst.ss_len);
|
||||
memcpy(rtmes.m_space + sadst.ss_len, &samask, samask.ss_len);
|
||||
rtmes.m_rtm.rtm_msglen = rtmes.m_space - (char *)&rtmes;
|
||||
rtmes.m_rtm.rtm_msglen+= sadst.ss_len + samask.ss_len;
|
||||
rtmes.m_rtm.rtm_msglen = p - (char *)&rtmes;
|
||||
|
||||
wb = ID0write(s, &rtmes, rtmes.m_rtm.rtm_msglen);
|
||||
if (wb < 0) {
|
||||
ncprange_setsa(&ncpdst, dst, mask);
|
||||
|
||||
log_Printf(LogTCPIP, "rt_Update failure:\n");
|
||||
log_Printf(LogTCPIP, "rt_Update: Dst = %s\n", ncprange_ntoa(dst));
|
||||
log_Printf(LogTCPIP, "rt_Update: Dst = %s\n", ncprange_ntoa(&ncpdst));
|
||||
|
||||
if (rtmes.m_rtm.rtm_errno == 0)
|
||||
log_Printf(LogWARN, "%s: Change route failed: errno: %s\n",
|
||||
ncprange_ntoa(dst), strerror(errno));
|
||||
ncprange_ntoa(&ncpdst), strerror(errno));
|
||||
else
|
||||
log_Printf(LogWARN, "%s: Change route failed: %s\n",
|
||||
ncprange_ntoa(dst), strerror(rtmes.m_rtm.rtm_errno));
|
||||
ncprange_ntoa(&ncpdst), strerror(rtmes.m_rtm.rtm_errno));
|
||||
}
|
||||
log_Printf(LogDEBUG, "wrote %d: cmd = Change, dst = %s\n",
|
||||
wb, ncprange_ntoa(dst));
|
||||
close(s);
|
||||
}
|
||||
|
@ -69,4 +69,5 @@ extern void route_ShowSticky(struct prompt *, struct sticky_route *,
|
||||
extern void route_ParseHdr(struct rt_msghdr *, struct sockaddr *[RTAX_MAX]);
|
||||
extern int rt_Set(struct bundle *, int, const struct ncprange *,
|
||||
const struct ncpaddr *, int, int);
|
||||
extern void rt_Update(struct bundle *, const struct ncprange *);
|
||||
extern void rt_Update(struct bundle *, const struct sockaddr *,
|
||||
const struct sockaddr *, const struct sockaddr *);
|
||||
|
Loading…
Reference in New Issue
Block a user