From: mpi Date: Wed, 7 May 2014 08:09:33 +0000 (+0000) Subject: Remove some m->m_pkthdr.rcvif dereference to help for upcoming X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=3a2d9b458f3cab280f64ea75fef643fbbe3ce294;p=openbsd Remove some m->m_pkthdr.rcvif dereference to help for upcoming receiving pointer -> index conversion. No functional change. ok chrisz@, jca@, mikeb@, lteo@ --- diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index e00a46a5c81..1e3fa7c336d 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_icmp.c,v 1.121 2014/04/21 12:22:26 henning Exp $ */ +/* $OpenBSD: ip_icmp.c,v 1.122 2014/05/07 08:09:33 mpi Exp $ */ /* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */ /* @@ -305,6 +305,7 @@ icmp_error(struct mbuf *n, int type, int code, n_long dest, int destmtu) void icmp_input(struct mbuf *m, ...) { + struct ifnet *ifp; struct icmp *icp; struct ip *ip = mtod(m, struct ip *); struct sockaddr_in sin; @@ -318,6 +319,8 @@ icmp_input(struct mbuf *m, ...) hlen = va_arg(ap, int); va_end(ap); + ifp = m->m_pkthdr.rcvif; + /* * Locate icmp structure in mbuf, and check * that not corrupted and of at least minimum length. @@ -480,7 +483,7 @@ icmp_input(struct mbuf *m, ...) sin.sin_len = sizeof(struct sockaddr_in); sin.sin_addr = icp->icmp_ip.ip_dst; #if NCARP > 0 - if (m->m_pkthdr.rcvif->if_type == IFT_CARP && + if (ifp->if_type == IFT_CARP && carp_lsdrop(m, AF_INET, &sin.sin_addr.s_addr, &ip->ip_dst.s_addr)) goto freeit; @@ -545,10 +548,9 @@ icmp_input(struct mbuf *m, ...) sin.sin_addr = ip->ip_src; else sin.sin_addr = ip->ip_dst; - if (m->m_pkthdr.rcvif == NULL) + if (ifp == NULL) break; - ia = ifatoia(ifaof_ifpforaddr(sintosa(&sin), - m->m_pkthdr.rcvif)); + ia = ifatoia(ifaof_ifpforaddr(sintosa(&sin), ifp)); if (ia == 0) break; icp->icmp_type = ICMP_MASKREPLY; @@ -565,7 +567,7 @@ icmp_input(struct mbuf *m, ...) } reflect: #if NCARP > 0 - if (m->m_pkthdr.rcvif->if_type == IFT_CARP && + if (ifp->if_type == IFT_CARP && carp_lsdrop(m, AF_INET, &ip->ip_src.s_addr, &ip->ip_dst.s_addr)) goto freeit; @@ -631,7 +633,7 @@ reflect: #endif #if NCARP > 0 - if (m->m_pkthdr.rcvif->if_type == IFT_CARP && + if (ifp->if_type == IFT_CARP && carp_lsdrop(m, AF_INET, &sdst.sin_addr.s_addr, &ip->ip_dst.s_addr)) goto freeit; diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index a5b1f852738..7f0520cdce8 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: icmp6.c,v 1.143 2014/04/18 10:48:30 jca Exp $ */ +/* $OpenBSD: icmp6.c,v 1.144 2014/05/07 08:09:33 mpi Exp $ */ /* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */ /* @@ -385,6 +385,7 @@ icmp6_error(struct mbuf *m, int type, int code, int param) int icmp6_input(struct mbuf **mp, int *offp, int proto) { + struct ifnet *ifp; struct mbuf *m = *mp, *n; struct ip6_hdr *ip6, *nip6; struct icmp6_hdr *icmp6, *nicmp6; @@ -393,7 +394,9 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) int code, sum, noff; char src[INET6_ADDRSTRLEN], dst[INET6_ADDRSTRLEN]; - icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_msg); + ifp = m->m_pkthdr.rcvif; + + icmp6_ifstat_inc(ifp, ifs6_in_msg); /* * Locate icmp6 structure in mbuf, and check @@ -403,7 +406,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) ip6 = mtod(m, struct ip6_hdr *); if (icmp6len < sizeof(struct icmp6_hdr)) { icmp6stat.icp6s_tooshort++; - icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_error); + icmp6_ifstat_inc(ifp, ifs6_in_error); goto freeit; } @@ -423,7 +426,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) icmp6->icmp6_type, sum, inet_ntop(AF_INET6, &ip6->ip6_src, src, sizeof(src)))); icmp6stat.icp6s_checksum++; - icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_error); + icmp6_ifstat_inc(ifp, ifs6_in_error); goto freeit; } @@ -446,7 +449,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) #endif /* NPF */ #if NCARP > 0 - if (m->m_pkthdr.rcvif->if_type == IFT_CARP && + if (ifp->if_type == IFT_CARP && icmp6->icmp6_type == ICMP6_ECHO_REQUEST && carp_lsdrop(m, AF_INET6, ip6->ip6_src.s6_addr32, ip6->ip6_dst.s6_addr32)) @@ -456,13 +459,13 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) switch (icmp6->icmp6_type) { case ICMP6_DST_UNREACH: - icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_dstunreach); + icmp6_ifstat_inc(ifp, ifs6_in_dstunreach); switch (code) { case ICMP6_DST_UNREACH_NOROUTE: code = PRC_UNREACH_NET; break; case ICMP6_DST_UNREACH_ADMIN: - icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_adminprohib); + icmp6_ifstat_inc(ifp, ifs6_in_adminprohib); code = PRC_UNREACH_PROTOCOL; /* is this a good code? */ break; case ICMP6_DST_UNREACH_ADDR: @@ -487,7 +490,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) goto deliver; case ICMP6_PACKET_TOO_BIG: - icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_pkttoobig); + icmp6_ifstat_inc(ifp, ifs6_in_pkttoobig); /* MTU is checked in icmp6_mtudisc_update. */ code = PRC_MSGSIZE; @@ -499,7 +502,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) goto deliver; case ICMP6_TIME_EXCEEDED: - icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_timeexceed); + icmp6_ifstat_inc(ifp, ifs6_in_timeexceed); switch (code) { case ICMP6_TIME_EXCEED_TRANSIT: code = PRC_TIMXCEED_INTRANS; @@ -513,7 +516,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) goto deliver; case ICMP6_PARAM_PROB: - icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_paramprob); + icmp6_ifstat_inc(ifp, ifs6_in_paramprob); switch (code) { case ICMP6_PARAMPROB_NEXTHEADER: code = PRC_UNREACH_PROTOCOL; @@ -528,7 +531,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) goto deliver; case ICMP6_ECHO_REQUEST: - icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_echo); + icmp6_ifstat_inc(ifp, ifs6_in_echo); if (code != 0) goto badcode; /* @@ -614,7 +617,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) break; case ICMP6_ECHO_REPLY: - icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_echoreply); + icmp6_ifstat_inc(ifp, ifs6_in_echoreply); if (code != 0) goto badcode; break; @@ -624,9 +627,9 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) if (icmp6len < sizeof(struct mld_hdr)) goto badlen; if (icmp6->icmp6_type == MLD_LISTENER_QUERY) /* XXX: ugly... */ - icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_mldquery); + icmp6_ifstat_inc(ifp, ifs6_in_mldquery); else - icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_mldreport); + icmp6_ifstat_inc(ifp, ifs6_in_mldreport); if ((n = m_copym(m, 0, M_COPYALL, M_DONTWAIT)) == NULL) { /* give up local */ mld6_input(m, off); @@ -638,7 +641,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) break; case MLD_LISTENER_DONE: - icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_mlddone); + icmp6_ifstat_inc(ifp, ifs6_in_mlddone); if (icmp6len < sizeof(struct mld_hdr)) /* necessary? */ goto badlen; break; /* nothing to be done in kernel */ @@ -735,7 +738,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) break; case ND_ROUTER_SOLICIT: - icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_routersolicit); + icmp6_ifstat_inc(ifp, ifs6_in_routersolicit); if (code != 0) goto badcode; if (icmp6len < sizeof(struct nd_router_solicit)) @@ -751,7 +754,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) break; case ND_ROUTER_ADVERT: - icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_routeradvert); + icmp6_ifstat_inc(ifp, ifs6_in_routeradvert); if (code != 0) goto badcode; if (icmp6len < sizeof(struct nd_router_advert)) @@ -767,7 +770,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) break; case ND_NEIGHBOR_SOLICIT: - icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_neighborsolicit); + icmp6_ifstat_inc(ifp, ifs6_in_neighborsolicit); if (code != 0) goto badcode; if (icmp6len < sizeof(struct nd_neighbor_solicit)) @@ -783,7 +786,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) break; case ND_NEIGHBOR_ADVERT: - icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_neighboradvert); + icmp6_ifstat_inc(ifp, ifs6_in_neighboradvert); if (code != 0) goto badcode; if (icmp6len < sizeof(struct nd_neighbor_advert)) @@ -799,7 +802,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) break; case ND_REDIRECT: - icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_redirect); + icmp6_ifstat_inc(ifp, ifs6_in_redirect); if (code != 0) goto badcode; if (icmp6len < sizeof(struct nd_redirect)) @@ -828,7 +831,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) icmp6->icmp6_type, inet_ntop(AF_INET6, &ip6->ip6_src, src, sizeof(src)), inet_ntop(AF_INET6, &ip6->ip6_dst, dst, sizeof(dst)), - m->m_pkthdr.rcvif ? m->m_pkthdr.rcvif->if_index : 0)); + ifp ? ifp->if_index : 0)); if (icmp6->icmp6_type < ICMP6_ECHO_REQUEST) { /* ICMPv6 error: MUST deliver it by spec... */ code = PRC_NCMDS;