Module Name: src Committed By: maxv Date: Thu Mar 29 07:46:43 UTC 2018
Modified Files: src/sys/netinet: tcp_congctl.c tcp_debug.c tcp_output.c tcp_sack.c tcp_subr.c tcp_timer.c tcp_usrreq.c Log Message: Remove #ifdef INET. Same as tcp_input.c. Makes the code easier to understand. Also make tcp6_mtudisc() static in tcp_subr.c. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/netinet/tcp_congctl.c cvs rdiff -u -r1.30 -r1.31 src/sys/netinet/tcp_debug.c cvs rdiff -u -r1.199 -r1.200 src/sys/netinet/tcp_output.c cvs rdiff -u -r1.33 -r1.34 src/sys/netinet/tcp_sack.c cvs rdiff -u -r1.273 -r1.274 src/sys/netinet/tcp_subr.c cvs rdiff -u -r1.93 -r1.94 src/sys/netinet/tcp_timer.c cvs rdiff -u -r1.216 -r1.217 src/sys/netinet/tcp_usrreq.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_congctl.c diff -u src/sys/netinet/tcp_congctl.c:1.23 src/sys/netinet/tcp_congctl.c:1.24 --- src/sys/netinet/tcp_congctl.c:1.23 Mon Jan 2 09:29:38 2017 +++ src/sys/netinet/tcp_congctl.c Thu Mar 29 07:46:43 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_congctl.c,v 1.23 2017/01/02 09:29:38 skrll Exp $ */ +/* $NetBSD: tcp_congctl.c,v 1.24 2018/03/29 07:46:43 maxv Exp $ */ /*- * Copyright (c) 1997, 1998, 1999, 2001, 2005, 2006 The NetBSD Foundation, Inc. @@ -135,7 +135,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tcp_congctl.c,v 1.23 2017/01/02 09:29:38 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_congctl.c,v 1.24 2018/03/29 07:46:43 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -167,9 +167,6 @@ __KERNEL_RCSID(0, "$NetBSD: tcp_congctl. #include <netinet/ip_var.h> #ifdef INET6 -#ifndef INET -#include <netinet/in.h> -#endif #include <netinet/ip6.h> #include <netinet6/ip6_var.h> #include <netinet6/in6_pcb.h> Index: src/sys/netinet/tcp_debug.c diff -u src/sys/netinet/tcp_debug.c:1.30 src/sys/netinet/tcp_debug.c:1.31 --- src/sys/netinet/tcp_debug.c:1.30 Tue Apr 26 08:44:44 2016 +++ src/sys/netinet/tcp_debug.c Thu Mar 29 07:46:43 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_debug.c,v 1.30 2016/04/26 08:44:44 ozaki-r Exp $ */ +/* $NetBSD: tcp_debug.c,v 1.31 2018/03/29 07:46:43 maxv Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tcp_debug.c,v 1.30 2016/04/26 08:44:44 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_debug.c,v 1.31 2018/03/29 07:46:43 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -91,9 +91,6 @@ __KERNEL_RCSID(0, "$NetBSD: tcp_debug.c, #include <netinet/ip_var.h> #ifdef INET6 -#ifndef INET -#include <netinet/in.h> -#endif #include <netinet/ip6.h> #endif Index: src/sys/netinet/tcp_output.c diff -u src/sys/netinet/tcp_output.c:1.199 src/sys/netinet/tcp_output.c:1.200 --- src/sys/netinet/tcp_output.c:1.199 Sat Mar 10 23:28:13 2018 +++ src/sys/netinet/tcp_output.c Thu Mar 29 07:46:43 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_output.c,v 1.199 2018/03/10 23:28:13 khorben Exp $ */ +/* $NetBSD: tcp_output.c,v 1.200 2018/03/29 07:46:43 maxv Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -135,7 +135,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.199 2018/03/10 23:28:13 khorben Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.200 2018/03/29 07:46:43 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -166,9 +166,6 @@ __KERNEL_RCSID(0, "$NetBSD: tcp_output.c #include <netinet/ip_var.h> #ifdef INET6 -#ifndef INET -#include <netinet/in.h> -#endif #include <netinet/ip6.h> #include <netinet6/in6_var.h> #include <netinet6/ip6_var.h> @@ -182,7 +179,7 @@ __KERNEL_RCSID(0, "$NetBSD: tcp_output.c #ifdef INET6 #include <netipsec/ipsec6.h> #endif -#endif /* IPSEC*/ +#endif #include <netinet/tcp.h> #define TCPOUTFLAGS @@ -238,9 +235,7 @@ int tcp_segsize(struct tcpcb *tp, int *txsegsizep, int *rxsegsizep, bool *alwaysfragp) { -#ifdef INET struct inpcb *inp = tp->t_inpcb; -#endif #ifdef INET6 struct in6pcb *in6p = tp->t_in6pcb; #endif @@ -258,11 +253,9 @@ tcp_segsize(struct tcpcb *tp, int *txseg panic("tcp_segsize: both t_inpcb and t_in6pcb are set"); #endif switch (tp->t_family) { -#ifdef INET case AF_INET: hdrlen = sizeof(struct ip) + sizeof(struct tcphdr); break; -#endif #ifdef INET6 case AF_INET6: hdrlen = sizeof(struct ip6_hdr) + sizeof(struct tcphdr); @@ -274,12 +267,10 @@ tcp_segsize(struct tcpcb *tp, int *txseg } rt = NULL; -#ifdef INET if (inp) { rt = in_pcbrtentry(inp); so = inp->inp_socket; } -#endif #ifdef INET6 if (in6p) { rt = in6_pcbrtentry(in6p); @@ -311,24 +302,19 @@ tcp_segsize(struct tcpcb *tp, int *txseg #endif } else if (ifp->if_flags & IFF_LOOPBACK) size = ifp->if_mtu - hdrlen; -#ifdef INET else if (inp && tp->t_mtudisc) size = ifp->if_mtu - hdrlen; else if (inp && in_localaddr(inp->inp_faddr)) size = ifp->if_mtu - hdrlen; -#endif #ifdef INET6 else if (in6p) { -#ifdef INET if (IN6_IS_ADDR_V4MAPPED(&in6p->in6p_faddr)) { /* mapped addr case */ struct in_addr d; bcopy(&in6p->in6p_faddr.s6_addr32[3], &d, sizeof(d)); if (tp->t_mtudisc || in_localaddr(d)) size = ifp->if_mtu - hdrlen; - } else -#endif - { + } else { /* * for IPv6, path MTU discovery is always turned on, * or the node must use packet size <= 1280. @@ -338,10 +324,8 @@ tcp_segsize(struct tcpcb *tp, int *txseg } } #endif -#ifdef INET if (inp) in_pcbrtentry_unref(rt, inp); -#endif #ifdef INET6 if (in6p) in6_pcbrtentry_unref(rt, in6p); @@ -357,7 +341,7 @@ tcp_segsize(struct tcpcb *tp, int *txseg * XXX tp->t_ourmss should have the right size, but without this code * fragmentation will occur... need more investigation */ -#ifdef INET + if (inp) { #if defined(IPSEC) if (ipsec_used && @@ -366,9 +350,8 @@ tcp_segsize(struct tcpcb *tp, int *txseg #endif optlen += ip_optlen(inp); } -#endif + #ifdef INET6 -#ifdef INET if (in6p && tp->t_family == AF_INET) { #if defined(IPSEC) if (ipsec_used && @@ -376,9 +359,7 @@ tcp_segsize(struct tcpcb *tp, int *txseg optlen += ipsec4_hdrsiz_tcp(tp); #endif /* XXX size -= ip_optlen(in6p); */ - } else -#endif - if (in6p && tp->t_family == AF_INET6) { + } else if (in6p && tp->t_family == AF_INET6) { #if defined(IPSEC) if (ipsec_used && !ipsec_pcb_skip_ipsec(in6p->in6p_sp, IPSEC_DIR_OUTBOUND)) @@ -605,7 +586,6 @@ tcp_output(struct tcpcb *tp) #endif switch (af = tp->t_family) { -#ifdef INET case AF_INET: if (tp->t_inpcb) break; @@ -615,7 +595,6 @@ tcp_output(struct tcpcb *tp) break; #endif return (EINVAL); -#endif #ifdef INET6 case AF_INET6: if (tp->t_in6pcb) @@ -638,7 +617,7 @@ tcp_output(struct tcpcb *tp) * - If the interface can do it */ has_tso4 = has_tso6 = false; -#if defined(INET) + has_tso4 = tp->t_inpcb != NULL && #if defined(IPSEC) (!ipsec_used || ipsec_pcb_skip_ipsec(tp->t_inpcb->inp_sp, @@ -650,7 +629,7 @@ tcp_output(struct tcpcb *tp) rtcache_unref(rt, &tp->t_inpcb->inp_route); rt = NULL; } -#endif /* defined(INET) */ + #if defined(INET6) has_tso6 = tp->t_in6pcb != NULL && #if defined(IPSEC) @@ -695,11 +674,9 @@ tcp_output(struct tcpcb *tp) * slow start to get ack "clock" running again. */ int ss = tcp_init_win; -#ifdef INET if (tp->t_inpcb && in_localaddr(tp->t_inpcb->inp_faddr)) ss = tcp_init_win_local; -#endif #ifdef INET6 if (tp->t_in6pcb && in6_localaddr(&tp->t_in6pcb->in6p_faddr)) @@ -1118,11 +1095,9 @@ send: optlen = 0; optp = opt; switch (af) { -#ifdef INET case AF_INET: iphdrlen = sizeof(struct ip) + sizeof(struct tcphdr); break; -#endif #ifdef INET6 case AF_INET6: iphdrlen = sizeof(struct ip6_hdr) + sizeof(struct tcphdr); @@ -1137,10 +1112,8 @@ send: struct rtentry *synrt; synrt = NULL; -#ifdef INET if (tp->t_inpcb) synrt = in_pcbrtentry(tp->t_inpcb); -#endif #ifdef INET6 if (tp->t_in6pcb) synrt = in6_pcbrtentry(tp->t_in6pcb); @@ -1149,10 +1122,8 @@ send: tp->snd_nxt = tp->iss; tp->t_ourmss = tcp_mss_to_advertise(synrt != NULL ? synrt->rt_ifp : NULL, af); -#ifdef INET if (tp->t_inpcb) in_pcbrtentry_unref(synrt, tp->t_inpcb); -#endif #ifdef INET6 if (tp->t_in6pcb) in6_pcbrtentry_unref(synrt, tp->t_in6pcb); @@ -1358,7 +1329,6 @@ reset: TCP_REASS_UNLOCK(tp); } m_reset_rcvif(m); switch (af) { -#ifdef INET case AF_INET: ip = mtod(m, struct ip *); #ifdef INET6 @@ -1366,7 +1336,6 @@ reset: TCP_REASS_UNLOCK(tp); #endif th = (struct tcphdr *)(ip + 1); break; -#endif #ifdef INET6 case AF_INET6: ip = NULL; @@ -1513,7 +1482,6 @@ reset: TCP_REASS_UNLOCK(tp); * hits the wire. */ switch (af) { -#ifdef INET case AF_INET: m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); if (use_tso) { @@ -1529,7 +1497,6 @@ reset: TCP_REASS_UNLOCK(tp); } } break; -#endif #ifdef INET6 case AF_INET6: m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); @@ -1628,7 +1595,6 @@ timer: m->m_pkthdr.len = hdrlen + len; switch (af) { -#ifdef INET case AF_INET: ip->ip_len = htons(m->m_pkthdr.len); packetlen = m->m_pkthdr.len; @@ -1643,7 +1609,6 @@ timer: } #endif break; -#endif #ifdef INET6 case AF_INET6: packetlen = m->m_pkthdr.len; @@ -1668,7 +1633,6 @@ timer: } switch (af) { -#ifdef INET case AF_INET: { struct mbuf *opts; @@ -1682,7 +1646,6 @@ timer: (so->so_options & SO_DONTROUTE), NULL, tp->t_inpcb); break; } -#endif #ifdef INET6 case AF_INET6: { @@ -1705,10 +1668,8 @@ timer: out: if (error == ENOBUFS) { TCP_STATINC(TCP_STAT_SELFQUENCH); -#ifdef INET if (tp->t_inpcb) tcp_quench(tp->t_inpcb, 0); -#endif #ifdef INET6 if (tp->t_in6pcb) tcp6_quench(tp->t_in6pcb, 0); Index: src/sys/netinet/tcp_sack.c diff -u src/sys/netinet/tcp_sack.c:1.33 src/sys/netinet/tcp_sack.c:1.34 --- src/sys/netinet/tcp_sack.c:1.33 Tue Dec 13 08:29:03 2016 +++ src/sys/netinet/tcp_sack.c Thu Mar 29 07:46:43 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_sack.c,v 1.33 2016/12/13 08:29:03 ozaki-r Exp $ */ +/* $NetBSD: tcp_sack.c,v 1.34 2018/03/29 07:46:43 maxv Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -102,7 +102,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tcp_sack.c,v 1.33 2016/12/13 08:29:03 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_sack.c,v 1.34 2018/03/29 07:46:43 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -135,9 +135,6 @@ __KERNEL_RCSID(0, "$NetBSD: tcp_sack.c,v #include <netinet/ip_var.h> #ifdef INET6 -#ifndef INET -#include <netinet/in.h> -#endif #include <netinet/ip6.h> #include <netinet6/ip6_var.h> #include <netinet6/in6_pcb.h> Index: src/sys/netinet/tcp_subr.c diff -u src/sys/netinet/tcp_subr.c:1.273 src/sys/netinet/tcp_subr.c:1.274 --- src/sys/netinet/tcp_subr.c:1.273 Mon Feb 26 08:50:25 2018 +++ src/sys/netinet/tcp_subr.c Thu Mar 29 07:46:43 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_subr.c,v 1.273 2018/02/26 08:50:25 maxv Exp $ */ +/* $NetBSD: tcp_subr.c,v 1.274 2018/03/29 07:46:43 maxv Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -91,7 +91,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.273 2018/02/26 08:50:25 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.274 2018/03/29 07:46:43 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -126,9 +126,6 @@ __KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v #include <netinet/ip_icmp.h> #ifdef INET6 -#ifndef INET -#include <netinet/in.h> -#endif #include <netinet/ip6.h> #include <netinet6/in6_pcb.h> #include <netinet6/ip6_var.h> @@ -154,8 +151,8 @@ __KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v #ifdef INET6 #include <netipsec/ipsec6.h> #endif - #include <netipsec/key.h> -#endif /* IPSEC*/ +#include <netipsec/key.h> +#endif struct inpcbtable tcbtable; /* head of queue of active tcpcb's */ @@ -238,12 +235,10 @@ struct syn_cache_head tcp_syn_cache[TCP_ int tcp_freeq(struct tcpcb *); static int tcp_iss_secret_init(void); -#ifdef INET static void tcp_mtudisc_callback(struct in_addr); -#endif #ifdef INET6 -void tcp6_mtudisc(struct in6pcb *, int); +static void tcp6_mtudisc(struct in6pcb *, int); #endif static struct pool tcpcb_pool; @@ -253,7 +248,6 @@ static int tcp_drainwanted; #ifdef TCP_CSUM_COUNTERS #include <sys/device.h> -#if defined(INET) struct evcnt tcp_hwcsum_bad = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, "tcp", "hwcsum bad"); struct evcnt tcp_hwcsum_ok = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, @@ -267,7 +261,6 @@ EVCNT_ATTACH_STATIC(tcp_hwcsum_bad); EVCNT_ATTACH_STATIC(tcp_hwcsum_ok); EVCNT_ATTACH_STATIC(tcp_hwcsum_data); EVCNT_ATTACH_STATIC(tcp_swcsum); -#endif /* defined(INET) */ #if defined(INET6) struct evcnt tcp6_hwcsum_bad = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, @@ -646,10 +639,8 @@ tcp_respond(struct tcpcb *tp, struct mbu if (tp->t_inpcb && tp->t_in6pcb) panic("tcp_respond: both t_inpcb and t_in6pcb are set"); #endif -#ifdef INET if (tp->t_inpcb) win = sbspace(&tp->t_inpcb->inp_socket->so_rcv); -#endif #ifdef INET6 if (tp->t_in6pcb) win = sbspace(&tp->t_in6pcb->in6p_socket->so_rcv); @@ -844,7 +835,6 @@ tcp_respond(struct tcpcb *tp, struct mbu th->th_urp = 0; switch (family) { -#ifdef INET case AF_INET: { struct ipovly *ipov = (struct ipovly *)ip; @@ -857,7 +847,6 @@ tcp_respond(struct tcpcb *tp, struct mbu ip->ip_ttl = ip_defttl; break; } -#endif #ifdef INET6 case AF_INET6: { @@ -916,13 +905,11 @@ tcp_respond(struct tcpcb *tp, struct mbu ro = NULL; switch (family) { -#ifdef INET case AF_INET: error = ip_output(m, NULL, ro, (tp && tp->t_mtudisc ? IP_MTUDISC : 0), NULL, tp ? tp->t_inpcb : NULL); break; -#endif #ifdef INET6 case AF_INET6: error = ip6_output(m, NULL, ro, 0, NULL, @@ -1098,10 +1085,8 @@ tcp_drop(struct tcpcb *tp, int errno) if (tp->t_inpcb && tp->t_in6pcb) panic("tcp_drop: both t_inpcb and t_in6pcb are set"); #endif -#ifdef INET if (tp->t_inpcb) so = tp->t_inpcb->inp_socket; -#endif #ifdef INET6 if (tp->t_in6pcb) so = tp->t_in6pcb->in6p_socket; @@ -1539,7 +1524,6 @@ tcp6_ctlinput(int cmd, const struct sock } #endif -#ifdef INET /* assumes that ip header and tcp header are contiguous on mbuf */ void * tcp_ctlinput(int cmd, const struct sockaddr *sa, void *v) @@ -1702,7 +1686,6 @@ tcp_quench(struct inpcb *inp, int errno) tp->t_bytes_acked = 0; } } -#endif #ifdef INET6 void @@ -1717,7 +1700,6 @@ tcp6_quench(struct in6pcb *in6p, int err } #endif -#ifdef INET /* * Path MTU Discovery handlers. */ @@ -1782,7 +1764,6 @@ tcp_mtudisc(struct inpcb *inp, int errno tp->snd_nxt = tp->sack_newdata = tp->snd_una; tcp_output(tp); } -#endif /* INET */ #ifdef INET6 /* @@ -1952,14 +1933,14 @@ tcp_mss_from_peer(struct tcpcb *tp, int #endif so = NULL; rt = NULL; -#ifdef INET + if (tp->t_inpcb) { so = tp->t_inpcb->inp_socket; #if defined(RTV_SPIPE) || defined(RTV_SSTHRESH) rt = in_pcbrtentry(tp->t_inpcb); #endif } -#endif + #ifdef INET6 if (tp->t_in6pcb) { so = tp->t_in6pcb->in6p_socket; @@ -1979,10 +1960,8 @@ tcp_mss_from_peer(struct tcpcb *tp, int mss = max(mss, 256); /* sanity */ tp->t_peermss = mss; mss -= tcp_optlen(tp); -#ifdef INET if (tp->t_inpcb) mss -= ip_optlen(tp->t_inpcb); -#endif #ifdef INET6 if (tp->t_in6pcb) mss -= ip6_optlen(tp->t_in6pcb); @@ -2025,10 +2004,8 @@ tcp_mss_from_peer(struct tcpcb *tp, int } #endif #if defined(RTV_SPIPE) || defined(RTV_SSTHRESH) -#ifdef INET if (tp->t_inpcb) in_pcbrtentry_unref(rt, tp->t_inpcb); -#endif #ifdef INET6 if (tp->t_in6pcb) in6_pcbrtentry_unref(rt, tp->t_in6pcb); @@ -2054,7 +2031,7 @@ tcp_established(struct tcpcb *tp) #endif so = NULL; rt = NULL; -#ifdef INET + /* This is a while() to reduce the dreadful stairstepping below */ while (tp->t_inpcb) { so = tp->t_inpcb->inp_socket; @@ -2080,7 +2057,7 @@ tcp_established(struct tcpcb *tp) tp->t_msl = tcp_msl_remote ? tcp_msl_remote : TCPTV_MSL; break; } -#endif + #ifdef INET6 /* The !tp->t_inpcb lets the compiler know it can't be v4 *and* v6 */ while (!tp->t_inpcb && tp->t_in6pcb) { @@ -2131,10 +2108,8 @@ tcp_established(struct tcpcb *tp) (void) sbreserve(&so->so_rcv, bufsize, so); } #ifdef RTV_RPIPE -#ifdef INET if (tp->t_inpcb) in_pcbrtentry_unref(rt, tp->t_inpcb); -#endif #ifdef INET6 if (tp->t_in6pcb) in6_pcbrtentry_unref(rt, tp->t_in6pcb); @@ -2158,10 +2133,8 @@ tcp_rmx_rtt(struct tcpcb *tp) if (tp->t_inpcb && tp->t_in6pcb) panic("tcp_rmx_rtt: both t_inpcb and t_in6pcb are set"); #endif -#ifdef INET if (tp->t_inpcb) rt = in_pcbrtentry(tp->t_inpcb); -#endif #ifdef INET6 if (tp->t_in6pcb) rt = in6_pcbrtentry(tp->t_in6pcb); @@ -2193,10 +2166,8 @@ tcp_rmx_rtt(struct tcpcb *tp) ((tp->t_srtt >> 2) + tp->t_rttvar) >> (1 + 2), tp->t_rttmin, TCPTV_REXMTMAX); } -#ifdef INET if (tp->t_inpcb) in_pcbrtentry_unref(rt, tp->t_inpcb); -#endif #ifdef INET6 if (tp->t_in6pcb) in6_pcbrtentry_unref(rt, tp->t_in6pcb); @@ -2213,14 +2184,12 @@ tcp_seq tcp_new_iss(struct tcpcb *tp, tcp_seq addin) { -#ifdef INET if (tp->t_inpcb != NULL) { return (tcp_new_iss1(&tp->t_inpcb->inp_laddr, &tp->t_inpcb->inp_faddr, tp->t_inpcb->inp_lport, tp->t_inpcb->inp_fport, sizeof(tp->t_inpcb->inp_laddr), addin)); } -#endif #ifdef INET6 if (tp->t_in6pcb != NULL) { return (tcp_new_iss1(&tp->t_in6pcb->in6p_laddr, Index: src/sys/netinet/tcp_timer.c diff -u src/sys/netinet/tcp_timer.c:1.93 src/sys/netinet/tcp_timer.c:1.94 --- src/sys/netinet/tcp_timer.c:1.93 Fri Jan 19 07:53:01 2018 +++ src/sys/netinet/tcp_timer.c Thu Mar 29 07:46:43 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_timer.c,v 1.93 2018/01/19 07:53:01 ozaki-r Exp $ */ +/* $NetBSD: tcp_timer.c,v 1.94 2018/03/29 07:46:43 maxv Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -93,7 +93,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tcp_timer.c,v 1.93 2018/01/19 07:53:01 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_timer.c,v 1.94 2018/03/29 07:46:43 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -122,9 +122,6 @@ __KERNEL_RCSID(0, "$NetBSD: tcp_timer.c, #include <netinet/ip_icmp.h> #ifdef INET6 -#ifndef INET -#include <netinet/in.h> -#endif #include <netinet/ip6.h> #include <netinet6/in6_pcb.h> #endif @@ -347,10 +344,8 @@ tcp_timer_rexmt(void *arg) return; } #ifdef TCP_DEBUG -#ifdef INET if (tp->t_inpcb) so = tp->t_inpcb->inp_socket; -#endif #ifdef INET6 if (tp->t_in6pcb) so = tp->t_in6pcb->in6p_socket; @@ -396,11 +391,9 @@ tcp_timer_rexmt(void *arg) if (tp->t_mtudisc && tp->t_rxtshift > TCP_MAXRXTSHIFT / 6) { TCP_STATINC(TCP_STAT_PMTUBLACKHOLE); -#ifdef INET /* try turning PMTUD off */ if (tp->t_inpcb) tp->t_mtudisc = 0; -#endif #ifdef INET6 /* try using IPv6 minimum MTU */ if (tp->t_in6pcb) @@ -419,10 +412,8 @@ tcp_timer_rexmt(void *arg) * retransmit times until then. */ if (tp->t_rxtshift > TCP_MAXRXTSHIFT / 4) { -#ifdef INET if (tp->t_inpcb) in_losing(tp->t_inpcb); -#endif #ifdef INET6 if (tp->t_in6pcb) in6_losing(tp->t_in6pcb); @@ -491,10 +482,8 @@ tcp_timer_persist(void *arg) KERNEL_LOCK(1, NULL); #ifdef TCP_DEBUG -#ifdef INET if (tp->t_inpcb) so = tp->t_inpcb->inp_socket; -#endif #ifdef INET6 if (tp->t_in6pcb) so = tp->t_in6pcb->in6p_socket; @@ -574,10 +563,8 @@ tcp_timer_keep(void *arg) TCP_STATINC(TCP_STAT_KEEPTIMEO); if (TCPS_HAVEESTABLISHED(tp->t_state) == 0) goto dropit; -#ifdef INET if (tp->t_inpcb) so = tp->t_inpcb->inp_socket; -#endif #ifdef INET6 if (tp->t_in6pcb) so = tp->t_in6pcb->in6p_socket; @@ -655,10 +642,8 @@ tcp_timer_2msl(void *arg) tp->snd_fack = tp->snd_una; #ifdef TCP_DEBUG -#ifdef INET if (tp->t_inpcb) so = tp->t_inpcb->inp_socket; -#endif #ifdef INET6 if (tp->t_in6pcb) so = tp->t_in6pcb->in6p_socket; Index: src/sys/netinet/tcp_usrreq.c diff -u src/sys/netinet/tcp_usrreq.c:1.216 src/sys/netinet/tcp_usrreq.c:1.217 --- src/sys/netinet/tcp_usrreq.c:1.216 Tue Aug 15 09:21:48 2017 +++ src/sys/netinet/tcp_usrreq.c Thu Mar 29 07:46:43 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_usrreq.c,v 1.216 2017/08/15 09:21:48 christos Exp $ */ +/* $NetBSD: tcp_usrreq.c,v 1.217 2018/03/29 07:46:43 maxv Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -99,7 +99,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.216 2017/08/15 09:21:48 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.217 2018/03/29 07:46:43 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -136,9 +136,6 @@ __KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c #include <netinet/in_offload.h> #ifdef INET6 -#ifndef INET -#include <netinet/in.h> -#endif #include <netinet/ip6.h> #include <netinet6/in6_pcb.h> #include <netinet6/ip6_var.h> @@ -190,14 +187,12 @@ tcp_getpcb(struct socket *so, struct inp * structure will point at a subsidary (struct tcpcb). */ switch (so->so_proto->pr_domain->dom_family) { -#ifdef INET case PF_INET: *inp = sotoinpcb(so); if (*inp == NULL) return EINVAL; *tp = intotcpcb(*inp); break; -#endif #ifdef INET6 case PF_INET6: *in6p = sotoin6pcb(so); @@ -316,14 +311,12 @@ tcp_ctloutput(int op, struct socket *so, s = splsoftnet(); switch (family) { -#ifdef INET case PF_INET: inp = sotoinpcb(so); #ifdef INET6 in6p = NULL; #endif break; -#endif #ifdef INET6 case PF_INET6: inp = NULL; @@ -345,11 +338,9 @@ tcp_ctloutput(int op, struct socket *so, } if (level != IPPROTO_TCP) { switch (family) { -#ifdef INET case PF_INET: error = ip_ctloutput(op, so, sopt); break; -#endif #ifdef INET6 case PF_INET6: error = ip6_ctloutput(op, so, sopt); @@ -534,14 +525,12 @@ tcp_attach(struct socket *so, int proto) family = so->so_proto->pr_domain->dom_family; switch (family) { -#ifdef INET case PF_INET: inp = sotoinpcb(so); #ifdef INET6 in6p = NULL; #endif break; -#endif #ifdef INET6 case PF_INET6: inp = NULL; @@ -573,7 +562,6 @@ tcp_attach(struct socket *so, int proto) so->so_snd.sb_flags |= SB_AUTOSIZE; switch (family) { -#ifdef INET case PF_INET: error = in_pcballoc(so, &tcbtable); if (error) @@ -583,7 +571,6 @@ tcp_attach(struct socket *so, int proto) in6p = NULL; #endif break; -#endif #ifdef INET6 case PF_INET6: error = in6_pcballoc(so, &tcbtable); @@ -610,10 +597,8 @@ tcp_attach(struct socket *so, int proto) int nofd = so->so_state & SS_NOFDREF; /* XXX */ so->so_state &= ~SS_NOFDREF; /* don't free the socket yet */ -#ifdef INET if (inp) in_pcbdetach(inp); -#endif #ifdef INET6 if (in6p) in6_pcbdetach(in6p); @@ -669,11 +654,9 @@ tcp_accept(struct socket *so, struct soc * of the peer, storing through addr. */ s = splsoftnet(); -#ifdef INET if (inp) { in_setpeeraddr(inp, (struct sockaddr_in *)nam); } -#endif #ifdef INET6 if (in6p) { in6_setpeeraddr(in6p, (struct sockaddr_in6 *)nam); @@ -709,11 +692,9 @@ tcp_bind(struct socket *so, struct socka */ s = splsoftnet(); switch (so->so_proto->pr_domain->dom_family) { -#ifdef INET case PF_INET: error = in_pcbbind(inp, sin, l); break; -#endif #ifdef INET6 case PF_INET6: error = in6_pcbbind(in6p, sin6, l); @@ -752,13 +733,11 @@ tcp_listen(struct socket *so, struct lwp * Prepare to accept connections. */ s = splsoftnet(); -#ifdef INET if (inp && inp->inp_lport == 0) { error = in_pcbbind(inp, NULL, l); if (error) goto release; } -#endif #ifdef INET6 if (in6p && in6p->in6p_lport == 0) { error = in6_pcbbind(in6p, NULL, l); @@ -798,7 +777,7 @@ tcp_connect(struct socket *so, struct so * Send initial segment on connection. */ s = splsoftnet(); -#ifdef INET + if (inp) { if (inp->inp_lport == 0) { error = in_pcbbind(inp, NULL, l); @@ -807,7 +786,6 @@ tcp_connect(struct socket *so, struct so } error = in_pcbconnect(inp, (struct sockaddr_in *)nam, l); } -#endif #ifdef INET6 if (in6p) { if (in6p->in6p_lport == 0) { @@ -829,10 +807,8 @@ tcp_connect(struct socket *so, struct so goto release; tp->t_template = tcp_template(tp); if (tp->t_template == 0) { -#ifdef INET if (inp) in_pcbdisconnect(inp); -#endif #ifdef INET6 if (in6p) in6_pcbdisconnect(in6p); @@ -975,10 +951,8 @@ static int tcp_ioctl(struct socket *so, u_long cmd, void *nam, struct ifnet *ifp) { switch (so->so_proto->pr_domain->dom_family) { -#ifdef INET case PF_INET: return in_control(so, cmd, nam, ifp); -#endif #ifdef INET6 case PF_INET6: return in6_control(so, cmd, nam, ifp); @@ -1013,11 +987,9 @@ tcp_peeraddr(struct socket *so, struct s ostate = tcp_debug_capture(tp, PRU_PEERADDR); s = splsoftnet(); -#ifdef INET if (inp) { in_setpeeraddr(inp, (struct sockaddr_in *)nam); } -#endif #ifdef INET6 if (in6p) { in6_setpeeraddr(in6p, (struct sockaddr_in6 *)nam); @@ -1045,11 +1017,9 @@ tcp_sockaddr(struct socket *so, struct s ostate = tcp_debug_capture(tp, PRU_SOCKADDR); s = splsoftnet(); -#ifdef INET if (inp) { in_setsockaddr(inp, (struct sockaddr_in *)nam); } -#endif #ifdef INET6 if (in6p) { in6_setsockaddr(in6p, (struct sockaddr_in6 *)nam); @@ -1222,7 +1192,6 @@ tcp_purgeif(struct socket *so, struct if mutex_enter(softnet_lock); switch (so->so_proto->pr_domain->dom_family) { -#ifdef INET case PF_INET: in_pcbpurgeif0(&tcbtable, ifp); #ifdef NET_MPSAFE @@ -1234,7 +1203,6 @@ tcp_purgeif(struct socket *so, struct if #endif in_pcbpurgeif(&tcbtable, ifp); break; -#endif #ifdef INET6 case PF_INET6: in6_pcbpurgeif0(&tcbtable, ifp); @@ -1440,7 +1408,6 @@ sysctl_net_inet_ip_ports(SYSCTLFN_ARGS) return (EINVAL); switch (name[-3]) { -#ifdef INET case PF_INET: apmin = anonportmin; apmax = anonportmax; @@ -1449,7 +1416,6 @@ sysctl_net_inet_ip_ports(SYSCTLFN_ARGS) lpmax = lowportmax; #endif /* IPNOPRIVPORTS */ break; -#endif /* INET */ #ifdef INET6 case PF_INET6: apmin = ip6_anonportmin; @@ -1637,12 +1603,10 @@ inet6_ident_core(struct in6_addr *raddr, static int sysctl_net_inet_tcp_ident(SYSCTLFN_ARGS) { -#ifdef INET struct sockaddr_in *si4[2]; -#endif /* INET */ #ifdef INET6 struct sockaddr_in6 *si6[2]; -#endif /* INET6 */ +#endif struct sockaddr_storage sa[2]; int error, pf, dodrop; @@ -1663,7 +1627,6 @@ sysctl_net_inet_tcp_ident(SYSCTLFN_ARGS) /* old style lookup, ipv4 only */ if (namelen == 4) { -#ifdef INET struct in_addr laddr, raddr; u_int lport, rport; @@ -1679,9 +1642,6 @@ sysctl_net_inet_tcp_ident(SYSCTLFN_ARGS) oldp, oldlenp, l, dodrop); mutex_exit(softnet_lock); return error; -#else /* INET */ - return EINVAL; -#endif /* INET */ } if (newp == NULL || newlen != sizeof(sa)) @@ -1730,7 +1690,6 @@ sysctl_net_inet_tcp_ident(SYSCTLFN_ARGS) in6_sin6_2_sin_in_sock((struct sockaddr *)&sa[1]); /*FALLTHROUGH*/ #endif /* INET6 */ -#ifdef INET case PF_INET: si4[0] = (struct sockaddr_in*)&sa[0]; si4[1] = (struct sockaddr_in*)&sa[1]; @@ -1744,7 +1703,6 @@ sysctl_net_inet_tcp_ident(SYSCTLFN_ARGS) oldp, oldlenp, l, dodrop); mutex_exit(softnet_lock); return error; -#endif /* INET */ default: return EPROTONOSUPPORT; } @@ -1759,10 +1717,8 @@ sysctl_net_inet_tcp_ident(SYSCTLFN_ARGS) int sysctl_inpcblist(SYSCTLFN_ARGS) { -#ifdef INET struct sockaddr_in *in; const struct inpcb *inp; -#endif #ifdef INET6 struct sockaddr_in6 *in6; const struct in6pcb *in6p; @@ -1807,9 +1763,7 @@ sysctl_inpcblist(SYSCTLFN_ARGS) mutex_enter(softnet_lock); TAILQ_FOREACH(inph, &pcbtbl->inpt_queue, inph_queue) { -#ifdef INET inp = (const struct inpcb *)inph; -#endif #ifdef INET6 in6p = (const struct in6pcb *)inph; #endif @@ -1831,7 +1785,6 @@ sysctl_inpcblist(SYSCTLFN_ARGS) case 0: /* just probing for size */ break; -#ifdef INET case PF_INET: pcb.ki_family = inp->inp_socket->so_proto-> pr_domain->dom_family; @@ -1869,7 +1822,6 @@ sysctl_inpcblist(SYSCTLFN_ARGS) in->sin_addr = inp->inp_faddr; } break; -#endif #ifdef INET6 case PF_INET6: pcb.ki_family = in6p->in6p_socket->so_proto-> @@ -2477,9 +2429,7 @@ void tcp_usrreq_init(void) { -#ifdef INET sysctl_net_inet_tcp_setup2(NULL, PF_INET, "inet", "tcp"); -#endif #ifdef INET6 sysctl_net_inet_tcp_setup2(NULL, PF_INET6, "inet6", "tcp6"); #endif