-/* $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 $ */
/*
void
icmp_input(struct mbuf *m, ...)
{
+ struct ifnet *ifp;
struct icmp *icp;
struct ip *ip = mtod(m, struct ip *);
struct sockaddr_in sin;
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.
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;
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;
}
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;
#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;
-/* $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 $ */
/*
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;
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
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;
}
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;
}
#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))
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:
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;
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;
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;
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;
/*
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;
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);
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 */
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))
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))
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))
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))
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))
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;