summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2015-09-10 12:10:52 +0000
committerdlg <dlg@openbsd.org>2015-09-10 12:10:52 +0000
commit321aa4083d0c9fc6946a462e4f47fcb81f529e19 (patch)
tree3796fe9917f02b730537b68399622f481e26f4f2
parentShow usb stack error code if a firmware page fails to load in urtwn(4). (diff)
downloadwireguard-openbsd-321aa4083d0c9fc6946a462e4f47fcb81f529e19.tar.xz
wireguard-openbsd-321aa4083d0c9fc6946a462e4f47fcb81f529e19.zip
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@
-rw-r--r--sys/netinet/ip_icmp.c32
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