On 07/14/13 23:50, Philip Guenther wrote:
> On Sun, Jul 14, 2013 at 12:54 AM, Rafael Neves <rafaelne...@gmail.com> wrote:
>> The patch below fixes a bug on sysctl(8) introduced by revision 1.191
>> of sysctl.c. After rev1.191, `sysctl vfs' mangles information about
>> filesystems (mounted instances of ffs are attributed to nfs, of nfs
>> are atrributed to mfs, and so on). As a consequence, `sysctl
>> vfs.mounts.nfs' reports 0 mounted instances on a diskless(8) setup,
>> thus /etc/rc script (lines 335 to 342) doesn't add pf rules that allow
>> NFS, and system hangs when it enables pf.
> 
> First off: thank you for (a) noticing this, and (b) tracking down the 
> mismatch.
> 
> ...
>> --- sysctl.c    9 Jun 2013 12:54:38 -0000       1.192
>> +++ sysctl.c    14 Jul 2013 07:09:28 -0000
>> @@ -1175,8 +1175,8 @@ vfsinit(void)
>>
>>         vfsname[0].ctl_name = "mounts";
>>         vfsname[0].ctl_type = CTLTYPE_NODE;
>> -       vfsvars[0].list = vfsname + 1;
>> -       vfsvars[0].size = maxtypenum - 1;
>> +       vfsvars[0].list = vfsname;
>> +       vfsvars[0].size = maxtypenum;
> 
> Soooooo close...
> 
> While this fixes the observed problem, it's not 100% correct.  The
> glitch is that it fails a negative test: the command
>      sysctl vfs.mounts.mounts
> should fail with the error
>      sysctl: third level name mounts in vfs.mounts.mounts is invalid
> 
> but with your patch it silently succeeds.  The vfsname list is offset
> by one in vfsvars[0].list to prevent that, so the fix that avoids the
> unwanted match against vfsname[0] is to keep the offset, but undo it
> in the lookup:
> 
> --- sysctl.c    9 Jun 2013 12:54:38 -0000       1.192
> +++ sysctl.c    15 Jul 2013 03:43:27 -0000
> @@ -1200,7 +1200,7 @@ sysctl_vfsgen(char *string, char **bufpp
> 
>         mib[1] = VFS_GENERIC;
>         mib[2] = VFS_CONF;
> -       mib[3] = indx;
> +       mib[3] = indx + 1;
>         size = sizeof vfc;
>         if (sysctl(mib, 4, &vfc, &size, (void *)0, (size_t)0) < 0) {
>                 if (errno != EOPNOTSUPP)
> 
> 
> That make sense?

Sorry, I previously replied to the wrong list...

Your patch produces correct results for my previous report.  Without repeating
that email, here's the current summary:

172>diff -wbu before after
--- before      Mon Jul 15 05:53:23 2013
+++ after       Mon Jul 15 05:53:58 2013
@@ -17,9 +17,9 @@
 a8v:/pub2 on /a8v/pub2 type nfs (nodev, nosuid, read-only, v3, udp, timeo=100,
retrans=101)
 nas2:/work on /nas2/work type nfs (nodev, nosuid, v3, udp, timeo=100, 
retrans=101)
 nas2:/media on /nas2/media type nfs (nodev, nosuid, v3, udp, rdirsize=4096,
timeo=100, retrans=101)
-vfs.mounts.nfs has 12 mounted instances
-vfs.mounts.mfs has 6 mounted instances
-vfs.mounts.msdos has 1 mounted instance
+vfs.mounts.ffs has 12 mounted instances
+vfs.mounts.nfs has 6 mounted instances
+vfs.mounts.mfs has 1 mounted instance
 vfs.ffs.doclusterread=1
 vfs.ffs.doclusterwrite=1
 vfs.ffs.doreallocblks=1

Thanks.

Reply via email to