From owner-svn-src-all@FreeBSD.ORG Thu Jul 19 09:33:00 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B1C481065672; Thu, 19 Jul 2012 09:33:00 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 993998FC12; Thu, 19 Jul 2012 09:33:00 +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 q6J9X0Kw064248; Thu, 19 Jul 2012 09:33:00 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q6J9X0k0064240; Thu, 19 Jul 2012 09:33:00 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201207190933.q6J9X0k0064240@svn.freebsd.org> From: Michael Tuexen Date: Thu, 19 Jul 2012 09:33:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238613 - in stable/9: sys/netinet sys/netinet6 usr.bin/netstat X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jul 2012 09:33:00 -0000 Author: tuexen Date: Thu Jul 19 09:32:59 2012 New Revision: 238613 URL: http://svn.freebsd.org/changeset/base/238613 Log: MFC r238501, r 238514: Changes which improve compilation if neither INET nor INET6 is defined. Allow netstat to be build if INET is not defined in the kernel. Thanks to Garrett Cooper for reporting the issue. This also fixes a bug where netstat doesn't work correctly for SCTP on INET only (no INET6) kernels. Approved by: re@ Modified: stable/9/sys/netinet/sctp_asconf.c stable/9/sys/netinet/sctp_output.c stable/9/sys/netinet/sctp_uio.h stable/9/sys/netinet/sctp_usrreq.c stable/9/sys/netinet6/sctp6_usrreq.c stable/9/usr.bin/netstat/Makefile stable/9/usr.bin/netstat/sctp.c Directory Properties: stable/9/sys/ (props changed) stable/9/usr.bin/ (props changed) stable/9/usr.bin/netstat/ (props changed) Modified: stable/9/sys/netinet/sctp_asconf.c ============================================================================== --- stable/9/sys/netinet/sctp_asconf.c Thu Jul 19 08:56:30 2012 (r238612) +++ stable/9/sys/netinet/sctp_asconf.c Thu Jul 19 09:32:59 2012 (r238613) @@ -2806,13 +2806,14 @@ sctp_process_initack_addresses(struct sc struct sctp_paramhdr tmp_param, *ph; uint16_t plen, ptype; struct sctp_ifa *sctp_ifa; - struct sctp_ipv6addr_param addr_store; #ifdef INET6 + struct sctp_ipv6addr_param addr6_store; struct sockaddr_in6 sin6; #endif #ifdef INET + struct sctp_ipv4addr_param addr4_store; struct sockaddr_in sin; #endif @@ -2861,7 +2862,7 @@ sctp_process_initack_addresses(struct sc a6p = (struct sctp_ipv6addr_param *) sctp_m_getptr(m, offset, sizeof(struct sctp_ipv6addr_param), - (uint8_t *) & addr_store); + (uint8_t *) & addr6_store); if (plen != sizeof(struct sctp_ipv6addr_param) || a6p == NULL) { return; @@ -2880,7 +2881,7 @@ sctp_process_initack_addresses(struct sc /* get the entire IPv4 address param */ a4p = (struct sctp_ipv4addr_param *)sctp_m_getptr(m, offset, sizeof(struct sctp_ipv4addr_param), - (uint8_t *) & addr_store); + (uint8_t *) & addr4_store); if (plen != sizeof(struct sctp_ipv4addr_param) || a4p == NULL) { return; @@ -2958,16 +2959,17 @@ sctp_addr_in_initack(struct mbuf *m, uin { struct sctp_paramhdr tmp_param, *ph; uint16_t plen, ptype; - struct sctp_ipv6addr_param addr_store; #ifdef INET struct sockaddr_in *sin; struct sctp_ipv4addr_param *a4p; + struct sctp_ipv6addr_param addr4_store; #endif #ifdef INET6 struct sockaddr_in6 *sin6; struct sctp_ipv6addr_param *a6p; + struct sctp_ipv6addr_param addr6_store; struct sockaddr_in6 sin6_tmp; #endif @@ -3013,7 +3015,7 @@ sctp_addr_in_initack(struct mbuf *m, uin a6p = (struct sctp_ipv6addr_param *) sctp_m_getptr(m, offset, sizeof(struct sctp_ipv6addr_param), - (uint8_t *) & addr_store); + (uint8_t *) & addr6_store); if (a6p == NULL) { return (0); } @@ -3043,7 +3045,7 @@ sctp_addr_in_initack(struct mbuf *m, uin a4p = (struct sctp_ipv4addr_param *) sctp_m_getptr(m, offset, sizeof(struct sctp_ipv4addr_param), - (uint8_t *) & addr_store); + (uint8_t *) & addr4_store); if (a4p == NULL) { return (0); } Modified: stable/9/sys/netinet/sctp_output.c ============================================================================== --- stable/9/sys/netinet/sctp_output.c Thu Jul 19 08:56:30 2012 (r238612) +++ stable/9/sys/netinet/sctp_output.c Thu Jul 19 09:32:59 2012 (r238613) @@ -3799,6 +3799,7 @@ sctp_get_ect(struct sctp_tcb *stcb) } } +#if defined(INET) || defined(INET6) static void sctp_handle_no_route(struct sctp_tcb *stcb, struct sctp_nets *net, @@ -3843,6 +3844,8 @@ sctp_handle_no_route(struct sctp_tcb *st } } +#endif + static int sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, struct sctp_tcb *stcb, /* may be NULL */ @@ -3882,14 +3885,18 @@ sctp_lowlevel_chunk_output(struct sctp_i * interface and smallest_mtu size as well. */ /* Will need ifdefs around this */ - struct mbuf *o_pak; struct mbuf *newm; struct sctphdr *sctphdr; int packet_length; int ret; uint32_t vrf_id; + +#if defined(INET) || defined(INET6) + struct mbuf *o_pak; sctp_route_t *ro = NULL; struct udphdr *udp = NULL; + +#endif uint8_t tos_value; #if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING) Modified: stable/9/sys/netinet/sctp_uio.h ============================================================================== --- stable/9/sys/netinet/sctp_uio.h Thu Jul 19 08:56:30 2012 (r238612) +++ stable/9/sys/netinet/sctp_uio.h Thu Jul 19 09:32:59 2012 (r238613) @@ -1124,10 +1124,10 @@ struct sctpstat { #define SCTP_STAT_DECR_GAUGE32(_x) SCTP_STAT_DECR(_x) union sctp_sockstore { -#if defined(INET) || !defined(_KERNEL) +#if defined(INET) struct sockaddr_in sin; #endif -#if defined(INET6) || !defined(_KERNEL) +#if defined(INET6) struct sockaddr_in6 sin6; #endif struct sockaddr sa; Modified: stable/9/sys/netinet/sctp_usrreq.c ============================================================================== --- stable/9/sys/netinet/sctp_usrreq.c Thu Jul 19 08:56:30 2012 (r238612) +++ stable/9/sys/netinet/sctp_usrreq.c Thu Jul 19 09:32:59 2012 (r238613) @@ -5258,7 +5258,6 @@ sctp_setopt(struct socket *so, int optna case SCTP_BINDX_ADD_ADDR: { struct sctp_getaddresses *addrs; - size_t sz; struct thread *td; td = (struct thread *)p; @@ -5266,8 +5265,7 @@ sctp_setopt(struct socket *so, int optna optsize); #ifdef INET if (addrs->addr->sa_family == AF_INET) { - sz = sizeof(struct sctp_getaddresses) - sizeof(struct sockaddr) + sizeof(struct sockaddr_in); - if (optsize < sz) { + if (optsize < sizeof(struct sctp_getaddresses) - sizeof(struct sockaddr) + sizeof(struct sockaddr_in)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; break; @@ -5280,8 +5278,7 @@ sctp_setopt(struct socket *so, int optna #endif #ifdef INET6 if (addrs->addr->sa_family == AF_INET6) { - sz = sizeof(struct sctp_getaddresses) - sizeof(struct sockaddr) + sizeof(struct sockaddr_in6); - if (optsize < sz) { + if (optsize < sizeof(struct sctp_getaddresses) - sizeof(struct sockaddr) + sizeof(struct sockaddr_in6)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; break; @@ -5305,7 +5302,6 @@ sctp_setopt(struct socket *so, int optna case SCTP_BINDX_REM_ADDR: { struct sctp_getaddresses *addrs; - size_t sz; struct thread *td; td = (struct thread *)p; @@ -5313,8 +5309,7 @@ sctp_setopt(struct socket *so, int optna SCTP_CHECK_AND_CAST(addrs, optval, struct sctp_getaddresses, optsize); #ifdef INET if (addrs->addr->sa_family == AF_INET) { - sz = sizeof(struct sctp_getaddresses) - sizeof(struct sockaddr) + sizeof(struct sockaddr_in); - if (optsize < sz) { + if (optsize < sizeof(struct sctp_getaddresses) - sizeof(struct sockaddr) + sizeof(struct sockaddr_in)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; break; @@ -5327,8 +5322,7 @@ sctp_setopt(struct socket *so, int optna #endif #ifdef INET6 if (addrs->addr->sa_family == AF_INET6) { - sz = sizeof(struct sctp_getaddresses) - sizeof(struct sockaddr) + sizeof(struct sockaddr_in6); - if (optsize < sz) { + if (optsize < sizeof(struct sctp_getaddresses) - sizeof(struct sockaddr) + sizeof(struct sockaddr_in6)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; break; Modified: stable/9/sys/netinet6/sctp6_usrreq.c ============================================================================== --- stable/9/sys/netinet6/sctp6_usrreq.c Thu Jul 19 08:56:30 2012 (r238612) +++ stable/9/sys/netinet6/sctp6_usrreq.c Thu Jul 19 09:32:59 2012 (r238613) @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include +#ifdef INET6 #include #include #include @@ -1354,3 +1355,5 @@ struct pr_usrreqs sctp6_usrreqs = { .pru_sosend = sctp_sosend, .pru_soreceive = sctp_soreceive }; + +#endif Modified: stable/9/usr.bin/netstat/Makefile ============================================================================== --- stable/9/usr.bin/netstat/Makefile Thu Jul 19 08:56:30 2012 (r238612) +++ stable/9/usr.bin/netstat/Makefile Thu Jul 19 09:32:59 2012 (r238613) @@ -13,6 +13,10 @@ CFLAGS+=-fno-strict-aliasing CFLAGS+=-DIPSEC CFLAGS+=-DSCTP +.if ${MK_INET_SUPPORT} != "no" +CFLAGS+=-DINET +.endif + .if ${MK_INET6_SUPPORT} != "no" SRCS+= inet6.c CFLAGS+=-DINET6 Modified: stable/9/usr.bin/netstat/sctp.c ============================================================================== --- stable/9/usr.bin/netstat/sctp.c Thu Jul 19 08:56:30 2012 (r238612) +++ stable/9/usr.bin/netstat/sctp.c Thu Jul 19 09:32:59 2012 (r238613) @@ -107,6 +107,7 @@ struct xraddr_entry { * If numeric_addr has been supplied, give * numeric value, otherwise try for symbolic name. */ +#ifdef INET static char * inetname(struct in_addr *inp) { @@ -146,6 +147,7 @@ inetname(struct in_addr *inp) } return (line); } +#endif #ifdef INET6 static char ntop_buf[INET6_ADDRSTRLEN]; @@ -197,9 +199,11 @@ sctp_print_address(union sctp_sockstore int width; switch (address->sa.sa_family) { +#ifdef INET case AF_INET: sprintf(line, "%.*s.", Wflag ? 39 : 16, inetname(&address->sin.sin_addr)); break; +#endif #ifdef INET6 case AF_INET6: sprintf(line, "%.*s.", Wflag ? 39 : 16, inet6name(&address->sin6.sin6_addr));