[PATCH] nmbclusters should be always positive
    Davide Italiano 
    davide at freebsd.org
       
    Mon Jan 19 23:12:27 UTC 2015
    
    
  
Currently, the following is allowed in FreeBSD:
root at 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
    
    
More information about the freebsd-current
mailing list