In the case the destination of a packet was changed by the packet filter

to point to a local IP address; and the packet was sourced from this host
we fill in the m_pkthdr.rcvif with a pointer to the loopback interface.

Before the function ifunit("lo0") was used to obtain the ifp.  However
this is sub-optimal from a performance point of view and might be dangerous
if the loopback interface has been renamed.  Use the global variable 'loif'
instead which always points to the loopback interface.

Submitted by:	brooks
This commit is contained in:
Andre Oppermann 2004-08-27 15:39:34 +00:00
parent 319c4c256a
commit a9c92b54a9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=134385

View File

@ -676,7 +676,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro,
if (in_localip(ip->ip_dst)) {
m->m_flags |= M_FASTFWD_OURS;
if (m->m_pkthdr.rcvif == NULL)
m->m_pkthdr.rcvif = ifunit("lo0");
m->m_pkthdr.rcvif = loif;
if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) {
m->m_pkthdr.csum_flags |=
CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
@ -695,7 +695,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro,
/* See if local, if yes, send it to netisr with IP_FASTFWD_OURS. */
if (m->m_flags & M_FASTFWD_OURS) {
if (m->m_pkthdr.rcvif == NULL)
m->m_pkthdr.rcvif = ifunit("lo0");
m->m_pkthdr.rcvif = loif;
if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) {
m->m_pkthdr.csum_flags |=
CSUM_DATA_VALID | CSUM_PSEUDO_HDR;