diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2015-09-10 12:10:53 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2015-09-10 12:10:53 +0000 |
commit | c657313aa253965e8945d23733dd7c5ede450d58 (patch) | |
tree | fe98baca844bf1ea374af56446532aab166bdc22 /sys/netinet | |
parent | d17f06b1ba131a0e7b2b2af63830ceecb04477f9 (diff) |
if_put after if_get in icmp input.
instead of chasing all the ways out of icmp_input, rename it to
icmp_input_if and call it from a wrapper that gets the ifp and puts
it after icmp_input_if call.
ok claudio@
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/ip_icmp.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index bdcc12feeb7..518583717f5 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_icmp.c,v 1.138 2015/09/01 21:24:04 bluhm Exp $ */ +/* $OpenBSD: ip_icmp.c,v 1.139 2015/09/10 12:10:52 dlg Exp $ */ /* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */ /* @@ -128,6 +128,7 @@ int *icmpctl_vars[ICMPCTL_MAXID] = ICMPCTL_VARS; void icmp_mtudisc_timeout(struct rtentry *, struct rttimer *); int icmp_ratelimit(const struct in_addr *, const int, const int); void icmp_redirect_timeout(struct rtentry *, struct rttimer *); +void icmp_input_if(struct ifnet *, struct mbuf *, int); void icmp_init(void) @@ -306,22 +307,33 @@ void icmp_input(struct mbuf *m, ...) { struct ifnet *ifp; - struct icmp *icp; - struct ip *ip = mtod(m, struct ip *); - struct sockaddr_in sin; - int icmplen, i, code, hlen; - struct in_ifaddr *ia; - void *(*ctlfunc)(int, struct sockaddr *, u_int, void *); + int hlen; va_list ap; - struct mbuf *opts; va_start(ap, m); hlen = va_arg(ap, int); va_end(ap); ifp = if_get(m->m_pkthdr.ph_ifidx); - if (ifp == NULL) - goto freeit; + if (ifp == NULL) { + m_freem(m); + return; + } + + icmp_input_if(ifp, m, hlen); + if_put(ifp); +} + +void +icmp_input_if(struct ifnet *ifp, struct mbuf *m, int hlen) +{ + struct icmp *icp; + struct ip *ip = mtod(m, struct ip *); + struct sockaddr_in sin; + int icmplen, i, code; + struct in_ifaddr *ia; + void *(*ctlfunc)(int, struct sockaddr *, u_int, void *); + struct mbuf *opts; /* * Locate icmp structure in mbuf, and check |