From owner-svn-src-head@FreeBSD.ORG Tue Apr 29 19:48:12 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2B145352; Tue, 29 Apr 2014 19:48:12 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F21D61266; Tue, 29 Apr 2014 19:48:11 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3TJmBKg005372; Tue, 29 Apr 2014 19:48:11 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3TJmBcw005371; Tue, 29 Apr 2014 19:48:11 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201404291948.s3TJmBcw005371@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Tue, 29 Apr 2014 19:48:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r265104 - head/sys/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 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: Tue, 29 Apr 2014 19:48:12 -0000 Author: melifaro Date: Tue Apr 29 19:48:11 2014 New Revision: 265104 URL: http://svnweb.freebsd.org/changeset/base/265104 Log: Partially revert r265019 - allocating 512 bytes on stack can be too much for architectures like ARM. Always use rounded malloc instead. Discussed with: jmallett MFC after: 4 weeks Modified: head/sys/net/rtsock.c Modified: head/sys/net/rtsock.c ============================================================================== --- head/sys/net/rtsock.c Tue Apr 29 19:14:42 2014 (r265103) +++ head/sys/net/rtsock.c Tue Apr 29 19:48:11 2014 (r265104) @@ -531,7 +531,6 @@ route_output(struct mbuf *m, struct sock sa_family_t saf = AF_UNSPEC; struct rawcb *rp = NULL; struct walkarg w; - char msgbuf[512]; fibnum = so->so_fibnum; @@ -548,20 +547,12 @@ route_output(struct mbuf *m, struct sock /* * Most of current messages are in range 200-240 bytes, - * minimize possible failures by using on-stack buffer - * which should fit for most messages. - * However, use stable memory if we need to handle - * something large. + * minimize possible re-allocation on reply using larger size + * buffer aligned on 1k boundaty. */ - if (len < sizeof(msgbuf)) { - alloc_len = sizeof(msgbuf); - rtm = (struct rt_msghdr *)msgbuf; - } else { - alloc_len = roundup2(len, 1024); - rtm = malloc(alloc_len, M_TEMP, M_NOWAIT); - if (rtm == NULL) - senderr(ENOBUFS); - } + alloc_len = roundup2(len, 1024); + if ((rtm = malloc(alloc_len, M_TEMP, M_NOWAIT)) == NULL) + senderr(ENOBUFS); m_copydata(m, 0, len, (caddr_t)rtm); bzero(&info, sizeof(info)); @@ -569,8 +560,7 @@ route_output(struct mbuf *m, struct sock if (rtm->rtm_version != RTM_VERSION) { /* Do not touch message since format is unknown */ - if ((char *)rtm != msgbuf) - free(rtm, M_TEMP); + free(rtm, M_TEMP); rtm = NULL; senderr(EPROTONOSUPPORT); } @@ -861,7 +851,7 @@ flush: */ if ((so->so_options & SO_USELOOPBACK) == 0) { if (V_route_cb.any_count <= 1) { - if (rtm != NULL && (char *)rtm != msgbuf) + if (rtm != NULL) free(rtm, M_TEMP); m_freem(m); return (error); @@ -899,8 +889,7 @@ flush: } else if (m->m_pkthdr.len > rtm->rtm_msglen) m_adj(m, rtm->rtm_msglen - m->m_pkthdr.len); - if ((char *)rtm != msgbuf) - free(rtm, M_TEMP); + free(rtm, M_TEMP); } if (m != NULL) { M_SETFIB(m, fibnum);