Hi tech@,

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.

For example, on -current I get (dmesg at end):
output of mount(8):
        /dev/wd0a on / type ffs (local)
        /dev/wd0k on /home type ffs (local, nodev, nosuid)
        /dev/wd0d on /tmp type ffs (local, nodev, nosuid)
        /dev/wd0f on /usr type ffs (local, nodev)
        /dev/wd0g on /usr/X11R6 type ffs (local, nodev)
        /dev/wd0h on /usr/local type ffs (local, nodev)
        /dev/wd0j on /usr/obj type ffs (local, nodev, nosuid)
        /dev/wd0e on /var type ffs (local, nodev, nosuid)
        /dev/sd1i on /usr/src type ffs (local, nodev, nosuid, softdep)
        /dev/sd2a on /mnt2 type ext2fs (local)

output of sysctl(8) (`sysctl vfs'):
        vfs.mounts.nfs has 9 mounted instances
        vfs.ffs.doclusterread=1
        vfs.ffs.doclusterwrite=1
        vfs.ffs.doreallocblks=1
        vfs.ffs.doasyncfree=1
        vfs.ffs.max_softdeps=23704
        vfs.ffs.sd_tickdelay=2
        vfs.ffs.sd_worklist_push=0
        vfs.ffs.sd_blk_limit_push=0
        vfs.ffs.sd_ino_limit_push=0
        vfs.ffs.sd_blk_limit_hit=0
        vfs.ffs.sd_ino_limit_hit=0
        vfs.ffs.sd_sync_limit_hit=0
        vfs.ffs.sd_indir_blk_ptrs=0
        vfs.ffs.sd_inode_bitmap=37
        vfs.ffs.sd_direct_blk_ptrs=26
        vfs.ffs.sd_dir_entry=14
        vfs.ffs.dirhash_dirsize=2560
        vfs.ffs.dirhash_maxmem=2097152
        vfs.ffs.dirhash_mem=325453
        vfs.nfs.iothreads=-1


The problem is that sysctl(8) expects that vfsvars->list[] and
filesystem indexes match, so findname() result could be used in
sysctl(2) to get filesystem information. Currently, it is not the case
because vfsvars->list[] is filled with:
        vfsvars->list[0].ctl_name = ffs
        vfsvars->list[1].ctl_name = nfs
        vfsvars->list[2].ctl_name = mfs
        vfsvars->list[3].ctl_name = msdos
        vfsvars->list[4].ctl_name = NULL
        vfsvars->list[5].ctl_name = ntfs
        vfsvars->list[6].ctl_name = NULL
        vfsvars->list[7].ctl_name = NULL
        vfsvars->list[8].ctl_name = NULL
        vfsvars->list[9].ctl_name = NULL
        vfsvars->list[10].ctl_name = NULL
        vfsvars->list[11].ctl_name = procfs
        vfsvars->list[12].ctl_name = udf
        vfsvars->list[13].ctl_name = cd9660
        vfsvars->list[14].ctl_name = NULL
        vfsvars->list[15].ctl_name = NULL
        vfsvars->list[16].ctl_name = ext2fs


The patch completes the off-by-one adjust needed to access the last
filesystem and works with FUSE enabled. After the patch I get:
        vfs.mounts.ffs has 9 mounted instances
        vfs.mounts.ext2fs has 1 mounted instance
        vfs.ffs.doclusterread=1
        vfs.ffs.doclusterwrite=1
        vfs.ffs.doreallocblks=1
        vfs.ffs.doasyncfree=1
        vfs.ffs.max_softdeps=23704
        vfs.ffs.sd_tickdelay=2
        vfs.ffs.sd_worklist_push=0
        vfs.ffs.sd_blk_limit_push=0
        vfs.ffs.sd_ino_limit_push=0
        vfs.ffs.sd_blk_limit_hit=0
        vfs.ffs.sd_ino_limit_hit=0
        vfs.ffs.sd_sync_limit_hit=0
        vfs.ffs.sd_indir_blk_ptrs=0
        vfs.ffs.sd_inode_bitmap=37
        vfs.ffs.sd_direct_blk_ptrs=26
        vfs.ffs.sd_dir_entry=14
        vfs.ffs.dirhash_dirsize=2560
        vfs.ffs.dirhash_maxmem=2097152
        vfs.ffs.dirhash_mem=325453
        vfs.nfs.iothreads=-1

Thanks in advance for any comments.

Regards
Rafael Neves

dmesg:
OpenBSD 5.3-current (GENERIC) #15: Thu Jul  4 11:52:29 MDT 2013
    dera...@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC
cpu0: Intel(R) Pentium(R) 4 CPU 1.80GHz ("GenuineIntel" 686-class) 1.81 GHz
cpu0: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PERF
real mem  = 771223552 (735MB)
avail mem = 747171840 (712MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 03/10/03, BIOS32 rev. 0 @
0xfdad0, SMBIOS rev. 2.3 @ 0xf0630 (19 entries)
bios0: vendor American Megatrends Inc. version "07.00T" date 04/02/01
bios0: ECS P4VMM2
acpi0 at bios0: rev 0
acpi0: sleep states S0 S1 S4 S5
acpi0: tables DSDT FACP
acpi0: wakeup devices UAR1(S4) USB1(S4) USB2(S4) USB3(S4) EHCI(S4)
AC9_(S4) MC9_(S4) ILAN(S4) PCI0(S4) SLPB(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpiprt0 at acpi0: bus 0 (PCI0)
acpicpu0 at acpi0
acpipwrres0 at acpi0: URP1
acpipwrres1 at acpi0: URP2
acpipwrres2 at acpi0: FDDP
acpipwrres3 at acpi0: LPTP
acpibtn0 at acpi0: PWRB
acpibtn1 at acpi0: SLPB
bios0: ROM list: 0xc0000/0xc000 0xcc000/0x4000!
cpu0 at mainbus0: (uniprocessor)
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 "VIA VT8751 PCI" rev 0x00
viaagp0 at pchb0: v2
agp0 at viaagp0: aperture at 0xe0000000, size 0x10000000
ppb0 at pci0 dev 1 function 0 "VIA VT8633 AGP" rev 0x00
pci1 at ppb0 bus 1
vga1 at pci1 dev 0 function 0 "S3 ProSavage DDR-K" rev 0x00
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
uhci0 at pci0 dev 16 function 0 "VIA VT83C572 USB" rev 0x80: irq 11
uhci1 at pci0 dev 16 function 1 "VIA VT83C572 USB" rev 0x80: irq 5
uhci2 at pci0 dev 16 function 2 "VIA VT83C572 USB" rev 0x80: irq 12
ehci0 at pci0 dev 16 function 3 "VIA VT6202 USB" rev 0x82: irq 10
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "VIA EHCI root hub" rev 2.00/1.00 addr 1
viapm0 at pci0 dev 17 function 0 "VIA VT8235 ISA" rev 0x00: SMI
iic0 at viapm0
spdmem0 at iic0 addr 0x50: 1GB DDR SDRAM non-parity PC3200CL3.0
spdmem1 at iic0 addr 0x51: 256MB DDR SDRAM non-parity PC3200CL3.0
pciide0 at pci0 dev 17 function 1 "VIA VT82C571 IDE" rev 0x06: ATA133,
channel 0 configured to compatibility, channel 1 configured to
compatibility
wd0 at pciide0 channel 0 drive 0: <SAMSUNG SP0411N>
wd0: 16-sector PIO, LBA48, 38204MB, 78242976 sectors
atapiscsi0 at pciide0 channel 0 drive 1
scsibus0 at atapiscsi0: 2 targets
cd0 at scsibus0 targ 0 lun 0: <HL-DT-ST, CD-ROM GCR-8523B, 1.00> ATAPI
5/cdrom removable
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 5
cd0(pciide0:0:1): using PIO mode 4, DMA mode 2
pciide0: channel 1 disabled (no drives)
auvia0 at pci0 dev 17 function 5 "VIA VT8233 AC97" rev 0x50: irq 12
ac97: codec id 0x56494161 (VIA Technologies VT1612A)
ac97: codec features headphone, 18 bit DAC, 18 bit ADC, KS Waves 3D
audio0 at auvia0
vr0 at pci0 dev 18 function 0 "VIA RhineII-2" rev 0x74: irq 11,
address 00:0d:87:11:e8:f4
ukphy0 at vr0 phy 1: Generic IEEE 802.3u media interface, rev. 8: OUI
0x004063, model 0x0032
usb1 at uhci0: USB revision 1.0
uhub1 at usb1 "VIA UHCI root hub" rev 1.00/1.00 addr 1
usb2 at uhci1: USB revision 1.0
uhub2 at usb2 "VIA UHCI root hub" rev 1.00/1.00 addr 1
usb3 at uhci2: USB revision 1.0
uhub3 at usb3 "VIA UHCI root hub" rev 1.00/1.00 addr 1
isa0 at mainbus0
isadma0 at isa0
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
com0: console
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
lpt0 at isa0 port 0x378/4 irq 7
it0 at isa0 port 0x2e/2: IT8705F rev 2, EC port 0x290
npx0 at isa0 port 0xf0/16: reported by CPUID; using exception 16
fdc0 at isa0 port 0x3f0/6 irq 6 drq 2
mtrr: Pentium Pro MTRR support
umass0 at uhub0 port 2 configuration 1 interface 0 "JMicron Samsung S2
Portable" rev 2.00/0.00 addr 2
umass0: using SCSI over Bulk-Only
scsibus1 at umass0: 2 targets, initiator 0
sd0 at scsibus1 targ 1 lun 0: <Samsung, S2 Portable, > SCSI2 0/direct
fixed serial.04e81f05000002CE09CE
sd0: 476940MB, 512 bytes/sector, 976773168 sectors
vscsi0 at root
scsibus2 at vscsi0: 256 targets
softraid0 at root
scsibus3 at softraid0: 256 targets
root on wd0a (c329692700b15a23.a) swap on wd0b dump on wd0b
wd0a: aborted command, interface CRC error reading fsbn 128 of 128-143
(wd0 bn 42662016; cn 2655 tn 149 sn 54), retrying
wd0: transfer error, downgrading to Ultra-DMA mode 4
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 4
cd0(pciide0:0:1): using PIO mode 4, DMA mode 2
wd0a: aborted command, interface CRC error reading fsbn 128 of 128-143
(wd0 bn 42662016; cn 2655 tn 149 sn 54), retrying
wd0: soft error (corrected)
wd0: transfer error, downgrading to Ultra-DMA mode 3
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 3
cd0(pciide0:0:1): using PIO mode 4, DMA mode 2
wd0e: aborted command, interface CRC error writing fsbn 1665280 of
1665280-1665311 (wd0 bn 48662144; cn 3029 tn 19 sn 62), retrying
wd0: soft error (corrected)
sd1 at scsibus3 targ 1 lun 0: <OPENBSD, SR CRYPTO, 005> SCSI2 0/direct fixed
sd1: 51205MB, 512 bytes/sector, 104869297 sectors
softraid0: volume sd1 is roaming, it used to be sd2, updating metadata
softraid0: roaming device sd1a -> sd0a
umass1 at uhub0 port 4 configuration 1 interface 0 " USB DISK 2.0" rev
2.00/1.00 addr 3
umass1: using SCSI over Bulk-Only
scsibus4 at umass1: 2 targets, initiator 0
sd2 at scsibus4 targ 1 lun 0: <, USB DISK 2.0, PMAP> SCSI2 0/direct
removable serial.13fe41002C36A0FFFF48
sd2: 3769MB, 512 bytes/sector, 7719360 sectors



Patch:

Index: sysctl.c
===================================================================
RCS file: /cvs/src/sbin/sysctl/sysctl.c,v
retrieving revision 1.192
diff -u -p -r1.192 sysctl.c
--- 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;

        secondlevel[CTL_VFS].list = vfsname;
        secondlevel[CTL_VFS].size = maxtypenum;

Reply via email to