sync with OpenBSD -current
This commit is contained in:
parent
382ecd9441
commit
1b576c8ddf
25 changed files with 517 additions and 395 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: ip6_forward.c,v 1.116 2024/02/28 10:57:20 bluhm Exp $ */
|
||||
/* $OpenBSD: ip6_forward.c,v 1.117 2024/04/16 12:56:39 bluhm Exp $ */
|
||||
/* $KAME: ip6_forward.c,v 1.75 2001/06/29 12:42:13 jinmei Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -82,11 +82,12 @@
|
|||
*/
|
||||
|
||||
void
|
||||
ip6_forward(struct mbuf *m, struct rtentry *rt, int srcrt)
|
||||
ip6_forward(struct mbuf *m, struct route *ro, int srcrt)
|
||||
{
|
||||
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
|
||||
struct route iproute;
|
||||
struct rtentry *rt;
|
||||
struct sockaddr *dst;
|
||||
struct route ro;
|
||||
struct ifnet *ifp = NULL;
|
||||
int error = 0, type = 0, code = 0, destmtu = 0;
|
||||
struct mbuf *mcopy;
|
||||
|
@ -165,25 +166,22 @@ reroute:
|
|||
}
|
||||
#endif /* IPSEC */
|
||||
|
||||
ro.ro_rt = NULL;
|
||||
route6_cache(&ro, &ip6->ip6_dst, &ip6->ip6_src,
|
||||
m->m_pkthdr.ph_rtableid);
|
||||
dst = &ro.ro_dstsa;
|
||||
if (!rtisvalid(rt)) {
|
||||
rtfree(rt);
|
||||
rt = rtalloc_mpath(dst, &ip6->ip6_src.s6_addr32[0],
|
||||
m->m_pkthdr.ph_rtableid);
|
||||
if (rt == NULL) {
|
||||
ip6stat_inc(ip6s_noroute);
|
||||
if (mcopy != NULL) {
|
||||
icmp6_error(mcopy, ICMP6_DST_UNREACH,
|
||||
ICMP6_DST_UNREACH_NOROUTE, 0);
|
||||
}
|
||||
m_freem(m);
|
||||
goto done;
|
||||
}
|
||||
if (ro == NULL) {
|
||||
ro = &iproute;
|
||||
ro->ro_rt = NULL;
|
||||
}
|
||||
ro.ro_rt = rt;
|
||||
rt = route6_mpath(ro, &ip6->ip6_dst, &ip6->ip6_src,
|
||||
m->m_pkthdr.ph_rtableid);
|
||||
if (rt == NULL) {
|
||||
ip6stat_inc(ip6s_noroute);
|
||||
if (mcopy != NULL) {
|
||||
icmp6_error(mcopy, ICMP6_DST_UNREACH,
|
||||
ICMP6_DST_UNREACH_NOROUTE, 0);
|
||||
}
|
||||
m_freem(m);
|
||||
goto done;
|
||||
}
|
||||
dst = &ro->ro_dstsa;
|
||||
|
||||
/*
|
||||
* Scope check: if a packet can't be delivered to its destination
|
||||
|
@ -225,8 +223,8 @@ reroute:
|
|||
*/
|
||||
if (tdb != NULL) {
|
||||
/* Callee frees mbuf */
|
||||
error = ip6_output_ipsec_send(tdb, m, &ro, 0, 1);
|
||||
rt = ro.ro_rt;
|
||||
error = ip6_output_ipsec_send(tdb, m, ro, 0, 1);
|
||||
rt = ro->ro_rt;
|
||||
if (error)
|
||||
goto senderr;
|
||||
goto freecopy;
|
||||
|
@ -254,7 +252,7 @@ reroute:
|
|||
ip6_sendredirects &&
|
||||
(rt->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0) {
|
||||
if ((ifp->if_flags & IFF_POINTOPOINT) &&
|
||||
nd6_is_addr_neighbor(&ro.ro_dstsin6, ifp)) {
|
||||
nd6_is_addr_neighbor(&ro->ro_dstsin6, ifp)) {
|
||||
/*
|
||||
* If the incoming interface is equal to the outgoing
|
||||
* one, the link attached to the interface is
|
||||
|
@ -308,8 +306,9 @@ reroute:
|
|||
/* tag as generated to skip over pf_test on rerun */
|
||||
m->m_pkthdr.pf.flags |= PF_TAG_GENERATED;
|
||||
srcrt = 1;
|
||||
rtfree(rt);
|
||||
rt = NULL;
|
||||
if (ro == &iproute)
|
||||
rtfree(ro->ro_rt);
|
||||
ro = NULL;
|
||||
if_put(ifp);
|
||||
ifp = NULL;
|
||||
goto reroute;
|
||||
|
@ -388,7 +387,8 @@ senderr:
|
|||
freecopy:
|
||||
m_freem(mcopy);
|
||||
done:
|
||||
rtfree(rt);
|
||||
if (ro == &iproute)
|
||||
rtfree(ro->ro_rt);
|
||||
if_put(ifp);
|
||||
#ifdef IPSEC
|
||||
tdb_unref(tdb);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue