diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2017-04-17 20:59:36 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2017-04-17 20:59:36 +0000 |
commit | 6b815df989e6a061089d9f1cbcfff2c12eca43a8 (patch) | |
tree | 3c21b6bef33fd847499ec62a008bd64d5d942333 | |
parent | 0281e851b351275400561514fcc4c52eb615c153 (diff) |
Use the address family passed down with pr_input to simplify
tcp_input().
OK florian@
-rw-r--r-- | sys/netinet/tcp_input.c | 52 |
1 files changed, 4 insertions, 48 deletions
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 880c1402677..4fdfac19491 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_input.c,v 1.339 2017/04/14 20:46:31 bluhm Exp $ */ +/* $OpenBSD: tcp_input.c,v 1.340 2017/04/17 20:59:35 bluhm Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* @@ -359,7 +359,7 @@ tcp_input(struct mbuf **mp, int *offp, int proto, int af) { struct mbuf *m = *mp; int iphlen = *offp; - struct ip *ip; + struct ip *ip = NULL; struct inpcb *inp = NULL; u_int8_t *optp = NULL; int optlen = 0; @@ -399,51 +399,9 @@ tcp_input(struct mbuf **mp, int *offp, int proto, int af) goto drop; /* - * Before we do ANYTHING, we have to figure out if it's TCP/IPv6 or - * TCP/IPv4. - */ - switch (mtod(m, struct ip *)->ip_v) { -#ifdef INET6 - case 6: - af = AF_INET6; - break; -#endif - case 4: - af = AF_INET; - break; - default: - m_freem(m); - return IPPROTO_DONE; - } - - /* * Get IP and TCP header together in first mbuf. * Note: IP leaves IP header in first mbuf. */ - switch (af) { - case AF_INET: -#ifdef DIAGNOSTIC - if (iphlen < sizeof(struct ip)) { - m_freem(m); - return IPPROTO_DONE; - } -#endif /* DIAGNOSTIC */ - break; -#ifdef INET6 - case AF_INET6: -#ifdef DIAGNOSTIC - if (iphlen < sizeof(struct ip6_hdr)) { - m_freem(m); - return IPPROTO_DONE; - } -#endif /* DIAGNOSTIC */ - break; -#endif - default: - m_freem(m); - return IPPROTO_DONE; - } - IP6_EXTHDR_GET(th, struct tcphdr *, m, iphlen, sizeof(*th)); if (!th) { tcpstat_inc(tcps_rcvshort); @@ -451,10 +409,6 @@ tcp_input(struct mbuf **mp, int *offp, int proto, int af) } tlen = m->m_pkthdr.len - iphlen; - ip = NULL; -#ifdef INET6 - ip6 = NULL; -#endif switch (af) { case AF_INET: ip = mtod(m, struct ip *); @@ -497,6 +451,8 @@ tcp_input(struct mbuf **mp, int *offp, int proto, int af) } break; #endif + default: + unhandled_af(af); } /* |