diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2014-05-07 08:09:34 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2014-05-07 08:09:34 +0000 |
commit | 554f5fef639b184bff077dbfaaa103eca2b86ad0 (patch) | |
tree | 85d365bde587b14455a54ff81145bf0f9058478a /sys/netinet6 | |
parent | 46e7f809788fbeffddf88d450c92fe6c402666a6 (diff) |
Remove some m->m_pkthdr.rcvif dereference to help for upcoming
receiving pointer -> index conversion. No functional change.
ok chrisz@, jca@, mikeb@, lteo@
Diffstat (limited to 'sys/netinet6')
-rw-r--r-- | sys/netinet6/icmp6.c | 45 |
1 files changed, 24 insertions, 21 deletions
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; |