diff --git a/sys/netinet6/ip6_fastfwd.c b/sys/netinet6/ip6_fastfwd.c index 5131d9c..38512a8 100644 --- a/sys/netinet6/ip6_fastfwd.c +++ b/sys/netinet6/ip6_fastfwd.c @@ -65,7 +65,6 @@ ip6_fastforward(struct mbuf *m) struct m_tag *fwd_tag; struct ip6_hdr *ip6; struct ifnet *rcvif, *oif; - struct mbuf *mcopy; uint32_t plen; int mflags, mnext; @@ -81,7 +80,6 @@ ip6_fastforward(struct mbuf *m) mflags = m->m_flags; mnext = (m->m_next != NULL); rcvif = m->m_pkthdr.rcvif; - mcopy = NULL; /* * Drop the packet if IPv6 operation is disabled on the interface. */ @@ -206,13 +204,6 @@ ip6_fastforward(struct mbuf *m) goto dropin; } /* - * Save at most ICMPV6_PLD_MAXLEN (= the min IPv6 MTU - - * size of IPv6 + ICMPv6 headers) bytes of the packet in case - * we need to generate an ICMP6 message to the src. - * Thanks to M_EXT, in most cases copy will not occur. - */ - mcopy = m_copy(m, 0, imin(m->m_pkthdr.len, ICMPV6_PLD_MAXLEN)); - /* * Initialize route. * First we plan to find route to ip6_dst. */ @@ -241,7 +232,7 @@ ip6_fastforward(struct mbuf *m) * M_IP6_NEXTHOP flag is set and fwd_tag is attached to mbuf. */ if (m->m_flags & M_FASTFWD_OURS) - goto freecopy; + return (m); if ((m->m_flags & M_IP6_NEXTHOP) && (fwd_tag = m_tag_find(m, PACKET_TAG_IPFORWARD, NULL)) != NULL) { /* @@ -253,11 +244,6 @@ ip6_fastforward(struct mbuf *m) m_tag_delete(m, fwd_tag); } passin: -#ifdef IPSTEALTH - if (!V_ip6stealth) -#endif - ip6->ip6_hlim -= IPV6_HLIMDEC; -again: /* * Find route to destination. */ @@ -265,20 +251,18 @@ again: if (ro.ro_rt == NULL || (ro.ro_rt->rt_flags & RTF_REJECT)) { IP6STAT_INC(ip6s_noroute); in6_ifstat_inc(rcvif, ifs6_in_noroute); - icmp6_error(mcopy, ICMP6_DST_UNREACH, + icmp6_error(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOROUTE, 0); -// RO_RTFREE(&ro); - mcopy = NULL; + m = NULL; goto dropin; } if (!(ro.ro_rt->rt_flags & RTF_UP) || !(ro.ro_rt->rt_ifp->if_flags & IFF_UP)) { IP6STAT_INC(ip6s_noroute); in6_ifstat_inc(rcvif, ifs6_in_noroute); - icmp6_error(mcopy, ICMP6_DST_UNREACH, + icmp6_error(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADDR, 0); -// RO_RTFREE(&ro); - mcopy = NULL; + m = NULL; goto dropin; } oif = ro.ro_rt->rt_ifp; @@ -288,9 +272,8 @@ again: */ if (m->m_pkthdr.len > IN6_LINKMTU(oif)) { in6_ifstat_inc(oif, ifs6_in_toobig); - icmp6_error(mcopy, ICMP6_PACKET_TOO_BIG, 0, IN6_LINKMTU(oif)); -// RO_RTFREE(&ro); - mcopy = NULL; + icmp6_error(m, ICMP6_PACKET_TOO_BIG, 0, IN6_LINKMTU(oif)); + m = NULL; goto dropout; } /* @@ -298,7 +281,6 @@ again: */ if (ro.ro_rt->rt_flags & RTF_GATEWAY) ro.ro_dst = *(struct sockaddr_in6 *)ro.ro_rt->rt_gateway; -// RO_RTFREE(&ro); /* * Outgoing packet firewall processing. */ @@ -319,17 +301,26 @@ again: * Also it can forward packet to another destination, e.g. * M_IP6_NEXTHOP flag is set and fwd_tag is attached to mbuf. */ - if (m->m_flags & M_FASTFWD_OURS) - goto freecopy; + if (m->m_flags & M_FASTFWD_OURS) { +#ifdef IPSTEALTH + if (!V_ip6stealth) +#endif + ip6->ip6_hlim -= IPV6_HLIMDEC; + return (m); + } if ((m->m_flags & M_IP6_NEXTHOP) && (fwd_tag = m_tag_find(m, PACKET_TAG_IPFORWARD, NULL)) != NULL) { bcopy((fwd_tag + 1), &ro.ro_dst, sizeof(struct sockaddr_in6)); m->m_flags |= M_SKIP_FIREWALL; m->m_flags &= ~M_IP6_NEXTHOP; m_tag_delete(m, fwd_tag); - goto again; + goto passin; } passout: +#ifdef IPSTEALTH + if (!V_ip6stealth) +#endif + ip6->ip6_hlim -= IPV6_HLIMDEC; if (nd6_output(oif, rcvif, m, &ro.ro_dst, NULL) != 0) { in6_ifstat_inc(oif, ifs6_out_discard); IP6STAT_INC(ip6s_cantforward); @@ -338,20 +329,15 @@ passout: IP6STAT_INC(ip6s_forward); } m = NULL; - goto freecopy; + goto drop; dropin: in6_ifstat_inc(rcvif, ifs6_in_discard); goto drop; dropout: in6_ifstat_inc(oif, ifs6_out_discard); drop: - if (m != NULL) { + if (m != NULL) m_freem(m); - m = NULL; - } -freecopy: - if (mcopy != NULL) - m_freem(mcopy); /* * Update statistics. */ @@ -373,6 +359,6 @@ freecopy: } in6_ifstat_inc(rcvif, ifs6_in_receive); IP6STAT_INC(ip6s_total); - return (m); + return (NULL); }