sync with OpenBSD -current
This commit is contained in:
parent
fe0bbab526
commit
6d4aa64db6
32 changed files with 551 additions and 517 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: in_pcb.c,v 1.287 2024/01/28 20:34:25 bluhm Exp $ */
|
||||
/* $OpenBSD: in_pcb.c,v 1.288 2024/01/31 12:27:57 bluhm Exp $ */
|
||||
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -909,6 +909,11 @@ in_pcbrtentry(struct inpcb *inp)
|
|||
{
|
||||
struct route *ro;
|
||||
|
||||
#ifdef INET6
|
||||
if (ISSET(inp->inp_flags, INP_IPV6))
|
||||
in6_pcbrtentry(inp);
|
||||
#endif
|
||||
|
||||
ro = &inp->inp_route;
|
||||
|
||||
/* check if route is still valid */
|
||||
|
@ -921,34 +926,16 @@ in_pcbrtentry(struct inpcb *inp)
|
|||
* No route yet, so try to acquire one.
|
||||
*/
|
||||
if (ro->ro_rt == NULL) {
|
||||
#ifdef INET6
|
||||
memset(ro, 0, sizeof(struct route_in6));
|
||||
#else
|
||||
memset(ro, 0, sizeof(struct route));
|
||||
#endif
|
||||
|
||||
#ifdef INET6
|
||||
if (ISSET(inp->inp_flags, INP_IPV6)) {
|
||||
if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6))
|
||||
return (NULL);
|
||||
ro->ro_dst.sa_family = AF_INET6;
|
||||
ro->ro_dst.sa_len = sizeof(struct sockaddr_in6);
|
||||
satosin6(&ro->ro_dst)->sin6_addr = inp->inp_faddr6;
|
||||
ro->ro_tableid = inp->inp_rtableid;
|
||||
ro->ro_rt = rtalloc_mpath(&ro->ro_dst,
|
||||
&inp->inp_laddr6.s6_addr32[0], ro->ro_tableid);
|
||||
} else
|
||||
#endif /* INET6 */
|
||||
{
|
||||
if (inp->inp_faddr.s_addr == INADDR_ANY)
|
||||
return (NULL);
|
||||
ro->ro_dst.sa_family = AF_INET;
|
||||
ro->ro_dst.sa_len = sizeof(struct sockaddr_in);
|
||||
satosin(&ro->ro_dst)->sin_addr = inp->inp_faddr;
|
||||
ro->ro_tableid = inp->inp_rtableid;
|
||||
ro->ro_rt = rtalloc_mpath(&ro->ro_dst,
|
||||
&inp->inp_laddr.s_addr, ro->ro_tableid);
|
||||
}
|
||||
if (inp->inp_faddr.s_addr == INADDR_ANY)
|
||||
return (NULL);
|
||||
ro->ro_dst.sa_family = AF_INET;
|
||||
ro->ro_dst.sa_len = sizeof(struct sockaddr_in);
|
||||
satosin(&ro->ro_dst)->sin_addr = inp->inp_faddr;
|
||||
ro->ro_tableid = inp->inp_rtableid;
|
||||
ro->ro_rt = rtalloc_mpath(&ro->ro_dst,
|
||||
&inp->inp_laddr.s_addr, ro->ro_tableid);
|
||||
}
|
||||
return (ro->ro_rt);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: in_pcb.h,v 1.149 2024/01/28 20:34:25 bluhm Exp $ */
|
||||
/* $OpenBSD: in_pcb.h,v 1.150 2024/01/31 12:27:57 bluhm Exp $ */
|
||||
/* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -367,6 +367,8 @@ struct rtentry *
|
|||
in_pcbrtentry(struct inpcb *);
|
||||
|
||||
/* INET6 stuff */
|
||||
struct rtentry *
|
||||
in6_pcbrtentry(struct inpcb *);
|
||||
void in6_pcbnotify(struct inpcbtable *, const struct sockaddr_in6 *,
|
||||
u_int, const struct sockaddr_in6 *, u_int, u_int, int, void *,
|
||||
void (*)(struct inpcb *, int));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: ip_input.c,v 1.387 2023/09/16 09:33:27 mpi Exp $ */
|
||||
/* $OpenBSD: ip_input.c,v 1.388 2024/01/31 14:56:42 bluhm Exp $ */
|
||||
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -1475,7 +1475,6 @@ ip_forward(struct mbuf *m, struct ifnet *ifp, struct rtentry *rt, int srcrt)
|
|||
{
|
||||
struct mbuf mfake, *mcopy = NULL;
|
||||
struct ip *ip = mtod(m, struct ip *);
|
||||
struct sockaddr_in *sin;
|
||||
struct route ro;
|
||||
int error = 0, type = 0, code = 0, destmtu = 0, fake = 0, len;
|
||||
u_int32_t dest;
|
||||
|
@ -1491,15 +1490,11 @@ ip_forward(struct mbuf *m, struct ifnet *ifp, struct rtentry *rt, int srcrt)
|
|||
goto freecopy;
|
||||
}
|
||||
|
||||
memset(&ro, 0, sizeof(ro));
|
||||
sin = satosin(&ro.ro_dst);
|
||||
sin->sin_family = AF_INET;
|
||||
sin->sin_len = sizeof(*sin);
|
||||
sin->sin_addr = ip->ip_dst;
|
||||
|
||||
ro.ro_rt = NULL;
|
||||
route_cache(&ro, ip->ip_dst, m->m_pkthdr.ph_rtableid);
|
||||
if (!rtisvalid(rt)) {
|
||||
rtfree(rt);
|
||||
rt = rtalloc_mpath(sintosa(sin), &ip->ip_src.s_addr,
|
||||
rt = rtalloc_mpath(&ro.ro_dst, &ip->ip_src.s_addr,
|
||||
m->m_pkthdr.ph_rtableid);
|
||||
if (rt == NULL) {
|
||||
ipstat_inc(ips_noroute);
|
||||
|
@ -1507,6 +1502,7 @@ ip_forward(struct mbuf *m, struct ifnet *ifp, struct rtentry *rt, int srcrt)
|
|||
return;
|
||||
}
|
||||
}
|
||||
ro.ro_rt = rt;
|
||||
|
||||
/*
|
||||
* Save at most 68 bytes of the packet in case
|
||||
|
@ -1557,8 +1553,6 @@ ip_forward(struct mbuf *m, struct ifnet *ifp, struct rtentry *rt, int srcrt)
|
|||
}
|
||||
}
|
||||
|
||||
ro.ro_rt = rt;
|
||||
ro.ro_tableid = m->m_pkthdr.ph_rtableid;
|
||||
error = ip_output(m, NULL, &ro,
|
||||
(IP_FORWARDING | (ip_directedbcast ? IP_ALLOWBROADCAST : 0)),
|
||||
NULL, NULL, 0);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: ip_output.c,v 1.393 2024/01/18 11:03:16 claudio Exp $ */
|
||||
/* $OpenBSD: ip_output.c,v 1.394 2024/01/31 14:56:43 bluhm Exp $ */
|
||||
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -159,28 +159,15 @@ reroute:
|
|||
*/
|
||||
if (ro == NULL) {
|
||||
ro = &iproute;
|
||||
memset(ro, 0, sizeof(*ro));
|
||||
ro->ro_rt = NULL;
|
||||
}
|
||||
|
||||
dst = satosin(&ro->ro_dst);
|
||||
|
||||
/*
|
||||
* If there is a cached route, check that it is to the same
|
||||
* destination and is still up. If not, free it and try again.
|
||||
*/
|
||||
if (!rtisvalid(ro->ro_rt) ||
|
||||
dst->sin_addr.s_addr != ip->ip_dst.s_addr ||
|
||||
ro->ro_tableid != m->m_pkthdr.ph_rtableid) {
|
||||
rtfree(ro->ro_rt);
|
||||
ro->ro_rt = NULL;
|
||||
}
|
||||
|
||||
if (ro->ro_rt == NULL) {
|
||||
dst->sin_family = AF_INET;
|
||||
dst->sin_len = sizeof(*dst);
|
||||
dst->sin_addr = ip->ip_dst;
|
||||
ro->ro_tableid = m->m_pkthdr.ph_rtableid;
|
||||
}
|
||||
route_cache(ro, ip->ip_dst, m->m_pkthdr.ph_rtableid);
|
||||
dst = satosin(&ro->ro_dst);
|
||||
|
||||
if ((IN_MULTICAST(ip->ip_dst.s_addr) ||
|
||||
(ip->ip_dst.s_addr == INADDR_BROADCAST)) &&
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue