From owner-freebsd-current@FreeBSD.ORG Mon Jan 19 23:12:27 2015 Return-Path: Delivered-To: freebsd-current@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 D1FD7FBD for ; Mon, 19 Jan 2015 23:12:27 +0000 (UTC) Received: from mail-la0-x22a.google.com (mail-la0-x22a.google.com [IPv6:2a00:1450:4010:c03::22a]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 54B198F9 for ; Mon, 19 Jan 2015 23:12:27 +0000 (UTC) Received: by mail-la0-f42.google.com with SMTP id ms9so9158045lab.1 for ; Mon, 19 Jan 2015 15:12:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=MELkzZp6s7sP/8SZd0zX8HxWCSzRhYJhsGyzUJqA41c=; b=a4CoR5bc0Ox94Ufq/HKI8SWHFq/GU8K5RMhPiscKZrEpCgi5xWvgi/eOeQSYZinUJn i+AqjHg+2krs6wQP04p+f5EXQVfSEee1bf3tPXnMGW06n9ALNKOeTm/FiTRI59MxkAso rJ7/uVjvACTai3/UKxR4kSPor3zOxL5GXvfN2aTQuAoU4hDm27ZCWzK+TJpnA2vhMz7q s9+IAdZq6GXTUUxZZV/P2U+5yImOJ3GnraTJW0ssyLOonhl3E/zw6mmaFvXMkI++vmI8 665V1X3VU2/CijeI46sZfOrveGtJ3h8ZXfnLUYsMOdiA+gSNi3gmEekMo6za/GVk56vy aVAg== MIME-Version: 1.0 X-Received: by 10.152.207.37 with SMTP id lt5mr34655940lac.66.1421709145225; Mon, 19 Jan 2015 15:12:25 -0800 (PST) Sender: davide.italiano@gmail.com Received: by 10.25.155.4 with HTTP; Mon, 19 Jan 2015 15:12:25 -0800 (PST) Date: Mon, 19 Jan 2015 15:12:25 -0800 X-Google-Sender-Auth: tT5QggOUL-53m_Pc_p50GU-1-yo Message-ID: Subject: [PATCH] nmbclusters should be always positive From: Davide Italiano To: freebsd-current Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Jan 2015 23:12:27 -0000 Currently, the following is allowed in FreeBSD: root@rabbit1:/home/davide/udp-clt # sysctl kern.ipc.nmbclusters=2147483647 kern.ipc.nmbclusters: 2036598 -> -2147483648 The following is an attempt of fixing. I also think nmbcluster should actually be u_int and not it, but this is a discussion for another day, maybe. diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c index 7ab6509..15b38a9 100644 --- a/sys/kern/kern_mbuf.c +++ b/sys/kern/kern_mbuf.c @@ -162,7 +162,7 @@ sysctl_nmbclusters(SYSCTL_HANDLER_ARGS) newnmbclusters = nmbclusters; error = sysctl_handle_int(oidp, &newnmbclusters, 0, req); if (error == 0 && req->newptr && newnmbclusters != nmbclusters) { - if (newnmbclusters > nmbclusters && + if (newnmbclusters > 0 && newnmbclusters > nmbclusters && nmbufs >= nmbclusters + nmbjumbop + nmbjumbo9 + nmbjumbo16) { nmbclusters = newnmbclusters; nmbclusters = uma_zone_set_max(zone_clust, nmbclusters); -- Davide "There are no solved problems; there are only problems that are more or less solved" -- Henri Poincare