From owner-svn-src-head@FreeBSD.ORG Sat Apr 30 11:21:29 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6EF89106566C; Sat, 30 Apr 2011 11:21:29 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5D8998FC16; Sat, 30 Apr 2011 11:21:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p3UBLTeC043453; Sat, 30 Apr 2011 11:21:29 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p3UBLTBX043445; Sat, 30 Apr 2011 11:21:29 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201104301121.p3UBLTBX043445@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sat, 30 Apr 2011 11:21:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r221250 - in head/sys: conf netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Apr 2011 11:21:29 -0000 Author: bz Date: Sat Apr 30 11:21:29 2011 New Revision: 221250 URL: http://svn.freebsd.org/changeset/base/221250 Log: Make the TCP code compile without INET. Sort #includes and add #ifdef INETs. Add some comments at #endifs given more nestedness. To make the compiler happy, some default initializations were added in accordance with the style on the files. Reviewed by: gnn Sponsored by: The FreeBSD Foundation Sponsored by: iXsystems MFC after: 4 days Modified: head/sys/conf/files head/sys/netinet/tcp_input.c head/sys/netinet/tcp_output.c head/sys/netinet/tcp_subr.c head/sys/netinet/tcp_syncache.c head/sys/netinet/tcp_timewait.c head/sys/netinet/tcp_usrreq.c Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Sat Apr 30 11:18:16 2011 (r221249) +++ head/sys/conf/files Sat Apr 30 11:21:29 2011 (r221250) @@ -2740,8 +2740,8 @@ netinet/ip_mroute.c optional mrouting i netinet/ip_options.c optional inet netinet/ip_output.c optional inet netinet/raw_ip.c optional inet -netinet/cc/cc.c optional inet -netinet/cc/cc_newreno.c optional inet +netinet/cc/cc.c optional inet | inet6 +netinet/cc/cc_newreno.c optional inet | inet6 netinet/sctp_asconf.c optional inet sctp netinet/sctp_auth.c optional inet sctp netinet/sctp_bsd_addr.c optional inet sctp @@ -2758,18 +2758,18 @@ netinet/sctp_timer.c optional inet sctp netinet/sctp_usrreq.c optional inet sctp netinet/sctputil.c optional inet sctp netinet/tcp_debug.c optional tcpdebug -netinet/tcp_hostcache.c optional inet -netinet/tcp_input.c optional inet -netinet/tcp_lro.c optional inet -netinet/tcp_output.c optional inet -netinet/tcp_offload.c optional inet -netinet/tcp_reass.c optional inet -netinet/tcp_sack.c optional inet -netinet/tcp_subr.c optional inet -netinet/tcp_syncache.c optional inet -netinet/tcp_timer.c optional inet -netinet/tcp_timewait.c optional inet -netinet/tcp_usrreq.c optional inet +netinet/tcp_hostcache.c optional inet | inet6 +netinet/tcp_input.c optional inet | inet6 +netinet/tcp_lro.c optional inet | inet6 +netinet/tcp_output.c optional inet | inet6 +netinet/tcp_offload.c optional inet | inet6 +netinet/tcp_reass.c optional inet | inet6 +netinet/tcp_sack.c optional inet | inet6 +netinet/tcp_subr.c optional inet | inet6 +netinet/tcp_syncache.c optional inet | inet6 +netinet/tcp_timer.c optional inet | inet6 +netinet/tcp_timewait.c optional inet | inet6 +netinet/tcp_usrreq.c optional inet | inet6 netinet/udp_usrreq.c optional inet | inet6 netinet/libalias/alias.c optional libalias inet | netgraph_nat inet netinet/libalias/alias_db.c optional libalias inet | netgraph_nat inet Modified: head/sys/netinet/tcp_input.c ============================================================================== --- head/sys/netinet/tcp_input.c Sat Apr 30 11:18:16 2011 (r221249) +++ head/sys/netinet/tcp_input.c Sat Apr 30 11:21:29 2011 (r221250) @@ -367,12 +367,13 @@ cc_conn_init(struct tcpcb *tp) tp->snd_cwnd = min(4 * tp->t_maxseg, max(2 * tp->t_maxseg, 4380)); #ifdef INET6 - else if ((isipv6 && in6_localaddr(&inp->in6p_faddr)) || - (!isipv6 && in_localaddr(inp->inp_faddr))) -#else - else if (in_localaddr(inp->inp_faddr)) + else if (isipv6 && in6_localaddr(&inp->in6p_faddr)) + tp->snd_cwnd = tp->t_maxseg * V_ss_fltsz_local; #endif +#if defined(INET) || defined(INET6) + else if (in_localaddr(inp->inp_faddr)) tp->snd_cwnd = tp->t_maxseg * V_ss_fltsz_local; +#endif else tp->snd_cwnd = tp->t_maxseg * V_ss_fltsz; @@ -542,37 +543,46 @@ tcp6_input(struct mbuf **mp, int *offp, tcp_input(m, *offp); return IPPROTO_DONE; } -#endif +#endif /* INET6 */ void tcp_input(struct mbuf *m, int off0) { - struct tcphdr *th; + struct tcphdr *th = NULL; struct ip *ip = NULL; +#ifdef INET struct ipovly *ipov; +#endif struct inpcb *inp = NULL; struct tcpcb *tp = NULL; struct socket *so = NULL; u_char *optp = NULL; int optlen = 0; - int len, tlen, off; +#ifdef INET + int len; +#endif + int tlen = 0, off; int drop_hdrlen; int thflags; int rstreason = 0; /* For badport_bandlim accounting purposes */ - uint8_t iptos; #ifdef TCP_SIGNATURE uint8_t sig_checked = 0; #endif + uint8_t iptos = 0; +#ifdef INET #ifdef IPFIREWALL_FORWARD struct m_tag *fwd_tag; #endif +#endif /* INET */ #ifdef INET6 struct ip6_hdr *ip6 = NULL; int isipv6; #else const void *ip6 = NULL; +#if (defined(INET) && defined(IPFIREWALL_FORWARD)) || defined(TCPDEBUG) const int isipv6 = 0; #endif +#endif /* INET6 */ struct tcpopt to; /* options in this segment */ char *s = NULL; /* address and port logging */ int ti_locked; @@ -597,8 +607,8 @@ tcp_input(struct mbuf *m, int off0) to.to_flags = 0; TCPSTAT_INC(tcps_rcvtotal); - if (isipv6) { #ifdef INET6 + if (isipv6) { /* IP6_EXTHDR_CHECK() is already done at tcp6_input(). */ ip6 = mtod(m, struct ip6_hdr *); tlen = sizeof(*ip6) + ntohs(ip6->ip6_plen) - off0; @@ -620,10 +630,13 @@ tcp_input(struct mbuf *m, int off0) /* XXX stat */ goto drop; } -#else - th = NULL; /* XXX: Avoid compiler warning. */ + } #endif - } else { +#if defined(INET) && defined(INET6) + else +#endif +#ifdef INET + { /* * Get IP and TCP header together in first mbuf. * Note: IP leaves IP header in first mbuf. @@ -675,13 +688,18 @@ tcp_input(struct mbuf *m, int off0) /* Re-initialization for later version check */ ip->ip_v = IPVERSION; } +#endif /* INET */ #ifdef INET6 if (isipv6) iptos = (ntohl(ip6->ip6_flow) >> 20) & 0xff; +#endif +#if defined(INET) && defined(INET6) else #endif +#ifdef INET iptos = ip->ip_tos; +#endif /* * Check that TCP offset makes sense, @@ -694,13 +712,18 @@ tcp_input(struct mbuf *m, int off0) } tlen -= off; /* tlen is used instead of ti->ti_len */ if (off > sizeof (struct tcphdr)) { - if (isipv6) { #ifdef INET6 + if (isipv6) { IP6_EXTHDR_CHECK(m, off0, off, ); ip6 = mtod(m, struct ip6_hdr *); th = (struct tcphdr *)((caddr_t)ip6 + off0); + } #endif - } else { +#if defined(INET) && defined(INET6) + else +#endif +#ifdef INET + { if (m->m_len < sizeof(struct ip) + off) { if ((m = m_pullup(m, sizeof (struct ip) + off)) == NULL) { @@ -712,6 +735,7 @@ tcp_input(struct mbuf *m, int off0) th = (struct tcphdr *)((caddr_t)ip + off0); } } +#endif optlen = off - sizeof (struct tcphdr); optp = (u_char *)(th + 1); } @@ -754,6 +778,7 @@ findpcb: panic("%s: findpcb ti_locked %d\n", __func__, ti_locked); #endif +#ifdef INET #ifdef IPFIREWALL_FORWARD /* * Grab info from PACKET_TAG_IPFORWARD tag prepended to the chain. @@ -787,21 +812,26 @@ findpcb: m_tag_delete(m, fwd_tag); } else #endif /* IPFIREWALL_FORWARD */ +#endif /* INET */ { - if (isipv6) { #ifdef INET6 + if (isipv6) inp = in6_pcblookup_hash(&V_tcbinfo, &ip6->ip6_src, th->th_sport, &ip6->ip6_dst, th->th_dport, INPLOOKUP_WILDCARD, m->m_pkthdr.rcvif); #endif - } else +#if defined(INET) && defined(INET6) + else +#endif +#ifdef INET inp = in_pcblookup_hash(&V_tcbinfo, ip->ip_src, th->th_sport, ip->ip_dst, th->th_dport, INPLOOKUP_WILDCARD, m->m_pkthdr.rcvif); +#endif } /* @@ -989,7 +1019,7 @@ relocked: bcopy((char *)ip, (char *)tcp_saveipgen, sizeof(*ip)); tcp_savetcp = *th; } -#endif +#endif /* TCPDEBUG */ /* * When the socket is accepting connections (the INPCB is in LISTEN * state) we look into the SYN cache if this is a new connection @@ -1224,7 +1254,7 @@ relocked: } ifa_free(&ia6->ia_ifa); } -#endif +#endif /* INET6 */ /* * Basic sanity checks on incoming SYN requests: * Don't respond if the destination is a link layer @@ -1243,8 +1273,8 @@ relocked: "link layer address ignored\n", s, __func__); goto dropunlock; } - if (isipv6) { #ifdef INET6 + if (isipv6) { if (th->th_dport == th->th_sport && IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &ip6->ip6_src)) { if ((s = tcp_log_addrs(&inc, th, NULL, NULL))) @@ -1261,8 +1291,13 @@ relocked: "address ignored\n", s, __func__); goto dropunlock; } + } #endif - } else { +#if defined(INET) && defined(INET6) + else +#endif +#ifdef INET + { if (th->th_dport == th->th_sport && ip->ip_dst.s_addr == ip->ip_src.s_addr) { if ((s = tcp_log_addrs(&inc, th, NULL, NULL))) @@ -1283,6 +1318,7 @@ relocked: goto dropunlock; } } +#endif /* * SYN appears to be valid. Create compressed TCP state * for syncache. @@ -3020,7 +3056,9 @@ static void tcp_dropwithreset(struct mbuf *m, struct tcphdr *th, struct tcpcb *tp, int tlen, int rstreason) { +#ifdef INET struct ip *ip; +#endif #ifdef INET6 struct ip6_hdr *ip6; #endif @@ -3039,8 +3077,12 @@ tcp_dropwithreset(struct mbuf *m, struct IN6_IS_ADDR_MULTICAST(&ip6->ip6_src)) goto drop; /* IPv6 anycast check is done at tcp6_input() */ - } else + } #endif +#if defined(INET) && defined(INET6) + else +#endif +#ifdef INET { ip = mtod(m, struct ip *); if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) || @@ -3049,6 +3091,7 @@ tcp_dropwithreset(struct mbuf *m, struct in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif)) goto drop; } +#endif /* Perform bandwidth limiting. */ if (badport_bandlim(rstreason) < 0) @@ -3308,8 +3351,8 @@ void tcp_mss_update(struct tcpcb *tp, int offer, struct hc_metrics_lite *metricptr, int *mtuflags) { - int mss; - u_long maxmtu; + int mss = 0; + u_long maxmtu = 0; struct inpcb *inp = tp->t_inpcb; struct hc_metrics_lite metrics; int origoffer = offer; @@ -3329,12 +3372,17 @@ tcp_mss_update(struct tcpcb *tp, int off if (isipv6) { maxmtu = tcp_maxmtu6(&inp->inp_inc, mtuflags); tp->t_maxopd = tp->t_maxseg = V_tcp_v6mssdflt; - } else + } #endif +#if defined(INET) && defined(INET6) + else +#endif +#ifdef INET { maxmtu = tcp_maxmtu(&inp->inp_inc, mtuflags); tp->t_maxopd = tp->t_maxseg = V_tcp_mssdflt; } +#endif /* * No route to sender, stay with default mss and return. @@ -3395,14 +3443,19 @@ tcp_mss_update(struct tcpcb *tp, int off if (!V_path_mtu_discovery && !in6_localaddr(&inp->in6p_faddr)) mss = min(mss, V_tcp_v6mssdflt); - } else + } #endif +#if defined(INET) && defined(INET6) + else +#endif +#ifdef INET { mss = maxmtu - min_protoh; if (!V_path_mtu_discovery && !in_localaddr(inp->inp_faddr)) mss = min(mss, V_tcp_mssdflt); } +#endif /* * XXX - The above conditional (mss = maxmtu - min_protoh) * probably violates the TCP spec. @@ -3540,14 +3593,19 @@ tcp_mssopt(struct in_conninfo *inc) maxmtu = tcp_maxmtu6(inc, NULL); thcmtu = tcp_hc_getmtu(inc); /* IPv4 and IPv6 */ min_protoh = sizeof(struct ip6_hdr) + sizeof(struct tcphdr); - } else + } +#endif +#if defined(INET) && defined(INET6) + else #endif +#ifdef INET { mss = V_tcp_mssdflt; maxmtu = tcp_maxmtu(inc, NULL); thcmtu = tcp_hc_getmtu(inc); /* IPv4 and IPv6 */ min_protoh = sizeof(struct tcpiphdr); } +#endif if (maxmtu && thcmtu) mss = min(maxmtu, thcmtu) - min_protoh; else if (maxmtu || thcmtu) Modified: head/sys/netinet/tcp_output.c ============================================================================== --- head/sys/netinet/tcp_output.c Sat Apr 30 11:18:16 2011 (r221249) +++ head/sys/netinet/tcp_output.c Sat Apr 30 11:21:29 2011 (r221250) @@ -173,7 +173,7 @@ tcp_output(struct tcpcb *tp) { struct socket *so = tp->t_inpcb->inp_socket; long len, recwin, sendwin; - int off, flags, error; + int off, flags, error = 0; /* Keep compiler happy */ struct mbuf *m; struct ip *ip = NULL; struct ipovly *ipov = NULL; @@ -659,7 +659,7 @@ send: hdrlen = sizeof (struct ip6_hdr) + sizeof (struct tcphdr); else #endif - hdrlen = sizeof (struct tcpiphdr); + hdrlen = sizeof (struct tcpiphdr); /* * Compute options for segment. @@ -866,7 +866,7 @@ send: goto out; } } -#endif +#endif /* notyet */ /* * If we're sending everything we've got, set PUSH. * (This will keep happy those implementations which only @@ -1189,7 +1189,7 @@ timer: #endif ipov->ih_len = save; } -#endif +#endif /* TCPDEBUG */ /* * Fill in IP length and desired time to live and @@ -1216,8 +1216,12 @@ timer: tp->t_inpcb->in6p_outputopts, NULL, ((so->so_options & SO_DONTROUTE) ? IP_ROUTETOIF : 0), NULL, NULL, tp->t_inpcb); - } else + } #endif /* INET6 */ +#if defined(INET) && defined(INET6) + else +#endif +#ifdef INET { ip->ip_len = m->m_pkthdr.len; #ifdef INET6 @@ -1239,6 +1243,7 @@ timer: ((so->so_options & SO_DONTROUTE) ? IP_ROUTETOIF : 0), 0, tp->t_inpcb); } +#endif /* INET */ if (error) { /* Modified: head/sys/netinet/tcp_subr.c ============================================================================== --- head/sys/netinet/tcp_subr.c Sat Apr 30 11:18:16 2011 (r221249) +++ head/sys/netinet/tcp_subr.c Sat Apr 30 11:21:29 2011 (r221250) @@ -66,23 +66,20 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include +#include #include +#include +#include #ifdef INET6 #include -#endif -#include -#ifdef INET6 #include -#endif -#include -#include -#ifdef INET6 #include #include #include #endif -#include + #include #include #include @@ -96,7 +93,9 @@ __FBSDID("$FreeBSD$"); #ifdef TCPDEBUG #include #endif +#ifdef INET6 #include +#endif #ifdef IPSEC #include @@ -160,7 +159,7 @@ SYSCTL_VNET_PROC(_net_inet_tcp, TCPCTL_V CTLTYPE_INT|CTLFLAG_RW, &VNET_NAME(tcp_v6mssdflt), 0, &sysctl_net_inet_tcp_mss_v6_check, "I", "Default TCP Maximum Segment Size for IPv6"); -#endif +#endif /* INET6 */ /* * Minimum MSS we accept and use. This prevents DoS attacks where @@ -414,8 +413,12 @@ tcpip_fillheaders(struct inpcb *inp, voi ip6->ip6_plen = htons(sizeof(struct tcphdr)); ip6->ip6_src = inp->in6p_laddr; ip6->ip6_dst = inp->in6p_faddr; - } else + } +#endif /* INET6 */ +#if defined(INET6) && defined(INET) + else #endif +#ifdef INET { struct ip *ip; @@ -432,6 +435,7 @@ tcpip_fillheaders(struct inpcb *inp, voi ip->ip_src = inp->inp_laddr; ip->ip_dst = inp->inp_faddr; } +#endif /* INET */ th->th_sport = inp->inp_lport; th->th_dport = inp->inp_fport; th->th_seq = 0; @@ -493,7 +497,7 @@ tcp_respond(struct tcpcb *tp, void *ipge KASSERT(tp != NULL || m != NULL, ("tcp_respond: tp and m both NULL")); #ifdef INET6 - isipv6 = ((struct ip *)ipgen)->ip_v == 6; + isipv6 = ((struct ip *)ipgen)->ip_v == (IPV6_VERSION >> 4); ip6 = ipgen; #endif /* INET6 */ ip = ipgen; @@ -574,8 +578,12 @@ tcp_respond(struct tcpcb *tp, void *ipge ip6->ip6_plen = htons((u_short)(sizeof (struct tcphdr) + tlen)); tlen += sizeof (struct ip6_hdr) + sizeof (struct tcphdr); - } else + } #endif +#if defined(INET) && defined(INET6) + else +#endif +#ifdef INET { tlen += sizeof (struct tcpiphdr); ip->ip_len = tlen; @@ -583,6 +591,7 @@ tcp_respond(struct tcpcb *tp, void *ipge if (V_path_mtu_discovery) ip->ip_off |= IP_DF; } +#endif m->m_len = tlen; m->m_pkthdr.len = tlen; m->m_pkthdr.rcvif = NULL; @@ -620,14 +629,19 @@ tcp_respond(struct tcpcb *tp, void *ipge tlen - sizeof(struct ip6_hdr)); ip6->ip6_hlim = in6_selecthlim(tp != NULL ? tp->t_inpcb : NULL, NULL); - } else + } #endif /* INET6 */ +#if defined(INET6) && defined(INET) + else +#endif +#ifdef INET { nth->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, htons((u_short)(tlen - sizeof(struct ip) + ip->ip_p))); m->m_pkthdr.csum_flags = CSUM_TCP; m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); } +#endif /* INET */ #ifdef TCPDEBUG if (tp == NULL || (inp->inp_socket->so_options & SO_DEBUG)) tcp_trace(TA_OUTPUT, 0, tp, mtod(m, void *), th, 0); @@ -635,9 +649,13 @@ tcp_respond(struct tcpcb *tp, void *ipge #ifdef INET6 if (isipv6) (void) ip6_output(m, NULL, NULL, ipflags, NULL, NULL, inp); - else #endif /* INET6 */ - (void) ip_output(m, NULL, NULL, ipflags, NULL, inp); +#if defined(INET) && defined(INET6) + else +#endif +#ifdef INET + (void) ip_output(m, NULL, NULL, ipflags, NULL, inp); +#endif } /* @@ -1200,6 +1218,7 @@ SYSCTL_PROC(_net_inet_tcp, TCPCTL_PCBLIS CTLTYPE_OPAQUE | CTLFLAG_RD, NULL, 0, tcp_pcblist, "S,xtcpcb", "List of active TCP connections"); +#ifdef INET static int tcp_getcred(SYSCTL_HANDLER_ARGS) { @@ -1239,6 +1258,7 @@ tcp_getcred(SYSCTL_HANDLER_ARGS) SYSCTL_PROC(_net_inet_tcp, OID_AUTO, getcred, CTLTYPE_OPAQUE|CTLFLAG_RW|CTLFLAG_PRISON, 0, 0, tcp_getcred, "S,xucred", "Get the xucred of a TCP connection"); +#endif /* INET */ #ifdef INET6 static int @@ -1247,7 +1267,10 @@ tcp6_getcred(SYSCTL_HANDLER_ARGS) struct xucred xuc; struct sockaddr_in6 addrs[2]; struct inpcb *inp; - int error, mapped = 0; + int error; +#ifdef INET + int mapped = 0; +#endif error = priv_check(req->td, PRIV_NETINET_GETCRED); if (error) @@ -1260,13 +1283,16 @@ tcp6_getcred(SYSCTL_HANDLER_ARGS) return (error); } if (IN6_IS_ADDR_V4MAPPED(&addrs[0].sin6_addr)) { +#ifdef INET if (IN6_IS_ADDR_V4MAPPED(&addrs[1].sin6_addr)) mapped = 1; else +#endif return (EINVAL); } INP_INFO_RLOCK(&V_tcbinfo); +#ifdef INET if (mapped == 1) inp = in_pcblookup_hash(&V_tcbinfo, *(struct in_addr *)&addrs[1].sin6_addr.s6_addr[12], @@ -1275,6 +1301,7 @@ tcp6_getcred(SYSCTL_HANDLER_ARGS) addrs[0].sin6_port, 0, NULL); else +#endif inp = in6_pcblookup_hash(&V_tcbinfo, &addrs[1].sin6_addr, addrs[1].sin6_port, &addrs[0].sin6_addr, addrs[0].sin6_port, 0, NULL); @@ -1300,9 +1327,10 @@ tcp6_getcred(SYSCTL_HANDLER_ARGS) SYSCTL_PROC(_net_inet6_tcp6, OID_AUTO, getcred, CTLTYPE_OPAQUE|CTLFLAG_RW|CTLFLAG_PRISON, 0, 0, tcp6_getcred, "S,xucred", "Get the xucred of a TCP6 connection"); -#endif +#endif /* INET6 */ +#ifdef INET void tcp_ctlinput(int cmd, struct sockaddr *sa, void *vip) { @@ -1415,6 +1443,7 @@ tcp_ctlinput(int cmd, struct sockaddr *s } else in_pcbnotifyall(&V_tcbinfo, faddr, inetctlerrmap[cmd], notify); } +#endif /* INET */ #ifdef INET6 void @@ -1694,6 +1723,7 @@ tcp_mtudisc(struct inpcb *inp, int errno return (inp); } +#ifdef INET /* * Look-up the routing entry to the peer of this inpcb. If no route * is found and it cannot be allocated, then return 0. This routine @@ -1735,6 +1765,7 @@ tcp_maxmtu(struct in_conninfo *inc, int } return (maxmtu); } +#endif /* INET */ #ifdef INET6 u_long @@ -1858,11 +1889,15 @@ tcp_signature_compute(struct mbuf *m, in u_char *buf, u_int direction) { union sockaddr_union dst; +#ifdef INET struct ippseudo ippseudo; +#endif MD5_CTX ctx; int doff; struct ip *ip; +#ifdef INET struct ipovly *ipovly; +#endif struct secasvar *sav; struct tcphdr *th; #ifdef INET6 @@ -1884,12 +1919,14 @@ tcp_signature_compute(struct mbuf *m, in ip6 = NULL; /* Make the compiler happy. */ #endif switch (ip->ip_v) { +#ifdef INET case IPVERSION: dst.sa.sa_len = sizeof(struct sockaddr_in); dst.sa.sa_family = AF_INET; dst.sin.sin_addr = (direction == IPSEC_DIR_INBOUND) ? ip->ip_src : ip->ip_dst; break; +#endif #ifdef INET6 case (IPV6_VERSION >> 4): ip6 = mtod(m, struct ip6_hdr *); @@ -1929,6 +1966,7 @@ tcp_signature_compute(struct mbuf *m, in * tcp_output(), the underlying ip_len member has not yet been set. */ switch (ip->ip_v) { +#ifdef INET case IPVERSION: ipovly = (struct ipovly *)ip; ippseudo.ippseudo_src = ipovly->ih_src; @@ -1942,6 +1980,7 @@ tcp_signature_compute(struct mbuf *m, in th = (struct tcphdr *)((u_char *)ip + sizeof(struct ip)); doff = sizeof(struct ip) + sizeof(struct tcphdr) + optlen; break; +#endif #ifdef INET6 /* * RFC 2385, 2.0 Proposal @@ -2122,6 +2161,7 @@ sysctl_drop(SYSCTL_HANDLER_ARGS) return (error); break; #endif +#ifdef INET case AF_INET: fin = (struct sockaddr_in *)&addrs[0]; lin = (struct sockaddr_in *)&addrs[1]; @@ -2129,6 +2169,7 @@ sysctl_drop(SYSCTL_HANDLER_ARGS) lin->sin_len != sizeof(struct sockaddr_in)) return (EINVAL); break; +#endif default: return (EINVAL); } @@ -2141,10 +2182,12 @@ sysctl_drop(SYSCTL_HANDLER_ARGS) NULL); break; #endif +#ifdef INET case AF_INET: inp = in_pcblookup_hash(&V_tcbinfo, fin->sin_addr, fin->sin_port, lin->sin_addr, lin->sin_port, 0, NULL); break; +#endif } if (inp != NULL) { INP_WLOCK(inp); @@ -2272,6 +2315,7 @@ tcp_log_addr(struct in_conninfo *inc, st sp = s + strlen(s); sprintf(sp, "]:%i", ntohs(th->th_dport)); #endif /* INET6 */ +#ifdef INET } else if (ip && th) { inet_ntoa_r(ip->ip_src, sp); sp = s + strlen(s); @@ -2280,6 +2324,7 @@ tcp_log_addr(struct in_conninfo *inc, st inet_ntoa_r(ip->ip_dst, sp); sp = s + strlen(s); sprintf(sp, "]:%i", ntohs(th->th_dport)); +#endif /* INET */ } else { free(s, M_TCPLOG); return (NULL); Modified: head/sys/netinet/tcp_syncache.c ============================================================================== --- head/sys/netinet/tcp_syncache.c Sat Apr 30 11:18:16 2011 (r221249) +++ head/sys/netinet/tcp_syncache.c Sat Apr 30 11:21:29 2011 (r221250) @@ -742,8 +742,12 @@ syncache_socket(struct syncache *sc, str /* Override flowlabel from in6_pcbconnect. */ inp->inp_flow &= ~IPV6_FLOWLABEL_MASK; inp->inp_flow |= sc->sc_flowlabel; - } else + } +#endif /* INET6 */ +#if defined(INET) && defined(INET6) + else #endif +#ifdef INET { struct in_addr laddr; struct sockaddr_in sin; @@ -775,6 +779,7 @@ syncache_socket(struct syncache *sc, str goto abort; } } +#endif /* INET */ tp = intotcpcb(inp); tp->t_state = TCPS_SYN_RECEIVED; tp->iss = sc->sc_iss; @@ -1067,7 +1072,11 @@ _syncache_add(struct in_conninfo *inc, s #ifdef INET6 if (!(inc->inc_flags & INC_ISIPV6)) #endif +#ifdef INET ipopts = (m) ? ip_srcroute(m) : NULL; +#else + ipopts = NULL; +#endif /* * See if we already have an entry for this connection. @@ -1301,8 +1310,8 @@ syncache_respond(struct syncache *sc) { struct ip *ip = NULL; struct mbuf *m; - struct tcphdr *th; - int optlen, error; + struct tcphdr *th = NULL; + int optlen, error = 0; /* Make compiler happy */ u_int16_t hlen, tlen, mssopt; struct tcpopt to; #ifdef INET6 @@ -1350,8 +1359,12 @@ syncache_respond(struct syncache *sc) ip6->ip6_flow |= sc->sc_flowlabel; th = (struct tcphdr *)(ip6 + 1); - } else + } #endif +#if defined(INET6) && defined(INET) + else +#endif +#ifdef INET { ip = mtod(m, struct ip *); ip->ip_v = IPVERSION; @@ -1378,6 +1391,7 @@ syncache_respond(struct syncache *sc) th = (struct tcphdr *)(ip + 1); } +#endif /* INET */ th->th_sport = sc->sc_inc.inc_lport; th->th_dport = sc->sc_inc.inc_fport; @@ -1445,8 +1459,12 @@ syncache_respond(struct syncache *sc) tlen + optlen - hlen); ip6->ip6_hlim = in6_selecthlim(NULL, NULL); error = ip6_output(m, NULL, NULL, 0, NULL, NULL, NULL); - } else + } #endif +#if defined(INET6) && defined(INET) + else +#endif +#ifdef INET { th->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, htons(tlen + optlen - hlen + IPPROTO_TCP)); @@ -1454,6 +1472,7 @@ syncache_respond(struct syncache *sc) m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); error = ip_output(m, sc->sc_ipopts, NULL, 0, NULL, NULL); } +#endif return (error); } Modified: head/sys/netinet/tcp_timewait.c ============================================================================== --- head/sys/netinet/tcp_timewait.c Sat Apr 30 11:18:16 2011 (r221249) +++ head/sys/netinet/tcp_timewait.c Sat Apr 30 11:21:29 2011 (r221250) @@ -57,23 +57,19 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include +#include #include +#include +#include #ifdef INET6 #include -#endif -#include -#ifdef INET6 #include -#endif -#include -#include -#ifdef INET6 #include #include #include #endif -#include #include #include #include @@ -86,7 +82,9 @@ __FBSDID("$FreeBSD$"); #ifdef TCPDEBUG #include #endif +#ifdef INET6 #include +#endif #include @@ -202,15 +200,31 @@ tcp_twstart(struct tcpcb *tp) struct inpcb *inp = tp->t_inpcb; int acknow; struct socket *so; +#ifdef INET6 + int isipv6 = inp->inp_inc.inc_flags & INC_ISIPV6; +#endif INP_INFO_WLOCK_ASSERT(&V_tcbinfo); /* tcp_tw_2msl_reset(). */ INP_WLOCK_ASSERT(inp); - if (V_nolocaltimewait && in_localip(inp->inp_faddr)) { - tp = tcp_close(tp); - if (tp != NULL) - INP_WUNLOCK(inp); - return; + if (V_nolocaltimewait) { + int error = 0; +#ifdef INET6 + if (isipv6) + error = in6_localaddr(&inp->in6p_faddr); +#endif +#if defined(INET6) && defined(INET) + else +#endif +#ifdef INET + error = in_localip(inp->inp_faddr); +#endif + if (error) { + tp = tcp_close(tp); + if (tp != NULL) + INP_WUNLOCK(inp); + return; + } } tw = uma_zalloc(V_tcptw_zone, M_NOWAIT); @@ -488,11 +502,15 @@ int tcp_twrespond(struct tcptw *tw, int flags) { struct inpcb *inp = tw->tw_inpcb; - struct tcphdr *th; +#if defined(INET6) || defined(INET) + struct tcphdr *th = NULL; +#endif struct mbuf *m; +#ifdef INET struct ip *ip = NULL; +#endif u_int hdrlen, optlen; - int error; + int error = 0; /* Keep compiler happy */ struct tcpopt to; #ifdef INET6 struct ip6_hdr *ip6 = NULL; @@ -516,14 +534,19 @@ tcp_twrespond(struct tcptw *tw, int flag ip6 = mtod(m, struct ip6_hdr *); th = (struct tcphdr *)(ip6 + 1); tcpip_fillheaders(inp, ip6, th); - } else + } #endif +#if defined(INET6) && defined(INET) + else +#endif +#ifdef INET { hdrlen = sizeof(struct tcpiphdr); ip = mtod(m, struct ip *); th = (struct tcphdr *)(ip + 1); tcpip_fillheaders(inp, ip, th); } +#endif to.to_flags = 0; /* @@ -555,8 +578,12 @@ tcp_twrespond(struct tcptw *tw, int flag ip6->ip6_hlim = in6_selecthlim(inp, NULL); error = ip6_output(m, inp->in6p_outputopts, NULL, (tw->tw_so_options & SO_DONTROUTE), NULL, NULL, inp); - } else + } #endif +#if defined(INET6) && defined(INET) + else +#endif +#ifdef INET { th->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, htons(sizeof(struct tcphdr) + optlen + IPPROTO_TCP)); @@ -569,6 +596,7 @@ tcp_twrespond(struct tcptw *tw, int flag ((tw->tw_so_options & SO_DONTROUTE) ? IP_ROUTETOIF : 0), NULL, inp); } +#endif if (flags & TH_ACK) TCPSTAT_INC(tcps_sndacks); else Modified: head/sys/netinet/tcp_usrreq.c ============================================================================== --- head/sys/netinet/tcp_usrreq.c Sat Apr 30 11:18:16 2011 (r221249) +++ head/sys/netinet/tcp_usrreq.c Sat Apr 30 11:21:29 2011 (r221250) @@ -64,17 +64,13 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#ifdef INET6 *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***