From owner-freebsd-net@FreeBSD.ORG Mon Apr 27 05:50:31 2015 Return-Path: Delivered-To: freebsd-net@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 99728F42 for ; Mon, 27 Apr 2015 05:50:31 +0000 (UTC) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.69.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebius.int.ru", Issuer "cell.glebius.int.ru" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 25C8811BB for ; Mon, 27 Apr 2015 05:50:30 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.9/8.14.9) with ESMTP id t3R5oLPs099347 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 27 Apr 2015 08:50:21 +0300 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.9/8.14.9/Submit) id t3R5oKbc099346; Mon, 27 Apr 2015 08:50:20 +0300 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Mon, 27 Apr 2015 08:50:20 +0300 From: Gleb Smirnoff To: John-Mark Gurney Cc: freebsd-net@FreeBSD.org, Poul-Henning Kamp Subject: Re: should m_copyback possibly throw data away? Message-ID: <20150427055020.GC883@FreeBSD.org> References: <20150424181158.GJ37063@funkthat.com> <20150424182308.GK37063@funkthat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150424182308.GK37063@funkthat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Apr 2015 05:50:31 -0000 On Fri, Apr 24, 2015 at 11:23:08AM -0700, John-Mark Gurney wrote: J> John-Mark Gurney wrote this message on Fri, Apr 24, 2015 at 11:11 -0700: J> > I would also be fine w/ documenting this behavior, though I'm sure J> > it'd be surprising to many that you'd have to check to make sure your J> > data was properly copied. J> J> Should have reviewed the m_copyback function before sending this J> email... J> J> It gets worse.. If the m_get to extend it fails, there is no J> notification that your data didn't get copyied into the mbuf.. and no J> warning in the man page that this function is unsafe and may cause J> data loss... J> J> Comments? My suggestion is: 1) make it return int 2) change first check to KASSERT 3) add wait parameter 4) while here change relic of c_caddr_t to const char * Yes, this requires some time. You can also look at OpenBSD/NetBSD. -- Totus tuus, Glebius.