summaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2017-09-06 11:43:05 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2017-09-06 11:43:05 +0000
commit771206b5d171aa8a9b5e87e0ab3578fea211bc57 (patch)
treeb41082a88a1cbbc0713ec9a492bb9616417064ea /sys/netinet
parent4c6f8cecf9d7b2030e5b06a1663b69bb510faa92 (diff)
Replace the call to ifa_ifwithaddr() in divert6_output() with a
route lookup to make it MP safe. Only set the mbuf header fields that are needed. Validate the name input. Also use the same variables in IPv4 and IPv6 functions and avoid unneccessary initialization. OK mpi@
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/ip_divert.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c
index 9f8821d3559..a6b57213d81 100644
--- a/sys/netinet/ip_divert.c
+++ b/sys/netinet/ip_divert.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_divert.c,v 1.51 2017/09/06 00:05:02 bluhm Exp $ */
+/* $OpenBSD: ip_divert.c,v 1.52 2017/09/06 11:43:04 bluhm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -75,16 +75,13 @@ divert_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam,
struct mbuf *control)
{
struct sockaddr_in *sin;
- struct socket *so;
- int error, min_hdrlen = 0, dir;
+ int error, min_hdrlen, off, dir;
struct ip *ip;
- u_int16_t off;
m_freem(control);
if ((error = in_nam2sin(nam, &sin)))
goto fail;
- so = inp->inp_socket;
/* Do basic sanity checks. */
if (m->m_pkthdr.len < sizeof(struct ip))
@@ -118,7 +115,7 @@ divert_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam,
m->m_pkthdr.csum_flags |= M_ICMP_CSUM_OUT;
break;
default:
- /* nothing */
+ min_hdrlen = 0;
break;
}
if (min_hdrlen && m->m_pkthdr.len < off + min_hdrlen)