Module Name: src Committed By: rtr Date: Sat Mar 14 02:08:16 UTC 2015
Modified Files: src/sys/netinet: tcp_input.c Log Message: Move code that is conditional on options INET6 into #ifdef INET6. * Re-organize some variable declarations to limit #ifdef's. * Move INET and INET6 code into respective switch cases to simplify #ifdef INET6. No intended functional change. To generate a diff of this commit: cvs rdiff -u -r1.336 -r1.337 src/sys/netinet/tcp_input.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/netinet/tcp_input.c diff -u src/sys/netinet/tcp_input.c:1.336 src/sys/netinet/tcp_input.c:1.337 --- src/sys/netinet/tcp_input.c:1.336 Sat Feb 14 12:57:53 2015 +++ src/sys/netinet/tcp_input.c Sat Mar 14 02:08:16 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_input.c,v 1.336 2015/02/14 12:57:53 he Exp $ */ +/* $NetBSD: tcp_input.c,v 1.337 2015/03/14 02:08:16 rtr Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -148,7 +148,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.336 2015/02/14 12:57:53 he Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.337 2015/03/14 02:08:16 rtr Exp $"); #include "opt_inet.h" #include "opt_ipsec.h" @@ -3191,9 +3191,11 @@ tcp_signature(struct mbuf *m, struct tcp MD5_CTX ctx; struct ip *ip; struct ipovly *ipovly; +#ifdef INET6 struct ip6_hdr *ip6; - struct ippseudo ippseudo; struct ip6_hdr_pseudo ip6pseudo; +#endif /* INET6 */ + struct ippseudo ippseudo; struct tcphdr th0; int l, tcphdrlen; @@ -3204,20 +3206,8 @@ tcp_signature(struct mbuf *m, struct tcp switch (mtod(m, struct ip *)->ip_v) { case 4: + MD5Init(&ctx); ip = mtod(m, struct ip *); - ip6 = NULL; - break; - case 6: - ip = NULL; - ip6 = mtod(m, struct ip6_hdr *); - break; - default: - return (-1); - } - - MD5Init(&ctx); - - if (ip) { memset(&ippseudo, 0, sizeof(ippseudo)); ipovly = (struct ipovly *)ip; ippseudo.ippseudo_src = ipovly->ih_src; @@ -3226,7 +3216,11 @@ tcp_signature(struct mbuf *m, struct tcp ippseudo.ippseudo_p = IPPROTO_TCP; ippseudo.ippseudo_len = htons(m->m_pkthdr.len - thoff); MD5Update(&ctx, (char *)&ippseudo, sizeof(ippseudo)); - } else { + break; +#if INET6 + case 6: + MD5Init(&ctx); + ip6 = mtod(m, struct ip6_hdr *); memset(&ip6pseudo, 0, sizeof(ip6pseudo)); ip6pseudo.ip6ph_src = ip6->ip6_src; in6_clearscope(&ip6pseudo.ip6ph_src); @@ -3235,6 +3229,10 @@ tcp_signature(struct mbuf *m, struct tcp ip6pseudo.ip6ph_len = htons(m->m_pkthdr.len - thoff); ip6pseudo.ip6ph_nxt = IPPROTO_TCP; MD5Update(&ctx, (char *)&ip6pseudo, sizeof(ip6pseudo)); + break; +#endif /* INET6 */ + default: + return (-1); } th0 = *th;