summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2016-06-14 14:40:19 -0500
committerRenato Botelho <renato@netgate.com>2016-06-14 14:40:19 -0500
commit20a32898b6944f9ebcdbb846253d812943036066 (patch)
tree2d3bb1c4acf6d65a66c132d4c59643a3e99dfe34
parent4fdb7654ef71cc3e4f0353cc46f28f652cd35605 (diff)
parenta048478c507785f68e86db1a32431aa36773ee06 (diff)
downloadFreeBSD-src-20a32898b6944f9ebcdbb846253d812943036066.zip
FreeBSD-src-20a32898b6944f9ebcdbb846253d812943036066.tar.gz
Merge remote-tracking branch 'origin/master' into devel-11
-rw-r--r--Makefile85
-rw-r--r--Makefile.inc12
-rw-r--r--Makefile.libcompat2
-rw-r--r--ObsoleteFiles.inc51
-rw-r--r--bin/csh/Makefile2
-rw-r--r--bin/setfacl/file.c6
-rw-r--r--contrib/atf/config.h4
-rw-r--r--contrib/blacklist/bin/blacklistctl.88
-rw-r--r--contrib/blacklist/bin/blacklistctl.c2
-rw-r--r--contrib/blacklist/bin/blacklistd.88
-rw-r--r--contrib/blacklist/bin/blacklistd.conf.58
-rw-r--r--contrib/blacklist/libexec/blacklistd-helper52
-rw-r--r--contrib/bmake/ChangeLog6
-rw-r--r--contrib/bmake/Makefile4
-rw-r--r--contrib/bmake/README51
-rw-r--r--contrib/bmake/config.h.in3
-rwxr-xr-xcontrib/bmake/configure29
-rw-r--r--contrib/bmake/configure.in5
-rw-r--r--contrib/bmake/dir.c115
-rw-r--r--contrib/bmake/hash.h13
-rw-r--r--contrib/bmake/main.c18
-rw-r--r--contrib/bmake/make.h4
-rw-r--r--contrib/bmake/meta.c10
-rw-r--r--contrib/ipfilter/man/ipf.85
-rw-r--r--contrib/jemalloc/ChangeLog11
-rw-r--r--contrib/jemalloc/FREEBSD-diffs4
-rw-r--r--contrib/jemalloc/VERSION2
-rw-r--r--contrib/jemalloc/doc/jemalloc.38
-rw-r--r--contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h4
-rw-r--r--contrib/jemalloc/include/jemalloc/internal/prof.h1
-rw-r--r--contrib/jemalloc/include/jemalloc/jemalloc.h8
-rw-r--r--contrib/jemalloc/src/arena.c2
-rw-r--r--contrib/jemalloc/src/chunk.c88
-rw-r--r--contrib/jemalloc/src/chunk_mmap.c2
-rw-r--r--contrib/jemalloc/src/huge.c10
-rw-r--r--contrib/jemalloc/src/jemalloc.c8
-rw-r--r--contrib/jemalloc/src/nstime.c8
-rw-r--r--contrib/ldns-host/Makefile4
-rw-r--r--contrib/ldns-host/ldns-host.13
-rw-r--r--contrib/ldns-host/ldns-host.c247
-rw-r--r--contrib/libc-vis/unvis.c10
-rw-r--r--contrib/libc-vis/vis.349
-rw-r--r--contrib/libc-vis/vis.c145
-rw-r--r--contrib/libc-vis/vis.h6
-rwxr-xr-xcontrib/netbsd-tests/lib/libc/db/t_db.sh32
-rw-r--r--contrib/netbsd-tests/lib/libc/string/t_memcpy.c7
-rw-r--r--contrib/tcpdump/addrtoname.c10
-rw-r--r--contrib/tcpdump/config.h.in2
-rwxr-xr-xcontrib/tcpdump/configure2
-rw-r--r--contrib/tcpdump/tcpdump.c54
-rw-r--r--crypto/openssh/auth-pam.c6
-rw-r--r--crypto/openssh/auth.c10
-rw-r--r--crypto/openssh/auth1.c9
-rw-r--r--crypto/openssh/auth2.c6
-rw-r--r--crypto/openssh/blacklist.c64
-rw-r--r--crypto/openssh/blacklist_client.h31
-rw-r--r--crypto/openssh/packet.c6
-rw-r--r--crypto/openssh/sshd.c13
-rw-r--r--etc/Makefile2
-rw-r--r--etc/defaults/rc.conf4
-rw-r--r--etc/mtree/BSD.include.dist2
-rw-r--r--etc/nsswitch.conf1
-rw-r--r--etc/rc.d/Makefile2
-rw-r--r--gnu/lib/libsupc++/Version.map2
-rw-r--r--gnu/usr.bin/groff/src/libs/libbib/Makefile.depend1
-rw-r--r--include/Makefile2
-rw-r--r--include/netdb.h1
-rw-r--r--kerberos5/Makefile.inc2
-rw-r--r--kerberos5/tools/asn1_compile/Makefile.depend1
-rw-r--r--lib/Makefile2
-rw-r--r--lib/libc/gen/Symbol.map2
-rw-r--r--lib/libc/gen/getnetgrent.38
-rw-r--r--lib/libc/gen/getnetgrent.c586
-rw-r--r--lib/libc/gen/utime.36
-rw-r--r--lib/libc/resolv/res_init.c25
-rw-r--r--lib/libc/rpc/getnetpath.c2
-rw-r--r--lib/libc/rpc/rpc_callmsg.c8
-rw-r--r--lib/libc/rpc/rpc_prot.c12
-rw-r--r--lib/libc/rpc/rpcb_clnt.c2
-rw-r--r--lib/libc/rpc/rpcb_prot.c10
-rw-r--r--lib/libc/rpc/rpcb_st_xdr.c22
-rw-r--r--lib/libc/stdio/vfscanf.c6
-rw-r--r--lib/libc/sys/pdfork.26
-rw-r--r--lib/libc/sys/utimes.217
-rw-r--r--lib/libcasper/libcasper/libcasper_impl.h4
-rw-r--r--lib/libcasper/libcasper/libcasper_service.c10
-rw-r--r--lib/libcasper/libcasper/libcasper_service.h12
-rw-r--r--lib/libcasper/libcasper/service.c61
-rw-r--r--lib/libcasper/libcasper/zygote.c30
-rw-r--r--lib/libcasper/services/cap_dns/cap_dns.c2
-rw-r--r--lib/libcasper/services/cap_grp/cap_grp.c2
-rw-r--r--lib/libcasper/services/cap_pwd/cap_pwd.c2
-rw-r--r--lib/libcasper/services/cap_random/cap_random.c2
-rw-r--r--lib/libcasper/services/cap_sysctl/cap_sysctl.c2
-rw-r--r--lib/libclang_rt/asan_cxx/Makefile.depend1
-rw-r--r--lib/libclang_rt/profile/Makefile.depend1
-rw-r--r--lib/libclang_rt/safestack/Makefile.depend1
-rw-r--r--lib/libpam/Makefile.inc2
-rw-r--r--lib/libpam/libpam/Makefile2
-rw-r--r--lib/libpam/libpam/security/pam_mod_misc.h17
-rw-r--r--lib/libpam/static_libpam/Makefile.depend1
-rw-r--r--lib/libusb/libusb10.c16
-rw-r--r--lib/libusb/libusb10_desc.c2
-rw-r--r--lib/msun/src/math.h2
-rw-r--r--libexec/Makefile2
-rw-r--r--libexec/fingerd/Makefile.depend2
-rw-r--r--libexec/ftpd/Makefile.depend2
-rw-r--r--libexec/ftpd/blacklist.c2
-rw-r--r--libexec/ftpd/ftpd.c22
-rw-r--r--libexec/rlogind/Makefile.depend2
-rw-r--r--libexec/rshd/Makefile.depend2
-rw-r--r--release/Makefile.ec22
-rw-r--r--release/doc/en_US.ISO8859-1/relnotes/article.xml45
-rwxr-xr-xrelease/scripts/mm-mtree.sh2
-rw-r--r--release/tools/ec2.conf6
-rw-r--r--sbin/ifconfig/ifconfig.82
-rw-r--r--sbin/ifconfig/ifieee80211.c7
-rw-r--r--secure/usr.sbin/sshd/Makefile7
-rw-r--r--secure/usr.sbin/sshd/Makefile.depend1
-rw-r--r--share/man/man3/tree.36
-rw-r--r--share/man/man4/Makefile2
-rw-r--r--share/man/man4/ahci.43
-rw-r--r--share/man/man4/apic.43
-rw-r--r--share/man/man4/atp.43
-rw-r--r--share/man/man4/atrtc.43
-rw-r--r--share/man/man4/bcma.44
-rw-r--r--share/man/man4/bhnd.44
-rw-r--r--share/man/man4/bhyve.44
-rw-r--r--share/man/man4/bpf.45
-rw-r--r--share/man/man4/cmx.425
-rw-r--r--share/man/man4/cxgbe.46
-rw-r--r--share/man/man4/dcons.42
-rw-r--r--share/man/man4/ddb.420
-rw-r--r--share/man/man4/devctl.43
-rw-r--r--share/man/man4/fdt.434
-rw-r--r--share/man/man4/fdtbus.46
-rw-r--r--share/man/man4/hpet.422
-rw-r--r--share/man/man4/hptrr.43
-rw-r--r--share/man/man4/iicbus.42
-rw-r--r--share/man/man4/inet.46
-rw-r--r--share/man/man4/ip.42
-rw-r--r--share/man/man4/ipmi.44
-rw-r--r--share/man/man4/iscsi.41
-rw-r--r--share/man/man4/iser.494
-rw-r--r--share/man/man4/ixl.440
-rw-r--r--share/man/man4/ixlv.440
-rw-r--r--share/man/man4/ksyms.428
-rw-r--r--share/man/man4/man4.arm/cgem.46
-rw-r--r--share/man/man4/man4.arm/mge.412
-rw-r--r--share/man/man4/mdio.43
-rw-r--r--share/man/man4/mfi.45
-rw-r--r--share/man/man4/mpr.44
-rw-r--r--share/man/man4/mpt.43
-rw-r--r--share/man/man4/nand.428
-rw-r--r--share/man/man4/ng_atm.44
-rw-r--r--share/man/man4/ng_bridge.44
-rw-r--r--share/man/man4/ng_car.43
-rw-r--r--share/man/man4/ng_deflate.43
-rw-r--r--share/man/man4/ng_hub.44
-rw-r--r--share/man/man4/ng_mppc.48
-rw-r--r--share/man/man4/ng_netflow.48
-rw-r--r--share/man/man4/ng_pptpgre.43
-rw-r--r--share/man/man4/ng_pred1.43
-rw-r--r--share/man/man4/ng_tag.44
-rw-r--r--share/man/man4/nvd.45
-rw-r--r--share/man/man4/nvme.43
-rw-r--r--share/man/man4/nvram2env.413
-rw-r--r--share/man/man4/oce.42
-rw-r--r--share/man/man4/pass.44
-rw-r--r--share/man/man4/pf.42
-rw-r--r--share/man/man4/proto.410
-rw-r--r--share/man/man4/psm.48
-rw-r--r--share/man/man4/pts.49
-rw-r--r--share/man/man4/puc.42
-rw-r--r--share/man/man4/qlxgbe.42
-rw-r--r--share/man/man4/qlxge.42
-rw-r--r--share/man/man4/random.44
-rw-r--r--share/man/man4/rum.410
-rw-r--r--share/man/man4/sdhci.44
-rw-r--r--share/man/man4/sfxge.44
-rw-r--r--share/man/man4/siba.44
-rw-r--r--share/man/man4/siftr.423
-rw-r--r--share/man/man4/simplebus.46
-rw-r--r--share/man/man4/snd_hda.415
-rw-r--r--share/man/man4/stf.45
-rw-r--r--share/man/man4/u3g.45
-rw-r--r--share/man/man4/unix.42
-rw-r--r--share/man/man4/urtwn.464
-rw-r--r--share/man/man4/usb_template.434
-rw-r--r--share/man/man4/usfs.413
-rw-r--r--share/man/man4/vale.42
-rw-r--r--share/man/man4/virtio_scsi.45
-rw-r--r--share/man/man4/vlan.42
-rw-r--r--share/man/man4/witness.47
-rw-r--r--share/man/man5/ar.52
-rw-r--r--share/man/man5/devfs.rules.53
-rw-r--r--share/man/man5/elf.52
-rw-r--r--share/man/man5/nandfs.53
-rw-r--r--share/man/man5/nsswitch.conf.56
-rw-r--r--share/man/man5/quota.user.53
-rw-r--r--share/man/man5/rc.conf.536
-rw-r--r--share/man/man5/src.conf.533
-rw-r--r--share/man/man8/nanobsd.83
-rw-r--r--share/man/man9/BUS_NEW_PASS.92
-rw-r--r--share/man/man9/EVENTHANDLER.96
-rw-r--r--share/man/man9/SYSCALL_MODULE.92
-rw-r--r--share/man/man9/bpf.94
-rw-r--r--share/man/man9/counter.910
-rw-r--r--share/man/man9/firmware.99
-rw-r--r--share/man/man9/kqueue.94
-rw-r--r--share/man/man9/lock.93
-rw-r--r--share/man/man9/locking.93
-rw-r--r--share/man/man9/pmap.91
-rw-r--r--share/man/man9/stack.94
-rw-r--r--share/man/man9/sysctl.96
-rw-r--r--share/man/man9/timeout.96
-rw-r--r--share/man/man9/usbdi.969
-rw-r--r--share/man/man9/vn_fullpath.93
-rw-r--r--share/man/man9/zone.96
-rw-r--r--share/misc/committers-ports.dot6
-rw-r--r--share/misc/committers-src.dot2
-rw-r--r--share/mk/bsd.crunchgen.mk2
-rw-r--r--share/mk/bsd.init.mk10
-rw-r--r--share/mk/bsd.lib.mk5
-rw-r--r--share/mk/local.sys.mk16
-rw-r--r--share/mk/sys.mk10
-rw-r--r--sys/amd64/amd64/pmap.c25
-rw-r--r--sys/arm/arm/cpufunc.c26
-rw-r--r--sys/arm/arm/genassym.c2
-rw-r--r--sys/arm/arm/mp_machdep.c4
-rw-r--r--sys/arm/include/_types.h4
-rw-r--r--sys/arm/include/armreg.h54
-rw-r--r--sys/arm/include/proc.h2
-rw-r--r--sys/arm64/conf/GENERIC1
-rw-r--r--sys/arm64/conf/GENERIC-INTRNG15
-rw-r--r--sys/boot/efi/Makefile.inc4
-rw-r--r--sys/boot/efi/libefi/efi_console.c12
-rw-r--r--sys/boot/efi/libefi/efipart.c5
-rw-r--r--sys/boot/fdt/dts/arm/pcduino3b.dts48
-rw-r--r--sys/cam/ata/ata_da.c1
-rw-r--r--sys/cam/cam_ccb.h65
-rw-r--r--sys/cam/cam_xpt.c100
-rw-r--r--sys/cam/cam_xpt_internal.h3
-rw-r--r--sys/cam/nvme/nvme_all.c124
-rw-r--r--sys/cam/nvme/nvme_all.h48
-rw-r--r--sys/cam/nvme/nvme_da.c1152
-rw-r--r--sys/cam/nvme/nvme_xpt.c607
-rw-r--r--sys/cam/scsi/scsi_da.c1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c12
-rw-r--r--sys/compat/linprocfs/linprocfs.c6
-rw-r--r--sys/compat/linuxkpi/common/include/linux/etherdevice.h5
-rw-r--r--sys/compat/linuxkpi/common/include/linux/random.h6
-rw-r--r--sys/compat/linuxkpi/common/src/linux_idr.c3
-rw-r--r--sys/conf/files3
-rw-r--r--sys/conf/files.amd641
-rw-r--r--sys/conf/kern.opts.mk1
-rw-r--r--sys/conf/kern.post.mk4
-rw-r--r--sys/conf/newvers.sh2
-rw-r--r--sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h2
-rw-r--r--sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.c3
-rw-r--r--sys/contrib/dev/ath/ath_hal/ar9300/ar9300_xmit.c89
-rw-r--r--sys/contrib/dev/ath/ath_hal/ar9300/ar9300reg.h1
-rw-r--r--sys/dev/acpica/acpi_thermal.c79
-rw-r--r--sys/dev/ath/if_ath_alq.h8
-rw-r--r--sys/dev/ath/if_ath_sysctl.c3
-rw-r--r--sys/dev/bhnd/bcma/bcma_nexus.c3
-rw-r--r--sys/dev/bhnd/bhnd.h12
-rw-r--r--sys/dev/bhnd/bhnd_subr.c4
-rw-r--r--sys/dev/bhnd/cores/chipc/chipc.c2
-rw-r--r--sys/dev/bhnd/cores/pci/bhnd_pci.c4
-rw-r--r--sys/dev/bhnd/cores/pci/bhnd_pci_hostb.c2
-rw-r--r--sys/dev/bhnd/cores/pcie2/bhnd_pcie2.c2
-rw-r--r--sys/dev/bhnd/cores/pcie2/bhnd_pcie2_hostb.c2
-rw-r--r--sys/dev/bhnd/siba/siba_bhndb.c2
-rw-r--r--sys/dev/bhnd/siba/siba_nexus.c3
-rw-r--r--sys/dev/cxgb/cxgb_sge.c3
-rw-r--r--sys/dev/cxgbe/adapter.h15
-rw-r--r--sys/dev/cxgbe/t4_ioctl.h28
-rw-r--r--sys/dev/cxgbe/t4_main.c385
-rw-r--r--sys/dev/cxgbe/t4_sge.c81
-rw-r--r--sys/dev/dwc/if_dwc.c29
-rw-r--r--sys/dev/dwc/if_dwc.h2
-rw-r--r--sys/dev/e1000/if_igb.c2
-rw-r--r--sys/dev/flash/mx25l.c3
-rw-r--r--sys/dev/gpio/gpiobus.c45
-rw-r--r--sys/dev/gpio/gpiobusvar.h7
-rw-r--r--sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c12
-rw-r--r--sys/dev/hyperv/vmbus/hv_channel.c19
-rw-r--r--sys/dev/hyperv/vmbus/hv_connection.c72
-rw-r--r--sys/dev/hyperv/vmbus/hv_vmbus_priv.h23
-rw-r--r--sys/dev/hyperv/vmbus/vmbus.c50
-rw-r--r--sys/dev/hyperv/vmbus/vmbus_reg.h1
-rw-r--r--sys/dev/hyperv/vmbus/vmbus_var.h16
-rw-r--r--sys/dev/ioat/ioat.c99
-rw-r--r--sys/dev/iscsi/iscsi_ioctl.h20
-rw-r--r--sys/dev/iwm/if_iwm.c52
-rw-r--r--sys/dev/iwm/if_iwmvar.h1
-rw-r--r--sys/dev/ixgbe/ix_txrx.c2
-rw-r--r--sys/dev/ixl/ixl_txrx.c6
-rw-r--r--sys/dev/mii/miidevs1
-rw-r--r--sys/dev/mii/smscphy.c1
-rw-r--r--sys/dev/mlx5/driver.h1
-rw-r--r--sys/dev/mlx5/mlx5_core/mlx5_vport.c358
-rw-r--r--sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c132
-rw-r--r--sys/dev/mlx5/mlx5_en/mlx5_en_main.c7
-rw-r--r--sys/dev/mlx5/mlx5_en/mlx5_en_rx.c4
-rw-r--r--sys/dev/mlx5/vport.h28
-rw-r--r--sys/dev/nvme/nvme.h49
-rw-r--r--sys/dev/nvme/nvme_ctrlr.c4
-rw-r--r--sys/dev/nvme/nvme_ns_cmd.c42
-rw-r--r--sys/dev/nvme/nvme_private.h6
-rw-r--r--sys/dev/qlxgbe/ql_isr.c4
-rw-r--r--sys/dev/qlxge/qls_isr.c2
-rw-r--r--sys/dev/ral/rt2860.c19
-rw-r--r--sys/dev/ral/rt2860reg.h11
-rw-r--r--sys/dev/sfxge/common/ef10_nvram.c23
-rw-r--r--sys/dev/sfxge/sfxge_ev.c2
-rw-r--r--sys/dev/sfxge/sfxge_port.c4
-rw-r--r--sys/dev/sfxge/sfxge_tx.c4
-rw-r--r--sys/dev/sfxge/sfxge_version.h2
-rw-r--r--sys/dev/urtwn/if_urtwn.c58
-rw-r--r--sys/dev/urtwn/if_urtwnvar.h2
-rw-r--r--sys/dev/xen/netfront/netfront.c23
-rw-r--r--sys/dev/xen/timer/timer.c3
-rw-r--r--sys/fs/ext2fs/ext2_alloc.c4
-rw-r--r--sys/fs/ext2fs/ext2_bmap.c43
-rw-r--r--sys/fs/ext2fs/ext2_extents.h4
-rw-r--r--sys/fs/ext2fs/ext2_vfsops.c22
-rw-r--r--sys/fs/ext2fs/ext2fs.h18
-rw-r--r--sys/fs/nfsclient/nfs_clvfsops.c63
-rw-r--r--sys/kern/kern_exec.c10
-rw-r--r--sys/kern/kern_fail.c26
-rw-r--r--sys/kern/kern_fork.c8
-rw-r--r--sys/kern/kern_jail.c125
-rw-r--r--sys/kern/kern_linker.c21
-rw-r--r--sys/kern/kern_shutdown.c11
-rw-r--r--sys/kern/kern_sig.c3
-rw-r--r--sys/kern/kern_timeout.c37
-rw-r--r--sys/kern/subr_intr.c174
-rw-r--r--sys/kern/subr_prf.c8
-rw-r--r--sys/kern/sys_procdesc.c16
-rw-r--r--sys/kern/sysv_msg.c6
-rw-r--r--sys/mips/broadcom/bcm_mipscore.c19
-rw-r--r--sys/mips/mips/swtch.S6
-rw-r--r--sys/modules/Makefile6
-rw-r--r--sys/modules/bwn/Makefile2
-rw-r--r--sys/modules/bwn_pci/Makefile1
-rw-r--r--sys/modules/dtb/allwinner/Makefile1
-rw-r--r--sys/modules/netgraph/mppc/Makefile3
-rw-r--r--sys/modules/siba_bwn/Makefile2
-rw-r--r--sys/modules/tcp/fastpath/Makefile2
-rw-r--r--sys/net/flowtable.c2
-rw-r--r--sys/net/if.c12
-rw-r--r--sys/net/if_vxlan.c3
-rw-r--r--sys/net/iflib.c25
-rw-r--r--sys/net/mppc.h62
-rw-r--r--sys/net/mppcc.c299
-rw-r--r--sys/net/mppcd.c284
-rw-r--r--sys/net/pfil.c10
-rw-r--r--sys/net/route.c9
-rw-r--r--sys/net/route.h1
-rw-r--r--sys/net80211/ieee80211_hostap.c4
-rw-r--r--sys/net80211/ieee80211_output.c5
-rw-r--r--sys/netgraph/bluetooth/l2cap/ng_l2cap_misc.c3
-rw-r--r--sys/netgraph/bluetooth/l2cap/ng_l2cap_ulpi.c8
-rw-r--r--sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c2
-rw-r--r--sys/netinet/igmp.c37
-rw-r--r--sys/netinet/ip_fastfwd.c1
-rw-r--r--sys/netinet/ip_id.c2
-rw-r--r--sys/netinet/ip_input.c1
-rw-r--r--sys/netinet/ip_output.c1
-rw-r--r--sys/netinet/sctp_input.c11
-rw-r--r--sys/netinet/sctp_output.c42
-rw-r--r--sys/netinet/sctp_pcb.c2
-rw-r--r--sys/netinet/sctp_structs.h9
-rw-r--r--sys/netinet/sctputil.c32
-rw-r--r--sys/netinet/tcp_input.c1
-rw-r--r--sys/netinet/tcp_stacks/fastpath.c1
-rw-r--r--sys/netinet/udp_usrreq.c1
-rw-r--r--sys/netinet6/in6.c44
-rw-r--r--sys/netinet6/in6_var.h1
-rw-r--r--sys/netinet6/ip6_forward.c1
-rw-r--r--sys/netinet6/ip6_input.c1
-rw-r--r--sys/netinet6/ip6_output.c1
-rw-r--r--sys/netinet6/mld6.c3
-rw-r--r--sys/netinet6/nd6.c7
-rw-r--r--sys/netinet6/udp6_usrreq.c1
-rw-r--r--sys/ofed/drivers/net/mlx4/en_rx.c2
-rw-r--r--sys/riscv/include/riscvreg.h1
-rw-r--r--sys/rpc/clnt_bck.c11
-rw-r--r--sys/rpc/rpcb_clnt.c2
-rw-r--r--sys/security/audit/audit_bsm.c2
-rw-r--r--sys/sys/intr.h24
-rw-r--r--sys/sys/param.h2
-rw-r--r--sys/sys/procdesc.h6
-rw-r--r--sys/vm/swap_pager.c120
-rw-r--r--sys/xen/xen-os.h2
-rw-r--r--tools/build/Makefile10
-rw-r--r--tools/build/futimens.c96
-rw-r--r--tools/build/mk/OptionalObsoleteFiles.inc14
-rw-r--r--tools/build/options/WITHOUT_BLACKLIST2
-rw-r--r--tools/build/options/WITHOUT_BLACKLIST_SUPPORT8
-rw-r--r--tools/build/options/WITH_META_MODE11
-rw-r--r--tools/build/stat.h (renamed from lib/libpam/libpam/pam_debug_log.c)50
-rw-r--r--tools/build/utimensat.c108
-rw-r--r--tools/tools/cxgbetool/cxgbetool.c4
-rw-r--r--usr.bin/awk/Makefile6
-rw-r--r--usr.bin/bmake/Makefile4
-rw-r--r--usr.bin/bmake/config.h7
-rw-r--r--usr.bin/calendar/calendars/calendar.freebsd3
-rw-r--r--usr.bin/indent/lexi.c2
-rw-r--r--usr.bin/random/randomize_fd.c7
-rw-r--r--usr.bin/truss/Makefile1
-rw-r--r--usr.bin/truss/amd64-linux.c104
-rwxr-xr-xusr.bin/xinstall/tests/install_test.sh7
-rw-r--r--usr.bin/xinstall/xinstall.c30
-rw-r--r--usr.sbin/Makefile6
-rw-r--r--usr.sbin/bluetooth/ath3kfw/Makefile1
-rw-r--r--usr.sbin/bluetooth/ath3kfw/ath3k_dbg.h41
-rw-r--r--usr.sbin/bluetooth/ath3kfw/ath3k_fw.c114
-rw-r--r--usr.sbin/bluetooth/ath3kfw/ath3k_fw.h56
-rw-r--r--usr.sbin/bluetooth/ath3kfw/ath3k_hw.c358
-rw-r--r--usr.sbin/bluetooth/ath3kfw/ath3k_hw.h66
-rw-r--r--usr.sbin/bluetooth/ath3kfw/ath3kfw.832
-rw-r--r--usr.sbin/bluetooth/ath3kfw/ath3kfw.c297
-rw-r--r--usr.sbin/bluetooth/ath3kfw/main.c394
-rwxr-xr-xusr.sbin/bsdinstall/scripts/wlanconfig215
-rwxr-xr-xusr.sbin/bsdinstall/scripts/zfsboot14
-rw-r--r--usr.sbin/ctld/ctld.h1
-rw-r--r--usr.sbin/ctld/login.c11
-rwxr-xr-xusr.sbin/extattr/tests/extattr_test.sh27
-rw-r--r--usr.sbin/iscsid/iscsid.h4
-rw-r--r--usr.sbin/iscsid/login.c24
-rw-r--r--usr.sbin/makefs/cd9660.c30
-rw-r--r--usr.sbin/makefs/ffs.c60
-rw-r--r--usr.sbin/makefs/ffs/mkfs.c12
-rw-r--r--usr.sbin/makefs/ffs/newfs_extern.h4
-rw-r--r--usr.sbin/makefs/makefs.815
-rw-r--r--usr.sbin/makefs/makefs.c47
-rw-r--r--usr.sbin/makefs/makefs.h1
-rw-r--r--usr.sbin/makefs/walk.c14
-rw-r--r--usr.sbin/newsyslog/newsyslog.c16
-rw-r--r--usr.sbin/rpc.lockd/lockd_lock.c1
-rw-r--r--usr.sbin/rpcbind/rpcb_stat.c2
-rw-r--r--usr.sbin/rpcbind/rpcb_svc_com.c6
-rw-r--r--usr.sbin/services_mkdb/services_mkdb.82
-rw-r--r--usr.sbin/sysrc/sysrc.82
-rw-r--r--usr.sbin/tcpdump/tcpdump/config.h2
-rw-r--r--usr.sbin/ypldap/ypldap.86
450 files changed, 9264 insertions, 2572 deletions
diff --git a/Makefile b/Makefile
index b46d99e..1a1d885 100644
--- a/Makefile
+++ b/Makefile
@@ -133,12 +133,27 @@ TGTS= all all-man buildenv buildenvvars buildkernel buildworld \
create-world-packages create-kernel-packages create-packages \
packages installconfig real-packages sign-packages package-pkg
+# XXX: r156740: This can't work since bsd.subdir.mk is not included ever.
+# It will only work for SUBDIR_TARGETS in make.conf.
TGTS+= ${SUBDIR_TARGETS}
BITGTS= files includes
BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
TGTS+= ${BITGTS}
+# Only some targets are allowed to use meta mode. Others get it
+# disabled. In some cases, such as 'install', meta mode can be dangerous
+# as a cookie may be used to prevent redundant installations (such as
+# for WORLDTMP staging). For DESTDIR=/ we always want to install though.
+# For other cases, such as delete-old-libs, meta mode may break
+# the interactive tty prompt. The safest route is to just whitelist
+# the ones that benefit from it.
+META_TGT_WHITELIST+= \
+ _* build32 buildfiles buildincludes buildkernel buildsoft \
+ buildworld everything kernel-toolchains kernels libraries \
+ native-xtools showconfig tinderbox toolchain toolchains universe \
+ worlds xdev xdev-build
+
.ORDER: buildworld installworld
.ORDER: buildworld distributeworld
.ORDER: buildworld buildkernel
@@ -194,14 +209,24 @@ SUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
_MAKE= PATH=${PATH} ${SUB_MAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
-# Must disable META_MODE when installing to avoid missing anything. The
-# main problem is that buildworld will create cookies for install targets
-# since they are being installed into WORLDTMP. This avoids unneeded and
-# redundant restaging but is dangerous for user install targets.
-.if make(distrib*) || make(*install*)
+# Only allow meta mode for the whitelisted targets. See META_TGT_WHITELIST
+# above.
+.for _tgt in ${META_TGT_WHITELIST}
+.if make(${_tgt})
+_CAN_USE_META_MODE?= yes
+.endif
+.endfor
+.if !defined(_CAN_USE_META_MODE)
_MAKE+= MK_META_MODE=no
.unexport META_MODE
-.endif
+.elif defined(MK_META_MODE) && ${MK_META_MODE} == "yes"
+.if !exists(/dev/filemon) && !defined(NO_FILEMON) && !make(showconfig)
+# Require filemon be loaded to provide a working incremental build
+.error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded. \
+ ${.newline}ERROR: WITH_META_MODE is enabled but requires filemon for an incremental build. \
+ ${.newline}ERROR: 'kldload filemon' or pass -DNO_FILEMON to suppress this error.
+.endif # !exists(/dev/filemon) && !defined(NO_FILEMON)
+.endif # !defined(_CAN_USE_META_MODE)
# Guess machine architecture from machine type, and vice versa.
.if !defined(TARGET_ARCH) && defined(TARGET)
@@ -274,7 +299,7 @@ CHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s ; echo
# not included. One can argue that this target doesn't build everything
# then.
#
-world: upgrade_checks
+world: upgrade_checks .PHONY
@echo "--------------------------------------------------------------"
@echo ">>> make world started on ${STARTTIME}"
@echo "--------------------------------------------------------------"
@@ -300,7 +325,7 @@ world: upgrade_checks
@echo " (started ${STARTTIME})"
@echo "--------------------------------------------------------------"
.else
-world:
+world: .PHONY
@echo "WARNING: make world will overwrite your existing FreeBSD"
@echo "installation without also building and installing a new"
@echo "kernel. This can be dangerous. Please read the handbook,"
@@ -317,13 +342,13 @@ world:
#
# Short hand for `make buildkernel installkernel'
#
-kernel: buildkernel installkernel
+kernel: buildkernel installkernel .PHONY
#
# Perform a few tests to determine if the installed tools are adequate
# for building the world.
#
-upgrade_checks:
+upgrade_checks: .PHONY
.if defined(NEED_MAKE_UPGRADE)
@${_+_}(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
.endif
@@ -359,19 +384,19 @@ regress: .PHONY
tinderbox toolchains kernel-toolchains kernels worlds: upgrade_checks
-tinderbox:
+tinderbox: .PHONY
@cd ${.CURDIR}; ${SUB_MAKE} DOING_TINDERBOX=YES universe
-toolchains:
+toolchains: .PHONY
@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
-kernel-toolchains:
+kernel-toolchains: .PHONY
@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe
-kernels:
+kernels: .PHONY
@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=buildkernel universe
-worlds:
+worlds: .PHONY
@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=buildworld universe
#
@@ -397,9 +422,9 @@ TARGET_ARCHES_${target}?= ${target}
# It does not build with the in-tree linker.
.if !exists(/usr/local/aarch64-freebsd/bin/ld) && empty(${TARGETS})
_UNIVERSE_TARGETS:= ${_UNIVERSE_TARGETS:Narm64}
-universe: universe_arm64_skip
-universe_epilogue: universe_arm64_skip
-universe_arm64_skip: universe_prologue
+universe: universe_arm64_skip .PHONY
+universe_epilogue: universe_arm64_skip .PHONY
+universe_arm64_skip: universe_prologue .PHONY
@echo ">> arm64 skipped - install aarch64-binutils port or package to build"
.endif
@@ -437,16 +462,16 @@ universe_prologue: .PHONY
.for target in ${_UNIVERSE_TARGETS}
universe: universe_${target}
universe_epilogue: universe_${target}
-universe_${target}: universe_${target}_prologue
-universe_${target}_prologue: universe_prologue
+universe_${target}: universe_${target}_prologue .PHONY
+universe_${target}_prologue: universe_prologue .PHONY
@echo ">> ${target} started on `LC_ALL=C date`"
-universe_${target}_worlds:
+universe_${target}_worlds: .PHONY
.if !defined(MAKE_JUST_KERNELS)
-universe_${target}_done: universe_${target}_worlds
+universe_${target}_done: universe_${target}_worlds .PHONY
.for target_arch in ${TARGET_ARCHES_${target}}
-universe_${target}_worlds: universe_${target}_${target_arch}
-universe_${target}_${target_arch}: universe_${target}_prologue .MAKE
+universe_${target}_worlds: universe_${target}_${target_arch} .PHONY
+universe_${target}_${target_arch}: universe_${target}_prologue .MAKE .PHONY
@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
@@ -461,9 +486,9 @@ universe_${target}_${target_arch}: universe_${target}_prologue .MAKE
.endif # !MAKE_JUST_KERNELS
.if !defined(MAKE_JUST_WORLDS)
-universe_${target}_done: universe_${target}_kernels
-universe_${target}_kernels: universe_${target}_worlds
-universe_${target}_kernels: universe_${target}_prologue .MAKE
+universe_${target}_done: universe_${target}_kernels .PHONY
+universe_${target}_kernels: universe_${target}_worlds .PHONY
+universe_${target}_kernels: universe_${target}_prologue .MAKE .PHONY
.if exists(${KERNSRCDIR}/${target}/conf/NOTES)
@(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
${SUB_MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
@@ -479,7 +504,7 @@ universe_${target}: universe_${target}_done
universe_${target}_done:
@echo ">> ${target} completed on `LC_ALL=C date`"
.endfor
-universe_kernels: universe_kernconfs
+universe_kernels: universe_kernconfs .PHONY
.if !defined(TARGET)
TARGET!= uname -m
.endif
@@ -493,7 +518,7 @@ KERNCONFS!= cd ${KERNSRCDIR}/${TARGET}/conf && \
-type f -maxdepth 0 \
! -name DEFAULTS ! -name NOTES | \
${_THINNER}
-universe_kernconfs:
+universe_kernconfs: .PHONY
.for kernel in ${KERNCONFS}
TARGET_ARCH_${kernel}!= cd ${KERNSRCDIR}/${TARGET}/conf && \
config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
@@ -527,7 +552,7 @@ universe_epilogue: .PHONY
.endif
.endif
-buildLINT:
+buildLINT: .PHONY
${MAKE} -C ${.CURDIR}/sys/${_TARGET}/conf LINT
.if defined(.PARSEDIR)
diff --git a/Makefile.inc1 b/Makefile.inc1
index dd17644..0daa440 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -646,6 +646,8 @@ _worldtmp: .PHONY
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
-p ${WORLDTMP}/legacy/usr >/dev/null
.endif
+ mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
+ -p ${WORLDTMP}/legacy/usr/include >/dev/null
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
-p ${WORLDTMP}/usr >/dev/null
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
diff --git a/Makefile.libcompat b/Makefile.libcompat
index f7911c3..f0aafe6 100644
--- a/Makefile.libcompat
+++ b/Makefile.libcompat
@@ -19,7 +19,7 @@ LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
MACHINE_CPU="i686 mmx sse sse2"
LIB32WMAKEFLAGS= \
AS="${XAS} --32" \
- LD="${XLD} -m elf_i386_fbsd -Y P,${LIBCOMPATTMP}/usr/lib32" \
+ LD="${XLD} -m elf_i386_fbsd -L${LIBCOMPATTMP}/usr/lib32" \
OBJCOPY="${XOBJCOPY}"
.elif ${TARGET_ARCH} == "powerpc64"
diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
index ca7a40f..d3a16389 100644
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -38,6 +38,57 @@
# xargs -n1 | sort | uniq -d;
# done
+# 20160608: removed pam_verbose_error
+OLD_LIBS+=usr/lib/libpam.so.5
+OLD_LIBS+=usr/lib/pam_chroot.so.5
+OLD_LIBS+=usr/lib/pam_deny.so.5
+OLD_LIBS+=usr/lib/pam_echo.so.5
+OLD_LIBS+=usr/lib/pam_exec.so.5
+OLD_LIBS+=usr/lib/pam_ftpusers.so.5
+OLD_LIBS+=usr/lib/pam_group.so.5
+OLD_LIBS+=usr/lib/pam_guest.so.5
+OLD_LIBS+=usr/lib/pam_krb5.so.5
+OLD_LIBS+=usr/lib/pam_ksu.so.5
+OLD_LIBS+=usr/lib/pam_lastlog.so.5
+OLD_LIBS+=usr/lib/pam_login_access.so.5
+OLD_LIBS+=usr/lib/pam_nologin.so.5
+OLD_LIBS+=usr/lib/pam_opie.so.5
+OLD_LIBS+=usr/lib/pam_opieaccess.so.5
+OLD_LIBS+=usr/lib/pam_passwdqc.so.5
+OLD_LIBS+=usr/lib/pam_permit.so.5
+OLD_LIBS+=usr/lib/pam_radius.so.5
+OLD_LIBS+=usr/lib/pam_rhosts.so.5
+OLD_LIBS+=usr/lib/pam_rootok.so.5
+OLD_LIBS+=usr/lib/pam_securetty.so.5
+OLD_LIBS+=usr/lib/pam_self.so.5
+OLD_LIBS+=usr/lib/pam_ssh.so.5
+OLD_LIBS+=usr/lib/pam_tacplus.so.5
+OLD_LIBS+=usr/lib/pam_unix.so.5
+OLD_LIBS+=usr/lib32/libpam.so.5
+OLD_LIBS+=usr/lib32/pam_chroot.so.5
+OLD_LIBS+=usr/lib32/pam_deny.so.5
+OLD_LIBS+=usr/lib32/pam_echo.so.5
+OLD_LIBS+=usr/lib32/pam_exec.so.5
+OLD_LIBS+=usr/lib32/pam_ftpusers.so.5
+OLD_LIBS+=usr/lib32/pam_group.so.5
+OLD_LIBS+=usr/lib32/pam_guest.so.5
+OLD_LIBS+=usr/lib32/pam_krb5.so.5
+OLD_LIBS+=usr/lib32/pam_ksu.so.5
+OLD_LIBS+=usr/lib32/pam_lastlog.so.5
+OLD_LIBS+=usr/lib32/pam_login_access.so.5
+OLD_LIBS+=usr/lib32/pam_nologin.so.5
+OLD_LIBS+=usr/lib32/pam_opie.so.5
+OLD_LIBS+=usr/lib32/pam_opieaccess.so.5
+OLD_LIBS+=usr/lib32/pam_passwdqc.so.5
+OLD_LIBS+=usr/lib32/pam_permit.so.5
+OLD_LIBS+=usr/lib32/pam_radius.so.5
+OLD_LIBS+=usr/lib32/pam_rhosts.so.5
+OLD_LIBS+=usr/lib32/pam_rootok.so.5
+OLD_LIBS+=usr/lib32/pam_securetty.so.5
+OLD_LIBS+=usr/lib32/pam_self.so.5
+OLD_LIBS+=usr/lib32/pam_ssh.so.5
+OLD_LIBS+=usr/lib32/pam_tacplus.so.5
+OLD_LIBS+=usr/lib32/pam_unix.so.5
# 20160523: remove extranous ALTQ files
OLD_FILES+=usr/include/altq/altq_codel.h
OLD_FILES+=usr/include/altq/altq_fairq.h
diff --git a/bin/csh/Makefile b/bin/csh/Makefile
index 3dbd0b5..e43de07 100644
--- a/bin/csh/Makefile
+++ b/bin/csh/Makefile
@@ -136,7 +136,7 @@ sh.err.h: sh.err.c
grep 'ERR_' ${.ALLSRC} | grep '^#define' >> ${.TARGET}
@echo '#endif /* _h_sh_err */' >> ${.TARGET}
-tc.const.h: tc.const.c sh.char.h config.h config_f.h sh.types.h sh.err.h
+tc.const.h: tc.const.c sh.char.h config.h config_f.h sh.types.h sh.err.h ${BUILD_TOOLS_META}
@rm -f ${.TARGET}
@echo '/* Do not edit this file, make creates it. */' > ${.TARGET}
@echo '#ifndef _h_tc_const' >> ${.TARGET}
diff --git a/bin/setfacl/file.c b/bin/setfacl/file.c
index e5e19a2..7499f1c 100644
--- a/bin/setfacl/file.c
+++ b/bin/setfacl/file.c
@@ -43,13 +43,12 @@ acl_t
get_acl_from_file(const char *filename)
{
FILE *file;
+ size_t len;
char buf[BUFSIZ+1];
if (filename == NULL)
err(1, "(null) filename in get_acl_from_file()");
- bzero(&buf, sizeof(buf));
-
if (strcmp(filename, "-") == 0) {
if (have_stdin != 0)
err(1, "cannot specify more than one stdin");
@@ -61,7 +60,8 @@ get_acl_from_file(const char *filename)
err(1, "fopen() %s failed", filename);
}
- fread(buf, sizeof(buf) - 1, (size_t)1, file);
+ len = fread(buf, (size_t)1, sizeof(buf) - 1, file);
+ buf[len] = '\0';
if (ferror(file) != 0) {
fclose(file);
err(1, "error reading from %s", filename);
diff --git a/contrib/atf/config.h b/contrib/atf/config.h
index befc2e3..a7094fc 100644
--- a/contrib/atf/config.h
+++ b/contrib/atf/config.h
@@ -2,10 +2,10 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if basename takes a constant pointer */
-#define HAVE_CONST_BASENAME 1
+/* #undef HAVE_CONST_BASENAME */
/* Define to 1 if dirname takes a constant pointer */
-#define HAVE_CONST_DIRNAME 1
+/* #undef HAVE_CONST_DIRNAME */
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
diff --git a/contrib/blacklist/bin/blacklistctl.8 b/contrib/blacklist/bin/blacklistctl.8
index d8ed1f0..f28ab28 100644
--- a/contrib/blacklist/bin/blacklistctl.8
+++ b/contrib/blacklist/bin/blacklistctl.8
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd April 29, 2015
+.Dd June 7, 2016
.Dt BLACKLISTCTL 8
.Os
.Sh NAME
@@ -75,7 +75,11 @@ will first attempt to remove the existing rule, and then it will re-add
it to make sure that there is only one rule active.
.Sh HISTORY
.Nm
-appeared in
+first appeared in
.Nx 7 .
+.Fx support for
+.Nm
+was implemented in
+.Fx 11 .
.Sh AUTHORS
.An Christos Zoulas
diff --git a/contrib/blacklist/bin/blacklistctl.c b/contrib/blacklist/bin/blacklistctl.c
index d202fb1..3ac65a5 100644
--- a/contrib/blacklist/bin/blacklistctl.c
+++ b/contrib/blacklist/bin/blacklistctl.c
@@ -96,10 +96,10 @@ main(int argc, char *argv[])
break;
case 'b':
blocked = 1;
+ break;
case 'D':
dbname = optarg;
break;
- break;
case 'd':
debug++;
break;
diff --git a/contrib/blacklist/bin/blacklistd.8 b/contrib/blacklist/bin/blacklistd.8
index 80a53da..0d34d1e 100644
--- a/contrib/blacklist/bin/blacklistd.8
+++ b/contrib/blacklist/bin/blacklistd.8
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd June 4, 2015
+.Dd June 7, 2016
.Dt BLACKLISTD 8
.Os
.Sh NAME
@@ -216,7 +216,11 @@ Socket to receive connection notifications.
.Xr syslogd 8
.Sh HISTORY
.Nm
-appeared in
+first appeared in
.Nx 7 .
+.Fx support for
+.Nm
+was implemented in
+.Fx 11 .
.Sh AUTHORS
.An Christos Zoulas
diff --git a/contrib/blacklist/bin/blacklistd.conf.5 b/contrib/blacklist/bin/blacklistd.conf.5
index 40d507b..aa10e34 100644
--- a/contrib/blacklist/bin/blacklistd.conf.5
+++ b/contrib/blacklist/bin/blacklistd.conf.5
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd April 29, 2015
+.Dd June 7, 2016
.Dt BLACKLISTD.CONF 5
.Os
.Sh NAME
@@ -216,7 +216,11 @@ bnx0:ssh * * * * 3 6h
.Xr blacklistd 8
.Sh HISTORY
.Nm
-appeared in
+first appeared in
.Nx 7 .
+.Fx support for
+.Nm
+was implemented in
+.Fx 11 .
.Sh AUTHORS
.An Christos Zoulas
diff --git a/contrib/blacklist/libexec/blacklistd-helper b/contrib/blacklist/libexec/blacklistd-helper
index 743ccf5..be63a9c 100644
--- a/contrib/blacklist/libexec/blacklistd-helper
+++ b/contrib/blacklist/libexec/blacklistd-helper
@@ -10,12 +10,20 @@
# $7 id
pf=
-for f in npf pf; do
- if [ -f "/etc/$f.conf" ]; then
- pf="$f"
- break
- fi
-done
+if [ -f "/etc/ipfw-blacklist.rc" ]; then
+ pf="ipfw"
+ . /etc/ipfw-blacklist.rc
+ ipfw_offset=${ipfw_offset:-2000}
+fi
+
+if [ -z "$pf" ]; then
+ for f in npf pf ipf; do
+ if [ -f "/etc/$f.conf" ]; then
+ pf="$f"
+ break
+ fi
+ done
+fi
if [ -z "$pf" ]; then
echo "$0: Unsupported packet filter" 1>&2
@@ -43,6 +51,21 @@ esac
case "$1" in
add)
case "$pf" in
+ ipf)
+ /sbin/ipfstat -io | /sbin/ipf -I -f - >/dev/null 2>&1
+ echo block in quick $proto from $addr/$mask to \
+ any port=$6 head port$6 | \
+ /sbin/ipf -I -f - -s >/dev/null 2>&1
+ ;;
+ ipfw)
+ # use $ipfw_offset+$port for rule number
+ rule=$(($ipfw_offset + $6))
+ tname="port$6"
+ /sbin/ipfw table $tname create type addr 2>/dev/null
+ /sbin/ipfw -q table $tname add "$addr/$mask"
+ /sbin/ipfw -q add $rule drop $3 from "table("$tname")" to \
+ any dst-port $6
+ ;;
npf)
/sbin/npfctl rule "$2" add block in final $proto from \
"$addr/$mask" to any $port
@@ -57,6 +80,15 @@ add)
;;
rem)
case "$pf" in
+ ipf)
+ /sbin/ipfstat -io | /sbin/ipf -I -f - >/dev/null 2>&1
+ echo block in quick $proto from $addr/$mask to \
+ any port=$6 head port$6 | \
+ /sbin/ipf -I -r -f - -s >/dev/null 2>&1
+ ;;
+ ipfw)
+ /sbin/ipfw table "port$6" delete "$addr/$mask" 2>/dev/null
+ ;;
npf)
/sbin/npfctl rule "$2" rem-id "$7"
;;
@@ -66,7 +98,13 @@ rem)
esac
;;
flush)
- case "$pf" in
+ case "$pf" in
+ ipf)
+ /sbin/ipf -Z -I -Fi -s > /dev/null
+ ;;
+ ipfw)
+ /sbin/ipfw table "port$6" flush 2>/dev/null
+ ;;
npf)
/sbin/npfctl rule "$2" flush
;;
diff --git a/contrib/bmake/ChangeLog b/contrib/bmake/ChangeLog
index 96b8930..deee9bf 100644
--- a/contrib/bmake/ChangeLog
+++ b/contrib/bmake/ChangeLog
@@ -1,3 +1,9 @@
+2016-06-06 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile (_MAKE_VERSION): 20160606
+ Merge with NetBSD make, pick up
+ o dir.c: extend mtimes cache to others via cached_stat()
+
2016-06-04 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (_MAKE_VERSION): 20160604
diff --git a/contrib/bmake/Makefile b/contrib/bmake/Makefile
index deba694..9c63e4f 100644
--- a/contrib/bmake/Makefile
+++ b/contrib/bmake/Makefile
@@ -1,7 +1,7 @@
-# $Id: Makefile,v 1.66 2016/06/04 22:21:15 sjg Exp $
+# $Id: Makefile,v 1.67 2016/06/07 00:46:12 sjg Exp $
# Base version on src date
-_MAKE_VERSION= 20160604
+_MAKE_VERSION= 20160606
PROG= bmake
diff --git a/contrib/bmake/README b/contrib/bmake/README
index d09e977..a782f6d 100644
--- a/contrib/bmake/README
+++ b/contrib/bmake/README
@@ -1,47 +1,52 @@
bmake
+ *****
-This directory contains a port of the BSD make tool (from NetBSD)
-I have run it on SunOS,Solaris,HP-UX,AIX,IRIX,FreeBSD and Linux.
+This directory contains a port of the BSD make tool (from NetBSD).
+Since 1993 I have run it on AIX, BSDi, Darwin, FreeBSD, HP-UX, IRIX,
+Linux, Minix, OSF, Solaris, SunOS and even UTS.
+Others have run it on many more systems.
-Version 3 was re-worked from scratch to better facilitate
-importing newer make(1) versions from NetBSD. The original code base
-was NetBSD-1.0, so version 3 was built by doing a fresh import of the
-NetBSD-1.0 usr.bin/make, adding the autoconf and other portability
-patches to sync it with bmake v2, and then NetBSD's make
-of Feb 20, 2000 was imported and conflicts dealt with.
-NetBSD's make was again imported on June 6 and December 15, 2000.
+Currently each release is tested on NetBSD, FreeBSD, Solaris and Linux.
-In 2003 bmake switched to a date based version (first was 20030714)
+Since 2003 bmake switched to a date based version (first was 20030714)
which generally represents the date it was last merged with NetBSD's
make. Since then, NetBSD's make is imported within a week of any
interesting changes, so that bmake tracks it very closely.
-Building:
+Building
+========
-The preferred way to bootstrap bmake is:
+The preferred way to bootstrap bmake is::
-./bmake/boot-strap
+ ./bmake/boot-strap
there are a number of args - most of which get passed to configure,
eg.
+::
-./bmake/boot-strap --prefix=/opt
+ ./bmake/boot-strap --prefix=/opt
see the boot-strap script for details.
+For folk that hate to read anything, since 20121212 you can also use
+the GNU standard process of::
+
+ ./configure; make; make install
+
To make much use of bmake you will need the bsd.*.mk macros or my
-portable *.mk macros. See
+portable *.mk macros which are included with bmake since 20121212
+and separately available from
http://www.crufty.net/ftp/pub/sjg/mk.tar.gz
which will be links to the latest versions.
-On a non-BSD system, you would want to unpack mk[-YYYYmmdd].tar.gz in
-the same directory as bmake (so ./mk and ./bmake exist), and
-./bmake/boot-strap will do the rest.
+Porting
+=======
+
+If you encounter a system that bmake does not build or work on *out of
+the box*, I welcome patches.
+If you can provide access to a suitable machine - even better.
-If you want to do it all by hand then read boot-strap first to get the
-idea.
+More info can be found at http://www.crufty.net/help/sjg/bmake.htm
-Even if you have an earlier version of bmake installed, use boot-strap
-to ensure that all goes well.
+--sjg <sjg@crufty.net>
---sjg
diff --git a/contrib/bmake/config.h.in b/contrib/bmake/config.h.in
index ce1700d..82e7e99 100644
--- a/contrib/bmake/config.h.in
+++ b/contrib/bmake/config.h.in
@@ -324,6 +324,9 @@
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
+/* Define to `int' if <sys/types.h> does not define. */
+#undef mode_t
+
/* Define to `long int' if <sys/types.h> does not define. */
#undef off_t
diff --git a/contrib/bmake/configure b/contrib/bmake/configure
index 946b8da..1a70f3d 100755
--- a/contrib/bmake/configure
+++ b/contrib/bmake/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.64 for bmake 20151022.
+# Generated by GNU Autoconf 2.64 for bmake 20160606.
#
# Report bugs to <sjg@NetBSD.org>.
#
@@ -549,8 +549,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='bmake'
PACKAGE_TARNAME='bmake'
-PACKAGE_VERSION='20151022'
-PACKAGE_STRING='bmake 20151022'
+PACKAGE_VERSION='20160606'
+PACKAGE_STRING='bmake 20160606'
PACKAGE_BUGREPORT='sjg@NetBSD.org'
PACKAGE_URL=''
@@ -1221,7 +1221,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures bmake 20151022 to adapt to many kinds of systems.
+\`configure' configures bmake 20160606 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1282,7 +1282,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of bmake 20151022:";;
+ short | recursive ) echo "Configuration of bmake 20160606:";;
esac
cat <<\_ACEOF
@@ -1387,7 +1387,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-bmake configure 20151022
+bmake configure 20160606
generated by GNU Autoconf 2.64
Copyright (C) 2009 Free Software Foundation, Inc.
@@ -1960,7 +1960,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by bmake $as_me 20151022, which was
+It was created by bmake $as_me 20160606, which was
generated by GNU Autoconf 2.64. Invocation command line was
$ $0 $@
@@ -5055,6 +5055,17 @@ $as_echo "#define const /**/" >>confdefs.h
fi
+ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default"
+if test "x$ac_cv_type_mode_t" = x""yes; then :
+
+else
+
+cat >>confdefs.h <<_ACEOF
+#define mode_t int
+_ACEOF
+
+fi
+
ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default"
if test "x$ac_cv_type_off_t" = x""yes; then :
@@ -6502,7 +6513,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by bmake $as_me 20151022, which was
+This file was extended by bmake $as_me 20160606, which was
generated by GNU Autoconf 2.64. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -6562,7 +6573,7 @@ Report bugs to <sjg@NetBSD.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\
-bmake config.status 20151022
+bmake config.status 20160606
configured by $0, generated by GNU Autoconf 2.64,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
diff --git a/contrib/bmake/configure.in b/contrib/bmake/configure.in
index c4b6808..29d368b 100644
--- a/contrib/bmake/configure.in
+++ b/contrib/bmake/configure.in
@@ -1,11 +1,11 @@
dnl
dnl RCSid:
-dnl $Id: configure.in,v 1.56 2015/10/25 05:20:48 sjg Exp $
+dnl $Id: configure.in,v 1.57 2016/06/07 00:49:44 sjg Exp $
dnl
dnl Process this file with autoconf to produce a configure script
dnl
AC_PREREQ(2.50)
-AC_INIT([bmake], [20151022], [sjg@NetBSD.org])
+AC_INIT([bmake], [20160606], [sjg@NetBSD.org])
AC_CONFIG_HEADERS(config.h)
dnl make srcdir absolute
@@ -148,6 +148,7 @@ dnl Checks for typedefs, structures, and compiler characteristics.
AC_C___ATTRIBUTE__
AC_C_BIGENDIAN
AC_C_CONST
+AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
diff --git a/contrib/bmake/dir.c b/contrib/bmake/dir.c
index 7b12769..4667e3c 100644
--- a/contrib/bmake/dir.c
+++ b/contrib/bmake/dir.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.67 2013/03/05 22:01:43 christos Exp $ */
+/* $NetBSD: dir.c,v 1.68 2016/06/07 00:40:00 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.67 2013/03/05 22:01:43 christos Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.68 2016/06/07 00:40:00 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: dir.c,v 1.67 2013/03/05 22:01:43 christos Exp $");
+__RCSID("$NetBSD: dir.c,v 1.68 2016/06/07 00:40:00 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -244,6 +244,7 @@ static Hash_Table mtimes; /* Results of doing a last-resort stat in
* be two rules to update a single file, so this
* should be ok, but... */
+static Hash_Table lmtimes; /* same as mtimes but for lstat */
static int DirFindName(const void *, const void *);
static int DirMatchFiles(const char *, Path *, Lst);
@@ -256,6 +257,80 @@ static char *DirLookupSubdir(Path *, const char *);
static char *DirFindDot(Boolean, const char *, const char *);
static char *DirLookupAbs(Path *, const char *, const char *);
+
+/*
+ * We use stat(2) a lot, cache the results
+ * mtime and mode are all we care about.
+ */
+struct cache_st {
+ time_t mtime;
+ mode_t mode;
+};
+
+/* minimize changes below */
+static time_t
+Hash_GetTimeValue(Hash_Entry *entry)
+{
+ struct cache_st *cst;
+
+ cst = entry->clientPtr;
+ return cst->mtime;
+}
+
+#define CST_LSTAT 1
+#define CST_UPDATE 2
+
+static int
+cached_stats(Hash_Table *htp, const char *pathname, struct stat *st, int flags)
+{
+ Hash_Entry *entry;
+ struct cache_st *cst;
+ int rc;
+
+ if (!pathname || !pathname[0])
+ return -1;
+
+ entry = Hash_FindEntry(htp, pathname);
+
+ if (entry && (flags & CST_UPDATE) == 0) {
+ cst = entry->clientPtr;
+
+ memset(st, 0, sizeof(*st));
+ st->st_mtime = cst->mtime;
+ st->st_mode = cst->mode;
+ return 0;
+ }
+
+ rc = (flags & CST_LSTAT) ? lstat(pathname, st) : stat(pathname, st);
+ if (rc == -1)
+ return -1;
+
+ if (st->st_mtime == 0)
+ st->st_mtime = 1; /* avoid confusion with missing file */
+
+ if (!entry)
+ entry = Hash_CreateEntry(htp, pathname, NULL);
+ if (!entry->clientPtr)
+ entry->clientPtr = bmake_malloc(sizeof(*cst));
+ cst = entry->clientPtr;
+ cst->mtime = st->st_mtime;
+ cst->mode = st->st_mode;
+
+ return 0;
+}
+
+int
+cached_stat(const char *pathname, void *st)
+{
+ return cached_stats(&mtimes, pathname, st, 0);
+}
+
+int
+cached_lstat(const char *pathname, void *st)
+{
+ return cached_stats(&lmtimes, pathname, st, CST_LSTAT);
+}
+
/*-
*-----------------------------------------------------------------------
* Dir_Init --
@@ -274,6 +349,7 @@ Dir_Init(const char *cdname)
dirSearchPath = Lst_Init(FALSE);
openDirectories = Lst_Init(FALSE);
Hash_InitTable(&mtimes, 0);
+ Hash_InitTable(&lmtimes, 0);
Dir_InitCur(cdname);
@@ -901,7 +977,6 @@ static char *
DirLookupSubdir(Path *p, const char *name)
{
struct stat stb; /* Buffer for stat, if necessary */
- Hash_Entry *entry; /* Entry for mtimes table */
char *file; /* the current filename to check */
if (p != dot) {
@@ -917,9 +992,7 @@ DirLookupSubdir(Path *p, const char *name)
fprintf(debug_file, "checking %s ...\n", file);
}
- if (stat(file, &stb) == 0) {
- if (stb.st_mtime == 0)
- stb.st_mtime = 1;
+ if (cached_stat(file, &stb) == 0) {
/*
* Save the modification time so if it's needed, we don't have
* to fetch it again.
@@ -928,8 +1001,6 @@ DirLookupSubdir(Path *p, const char *name)
fprintf(debug_file, " Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
file);
}
- entry = Hash_CreateEntry(&mtimes, file, NULL);
- Hash_SetTimeValue(entry, stb.st_mtime);
nearmisses += 1;
return (file);
}
@@ -1312,15 +1383,11 @@ Dir_FindFile(const char *name, Lst path)
fprintf(debug_file, " got it (in mtime cache)\n");
}
return(bmake_strdup(name));
- } else if (stat(name, &stb) == 0) {
- if (stb.st_mtime == 0)
- stb.st_mtime = 1;
- entry = Hash_CreateEntry(&mtimes, name, NULL);
+ } else if (cached_stat(name, &stb) == 0) {
if (DEBUG(DIR)) {
fprintf(debug_file, " Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
name);
}
- Hash_SetTimeValue(entry, stb.st_mtime);
return (bmake_strdup(name));
} else {
if (DEBUG(DIR)) {
@@ -1368,7 +1435,7 @@ Dir_FindHereOrAbove(char *here, char *search_path, char *result, int rlen) {
/* try and stat(2) it ... */
snprintf(try, sizeof(try), "%s/%s", dirbase, search_path);
- if (stat(try, &st) != -1) {
+ if (cached_stat(try, &st) != -1) {
/*
* success! if we found a file, chop off
* the filename so we return a directory.
@@ -1489,12 +1556,12 @@ Dir_MTime(GNode *gn, Boolean recheck)
else
entry = NULL;
if (entry != NULL) {
+ stb.st_mtime = Hash_GetTimeValue(entry);
if (DEBUG(DIR)) {
fprintf(debug_file, "Using cached time %s for %s\n",
- Targ_FmtTime(Hash_GetTimeValue(entry)), fullName);
+ Targ_FmtTime(stb.st_mtime), fullName);
}
- stb.st_mtime = Hash_GetTimeValue(entry);
- } else if (stat(fullName, &stb) < 0) {
+ } else if (cached_stats(&mtimes, fullName, &stb, recheck ? CST_UPDATE : 0) < 0) {
if (gn->type & OP_MEMBER) {
if (fullName != gn->path)
free(fullName);
@@ -1502,18 +1569,8 @@ Dir_MTime(GNode *gn, Boolean recheck)
} else {
stb.st_mtime = 0;
}
- } else {
- if (stb.st_mtime == 0) {
- /*
- * 0 handled specially by the code, if the time is really 0,
- * return something else instead
- */
- stb.st_mtime = 1;
- }
- entry = Hash_CreateEntry(&mtimes, fullName, NULL);
- Hash_SetTimeValue(entry, stb.st_mtime);
}
-
+
if (fullName && gn->path == NULL) {
gn->path = fullName;
}
diff --git a/contrib/bmake/hash.h b/contrib/bmake/hash.h
index 31d2ff1..0e3d22d 100644
--- a/contrib/bmake/hash.h
+++ b/contrib/bmake/hash.h
@@ -1,4 +1,4 @@
-/* $NetBSD: hash.h,v 1.10 2009/01/24 10:59:09 dsl Exp $ */
+/* $NetBSD: hash.h,v 1.11 2016/06/07 00:40:00 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -89,10 +89,7 @@ typedef struct Hash_Entry {
struct Hash_Entry *next; /* Used to link together all the
* entries associated with the same
* bucket. */
- union {
- void *clientPtr; /* Arbitrary pointer */
- time_t clientTime; /* Arbitrary Time */
- } clientInfo;
+ void *clientPtr; /* Arbitrary pointer */
unsigned namehash; /* hash value of key */
char name[1]; /* key string */
} Hash_Entry;
@@ -125,8 +122,7 @@ typedef struct Hash_Search {
* Hash_Entry *h;
*/
-#define Hash_GetValue(h) ((h)->clientInfo.clientPtr)
-#define Hash_GetTimeValue(h) ((h)->clientInfo.clientTime)
+#define Hash_GetValue(h) ((h)->clientPtr)
/*
* Hash_SetValue(h, val);
@@ -134,8 +130,7 @@ typedef struct Hash_Search {
* char *val;
*/
-#define Hash_SetValue(h, val) ((h)->clientInfo.clientPtr = (val))
-#define Hash_SetTimeValue(h, val) ((h)->clientInfo.clientTime = (val))
+#define Hash_SetValue(h, val) ((h)->clientPtr = (val))
/*
* Hash_Size(n) returns the number of words in an object of n bytes
diff --git a/contrib/bmake/main.c b/contrib/bmake/main.c
index 57a59cb..20aa9c9 100644
--- a/contrib/bmake/main.c
+++ b/contrib/bmake/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.245 2016/06/03 01:21:59 sjg Exp $ */
+/* $NetBSD: main.c,v 1.247 2016/06/05 01:39:17 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.245 2016/06/03 01:21:59 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.247 2016/06/05 01:39:17 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.245 2016/06/03 01:21:59 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.247 2016/06/05 01:39:17 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -1906,15 +1906,11 @@ cached_realpath(const char *pathname, char *resolved)
rp = Var_Value(pathname, cache, &cp);
if (rp) {
/* a hit */
- if (resolved)
- strlcpy(resolved, rp, MAXPATHLEN);
- else
- resolved = bmake_strdup(rp);
- } else {
- if ((rp = realpath(pathname, resolved))) {
- Var_Set(pathname, rp, cache, 0);
- }
+ strlcpy(resolved, rp, MAXPATHLEN);
+ } else if ((rp = realpath(pathname, resolved))) {
+ Var_Set(pathname, rp, cache, 0);
}
+ free(cp);
return rp ? resolved : NULL;
}
diff --git a/contrib/bmake/make.h b/contrib/bmake/make.h
index b3962f0..0fe12ab 100644
--- a/contrib/bmake/make.h
+++ b/contrib/bmake/make.h
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.99 2016/06/03 01:21:59 sjg Exp $ */
+/* $NetBSD: make.h,v 1.100 2016/06/07 00:40:00 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -506,6 +506,8 @@ void Main_ExportMAKEFLAGS(Boolean);
Boolean Main_SetObjdir(const char *);
int mkTempFile(const char *, char **);
int str2Lst_Append(Lst, char *, const char *);
+int cached_lstat(const char *, void *);
+int cached_stat(const char *, void *);
#define VARF_UNDEFERR 1
#define VARF_WANTRES 2
diff --git a/contrib/bmake/meta.c b/contrib/bmake/meta.c
index 4f54a00..dcd396d 100644
--- a/contrib/bmake/meta.c
+++ b/contrib/bmake/meta.c
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.c,v 1.60 2016/06/04 22:17:14 sjg Exp $ */
+/* $NetBSD: meta.c,v 1.61 2016/06/07 00:40:00 sjg Exp $ */
/*
* Implement 'meta' mode.
@@ -429,7 +429,7 @@ meta_needed(GNode *gn, const char *dname, const char *tname,
}
/* The object directory may not exist. Check it.. */
- if (stat(dname, &fs) != 0) {
+ if (cached_stat(dname, &fs) != 0) {
if (verbose)
fprintf(debug_file, "Skipping meta for %s: no .OBJDIR\n",
gn->name);
@@ -1238,8 +1238,8 @@ meta_oodate(GNode *gn, Boolean oodate)
if ((strstr("tmp", p)))
break;
- if ((link_src != NULL && lstat(p, &fs) < 0) ||
- (link_src == NULL && stat(p, &fs) < 0)) {
+ if ((link_src != NULL && cached_lstat(p, &fs) < 0) ||
+ (link_src == NULL && cached_stat(p, &fs) < 0)) {
if (Lst_Find(missingFiles, p, string_match) == NULL)
Lst_AtEnd(missingFiles, bmake_strdup(p));
}
@@ -1328,7 +1328,7 @@ meta_oodate(GNode *gn, Boolean oodate)
if (DEBUG(META))
fprintf(debug_file, "%s: %d: looking for: %s\n", fname, lineno, *sdp);
#endif
- if (stat(*sdp, &fs) == 0) {
+ if (cached_stat(*sdp, &fs) == 0) {
found = 1;
p = *sdp;
}
diff --git a/contrib/ipfilter/man/ipf.8 b/contrib/ipfilter/man/ipf.8
index 6e88a9d..afd3c61 100644
--- a/contrib/ipfilter/man/ipf.8
+++ b/contrib/ipfilter/man/ipf.8
@@ -35,7 +35,10 @@ which they appear when given to \fBipf\fP.
.SH OPTIONS
.TP
.B \-6
-This option is required to parse IPv6 rules and to have them loaded.
+IPv4 and IPv6 rules are stored in a single table and can be read from a
+single file. This option is no longer required to load IPv6 rules. This
+option is ignored when specified with the -F option and the -F option
+will flush IPv4 rules even if this option is specified.
.TP
.B \-A
Set the list to make changes to the active list (default).
diff --git a/contrib/jemalloc/ChangeLog b/contrib/jemalloc/ChangeLog
index c9ce7c4..532255d 100644
--- a/contrib/jemalloc/ChangeLog
+++ b/contrib/jemalloc/ChangeLog
@@ -4,6 +4,17 @@ brevity. Much more detail can be found in the git revision history:
https://github.com/jemalloc/jemalloc
+* 4.2.1 (June 8, 2016)
+
+ Bug fixes:
+ - Fix bootstrapping issues for configurations that require allocation during
+ tsd initialization (e.g. --disable-tls). (@cferris1000, @jasone)
+ - Fix gettimeofday() version of nstime_update(). (@ronawho)
+ - Fix Valgrind regressions in calloc() and chunk_alloc_wrapper(). (@ronawho)
+ - Fix potential VM map fragmentation regression. (@jasone)
+ - Fix opt_zero-triggered in-place huge reallocation zeroing. (@jasone)
+ - Fix heap profiling context leaks in reallocation edge cases. (@jasone)
+
* 4.2.0 (May 12, 2016)
New features:
diff --git a/contrib/jemalloc/FREEBSD-diffs b/contrib/jemalloc/FREEBSD-diffs
index 6b5e52b..df0a538 100644
--- a/contrib/jemalloc/FREEBSD-diffs
+++ b/contrib/jemalloc/FREEBSD-diffs
@@ -79,7 +79,7 @@ index b1de2b6..da6b6d2 100644
JEMALLOC_ALWAYS_INLINE size_t
diff --git a/include/jemalloc/internal/jemalloc_internal.h.in b/include/jemalloc/internal/jemalloc_internal.h.in
-index 51bf897..7de22ea 100644
+index 8f82edd..78e2df2 100644
--- a/include/jemalloc/internal/jemalloc_internal.h.in
+++ b/include/jemalloc/internal/jemalloc_internal.h.in
@@ -8,6 +8,9 @@
@@ -335,7 +335,7 @@ index f943891..47d032c 100755
+#include "jemalloc_FreeBSD.h"
EOF
diff --git a/src/jemalloc.c b/src/jemalloc.c
-index 40eb2ea..666c49d 100644
+index 5d1f493..46dd1d1 100644
--- a/src/jemalloc.c
+++ b/src/jemalloc.c
@@ -4,6 +4,10 @@
diff --git a/contrib/jemalloc/VERSION b/contrib/jemalloc/VERSION
index b4ecbbf..b17fa1d 100644
--- a/contrib/jemalloc/VERSION
+++ b/contrib/jemalloc/VERSION
@@ -1 +1 @@
-4.2.0-1-gdc7ff6306d7a15b53479e2fb8e5546404b82e6fc
+4.2.1-0-g3de035335255d553bdb344c32ffdb603816195d8
diff --git a/contrib/jemalloc/doc/jemalloc.3 b/contrib/jemalloc/doc/jemalloc.3
index 21d40c1..26fb02a 100644
--- a/contrib/jemalloc/doc/jemalloc.3
+++ b/contrib/jemalloc/doc/jemalloc.3
@@ -2,12 +2,12 @@
.\" Title: JEMALLOC
.\" Author: Jason Evans
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
-.\" Date: 05/12/2016
+.\" Date: 06/08/2016
.\" Manual: User Manual
-.\" Source: jemalloc 4.2.0-1-gdc7ff6306d7a15b53479e2fb8e5546404b82e6fc
+.\" Source: jemalloc 4.2.1-0-g3de035335255d553bdb344c32ffdb603816195d8
.\" Language: English
.\"
-.TH "JEMALLOC" "3" "05/12/2016" "jemalloc 4.2.0-1-gdc7ff6306d7a" "User Manual"
+.TH "JEMALLOC" "3" "06/08/2016" "jemalloc 4.2.1-0-g3de035335255" "User Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -31,7 +31,7 @@
jemalloc \- general purpose memory allocation functions
.SH "LIBRARY"
.PP
-This manual describes jemalloc 4\&.2\&.0\-1\-gdc7ff6306d7a15b53479e2fb8e5546404b82e6fc\&. More information can be found at the
+This manual describes jemalloc 4\&.2\&.1\-0\-g3de035335255d553bdb344c32ffdb603816195d8\&. More information can be found at the
\m[blue]\fBjemalloc website\fR\m[]\&\s-2\u[1]\d\s+2\&.
.PP
The following configuration options are enabled in libc\*(Aqs built\-in jemalloc:
diff --git a/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h b/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h
index a694869..49f14a5 100644
--- a/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h
+++ b/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h
@@ -751,7 +751,7 @@ sa2u(size_t size, size_t alignment)
* Calculate the size of the over-size run that arena_palloc()
* would need to allocate in order to guarantee the alignment.
*/
- if (usize + large_pad + alignment <= arena_maxrun)
+ if (usize + large_pad + alignment - PAGE <= arena_maxrun)
return (usize);
}
@@ -781,7 +781,7 @@ sa2u(size_t size, size_t alignment)
* Calculate the multi-chunk mapping that huge_palloc() would need in
* order to guarantee the alignment.
*/
- if (usize + alignment < usize) {
+ if (usize + alignment - PAGE < usize) {
/* size_t overflow. */
return (0);
}
diff --git a/contrib/jemalloc/include/jemalloc/internal/prof.h b/contrib/jemalloc/include/jemalloc/internal/prof.h
index 691e153..21dff5f 100644
--- a/contrib/jemalloc/include/jemalloc/internal/prof.h
+++ b/contrib/jemalloc/include/jemalloc/internal/prof.h
@@ -513,6 +513,7 @@ prof_realloc(tsd_t *tsd, const void *ptr, size_t usize, prof_tctx_t *tctx,
* though its actual usize was insufficient to cross the
* sample threshold.
*/
+ prof_alloc_rollback(tsd, tctx, true);
tctx = (prof_tctx_t *)(uintptr_t)1U;
}
}
diff --git a/contrib/jemalloc/include/jemalloc/jemalloc.h b/contrib/jemalloc/include/jemalloc/jemalloc.h
index 394699f..d2c876e 100644
--- a/contrib/jemalloc/include/jemalloc/jemalloc.h
+++ b/contrib/jemalloc/include/jemalloc/jemalloc.h
@@ -87,12 +87,12 @@ extern "C" {
#include <limits.h>
#include <strings.h>
-#define JEMALLOC_VERSION "4.2.0-1-gdc7ff6306d7a15b53479e2fb8e5546404b82e6fc"
+#define JEMALLOC_VERSION "4.2.1-0-g3de035335255d553bdb344c32ffdb603816195d8"
#define JEMALLOC_VERSION_MAJOR 4
#define JEMALLOC_VERSION_MINOR 2
-#define JEMALLOC_VERSION_BUGFIX 0
-#define JEMALLOC_VERSION_NREV 1
-#define JEMALLOC_VERSION_GID "dc7ff6306d7a15b53479e2fb8e5546404b82e6fc"
+#define JEMALLOC_VERSION_BUGFIX 1
+#define JEMALLOC_VERSION_NREV 0
+#define JEMALLOC_VERSION_GID "3de035335255d553bdb344c32ffdb603816195d8"
# define MALLOCX_LG_ALIGN(la) ((int)(la))
# if LG_SIZEOF_PTR == 2
diff --git a/contrib/jemalloc/src/arena.c b/contrib/jemalloc/src/arena.c
index c605bcd..ce62590 100644
--- a/contrib/jemalloc/src/arena.c
+++ b/contrib/jemalloc/src/arena.c
@@ -2687,7 +2687,7 @@ arena_palloc_large(tsdn_t *tsdn, arena_t *arena, size_t usize, size_t alignment,
return (NULL);
alignment = PAGE_CEILING(alignment);
- alloc_size = usize + large_pad + alignment;
+ alloc_size = usize + large_pad + alignment - PAGE;
malloc_mutex_lock(tsdn, &arena->lock);
run = arena_run_alloc_large(tsdn, arena, alloc_size, false);
diff --git a/contrib/jemalloc/src/chunk.c b/contrib/jemalloc/src/chunk.c
index adc666f..f292c980 100644
--- a/contrib/jemalloc/src/chunk.c
+++ b/contrib/jemalloc/src/chunk.c
@@ -421,15 +421,11 @@ chunk_arena_get(tsdn_t *tsdn, unsigned arena_ind)
}
static void *
-chunk_alloc_default(void *new_addr, size_t size, size_t alignment, bool *zero,
- bool *commit, unsigned arena_ind)
+chunk_alloc_default_impl(tsdn_t *tsdn, arena_t *arena, void *new_addr,
+ size_t size, size_t alignment, bool *zero, bool *commit)
{
void *ret;
- tsdn_t *tsdn;
- arena_t *arena;
- tsdn = tsdn_fetch();
- arena = chunk_arena_get(tsdn, arena_ind);
ret = chunk_alloc_core(tsdn, arena, new_addr, size, alignment, zero,
commit, arena->dss_prec);
if (ret == NULL)
@@ -441,6 +437,20 @@ chunk_alloc_default(void *new_addr, size_t size, size_t alignment, bool *zero,
}
static void *
+chunk_alloc_default(void *new_addr, size_t size, size_t alignment, bool *zero,
+ bool *commit, unsigned arena_ind)
+{
+ tsdn_t *tsdn;
+ arena_t *arena;
+
+ tsdn = tsdn_fetch();
+ arena = chunk_arena_get(tsdn, arena_ind);
+
+ return (chunk_alloc_default_impl(tsdn, arena, new_addr, size, alignment,
+ zero, commit));
+}
+
+static void *
chunk_alloc_retained(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks,
void *new_addr, size_t size, size_t alignment, bool *zero, bool *commit)
{
@@ -472,14 +482,23 @@ chunk_alloc_wrapper(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks,
ret = chunk_alloc_retained(tsdn, arena, chunk_hooks, new_addr, size,
alignment, zero, commit);
if (ret == NULL) {
- ret = chunk_hooks->alloc(new_addr, size, alignment, zero,
- commit, arena->ind);
+ if (chunk_hooks->alloc == chunk_alloc_default) {
+ /* Call directly to propagate tsdn. */
+ ret = chunk_alloc_default_impl(tsdn, arena, new_addr,
+ size, alignment, zero, commit);
+ } else {
+ ret = chunk_hooks->alloc(new_addr, size, alignment,
+ zero, commit, arena->ind);
+ }
+
if (ret == NULL)
return (NULL);
+
+ if (config_valgrind && chunk_hooks->alloc !=
+ chunk_alloc_default)
+ JEMALLOC_VALGRIND_MAKE_MEM_UNDEFINED(ret, chunksize);
}
- if (config_valgrind && chunk_hooks->alloc != chunk_alloc_default)
- JEMALLOC_VALGRIND_MAKE_MEM_UNDEFINED(ret, chunksize);
return (ret);
}
@@ -591,19 +610,30 @@ chunk_dalloc_cache(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks,
}
static bool
-chunk_dalloc_default(void *chunk, size_t size, bool committed,
- unsigned arena_ind)
+chunk_dalloc_default_impl(tsdn_t *tsdn, void *chunk, size_t size)
{
- if (!have_dss || !chunk_in_dss(tsdn_fetch(), chunk))
+ if (!have_dss || !chunk_in_dss(tsdn, chunk))
return (chunk_dalloc_mmap(chunk, size));
return (true);
}
+static bool
+chunk_dalloc_default(void *chunk, size_t size, bool committed,
+ unsigned arena_ind)
+{
+ tsdn_t *tsdn;
+
+ tsdn = tsdn_fetch();
+
+ return (chunk_dalloc_default_impl(tsdn, chunk, size));
+}
+
void
chunk_dalloc_wrapper(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks,
void *chunk, size_t size, bool zeroed, bool committed)
{
+ bool err;
assert(chunk != NULL);
assert(CHUNK_ADDR2BASE(chunk) == chunk);
@@ -612,7 +642,13 @@ chunk_dalloc_wrapper(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks,
chunk_hooks_assure_initialized(tsdn, arena, chunk_hooks);
/* Try to deallocate. */
- if (!chunk_hooks->dalloc(chunk, size, committed, arena->ind))
+ if (chunk_hooks->dalloc == chunk_dalloc_default) {
+ /* Call directly to propagate tsdn. */
+ err = chunk_dalloc_default_impl(tsdn, chunk, size);
+ } else
+ err = chunk_hooks->dalloc(chunk, size, committed, arena->ind);
+
+ if (!err)
return;
/* Try to decommit; purge if that fails. */
if (committed) {
@@ -681,26 +717,34 @@ chunk_split_default(void *chunk, size_t size, size_t size_a, size_t size_b,
}
static bool
-chunk_merge_default(void *chunk_a, size_t size_a, void *chunk_b, size_t size_b,
- bool committed, unsigned arena_ind)
+chunk_merge_default_impl(tsdn_t *tsdn, void *chunk_a, void *chunk_b)
{
if (!maps_coalesce)
return (true);
- if (have_dss) {
- tsdn_t *tsdn = tsdn_fetch();
- if (chunk_in_dss(tsdn, chunk_a) != chunk_in_dss(tsdn, chunk_b))
- return (true);
- }
+ if (have_dss && chunk_in_dss(tsdn, chunk_a) != chunk_in_dss(tsdn,
+ chunk_b))
+ return (true);
return (false);
}
+static bool
+chunk_merge_default(void *chunk_a, size_t size_a, void *chunk_b, size_t size_b,
+ bool committed, unsigned arena_ind)
+{
+ tsdn_t *tsdn;
+
+ tsdn = tsdn_fetch();
+
+ return (chunk_merge_default_impl(tsdn, chunk_a, chunk_b));
+}
+
static rtree_node_elm_t *
chunks_rtree_node_alloc(size_t nelms)
{
- return ((rtree_node_elm_t *)base_alloc(tsdn_fetch(), nelms *
+ return ((rtree_node_elm_t *)base_alloc(TSDN_NULL, nelms *
sizeof(rtree_node_elm_t)));
}
diff --git a/contrib/jemalloc/src/chunk_mmap.c b/contrib/jemalloc/src/chunk_mmap.c
index f95ae75..73fc497 100644
--- a/contrib/jemalloc/src/chunk_mmap.c
+++ b/contrib/jemalloc/src/chunk_mmap.c
@@ -9,7 +9,7 @@ chunk_alloc_mmap_slow(size_t size, size_t alignment, bool *zero, bool *commit)
void *ret;
size_t alloc_size;
- alloc_size = size + alignment;
+ alloc_size = size + alignment - PAGE;
/* Beware size_t wrap-around. */
if (alloc_size < size)
return (NULL);
diff --git a/contrib/jemalloc/src/huge.c b/contrib/jemalloc/src/huge.c
index 1aa02a0..3a2877c 100644
--- a/contrib/jemalloc/src/huge.c
+++ b/contrib/jemalloc/src/huge.c
@@ -262,19 +262,19 @@ huge_ralloc_no_move_expand(tsdn_t *tsdn, void *ptr, size_t oldsize,
malloc_mutex_unlock(tsdn, &arena->huge_mtx);
/*
- * Copy zero into is_zeroed_chunk and pass the copy to chunk_alloc(), so
- * that it is possible to make correct junk/zero fill decisions below.
+ * Use is_zeroed_chunk to detect whether the trailing memory is zeroed,
+ * update extent's zeroed field, and zero as necessary.
*/
- is_zeroed_chunk = zero;
-
+ is_zeroed_chunk = false;
if (arena_chunk_ralloc_huge_expand(tsdn, arena, ptr, oldsize, usize,
&is_zeroed_chunk))
return (true);
malloc_mutex_lock(tsdn, &arena->huge_mtx);
- /* Update the size of the huge allocation. */
huge_node_unset(ptr, node);
extent_node_size_set(node, usize);
+ extent_node_zeroed_set(node, extent_node_zeroed_get(node) &&
+ is_zeroed_chunk);
huge_node_reset(tsdn, ptr, node);
malloc_mutex_unlock(tsdn, &arena->huge_mtx);
diff --git a/contrib/jemalloc/src/jemalloc.c b/contrib/jemalloc/src/jemalloc.c
index 666c49d..46dd1d1 100644
--- a/contrib/jemalloc/src/jemalloc.c
+++ b/contrib/jemalloc/src/jemalloc.c
@@ -1743,7 +1743,7 @@ je_calloc(size_t num, size_t size)
ret = ialloc_body(num_size, true, &tsdn, &usize, true);
ialloc_post_check(ret, tsdn, usize, "calloc", true, true);
UTRACE(0, num_size, ret);
- JEMALLOC_VALGRIND_MALLOC(ret != NULL, tsdn, ret, usize, false);
+ JEMALLOC_VALGRIND_MALLOC(ret != NULL, tsdn, ret, usize, true);
}
return (ret);
@@ -2226,7 +2226,7 @@ irallocx_prof(tsd_t *tsd, void *old_ptr, size_t old_usize, size_t size,
prof_active = prof_active_get_unlocked();
old_tctx = prof_tctx_get(tsd_tsdn(tsd), old_ptr);
- tctx = prof_alloc_prep(tsd, *usize, prof_active, true);
+ tctx = prof_alloc_prep(tsd, *usize, prof_active, false);
if (unlikely((uintptr_t)tctx != (uintptr_t)1U)) {
p = irallocx_prof_sample(tsd, old_ptr, old_usize, *usize,
alignment, zero, tcache, arena, tctx);
@@ -2235,7 +2235,7 @@ irallocx_prof(tsd_t *tsd, void *old_ptr, size_t old_usize, size_t size,
tcache, arena);
}
if (unlikely(p == NULL)) {
- prof_alloc_rollback(tsd, tctx, true);
+ prof_alloc_rollback(tsd, tctx, false);
return (NULL);
}
@@ -2250,7 +2250,7 @@ irallocx_prof(tsd_t *tsd, void *old_ptr, size_t old_usize, size_t size,
*/
*usize = isalloc(tsd_tsdn(tsd), p, config_prof);
}
- prof_realloc(tsd, p, *usize, tctx, prof_active, true, old_ptr,
+ prof_realloc(tsd, p, *usize, tctx, prof_active, false, old_ptr,
old_usize, old_tctx);
return (p);
diff --git a/contrib/jemalloc/src/nstime.c b/contrib/jemalloc/src/nstime.c
index 26e49dc..aad2c26 100644
--- a/contrib/jemalloc/src/nstime.c
+++ b/contrib/jemalloc/src/nstime.c
@@ -128,9 +128,11 @@ nstime_update(nstime_t *time)
time->ns = ts.tv_sec * BILLION + ts.tv_nsec;
}
#else
- struct timeval tv;
- gettimeofday(&tv, NULL);
- time->ns = tv.tv_sec * BILLION + tv.tv_usec * 1000;
+ {
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ time->ns = tv.tv_sec * BILLION + tv.tv_usec * 1000;
+ }
#endif
/* Handle non-monotonic clocks. */
diff --git a/contrib/ldns-host/Makefile b/contrib/ldns-host/Makefile
index 9d07a58..ba79ea8 100644
--- a/contrib/ldns-host/Makefile
+++ b/contrib/ldns-host/Makefile
@@ -6,11 +6,11 @@ LOCALBASE?=/usr/local
PREFIX?=${LOCALBASE}
MANDIR?=${PREFIX}/man
-XCFLAGS=${CFLAGS} -I${LOCALBASE}/include
+XCFLAGS=${CFLAGS} -I${LOCALBASE}/include -std=c99 -Wall -Wextra -pedantic
XLDFLAGS=${LDFLAGS} -L${LOCALBASE}/lib -lldns
${PROG}: ${SRC}
- ${CC} -o $@ ${XCFLAGS} ${XLDFLAGS} ${SRC}
+ ${CC} -o $@ ${XCFLAGS} ${SRC} ${XLDFLAGS}
clean:
rm -f ${PROG}
diff --git a/contrib/ldns-host/ldns-host.1 b/contrib/ldns-host/ldns-host.1
index 3a85ac4..38cffa6 100644
--- a/contrib/ldns-host/ldns-host.1
+++ b/contrib/ldns-host/ldns-host.1
@@ -236,9 +236,6 @@ commands, while
.Sq host
from BIND9 uses whatever command was specified last.
.It
-Multi-packet zone transfers are not supported; only the first
-response packet is printed.
-.It
.Sq Pseudosection TSIG
is missing from verbose packet output.
.El
diff --git a/contrib/ldns-host/ldns-host.c b/contrib/ldns-host/ldns-host.c
index 85c7dcb..3184f68 100644
--- a/contrib/ldns-host/ldns-host.c
+++ b/contrib/ldns-host/ldns-host.c
@@ -7,16 +7,14 @@
* without any warranty.
*/
-#include <netinet/in.h>
-
+#include <ldns/ldns.h>
#include <limits.h>
#include <netdb.h>
+#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#include <ldns/ldns.h>
-
/* General utilities.
*/
@@ -159,11 +157,108 @@ memerr:
}
static ldns_status
+ldns_tcp_start(ldns_resolver *res, ldns_pkt *qpkt, int nameserver) {
+ /* This routine is based on ldns_axfr_start, with the major
+ * difference in that it takes a query packet explicitly.
+ */
+ struct sockaddr_storage *ns = NULL;
+ size_t ns_len = 0;
+ ldns_buffer *qbuf = NULL;
+ ldns_status status;
+
+ ns = ldns_rdf2native_sockaddr_storage(
+ res->_nameservers[nameserver], ldns_resolver_port(res), &ns_len);
+ if (ns == NULL) {
+ status = LDNS_STATUS_MEM_ERR;
+ goto error;
+ }
+
+ res->_socket = ldns_tcp_connect(
+ ns, (socklen_t)ns_len, ldns_resolver_timeout(res));
+ if (res->_socket <= 0) {
+ status = LDNS_STATUS_ADDRESS_ERR;
+ goto error;
+ }
+
+ qbuf = ldns_buffer_new(LDNS_MAX_PACKETLEN);
+ if (qbuf == NULL) {
+ status = LDNS_STATUS_MEM_ERR;
+ goto error;
+ }
+
+ status = ldns_pkt2buffer_wire(qbuf, qpkt);
+ if (status != LDNS_STATUS_OK)
+ goto error;
+
+ if (ldns_tcp_send_query(qbuf, res->_socket, ns, (socklen_t)ns_len) == 0) {
+ status = LDNS_STATUS_NETWORK_ERR;
+ goto error;
+ }
+
+ ldns_buffer_free(qbuf);
+ free(ns);
+ return LDNS_STATUS_OK;
+
+error:
+ ldns_buffer_free(qbuf);
+ free(ns);
+ if (res->_socket > 0) {
+ close(res->_socket);
+ res->_socket = 0;
+ }
+ return status;
+}
+
+static ldns_status
+ldns_tcp_read(ldns_pkt **answer, ldns_resolver *res) {
+ ldns_status status;
+ struct timeval t1, t2;
+ uint8_t *data;
+ size_t size;
+
+ if (res->_socket <= 0)
+ return LDNS_STATUS_ERR;
+
+ gettimeofday(&t1, NULL);
+ data = ldns_tcp_read_wire_timeout(
+ res->_socket, &size, ldns_resolver_timeout(res));
+ if (data == NULL)
+ goto error;
+
+ status = ldns_wire2pkt(answer, data, size);
+ free(data);
+ if (status != LDNS_STATUS_OK)
+ goto error;
+
+ gettimeofday(&t2, NULL);
+ ldns_pkt_set_querytime(*answer,
+ (uint32_t)((t2.tv_sec - t1.tv_sec)*1000) +
+ (t2.tv_usec - t1.tv_usec)/1000);
+ ldns_pkt_set_timestamp(*answer, t2);
+ return status;
+
+error:
+ close(res->_socket);
+ res->_socket = 0;
+ return LDNS_STATUS_ERR;
+}
+
+static void
+ldns_tcp_close(ldns_resolver *res) {
+ if (res->_socket > 0) {
+ close(res->_socket);
+ res->_socket = 0;
+ }
+}
+
+static ldns_status
ldns_resolver_send_to(ldns_pkt **answer, ldns_resolver *res,
const ldns_rdf *name, ldns_rr_type t, ldns_rr_class c,
- uint16_t flags, uint32_t ixfr_serial, int nameserver) {
- ldns_status status;
+ uint16_t flags, uint32_t ixfr_serial, int nameserver,
+ bool close_tcp) {
+ ldns_status status = LDNS_STATUS_OK;
ldns_pkt *qpkt;
+ struct timeval now;
int nscnt = ldns_resolver_nameserver_count(res);
ldns_rdf **ns = ldns_resolver_nameservers(res);
@@ -173,12 +268,38 @@ ldns_resolver_send_to(ldns_pkt **answer, ldns_resolver *res,
ldns_resolver_set_rtt(res, &rtt[nameserver]);
ldns_resolver_set_nameserver_count(res, 1);
- status = ldns_resolver_prepare_query_pkt(&qpkt, res, name, t, c, flags);
- if (status == LDNS_STATUS_OK && t == LDNS_RR_TYPE_IXFR)
+ /* The next fragment should have been a call to
+ * ldns_resolver_prepare_query_pkt(), but starting with ldns
+ * version 1.6.17 that function tries to add it's own SOA
+ * records when rr_type is LDNS_RR_TYPE_IXFR, and we don't
+ * want that.
+ */
+ qpkt = ldns_pkt_query_new(ldns_rdf_clone(name), t, c, flags);
+ if (qpkt == NULL) {
+ status = LDNS_STATUS_ERR;
+ goto done;
+ }
+ now.tv_sec = time(NULL);
+ now.tv_usec = 0;
+ ldns_pkt_set_timestamp(qpkt, now);
+ ldns_pkt_set_random_id(qpkt);
+
+ if (t == LDNS_RR_TYPE_IXFR) {
status = ldns_pkt_push_rr_soa(qpkt,
LDNS_SECTION_AUTHORITY, name, c, ixfr_serial);
- if (status == LDNS_STATUS_OK)
+ if (status != LDNS_STATUS_OK) goto done;
+ }
+ if (close_tcp) {
status = ldns_resolver_send_pkt(answer, res, qpkt);
+ } else {
+ status = ldns_tcp_start(res, qpkt, 0);
+ if (status != LDNS_STATUS_OK) goto done;
+ status = ldns_tcp_read(answer, res);
+ if (status != LDNS_STATUS_OK) goto done;
+ ldns_pkt_set_answerfrom(*answer, ldns_rdf_clone(ns[0]));
+ }
+
+done:
ldns_pkt_free(qpkt);
ldns_resolver_set_nameservers(res, ns);
@@ -203,9 +324,9 @@ ldns_pkt_filter_answer(ldns_pkt *pkt, ldns_rr_type type) {
type == rrtype ||
(type == LDNS_RR_TYPE_AXFR &&
(rrtype == LDNS_RR_TYPE_A ||
- rrtype == LDNS_RR_TYPE_AAAA ||
- rrtype == LDNS_RR_TYPE_NS ||
- rrtype == LDNS_RR_TYPE_PTR)))
+ rrtype == LDNS_RR_TYPE_AAAA ||
+ rrtype == LDNS_RR_TYPE_NS ||
+ rrtype == LDNS_RR_TYPE_PTR)))
ldns_rr_list_set_rr(rrlist, rr, j++);
}
ldns_rr_list_set_rr_count(rrlist, j);
@@ -438,7 +559,7 @@ print_received_line(ldns_resolver *res, ldns_pkt *pkt) {
#define DEFAULT_TCP_TIMEOUT 10
#define DEFAULT_UDP_TIMEOUT 5
-enum operation_mode { M_AXFR, M_DEFAULT_Q, M_SINGLE_Q, M_SOA };
+enum operation_mode { M_AXFR, M_IXFR, M_DEFAULT_Q, M_SINGLE_Q, M_SOA };
static enum operation_mode o_mode = M_DEFAULT_Q;
static bool o_ignore_servfail = true;
@@ -454,15 +575,15 @@ static int o_ipversion = LDNS_RESOLV_INETANY;
static int o_ndots = 1;
static int o_retries = 1;
static ldns_rr_class o_rrclass = LDNS_RR_CLASS_IN;
-static ldns_rr_type o_rrtype = LDNS_RR_TYPE_A;
+static ldns_rr_type o_rrtype = (ldns_rr_type)-1;
static time_t o_timeout = 0;
static uint32_t o_ixfr_serial = 0;
static void
usage(void) {
- fputs(
- "Usage: host [-aCdilrsTvw46] [-c class] [-N ndots] [-R number]\n"
- " [-t type] [-W wait] name [server]\n"
+ fprintf(stderr,
+ "Usage: %s [-aCdilrsTvw46] [-c class] [-N ndots] [-R number]\n"
+ " %*c [-t type] [-W wait] name [server]\n"
"\t-a same as -v -t ANY\n"
"\t-C query SOA records from all authoritative name servers\n"
"\t-c use this query class (IN, CH, HS, etc)\n"
@@ -480,7 +601,7 @@ usage(void) {
"\t-W wait this many seconds for a reply\n"
"\t-4 use IPv4 only\n"
"\t-6 use IPv6 only\n",
- stderr);
+ progname, (int)strlen(progname), ' ');
exit(1);
}
@@ -513,7 +634,8 @@ parse_args(int argc, char *argv[]) {
case 'i': o_ip6_int = true; break;
case 'l':
o_mode = M_AXFR;
- o_rrtype = LDNS_RR_TYPE_AXFR;
+ if (o_rrtype == (ldns_rr_type)-1)
+ o_rrtype = LDNS_RR_TYPE_AXFR;
o_tcp = true;
break;
case 'N':
@@ -542,13 +664,15 @@ parse_args(int argc, char *argv[]) {
if (o_rrtype <= 0)
die(2, "invalid type: %s\n", optarg);
}
- if (o_rrtype == LDNS_RR_TYPE_AXFR || o_rrtype == LDNS_RR_TYPE_IXFR)
- o_tcp = true;
if (o_rrtype == LDNS_RR_TYPE_AXFR) {
o_mode = M_AXFR;
o_rrtype = LDNS_RR_TYPE_ANY;
o_verbose = true;
}
+ if (o_rrtype == LDNS_RR_TYPE_IXFR) {
+ o_mode = M_IXFR;
+ o_rrtype = LDNS_RR_TYPE_ANY;
+ }
break;
case 'v': o_verbose = true; break;
case 'w':
@@ -574,6 +698,8 @@ parse_args(int argc, char *argv[]) {
o_server = argv[1];
o_print_pkt_server = true;
}
+ if (o_rrtype == (ldns_rr_type)-1)
+ o_rrtype = LDNS_RR_TYPE_A;
}
static ldns_rdf*
@@ -602,7 +728,7 @@ safe_dname_cat_clone(const ldns_rdf *rd1, const ldns_rdf *rd2) {
}
static bool
-query(ldns_resolver *res, ldns_rdf *domain, ldns_pkt **pkt) {
+query(ldns_resolver *res, ldns_rdf *domain, ldns_pkt **pkt, bool close_tcp) {
ldns_status status;
ldns_pkt_rcode rcode;
int i, cnt;
@@ -614,7 +740,8 @@ query(ldns_resolver *res, ldns_rdf *domain, ldns_pkt **pkt) {
}
for (cnt = ldns_resolver_nameserver_count(res), i = 0; i < cnt; i++) {
status = ldns_resolver_send_to(pkt, res, domain, o_rrtype,
- o_rrclass, o_recursive ? LDNS_RD : 0, o_ixfr_serial, i);
+ o_rrclass, o_recursive ? LDNS_RD : 0, o_ixfr_serial, i,
+ close_tcp);
if (status != LDNS_STATUS_OK) {
*pkt = NULL;
continue;
@@ -624,7 +751,8 @@ query(ldns_resolver *res, ldns_rdf *domain, ldns_pkt **pkt) {
printf(";; Truncated, retrying in TCP mode.\n");
ldns_resolver_set_usevc(res, true);
status = ldns_resolver_send_to(pkt, res, domain, o_rrtype,
- o_rrclass, o_recursive ? LDNS_RD : 0, o_ixfr_serial, i);
+ o_rrclass, o_recursive ? LDNS_RD : 0, o_ixfr_serial, i,
+ close_tcp);
ldns_resolver_set_usevc(res, false);
if (status != LDNS_STATUS_OK)
continue;
@@ -642,16 +770,17 @@ query(ldns_resolver *res, ldns_rdf *domain, ldns_pkt **pkt) {
}
static ldns_rdf *
-search(ldns_resolver *res, ldns_rdf *domain, ldns_pkt **pkt, bool absolute) {
+search(ldns_resolver *res, ldns_rdf *domain, ldns_pkt **pkt,
+ bool absolute, bool close_tcp) {
ldns_rdf *dname, **searchlist;
int i, n;
- if (absolute && query(res, domain, pkt))
+ if (absolute && query(res, domain, pkt, close_tcp))
return domain;
if ((dname = ldns_resolver_domain(res)) != NULL) {
dname = safe_dname_cat_clone(domain, dname);
- if (query(res, dname, pkt))
+ if (query(res, dname, pkt, close_tcp))
return dname;
}
@@ -659,11 +788,11 @@ search(ldns_resolver *res, ldns_rdf *domain, ldns_pkt **pkt, bool absolute) {
n = ldns_resolver_searchlist_count(res);
for (i = 0; i < n; i++) {
dname = safe_dname_cat_clone(domain, searchlist[i]);
- if (query(res, dname, pkt))
+ if (query(res, dname, pkt, close_tcp))
return dname;
}
- if (!absolute && query(res, domain, pkt))
+ if (!absolute && query(res, domain, pkt, close_tcp))
return domain;
return NULL;
@@ -691,7 +820,7 @@ report(ldns_resolver *res, ldns_rdf *domain, ldns_pkt *pkt) {
print_pkt_verbose(pkt);
} else {
print_pkt_short(pkt, o_print_rr_server);
- if (o_mode != M_DEFAULT_Q &&
+ if (o_mode == M_SINGLE_Q &&
ldns_rr_list_rr_count(ldns_pkt_answer(pkt)) == 0) {
print_rdf_nodot(domain);
printf(" has no ");
@@ -709,7 +838,7 @@ doquery(ldns_resolver *res, ldns_rdf *domain) {
ldns_pkt *pkt;
bool q;
- q = query(res, domain, &pkt);
+ q = query(res, domain, &pkt, true);
report(res, domain, pkt);
return q;
}
@@ -719,7 +848,7 @@ doquery_filtered(ldns_resolver *res, ldns_rdf *domain) {
ldns_pkt *pkt;
bool q;
- q = query(res, domain, &pkt);
+ q = query(res, domain, &pkt, true);
ldns_pkt_filter_answer(pkt, o_rrtype);
report(res, domain, pkt);
return q;
@@ -730,7 +859,7 @@ dosearch(ldns_resolver *res, ldns_rdf *domain, bool absolute) {
ldns_pkt *pkt;
ldns_rdf *dname;
- dname = search(res, domain, &pkt, absolute);
+ dname = search(res, domain, &pkt, absolute, true);
report(res, dname != NULL ? dname : domain, pkt);
return o_mode != M_DEFAULT_Q ? (dname != NULL) :
(dname != NULL) &&
@@ -739,17 +868,44 @@ dosearch(ldns_resolver *res, ldns_rdf *domain, bool absolute) {
}
static bool
-doaxfr(ldns_resolver *res, ldns_rdf *domain, bool absolute) {
- ldns_pkt *pkt;
+dozonetransfer(ldns_resolver *res, ldns_rdf *domain, bool absolute) {
+ ldns_pkt *pkt, *nextpkt;
ldns_rdf *dname;
ldns_rr_type rrtype;
+ ldns_rr_list *rrl;
+ int i, nsoa = 0;
rrtype = o_rrtype;
- o_rrtype = LDNS_RR_TYPE_AXFR;
- dname = search(res, domain, &pkt, absolute);
- ldns_pkt_filter_answer(pkt, rrtype);
- report(res, dname != NULL ? dname : domain, pkt);
- return dname != NULL;
+ o_rrtype = (o_mode == M_AXFR) ? LDNS_RR_TYPE_AXFR : LDNS_RR_TYPE_IXFR;
+ dname = search(res, domain, &pkt, absolute, false);
+
+ for (;;) {
+ rrl = ldns_pkt_answer(pkt);
+ for (i = ldns_rr_list_rr_count(rrl) - 1; i >= 0; i--) {
+ if (ldns_rr_get_type(ldns_rr_list_rr(rrl, i)) == LDNS_RR_TYPE_SOA)
+ nsoa++;
+ }
+ ldns_pkt_filter_answer(pkt, rrtype);
+ report(res, dname != NULL ? dname : domain, pkt);
+ if ((dname == NULL) ||
+ (ldns_pkt_get_rcode(pkt) != LDNS_RCODE_NOERROR)) {
+ printf("; Transfer failed.\n");
+ ldns_tcp_close(res);
+ return false;
+ }
+ if (nsoa >= 2) {
+ ldns_tcp_close(res);
+ return true;
+ }
+ if (ldns_tcp_read(&nextpkt, res) != LDNS_STATUS_OK) {
+ printf("; Transfer failed.\n");
+ return false;
+ }
+ ldns_pkt_set_answerfrom(nextpkt,
+ ldns_rdf_clone(ldns_pkt_answerfrom(pkt)));
+ ldns_pkt_free(pkt);
+ pkt = nextpkt;
+ }
}
static bool
@@ -760,7 +916,7 @@ dosoa(ldns_resolver *res, ldns_rdf *domain, bool absolute) {
ldns_rr *rr;
size_t i, j, n, cnt;
- if ((dname = search(res, domain, &pkt, absolute)) == NULL)
+ if ((dname = search(res, domain, &pkt, absolute, true)) == NULL)
return false;
answer = ldns_pkt_answer(pkt);
@@ -780,9 +936,9 @@ dosoa(ldns_resolver *res, ldns_rdf *domain, bool absolute) {
ldns_resolver_remove_nameservers(res);
rr = ldns_rr_list_rr(nsaddrs[i], j);
if ((ldns_resolver_ip6(res) == LDNS_RESOLV_INET &&
- ldns_rr_get_type(rr) == LDNS_RR_TYPE_AAAA) ||
+ ldns_rr_get_type(rr) == LDNS_RR_TYPE_AAAA) ||
(ldns_resolver_ip6(res) == LDNS_RESOLV_INET6 &&
- ldns_rr_get_type(rr) == LDNS_RR_TYPE_A))
+ ldns_rr_get_type(rr) == LDNS_RR_TYPE_A))
continue;
if (ldns_resolver_push_nameserver_rr(res, rr) == LDNS_STATUS_OK)
/* bind9-host queries for domain, not dname here */
@@ -879,6 +1035,9 @@ main(int argc, char *argv[]) {
o_rrtype = LDNS_RR_TYPE_PTR;
return !doquery(res, dname);
}
- return !(o_mode == M_SOA ? dosoa : o_mode == M_AXFR ? doaxfr : dosearch)
+ return !(o_mode == M_SOA ? dosoa :
+ o_mode == M_AXFR ? dozonetransfer :
+ o_mode == M_IXFR ? dozonetransfer :
+ dosearch)
(res, safe_str2rdf_dname(o_name), ndots(o_name) >= o_ndots);
}
diff --git a/contrib/libc-vis/unvis.c b/contrib/libc-vis/unvis.c
index 9cf112c..d96d231 100644
--- a/contrib/libc-vis/unvis.c
+++ b/contrib/libc-vis/unvis.c
@@ -1,4 +1,4 @@
-/* $NetBSD: unvis.c,v 1.41 2012/12/15 04:29:53 matt Exp $ */
+/* $NetBSD: unvis.c,v 1.44 2014/09/26 15:43:36 roy Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: unvis.c,v 1.41 2012/12/15 04:29:53 matt Exp $");
+__RCSID("$NetBSD: unvis.c,v 1.44 2014/09/26 15:43:36 roy Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
__FBSDID("$FreeBSD$");
@@ -322,6 +322,12 @@ unvis(char *cp, int c, int *astate, int flag)
*/
*astate = SS(0, S_GROUND);
return UNVIS_NOCHAR;
+ default:
+ if (isgraph(c)) {
+ *cp = c;
+ *astate = SS(0, S_GROUND);
+ return UNVIS_VALID;
+ }
}
goto bad;
diff --git a/contrib/libc-vis/vis.3 b/contrib/libc-vis/vis.3
index 4bff663..71daad6 100644
--- a/contrib/libc-vis/vis.3
+++ b/contrib/libc-vis/vis.3
@@ -1,4 +1,4 @@
-.\" $NetBSD: vis.3,v 1.39 2013/02/20 20:05:26 christos Exp $
+.\" $NetBSD: vis.3,v 1.45 2016/06/08 15:00:04 wiz Exp $
.\" $FreeBSD$
.\"
.\" Copyright (c) 1989, 1991, 1993
@@ -30,13 +30,14 @@
.\"
.\" @(#)vis.3 8.1 (Berkeley) 6/9/93
.\"
-.Dd February 19, 2013
+.Dd January 14, 2015
.Dt VIS 3
.Os
.Sh NAME
.Nm vis ,
.Nm nvis ,
.Nm strvis ,
+.Nm stravis ,
.Nm strnvis ,
.Nm strvisx ,
.Nm strnvisx ,
@@ -60,6 +61,8 @@
.Ft int
.Fn strvis "char *dst" "const char *src" "int flag"
.Ft int
+.Fn stravis "char **dst" "const char *src" "int flag"
+.Ft int
.Fn strnvis "char *dst" "size_t dlen" "const char *src" "int flag"
.Ft int
.Fn strvisx "char *dst" "const char *src" "size_t len" "int flag"
@@ -112,6 +115,7 @@ encoding format (explained below).
.Pp
The
.Fn strvis ,
+.Fn stravis ,
.Fn strnvis ,
.Fn strvisx ,
and
@@ -158,6 +162,9 @@ forms return the number of characters in
(not including the trailing
.Dv NUL ) .
The
+.Fn stravis
+function allocates space dynamically to hold the string.
+The
.Dq Nm n
versions of the functions also take an additional argument
.Fa dlen
@@ -240,11 +247,31 @@ alter this:
Also encode the magic characters
.Ql ( * ,
.Ql \&? ,
-.Ql \&[
+.Ql \&[ ,
and
.Ql # )
recognized by
.Xr glob 3 .
+.It Dv VIS_SHELL
+Also encode the meta characters used by shells (in addition to the glob
+characters):
+.Ql ( ' ,
+.Ql ` ,
+.Ql \&" ,
+.Ql \&; ,
+.Ql & ,
+.Ql < ,
+.Ql > ,
+.Ql \&( ,
+.Ql \&) ,
+.Ql \&| ,
+.Ql \&] ,
+.Ql \e ,
+.Ql $ ,
+.Ql \&! ,
+.Ql \&^ ,
+and
+.Ql ~ ) .
.It Dv VIS_SP
Also encode space.
.It Dv VIS_TAB
@@ -253,11 +280,10 @@ Also encode tab.
Also encode newline.
.It Dv VIS_WHITE
Synonym for
-.Dv VIS_SP
-\&|
-.Dv VIS_TAB
-\&|
-.Dv VIS_NL .
+.Dv VIS_SP | VIS_TAB | VIS_NL .
+.It Dv VIS_META
+Synonym for
+.Dv VIS_WHITE | VIS_GLOB | VIS_SHELL .
.It Dv VIS_SAFE
Only encode
.Dq unsafe
@@ -418,6 +444,11 @@ The encoding conversion is influenced by the setting of the
environment variable which defines the set of characters
that can be copied without encoding.
.Pp
+If
+.Dv VIS_NOLOCALE
+is set, processing is done assuming the C locale and overriding
+any other environment settings.
+.Pp
When 8-bit data is present in the input,
.Ev LC_CTYPE
must be set to the correct locale or to the C locale.
@@ -513,7 +544,7 @@ appeared in
.Nx 6.0
and
.Fx 9.2 .
-Myltibyte character support was added in
+Multibyte character support was added in
.Nx 7.0
and
.Fx 9.2 .
diff --git a/contrib/libc-vis/vis.c b/contrib/libc-vis/vis.c
index 4863bbe..b4a5f32 100644
--- a/contrib/libc-vis/vis.c
+++ b/contrib/libc-vis/vis.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vis.c,v 1.62 2014/09/08 17:35:01 christos Exp $ */
+/* $NetBSD: vis.c,v 1.71 2016/01/14 20:41:23 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -57,7 +57,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: vis.c,v 1.62 2014/09/08 17:35:01 christos Exp $");
+__RCSID("$NetBSD: vis.c,v 1.71 2016/01/14 20:41:23 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#ifdef __FBSDID
__FBSDID("$FreeBSD$");
@@ -97,6 +97,30 @@ static wchar_t *do_svis(wchar_t *, wint_t, int, wint_t, const wchar_t *);
#undef BELL
#define BELL L'\a'
+
+#if defined(LC_C_LOCALE)
+#define iscgraph(c) isgraph_l(c, LC_C_LOCALE)
+#else
+/* Keep it simple for now, no locale stuff */
+#define iscgraph(c) isgraph(c)
+#ifdef notyet
+#include <locale.h>
+static int
+iscgraph(int c) {
+ int rv;
+ char *ol;
+
+ ol = setlocale(LC_CTYPE, "C");
+ rv = isgraph(c);
+ if (ol)
+ setlocale(LC_CTYPE, ol);
+ return rv;
+}
+#endif
+#endif
+
+#define ISGRAPH(flags, c) \
+ (((flags) & VIS_NOLOCALE) ? iscgraph(c) : iswgraph(c))
#define iswoctal(c) (((u_char)(c)) >= L'0' && ((u_char)(c)) <= L'7')
#define iswwhite(c) (c == L' ' || c == L'\t' || c == L'\n')
@@ -104,7 +128,10 @@ static wchar_t *do_svis(wchar_t *, wint_t, int, wint_t, const wchar_t *);
#define xtoa(c) L"0123456789abcdef"[c]
#define XTOA(c) L"0123456789ABCDEF"[c]
-#define MAXEXTRAS 10
+#define MAXEXTRAS 30
+
+static const wchar_t char_shell[] = L"'`\";&<>()|{}]\\$!^~";
+static const wchar_t char_glob[] = L"*?[#";
#if !HAVE_NBTOOL_CONFIG_H
#ifndef __NetBSD__
@@ -213,8 +240,23 @@ do_mbyte(wchar_t *dst, wint_t c, int flags, wint_t nextc, int iswextra)
*dst++ = L'0';
}
return dst;
+ /* We cannot encode these characters in VIS_CSTYLE
+ * because they special meaning */
+ case L'n':
+ case L'r':
+ case L'b':
+ case L'a':
+ case L'v':
+ case L't':
+ case L'f':
+ case L's':
+ case L'0':
+ case L'M':
+ case L'^':
+ case L'$': /* vis(1) -l */
+ break;
default:
- if (iswgraph(c)) {
+ if (ISGRAPH(flags, c) && !iswoctal(c)) {
*dst++ = L'\\';
*dst++ = c;
return dst;
@@ -266,7 +308,7 @@ do_svis(wchar_t *dst, wint_t c, int flags, wint_t nextc, const wchar_t *extra)
uint64_t bmsk, wmsk;
iswextra = wcschr(extra, c) != NULL;
- if (!iswextra && (iswgraph(c) || iswwhite(c) ||
+ if (!iswextra && (ISGRAPH(flags, c) || iswwhite(c) ||
((flags & VIS_SAFE) && iswsafe(c)))) {
*dst++ = c;
return dst;
@@ -310,25 +352,27 @@ makeextralist(int flags, const char *src)
{
wchar_t *dst, *d;
size_t len;
+ const wchar_t *s;
len = strlen(src);
if ((dst = calloc(len + MAXEXTRAS, sizeof(*dst))) == NULL)
return NULL;
- if (mbstowcs(dst, src, len) == (size_t)-1) {
+ if ((flags & VIS_NOLOCALE) || mbstowcs(dst, src, len) == (size_t)-1) {
size_t i;
for (i = 0; i < len; i++)
- dst[i] = (wint_t)(u_char)src[i];
+ dst[i] = (wchar_t)(u_char)src[i];
d = dst + len;
} else
d = dst + wcslen(dst);
- if (flags & VIS_GLOB) {
- *d++ = L'*';
- *d++ = L'?';
- *d++ = L'[';
- *d++ = L'#';
- }
+ if (flags & VIS_GLOB)
+ for (s = char_glob; *s; *d++ = *s++)
+ continue;
+
+ if (flags & VIS_SHELL)
+ for (s = char_shell; *s; *d++ = *s++)
+ continue;
if (flags & VIS_SP) *d++ = L' ';
if (flags & VIS_TAB) *d++ = L'\t';
@@ -345,7 +389,7 @@ makeextralist(int flags, const char *src)
* All user-visible functions call this one.
*/
static int
-istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
+istrsenvisx(char **mbdstp, size_t *dlen, const char *mbsrc, size_t mblength,
int flags, const char *mbextra, int *cerr_ptr)
{
wchar_t *dst, *src, *pdst, *psrc, *start, *extra;
@@ -353,10 +397,11 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
uint64_t bmsk, wmsk;
wint_t c;
visfun_t f;
- int clen = 0, cerr = 0, error = -1, i, shft;
+ int clen = 0, cerr, error = -1, i, shft;
+ char *mbdst, *mdst;
ssize_t mbslength, maxolen;
- _DIAGASSERT(mbdst != NULL);
+ _DIAGASSERT(mbdstp != NULL);
_DIAGASSERT(mbsrc != NULL || mblength == 0);
_DIAGASSERT(mbextra != NULL);
@@ -375,16 +420,28 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
/* Allocate space for the wide char strings */
psrc = pdst = extra = NULL;
+ mdst = NULL;
if ((psrc = calloc(mblength + 1, sizeof(*psrc))) == NULL)
return -1;
if ((pdst = calloc((4 * mblength) + 1, sizeof(*pdst))) == NULL)
goto out;
+ if (*mbdstp == NULL) {
+ if ((mdst = calloc((4 * mblength) + 1, sizeof(*mdst))) == NULL)
+ goto out;
+ *mbdstp = mdst;
+ }
+
+ mbdst = *mbdstp;
dst = pdst;
src = psrc;
- /* Use caller's multibyte conversion error flag. */
- if (cerr_ptr)
- cerr = *cerr_ptr;
+ if (flags & VIS_NOLOCALE) {
+ /* Do one byte at a time conversion */
+ cerr = 1;
+ } else {
+ /* Use caller's multibyte conversion error flag. */
+ cerr = cerr_ptr ? *cerr_ptr : 0;
+ }
/*
* Input loop.
@@ -439,7 +496,7 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
errno = ENOSPC;
goto out;
}
- *mbdst = '\0'; /* can't create extra, return "" */
+ *mbdst = '\0'; /* can't create extra, return "" */
error = 0;
goto out;
}
@@ -511,9 +568,11 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
/* Terminate the output string. */
*mbdst = '\0';
- /* Pass conversion error flag out. */
- if (cerr_ptr)
- *cerr_ptr = cerr;
+ if (flags & VIS_NOLOCALE) {
+ /* Pass conversion error flag out. */
+ if (cerr_ptr)
+ *cerr_ptr = cerr;
+ }
free(extra);
free(pdst);
@@ -524,14 +583,15 @@ out:
free(extra);
free(pdst);
free(psrc);
+ free(mdst);
return error;
}
static int
-istrsenvisxl(char *mbdst, size_t *dlen, const char *mbsrc,
+istrsenvisxl(char **mbdstp, size_t *dlen, const char *mbsrc,
int flags, const char *mbextra, int *cerr_ptr)
{
- return istrsenvisx(mbdst, dlen, mbsrc,
+ return istrsenvisx(mbdstp, dlen, mbsrc,
mbsrc != NULL ? strlen(mbsrc) : 0, flags, mbextra, cerr_ptr);
}
@@ -554,7 +614,7 @@ svis(char *mbdst, int c, int flags, int nextc, const char *mbextra)
cc[0] = c;
cc[1] = nextc;
- ret = istrsenvisx(mbdst, NULL, cc, 1, flags, mbextra, NULL);
+ ret = istrsenvisx(&mbdst, NULL, cc, 1, flags, mbextra, NULL);
if (ret < 0)
return NULL;
return mbdst + ret;
@@ -569,7 +629,7 @@ snvis(char *mbdst, size_t dlen, int c, int flags, int nextc, const char *mbextra
cc[0] = c;
cc[1] = nextc;
- ret = istrsenvisx(mbdst, &dlen, cc, 1, flags, mbextra, NULL);
+ ret = istrsenvisx(&mbdst, &dlen, cc, 1, flags, mbextra, NULL);
if (ret < 0)
return NULL;
return mbdst + ret;
@@ -578,33 +638,33 @@ snvis(char *mbdst, size_t dlen, int c, int flags, int nextc, const char *mbextra
int
strsvis(char *mbdst, const char *mbsrc, int flags, const char *mbextra)
{
- return istrsenvisxl(mbdst, NULL, mbsrc, flags, mbextra, NULL);
+ return istrsenvisxl(&mbdst, NULL, mbsrc, flags, mbextra, NULL);
}
int
strsnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags, const char *mbextra)
{
- return istrsenvisxl(mbdst, &dlen, mbsrc, flags, mbextra, NULL);
+ return istrsenvisxl(&mbdst, &dlen, mbsrc, flags, mbextra, NULL);
}
int
strsvisx(char *mbdst, const char *mbsrc, size_t len, int flags, const char *mbextra)
{
- return istrsenvisx(mbdst, NULL, mbsrc, len, flags, mbextra, NULL);
+ return istrsenvisx(&mbdst, NULL, mbsrc, len, flags, mbextra, NULL);
}
int
strsnvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
const char *mbextra)
{
- return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, mbextra, NULL);
+ return istrsenvisx(&mbdst, &dlen, mbsrc, len, flags, mbextra, NULL);
}
int
strsenvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
const char *mbextra, int *cerr_ptr)
{
- return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, mbextra, cerr_ptr);
+ return istrsenvisx(&mbdst, &dlen, mbsrc, len, flags, mbextra, cerr_ptr);
}
#endif
@@ -621,7 +681,7 @@ vis(char *mbdst, int c, int flags, int nextc)
cc[0] = c;
cc[1] = nextc;
- ret = istrsenvisx(mbdst, NULL, cc, 1, flags, "", NULL);
+ ret = istrsenvisx(&mbdst, NULL, cc, 1, flags, "", NULL);
if (ret < 0)
return NULL;
return mbdst + ret;
@@ -636,7 +696,7 @@ nvis(char *mbdst, size_t dlen, int c, int flags, int nextc)
cc[0] = c;
cc[1] = nextc;
- ret = istrsenvisx(mbdst, &dlen, cc, 1, flags, "", NULL);
+ ret = istrsenvisx(&mbdst, &dlen, cc, 1, flags, "", NULL);
if (ret < 0)
return NULL;
return mbdst + ret;
@@ -653,13 +713,20 @@ nvis(char *mbdst, size_t dlen, int c, int flags, int nextc)
int
strvis(char *mbdst, const char *mbsrc, int flags)
{
- return istrsenvisxl(mbdst, NULL, mbsrc, flags, "", NULL);
+ return istrsenvisxl(&mbdst, NULL, mbsrc, flags, "", NULL);
}
int
strnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags)
{
- return istrsenvisxl(mbdst, &dlen, mbsrc, flags, "", NULL);
+ return istrsenvisxl(&mbdst, &dlen, mbsrc, flags, "", NULL);
+}
+
+int
+stravis(char **mbdstp, const char *mbsrc, int flags)
+{
+ *mbdstp = NULL;
+ return istrsenvisxl(mbdstp, NULL, mbsrc, flags, "", NULL);
}
/*
@@ -676,19 +743,19 @@ strnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags)
int
strvisx(char *mbdst, const char *mbsrc, size_t len, int flags)
{
- return istrsenvisx(mbdst, NULL, mbsrc, len, flags, "", NULL);
+ return istrsenvisx(&mbdst, NULL, mbsrc, len, flags, "", NULL);
}
int
strnvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags)
{
- return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, "", NULL);
+ return istrsenvisx(&mbdst, &dlen, mbsrc, len, flags, "", NULL);
}
int
strenvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
int *cerr_ptr)
{
- return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, "", cerr_ptr);
+ return istrsenvisx(&mbdst, &dlen, mbsrc, len, flags, "", cerr_ptr);
}
#endif
diff --git a/contrib/libc-vis/vis.h b/contrib/libc-vis/vis.h
index beb029c..e307a39 100644
--- a/contrib/libc-vis/vis.h
+++ b/contrib/libc-vis/vis.h
@@ -1,4 +1,4 @@
-/* $NetBSD: vis.h,v 1.21 2013/02/20 17:01:15 christos Exp $ */
+/* $NetBSD: vis.h,v 1.24 2016/01/14 20:42:14 christos Exp $ */
/* $FreeBSD$ */
/*-
@@ -64,6 +64,9 @@
#define VIS_HTTP1866 0x0400 /* http-style &#num; or &string; */
#define VIS_NOESCAPE 0x0800 /* don't decode `\' */
#define _VIS_END 0x1000 /* for unvis */
+#define VIS_SHELL 0x2000 /* encode shell special characters [not glob] */
+#define VIS_META (VIS_WHITE | VIS_GLOB | VIS_SHELL)
+#define VIS_NOLOCALE 0x4000 /* encode using the C locale */
/*
* unvis return codes
@@ -89,6 +92,7 @@ char *svis(char *, int, int, int, const char *);
char *snvis(char *, size_t, int, int, int, const char *);
int strvis(char *, const char *, int);
+int stravis(char **, const char *, int);
int strnvis(char *, size_t, const char *, int);
int strsvis(char *, const char *, int, const char *);
diff --git a/contrib/netbsd-tests/lib/libc/db/t_db.sh b/contrib/netbsd-tests/lib/libc/db/t_db.sh
index d256508..4f45ec1 100755
--- a/contrib/netbsd-tests/lib/libc/db/t_db.sh
+++ b/contrib/netbsd-tests/lib/libc/db/t_db.sh
@@ -37,6 +37,7 @@ dict()
elif [ -f /usr/dict/words ]; then
echo /usr/dict/words
else
+ echo ""
atf_fail "no dictionary found"
fi
}
@@ -44,12 +45,7 @@ dict()
# Begin FreeBSD
dict()
{
- if [ -f /usr/share/dict/words ]; then
- echo /usr/share/dict/words
- else
- echo /nonexistent
- atf_skip "Test requires dict/words"
- fi
+ echo /usr/share/dict/words
}
# End FreeBSD
@@ -62,6 +58,9 @@ small_btree_head()
"Checks btree database using small keys and small data" \
"pairs: takes the first hundred entries in the dictionary," \
"and makes them be key/data pairs."
+ # Begin FreeBSD
+ atf_set "require.files" /usr/share/dict/words
+ # End FreeBSD
}
small_btree_body()
{
@@ -88,6 +87,9 @@ small_hash_head()
"Checks hash database using small keys and small data" \
"pairs: takes the first hundred entries in the dictionary," \
"and makes them be key/data pairs."
+ # Begin FreeBSD
+ atf_set "require.files" /usr/share/dict/words
+ # End FreeBSD
}
small_hash_body()
{
@@ -114,6 +116,9 @@ small_recno_head()
"Checks recno database using small keys and small data" \
"pairs: takes the first hundred entries in the dictionary," \
"and makes them be key/data pairs."
+ # Begin FreeBSD
+ atf_set "require.files" /usr/share/dict/words
+ # End FreeBSD
}
small_recno_body()
{
@@ -138,6 +143,9 @@ medium_btree_head()
"Checks btree database using small keys and medium" \
"data pairs: takes the first 200 entries in the" \
"dictionary, and gives them each a medium size data entry."
+ # Begin FreeBSD
+ atf_set "require.files" /usr/share/dict/words
+ # End FreeBSD
}
medium_btree_body()
{
@@ -166,6 +174,9 @@ medium_hash_head()
"Checks hash database using small keys and medium" \
"data pairs: takes the first 200 entries in the" \
"dictionary, and gives them each a medium size data entry."
+ # Begin FreeBSD
+ atf_set "require.files" /usr/share/dict/words
+ # End FreeBSD
}
medium_hash_body()
{
@@ -731,6 +742,9 @@ small_page_btree_head()
"reverses them, and gives them each a small size data" \
"entry. Uses a small page size to make sure the btree" \
"split code gets hammered."
+ # Begin FreeBSD
+ atf_set "require.files" /usr/share/dict/words
+ # End FreeBSD
}
small_page_btree_body()
{
@@ -784,6 +798,9 @@ atf_test_case byte_orders_btree
byte_orders_btree_head()
{
atf_set "descr" "Checks btree database using differing byte orders"
+ # Begin FreeBSD
+ atf_set "require.files" /usr/share/dict/words
+ # End FreeBSD
}
byte_orders_btree_body()
{
@@ -816,6 +833,9 @@ bsize_ffactor_head()
atf_set "timeout" "480"
atf_set "descr" "Checks hash database with various" \
"bucketsizes and fill factors"
+ # Begin FreeBSD
+ atf_set "require.files" /usr/share/dict/words
+ # End FreeBSD
}
bsize_ffactor_body()
{
diff --git a/contrib/netbsd-tests/lib/libc/string/t_memcpy.c b/contrib/netbsd-tests/lib/libc/string/t_memcpy.c
index 192a4e8..5bbd924 100644
--- a/contrib/netbsd-tests/lib/libc/string/t_memcpy.c
+++ b/contrib/netbsd-tests/lib/libc/string/t_memcpy.c
@@ -54,7 +54,7 @@ char result[100];
#ifdef __NetBSD__
const char goodResult[] = "7b405d24bc03195474c70ddae9e1f8fb";
#else
-const char goodResult[] = "217b4fbe456916bf62a2f85df752e4ab";
+const char goodResult[] = "5ab4443f0e3e058d94087d9f2a11ef5e";
#endif
static void
@@ -108,7 +108,12 @@ ATF_TC_BODY(memcpy_basic, tc)
if (i != j)
runTest(start[i], start[j]);
MD5End(mc, result);
+#ifdef __NetBSD__
ATF_REQUIRE_EQ(strcmp(result, goodResult), 0);
+#else
+ ATF_REQUIRE_EQ_MSG(strcmp(result, goodResult), 0, "%s != %s",
+ result, goodResult);
+#endif
}
ATF_TC(memccpy_simple);
diff --git a/contrib/tcpdump/addrtoname.c b/contrib/tcpdump/addrtoname.c
index e224606..2befeae 100644
--- a/contrib/tcpdump/addrtoname.c
+++ b/contrib/tcpdump/addrtoname.c
@@ -29,10 +29,10 @@
#include "config.h"
#endif
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
#include <libcasper.h>
#include <casper/cap_dns.h>
-#endif /* HAVE_CAPSPER */
+#endif /* HAVE_CASPER */
#include <tcpdump-stdinc.h>
#ifdef USE_ETHER_NTOHOST
@@ -204,7 +204,7 @@ intoa(uint32_t addr)
static uint32_t f_netmask;
static uint32_t f_localnet;
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
extern cap_channel_t *capdns;
#endif
@@ -252,7 +252,7 @@ getname(netdissect_options *ndo, const u_char *ap)
*/
if (!ndo->ndo_nflag &&
(addr & f_netmask) == f_localnet) {
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
if (capdns != NULL) {
hp = cap_gethostbyaddr(capdns, (char *)&addr, 4,
AF_INET);
@@ -309,7 +309,7 @@ getname6(netdissect_options *ndo, const u_char *ap)
* Do not print names if -n was given.
*/
if (!ndo->ndo_nflag) {
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
if (capdns != NULL) {
hp = cap_gethostbyaddr(capdns, (char *)&addr,
sizeof(addr), AF_INET6);
diff --git a/contrib/tcpdump/config.h.in b/contrib/tcpdump/config.h.in
index f233245..c289f00 100644
--- a/contrib/tcpdump/config.h.in
+++ b/contrib/tcpdump/config.h.in
@@ -10,7 +10,7 @@
#undef HAVE_BPF_DUMP
/* capsicum support available */
-#undef HAVE_CAPSPER
+#undef HAVE_CASPER
/* Define to 1 if you have the `cap_enter' function. */
#undef HAVE_CAP_ENTER
diff --git a/contrib/tcpdump/configure b/contrib/tcpdump/configure
index 390af31..d10f2ac 100755
--- a/contrib/tcpdump/configure
+++ b/contrib/tcpdump/configure
@@ -4566,7 +4566,7 @@ fi
$as_echo_n "checking whether to sandbox using capsicum... " >&6; }
if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
-$as_echo "#define HAVE_CAPSPER 1" >>confdefs.h
+$as_echo "#define HAVE_CASPER 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
diff --git a/contrib/tcpdump/tcpdump.c b/contrib/tcpdump/tcpdump.c
index ce88d59..0939896 100644
--- a/contrib/tcpdump/tcpdump.c
+++ b/contrib/tcpdump/tcpdump.c
@@ -86,8 +86,9 @@ extern int SIZE_BUF;
#ifdef __FreeBSD__
#include <sys/capsicum.h>
#include <sys/sysctl.h>
+#include <libgen.h>
#endif /* __FreeBSD__ */
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
#include <libcasper.h>
#include <casper/cap_dns.h>
#include <sys/nv.h>
@@ -95,8 +96,7 @@ extern int SIZE_BUF;
#include <sys/ioccom.h>
#include <net/bpf.h>
#include <fcntl.h>
-#include <libgen.h>
-#endif /* HAVE_CAPSPER */
+#endif /* HAVE_CASPER */
#include <pcap.h>
#include <signal.h>
#include <stdio.h>
@@ -160,7 +160,7 @@ static int infoprint;
char *program_name;
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
cap_channel_t *capdns;
#endif
@@ -487,7 +487,7 @@ struct dump_info {
char *CurrentFileName;
pcap_t *pd;
pcap_dumper_t *p;
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
int dirfd;
#endif
};
@@ -911,7 +911,7 @@ get_next_file(FILE *VFile, char *ptr)
return ret;
}
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
static cap_channel_t *
capdns_setup(void)
{
@@ -938,7 +938,7 @@ capdns_setup(void)
return (capdnsloc);
}
-#endif /* HAVE_CAPSPER */
+#endif /* HAVE_CASPER */
#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
static int
@@ -970,7 +970,7 @@ tstamp_precision_to_string(int precision)
}
#endif
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
/*
* Ensure that, on a dump file's descriptor, we have all the rights
* necessary to make the standard I/O library work with an fdopen()ed
@@ -1070,9 +1070,9 @@ main(int argc, char **argv)
#endif
int status;
FILE *VFile;
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
cap_rights_t rights;
-#endif /* HAVE_CAPSPER */
+#endif /* !__FreeBSD__ */
int cansandbox;
#ifdef WIN32
@@ -1613,7 +1613,7 @@ main(int argc, char **argv)
if (pd == NULL)
error("%s", ebuf);
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
cap_rights_init(&rights, CAP_READ);
if (cap_rights_limit(fileno(pcap_file(pd)), &rights) < 0 &&
errno != ENOSYS) {
@@ -1850,10 +1850,10 @@ main(int argc, char **argv)
exit(0);
}
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
if (!nflag)
capdns = capdns_setup();
-#endif /* HAVE_CAPSPER */
+#endif /* HAVE_CASPER */
init_addrtoname(gndo, localnet, netmask);
init_checksum();
@@ -1921,7 +1921,7 @@ main(int argc, char **argv)
if (pcap_setfilter(pd, &fcode) < 0)
error("%s", pcap_geterr(pd));
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
if (RFileName == NULL && VFileName == NULL) {
static const unsigned long cmds[] = { BIOCGSTATS };
@@ -1971,11 +1971,11 @@ main(int argc, char **argv)
#endif /* HAVE_LIBCAP_NG */
if (p == NULL)
error("%s", pcap_geterr(pd));
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
set_dumper_capsicum_rights(p);
#endif
if (Cflag != 0 || Gflag != 0) {
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
dumpinfo.WFileName = strdup(basename(WFileName));
dumpinfo.dirfd = open(dirname(WFileName),
O_DIRECTORY | O_RDONLY);
@@ -1993,7 +1993,7 @@ main(int argc, char **argv)
errno != ENOSYS) {
error("unable to limit dump descriptor fcntls");
}
-#else /* !HAVE_CAPSPER */
+#else /* !__FreeBSD__ */
dumpinfo.WFileName = WFileName;
#endif
callback = dump_packet_and_trunc;
@@ -2069,7 +2069,7 @@ main(int argc, char **argv)
#ifdef __FreeBSD__
cansandbox = (VFileName == NULL && zflag == NULL);
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
cansandbox = (cansandbox && (nflag || capdns != NULL));
#else
cansandbox = (cansandbox && nflag);
@@ -2125,7 +2125,7 @@ main(int argc, char **argv)
pd = pcap_open_offline(RFileName, ebuf);
if (pd == NULL)
error("%s", ebuf);
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
cap_rights_init(&rights, CAP_READ);
if (cap_rights_limit(fileno(pcap_file(pd)),
&rights) < 0 && errno != ENOSYS) {
@@ -2328,7 +2328,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
/* If the time is greater than the specified window, rotate */
if (t - Gflag_time >= Gflag) {
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
FILE *fp;
int fd;
#endif
@@ -2386,7 +2386,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
capng_apply(CAPNG_SELECT_BOTH);
#endif /* HAVE_LIBCAP_NG */
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
fd = openat(dump_info->dirfd,
dump_info->CurrentFileName,
O_CREAT | O_WRONLY | O_TRUNC, 0644);
@@ -2400,7 +2400,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
dump_info->CurrentFileName);
}
dump_info->p = pcap_dump_fopen(dump_info->pd, fp);
-#else /* !HAVE_CAPSPER */
+#else /* !__FreeBSD__ */
dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName);
#endif
#ifdef HAVE_LIBCAP_NG
@@ -2409,7 +2409,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
#endif /* HAVE_LIBCAP_NG */
if (dump_info->p == NULL)
error("%s", pcap_geterr(pd));
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
set_dumper_capsicum_rights(dump_info->p);
#endif
}
@@ -2426,7 +2426,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
if (size == -1)
error("ftell fails on output file");
if (size > Cflag) {
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
FILE *fp;
int fd;
#endif
@@ -2458,7 +2458,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
capng_apply(CAPNG_SELECT_BOTH);
#endif /* HAVE_LIBCAP_NG */
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
fd = openat(dump_info->dirfd, dump_info->CurrentFileName,
O_CREAT | O_WRONLY | O_TRUNC, 0644);
if (fd < 0) {
@@ -2471,7 +2471,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
dump_info->CurrentFileName);
}
dump_info->p = pcap_dump_fopen(dump_info->pd, fp);
-#else /* !HAVE_CAPSPER */
+#else /* !__FreeBSD__ */
dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName);
#endif
#ifdef HAVE_LIBCAP_NG
@@ -2480,7 +2480,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
#endif /* HAVE_LIBCAP_NG */
if (dump_info->p == NULL)
error("%s", pcap_geterr(pd));
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
set_dumper_capsicum_rights(dump_info->p);
#endif
}
diff --git a/crypto/openssh/auth-pam.c b/crypto/openssh/auth-pam.c
index 8425af1..53b9dbe 100644
--- a/crypto/openssh/auth-pam.c
+++ b/crypto/openssh/auth-pam.c
@@ -98,6 +98,9 @@
#include "ssh-gss.h"
#endif
#include "monitor_wrap.h"
+#ifdef USE_BLACKLIST
+#include "blacklist_client.h"
+#endif
extern ServerOptions options;
extern Buffer loginmsg;
@@ -794,6 +797,9 @@ sshpam_query(void *ctx, char **name, char **info,
free(msg);
return (0);
}
+#ifdef USE_BLACKLIST
+ blacklist_notify(1);
+#endif
error("PAM: %s for %s%.100s from %.100s", msg,
sshpam_authctxt->valid ? "" : "illegal user ",
sshpam_authctxt->user,
diff --git a/crypto/openssh/auth.c b/crypto/openssh/auth.c
index ba908801..c23b55d 100644
--- a/crypto/openssh/auth.c
+++ b/crypto/openssh/auth.c
@@ -75,6 +75,9 @@ __RCSID("$FreeBSD$");
#include "authfile.h"
#include "ssherr.h"
#include "compat.h"
+#ifdef USE_BLACKLIST
+#include "blacklist_client.h"
+#endif
/* import */
extern ServerOptions options;
@@ -306,6 +309,10 @@ auth_log(Authctxt *authctxt, int authenticated, int partial,
compat20 ? "ssh2" : "ssh1",
authctxt->info != NULL ? ": " : "",
authctxt->info != NULL ? authctxt->info : "");
+#ifdef USE_BLACKLIST
+ if (!authctxt->postponed)
+ blacklist_notify(!authenticated);
+#endif
free(authctxt->info);
authctxt->info = NULL;
@@ -640,6 +647,9 @@ getpwnamallow(const char *user)
}
#endif
if (pw == NULL) {
+#ifdef USE_BLACKLIST
+ blacklist_notify(1);
+#endif
logit("Invalid user %.100s from %.100s",
user, get_remote_ipaddr());
#ifdef CUSTOM_FAILED_LOGIN
diff --git a/crypto/openssh/auth1.c b/crypto/openssh/auth1.c
index 5073c49..539e56c 100644
--- a/crypto/openssh/auth1.c
+++ b/crypto/openssh/auth1.c
@@ -43,6 +43,9 @@
#endif
#include "monitor_wrap.h"
#include "buffer.h"
+#ifdef USE_BLACKLIST
+#include "blacklist_client.h"
+#endif
/* import */
extern ServerOptions options;
@@ -337,6 +340,9 @@ do_authloop(Authctxt *authctxt)
char *msg;
size_t len;
+#ifdef USE_BLACKLIST
+ blacklist_notify(1);
+#endif
error("Access denied for user %s by PAM account "
"configuration", authctxt->user);
len = buffer_len(&loginmsg);
@@ -404,6 +410,9 @@ do_authentication(Authctxt *authctxt)
else {
debug("do_authentication: invalid user %s", user);
authctxt->pw = fakepw();
+#ifdef USE_BLACKLIST
+ blacklist_notify(1);
+#endif
}
/* Configuration may have changed as a result of Match */
diff --git a/crypto/openssh/auth2.c b/crypto/openssh/auth2.c
index 1d9aab0..eec196a 100644
--- a/crypto/openssh/auth2.c
+++ b/crypto/openssh/auth2.c
@@ -52,6 +52,9 @@ __RCSID("$FreeBSD$");
#include "pathnames.h"
#include "buffer.h"
#include "canohost.h"
+#ifdef USE_BLACKLIST
+#include "blacklist_client.h"
+#endif
#ifdef GSSAPI
#include "ssh-gss.h"
@@ -248,6 +251,9 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
} else {
logit("input_userauth_request: invalid user %s", user);
authctxt->pw = fakepw();
+#ifdef USE_BLACKLIST
+ blacklist_notify(1);
+#endif
#ifdef SSH_AUDIT_EVENTS
PRIVSEP(audit_event(SSH_INVALID_USER));
#endif
diff --git a/crypto/openssh/blacklist.c b/crypto/openssh/blacklist.c
new file mode 100644
index 0000000..d172945
--- /dev/null
+++ b/crypto/openssh/blacklist.c
@@ -0,0 +1,64 @@
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "ssh.h"
+#include "packet.h"
+#include "log.h"
+#include "blacklist_client.h"
+#include <blacklist.h>
+
+static struct blacklist *blstate;
+
+void
+blacklist_init(void)
+{
+ blstate = blacklist_open();
+}
+
+void
+blacklist_notify(int action)
+{
+ int fd;
+ if (blstate == NULL)
+ blacklist_init();
+ if (blstate == NULL)
+ return;
+ fd = packet_get_connection_in();
+ if (!packet_connection_is_on_socket()) {
+ fprintf(stderr, "packet_connection_is_on_socket: false "
+ "(fd = %d)\n", fd);
+ }
+ (void)blacklist_r(blstate, action, fd, "ssh");
+}
diff --git a/crypto/openssh/blacklist_client.h b/crypto/openssh/blacklist_client.h
new file mode 100644
index 0000000..e63554d
--- /dev/null
+++ b/crypto/openssh/blacklist_client.h
@@ -0,0 +1,31 @@
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+void blacklist_notify(int);
+void blacklist_init(void);
diff --git a/crypto/openssh/packet.c b/crypto/openssh/packet.c
index f3b3ce9..9e1165a 100644
--- a/crypto/openssh/packet.c
+++ b/crypto/openssh/packet.c
@@ -86,6 +86,9 @@ __RCSID("$FreeBSD$");
#include "packet.h"
#include "ssherr.h"
#include "sshbuf.h"
+#ifdef USE_BLACKLIST
+#include "blacklist_client.h"
+#endif
#ifdef PACKET_DEBUG
#define DBG(x) x
@@ -2071,6 +2074,9 @@ sshpkt_fatal(struct ssh *ssh, const char *tag, int r)
case SSH_ERR_NO_KEX_ALG_MATCH:
case SSH_ERR_NO_HOSTKEY_ALG_MATCH:
if (ssh && ssh->kex && ssh->kex->failed_choice) {
+#ifdef USE_BLACKLIST
+ blacklist_notify(1);
+#endif
fatal("Unable to negotiate with %.200s port %d: %s. "
"Their offer: %s", ssh_remote_ipaddr(ssh),
ssh_remote_port(ssh), ssh_err(r),
diff --git a/crypto/openssh/sshd.c b/crypto/openssh/sshd.c
index dd7fcdd..d1159291 100644
--- a/crypto/openssh/sshd.c
+++ b/crypto/openssh/sshd.c
@@ -135,6 +135,9 @@ __RCSID("$FreeBSD$");
#include "ssh-sandbox.h"
#include "version.h"
#include "ssherr.h"
+#ifdef USE_BLACKLIST
+#include "blacklist_client.h"
+#endif
#ifdef LIBWRAP
#include <tcpd.h>
@@ -388,6 +391,9 @@ grace_alarm_handler(int sig)
kill(0, SIGTERM);
}
+#ifdef USE_BLACKLIST
+ blacklist_notify(1);
+#endif
/* Log error and exit. */
sigdie("Timeout before authentication for %s", get_remote_ipaddr());
}
@@ -649,6 +655,10 @@ privsep_preauth_child(void)
/* Demote the private keys to public keys. */
demote_sensitive_data();
+#ifdef USE_BLACKLIST
+ blacklist_init();
+#endif
+
/* Demote the child */
if (getuid() == 0 || geteuid() == 0) {
/* Change our root directory */
@@ -1272,6 +1282,9 @@ server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s)
for (i = 0; i < options.max_startups; i++)
startup_pipes[i] = -1;
+#ifdef USE_BLACKLIST
+ blacklist_init();
+#endif
/*
* Stay listening for connections until the system crashes or
* the daemon is killed with a signal.
diff --git a/etc/Makefile b/etc/Makefile
index 99d905a..b41a806 100644
--- a/etc/Makefile
+++ b/etc/Makefile
@@ -86,7 +86,7 @@ BIN1+= apmd.conf
BIN1+= auto_master
.endif
-.if ${MK_BLACKLIST_SUPPORT} != "no"
+.if ${MK_BLACKLIST} != "no"
BIN1+= blacklistd.conf
.endif
diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf
index e8ce8a9..61bffc8 100644
--- a/etc/defaults/rc.conf
+++ b/etc/defaults/rc.conf
@@ -270,7 +270,7 @@ hastd_program="/sbin/hastd" # path to hastd, if you want a different one.
hastd_flags="" # Optional flags to hastd.
ctld_enable="NO" # CAM Target Layer / iSCSI target daemon.
local_unbound_enable="NO" # local caching resolver
-blacklistd_enable="YES" # Run blacklistd daemon (YES/NO).
+blacklistd_enable="NO" # Run blacklistd daemon (YES/NO).
blacklistd_flags="" # Optional flags for blacklistd(8).
#
@@ -481,7 +481,7 @@ ipv6_static_routes="" # Set to static route list (or leave empty).
# route toward loopback interface.
#ipv6_route_xxx="fec0:0000:0000:0006:: -prefixlen 64 ::1"
ipv6_gateway_enable="NO" # Set to YES if this host will be a gateway.
-ipv6_cpe_wanif="NO" # Set to the upstram interface name if this
+ipv6_cpe_wanif="NO" # Set to the upstream interface name if this
# node will work as a router to forward IPv6
# packets not explicitly addressed to itself.
ipv6_privacy="NO" # Use privacy address on RA-receiving IFs
diff --git a/etc/mtree/BSD.include.dist b/etc/mtree/BSD.include.dist
index 42980d0..f08c13a 100644
--- a/etc/mtree/BSD.include.dist
+++ b/etc/mtree/BSD.include.dist
@@ -90,6 +90,8 @@
cam
ata
..
+ nvme
+ ..
scsi
..
..
diff --git a/etc/nsswitch.conf b/etc/nsswitch.conf
index c95b9a4..e0f14af 100644
--- a/etc/nsswitch.conf
+++ b/etc/nsswitch.conf
@@ -5,6 +5,7 @@
group: compat
group_compat: nis
hosts: files dns
+netgroup: compat
networks: files
passwd: compat
passwd_compat: nis
diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile
index 9737adc..9ad9f91 100644
--- a/etc/rc.d/Makefile
+++ b/etc/rc.d/Makefile
@@ -170,7 +170,7 @@ FILES+= automountd
FILES+= autounmountd
.endif
-.if ${MK_BLACKLIST_SUPPORT} != "no"
+.if ${MK_BLACKLIST} != "no"
_blacklistd+= blacklistd
.endif
diff --git a/gnu/lib/libsupc++/Version.map b/gnu/lib/libsupc++/Version.map
index 26fc124..31e6cc6 100644
--- a/gnu/lib/libsupc++/Version.map
+++ b/gnu/lib/libsupc++/Version.map
@@ -132,7 +132,7 @@ CXXABI_1.3 {
GLIBCXX_3.4 {
# operator new and new[]
- _Znai[jm];
+ _Zna[jm];
_Zna[jm]RKSt9nothrow_t;
_Znw[jm];
_Znw[jm]RKSt9nothrow_t;
diff --git a/gnu/usr.bin/groff/src/libs/libbib/Makefile.depend b/gnu/usr.bin/groff/src/libs/libbib/Makefile.depend
index 18be76b..8c3d080 100644
--- a/gnu/usr.bin/groff/src/libs/libbib/Makefile.depend
+++ b/gnu/usr.bin/groff/src/libs/libbib/Makefile.depend
@@ -4,6 +4,7 @@
DIRDEPS = \
include \
include/xlocale \
+ lib/libc++ \
.include <dirdeps.mk>
diff --git a/include/Makefile b/include/Makefile
index 3003448..e4cdf72 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -42,7 +42,7 @@ LHDRS= aio.h errno.h fcntl.h linker_set.h poll.h stdatomic.h stdint.h \
LDIRS= bsm cam geom net net80211 netgraph netinet netinet6 \
netipsec netnatm netsmb nfs nfsclient nfsserver sys vm
-LSUBDIRS= cam/ata cam/scsi \
+LSUBDIRS= cam/ata cam/nvme cam/scsi \
dev/acpica dev/agp dev/an dev/bktr dev/ciss dev/filemon dev/firewire \
dev/hwpmc \
dev/ic dev/iicbus dev/io dev/lmc dev/mfi dev/nvme \
diff --git a/include/netdb.h b/include/netdb.h
index 3fa5ff3..0d9cb4e 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -275,6 +275,7 @@ int getnetbyname_r(const char *, struct netent *, char *, size_t,
int getnetent_r(struct netent *, char *, size_t, struct netent **,
int *);
int getnetgrent(char **, char **, char **);
+int getnetgrent_r(char **, char **, char **, char *, size_t);
int getprotobyname_r(const char *, struct protoent *, char *,
size_t, struct protoent **);
int getprotobynumber_r(int, struct protoent *, char *, size_t,
diff --git a/kerberos5/Makefile.inc b/kerberos5/Makefile.inc
index 82922cc..053522e 100644
--- a/kerberos5/Makefile.inc
+++ b/kerberos5/Makefile.inc
@@ -36,7 +36,7 @@ ETSRCS= \
.if ${SRCS:M${_ET}.[ch]} != ""
.ORDER: ${_ET}.h ${_ET}.c
${_ET}.c: .NOMETA
-${_ET}.c ${_ET}.h: ${ET}
+${_ET}.h ${_ET}.c: ${ET}
compile_et ${.ALLSRC}
CLEANFILES+= ${_ET}.h ${_ET}.c
.endif
diff --git a/kerberos5/tools/asn1_compile/Makefile.depend b/kerberos5/tools/asn1_compile/Makefile.depend
index a3edb7f..947a8ed 100644
--- a/kerberos5/tools/asn1_compile/Makefile.depend
+++ b/kerberos5/tools/asn1_compile/Makefile.depend
@@ -9,6 +9,7 @@ DIRDEPS = \
include/xlocale \
kerberos5/lib/libroken \
kerberos5/lib/libvers \
+ kerberos5/tools/make-roken.host \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
diff --git a/lib/Makefile b/lib/Makefile
index d475c6c..0fff802 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -161,7 +161,7 @@ SUBDIR_DEPEND_liblzma= ${_libthr}
_libngatm= libngatm
.endif
-.if ${MK_BLACKLIST_SUPPORT} != "no"
+.if ${MK_BLACKLIST} != "no"
_libblacklist= libblacklist
.endif
diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map
index d28991d..0d5dfec 100644
--- a/lib/libc/gen/Symbol.map
+++ b/lib/libc/gen/Symbol.map
@@ -410,10 +410,12 @@ FBSD_1.3 {
};
FBSD_1.4 {
+ getnetgrent_r;
pthread_mutex_consistent;
pthread_mutexattr_getrobust;
pthread_mutexattr_setrobust;
scandir_b;
+ stravis;
};
FBSDprivate_1.0 {
diff --git a/lib/libc/gen/getnetgrent.3 b/lib/libc/gen/getnetgrent.3
index 4cc2a21..8547e66 100644
--- a/lib/libc/gen/getnetgrent.3
+++ b/lib/libc/gen/getnetgrent.3
@@ -28,7 +28,7 @@
.\" @(#)getnetgrent.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd June 4, 1993
+.Dd June 5, 2016
.Dt GETNETGRENT 3
.Os
.Sh NAME
@@ -44,6 +44,8 @@
.Ft int
.Fn getnetgrent "char **host" "char **user" "char **domain"
.Ft int
+.Fn getnetgrent_r "char **host" "char **user" "char **domain" "char *buf" "size_t bufsize"
+.Ft int
.Fn innetgr "const char *netgroup" "const char *host" "const char *user" "const char *domain"
.Ft void
.Fn setnetgrent "const char *netgroup"
@@ -68,7 +70,7 @@ The function
sets the three pointer arguments to the strings of the next member of the
current netgroup.
If any of the string pointers are
-.Sy (char *)0
+.Dv NULL
that field is considered a wildcard.
.Pp
The functions
@@ -95,7 +97,7 @@ If any of the
or
.Sy domain
arguments are
-.Sy (char *)0
+.Dv NULL
those fields will match any string value in the netgroup member.
.Sh RETURN VALUES
The function
diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c
index 0dcf2a2..d71928e 100644
--- a/lib/libc/gen/getnetgrent.c
+++ b/lib/libc/gen/getnetgrent.c
@@ -36,12 +36,21 @@ static char sccsid[] = "@(#)getnetgrent.c 8.2 (Berkeley) 4/27/95";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "namespace.h"
+
#include <ctype.h>
+#include <errno.h>
+#include <netdb.h>
+#include <nsswitch.h>
+#include <pthread.h>
+#include <pthread_np.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "nss_tls.h"
+
#ifdef YP
/*
* Notes:
@@ -98,6 +107,16 @@ static int _yp_innetgr;
#define _PATH_NETGROUP "/etc/netgroup"
#endif
+enum constants {
+ NGRP_STORAGE_INITIAL = 1 << 10, /* 1 KByte */
+ NGRP_STORAGE_MAX = 1 << 20, /* 1 MByte */
+};
+
+static const ns_src defaultsrc[] = {
+ { NSSRC_COMPAT, NS_SUCCESS },
+ { NULL, 0 },
+};
+
/*
* Static Variables and functions used by setnetgrent(), getnetgrent() and
* endnetgrent().
@@ -117,51 +136,212 @@ struct netgrp {
struct netgrp *ng_next; /* Chain ptr */
char *ng_str[3]; /* Field pointers, see below */
};
+
+struct netgr_state {
+ FILE *st_netf;
+ struct linelist *st_linehead;
+ struct netgrp *st_nextgrp;
+ struct netgrp *st_gr;
+ char *st_grname;
+};
+
#define NG_HOST 0 /* Host name */
#define NG_USER 1 /* User name */
#define NG_DOM 2 /* and Domain name */
-static struct linelist *linehead = (struct linelist *)0;
-static struct netgrp *nextgrp = (struct netgrp *)0;
-static struct {
- struct netgrp *gr;
- char *grname;
-} grouphead = {
- (struct netgrp *)0,
- (char *)0,
-};
-static FILE *netf = (FILE *)0;
+static void netgr_endstate(void *);
+NSS_TLS_HANDLING(netgr);
+
+static int files_endnetgrent(void *, void *, va_list);
+static int files_getnetgrent_r(void *, void *, va_list);
+static int files_setnetgrent(void *, void *, va_list);
+
+static int compat_endnetgrent(void *, void *, va_list);
+static int compat_innetgr(void *, void *, va_list);
+static int compat_getnetgrent_r(void *, void *, va_list);
+static int compat_setnetgrent(void *, void *, va_list);
-static int parse_netgrp(const char *);
-static struct linelist *read_for_group(const char *);
-void setnetgrent(const char *);
-void endnetgrent(void);
-int getnetgrent(char **, char **, char **);
-int innetgr(const char *, const char *, const char *, const char *);
+static void _compat_clearstate(void);
+static int _getnetgrent_r(char **, char **, char **, char *, size_t, int *,
+ struct netgr_state *);
+static int _innetgr_fallback(void *, void *, const char *, const char *,
+ const char *, const char *);
+static int innetgr_fallback(void *, void *, va_list);
+static int parse_netgrp(const char *, struct netgr_state *, int);
+static struct linelist *read_for_group(const char *, struct netgr_state *, int);
#define LINSIZ 1024 /* Length of netgroup file line */
+static const ns_dtab getnetgrent_dtab[] = {
+ NS_FILES_CB(files_getnetgrent_r, NULL)
+ NS_COMPAT_CB(compat_getnetgrent_r, NULL)
+ { NULL, NULL, NULL },
+};
+
+static const ns_dtab setnetgrent_dtab[] = {
+ NS_FILES_CB(files_setnetgrent, NULL)
+ NS_COMPAT_CB(compat_setnetgrent, NULL)
+ { NULL, NULL, NULL },
+};
+
+static const ns_dtab endnetgrent_dtab[] = {
+ NS_FILES_CB(files_endnetgrent, NULL)
+ NS_COMPAT_CB(compat_endnetgrent, NULL)
+ { NULL, NULL, NULL },
+};
+
+static struct netgr_state compat_state;
+
+static void
+netgr_endstate(void *arg)
+{
+ struct linelist *lp, *olp;
+ struct netgrp *gp, *ogp;
+ struct netgr_state *st;
+
+ st = (struct netgr_state *)arg;
+ lp = st->st_linehead;
+ while (lp != NULL) {
+ olp = lp;
+ lp = lp->l_next;
+ free(olp->l_groupname);
+ free(olp->l_line);
+ free(olp);
+ }
+ st->st_linehead = NULL;
+ if (st->st_grname != NULL) {
+ free(st->st_grname);
+ st->st_grname = NULL;
+ }
+ gp = st->st_gr;
+ while (gp != NULL) {
+ ogp = gp;
+ gp = gp->ng_next;
+ free(ogp->ng_str[NG_HOST]);
+ free(ogp->ng_str[NG_USER]);
+ free(ogp->ng_str[NG_DOM]);
+ free(ogp);
+ }
+ st->st_gr = NULL;
+ st->st_nextgrp = NULL;
+}
+
+static int
+files_getnetgrent_r(void *retval, void *mdata, va_list ap)
+{
+ struct netgr_state *st;
+ char **hostp, **userp, **domp, *buf;
+ size_t bufsize;
+ int *errnop;
+
+ hostp = va_arg(ap, char **);
+ userp = va_arg(ap, char **);
+ domp = va_arg(ap, char **);
+ buf = va_arg(ap, char *);
+ bufsize = va_arg(ap, size_t);
+ errnop = va_arg(ap, int *);
+
+ if (netgr_getstate(&st) != 0)
+ return (NS_UNAVAIL);
+
+ return (_getnetgrent_r(hostp, userp, domp, buf, bufsize, errnop, st));
+}
+
+static int
+files_setnetgrent(void *retval, void *mdata, va_list ap)
+{
+ const ns_src src[] = {
+ { NSSRC_FILES, NS_SUCCESS },
+ { NULL, 0 },
+ };
+ struct netgr_state *st;
+ const char *group;
+ int rv;
+
+ group = va_arg(ap, const char *);
+
+ if (group == NULL || group[0] == '\0')
+ return (NS_RETURN);
+
+ rv = netgr_getstate(&st);
+ if (rv != 0)
+ return (NS_UNAVAIL);
+
+ if (st->st_gr == NULL || strcmp(group, st->st_grname) != 0) {
+ (void)_nsdispatch(NULL, endnetgrent_dtab, NSDB_NETGROUP,
+ "endnetgrent", src);
+ if ((st->st_netf = fopen(_PATH_NETGROUP, "re")) != NULL) {
+ if (parse_netgrp(group, st, 0) != 0)
+ (void)_nsdispatch(NULL, endnetgrent_dtab,
+ NSDB_NETGROUP, "endnetgrent", src);
+ else
+ st->st_grname = strdup(group);
+ (void)fclose(st->st_netf);
+ st->st_netf = NULL;
+ }
+ }
+ st->st_nextgrp = st->st_gr;
+ return (st->st_grname != NULL ? NS_SUCCESS : NS_NOTFOUND);
+}
+
+static int
+files_endnetgrent(void *retval, void *mdata, va_list ap)
+{
+ struct netgr_state *st;
+
+ if (netgr_getstate(&st) != 0)
+ return (NS_UNAVAIL);
+ netgr_endstate(st);
+ return (NS_SUCCESS);
+}
+
+static int
+compat_getnetgrent_r(void *retval, void *mdata, va_list ap)
+{
+ char **hostp, **userp, **domp, *buf;
+ size_t bufsize;
+ int *errnop;
+#ifdef YP
+ _yp_innetgr = 0;
+#endif
+
+ hostp = va_arg(ap, char **);
+ userp = va_arg(ap, char **);
+ domp = va_arg(ap, char **);
+ buf = va_arg(ap, char *);
+ bufsize = va_arg(ap, size_t);
+ errnop = va_arg(ap, int *);
+
+ return (_getnetgrent_r(hostp, userp, domp, buf, bufsize, errnop,
+ &compat_state));
+}
+
/*
- * setnetgrent()
+ * compat_setnetgrent()
* Parse the netgroup file looking for the netgroup and build the list
* of netgrp structures. Let parse_netgrp() and read_for_group() do
* most of the work.
*/
-void
-setnetgrent(const char *group)
+static int
+compat_setnetgrent(void *retval, void *mdata, va_list ap)
{
+ FILE *netf;
+ const char *group;
#ifdef YP
struct stat _yp_statp;
char _yp_plus;
#endif
- /* Sanity check */
+ group = va_arg(ap, const char *);
+ /* Sanity check */
if (group == NULL || !strlen(group))
- return;
+ return (NS_RETURN);
+
+ if (compat_state.st_gr == NULL ||
+ strcmp(group, compat_state.st_grname) != 0) {
+ _compat_clearstate();
- if (grouphead.gr == NULL || strcmp(group, grouphead.grname)) {
- endnetgrent();
#ifdef YP
/* Presumed guilty until proven innocent. */
_use_only_yp = 0;
@@ -173,6 +353,7 @@ setnetgrent(const char *group)
errno == ENOENT) || _yp_statp.st_size == 0)
_use_only_yp = _netgr_yp_enabled = 1;
if ((netf = fopen(_PATH_NETGROUP,"re")) != NULL ||_use_only_yp){
+ compat_state.st_netf = netf;
/*
* Icky: grab the first character of the netgroup file
* and turn on NIS if it's a '+'. rewind the stream
@@ -193,79 +374,81 @@ setnetgrent(const char *group)
/* dohw! */
if (netf != NULL)
fclose(netf);
- return;
+ return (NS_RETURN);
}
#else
if ((netf = fopen(_PATH_NETGROUP, "re"))) {
+ compat_state.st_netf = netf;
#endif
- if (parse_netgrp(group))
- endnetgrent();
- else {
- grouphead.grname = strdup(group);
+ if (parse_netgrp(group, &compat_state, 1)) {
+ _compat_clearstate();
+ } else {
+ compat_state.st_grname = strdup(group);
}
if (netf)
fclose(netf);
}
}
- nextgrp = grouphead.gr;
+ compat_state.st_nextgrp = compat_state.st_gr;
+ return (NS_SUCCESS);
}
-/*
- * Get the next netgroup off the list.
- */
-int
-getnetgrent(char **hostp, char **userp, char **domp)
+static void
+_compat_clearstate(void)
{
+
#ifdef YP
- _yp_innetgr = 0;
+ _netgr_yp_enabled = 0;
#endif
-
- if (nextgrp) {
- *hostp = nextgrp->ng_str[NG_HOST];
- *userp = nextgrp->ng_str[NG_USER];
- *domp = nextgrp->ng_str[NG_DOM];
- nextgrp = nextgrp->ng_next;
- return (1);
- }
- return (0);
+ netgr_endstate(&compat_state);
}
/*
- * endnetgrent() - cleanup
+ * compat_endnetgrent() - cleanup
*/
-void
-endnetgrent(void)
+static int
+compat_endnetgrent(void *retval, void *mdata, va_list ap)
{
- struct linelist *lp, *olp;
- struct netgrp *gp, *ogp;
- lp = linehead;
- while (lp) {
- olp = lp;
- lp = lp->l_next;
- free(olp->l_groupname);
- free(olp->l_line);
- free(olp);
- }
- linehead = NULL;
- if (grouphead.grname) {
- free(grouphead.grname);
- grouphead.grname = NULL;
- }
- gp = grouphead.gr;
- while (gp) {
- ogp = gp;
- gp = gp->ng_next;
- free(ogp->ng_str[NG_HOST]);
- free(ogp->ng_str[NG_USER]);
- free(ogp->ng_str[NG_DOM]);
- free(ogp);
+ _compat_clearstate();
+ return (NS_SUCCESS);
+}
+
+int
+_getnetgrent_r(char **hostp, char **userp, char **domp, char *buf,
+ size_t bufsize, int *errnop, struct netgr_state *st)
+{
+ char *p, *src;
+ size_t len;
+ int rv;
+
+#define COPY_NG_ELEM(dstp, i) do { \
+ src = st->st_nextgrp->ng_str[(i)]; \
+ if (src == NULL) \
+ src = ""; \
+ len = strlcpy(p, src, bufsize); \
+ if (len >= bufsize) { \
+ *errnop = ERANGE; \
+ return (NS_RETURN); \
+ } \
+ *(dstp) = p; \
+ p += len + 1; \
+ bufsize -= len + 1; \
+} while (0)
+
+ p = buf;
+ if (st->st_nextgrp != NULL) {
+ COPY_NG_ELEM(hostp, NG_HOST);
+ COPY_NG_ELEM(userp, NG_USER);
+ COPY_NG_ELEM(domp, NG_DOM);
+ st->st_nextgrp = st->st_nextgrp->ng_next;
+ rv = NS_SUCCESS;
+ } else {
+ rv = NS_NOTFOUND;
}
- grouphead.gr = NULL;
- nextgrp = NULL;
-#ifdef YP
- _netgr_yp_enabled = 0;
-#endif
+#undef COPY_NG_ELEM
+
+ return (rv);
}
#ifdef YP
@@ -343,20 +526,29 @@ _revnetgr_lookup(char* lookupdom, char* map, const char* str,
/*
* Search for a match in a netgroup.
*/
-int
-innetgr(const char *group, const char *host, const char *user, const char *dom)
+static int
+compat_innetgr(void *retval, void *mdata, va_list ap)
{
- char *hst, *usr, *dm;
- /* Sanity check */
-
+#ifdef YP
+ const ns_src src[] = {
+ { mdata, NS_SUCCESS },
+ { NULL, 0 },
+ };
+#endif
+ const char *group, *host, *user, *dom;
+
+ group = va_arg(ap, const char *);
+ host = va_arg(ap, const char *);
+ user = va_arg(ap, const char *);
+ dom = va_arg(ap, const char *);
+
if (group == NULL || !strlen(group))
- return (0);
+ return (NS_RETURN);
#ifdef YP
_yp_innetgr = 1;
-#endif
- setnetgrent(group);
-#ifdef YP
+ (void)_nsdispatch(NULL, setnetgrent_dtab, NSDB_NETGROUP, "setnetgrent",
+ src, group);
_yp_innetgr = 0;
/*
* If we're in NIS-only mode, do the search using
@@ -384,38 +576,105 @@ innetgr(const char *group, const char *host, const char *user, const char *dom)
if (_use_only_yp && (host == NULL) != (user == NULL)) {
int ret;
if(yp_get_default_domain(&_netgr_yp_domain))
- return (0);
- ret = _revnetgr_lookup(_netgr_yp_domain,
+ return (NS_NOTFOUND);
+ ret = _revnetgr_lookup(_netgr_yp_domain,
host?"netgroup.byhost":"netgroup.byuser",
host?host:user, dom, group);
- if (ret == 1)
- return (1);
- else if (ret == 0 && dom != NULL)
- return (0);
+ if (ret == 1) {
+ *(int *)retval = 1;
+ return (NS_SUCCESS);
+ } else if (ret == 0 && dom != NULL) {
+ *(int *)retval = 0;
+ return (NS_SUCCESS);
+ }
}
-
- setnetgrent(group);
#endif /* YP */
- while (getnetgrent(&hst, &usr, &dm))
- if ((host == NULL || hst == NULL || !strcmp(host, hst)) &&
- (user == NULL || usr == NULL || !strcmp(user, usr)) &&
- ( dom == NULL || dm == NULL || !strcmp(dom, dm))) {
- endnetgrent();
- return (1);
+ return (_innetgr_fallback(retval, mdata, group, host, user, dom));
+}
+
+static int
+_innetgr_fallback(void *retval, void *mdata, const char *group, const char *host,
+ const char *user, const char *dom)
+{
+ const ns_src src[] = {
+ { mdata, NS_SUCCESS },
+ { NULL, 0 },
+ };
+ char *h, *u, *d;
+ char *buf;
+ size_t bufsize;
+ int rv, ret_errno;
+
+ if (group == NULL || group[0] == '\0')
+ return (NS_RETURN);
+
+ bufsize = NGRP_STORAGE_INITIAL;
+ buf = malloc(bufsize);
+ if (buf == NULL)
+ return (NS_UNAVAIL);
+
+ *(int *)retval = 0;
+
+ (void)_nsdispatch(NULL, setnetgrent_dtab, NSDB_NETGROUP, "setnetgrent",
+ src, group);
+
+ for (;;) {
+ do {
+ ret_errno = 0;
+ rv = _nsdispatch(NULL, getnetgrent_dtab, NSDB_NETGROUP,
+ "getnetgrent_r", src, &h, &u, &d, buf, bufsize,
+ &ret_errno);
+ if (rv != NS_SUCCESS && ret_errno == ERANGE) {
+ bufsize *= 2;
+ if (bufsize > NGRP_STORAGE_MAX ||
+ (buf = reallocf(buf, bufsize)) == NULL)
+ goto out;
+ }
+ } while (rv != NS_SUCCESS && ret_errno == ERANGE);
+
+ if (rv != NS_SUCCESS) {
+ if (rv == NS_NOTFOUND && ret_errno == 0)
+ rv = NS_SUCCESS;
+ break;
}
- endnetgrent();
- return (0);
+
+ if ((host == NULL || h == NULL || strcmp(host, h) == 0) &&
+ (user == NULL || u == NULL || strcmp(user, u) == 0) &&
+ (dom == NULL || d == NULL || strcmp(dom, d) == 0)) {
+ *(int *)retval = 1;
+ break;
+ }
+ }
+
+out:
+ free(buf);
+ (void)_nsdispatch(NULL, endnetgrent_dtab, NSDB_NETGROUP, "endnetgrent",
+ src);
+ return (rv);
+}
+
+static int
+innetgr_fallback(void *retval, void *mdata, va_list ap)
+{
+ const char *group, *host, *user, *dom;
+
+ group = va_arg(ap, const char *);
+ host = va_arg(ap, const char *);
+ user = va_arg(ap, const char *);
+ dom = va_arg(ap, const char *);
+
+ return (_innetgr_fallback(retval, mdata, group, host, user, dom));
}
/*
* Parse the netgroup file setting up the linked lists.
*/
static int
-parse_netgrp(const char *group)
+parse_netgrp(const char *group, struct netgr_state *st, int niscompat)
{
struct netgrp *grp;
- struct linelist *lp = linehead;
+ struct linelist *lp = st->st_linehead;
char **ng;
char *epos, *gpos, *pos, *spos;
int freepos, len, strpos;
@@ -431,7 +690,7 @@ parse_netgrp(const char *group)
break;
lp = lp->l_next;
}
- if (lp == NULL && (lp = read_for_group(group)) == NULL)
+ if (lp == NULL && (lp = read_for_group(group, st, niscompat)) == NULL)
return (1);
if (lp->l_parsed) {
#ifdef DEBUG
@@ -493,8 +752,8 @@ parse_netgrp(const char *group)
}
bcopy(spos, ng[strpos], len + 1);
}
- grp->ng_next = grouphead.gr;
- grouphead.gr = grp;
+ grp->ng_next = st->st_gr;
+ st->st_gr = grp;
#ifdef DEBUG
/*
* Note: on other platforms, malformed netgroup
@@ -515,7 +774,7 @@ parse_netgrp(const char *group)
#endif
} else {
spos = strsep(&pos, ", \t");
- if (parse_netgrp(spos))
+ if (parse_netgrp(spos, st, niscompat))
continue;
}
if (pos == NULL)
@@ -531,19 +790,22 @@ parse_netgrp(const char *group)
* is found. Return 1 if eof is encountered.
*/
static struct linelist *
-read_for_group(const char *group)
+read_for_group(const char *group, struct netgr_state *st, int niscompat)
{
char *linep, *olinep, *pos, *spos;
int len, olen;
int cont;
struct linelist *lp;
char line[LINSIZ + 2];
+ FILE *netf;
#ifdef YP
char *result;
int resultlen;
linep = NULL;
- while (_netgr_yp_enabled || fgets(line, LINSIZ, netf) != NULL) {
+ netf = st->st_netf;
+ while ((_netgr_yp_enabled && niscompat) ||
+ fgets(line, LINSIZ, netf) != NULL) {
if (_netgr_yp_enabled) {
if(!_netgr_yp_domain)
if(yp_get_default_domain(&_netgr_yp_domain))
@@ -558,6 +820,10 @@ read_for_group(const char *group)
continue;
}
}
+ if (strlen(result) == 0) {
+ free(result);
+ return (NULL);
+ }
snprintf(line, LINSIZ, "%s %s", group, result);
free(result);
}
@@ -567,7 +833,7 @@ read_for_group(const char *group)
#endif
pos = (char *)&line;
#ifdef YP
- if (*pos == '+') {
+ if (niscompat && *pos == '+') {
_netgr_yp_enabled = 1;
continue;
}
@@ -584,11 +850,11 @@ read_for_group(const char *group)
while (*pos == ' ' || *pos == '\t')
pos++;
if (*pos != '\n' && *pos != '\0') {
- lp = (struct linelist *)malloc(sizeof (*lp));
- if (lp == NULL)
+ lp = malloc(sizeof (*lp));
+ if (lp == NULL)
return (NULL);
lp->l_parsed = 0;
- lp->l_groupname = (char *)malloc(len + 1);
+ lp->l_groupname = malloc(len + 1);
if (lp->l_groupname == NULL) {
free(lp);
return (NULL);
@@ -614,6 +880,8 @@ read_for_group(const char *group)
if (linep == NULL) {
free(lp->l_groupname);
free(lp);
+ if (olen > 0)
+ free(olinep);
return (NULL);
}
if (olen > 0) {
@@ -634,8 +902,8 @@ read_for_group(const char *group)
}
} while (cont);
lp->l_line = linep;
- lp->l_next = linehead;
- linehead = lp;
+ lp->l_next = st->st_linehead;
+ st->st_linehead = lp;
/*
* If this is the one we wanted, we are done.
@@ -656,3 +924,93 @@ read_for_group(const char *group)
#endif
return (NULL);
}
+
+int
+getnetgrent_r(char **hostp, char **userp, char **domp, char *buf, size_t bufsize)
+{
+ int rv, ret_errno;
+
+ ret_errno = 0;
+ rv = _nsdispatch(NULL, getnetgrent_dtab, NSDB_NETGROUP, "getnetgrent_r",
+ defaultsrc, hostp, userp, domp, buf, bufsize, &ret_errno);
+ if (rv == NS_SUCCESS) {
+ return (1);
+ } else {
+ errno = ret_errno;
+ return (0);
+ }
+}
+
+int
+getnetgrent(char **hostp, char **userp, char **domp)
+{
+ static char *ngrp_storage;
+ static size_t ngrp_storage_size;
+ int ret_errno, rv;
+
+ if (ngrp_storage == NULL) {
+ ngrp_storage_size = NGRP_STORAGE_INITIAL;
+ ngrp_storage = malloc(ngrp_storage_size);
+ if (ngrp_storage == NULL)
+ return (0);
+ }
+
+ do {
+ ret_errno = 0;
+ rv = _nsdispatch(NULL, getnetgrent_dtab, NSDB_NETGROUP,
+ "getnetgrent_r", defaultsrc, hostp, userp, domp,
+ ngrp_storage, ngrp_storage_size, &ret_errno);
+ if (rv != NS_SUCCESS && ret_errno == ERANGE) {
+ ngrp_storage_size *= 2;
+ if (ngrp_storage_size > NGRP_STORAGE_MAX) {
+ free(ngrp_storage);
+ ngrp_storage = NULL;
+ errno = ERANGE;
+ return (0);
+ }
+ ngrp_storage = reallocf(ngrp_storage,
+ ngrp_storage_size);
+ if (ngrp_storage == NULL)
+ return (0);
+ }
+ } while (rv != NS_SUCCESS && ret_errno == ERANGE);
+
+ if (rv == NS_SUCCESS) {
+ return (1);
+ } else {
+ errno = ret_errno;
+ return (0);
+ }
+}
+
+void
+setnetgrent(const char *netgroup)
+{
+
+ (void)_nsdispatch(NULL, setnetgrent_dtab, NSDB_NETGROUP, "setnetgrent",
+ defaultsrc, netgroup);
+}
+
+void
+endnetgrent(void)
+{
+
+ (void)_nsdispatch(NULL, endnetgrent_dtab, NSDB_NETGROUP, "endnetgrent",
+ defaultsrc);
+}
+
+int
+innetgr(const char *netgroup, const char *host, const char *user,
+ const char *domain)
+{
+ static const ns_dtab dtab[] = {
+ NS_COMPAT_CB(compat_innetgr, NULL)
+ NS_FALLBACK_CB(innetgr_fallback)
+ { NULL, NULL, NULL },
+ };
+ int result, rv;
+
+ rv = _nsdispatch(&result, dtab, NSDB_NETGROUP, "innetgr", defaultsrc,
+ netgroup, host, user, domain);
+ return (rv == NS_SUCCESS ? result : 0);
+}
diff --git a/lib/libc/gen/utime.3 b/lib/libc/gen/utime.3
index 1951613..20c7916 100644
--- a/lib/libc/gen/utime.3
+++ b/lib/libc/gen/utime.3
@@ -28,7 +28,7 @@
.\" @(#)utime.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd June 4, 1993
+.Dd June 9, 2016
.Dt UTIME 3
.Os
.Sh NAME
@@ -43,7 +43,8 @@
.Sh DESCRIPTION
.Bf -symbolic
This interface is obsoleted by
-.Xr utimes 2 .
+.Xr utimensat 2
+because it is not accurate to fractions of a second.
.Ef
.Pp
The
@@ -79,6 +80,7 @@ for any of the errors specified for the library function
.Xr utimes 2 .
.Sh SEE ALSO
.Xr stat 2 ,
+.Xr utimensat 2 ,
.Xr utimes 2
.Sh STANDARDS
The
diff --git a/lib/libc/resolv/res_init.c b/lib/libc/resolv/res_init.c
index 8b58559..732fb1e 100644
--- a/lib/libc/resolv/res_init.c
+++ b/lib/libc/resolv/res_init.c
@@ -411,20 +411,21 @@ __res_vinit(res_state statp, int preinit) {
hints.ai_socktype = SOCK_DGRAM; /*dummy*/
hints.ai_flags = AI_NUMERICHOST;
sprintf(sbuf, "%u", NAMESERVER_PORT);
- if (getaddrinfo(cp, sbuf, &hints, &ai) == 0 &&
- ai->ai_addrlen <= minsiz) {
- if (statp->_u._ext.ext != NULL) {
- memcpy(&statp->_u._ext.ext->nsaddrs[nserv],
- ai->ai_addr, ai->ai_addrlen);
+ if (getaddrinfo(cp, sbuf, &hints, &ai) == 0) {
+ if (ai->ai_addrlen <= minsiz) {
+ if (statp->_u._ext.ext != NULL) {
+ memcpy(&statp->_u._ext.ext->nsaddrs[nserv],
+ ai->ai_addr, ai->ai_addrlen);
+ }
+ if (ai->ai_addrlen <=
+ sizeof(statp->nsaddr_list[nserv])) {
+ memcpy(&statp->nsaddr_list[nserv],
+ ai->ai_addr, ai->ai_addrlen);
+ } else
+ statp->nsaddr_list[nserv].sin_family = 0;
+ nserv++;
}
- if (ai->ai_addrlen <=
- sizeof(statp->nsaddr_list[nserv])) {
- memcpy(&statp->nsaddr_list[nserv],
- ai->ai_addr, ai->ai_addrlen);
- } else
- statp->nsaddr_list[nserv].sin_family = 0;
freeaddrinfo(ai);
- nserv++;
}
}
continue;
diff --git a/lib/libc/rpc/getnetpath.c b/lib/libc/rpc/getnetpath.c
index ce2984b..8d31136 100644
--- a/lib/libc/rpc/getnetpath.c
+++ b/lib/libc/rpc/getnetpath.c
@@ -262,7 +262,7 @@ _get_next_token(char *npp, int token)
*cp++ = '\0'; /* null-terminate token */
/* get rid of any backslash escapes */
ep = npp;
- while ((np = strchr(ep, '\\')) != 0) {
+ while ((np = strchr(ep, '\\')) != NULL) {
if (np[1] == '\\')
np++;
strcpy(np, (ep = &np[1])); /* XXX: overlapping string copy */
diff --git a/lib/libc/rpc/rpc_callmsg.c b/lib/libc/rpc/rpc_callmsg.c
index 0e29e09..4063e8b 100644
--- a/lib/libc/rpc/rpc_callmsg.c
+++ b/lib/libc/rpc/rpc_callmsg.c
@@ -193,11 +193,11 @@ xdr_callmsg(XDR *xdrs, struct rpc_msg *cmsg)
xdr_u_int32_t(xdrs, &(cmsg->rm_xid)) &&
xdr_enum(xdrs, (enum_t *) prm_direction) &&
(cmsg->rm_direction == CALL) &&
- xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
+ xdr_rpcvers(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
(cmsg->rm_call.cb_rpcvers == RPC_MSG_VERSION) &&
- xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_prog)) &&
- xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_vers)) &&
- xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_proc)) &&
+ xdr_rpcprog(xdrs, &(cmsg->rm_call.cb_prog)) &&
+ xdr_rpcvers(xdrs, &(cmsg->rm_call.cb_vers)) &&
+ xdr_rpcproc(xdrs, &(cmsg->rm_call.cb_proc)) &&
xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_cred)) )
return (xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_verf)));
return (FALSE);
diff --git a/lib/libc/rpc/rpc_prot.c b/lib/libc/rpc/rpc_prot.c
index 53fc70a..50d11cc 100644
--- a/lib/libc/rpc/rpc_prot.c
+++ b/lib/libc/rpc/rpc_prot.c
@@ -119,9 +119,9 @@ xdr_accepted_reply(XDR *xdrs, struct accepted_reply *ar)
return ((*(ar->ar_results.proc))(xdrs, ar->ar_results.where));
case PROG_MISMATCH:
- if (! xdr_u_int32_t(xdrs, &(ar->ar_vers.low)))
+ if (!xdr_rpcvers(xdrs, &(ar->ar_vers.low)))
return (FALSE);
- return (xdr_u_int32_t(xdrs, &(ar->ar_vers.high)));
+ return (xdr_rpcvers(xdrs, &(ar->ar_vers.high)));
case GARBAGE_ARGS:
case SYSTEM_ERR:
@@ -152,9 +152,9 @@ xdr_rejected_reply(XDR *xdrs, struct rejected_reply *rr)
switch (rr->rj_stat) {
case RPC_MISMATCH:
- if (! xdr_u_int32_t(xdrs, &(rr->rj_vers.low)))
+ if (! xdr_rpcvers(xdrs, &(rr->rj_vers.low)))
return (FALSE);
- return (xdr_u_int32_t(xdrs, &(rr->rj_vers.high)));
+ return (xdr_rpcvers(xdrs, &(rr->rj_vers.high)));
case AUTH_ERROR:
prj_why = &rr->rj_why;
@@ -217,8 +217,8 @@ xdr_callhdr(XDR *xdrs, struct rpc_msg *cmsg)
(xdrs->x_op == XDR_ENCODE) &&
xdr_u_int32_t(xdrs, &(cmsg->rm_xid)) &&
xdr_enum(xdrs, (enum_t *) prm_direction) &&
- xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
- xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_prog)) )
+ xdr_rpcvers(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
+ xdr_rpcprog(xdrs, &(cmsg->rm_call.cb_prog)) )
return (xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_vers)));
return (FALSE);
}
diff --git a/lib/libc/rpc/rpcb_clnt.c b/lib/libc/rpc/rpcb_clnt.c
index 02206a9..f9d89c1 100644
--- a/lib/libc/rpc/rpcb_clnt.c
+++ b/lib/libc/rpc/rpcb_clnt.c
@@ -1010,7 +1010,7 @@ done:
*
* Assuming that the address is all properly allocated
*/
-int
+bool_t
rpcb_getaddr(rpcprog_t program, rpcvers_t version, const struct netconfig *nconf,
struct netbuf *address, const char *host)
{
diff --git a/lib/libc/rpc/rpcb_prot.c b/lib/libc/rpc/rpcb_prot.c
index 2b87f34..c462e19 100644
--- a/lib/libc/rpc/rpcb_prot.c
+++ b/lib/libc/rpc/rpcb_prot.c
@@ -56,10 +56,10 @@ __FBSDID("$FreeBSD$");
bool_t
xdr_rpcb(XDR *xdrs, RPCB *objp)
{
- if (!xdr_u_int32_t(xdrs, &objp->r_prog)) {
+ if (!xdr_rpcprog(xdrs, &objp->r_prog)) {
return (FALSE);
}
- if (!xdr_u_int32_t(xdrs, &objp->r_vers)) {
+ if (!xdr_rpcvers(xdrs, &objp->r_vers)) {
return (FALSE);
}
if (!xdr_string(xdrs, &objp->r_netid, (u_int)~0)) {
@@ -243,13 +243,13 @@ xdr_rpcb_rmtcallargs(XDR *xdrs, struct rpcb_rmtcallargs *p)
buf = XDR_INLINE(xdrs, 3 * BYTES_PER_XDR_UNIT);
if (buf == NULL) {
- if (!xdr_u_int32_t(xdrs, &objp->prog)) {
+ if (!xdr_rpcprog(xdrs, &objp->prog)) {
return (FALSE);
}
- if (!xdr_u_int32_t(xdrs, &objp->vers)) {
+ if (!xdr_rpcvers(xdrs, &objp->vers)) {
return (FALSE);
}
- if (!xdr_u_int32_t(xdrs, &objp->proc)) {
+ if (!xdr_rpcproc(xdrs, &objp->proc)) {
return (FALSE);
}
} else {
diff --git a/lib/libc/rpc/rpcb_st_xdr.c b/lib/libc/rpc/rpcb_st_xdr.c
index 8919144..9abc028 100644
--- a/lib/libc/rpc/rpcb_st_xdr.c
+++ b/lib/libc/rpc/rpcb_st_xdr.c
@@ -51,10 +51,10 @@ xdr_rpcbs_addrlist(XDR *xdrs, rpcbs_addrlist *objp)
{
struct rpcbs_addrlist **pnext;
- if (!xdr_u_int32_t(xdrs, &objp->prog)) {
+ if (!xdr_rpcprog(xdrs, &objp->prog)) {
return (FALSE);
}
- if (!xdr_u_int32_t(xdrs, &objp->vers)) {
+ if (!xdr_rpcvers(xdrs, &objp->vers)) {
return (FALSE);
}
if (!xdr_int(xdrs, &objp->success)) {
@@ -89,13 +89,13 @@ xdr_rpcbs_rmtcalllist(XDR *xdrs, rpcbs_rmtcalllist *objp)
if (xdrs->x_op == XDR_ENCODE) {
buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
if (buf == NULL) {
- if (!xdr_u_int32_t(xdrs, &objp->prog)) {
+ if (!xdr_rpcprog(xdrs, &objp->prog)) {
return (FALSE);
}
- if (!xdr_u_int32_t(xdrs, &objp->vers)) {
+ if (!xdr_rpcvers(xdrs, &objp->vers)) {
return (FALSE);
}
- if (!xdr_u_int32_t(xdrs, &objp->proc)) {
+ if (!xdr_rpcproc(xdrs, &objp->proc)) {
return (FALSE);
}
if (!xdr_int(xdrs, &objp->success)) {
@@ -128,13 +128,13 @@ xdr_rpcbs_rmtcalllist(XDR *xdrs, rpcbs_rmtcalllist *objp)
} else if (xdrs->x_op == XDR_DECODE) {
buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
if (buf == NULL) {
- if (!xdr_u_int32_t(xdrs, &objp->prog)) {
+ if (!xdr_rpcprog(xdrs, &objp->prog)) {
return (FALSE);
}
- if (!xdr_u_int32_t(xdrs, &objp->vers)) {
+ if (!xdr_rpcvers(xdrs, &objp->vers)) {
return (FALSE);
}
- if (!xdr_u_int32_t(xdrs, &objp->proc)) {
+ if (!xdr_rpcproc(xdrs, &objp->proc)) {
return (FALSE);
}
if (!xdr_int(xdrs, &objp->success)) {
@@ -164,13 +164,13 @@ xdr_rpcbs_rmtcalllist(XDR *xdrs, rpcbs_rmtcalllist *objp)
}
return (TRUE);
}
- if (!xdr_u_int32_t(xdrs, &objp->prog)) {
+ if (!xdr_rpcprog(xdrs, &objp->prog)) {
return (FALSE);
}
- if (!xdr_u_int32_t(xdrs, &objp->vers)) {
+ if (!xdr_rpcvers(xdrs, &objp->vers)) {
return (FALSE);
}
- if (!xdr_u_int32_t(xdrs, &objp->proc)) {
+ if (!xdr_rpcproc(xdrs, &objp->proc)) {
return (FALSE);
}
if (!xdr_int(xdrs, &objp->success)) {
diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c
index e94e3bd..e09a5b2 100644
--- a/lib/libc/stdio/vfscanf.c
+++ b/lib/libc/stdio/vfscanf.c
@@ -873,7 +873,7 @@ doswitch:
n = *fmt;
if (n == ']'
|| (table->__collate_load_error ? n < c :
- __collate_range_cmp (table, n, c) < 0
+ __wcollate_range_cmp(table, n, c) < 0
)
) {
c = '-';
@@ -887,8 +887,8 @@ doswitch:
} while (c < n);
} else {
for (i = 0; i < 256; i ++)
- if ( __collate_range_cmp (table, c, i) < 0
- && __collate_range_cmp (table, i, n) <= 0
+ if (__wcollate_range_cmp(table, c, i) < 0 &&
+ __wcollate_range_cmp(table, i, n) <= 0
)
tab[i] = v;
}
diff --git a/lib/libc/sys/pdfork.2 b/lib/libc/sys/pdfork.2
index e057f76..5f1a86e 100644
--- a/lib/libc/sys/pdfork.2
+++ b/lib/libc/sys/pdfork.2
@@ -32,7 +32,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 7, 2014
+.Dd June 8, 2016
.Dt PDFORK 2
.Os
.Sh NAME
@@ -80,6 +80,10 @@ This option is not permitted in
capability mode (see
.Xr cap_enter 2 ) .
.El
+.Bl -tag -width ".Dv PD_DAEMON"
+.It Dv PD_CLOEXEC
+Set close-on-exec on process descriptor.
+.El
.Pp
.Fn pdgetpid
queries the process ID (PID) in the process descriptor
diff --git a/lib/libc/sys/utimes.2 b/lib/libc/sys/utimes.2
index 15db627..30d31d2 100644
--- a/lib/libc/sys/utimes.2
+++ b/lib/libc/sys/utimes.2
@@ -30,7 +30,7 @@
.\" @(#)utimes.2 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd July 3, 2014
+.Dd June 9, 2016
.Dt UTIMES 2
.Os
.Sh NAME
@@ -52,6 +52,14 @@
.Ft int
.Fn futimesat "int fd" "const char *path" "const struct timeval times[2]"
.Sh DESCRIPTION
+.Bf -symbolic
+These interfaces are obsoleted by
+.Xr futimens 2
+and
+.Xr utimensat 2
+because they are not accurate to nanoseconds.
+.Ef
+.Pp
The access and modification times of the file named by
.Fa path
or referenced by
@@ -223,6 +231,7 @@ nor a file descriptor associated with a directory.
.Sh SEE ALSO
.Xr chflags 2 ,
.Xr stat 2 ,
+.Xr utimensat 2 ,
.Xr utime 3
.Sh STANDARDS
The
@@ -231,7 +240,11 @@ function is expected to conform to
.St -xpg4.2 .
The
.Fn futimesat
-system call follows The Open Group Extended API Set 2 specification.
+system call follows The Open Group Extended API Set 2 specification
+but was replaced by
+.Fn utimensat
+in
+.St -p1003.1-2008 .
.Sh HISTORY
The
.Fn utimes
diff --git a/lib/libcasper/libcasper/libcasper_impl.h b/lib/libcasper/libcasper/libcasper_impl.h
index bf2e6ce..89f244d 100644
--- a/lib/libcasper/libcasper/libcasper_impl.h
+++ b/lib/libcasper/libcasper/libcasper_impl.h
@@ -46,11 +46,11 @@ bool fd_is_valid(int fd);
/* Private service functions. */
struct service *service_alloc(const char *name,
service_limit_func_t *limitfunc,
- service_command_func_t *commandfunc);
+ service_command_func_t *commandfunc, uint64_t flags);
void service_free(struct service *service);
void service_message(struct service *service,
struct service_connection *sconn);
-void service_start(struct service *service, int sock);
+void service_start(struct service *service, int sock, int procfd);
const char *service_name(struct service *service);
/* Private service connection functions. */
diff --git a/lib/libcasper/libcasper/libcasper_service.c b/lib/libcasper/libcasper/libcasper_service.c
index 5b1c7c8..1f9e8d6 100644
--- a/lib/libcasper/libcasper/libcasper_service.c
+++ b/lib/libcasper/libcasper/libcasper_service.c
@@ -73,7 +73,7 @@ service_find(const char *name)
struct casper_service *
service_register(const char *name, service_limit_func_t *limitfunc,
- service_command_func_t *commandfunc)
+ service_command_func_t *commandfunc, uint64_t flags)
{
struct casper_service *casserv;
@@ -88,7 +88,8 @@ service_register(const char *name, service_limit_func_t *limitfunc,
if (casserv == NULL)
return (NULL);
- casserv->cs_service = service_alloc(name, limitfunc, commandfunc);
+ casserv->cs_service = service_alloc(name, limitfunc, commandfunc,
+ flags);
if (casserv->cs_service == NULL) {
free(casserv);
return (NULL);
@@ -141,11 +142,10 @@ service_execute(int chanfd)
exit(1);
service = (struct service *)(uintptr_t)nvlist_take_number(nvl,
"service");
- //XXX: We should remove this?
procfd = nvlist_take_descriptor(nvl, "procfd");
nvlist_destroy(nvl);
- service_start(service, chanfd);
+ service_start(service, chanfd, procfd);
/* Not reached. */
exit(1);
}
@@ -199,7 +199,7 @@ service_register_core(int fd)
struct service_connection *sconn;
casserv = service_register(CORE_CASPER_NAME, casper_limit,
- casper_command);
+ casper_command, 0);
sconn = service_connection_add(casserv->cs_service, fd, NULL);
if (sconn == NULL) {
close(fd);
diff --git a/lib/libcasper/libcasper/libcasper_service.h b/lib/libcasper/libcasper/libcasper_service.h
index 4efbeb2..a66c88e 100644
--- a/lib/libcasper/libcasper/libcasper_service.h
+++ b/lib/libcasper/libcasper/libcasper_service.h
@@ -40,21 +40,25 @@ struct nvlist;
typedef struct nvlist nvlist_t;
#endif
+#define CASPER_SERVICE_STDIO 0x00000001
+#define CASPER_SERVICE_FD 0x00000002
+
typedef int service_limit_func_t(const nvlist_t *, const nvlist_t *);
typedef int service_command_func_t(const char *cmd, const nvlist_t *,
nvlist_t *, nvlist_t *);
struct casper_service *service_register(const char *name,
- service_limit_func_t *limitfunc, service_command_func_t *commandfunc);
+ service_limit_func_t *limitfunc, service_command_func_t *commandfunc,
+ uint64_t flags);
#define __constructor __attribute__((constructor))
-#define CREATE_SERVICE(name, limit_func, command_func) \
+#define CREATE_SERVICE(name, limit_func, command_func, flags) \
static __constructor void \
init_casper_service(void) \
{ \
\
- (void)service_register(name, limit_func, \
- command_func); \
+ (void)service_register(name, limit_func, command_func, \
+ flags); \
}
#endif /* !_LIBCASPER_SERVICE_H_ */
diff --git a/lib/libcasper/libcasper/service.c b/lib/libcasper/libcasper/service.c
index e02d7d9..cc53d0d 100644
--- a/lib/libcasper/libcasper/service.c
+++ b/lib/libcasper/libcasper/service.c
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <errno.h>
#include <fcntl.h>
+#include <paths.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -78,6 +79,7 @@ struct service_connection {
struct service {
int s_magic;
char *s_name;
+ uint64_t s_flags;
service_limit_func_t *s_limit;
service_command_func_t *s_command;
TAILQ_HEAD(, service_connection) s_connections;
@@ -85,7 +87,7 @@ struct service {
struct service *
service_alloc(const char *name, service_limit_func_t *limitfunc,
- service_command_func_t *commandfunc)
+ service_command_func_t *commandfunc, uint64_t flags)
{
struct service *service;
@@ -99,6 +101,7 @@ service_alloc(const char *name, service_limit_func_t *limitfunc,
}
service->s_limit = limitfunc;
service->s_command = commandfunc;
+ service->s_flags = flags;
TAILQ_INIT(&service->s_connections);
service->s_magic = SERVICE_MAGIC;
@@ -338,8 +341,60 @@ service_name(struct service *service)
return (service->s_name);
}
+static void
+stdnull(void)
+{
+ int fd;
+
+ fd = open(_PATH_DEVNULL, O_RDWR);
+ if (fd == -1)
+ errx(1, "Unable to open %s", _PATH_DEVNULL);
+
+ if (setsid() == -1)
+ errx(1, "Unable to detach from session");
+
+ if (dup2(fd, STDIN_FILENO) == -1)
+ errx(1, "Unable to cover stdin");
+ if (dup2(fd, STDOUT_FILENO) == -1)
+ errx(1, "Unable to cover stdout");
+ if (dup2(fd, STDERR_FILENO) == -1)
+ errx(1, "Unable to cover stderr");
+
+ if (fd > STDERR_FILENO)
+ close(fd);
+}
+
+static void
+service_clean(int sock, int procfd, uint64_t flags)
+{
+ int fd, maxfd, minfd;
+
+ assert(sock > STDERR_FILENO);
+ assert(procfd > STDERR_FILENO);
+ assert(sock != procfd);
+
+ if ((flags & CASPER_SERVICE_STDIO) == 0)
+ stdnull();
+
+ if ((flags & CASPER_SERVICE_FD) == 0) {
+ if (procfd > sock) {
+ maxfd = procfd;
+ minfd = sock;
+ } else {
+ maxfd = sock;
+ minfd = procfd;
+ }
+
+ for (fd = STDERR_FILENO + 1; fd < maxfd; fd++) {
+ if (fd != minfd)
+ close(fd);
+ }
+ closefrom(maxfd + 1);
+ }
+}
+
void
-service_start(struct service *service, int sock)
+service_start(struct service *service, int sock, int procfd)
{
struct service_connection *sconn, *sconntmp;
fd_set fds;
@@ -348,6 +403,8 @@ service_start(struct service *service, int sock)
assert(service != NULL);
assert(service->s_magic == SERVICE_MAGIC);
setproctitle("%s", service->s_name);
+ service_clean(sock, procfd, service->s_flags);
+
if (service_connection_add(service, sock, NULL) == NULL)
exit(1);
diff --git a/lib/libcasper/libcasper/zygote.c b/lib/libcasper/libcasper/zygote.c
index e554a3e..feeb153 100644
--- a/lib/libcasper/libcasper/zygote.c
+++ b/lib/libcasper/libcasper/zygote.c
@@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$");
#include <assert.h>
#include <err.h>
#include <errno.h>
-#include <paths.h>
#include <stdbool.h>
#include <stdlib.h>
#include <strings.h>
@@ -51,28 +50,6 @@ __FBSDID("$FreeBSD$");
/* Zygote info. */
static int zygote_sock = -1;
-static void
-stdnull(void)
-{
- int fd;
-
- fd = open(_PATH_DEVNULL, O_RDWR);
- if (fd == -1)
- errx(1, "Unable to open %s", _PATH_DEVNULL);
-
- if (setsid() == -1)
- errx(1, "Unable to detach from session");
-
- if (dup2(fd, STDIN_FILENO) == -1)
- errx(1, "Unable to cover stdin");
- if (dup2(fd, STDOUT_FILENO) == -1)
- errx(1, "Unable to cover stdout");
- if (dup2(fd, STDERR_FILENO) == -1)
- errx(1, "Unable to cover stderr");
-
- close(fd);
-}
-
int
zygote_clone(zygote_func_t *func, int *chanfdp, int *procfdp)
{
@@ -113,7 +90,7 @@ zygote_clone(zygote_func_t *func, int *chanfdp, int *procfdp)
static void
zygote_main(int sock)
{
- int error, fd, procfd;
+ int error, procfd;
int chanfd[2];
nvlist_t *nvlin, *nvlout;
zygote_func_t *func;
@@ -123,11 +100,6 @@ zygote_main(int sock)
setproctitle("zygote");
- stdnull();
- for (fd = STDERR_FILENO + 1; fd < sock; fd++)
- close(fd);
- closefrom(sock + 1);
-
for (;;) {
nvlin = nvlist_recv(sock, 0);
if (nvlin == NULL) {
diff --git a/lib/libcasper/services/cap_dns/cap_dns.c b/lib/libcasper/services/cap_dns/cap_dns.c
index 0ecf047..4837d7d 100644
--- a/lib/libcasper/services/cap_dns/cap_dns.c
+++ b/lib/libcasper/services/cap_dns/cap_dns.c
@@ -759,4 +759,4 @@ dns_command(const char *cmd, const nvlist_t *limits, nvlist_t *nvlin,
return (error);
}
-CREATE_SERVICE("system.dns", dns_limit, dns_command);
+CREATE_SERVICE("system.dns", dns_limit, dns_command, 0);
diff --git a/lib/libcasper/services/cap_grp/cap_grp.c b/lib/libcasper/services/cap_grp/cap_grp.c
index 54a022f..4e3701d 100644
--- a/lib/libcasper/services/cap_grp/cap_grp.c
+++ b/lib/libcasper/services/cap_grp/cap_grp.c
@@ -786,4 +786,4 @@ grp_command(const char *cmd, const nvlist_t *limits, nvlist_t *nvlin,
return (error);
}
-CREATE_SERVICE("system.grp", grp_limit, grp_command);
+CREATE_SERVICE("system.grp", grp_limit, grp_command, 0);
diff --git a/lib/libcasper/services/cap_pwd/cap_pwd.c b/lib/libcasper/services/cap_pwd/cap_pwd.c
index 254e244..195f3e0 100644
--- a/lib/libcasper/services/cap_pwd/cap_pwd.c
+++ b/lib/libcasper/services/cap_pwd/cap_pwd.c
@@ -780,4 +780,4 @@ pwd_command(const char *cmd, const nvlist_t *limits, nvlist_t *nvlin,
return (error);
}
-CREATE_SERVICE("system.pwd", pwd_limit, pwd_command);
+CREATE_SERVICE("system.pwd", pwd_limit, pwd_command, 0);
diff --git a/lib/libcasper/services/cap_random/cap_random.c b/lib/libcasper/services/cap_random/cap_random.c
index d19fe96..56bd659 100644
--- a/lib/libcasper/services/cap_random/cap_random.c
+++ b/lib/libcasper/services/cap_random/cap_random.c
@@ -114,4 +114,4 @@ random_command(const char *cmd, const nvlist_t *limits __unused,
return (0);
}
-CREATE_SERVICE("system.random", NULL, random_command);
+CREATE_SERVICE("system.random", NULL, random_command, 0);
diff --git a/lib/libcasper/services/cap_sysctl/cap_sysctl.c b/lib/libcasper/services/cap_sysctl/cap_sysctl.c
index 7611d64..8ee7310 100644
--- a/lib/libcasper/services/cap_sysctl/cap_sysctl.c
+++ b/lib/libcasper/services/cap_sysctl/cap_sysctl.c
@@ -290,4 +290,4 @@ sysctl_command(const char *cmd, const nvlist_t *limits, nvlist_t *nvlin,
return (0);
}
-CREATE_SERVICE("system.sysctl", sysctl_limit, sysctl_command);
+CREATE_SERVICE("system.sysctl", sysctl_limit, sysctl_command, 0);
diff --git a/lib/libclang_rt/asan_cxx/Makefile.depend b/lib/libclang_rt/asan_cxx/Makefile.depend
index 79506ce..3ac123f 100644
--- a/lib/libclang_rt/asan_cxx/Makefile.depend
+++ b/lib/libclang_rt/asan_cxx/Makefile.depend
@@ -3,6 +3,7 @@
DIRDEPS = \
include \
+ lib/libc++ \
.include <dirdeps.mk>
diff --git a/lib/libclang_rt/profile/Makefile.depend b/lib/libclang_rt/profile/Makefile.depend
index 18be76b..8c3d080 100644
--- a/lib/libclang_rt/profile/Makefile.depend
+++ b/lib/libclang_rt/profile/Makefile.depend
@@ -4,6 +4,7 @@
DIRDEPS = \
include \
include/xlocale \
+ lib/libc++ \
.include <dirdeps.mk>
diff --git a/lib/libclang_rt/safestack/Makefile.depend b/lib/libclang_rt/safestack/Makefile.depend
index 082e283..1df7d33 100644
--- a/lib/libclang_rt/safestack/Makefile.depend
+++ b/lib/libclang_rt/safestack/Makefile.depend
@@ -5,6 +5,7 @@ DIRDEPS = \
include \
include/arpa \
include/xlocale \
+ lib/libc++ \
lib/ncurses/ncursesw \
diff --git a/lib/libpam/Makefile.inc b/lib/libpam/Makefile.inc
index 59a8ced..c046362 100644
--- a/lib/libpam/Makefile.inc
+++ b/lib/libpam/Makefile.inc
@@ -26,7 +26,7 @@
CFLAGS+= -DOPENPAM_DEBUG
-SHLIB_MAJOR= 5
+SHLIB_MAJOR= 6
STATIC_CFLAGS+= -DOPENPAM_STATIC_MODULES
diff --git a/lib/libpam/libpam/Makefile b/lib/libpam/libpam/Makefile
index 531feab..1e634b7 100644
--- a/lib/libpam/libpam/Makefile
+++ b/lib/libpam/libpam/Makefile
@@ -100,8 +100,6 @@ SRCS= openpam_asprintf.c \
pam_verror.c \
pam_vinfo.c \
pam_vprompt.c
-# Local additions
-SRCS+= pam_debug_log.c
MAN?= openpam.3 \
openpam_borrow_cred.3 \
diff --git a/lib/libpam/libpam/security/pam_mod_misc.h b/lib/libpam/libpam/security/pam_mod_misc.h
index c9fc8d7..13ff0f3 100644
--- a/lib/libpam/libpam/security/pam_mod_misc.h
+++ b/lib/libpam/libpam/security/pam_mod_misc.h
@@ -39,18 +39,17 @@
#define PAM_OPT_ECHO_PASS "echo_pass"
#define PAM_OPT_DEBUG "debug"
-__BEGIN_DECLS
-void _pam_verbose_error(pam_handle_t *, int, const char *,
- const char *, const char *, ...);
-__END_DECLS
-
-#define PAM_LOG(...) \
+#define PAM_LOG(...) \
openpam_log(PAM_LOG_DEBUG, __VA_ARGS__)
-#define PAM_RETURN(arg) \
+#define PAM_RETURN(arg) \
return (arg)
-#define PAM_VERBOSE_ERROR(...) \
- _pam_verbose_error(pamh, flags, __FILE__, __func__, __VA_ARGS__)
+#define PAM_VERBOSE_ERROR(...) \
+ do { \
+ if (!(flags & PAM_SILENT) && \
+ !openpam_get_option(pamh, "no_warn")) \
+ pam_error(pamh, __VA_ARGS__); \
+ } while (0);
#endif
diff --git a/lib/libpam/static_libpam/Makefile.depend b/lib/libpam/static_libpam/Makefile.depend
index 373bac4..c628f1c 100644
--- a/lib/libpam/static_libpam/Makefile.depend
+++ b/lib/libpam/static_libpam/Makefile.depend
@@ -4,7 +4,6 @@
DIRDEPS = \
include \
include/xlocale \
- lib/libpam/libpam \
lib/libpam/modules/pam_chroot \
lib/libpam/modules/pam_deny \
lib/libpam/modules/pam_echo \
diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c
index 8d42e59..1ccd630 100644
--- a/lib/libusb/libusb10.c
+++ b/lib/libusb/libusb10.c
@@ -51,6 +51,8 @@
#include "libusb.h"
#include "libusb10.h"
+#define LIBUSB_NUM_SW_ENDPOINTS (16 * 4)
+
static pthread_mutex_t default_context_lock = PTHREAD_MUTEX_INITIALIZER;
struct libusb_context *usbi_default_context = NULL;
@@ -442,7 +444,7 @@ libusb_open(libusb_device *dev, libusb_device_handle **devh)
if (dev == NULL)
return (LIBUSB_ERROR_INVALID_PARAM);
- err = libusb20_dev_open(pdev, 16 * 4 /* number of endpoints */ );
+ err = libusb20_dev_open(pdev, LIBUSB_NUM_SW_ENDPOINTS);
if (err) {
libusb_unref_device(dev);
return (LIBUSB_ERROR_NO_MEM);
@@ -1482,7 +1484,17 @@ libusb_cancel_transfer(struct libusb_transfer *uxfer)
UNEXPORTED void
libusb10_cancel_all_transfer(libusb_device *dev)
{
- /* TODO */
+ struct libusb20_device *pdev = dev->os_priv;
+ unsigned x;
+
+ for (x = 0; x != LIBUSB_NUM_SW_ENDPOINTS; x++) {
+ struct libusb20_transfer *xfer;
+
+ xfer = libusb20_tr_get_pointer(pdev, x);
+ if (xfer == NULL)
+ continue;
+ libusb20_tr_close(xfer);
+ }
}
uint16_t
diff --git a/lib/libusb/libusb10_desc.c b/lib/libusb/libusb10_desc.c
index d2f3f53..1fabc8e 100644
--- a/lib/libusb/libusb10_desc.c
+++ b/lib/libusb/libusb10_desc.c
@@ -332,7 +332,7 @@ libusb_get_string_descriptor_ascii(libusb_device_handle *pdev,
if (libusb20_dev_req_string_simple_sync(pdev, desc_index,
data, length) == 0)
- return (strlen(data));
+ return (strlen((char *)data));
return (LIBUSB_ERROR_OTHER);
}
diff --git a/lib/msun/src/math.h b/lib/msun/src/math.h
index 2ff1731..2214c07 100644
--- a/lib/msun/src/math.h
+++ b/lib/msun/src/math.h
@@ -461,7 +461,7 @@ long double fmal(long double, long double, long double);
long double fmaxl(long double, long double) __pure2;
long double fminl(long double, long double) __pure2;
long double fmodl(long double, long double);
-long double frexpl(long double value, int *); /* fundamentally !__pure2 */
+long double frexpl(long double, int *); /* fundamentally !__pure2 */
long double hypotl(long double, long double);
int ilogbl(long double) __pure2;
long double ldexpl(long double, int);
diff --git a/libexec/Makefile b/libexec/Makefile
index fdcc49a..5c6130a 100644
--- a/libexec/Makefile
+++ b/libexec/Makefile
@@ -34,7 +34,7 @@ SUBDIR= ${_atf} \
_atrun= atrun
.endif
-.if ${MK_BLACKLIST_SUPPORT} != "no"
+.if ${MK_BLACKLIST} != "no"
_blacklistd-helper+= blacklistd-helper
.endif
diff --git a/libexec/fingerd/Makefile.depend b/libexec/fingerd/Makefile.depend
index 7de116d..5ac9545 100644
--- a/libexec/fingerd/Makefile.depend
+++ b/libexec/fingerd/Makefile.depend
@@ -8,8 +8,10 @@ DIRDEPS = \
include/arpa \
include/xlocale \
lib/${CSU_DIR} \
+ lib/libblacklist \
lib/libc \
lib/libcompiler_rt \
+ lib/libthr \
lib/libutil \
diff --git a/libexec/ftpd/Makefile.depend b/libexec/ftpd/Makefile.depend
index 5480d1d..7d0157f 100644
--- a/libexec/ftpd/Makefile.depend
+++ b/libexec/ftpd/Makefile.depend
@@ -8,12 +8,14 @@ DIRDEPS = \
include/arpa \
include/xlocale \
lib/${CSU_DIR} \
+ lib/libblacklist \
lib/libc \
lib/libcompiler_rt \
lib/libcrypt \
lib/libmd \
lib/libopie \
lib/libpam/libpam \
+ lib/libthr \
lib/libutil \
lib/libxo \
lib/msun \
diff --git a/libexec/ftpd/blacklist.c b/libexec/ftpd/blacklist.c
index e56fc65..b66a1cd 100644
--- a/libexec/ftpd/blacklist.c
+++ b/libexec/ftpd/blacklist.c
@@ -48,8 +48,6 @@ void
blacklist_notify(int action, int fd, char *msg)
{
if (blstate == NULL)
- blacklist_init();
- if (blstate == NULL)
return;
(void)blacklist_r(blstate, action, fd, msg);
}
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index 5ce1d3a..16c7523 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -268,7 +268,7 @@ int
main(int argc, char *argv[], char **envp)
{
socklen_t addrlen;
- int ch, on = 1, tos;
+ int ch, on = 1, tos, s = STDIN_FILENO;
char *cp, line[LINE_MAX];
FILE *fd;
char *bindname = NULL;
@@ -504,8 +504,8 @@ main(int argc, char *argv[], char **envp)
switch (pid = fork()) {
case 0:
/* child */
- (void) dup2(fd, 0);
- (void) dup2(fd, 1);
+ (void) dup2(fd, s);
+ (void) dup2(fd, STDOUT_FILENO);
(void) close(fd);
for (i = 1; i <= *ctl_sock; i++)
close(ctl_sock[i]);
@@ -522,7 +522,7 @@ main(int argc, char *argv[], char **envp)
}
} else {
addrlen = sizeof(his_addr);
- if (getpeername(0, (struct sockaddr *)&his_addr, &addrlen) < 0) {
+ if (getpeername(s, (struct sockaddr *)&his_addr, &addrlen) < 0) {
syslog(LOG_ERR, "getpeername (%s): %m",argv[0]);
exit(1);
}
@@ -557,7 +557,7 @@ gotchild:
(void)sigaction(SIGPIPE, &sa, NULL);
addrlen = sizeof(ctrl_addr);
- if (getsockname(0, (struct sockaddr *)&ctrl_addr, &addrlen) < 0) {
+ if (getsockname(s, (struct sockaddr *)&ctrl_addr, &addrlen) < 0) {
syslog(LOG_ERR, "getsockname (%s): %m",argv[0]);
exit(1);
}
@@ -570,7 +570,7 @@ gotchild:
if (ctrl_addr.su_family == AF_INET)
{
tos = IPTOS_LOWDELAY;
- if (setsockopt(0, IPPROTO_IP, IP_TOS, &tos, sizeof(int)) < 0)
+ if (setsockopt(s, IPPROTO_IP, IP_TOS, &tos, sizeof(int)) < 0)
syslog(LOG_WARNING, "control setsockopt (IP_TOS): %m");
}
#endif
@@ -578,7 +578,7 @@ gotchild:
* Disable Nagle on the control channel so that we don't have to wait
* for peer's ACK before issuing our next reply.
*/
- if (setsockopt(0, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)) < 0)
+ if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)) < 0)
syslog(LOG_WARNING, "control setsockopt (TCP_NODELAY): %m");
data_source.su_port = htons(ntohs(ctrl_addr.su_port) - 1);
@@ -587,12 +587,12 @@ gotchild:
/* Try to handle urgent data inline */
#ifdef SO_OOBINLINE
- if (setsockopt(0, SOL_SOCKET, SO_OOBINLINE, &on, sizeof(on)) < 0)
+ if (setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &on, sizeof(on)) < 0)
syslog(LOG_WARNING, "control setsockopt (SO_OOBINLINE): %m");
#endif
#ifdef F_SETOWN
- if (fcntl(fileno(stdin), F_SETOWN, getpid()) == -1)
+ if (fcntl(s, F_SETOWN, getpid()) == -1)
syslog(LOG_ERR, "fcntl F_SETOWN: %m");
#endif
dolog((struct sockaddr *)&his_addr);
@@ -1423,7 +1423,7 @@ skip:
if (rval) {
reply(530, "Login incorrect.");
#ifdef USE_BLACKLIST
- blacklist_notify(1, 0, "Login incorrect");
+ blacklist_notify(1, STDIN_FILENO, "Login incorrect");
#endif
if (logging) {
syslog(LOG_NOTICE,
@@ -1444,7 +1444,7 @@ skip:
}
#ifdef USE_BLACKLIST
else {
- blacklist_notify(0, 0, "Login successful");
+ blacklist_notify(0, STDIN_FILENO, "Login successful");
}
#endif
}
diff --git a/libexec/rlogind/Makefile.depend b/libexec/rlogind/Makefile.depend
index 7de116d..5ac9545 100644
--- a/libexec/rlogind/Makefile.depend
+++ b/libexec/rlogind/Makefile.depend
@@ -8,8 +8,10 @@ DIRDEPS = \
include/arpa \
include/xlocale \
lib/${CSU_DIR} \
+ lib/libblacklist \
lib/libc \
lib/libcompiler_rt \
+ lib/libthr \
lib/libutil \
diff --git a/libexec/rshd/Makefile.depend b/libexec/rshd/Makefile.depend
index 7ce0fb7..2894848 100644
--- a/libexec/rshd/Makefile.depend
+++ b/libexec/rshd/Makefile.depend
@@ -8,9 +8,11 @@ DIRDEPS = \
include/arpa \
include/xlocale \
lib/${CSU_DIR} \
+ lib/libblacklist \
lib/libc \
lib/libcompiler_rt \
lib/libpam/libpam \
+ lib/libthr \
lib/libutil \
diff --git a/release/Makefile.ec2 b/release/Makefile.ec2
index 221ea6c..45a08e4 100644
--- a/release/Makefile.ec2
+++ b/release/Makefile.ec2
@@ -23,7 +23,7 @@ CW_EC2_PORTINSTALL=
cw-ec2-portinstall:
.if exists(${PORTSDIR}/net/bsdec2-image-upload/Makefile)
- make -C ${PORTSDIR}/net/bsdec2-image-upload BATCH=1 all install clean
+ env - PATH=$$PATH make -C ${PORTSDIR}/net/bsdec2-image-upload BATCH=1 all install clean
.else
. if !exists(/usr/local/sbin/pkg-static)
env ASSUME_ALWAYS_YES=yes pkg bootstrap -y
diff --git a/release/doc/en_US.ISO8859-1/relnotes/article.xml b/release/doc/en_US.ISO8859-1/relnotes/article.xml
index 99c9f24..bb6f9e9 100644
--- a/release/doc/en_US.ISO8859-1/relnotes/article.xml
+++ b/release/doc/en_US.ISO8859-1/relnotes/article.xml
@@ -505,8 +505,8 @@
<application>elftoolchain</application> utilities have been
updated to version 3179.</para>
- <para revision="281316">The &man.xz.1; utility has been updated
- to version 5.2.1.</para>
+ <para revision="291125">The &man.xz.1; utility has been updated
+ to version 5.2.2.</para>
<para revision="281373">The &man.nvi.1; utility has been updated
to version 2.1.3.</para>
@@ -601,6 +601,36 @@
<para revision="296417">The
<application>compiler_rt</application> utility has been
updated to version 3.8.0.</para>
+
+ <para revision="300879"><application>ACPICA</application> has been
+ updated to version 20160527.</para>
+
+ <para revision="292432"><application>OpenBSM</application> has been
+ updated to version 1.2 alpha 4.</para>
+
+ <para revision="301169" contrib="sponsor" sponsor="&ff;">The NetBSD
+ Project's &man.libblacklist.3; library and applications
+ have been ported and integrated into the system. Packet
+ filtering support for the &man.pf.4; packet filtering systems
+ has been implemented. The <application>blacklist</application>
+ system provides the <application>blacklistd</application>
+ daemon, the helper script
+ <application>blacklistd-helper</application> to make changes
+ to the running packet filter system and the
+ <application>blacklistctl</application> control program.
+ A selection of system daemons, including:
+ <application>fingerd</application>,
+ <application>ftpd</application>,
+ <application>rlogind</application>,
+ <application>rshd</application>, and
+ <application>sshd</application> have been modified to support
+ sending notifications to the <application>blacklistd</application>
+ daemon.</para>
+
+ <para revision="301736" contrib="sponsor" sponsor="&ff;">Support for
+ the &man.ipfw.4; packet filter has been added to the
+ <application>blacklistd-helper</application> script.</para>
+
</sect2>
<sect2 xml:id="userland-installer">
@@ -1517,6 +1547,13 @@
<acronym>TRIM</acronym>/<acronym>UNMAP</acronym> support on
<acronym>GELI</acronym>-backed <acronym>SSD</acronym> storage
providers.</para>
+
+ <para revision="300880" contrib="sponsor" sponsor="&spectralogic;">
+ Leading spaces are now stripped off <acronym>SCSI</acronym> disk serial
+ numbers when populating the CAM serial number. This affects the output of
+ &man.diskinfo.8; and the names of <filename>/dev/diskid/DISK-*</filename>
+ device nodes, among other things.</para>
+
</sect2>
<sect2 xml:id="storage-net">
@@ -1771,6 +1808,10 @@
</tgroup>
</informaltable>
+ <para revision="300779">Dummynet AQM, an independent implementation of
+ CoDel and FQ-CoDel for ipfw/dummynet has been imported to the base
+ system.</para>
+
</sect2>
</sect1>
diff --git a/release/scripts/mm-mtree.sh b/release/scripts/mm-mtree.sh
index 4499c10..620ab6d 100755
--- a/release/scripts/mm-mtree.sh
+++ b/release/scripts/mm-mtree.sh
@@ -147,7 +147,7 @@ find -d ${TEMPROOT} -type d -empty -delete 2>/dev/null
# Build the mtree database in a temporary location.
MTREENEW=`mktemp -t mergemaster.mtree`
-mtree -ci -p ${TEMPROOT} -k size,md5digest > ${MTREENEW} 2>/dev/null
+mtree -nci -p ${TEMPROOT} -k size,md5digest > ${MTREENEW} 2>/dev/null
if [ -s "${MTREENEW}" ]; then
echo "*** Saving mtree database for future upgrades"
diff --git a/release/tools/ec2.conf b/release/tools/ec2.conf
index 557e602..be7891b 100644
--- a/release/tools/ec2.conf
+++ b/release/tools/ec2.conf
@@ -62,8 +62,10 @@ vm_extra_pre_umount() {
echo 'autoboot_delay="-1"' >> ${DESTDIR}/boot/loader.conf
echo 'beastie_disable="YES"' >> ${DESTDIR}/boot/loader.conf
- # The EC2 console is an emulated serial port.
- echo 'console="comconsole"' >> ${DESTDIR}/boot/loader.conf
+ # EC2 has two consoles: An emulated serial port ("system log"),
+ # which has been present since 2006; and a VGA console ("instance
+ # screenshot") which was introduced in 2016.
+ echo 'boot_multicons="YES"' >> ${DESTDIR}/boot/loader.conf
# Some older EC2 hardware used a version of Xen with a bug in its
# emulated serial port. It is not clear if EC2 still has any such
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8
index 27f38e9..e8db561 100644
--- a/sbin/ifconfig/ifconfig.8
+++ b/sbin/ifconfig/ifconfig.8
@@ -28,7 +28,7 @@
.\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94
.\" $FreeBSD$
.\"
-.Dd May 29, 2016
+.Dd June 8, 2016
.Dt IFCONFIG 8
.Os
.Sh NAME
diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c
index 82c7515..caffe79 100644
--- a/sbin/ifconfig/ifieee80211.c
+++ b/sbin/ifconfig/ifieee80211.c
@@ -5190,6 +5190,7 @@ static void
wlan_create(int s, struct ifreq *ifr)
{
static const uint8_t zerobssid[IEEE80211_ADDR_LEN];
+ char orig_name[IFNAMSIZ];
if (params.icp_parent[0] == '\0')
errx(1, "must specify a parent device (wlandev) when creating "
@@ -5201,7 +5202,13 @@ wlan_create(int s, struct ifreq *ifr)
if (ioctl(s, SIOCIFCREATE2, ifr) < 0)
err(1, "SIOCIFCREATE2");
+ /* XXX preserve original name for ifclonecreate(). */
+ strlcpy(orig_name, name, sizeof(orig_name));
+ strlcpy(name, ifr->ifr_name, sizeof(name));
+
setdefregdomain(s);
+
+ strlcpy(name, orig_name, sizeof(name));
}
static
diff --git a/secure/usr.sbin/sshd/Makefile b/secure/usr.sbin/sshd/Makefile
index f9589a3..bab2901 100644
--- a/secure/usr.sbin/sshd/Makefile
+++ b/secure/usr.sbin/sshd/Makefile
@@ -40,6 +40,13 @@ CFLAGS+= -DUSE_BSM_AUDIT -DHAVE_GETAUDIT_ADDR
LIBADD+= bsm
.endif
+.if ${MK_BLACKLIST_SUPPORT} != "no"
+CFLAGS+= -DUSE_BLACKLIST -I${SRCTOP}/contrib/blacklist/include
+SRCS+= blacklist.c
+LIBADD+= blacklist
+LDFLAGS+=-L${LIBBLACKLISTDIR}
+.endif
+
.if ${MK_KERBEROS_SUPPORT} != "no"
CFLAGS+= -include krb5_config.h
SRCS+= krb5_config.h
diff --git a/secure/usr.sbin/sshd/Makefile.depend b/secure/usr.sbin/sshd/Makefile.depend
index d24b0be..220aae3 100644
--- a/secure/usr.sbin/sshd/Makefile.depend
+++ b/secure/usr.sbin/sshd/Makefile.depend
@@ -17,6 +17,7 @@ DIRDEPS = \
kerberos5/lib/libroken \
kerberos5/lib/libwind \
lib/${CSU_DIR} \
+ lib/libblacklist \
lib/libbsm \
lib/libc \
lib/libcom_err \
diff --git a/share/man/man3/tree.3 b/share/man/man3/tree.3
index ea70506..ff701a0 100644
--- a/share/man/man3/tree.3
+++ b/share/man/man3/tree.3
@@ -424,12 +424,14 @@ Individual prototypes can be declared with
.Fn RB_PROTOTYPE_PREV ,
and
.Fn RB_PROTOTYPE_MINMAX
-in case not all functions are required. The individual prototype macros expect
+in case not all functions are required.
+The individual prototype macros expect
.Fa NAME ,
.Fa TYPE ,
and
.Fa ATTR
-arguments. The
+arguments.
+The
.Fa ATTR
argument must be empty for global functions or
.Fa static
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile
index b99b6af..99535c2 100644
--- a/share/man/man4/Makefile
+++ b/share/man/man4/Makefile
@@ -863,7 +863,7 @@ _dtrace_udp.4= dtrace_udp.4
.if ${MK_ISCSI} != "no"
MAN+= iscsi.4
MAN+= iscsi_initiator.4
-
+MAN+= iser.4
.endif
.if ${MK_TESTS} != "no"
diff --git a/share/man/man4/ahci.4 b/share/man/man4/ahci.4
index 67a9606..24a277d 100644
--- a/share/man/man4/ahci.4
+++ b/share/man/man4/ahci.4
@@ -141,7 +141,8 @@ API or emulated
.Xr ses 4
device for localization and status reporting purposes.
Supporting AHCI controllers may transmit that information to the backplane
-controllers via SGPIO interface. Backplane controllers interpret received
+controllers via SGPIO interface.
+Backplane controllers interpret received
statuses in some way (IBPI standard) to report them using present indicators.
.Sh HARDWARE
The
diff --git a/share/man/man4/apic.4 b/share/man/man4/apic.4
index 0856232..2fb5b8c 100644
--- a/share/man/man4/apic.4
+++ b/share/man/man4/apic.4
@@ -43,7 +43,8 @@ The following tunable is settable from the
.Xr loader 8 :
.Bl -ohang
.It Va hint.apic. Ns Ar X Ns Va .clock
-controls event timers functionality support. Setting to 0, disables it.
+controls event timers functionality support.
+Setting to 0, disables it.
Default value is 1.
.It Va hint.apic. Ns Ar X Ns Va .disabled
Set this to 1 to disable APIC support, falling back to the legacy PIC.
diff --git a/share/man/man4/atp.4 b/share/man/man4/atp.4
index 6309d09..c326188 100644
--- a/share/man/man4/atp.4
+++ b/share/man/man4/atp.4
@@ -50,7 +50,8 @@ atp_load="YES"
The
.Nm
driver provides support for the Apple Internal Trackpad device found in many
-Apple laptops. Older (Fountain/Geyser) and the newer (Wellspring) trackpad
+Apple laptops.
+Older (Fountain/Geyser) and the newer (Wellspring) trackpad
families are all supported through a unified driver.
.Pp
The driver simulates a three\-button mouse using multi\-finger tap detection.
diff --git a/share/man/man4/atrtc.4 b/share/man/man4/atrtc.4
index 0b0dd8f..1ae8e41 100644
--- a/share/man/man4/atrtc.4
+++ b/share/man/man4/atrtc.4
@@ -37,7 +37,8 @@ The following tunable is settable from the
.Xr loader 8 :
.Bl -ohang
.It Va hint.atrtc. Ns Ar X Ns Va .clock
-controls event timers functionality support. Setting to 0, disables it.
+controls event timers functionality support.
+Setting to 0, disables it.
Default value is 1.
.El
.Sh DESCRIPTION
diff --git a/share/man/man4/bcma.4 b/share/man/man4/bcma.4
index 3a0313c..b0f13f6 100644
--- a/share/man/man4/bcma.4
+++ b/share/man/man4/bcma.4
@@ -55,7 +55,8 @@ in later Broadcom Home Networking Division's (HND) wireless chipsets and
embedded systems.
.Pp
A common interconnect connects all of the backplane's functional
-blocks. These functional blocks, known as cores, use the ARM AMBA AXI or
+blocks.
+These functional blocks, known as cores, use the ARM AMBA AXI or
APB interface to communicate with devices attached to the interconnect.
.Pp
The IP cores used in
@@ -63,7 +64,6 @@ The IP cores used in
devices were adapted by Broadcom for compatibility with the new
interconnect.
.Sh SEE ALSO
-.Xr bcma 4 ,
.Xr bhnd 4
.Sh HISTORY
The
diff --git a/share/man/man4/bhnd.4 b/share/man/man4/bhnd.4
index e54563f..0c2aba4 100644
--- a/share/man/man4/bhnd.4
+++ b/share/man/man4/bhnd.4
@@ -52,8 +52,8 @@ devices.
.Pp
The Broadcom HND device family consists of SoCs (System On a Chip)
and host-connected chipsets based on a common library of Broadcom IP
-cores connected via an internal hardware bus architecture. Drivers
-for these cores are implemented against the unified
+cores connected via an internal hardware bus architecture.
+Drivers for these cores are implemented against the unified
.Nm
interface.
.Pp
diff --git a/share/man/man4/bhyve.4 b/share/man/man4/bhyve.4
index f4ff2e1..f654855 100644
--- a/share/man/man4/bhyve.4
+++ b/share/man/man4/bhyve.4
@@ -38,8 +38,8 @@
.Cd "/boot/kernel/vmm.ko"
.Sh DESCRIPTION
.Nm
-is a virtual machine monitor that is hosted by FreeBSD. It is used to host
-unmodified guest operating systems on top of FreeBSD.
+is a virtual machine monitor that is hosted by FreeBSD.
+It is used to host unmodified guest operating systems on top of FreeBSD.
.Pp
.Nm
relies heavily on hardware assist provided by the CPU and chipset to virtualize
diff --git a/share/man/man4/bpf.4 b/share/man/man4/bpf.4
index 01cd0ea..e63b3a6 100644
--- a/share/man/man4/bpf.4
+++ b/share/man/man4/bpf.4
@@ -24,7 +24,7 @@
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
-.\"
+.\"
.\" Copyright (c) 1990 The Regents of the University of California.
.\" All rights reserved.
.\"
@@ -577,7 +577,8 @@ output via the interface is successful.
When
.Dv BPF_D_INOUT
direction is set, injected outgoing packet is not returned by BPF to avoid
-duplication. This flag is initialized to zero by default.
+duplication.
+This flag is initialized to zero by default.
.It Dv BIOCLOCK
Set the locked flag on the
.Nm
diff --git a/share/man/man4/cmx.4 b/share/man/man4/cmx.4
index 38ae466..aebcbc0 100644
--- a/share/man/man4/cmx.4
+++ b/share/man/man4/cmx.4
@@ -1,7 +1,7 @@
.\"
.\" Copyright (c) 2006-2007 Daniel Roethlisberger <daniel@roe.ch>
.\" All rights reserved.
-.\"
+.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
@@ -11,7 +11,7 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\"
+.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -42,7 +42,8 @@ driver provides support for the PCCARD based
smartcard reader.
The driver provides a character device special file based
.Em Chip/Smart Card Interface Devices (CCID)
-interface. The driver implements what the vendor calls the
+interface.
+The driver implements what the vendor calls the
.Em Synchronous API
onto the smartcard reader device.
.Pp
@@ -51,8 +52,9 @@ Reading and writing is synchronous, meaning that a call to
directly corresponds to a complete CCID command sent to the
device, while the following
.Xr read 2
-will return the complete answer from the reader. There is no
-support for partial reads or writes. There is no upper limit on
+will return the complete answer from the reader.
+There is no support for partial reads or writes.
+There is no upper limit on
CCID request or response sizes, but the complete CCID request
must be sent to the driver in
.Xr write 2
@@ -64,7 +66,8 @@ Non-blocking I/O,
.Xr select 2
and
.Xr poll 2
-are supported and work as expected. An open file descriptor
+are supported and work as expected.
+An open file descriptor
will always be ready for writing, but only ready for reading
if the device indicates that it has data available.
.Sh FILES
@@ -112,9 +115,9 @@ Early testing and bug fixes by
.An -nosplit
The way the
.Nm
-driver talks to the CardMan 4040 is a bit rough. Due to the
-complete lack of hardware documentation other than vendor drivers
+driver talks to the CardMan 4040 is a bit rough.
+Due to the complete lack of hardware documentation other than vendor drivers
for other operating systems, the gory details of the device's
-I/O registers are not understood very well. There may be error
-conditions which can only be solved by physically reinserting the
-reader.
+I/O registers are not understood very well.
+There may be error conditions which can only be solved by physically
+reinserting the reader.
diff --git a/share/man/man4/cxgbe.4 b/share/man/man4/cxgbe.4
index 9821797..72a9483 100644
--- a/share/man/man4/cxgbe.4
+++ b/share/man/man4/cxgbe.4
@@ -270,11 +270,13 @@ The default is -1 which lets the driver decide.
0 or 1 explicitly disable or enable this feature.
.It Va hw.cxgbe.allow_mbufs_in_cluster
1 allows the driver to lay down one or more mbufs within the receive buffer
-opportunistically. This is the default.
+opportunistically.
+This is the default.
0 prohibits the driver from doing so.
.It Va hw.cxgbe.largest_rx_cluster
.It Va hw.cxgbe.safest_rx_cluster
-Sizes of rx clusters. Each of these must be set to one of the sizes available
+Sizes of rx clusters.
+Each of these must be set to one of the sizes available
(usually 2048, 4096, 9216, and 16384) and largest_rx_cluster must be greater
than or equal to safest_rx_cluster.
The defaults are 16384 and 4096 respectively.
diff --git a/share/man/man4/dcons.4 b/share/man/man4/dcons.4
index 3f33dd2..d228ad5 100644
--- a/share/man/man4/dcons.4
+++ b/share/man/man4/dcons.4
@@ -100,7 +100,7 @@ See
for more details.
.Pp
If you want to use
-.Xr dcons 4
+.Nm
as a
.Xr gdb 1
port, add the following line into
diff --git a/share/man/man4/ddb.4 b/share/man/man4/ddb.4
index b6ef6ae..3e88aa5 100644
--- a/share/man/man4/ddb.4
+++ b/share/man/man4/ddb.4
@@ -60,7 +60,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 18, 2016
+.Dd June 6, 2016
.Dt DDB 4
.Os
.Sh NAME
@@ -599,6 +599,13 @@ See the
header file for more details on the exact meaning of the structure fields.
.\"
.Pp
+.It Ic show Cm callout Ar addr
+Show information about the callout structure
+.Vt struct callout
+present at
+.Ar addr .
+.\"
+.Pp
.It Ic show Cm cbstat
Show brief information about the TTY subsystem.
.\"
@@ -681,6 +688,13 @@ The second one is the name of the interrupt/trap handler.
Those functions are machine dependent.
.\"
.Pp
+.It Ic show Cm igi_list Ar addr
+Show information about the IGMP structure
+.Vt struct igmp_ifsoftc
+present at
+.Ar addr .
+.\"
+.Pp
.It Ic show Cm inodedeps Op Ar addr
Show brief information about each inodedep structure.
If
@@ -834,6 +848,10 @@ option is specified the
complete object is printed.
.\"
.Pp
+.It Ic show Cm panic
+Print the panic message if set.
+.\"
+.Pp
.It Ic show Cm page
Show statistics on VM pages.
.\"
diff --git a/share/man/man4/devctl.4 b/share/man/man4/devctl.4
index b86cf23..f71d029 100644
--- a/share/man/man4/devctl.4
+++ b/share/man/man4/devctl.4
@@ -75,7 +75,8 @@ Listening programs are expected to cope.
.Pp
The sysctl
.Va hw.bus.devctl_queue
-can be used to control queue length. It is set to 0 to disable
+can be used to control queue length.
+It is set to 0 to disable
.Nm
when no
.Xr devd 8
diff --git a/share/man/man4/fdt.4 b/share/man/man4/fdt.4
index 12542d0..6b371a5 100644
--- a/share/man/man4/fdt.4
+++ b/share/man/man4/fdt.4
@@ -41,19 +41,20 @@
.Sh DESCRIPTION
.Em Flattened Device Tree
is a mechanism for describing computer hardware resources, which cannot be
-probed or self enumerated, in a uniform and portable way. The primary
-consumers of this technology are
+probed or self enumerated, in a uniform and portable way.
+The primary consumers of this technology are
.Em embedded systems,
where a lot of designs are based on similar chips, but have different
assignment of pins, memory layout, addresses bindings, interrupts routing and
other resources.
.Pp
Configuration data, which cannot be self discovered in run-time, has to be
-supplied from external source. The concept of a flattened device tree is a
+supplied from external source.
+The concept of a flattened device tree is a
platform and architecture independent approach for resolving such problems.
The idea is inherited from Open Firmware IEEE 1275 device-tree notion, and has
-been successfully adopted by the embedded industry. The scheme works in the
-following way:
+been successfully adopted by the embedded industry.
+The scheme works in the following way:
.Bl -bullet
.It
Hardware platform resources are
@@ -72,7 +73,8 @@ from this [externally supplied] blob, which eliminates the need for embedding
any information about the underlying platform hardware resources in the kernel.
.It
The flattened device tree mechanism in principle does not depend on any
-particular first-stage bootloader or firmware features. The only overall
+particular first-stage bootloader or firmware features.
+The only overall
requirement for the environment is to provide a complete device tree
description to the kernel.
.El
@@ -89,8 +91,8 @@ maintenance.
.It Va Device tree source (DTS)
The device tree source is a text file which describes hardware resources of a
computer system in a human-readable form, with certain hierarchical structure
-(a tree). The default location for DTS files
-in the
+(a tree).
+The default location for DTS files in the
.Fx
source repository is
.Pa sys/boot/fdt/dts
@@ -140,7 +142,8 @@ kernel level.
.It Va options FDT
The primary option for enabling
.Nm
-support in the kernel. It covers all low-level and infrastructure parts of
+support in the kernel.
+It covers all low-level and infrastructure parts of
.Nm
kernel support, which primarily are the
.Xr fdtbus 4
@@ -149,16 +152,18 @@ and
drivers, as well as helper routines and libraries.
.It Va makeoptions FDT_DTS_FILE=<board name>.dts
Specifies a preferred (default) device tree source (DTS) file for a given
-kernel. The indicated DTS file will be converted (compiled) into a binary form
-along with building the kernel itself. The DTS file name is relative
-to the default location of DTS sources i.e.
+kernel.
+The indicated DTS file will be converted (compiled) into a binary form
+along with building the kernel itself.
+The DTS file name is relative to the default location of DTS sources i.e.
.Pa sys/boot/fdt/dts .
This makeoption is not mandatory unless FDT_DTB_STATIC is also defined (see
below).
.It Va options FDT_DTB_STATIC
Typically, the device tree blob (DTB) is a stand-alone file, physically
separate from the kernel, but this option lets statically embed a
-DTB file into a kernel image. Note that when this is specified the
+DTB file into a kernel image.
+Note that when this is specified the
FDT_DTS_FILE makeoption becomes mandatory (as there needs to be a DTS file
specified in order to embed it into the kernel image).
.El
@@ -182,5 +187,6 @@ support first appeared in
The
.Nm
support was developed by Semihalf under sponsorship from the FreeBSD
-Foundation. This manual page was written by
+Foundation.
+This manual page was written by
.An Rafal Jaworowski .
diff --git a/share/man/man4/fdtbus.4 b/share/man/man4/fdtbus.4
index 7141655..6755a7d 100644
--- a/share/man/man4/fdtbus.4
+++ b/share/man/man4/fdtbus.4
@@ -43,7 +43,8 @@ abstract bus driver is the primary connection and translation layer between
.Xr fdt 4
hardware resources description and
.Fx
-native newbus device drivers framework. For an embedded system
+native newbus device drivers framework.
+For an embedded system
.Nm
represents peripherals typically found on a highly integrated chip
(system-on-chip).
@@ -84,5 +85,6 @@ support first appeared in
The
.Nm
support was developed by Semihalf under sponsorship from the FreeBSD
-Foundation. This manual page was written by
+Foundation.
+This manual page was written by
.An Rafal Jaworowski .
diff --git a/share/man/man4/hpet.4 b/share/man/man4/hpet.4
index cd1b766..f006cde 100644
--- a/share/man/man4/hpet.4
+++ b/share/man/man4/hpet.4
@@ -42,16 +42,19 @@ The following tunables are settable from the
.Xr loader 8 :
.Bl -ohang
.It Va hint.hpet. Ns Ar X Ns Va .allowed_irqs
-is a 32bit mask. Each set bit allows driver to use respective IRQ,
+is a 32bit mask.
+Each set bit allows driver to use respective IRQ,
if BIOS also set respective capability bit in comparator's configuration
register.
Default value is 0xffff0000, except some known broken hardware.
.It Va hint.hpet. Ns Ar X Ns Va .clock
-controls event timers functionality support. Setting to 0, disables it.
+controls event timers functionality support.
+Setting to 0, disables it.
Default value is 1.
.It Va hint.hpet. Ns Ar X Ns Va .legacy_route
-controls "LegacyReplacement Route" mode. If enabled, HPET will steal IRQ0 of
-i8254 timer and IRQ8 of RTC. Before using it, make sure that respective
+controls "LegacyReplacement Route" mode.
+If enabled, HPET will steal IRQ0 of i8254 timer and IRQ8 of RTC.
+Before using it, make sure that respective
drivers are not using interrupts, by setting also:
.Bd -literal
hint.attimer.0.clock=0
@@ -77,8 +80,8 @@ Depending on hardware capabilities and configuration, interrupt can be
delivered as regular I/O APIC interrupt (ISA or PCI) in range from 0 to 31,
or as Front Side Bus interrupt, alike to PCI MSI interrupts, or in so called
"LegacyReplacement Route" HPET can steal IRQ0 of i8254 and IRQ8 of the RTC.
-Interrupt can be either edge- or level-triggered. In last case they could be
-safely shared with PCI IRQs.
+Interrupt can be either edge- or level-triggered.
+In last case they could be safely shared with PCI IRQs.
Driver prefers to use FSB interrupts, if supported, to avoid sharing.
If it is not possible, it uses single sharable IRQ from PCI range.
Other modes (LegacyReplacement and ISA IRQs) require special care to setup,
@@ -89,9 +92,10 @@ and irrelevant to CPU power states.
.Pp
Depending on hardware capabilities and configuration, driver can expose each
comparator as separate event timer or group them into one or several per-CPU
-event timers. In last case interrupt of every of those comparators within
-group is bound to specific CPU core. This is possible only when each
-of these comparators has own unsharable IRQ.
+event timers.
+In last case interrupt of every of those comparators within
+group is bound to specific CPU core.
+This is possible only when each of these comparators has own unsharable IRQ.
.Sh SEE ALSO
.Xr acpi 4 ,
.Xr apic 4 ,
diff --git a/share/man/man4/hptrr.4 b/share/man/man4/hptrr.4
index 0cbd2fd..1f488f8 100644
--- a/share/man/man4/hptrr.4
+++ b/share/man/man4/hptrr.4
@@ -51,7 +51,8 @@ The following tunables are settable from the loader:
.Bl -ohang
.It Va hw.hptrr.attach_generic
set to 1 to permit driver attach to chips with generic Marvell (non-HighPoint)
-PCI identification. These chips are also supported by
+PCI identification.
+These chips are also supported by
.Xr ata 4
and
.Xr mvs 4 .
diff --git a/share/man/man4/iicbus.4 b/share/man/man4/iicbus.4
index c89bfaf..d164bf8 100644
--- a/share/man/man4/iicbus.4
+++ b/share/man/man4/iicbus.4
@@ -122,7 +122,7 @@ Flattened Device Tree (FDT) data, tunables set via
or at runtime using
.Xr sysctl 8 .
When configuration is supplied using more than one method, FDT and
-hint data will be overridden by a tunable, which can be overriden by
+hint data will be overridden by a tunable, which can be overridden by
.Xr sysctl 8 .
.Ss Device Hints
Set
diff --git a/share/man/man4/inet.4 b/share/man/man4/inet.4
index 07e7354..49c050d 100644
--- a/share/man/man4/inet.4
+++ b/share/man/man4/inet.4
@@ -134,7 +134,7 @@ The following
.Xr ioctl 2
commands are provided for a datagram socket in the Internet domain:
.Pp
-.Bl -tag -width ".Dv SIOCGIFBRDADDR" -offset indent -compact
+.Bl -tag -width ".Dv SIOCGIFBRDADDR" -offset indent -compact
.It Dv SIOCAIFADDR
Add address to an interface.
The command requires
@@ -149,8 +149,8 @@ as argument.
.It Dv SIOCGIFBRDADDR
.It Dv SIOCGIFDSTADDR
.It Dv SIOCGIFNETMASK
-Return address information from interface. The returned value
-is in
+Return address information from interface.
+The returned value is in
.Ft struct ifreq .
This way of address information retrieval is obsoleted, a
preferred way is to use
diff --git a/share/man/man4/ip.4 b/share/man/man4/ip.4
index 101993f..27a7d8e 100644
--- a/share/man/man4/ip.4
+++ b/share/man/man4/ip.4
@@ -122,7 +122,7 @@ may be used to set the Don't Fragment flag on IP packets.
Currently this option is respected only on
.Xr udp 4
and raw
-.Xr ip 4
+.Nm
sockets, unless the
.Dv IP_HDRINCL
option has been set.
diff --git a/share/man/man4/ipmi.4 b/share/man/man4/ipmi.4
index 9516d31..ba99464 100644
--- a/share/man/man4/ipmi.4
+++ b/share/man/man4/ipmi.4
@@ -63,8 +63,8 @@ If the
.Ar port
and
.Ar spacing
-are not specified the interface type default will be used. Only specify
-either the
+are not specified the interface type default will be used.
+Only specify either the
.Ar port
for I/O access or
.Ar maddr
diff --git a/share/man/man4/iscsi.4 b/share/man/man4/iscsi.4
index 1a0731d..65edfe7 100644
--- a/share/man/man4/iscsi.4
+++ b/share/man/man4/iscsi.4
@@ -107,6 +107,7 @@ While the connection is down all input/output operations are suspended, to be
retried after the connection is reestablished.
.El
.Sh SEE ALSO
+.Xr iser 4 ,
.Xr iscsi.conf 5 ,
.Xr iscsictl 8 ,
.Xr iscsid 8
diff --git a/share/man/man4/iser.4 b/share/man/man4/iser.4
new file mode 100644
index 0000000..abaaa92
--- /dev/null
+++ b/share/man/man4/iser.4
@@ -0,0 +1,94 @@
+.\" Copyright (c) 2015, Mellanox Technologies, Inc. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\"
+.\" $FreeBSD$
+.Dd June 6, 2016
+.Dt ISER 4
+.Os
+.Sh NAME
+.Nm iser
+.Nd iSCSI Extensions for RDMA (iSER) driver
+.Sh SYNOPSIS
+To compile this driver into the kernel,
+place the following line in the
+kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "device iser"
+.Ed
+.Pp
+Alternatively, to load the driver as a
+module at boot time, place the following line in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+iser_load="YES"
+.Ed
+.Sh DESCRIPTION
+The
+.Nm
+(iSCSI Extensions for RDMA) initiator driver extends the iSCSI protocol to RDMA.
+It permits data to be transferred directly into and out of SCSI buffers
+without intermediate data copies.
+iSER uses the RDMA protocol suite to supply higher bandwidth for
+block storage transfers (zero copy behavior).
+To that fact, it eliminates the
+TCP/IP processing overhead while preserving the compatibility with iSCSI protocol.
+The initiator is the iSCSI/iSER client, which connects to an iSCSI/iSER target,
+providing local access to a remote block device.
+The userland component is provided by
+.Xr iscsid 8
+and both the kernel and userland are configured using
+.Xr iscsictl 8 .
+.Sh SYSCTL VARIABLES
+The following variables are available as both
+.Xr sysctl 8
+variables and
+.Xr loader 8
+tunables:
+.Bl -tag -width indent
+.It Va kern.iser.debug
+Verbosity level for log messages from the
+.Nm
+driver.
+Set to 0 to disable logging or 1 to warn about potential problems.
+Larger values enable info and debugging output.
+Defaults to 0.
+.El
+.Sh SEE ALSO
+.Xr iscsi 4 ,
+.Xr iscsi.conf 5 ,
+.Xr iscsictl 8 ,
+.Xr iscsid 8
+.Sh HISTORY
+The
+.Nm
+subsystem first appeared in
+.Fx 11.0 .
+.Sh AUTHORS
+The
+.Nm
+subsystem was developed by
+.An Max Gurtovoy Aq Mt maxg@mellanox.com
+and
+.An Sagi Grimberg Aq Mt sagig@mellanox.com
+under sponsorship from Mellanox Technologies.
diff --git a/share/man/man4/ixl.4 b/share/man/man4/ixl.4
index ced68f7..60aa5e6 100644
--- a/share/man/man4/ixl.4
+++ b/share/man/man4/ixl.4
@@ -1,29 +1,29 @@
-.\" Copyright (c) 2013-2015, Intel Corporation
+.\" Copyright (c) 2013-2015, Intel Corporation
.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
+.\"
+.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
-.\"
-.\" 1. Redistributions of source code must retain the above copyright notice,
+.\"
+.\" 1. Redistributions of source code must retain the above copyright notice,
.\" this list of conditions and the following disclaimer.
-.\"
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
+.\"
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" 3. Neither the name of the Intel Corporation nor the names of its
-.\" contributors may be used to endorse or promote products derived from
+.\"
+.\" 3. Neither the name of the Intel Corporation nor the names of its
+.\" contributors may be used to endorse or promote products derived from
.\" this software without specific prior written permission.
-.\"
+.\"
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-.\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
diff --git a/share/man/man4/ixlv.4 b/share/man/man4/ixlv.4
index 09aa2cd..1fb0eb9 100644
--- a/share/man/man4/ixlv.4
+++ b/share/man/man4/ixlv.4
@@ -1,29 +1,29 @@
-.\" Copyright (c) 2013-2015, Intel Corporation
+.\" Copyright (c) 2013-2015, Intel Corporation
.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
+.\"
+.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
-.\"
-.\" 1. Redistributions of source code must retain the above copyright notice,
+.\"
+.\" 1. Redistributions of source code must retain the above copyright notice,
.\" this list of conditions and the following disclaimer.
-.\"
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
+.\"
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" 3. Neither the name of the Intel Corporation nor the names of its
-.\" contributors may be used to endorse or promote products derived from
+.\"
+.\" 3. Neither the name of the Intel Corporation nor the names of its
+.\" contributors may be used to endorse or promote products derived from
.\" this software without specific prior written permission.
-.\"
+.\"
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-.\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
diff --git a/share/man/man4/ksyms.4 b/share/man/man4/ksyms.4
index 6ce42ea..fe10d20 100644
--- a/share/man/man4/ksyms.4
+++ b/share/man/man4/ksyms.4
@@ -39,16 +39,18 @@
The
.Pa /dev/ksyms
character device provides a read-only interface to a snapshot of the kernel
-symbol table. The in-kernel symbol manager is designed to be able to handle
+symbol table.
+The in-kernel symbol manager is designed to be able to handle
many types of symbols tables, however, only
.Xr elf 5
-symbol tables are supported by this device. The ELF format image contains two
+symbol tables are supported by this device.
+The ELF format image contains two
sections: a symbol table and a corresponding string table.
.Bl -tag -width indent -offset indent
.It Dv Symbol Table
The SYMTAB section contains the symbol table entries present in the current
-running kernel, including the symbol table entries of any loaded modules. The
-symbols are ordered by the kernel module load time starting with kernel file
+running kernel, including the symbol table entries of any loaded modules.
+The symbols are ordered by the kernel module load time starting with kernel file
symbols first, followed by the first loaded module's symbols and so on.
.It Dv String Table
The STRTAB section contains the symbol name strings from the kernel and any
@@ -97,14 +99,16 @@ of
will fail if:
.Bl -tag -width Er
.It Bq Er EBUSY
-The device is already open. A process must close
+The device is already open.
+A process must close
.Pa /dev/ksyms
before it can be opened again.
.It Bq Er ENOMEM
There is a resource shortage in the kernel.
.It Bq Er ENXIO
The driver was unsuccessful in creating a snapshot of the kernel symbol
-table. This may occur if the kernel was in the process of loading or
+table.
+This may occur if the kernel was in the process of loading or
unloading a module.
.El
.Sh SEE ALSO
@@ -133,13 +137,19 @@ driver was written by
.An Stacey Son Aq Mt sson@FreeBSD.org .
.Sh BUGS
Because files can be dynamically linked into the kernel at any time the symbol
-information can vary. When you open the
+information can vary.
+When you open the
.Pa /dev/ksyms
-file, you have access to an ELF image which represents a snapshot of the state of the kernel symbol information at that instant in time. Keeping the device open does not block the loading or unloading of kernel modules. To get a new snapshot you must close and re-open the device.
+file, you have access to an ELF image which represents a snapshot of the state
+of the kernel symbol information at that instant in time.
+Keeping the device open does not block the loading or unloading of kernel
+modules.
+To get a new snapshot you must close and re-open the device.
.Pp
A process is only allowed to open the
.Pa /dev/ksyms
-file once at a time. The process must close the
+file once at a time.
+The process must close the
.Pa /dev/ksyms
before it is allowed to open it again.
.Pp
diff --git a/share/man/man4/man4.arm/cgem.4 b/share/man/man4/man4.arm/cgem.4
index 01e2921..6de1d79 100644
--- a/share/man/man4/man4.arm/cgem.4
+++ b/share/man/man4/man4.arm/cgem.4
@@ -278,13 +278,15 @@ When receive checksum offloading is enabled, the device will discard packets
with bad TCP/UDP/IP checksums.
The bad packets will not be counted in any
.Xr netstat 1
-statistics. There are
+statistics.
+There are
.Xr sysctl 8
variables that count
packets discarded by the hardware (see below).
.Pp
The GEM used in the Zynq-7000 has a bug such that the receiver can
-potentially freeze up under a high load. The issue is described in sec. 16.7
+potentially freeze up under a high load.
+The issue is described in sec. 16.7
"Known Issues" of the Zynq-7000 SoC Technical Reference Manual (Xilinx
UG585 v1.7).
The
diff --git a/share/man/man4/man4.arm/mge.4 b/share/man/man4/man4.arm/mge.4
index a0f05bd..ddbacaf 100644
--- a/share/man/man4/man4.arm/mge.4
+++ b/share/man/man4/man4.arm/mge.4
@@ -90,17 +90,19 @@ The
.Nm
driver supports interrupts coalescing (IC) so that raising a transmit/receive
frame interrupt is delayed, if possible, until a threshold-defined period of
-time has elapsed. The following sysctls regulate this behaviour (separately
-for each path):
+time has elapsed.
+The following sysctls regulate this behaviour (separately for each path):
.Bl -tag -width indent
.It Va dev.mge.X.int_coal.rx_time
.It Va dev.mge.X.int_coal.tx_time
.Pp
Value of 0 disables IC on the given path, value greater than zero corresponds
to a real time period and is expressed in units equivalent to 64 ticks of the
-MGE clock. Maximum allowed value depends on MGE hardware revision. User
-provided values larger than supported will be trimmed to the maximum
-supported. More details are available in the reference manual of the device.
+MGE clock.
+Maximum allowed value depends on MGE hardware revision.
+User provided values larger than supported will be trimmed to the maximum
+supported.
+More details are available in the reference manual of the device.
.El
.Sh HARDWARE
Gigabit Ethernet controllers built into the following Marvell systems-on-chip
diff --git a/share/man/man4/mdio.4 b/share/man/man4/mdio.4
index 1a8bdd0..8120b07 100644
--- a/share/man/man4/mdio.4
+++ b/share/man/man4/mdio.4
@@ -32,7 +32,8 @@ external PHY devices.
.Tn MDIO
is one of two signal interfaces that comprise the
Media Independent Interface (MII) defined by the IEEE 802.3
-Standard. The
+Standard.
+The
.Xr miibus 4
driver provides support for devices that require full
.Tn MII
diff --git a/share/man/man4/mfi.4 b/share/man/man4/mfi.4
index c20d9bd..088676a 100644
--- a/share/man/man4/mfi.4
+++ b/share/man/man4/mfi.4
@@ -75,8 +75,9 @@ then the driver will allow mounted volumes to be removed.
.Pp
A tunable is provided to adjust the
.Nm
-driver's behaviour when attaching to a card. By default the driver will
-attach to all known cards with high probe priority. If the tunable
+driver's behaviour when attaching to a card.
+By default the driver will attach to all known cards with high probe priority.
+If the tunable
.Va hw.mfi.mrsas_enable
is set to 1,
then the driver will reduce its probe priority to allow
diff --git a/share/man/man4/mpr.4 b/share/man/man4/mpr.4
index ff500c2..13172f8 100644
--- a/share/man/man4/mpr.4
+++ b/share/man/man4/mpr.4
@@ -29,7 +29,7 @@
.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGES.
-.\"
+.\"
.\" mpr driver man page.
.\"
.\" Author: Ken Merry <ken@FreeBSD.org>
@@ -250,7 +250,7 @@ hw.mpr.X.debug_level
.Pp
tunable, either in
.Xr loader.conf 5
-or by using
+or by using
.Xr sysctl 8 .
These bits have the described effects:
.Bd -literal -offset indent
diff --git a/share/man/man4/mpt.4 b/share/man/man4/mpt.4
index 2e15325..b3a29f6 100644
--- a/share/man/man4/mpt.4
+++ b/share/man/man4/mpt.4
@@ -132,7 +132,8 @@ The
controller chips are also present on many new AMD/Opteron based systems,
like the Sun 4100.
Note that this controller can drive both SAS and SATA
-drives or a mix of them at the same time. The Integrated RAID Mirroring
+drives or a mix of them at the same time.
+The Integrated RAID Mirroring
available for these controllers is poorly supported at best.
.Pp
The
diff --git a/share/man/man4/nand.4 b/share/man/man4/nand.4
index 4371e38..2b5adb0 100644
--- a/share/man/man4/nand.4
+++ b/share/man/man4/nand.4
@@ -43,27 +43,29 @@ The
framework consists of a set of interfaces that aim to provide an extensible,
object oriented environement for NAND controllers and NAND Flash memory chips
from various hardware vendors, and to allow for uniform and flexible
-management of the NAND devices. It comprises of the following major
-components:
+management of the NAND devices.
+It comprises of the following major components:
.Bl -bullet
.It
NAND Flash controller (NFC) interface.
.Pp
Defines methods which allow to send commands as well as send/receive data
-between the controller and a NAND chip. Back-end drivers for specific NAND
+between the controller and a NAND chip.
+Back-end drivers for specific NAND
controllers plug into this interface and implement low-level routines for a
given NAND controller.
.Pp
-This layer implements basic functionality of a NAND Flash controller. It
-allows to send command and address to chip, drive CS (chip select line), as
-well as read/write to the selected NAND chip. This layer is independent of
+This layer implements basic functionality of a NAND Flash controller.
+It allows to send command and address to chip, drive CS (chip select line),
+as well as read/write to the selected NAND chip.
+This layer is independent of
NAND chip devices actually connected to the controller.
.It
NAND chip interface.
.Pp
-Provides basic operations like read page, program page, erase block. Currently
-three generic classes of drivers are available, which provide support for the
-following chips:
+Provides basic operations like read page, program page, erase block.
+Currently three generic classes of drivers are available, which provide
+support for the following chips:
.Bl -bullet
.It
large page
@@ -74,7 +76,8 @@ ONFI-compliant
.El
.Pp
This layer implements basic operations to be performed on a NAND chip, like
-read, program, erase, get status etc. Since these operations use specific
+read, program, erase, get status etc.
+Since these operations use specific
commands (depending on the vendor), each chip has potentially its own
implementation of the commands set.
.Pp
@@ -87,9 +90,10 @@ This layer is responsible for enumerating NAND chips in the system and
establishing the hierarchy between chips and their supervising controllers.
.Pp
Its main purpose is detecting type of NAND chips connected to a given chip
-select (CS line). It also allows manages locking access to the NAND
-controller. NANDbus passes requests from an active chip to the chip
+select (CS line).
+It also allows manages locking access to the NAND
controller.
+NANDbus passes requests from an active chip to the chip controller.
.It
NAND character / GEOM device.
.Pp
diff --git a/share/man/man4/ng_atm.4 b/share/man/man4/ng_atm.4
index 9c07334..2ac1acc 100644
--- a/share/man/man4/ng_atm.4
+++ b/share/man/man4/ng_atm.4
@@ -325,8 +325,8 @@ struct ngm_atm_cpcs_term {
};
.Ed
.It Dv NGM_ATM_GET_STATS Pq Ic getstats
-This command returns a message, containing node statistics. The
-structure of the message is:
+This command returns a message, containing node statistics.
+The structure of the message is:
.Bd -literal
struct ngm_atm_stats {
uint64_t in_packets;
diff --git a/share/man/man4/ng_bridge.4 b/share/man/man4/ng_bridge.4
index 9b3e600..fe5d385 100644
--- a/share/man/man4/ng_bridge.4
+++ b/share/man/man4/ng_bridge.4
@@ -186,8 +186,8 @@ This command sets the persistent flag on the node, and takes no arguments.
.Sh SHUTDOWN
This node shuts down upon receipt of a
.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected. Setting the
-persistent flag via a
+control message, or when all hooks have been disconnected.
+Setting the persistent flag via a
.Dv NGM_BRIDGE_SET_PERSISTENT
control message disables automatic node shutdown when the last hook gets
disconnected.
diff --git a/share/man/man4/ng_car.4 b/share/man/man4/ng_car.4
index 5950b99..cb1459f 100644
--- a/share/man/man4/ng_car.4
+++ b/share/man/man4/ng_car.4
@@ -109,7 +109,8 @@ links with bandwidth * delay product less than 6-8 TCP segments, but it
consumes additional system resources for queue processing.
.El
By default, all information rates are measured in bits per second and bursts
-are measured in bytes. But when NG_CAR_COUNT_PACKETS option is enabled,
+are measured in bytes.
+But when NG_CAR_COUNT_PACKETS option is enabled,
rates are measured in packets per second and bursts are in packets.
.Sh CONTROL MESSAGES
This node type supports the generic control messages and the following
diff --git a/share/man/man4/ng_deflate.4 b/share/man/man4/ng_deflate.4
index 92710b4..fef00ff 100644
--- a/share/man/man4/ng_deflate.4
+++ b/share/man/man4/ng_deflate.4
@@ -154,5 +154,6 @@ control message, or when hook have been disconnected.
.An Alexander Motin Aq Mt mav@alkar.net
.Sh BUGS
Due to nature of netgraph PPP implementation there are possible race conditions
-between data packet and ResetAck CCP packet in case of packet loss. As result,
+between data packet and ResetAck CCP packet in case of packet loss.
+As result,
packet loss can produce bigger performance degradation than supposed by protocol.
diff --git a/share/man/man4/ng_hub.4 b/share/man/man4/ng_hub.4
index bdd3f42..bba9e11 100644
--- a/share/man/man4/ng_hub.4
+++ b/share/man/man4/ng_hub.4
@@ -54,8 +54,8 @@ This command sets the persistent flag on the node, and takes no arguments.
.Sh SHUTDOWN
This node shuts down upon receipt of a
.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected. Setting the
-persistent flag via a
+control message, or when all hooks have been disconnected.
+Setting the persistent flag via a
.Dv NGM_HUB_SET_PERSISTENT
control message disables automatic node shutdown when the last hook gets
disconnected.
diff --git a/share/man/man4/ng_mppc.4 b/share/man/man4/ng_mppc.4
index 0d4d674..663cec8 100644
--- a/share/man/man4/ng_mppc.4
+++ b/share/man/man4/ng_mppc.4
@@ -35,7 +35,7 @@
.\" $Whistle: ng_mppc.8,v 1.1 1999/12/08 20:20:39 archie Exp $
.\" $FreeBSD$
.\"
-.Dd December 8, 1999
+.Dd June 7, 2016
.Dt NG_MPPC 4
.Os
.Sh NAME
@@ -153,12 +153,6 @@ and
are supplied to selectively compile in either or both capabilities.
At least one of these must be defined, or else this node type is useless.
.Pp
-The MPPC protocol requires proprietary compression code available
-from Hi/Fn (formerly STAC).
-These files must be obtained elsewhere and added to the kernel
-sources before this node type will compile with the
-.Dv NETGRAPH_MPPC_COMPRESSION
-option.
.Sh SEE ALSO
.Xr netgraph 4 ,
.Xr ng_ppp 4 ,
diff --git a/share/man/man4/ng_netflow.4 b/share/man/man4/ng_netflow.4
index 889c88a..5372f6c 100644
--- a/share/man/man4/ng_netflow.4
+++ b/share/man/man4/ng_netflow.4
@@ -74,8 +74,9 @@ plus two export hooks:
.Va export
(for NetFlow version 5) and
.Va export9
-(for NetFlow version 9). Export can be done simultaneously for all supported
-export hooks. By default (ingress NetFlow enabled) node does NetFlow accounting of data
+(for NetFlow version 9).
+Export can be done simultaneously for all supported export hooks.
+By default (ingress NetFlow enabled) node does NetFlow accounting of data
received on
.Va iface*
hooks.
@@ -196,7 +197,8 @@ struct ng_netflow_setconfig {
};
.Ed
.Pp
-Configuration is a bitmask of several options. Option NG_NETFLOW_CONF_INGRESS
+Configuration is a bitmask of several options.
+Option NG_NETFLOW_CONF_INGRESS
enabled by default enables ingress NetFlow generation (for data coming from
ifaceX hook).
Option
diff --git a/share/man/man4/ng_pptpgre.4 b/share/man/man4/ng_pptpgre.4
index fccecf8..867c86c 100644
--- a/share/man/man4/ng_pptpgre.4
+++ b/share/man/man4/ng_pptpgre.4
@@ -84,7 +84,8 @@ Connection to the lower protocol layers
This node type supports the generic control messages, plus the following:
.Bl -tag -width foo
.It Dv NGM_PPTPGRE_SET_CONFIG Pq Ic setconfig
-This command resets and configures hook for a session. If corresponding
+This command resets and configures hook for a session.
+If corresponding
session_hhhh hook is not connected, upper hook will be configured.
This command takes a
.Vt "struct ng_pptpgre_conf"
diff --git a/share/man/man4/ng_pred1.4 b/share/man/man4/ng_pred1.4
index 7befbbc..91a7103 100644
--- a/share/man/man4/ng_pred1.4
+++ b/share/man/man4/ng_pred1.4
@@ -141,5 +141,6 @@ control message, or when hook have been disconnected.
.An Alexander Motin Aq Mt mav@alkar.net
.Sh BUGS
Due to nature of netgraph PPP implementation there are possible race conditions
-between data packet and ResetAck CCP packet in case of packet loss. As result,
+between data packet and ResetAck CCP packet in case of packet loss.
+As result,
packet loss can produce bigger performance degradation than supposed by protocol.
diff --git a/share/man/man4/ng_tag.4 b/share/man/man4/ng_tag.4
index 6aac9fa..25bb7c3 100644
--- a/share/man/man4/ng_tag.4
+++ b/share/man/man4/ng_tag.4
@@ -230,7 +230,7 @@ node which will check for the specified string and return non-matching
packets to
.Xr ipfw 8 .
Matching packets are passed to
-.Xr ng_tag 4
+.Nm
node, which will set a tag and pass them back to
.Xr ng_bpf 4
node on a hook programmed to accept all packets and pass them back to
@@ -246,7 +246,7 @@ expressions must be altered accordingly.
Thus, there will be expression
.Dq Li "ether[40:2]=0x244c && ether[42:4]=0x6f636b20"
on incoming hook and empty expression to match all packets from
-.Xr ng_tag 4 .
+.Nm .
.Pp
So, this is
.Xr ngctl 8
diff --git a/share/man/man4/nvd.4 b/share/man/man4/nvd.4
index f778679..a1e9aac 100644
--- a/share/man/man4/nvd.4
+++ b/share/man/man4/nvd.4
@@ -77,8 +77,9 @@ disks and cannot be partitioned.
.Sh CONFIGURATION
The
.Nm
-driver defines a system-wide maximum delete size for NVMe devices. The
-default is 1GB. To select a different value, set the following tunable in
+driver defines a system-wide maximum delete size for NVMe devices.
+The default is 1GB.
+To select a different value, set the following tunable in
.Xr loader.conf 5 :
.Bd -literal -offset indent
hw.nvd.delete_max=<delete size in bytes>
diff --git a/share/man/man4/nvme.4 b/share/man/man4/nvme.4
index 83ca8ae..6449ec5 100644
--- a/share/man/man4/nvme.4
+++ b/share/man/man4/nvme.4
@@ -89,7 +89,8 @@ not 0, and this driver follows that convention.
By default,
.Nm
will create an I/O queue pair for each CPU, provided enough MSI-X vectors
-and NVMe queue pairs can be allocated. If not enough vectors or queue
+and NVMe queue pairs can be allocated.
+If not enough vectors or queue
pairs are available, nvme(4) will use a smaller number of queue pairs and
assign multiple CPUs per queue pair.
.Pp
diff --git a/share/man/man4/nvram2env.4 b/share/man/man4/nvram2env.4
index 3678160..798e04e 100644
--- a/share/man/man4/nvram2env.4
+++ b/share/man/man4/nvram2env.4
@@ -35,11 +35,11 @@
.Sh DESCRIPTION
.Nm
implements a simple method of reading the NVRAM-like data and information
-stored in flash and storing it in the kernel environment. It can then be
-used by various device drivers at boot-time.
+stored in flash and storing it in the kernel environment.
+It can then be used by various device drivers at boot-time.
.Pp
-The NVRAM-like data is an array of zero terminated strings. Each string contains
-the string name, "=" delimiter and the string value.
+The NVRAM-like data is an array of zero terminated strings.
+Each string contains the string name, "=" delimiter and the string value.
.Pp
.Nm
copies the environment values into kernel environment using the kernel setenv call.
@@ -63,13 +63,14 @@ maxsize - maximum size of data block.
flags - control flags, used to select nvram type and enable/disable CRC check.
.Bl -tag -width indent
.It Fa 0x0001
-Avoid CRC checking. Currently CRC checking is not implemented, so to be future
+Avoid CRC checking.
+Currently CRC checking is not implemented, so to be future
compatible, please set it to "1".
.It Fa 0x0002
Use format "Generic", skip uint32_t field, then zero terminating array of
strings.
.It Fa 0x0004
-Use Broadcom CFE format. uint32_t signature "FLSH", uint32_t size,
+Use Broadcom CFE format, uint32_t signature "FLSH", uint32_t size,
three unused fields uint32_t, then data.
.It Fa 0x0008
Use U-Boot format, uint32_t crc, then zero terminating array of strings.
diff --git a/share/man/man4/oce.4 b/share/man/man4/oce.4
index 51ac5ec..c502283 100644
--- a/share/man/man4/oce.4
+++ b/share/man/man4/oce.4
@@ -1,6 +1,6 @@
.\" Copyright (C) 2013 Emulex
.\" All rights reserved.
-.\"
+.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
.\"
diff --git a/share/man/man4/pass.4 b/share/man/man4/pass.4
index 618b643..3a2e1e7 100644
--- a/share/man/man4/pass.4
+++ b/share/man/man4/pass.4
@@ -98,7 +98,7 @@ It is probably more useful to issue this ioctl through the
device.
.It CAMIOQUEUE union ccb *
Queue a CCB to the
-.Xr pass 4
+.Nm
driver to be executed asynchronously.
The caller may use
.Xr select 2 ,
@@ -167,7 +167,7 @@ ioctl.
An error will only be returned from the
.Dv CAMIOGET
ioctl if the
-.Xr pass 4
+.Nm
driver fails to copy data to the user process or if there are no completed
CCBs available to retrieve.
If no CCBs are available to retrieve,
diff --git a/share/man/man4/pf.4 b/share/man/man4/pf.4
index b7b504d..6b16943 100644
--- a/share/man/man4/pf.4
+++ b/share/man/man4/pf.4
@@ -1077,7 +1077,7 @@ struct pfi_kif {
};
.Ed
.It Dv DIOCSETIFFLAG Fa "struct pfioc_iface *io"
-Set the user setable flags (described above) of the
+Set the user settable flags (described above) of the
.Nm
internal interface description.
The filtering process is the same as for
diff --git a/share/man/man4/proto.4 b/share/man/man4/proto.4
index 9638d4f..39f585d 100644
--- a/share/man/man4/proto.4
+++ b/share/man/man4/proto.4
@@ -108,7 +108,8 @@ system call can be used for the
.Dv PROTO_IOC_REGION
request.
This ioctl request returns the extend of the resource covered by this
-device special file. The extend is returned in the following structure:
+device special file.
+The extend is returned in the following structure:
.Bd -literal
struct proto_ioc_region {
unsigned long address;
@@ -200,8 +201,8 @@ The
field is set on output with the key of the DMA tag.
The tag is created with the constraints given by the
.Va tag
-sub-structure. These constraints correspond roughly to those that can be
-given to the
+sub-structure.
+These constraints correspond roughly to those that can be given to the
.Xr bus_dma_tag_create 9
function.
.It PROTO_IOC_BUSDMA_TAG_DERIVE
@@ -387,7 +388,8 @@ or
.Pa mem
representing I/O port or memory mapped I/O space (resp.)
.Pp
-ISA devices do not have a location. Instead, they are identified by the
+ISA devices do not have a location.
+Instead, they are identified by the
first I/O port address or first memory mapped I/O address.
Consequently, all device special files corresponding to an ISA device are
located under
diff --git a/share/man/man4/psm.4 b/share/man/man4/psm.4
index 866e447..df65c2c 100644
--- a/share/man/man4/psm.4
+++ b/share/man/man4/psm.4
@@ -110,7 +110,8 @@ The movement of the roller is reported as movement along the Z axis.
8 byte data packets are sent to the user program at this level.
.Pp
At the operation level two, data from the pointing device is passed to the
-user program as is. Conversely, command from the user program is passed
+user program as is.
+Conversely, command from the user program is passed
to the pointing device as is and the user program is responsible for
status validation and error recovery.
Modern PS/2 type pointing devices often use proprietary data format.
@@ -352,7 +353,8 @@ to
.Em 0
at boot-time.
Currently, this is only supported on Synaptics touchpads with Extended
-support disabled. The behaviour may be changed after boot by setting
+support disabled.
+The behaviour may be changed after boot by setting
the sysctl with the same name and by restarting
.Xr moused 8
using
@@ -469,7 +471,7 @@ typedef struct synapticshw {
int capPalmDetect; /* can detect a palm */
int capPassthrough; /* can passthrough guest packets */
int capMiddle; /* has a physical middle button */
- int nExtendedButtons; /* has N additionnal buttons */
+ int nExtendedButtons; /* has N additional buttons */
int nExtendedQueries; /* supports N extended queries */
} synapticshw_t;
.Ed
diff --git a/share/man/man4/pts.4 b/share/man/man4/pts.4
index c142c50..2008482 100644
--- a/share/man/man4/pts.4
+++ b/share/man/man4/pts.4
@@ -119,9 +119,11 @@ remote login with proper back-flushing of output; it can be
used by other similar programs.
.It Dv TIOCGPTN
Obtain device unit number, which can be used to generate the filename of
-the pseudo-terminal slave device. This
+the pseudo-terminal slave device.
+This
.Xr ioctl 2
-should not be used directly. Instead, the
+should not be used directly.
+Instead, the
.Xr ptsname 3
function should be used.
.It Dv TIOCPTMASTER
@@ -129,7 +131,8 @@ Determine whether the file descriptor is pointing to a pseudo-terminal
master device.
This
.Xr ioctl 2
-should not be used directly. It is used to implement routines like
+should not be used directly.
+It is used to implement routines like
.Xr grantpt 3 .
.El
.Sh FILES
diff --git a/share/man/man4/puc.4 b/share/man/man4/puc.4
index 34880cd..eb76c36 100644
--- a/share/man/man4/puc.4
+++ b/share/man/man4/puc.4
@@ -53,5 +53,5 @@ Support for new cards should be added there.
.Sh HISTORY
This driver took the idea from the
.Nx
-.Xr puc 4
+.Nm
driver.
diff --git a/share/man/man4/qlxgbe.4 b/share/man/man4/qlxgbe.4
index 32b7d34..fde9ef9 100644
--- a/share/man/man4/qlxgbe.4
+++ b/share/man/man4/qlxgbe.4
@@ -1,5 +1,5 @@
.\"-
-.\" Copyright (c) 2013 Qlogic Corportaion
+.\" Copyright (c) 2013 Qlogic Corportaion
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
diff --git a/share/man/man4/qlxge.4 b/share/man/man4/qlxge.4
index 21e6ce1..2da3a8d 100644
--- a/share/man/man4/qlxge.4
+++ b/share/man/man4/qlxge.4
@@ -1,5 +1,5 @@
.\"-
-.\" Copyright (c) 2013-2014 Qlogic Corporation
+.\" Copyright (c) 2013-2014 Qlogic Corporation
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
diff --git a/share/man/man4/random.4 b/share/man/man4/random.4
index 5e5388f..23578d0 100644
--- a/share/man/man4/random.4
+++ b/share/man/man4/random.4
@@ -48,7 +48,7 @@ it is seeded for the first time.
This may cause trouble at system boot
when keys and the like
are generated from
-.Xr random 4
+.Nm
so steps should be taken to ensure a
seeding as soon as possible.
.Pp
@@ -63,7 +63,7 @@ this could be done by
This sysctl will not return
random bytes unless
the
-.Xr random 4
+.Nm
device is seeded.
.Pp
This initial seeding
diff --git a/share/man/man4/rum.4 b/share/man/man4/rum.4
index 89af445..dfe2ab8 100644
--- a/share/man/man4/rum.4
+++ b/share/man/man4/rum.4
@@ -16,7 +16,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 13, 2008
+.Dd June 9, 2016
.Dt RUM 4
.Os
.Sh NAME
@@ -64,10 +64,14 @@ This chipset uses the MIMO (multiple-input multiple-output) technology
with multiple antennas to extend the operating range of the adapter
and to achieve higher throughput.
.Pp
+All chips have hardware support for WEP, AES-CCM, TKIP, and Michael
+cryptographic operations.
+.Pp
.Nm
supports
.Cm station ,
.Cm adhoc ,
+.Cm adhoc-demo ,
.Cm hostap ,
and
.Cm monitor
@@ -182,7 +186,3 @@ driver was written by
.An Niall O'Higgins Aq Mt niallo@openbsd.org
and
.An Damien Bergamini Aq Mt damien@openbsd.org .
-.Sh BUGS
-Host AP mode doesn't support client power save.
-Clients using power save mode will experience
-packet loss (disabling power saving on the client will fix this).
diff --git a/share/man/man4/sdhci.4 b/share/man/man4/sdhci.4
index 8fd16ff..b4b14bc 100644
--- a/share/man/man4/sdhci.4
+++ b/share/man/man4/sdhci.4
@@ -58,8 +58,8 @@ detaches it on card removing.
.Sh HARDWARE
The
.Nm
-driver supports different specification compatible chips. The following
-chips have been verified to work:
+driver supports different specification compatible chips.
+The following chips have been verified to work:
.Pp
.Bl -bullet -compact
.It
diff --git a/share/man/man4/sfxge.4 b/share/man/man4/sfxge.4
index 0232d23..9be27e0 100644
--- a/share/man/man4/sfxge.4
+++ b/share/man/man4/sfxge.4
@@ -153,8 +153,8 @@ from loss, because reducing the ACK rate can damage performance.
.It Va hw.sfxge.mcdi_logging
Enable logging of MCDI protocol messages (only available if enabled at compile-time).
.It Va hw.sfxge.N.mcdi_logging
-Enable or disable logging of MCDI protocol messages on a per-port basis. The default for each
-port will be the value of
+Enable or disable logging of MCDI protocol messages on a per-port basis.
+The default for each port will be the value of
.Va hw.sfxge.mcdi_logging.
The logging may also be enabled or disabled after the driver is loaded using the sysctl
.Va dev.sfxge.%d.mcdi_logging.
diff --git a/share/man/man4/siba.4 b/share/man/man4/siba.4
index 12e263b..7fcb5e6 100644
--- a/share/man/man4/siba.4
+++ b/share/man/man4/siba.4
@@ -54,7 +54,8 @@ interblock communications architecture found in earlier Broadcom Home
Networking Division wireless chipsets and embedded systems.
.Pp
A common interconnect connects all of the Silicon Backplane's functional
-blocks. These functional blocks, known as cores, use the Open Core Protocol
+blocks.
+These functional blocks, known as cores, use the Open Core Protocol
(OCP) interface to communicate with agents attached to the Silicon
Backplane.
.Pp
@@ -86,7 +87,6 @@ driver was originally written by
.An Bruce M. Simpson Aq Mt bms@FreeBSD.org
and
.An Weongyo Jeong Aq Mt weongyo@FreeBSD.org .
-
The driver was rewritten for
.Fx 11.0
by
diff --git a/share/man/man4/siftr.4 b/share/man/man4/siftr.4
index 7afa279..e122b5c 100644
--- a/share/man/man4/siftr.4
+++ b/share/man/man4/siftr.4
@@ -84,8 +84,8 @@ In the IPv4-only (default) mode, standard dotted decimal notation (e.g.
"136.186.229.95") is used to format IPv4 addresses for logging.
In IPv6 mode, standard dotted decimal notation is used to format IPv4 addresses,
and standard colon-separated hex notation (see RFC 4291) is used to format IPv6
-addresses for logging. Note that SIFTR uses uncompressed notation to format IPv6
-addresses.
+addresses for logging.
+Note that SIFTR uses uncompressed notation to format IPv6 addresses.
For example, the address "fe80::20f:feff:fea2:531b" would be logged as
"fe80:0:0:0:20f:feff:fea2:531b".
.Ss Run-time Configuration
@@ -143,8 +143,9 @@ present in the example log messages in this section indicates a
line continuation and is not part of the actual log message.
.Pp
The first type of log message is written to the file when the module is
-enabled and starts collecting data from the running kernel. The text below
-shows an example module enable log. The fields are tab delimited key-value
+enabled and starts collecting data from the running kernel.
+The text below shows an example module enable log.
+The fields are tab delimited key-value
pairs which describe some basic information about the system.
.Bd -literal -offset indent
enable_time_secs=1238556193 enable_time_usecs=462104 \\
@@ -289,8 +290,8 @@ The maximum segment size for the flow, in bytes.
The current smoothed RTT estimate for the flow, in units of TCP_RTT_SCALE * HZ,
where TCP_RTT_SCALE is a define found in tcp_var.h, and HZ is the kernel's tick
timer.
-Divide by TCP_RTT_SCALE * HZ to get the RTT in secs. TCP_RTT_SCALE and HZ are
-reported in the enable log message.
+Divide by TCP_RTT_SCALE * HZ to get the RTT in secs.
+TCP_RTT_SCALE and HZ are reported in the enable log message.
.El
.Bl -tag -offset indent -width Va
.It Va 18
@@ -307,8 +308,8 @@ for information about the various flags.
.It Va 20
The current retransmission timeout length for the flow, in units of HZ, where HZ
is the kernel's tick timer.
-Divide by HZ to get the timeout length in seconds. HZ is reported in the
-enable log message.
+Divide by HZ to get the timeout length in seconds.
+HZ is reported in the enable log message.
.El
.Bl -tag -offset indent -width Va
.It Va 21
@@ -339,7 +340,8 @@ The current number of segments in the reassembly queue.
.It Va 27
Flowid for the connection.
A caveat: Zero '0' either represents a valid flowid or a default value when it's
-not being set. There is no easy way to differentiate without looking at actual
+not being set.
+There is no easy way to differentiate without looking at actual
network interface card and drivers being used.
.El
.Bl -tag -offset indent -width Va
@@ -715,7 +717,8 @@ variable will create the new file and allow log messages to begin being written
to disk again.
The new log file path must differ from the path to the deleted file.
.It
-The hash table used within the code is sized to hold 65536 flows. This is not a
+The hash table used within the code is sized to hold 65536 flows.
+This is not a
hard limit, because chaining is used to handle collisions within the hash table
structure.
However, we suspect (based on analogies with other hash table performance data)
diff --git a/share/man/man4/simplebus.4 b/share/man/man4/simplebus.4
index 6834b38..337fc1e 100644
--- a/share/man/man4/simplebus.4
+++ b/share/man/man4/simplebus.4
@@ -51,7 +51,8 @@ controller, connectivity controllers, accelerating engines and so on.
.Pp
The driver is generic and common for all flattened device tree nodes claiming
.Pa simple-bus
-compatibility. It iterates over direct descendants of the
+compatibility.
+It iterates over direct descendants of the
.Pa simple-bus
node, instantiates newbus children and assigns resources to them, based on the
configuration data retrieved from the nodes properties in
@@ -78,5 +79,6 @@ support first appeared in
The
.Nm
support was developed by Semihalf under sponsorship from the FreeBSD
-Foundation. This manual page was written by
+Foundation.
+This manual page was written by
.An Rafal Jaworowski .
diff --git a/share/man/man4/snd_hda.4 b/share/man/man4/snd_hda.4
index 40a8862..6f9017a 100644
--- a/share/man/man4/snd_hda.4
+++ b/share/man/man4/snd_hda.4
@@ -322,8 +322,8 @@ driver.
.It Va misc
Misc bits.
Can be specified as a number from 0 to 15.
-Bit 0 has a special meaning. When set it means that jack detection is
-not implemented in hardware.
+Bit 0 has a special meaning.
+When set it means that jack detection is not implemented in hardware.
.El
.Ss Runtime Configuration
The following
@@ -411,8 +411,8 @@ Here we can see, that the nodes with ID (nid) 25 and 27 are front panel
connectors (Jack, Front), nids 20, 24 and 26 are rear panel connectors
(Jack, Rear) and nid 21 is a built-in speaker (Fixed, Onboard).
Pins with nids 22, 23, 28, 30 and 31 will be disabled by driver due to "None"
-connectivity. So the pin count and description matches to connectors that
-we have.
+connectivity.
+So the pin count and description matches to connectors that we have.
.Pp
Using association (as) and sequence (seq) fields values pins are grouped into
3 associations:
@@ -473,8 +473,8 @@ hint.hdac.0.cad0.nid21.config="as=2"
will swap line-out and speaker functions.
So the
.Li pcm0
-device will play to the line-out and headphones jacks. Line-out will
-be muted on the headphones jack connection.
+device will play to the line-out and headphones jacks.
+Line-out will be muted on the headphones jack connection.
Recording on
.Li pcm0
will go from two external microphones and line-in jacks.
@@ -576,7 +576,8 @@ PC speaker input
other random inputs
.El
.Pp
-Controls have different precision. Some could be just an on/off triggers.
+Controls have different precision.
+Some could be just an on/off triggers.
Most of controls use logarithmic scale.
.Sh HARDWARE
The
diff --git a/share/man/man4/stf.4 b/share/man/man4/stf.4
index 5e210df..786acb2 100644
--- a/share/man/man4/stf.4
+++ b/share/man/man4/stf.4
@@ -189,8 +189,9 @@ The default value is shown next to each variable.
.Bl -tag -width indent
.It Va net.link.stf.permit_rfc1918 : No 0
The RFC3056 requires the use of globally unique 32-bit IPv4
-addresses. This sysctl variable controls the behaviour of this
-requirement. When it set to not 0,
+addresses.
+This sysctl variable controls the behaviour of this requirement.
+When it set to not 0,
.Nm stf
allows the use of private IPv4 addresses described in the RFC1918.
This may be useful for an Intranet environment or when some mechanisms
diff --git a/share/man/man4/u3g.4 b/share/man/man4/u3g.4
index 0663a9a..ceec14b 100644
--- a/share/man/man4/u3g.4
+++ b/share/man/man4/u3g.4
@@ -91,8 +91,9 @@ In some of these devices a mass storage device supported by the
.Xr umass 4
driver is present which contains Windows and Mac OS X drivers.
The device starts up in disk mode (TruInstall, ZeroCD, etc.) and requires
-additional commands to switch it to modem mode. If your device is not
-switching automatically, please try to add quirks. See
+additional commands to switch it to modem mode.
+If your device is not switching automatically, please try to add quirks.
+See
.Xr usbconfig 8
and
.Xr usb_quirk 4 .
diff --git a/share/man/man4/unix.4 b/share/man/man4/unix.4
index 173fd0e..93cd399 100644
--- a/share/man/man4/unix.4
+++ b/share/man/man4/unix.4
@@ -241,7 +241,7 @@ These will arrive in the form of a filled in
structure, defined in
.In sys/ucred.h
as follows:
-.Bd -literal
+.Bd -literal
struct xucred {
u_int cr_version; /* structure layout version */
uid_t cr_uid; /* effective user id */
diff --git a/share/man/man4/urtwn.4 b/share/man/man4/urtwn.4
index a4c1b9f..026c981 100644
--- a/share/man/man4/urtwn.4
+++ b/share/man/man4/urtwn.4
@@ -14,13 +14,15 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 15, 2015
+.Dd June 9, 2016
.Dt URTWN 4
.Os
.Sh NAME
.Nm urtwn
.Nd Realtek RTL8188CU/RTL8188RU/RTL8188EU/RTL8192CU USB IEEE 802.11b/g/n wireless network device
.Sh SYNOPSIS
+.Cd "options URTWN_WITHOUT_UCODE"
+.Pp
To compile this driver into the kernel,
place the following lines in your
kernel configuration file:
@@ -39,13 +41,6 @@ module at boot time, place the following line in
.Bd -literal -offset indent
if_urtwn_load="YES"
.Ed
-.Pp
-In both cases, place the following line in
-.Xr loader.conf 5
-to acknowledge the firmware license (see below):
-.Bd -literal -offset indent
-legal.realtek.license_ack=1
-.Ed
.Sh DESCRIPTION
The
.Nm
@@ -64,15 +59,21 @@ The RTL8192CU is a highly integrated multiple-in, multiple-out (MIMO)
RF in a single chip.
It operates in the 2GHz spectrum only.
.Pp
-This driver requires the firmware built with the
-.Nm urtwnfw
-module to work.
-For the loaded firmware to be enabled for use the license at
-.Pa /usr/share/doc/legal/realtek.LICENSE
-must be agreed by adding the following line to
-.Xr loader.conf 5 :
+All chips have hardware support for WEP, AES-CCM and TKIP encryption.
+.Pp
+The driver supports
+.Cm station ,
+.Cm adhoc ,
+.Cm hostap ,
+and
+.Cm monitor
+mode operation.
+Only one virtual interface may be configured at any time.
.Pp
-.Dl "legal.realtek.license_ack=1"
+This driver may use the firmware built with the
+.Nm urtwnfw
+module for some additional features
+(when URTWN_WITHOUT_UCODE kernel option is not set).
.Sh FILES
.Bl -tag -width ".Pa /usr/share/doc/legal/realtek.LICENSE" -compact
.It Pa /usr/share/doc/legal/realtek.LICENSE
@@ -117,6 +118,28 @@ Join a specific BSS network with 64-bit WEP encryption:
ifconfig wlan create wlandev urtwn0 ssid my_net \e
wepmode on wepkey 0x1234567890 weptxkey 1 up
.Ed
+.Pp
+Create an IBSS network with 128-bit WEP encryption on the channel 4:
+.Bd -literal -offset indent
+ifconfig wlan0 create wlandev urtwn0 wlanmode adhoc ssid my_net \e
+ wepmode on wepkey 0x01020304050607080910111213 weptxkey 1 \e
+ channel 4
+.Ed
+.Pp
+Join/create an 802.11b IBSS network with network name
+.Dq Li my_net :
+.Bd -literal -offset indent
+ifconfig wlan0 create wlandev urtwn0 wlanmode adhoc
+ifconfig wlan0 inet 192.168.0.22 netmask 0xffffff00 ssid my_net \e
+ mode 11b
+.Ed
+.Pp
+Create an 802.11g host-based access point:
+.Bd -literal -offset indent
+ifconfig wlan0 create wlandev urtwn0 wlanmode hostap
+ifconfig wlan0 inet 192.168.0.10 netmask 0xffffff00 ssid my_ap \e
+ mode 11g
+.Ed
.Sh DIAGNOSTICS
.Bl -diag
.It "urtwn%d: error %d, could not read firmware %s"
@@ -134,6 +157,7 @@ This should not happen.
.Xr urtwnfw 4 ,
.Xr usb 4 ,
.Xr wlan 4 ,
+.Xr wlan_amrr 4 ,
.Xr wlan_ccmp 4 ,
.Xr wlan_tkip 4 ,
.Xr wlan_wep 4 ,
@@ -158,5 +182,9 @@ driver was written by
.Sh CAVEATS
The
.Nm
-driver does not support any of the 802.11n capabilities offered by the
-adapters.
+driver currently does not support A-MPDU 802.11n transmit aggregation.
+.Pp
+For non-RTL8188EUS chips
+.Dq "rate control"
+algorithm is absent; this may result in increased packet loss in noisy
+networks.
diff --git a/share/man/man4/usb_template.4 b/share/man/man4/usb_template.4
index e4dba2c..2cc1ee4 100644
--- a/share/man/man4/usb_template.4
+++ b/share/man/man4/usb_template.4
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd March 18, 2014
+.Dd June 8, 2016
.Dt USB_TEMPLATE 4
.Os
.
@@ -32,7 +32,7 @@
.
.Nm usb_template
.
-.Nd "USB templates"
+.Nd "USB device side templates"
.
.
.Sh SYNOPSIS
@@ -59,19 +59,33 @@ configuration descriptors, one or more USB interface descriptors, one
or more USB endpoint descriptors, USB strings and additional USB
descriptors.
.
-The USB template module currently has templates for USB Mass Storage,
-USB CDC Ethernet and Message Transfer Protocol.
+USB templates are selected using the
+.Va hw.usb.template
+sysctl and tunable.
.
-USB templates are currently selected using the "hw.usb.template"
-sysctl.
-.
-The "hw.usb.template" value can be changed at any time, but will not
+The
+.Va hw.usb.template
+value can be changed at any time, but will not
have any effect until the USB device has been re-enumerated.
.
-.
+Available templates are:
+.Bl -column -offset 3n "Value"
+.It Em Value Ta Em Description
+.It Dv 0 Ta USB Mass Storage
+.It Dv 1 Ta CDC Ethernet
+.It Dv 2 Ta Media Transfer Protocol (MTP)
+.It Dv 3 Ta USB serial port
+.It Dv 4 Ta USB audio
+.It Dv 5 Ta USB keyboard
+.It Dv 6 Ta USB mouse
+.It Dv 7 Ta USB phone
+.It Dv 8 Ta CDC Ethernet and serial port
+.It Dv 9 Ta USB MIDI
+.El
.
.Sh SEE ALSO
-.Xr usb 4
+.Xr usb 4 ,
+.Xr usfs 4
.Sh STANDARDS
The
.Nm
diff --git a/share/man/man4/usfs.4 b/share/man/man4/usfs.4
index a72a8d8..ef75785 100644
--- a/share/man/man4/usfs.4
+++ b/share/man/man4/usfs.4
@@ -22,10 +22,10 @@
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
-.\"
+.\"
.\" $FreeBSD$
.\"
-.Dd March 18, 2014
+.Dd June 8, 2016
.Dt USFS 4
.Os
.Sh NAME
@@ -50,12 +50,17 @@ usfs_load="YES"
The
.Nm
driver provides support for emulating an USB mass storage device when
-the USB stack is activated in USB device side mode.
+the USB stack is activated in USB device side mode (the
+.Xr usb_template 4
+module is loaded and the
+.Va hw.usb.template
+sysctl is set to 0).
.Pp
Upon attach the driver creates a RAM disk which can be read and written.
.Sh SEE ALSO
.Xr umass 4 ,
-.Xr usb 4
+.Xr usb 4 ,
+.Xr usb_template 4
.Sh HISTORY
The
.Nm
diff --git a/share/man/man4/vale.4 b/share/man/man4/vale.4
index 4eeab1a..722d8f0 100644
--- a/share/man/man4/vale.4
+++ b/share/man/man4/vale.4
@@ -21,7 +21,7 @@
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
-.\"
+.\"
.\" This document is derived in part from the enet man page (enet.4)
.\" distributed with 4.3BSD Unix.
.\"
diff --git a/share/man/man4/virtio_scsi.4 b/share/man/man4/virtio_scsi.4
index f65f8b7..3828eef 100644
--- a/share/man/man4/virtio_scsi.4
+++ b/share/man/man4/virtio_scsi.4
@@ -57,8 +57,9 @@ prompt before booting the kernel or stored in
.It Va hw.vtscsi.bus_reset_disable
In the initial QEMU release with VirtIO SCSI support, in-flight
operations were not aborted when stopping the device, rendering
-bus reset ineffective. This tunable disables attempts to issue
-reset bus commands. The default value is 1.
+bus reset ineffective.
+This tunable disables attempts to issue reset bus commands.
+The default value is 1.
.El
.Sh DEBUGGING
To enable debugging prints from the
diff --git a/share/man/man4/vlan.4 b/share/man/man4/vlan.4
index a47f68c..480d026 100644
--- a/share/man/man4/vlan.4
+++ b/share/man/man4/vlan.4
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 4, 2012
+.Dd June 8, 2016
.Dt VLAN 4
.Os
.Sh NAME
diff --git a/share/man/man4/witness.4 b/share/man/man4/witness.4
index 02505aa..fc745d5 100644
--- a/share/man/man4/witness.4
+++ b/share/man/man4/witness.4
@@ -62,7 +62,7 @@ If any of these checks fail, then the kernel will panic.
The
.Dv WITNESS_COUNT
kernel option controls the maximum number of
-.Xr witness 4
+.Nm
entries that are tracked in the kernel.
The maximum number of entries can be queried via the
.Va debug.witness.count
@@ -76,7 +76,7 @@ environment variable.
The
.Dv WITNESS_NO_VNODE
kernel option tells
-.Xr witness 4
+.Nm
to ignore locking issues between
.Xr vnode 9
objects.
@@ -118,7 +118,8 @@ The sysctl
specifies the level of witness involvement in the system.
A value of 1 specifies that witness is enabled.
A value of 0 specifies that witness is disabled, but that can be enabled
-again. This will maintain a small amount of overhead in the system.
+again.
+This will maintain a small amount of overhead in the system.
A value of -1 specifies that witness is disabled permanently and
cannot be enabled again.
The sysctl
diff --git a/share/man/man5/ar.5 b/share/man/man5/ar.5
index 1c1d79b..ca9f96d 100644
--- a/share/man/man5/ar.5
+++ b/share/man/man5/ar.5
@@ -70,7 +70,7 @@ file attributes associated with the member.
An archive header describes the file attributes for the archive member that
follows it.
The
-.Xr ar 5
+.Nm
format only supports a limited number of attributes: the file name,
the file creation time stamp, the uid and gid of the creator, the file
mode and the file size.
diff --git a/share/man/man5/devfs.rules.5 b/share/man/man5/devfs.rules.5
index b8016db..ca62377 100644
--- a/share/man/man5/devfs.rules.5
+++ b/share/man/man5/devfs.rules.5
@@ -90,7 +90,8 @@ configuration file.
.It Pa /etc/devfs.rules
Local
.Nm
-configuration file. Rulesets in here override those in
+configuration file.
+Rulesets in here override those in
.Pa /etc/defaults/devfs.rules
with the same ruleset number, otherwise the two files are effectively merged.
.El
diff --git a/share/man/man5/elf.5 b/share/man/man5/elf.5
index a72eed6..42e6b2c 100644
--- a/share/man/man5/elf.5
+++ b/share/man/man5/elf.5
@@ -1308,5 +1308,5 @@ This manual page was written by
.An Jeroen Ruigrok van der Werven Aq Mt asmodai@FreeBSD.org
with inspiration from BSDi's
.Bsx
-.Xr elf 5
+.Nm
manpage.
diff --git a/share/man/man5/nandfs.5 b/share/man/man5/nandfs.5
index 230989e..7e89599 100644
--- a/share/man/man5/nandfs.5
+++ b/share/man/man5/nandfs.5
@@ -109,7 +109,8 @@ partition at the specified mount point during system boot.
.Xr umount_nandfs 8
.Sh HISTORY
The NAND FS concepts are based on NILFS principles and initial implementation
-was derived from early read-only NILFS NetBSD code. Since then the NAND FS
+was derived from early read-only NILFS NetBSD code.
+Since then the NAND FS
code diverged significantly and is by no means compatible with NILFS.
.Pp
The NAND Flash file system first appeared in
diff --git a/share/man/man5/nsswitch.conf.5 b/share/man/man5/nsswitch.conf.5
index b1fbbd4..ec5d94c 100644
--- a/share/man/man5/nsswitch.conf.5
+++ b/share/man/man5/nsswitch.conf.5
@@ -33,7 +33,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 25, 2013
+.Dd June 6, 2016
.Dt NSSWITCH.CONF 5
.Os
.Sh NAME
@@ -148,7 +148,9 @@ The following databases are used by the following C library functions:
.Xr getprotoent 3
.It netgroup
.Xr getnetgrent 3 ,
+.Xr getnetgrent_r 3 ,
.Xr setnetgrent 3 ,
+.Xr endnetgrent 3 ,
.Xr innetgr 3
.El
.Ss Status codes
@@ -221,7 +223,7 @@ and continue on anything else (i.e,
You can enable caching for the particular database by specifying
.Dq cache
as the first source in the
-.Xr nsswitch.conf 5
+.Nm
file.
You should also enable caching for this database in
.Xr nscd.conf 5 .
diff --git a/share/man/man5/quota.user.5 b/share/man/man5/quota.user.5
index c314b65..0bcc591 100644
--- a/share/man/man5/quota.user.5
+++ b/share/man/man5/quota.user.5
@@ -98,7 +98,8 @@ utility will truncate the data files to the minimum size needed
to store the highest id with either non-zero file usage or
non-zero quota limits.
.Pp
-The data record for id 0 has special meaning. If the
+The data record for id 0 has special meaning.
+If the
.Dq Dv dqb_btime
or
.Dq Dv dbq_itime
diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5
index ae4972e..2ce3a0e 100644
--- a/share/man/man5/rc.conf.5
+++ b/share/man/man5/rc.conf.5
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 30, 2016
+.Dd June 8, 2016
.Dt RC.CONF 5
.Os
.Sh NAME
@@ -189,7 +189,8 @@ to this directory before running the service.
Run the service under this user account.
.It Ao Ar name Ac Ns Va _group
.Pq Vt str
-Run the chrooted service under this system group. Unlike the _user
+Run the chrooted service under this system group.
+Unlike the _user
setting, this setting has no effect if the service is not chrooted.
.It Ao Ar name Ac Ns Va _fib
.Pq Vt int
@@ -944,7 +945,8 @@ interface is desired,
.Va pflog_instances
is set to the list of
.Xr pflogd 8
-instances that should be started at system boot time. If
+instances that should be started at system boot time.
+If
.Va pflog_instances
is set, for each whitespace-seperated
.Ar element
@@ -983,11 +985,13 @@ This variable contains additional flags passed to the
program.
.It Va ftpproxy_instances
.Pq Vt str
-Empty by default. If multiple instances of
+Empty by default.
+If multiple instances of
.Xr ftp-proxy 8
are desired at boot time,
.Va ftpproxy_instances
-should contain a whitespace-seperated list of instance names. For each
+should contain a whitespace-seperated list of instance names.
+For each
.Ar element
in the list, a variable named
.Ao Ar element Ac Ns Va _flags
@@ -1203,12 +1207,12 @@ Note that the maximum number of the generated addresses from a range
specification is limited to an integer value specified in
.Va netif_ipexpand_max
in
-.Xr rc.conf 5
+.Nm
because a small typo can unexpectedly generate a large number of addresses.
The default value is
.Li 2048 .
It can be increased by adding the following line into
-.Xr rc.conf 5 :
+.Nm :
.Bd -literal
netif_ipexpand_max="4096"
.Ed
@@ -2559,6 +2563,22 @@ is set to
these are the flags to pass to the
.Xr ypbind 8
service.
+.It Va nis_ypldap_enable
+.Pq Vt bool
+If set to
+.Dq Li YES ,
+run the
+.Xr ypldap 8
+daemon at system boot time.
+.It Va nis_ypldap_flags
+.Pq Vt str
+If
+.Va nis.ypldap_enable
+is set to
+.Dq Li YES ,
+these are the flags to pass to the
+.Xr ypldap 8
+daemon.
.It Va nis_ypset_enable
.Pq Vt bool
If set to
@@ -3880,7 +3900,7 @@ all configured jails in
are stopped in reverse order.
.It Va jail_* variables
Note that older releases supported per-jail configuration via
-.Xr rc.conf 5
+.Nm
variables.
For example,
hostname of a jail named
diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5
index 2e5dfce..c88f9a0 100644
--- a/share/man/man5/src.conf.5
+++ b/share/man/man5/src.conf.5
@@ -1,7 +1,7 @@
.\" DO NOT EDIT-- this file is automatically generated.
.\" from FreeBSD: head/tools/build/options/makeman 292283 2015-12-15 18:42:30Z bdrewery
.\" $FreeBSD$
-.Dd June 5, 2016
+.Dd June 14, 2016
.Dt SRC.CONF 5
.Os
.Sh NAME
@@ -190,6 +190,24 @@ as part of the bootstrap process.
.Pp
It is a default setting on
amd64/amd64, arm/arm, arm/armeb, arm/armv6, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, pc98/i386, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
+.It Va WITHOUT_BLACKLIST
+.\" from FreeBSD: head/tools/build/options/WITHOUT_BLACKLIST 301554 2016-06-07 16:35:55Z lidl
+Set this if you do not want to build blacklistd / blacklistctl.
+When set, it also enforces the following options:
+.Pp
+.Bl -item -compact
+.It
+.Va WITHOUT_BLACKLIST_SUPPORT
+.El
+.It Va WITHOUT_BLACKLIST_SUPPORT
+.\" from FreeBSD: head/tools/build/options/WITHOUT_BLACKLIST_SUPPORT 301554 2016-06-07 16:35:55Z lidl
+Set to build some programs without blacklistd support, like
+.Xr fingerd 8 ,
+.Xr ftpd 8 ,
+.Xr rlogind 8 ,
+.Xr rshd 8 ,
+and
+.Xr sshd 8 .
.It Va WITHOUT_BLUETOOTH
.\" from FreeBSD: head/tools/build/options/WITHOUT_BLUETOOTH 156932 2006-03-21 07:50:50Z ru
Set to not build Bluetooth related kernel modules, programs and libraries.
@@ -1062,7 +1080,7 @@ Set to not build utilities for manual pages,
.Xr manctl 8 ,
and related support files.
.It Va WITH_META_MODE
-.\" from FreeBSD: head/tools/build/options/WITH_META_MODE 301474 2016-06-05 23:14:06Z bdrewery
+.\" from FreeBSD: head/tools/build/options/WITH_META_MODE 301889 2016-06-14 16:20:25Z bdrewery
Creates
.Xr make 1
meta files when building, which can provide a reliable incremental build when
@@ -1071,9 +1089,13 @@ using
The meta file is created in the OBJDIR as
.Pa target.meta .
These meta files track the command ran, its output, and the current directory.
-When the
+The
.Xr filemon 4
-module is loaded, any files used by the commands executed will be tracked as
+module is required unless
+.Va NO_FILEMON
+is defined.
+When the module is loaded, any files used by the commands executed will be
+tracked as
dependencies for the target in its meta file.
The target will be considered out-of-date and rebuilt if any of the following
are true compared to the last build:
@@ -1101,6 +1123,9 @@ The meta files can also be useful for debugging.
The build will hide commands ran unless
.Va NO_SILENT
is defined.
+Errors will cause
+.Xr make 1
+to show some of its environment for further debugging.
.Pp
The build operates as it normally would otherwise.
This option originally invoked a different build system but that was renamed
diff --git a/share/man/man8/nanobsd.8 b/share/man/man8/nanobsd.8
index f12434f..7f4e219 100644
--- a/share/man/man8/nanobsd.8
+++ b/share/man/man8/nanobsd.8
@@ -219,7 +219,8 @@ Path to the source tree used to build the image.
.It Va NANO_KERNEL
Name of the kernel configuration file used to build the kernel.
.It Va NANO_ARCH
-Machine processor architecture to build. Defaults to output of
+Machine processor architecture to build.
+Defaults to output of
.Cm uname -p .
.It Va NANO_BOOT0CFG
Controls the options passed to
diff --git a/share/man/man9/BUS_NEW_PASS.9 b/share/man/man9/BUS_NEW_PASS.9
index 1da2f67..e647f8f 100644
--- a/share/man/man9/BUS_NEW_PASS.9
+++ b/share/man/man9/BUS_NEW_PASS.9
@@ -44,7 +44,7 @@ The
method is called on each bus device to rescan the device tree when the pass
level has been changed.
This method is responsible for invoking
-.Xr BUS_NEW_PASS 9
+.Nm
on child bus devices to propagate the rescan to child devices.
It is also responsible for reprobing any unattached child devices and
allowing drivers for the current pass to identify new children.
diff --git a/share/man/man9/EVENTHANDLER.9 b/share/man/man9/EVENTHANDLER.9
index c8f3002..ebf02e1 100644
--- a/share/man/man9/EVENTHANDLER.9
+++ b/share/man/man9/EVENTHANDLER.9
@@ -197,11 +197,11 @@ Callbacks invoked on error of application core dump.
.It Vt bpf_track
Callbacks invoked when a BPF listener attaches to/detaches from network interface.
.It Vt cpufreq_levels_changed
-Callback invoked when cpu frequence levels have changed.
+Callback invoked when cpu frequency levels have changed.
.It Vt cpufreq_post_change
-Callback invoked after cpu frequence has changed.
+Callback invoked after cpu frequency has changed.
.It Vt cpufreq_pre_change
-Callback invoked before cpu frequence has changed
+Callback invoked before cpu frequency has changed.
.It Vt dcons_poll
Callback invoked to poll for dcons changes.
.It Vt dev_clone
diff --git a/share/man/man9/SYSCALL_MODULE.9 b/share/man/man9/SYSCALL_MODULE.9
index 8fc92aa..aec57a8 100644
--- a/share/man/man9/SYSCALL_MODULE.9
+++ b/share/man/man9/SYSCALL_MODULE.9
@@ -84,7 +84,7 @@ and
library functions in libc.
The MACRO
.Fn SYSCALL_MODULE_HELPER
-includes
+includes
.Fn SYSCALL_MODULE
and much of its boilerplate code.
.Sh EXAMPLES
diff --git a/share/man/man9/bpf.9 b/share/man/man9/bpf.9
index ebf26cb..cddff70 100644
--- a/share/man/man9/bpf.9
+++ b/share/man/man9/bpf.9
@@ -256,8 +256,8 @@ Pointer to
.Pq Vt "struct ifnet *"
is passed as the first argument, interface
.Fa dlt
-follows. Last argument indicates listener is attached (1) or
-detached (0).
+follows.
+Last argument indicates listener is attached (1) or detached (0).
Note that handler is invoked with
.Nm
global lock held, which implies restriction on sleeping and calling
diff --git a/share/man/man9/counter.9 b/share/man/man9/counter.9
index a89d14d..f717b64 100644
--- a/share/man/man9/counter.9
+++ b/share/man/man9/counter.9
@@ -154,7 +154,7 @@ A read of the oid returns value obtained through
Any write to the oid zeroes it.
.It Fn SYSCTL_COUNTER_U64_ARRAY parent nbr name access ptr len descr
Declare a static
-.Xr sysctl
+.Xr sysctl
oid that would represent an array of
.Nm .
The
@@ -172,7 +172,7 @@ Any write to the oid zeroes all array elements.
.It Fn SYSCTL_ADD_COUNTER_U64_ARRAY ctx parent nbr name access ptr len descr
Create a
.Xr sysctl
-oid that would represent an array of
+oid that would represent an array of
.Nm .
The
.Fa ptr
@@ -181,9 +181,9 @@ argument should be a pointer to allocated array of
The
.Fa len
argument should specify number of elements in the array.
-A read of the oid returns len-sized array of
-.Vt uint64_t
-values obtained through
+A read of the oid returns len-sized array of
+.Vt uint64_t
+values obtained through
.Fn counter_u64_fetch .
Any write to the oid zeroes all array elements.
.El
diff --git a/share/man/man9/firmware.9 b/share/man/man9/firmware.9
index f8c8b32..d600652 100644
--- a/share/man/man9/firmware.9
+++ b/share/man/man9/firmware.9
@@ -97,7 +97,8 @@ by calling the function
.Fn firmware_get
with the
.Nm imagename
-they want as an argument. If a matching image is not already registered,
+they want as an argument.
+If a matching image is not already registered,
the firmware subsystem will try to load it using the
mechanisms specified below (typically, a kernel module
with
@@ -127,7 +128,8 @@ pointer to the image requested.
.Fn firmware_unregister
tries to unregister the firmware image
.Nm imagename
-from the system. The function is successful and returns 0
+from the system.
+The function is successful and returns 0
if there are no pending references to the image, otherwise
it does not unregister the image and returns EBUSY.
.Pp
@@ -148,7 +150,8 @@ already mounted.
On success,
.Fn firmware_get
returns a pointer to the image description and increases the reference count
-for this image. On failure, the function returns NULL.
+for this image.
+On failure, the function returns NULL.
.Pp
.Fn firmware_put
drops a reference to a firmware image.
diff --git a/share/man/man9/kqueue.9 b/share/man/man9/kqueue.9
index ff379d1..ee56358 100644
--- a/share/man/man9/kqueue.9
+++ b/share/man/man9/kqueue.9
@@ -345,12 +345,12 @@ will have
.Dv EV_ONESHOT
set so that the
.Vt knote
-will be returned and removed durning the next scan.
+will be returned and removed during the next scan.
The
.Va f_detach
function will be called when the
.Vt knote
-is deleted durning the next scan.
+is deleted during the next scan.
This function must not be used when
.Va f_isfd
is set in
diff --git a/share/man/man9/lock.9 b/share/man/man9/lock.9
index 3ac23db..db99cad 100644
--- a/share/man/man9/lock.9
+++ b/share/man/man9/lock.9
@@ -215,7 +215,8 @@ The flag allows exclusive requests to preempt the current shared request
even if the current thread owns shared locks.
This is safe since shared lock is guaranteed to not recurse, and is used
when thread is known to held unrelated shared locks, to not cause
-unnecessary starvation. An example is
+unnecessary starvation.
+An example is
.Dv vp
locking in VFS
.Xr lookup 9 ,
diff --git a/share/man/man9/locking.9 b/share/man/man9/locking.9
index 30d3b92..06428e2 100644
--- a/share/man/man9/locking.9
+++ b/share/man/man9/locking.9
@@ -335,7 +335,8 @@ running inside an interrupt thread.
.El
.Ss Interaction table
The following table shows what you can and can not do while holding
-one of the locking primitives discussed. Note that
+one of the locking primitives discussed.
+Note that
.Dq sleep
includes
.Fn sema_wait ,
diff --git a/share/man/man9/pmap.9 b/share/man/man9/pmap.9
index f7edc33..231749c 100644
--- a/share/man/man9/pmap.9
+++ b/share/man/man9/pmap.9
@@ -87,7 +87,6 @@ and it must be updated by the implementation after each relevant
.Nm
operation.
.Sh SEE ALSO
-.Xr pmap 9 ,
.Xr pmap_activate 9 ,
.Xr pmap_clear_modify 9 ,
.Xr pmap_copy 9 ,
diff --git a/share/man/man9/stack.9 b/share/man/man9/stack.9
index 85640df..06065bd 100644
--- a/share/man/man9/stack.9
+++ b/share/man/man9/stack.9
@@ -171,10 +171,10 @@ is returned if the operation is not implemented.
.Sh AUTHORS
.An -nosplit
The
-.Xr stack 9
+.Nm
function suite was created by
.An Antoine Brodin .
-.Xr stack 9
+.Nm
was extended by
.An Robert Watson
for general-purpose use outside of
diff --git a/share/man/man9/sysctl.9 b/share/man/man9/sysctl.9
index 097cc97d..6b9098d 100644
--- a/share/man/man9/sysctl.9
+++ b/share/man/man9/sysctl.9
@@ -628,7 +628,8 @@ system boot.
.It Dv CTLFLAG_NOFETCH
In case the node is marked as a tunable using the CTLFLAG_[XX]TUN,
this flag will prevent fetching the initial value from the system
-environment. Typically this flag should only be used for very early
+environment.
+Typically this flag should only be used for very early
low level system setup code, and not by common drivers and modules.
.El
.Pp
@@ -780,7 +781,8 @@ Use positive logic instead:
.Va foobar_enable .
.Pp
A temporary sysctl node OID that should not be relied upon must be designated
-as such by a leading underscore character in its name. For example:
+as such by a leading underscore character in its name.
+For example:
.Va _dirty_hack .
.Sh SEE ALSO
.Xr sysctl 3 ,
diff --git a/share/man/man9/timeout.9 b/share/man/man9/timeout.9
index ee30942..df8538e 100644
--- a/share/man/man9/timeout.9
+++ b/share/man/man9/timeout.9
@@ -268,7 +268,8 @@ then that lock must be held when this function is called.
Note that when stopping multiple callouts that use the same lock it is possible
to get multiple return's of zero and multiple calls to the
.Fa drain
-function, depending upon which CPU's the callouts are running. The
+function, depending upon which CPU's the callouts are running.
+The
.Fa drain
function itself is called from the context of the completing callout
i.e. softclock or hardclock, just like a callout itself.
@@ -813,7 +814,8 @@ and
.Fn callout_drain
functions return a value of one if the callout was still pending when it was
called, a zero if the callout could not be stopped and a negative one is it
-was either not running or haas already completed. The
+was either not running or haas already completed.
+The
.Fn timeout
function returns a
.Ft struct callout_handle
diff --git a/share/man/man9/usbdi.9 b/share/man/man9/usbdi.9
index a42626a..588c79e 100644
--- a/share/man/man9/usbdi.9
+++ b/share/man/man9/usbdi.9
@@ -157,7 +157,8 @@ available.
.Fa udev
is a pointer to "struct usb_device".
.Fa ifaces
-is an array of interface index numbers to use. See "if_index".
+is an array of interface index numbers to use.
+See "if_index".
.Fa pxfer
is a pointer to an array of USB transfer pointers that are initialized
to NULL, and then pointed to allocated USB transfers.
@@ -171,9 +172,10 @@ is the private softc pointer, which will be used to initialize
"xfer->priv_sc".
.Fa priv_mtx
is the private mutex protecting the transfer structure and the
-softc. This pointer is used to initialize "xfer->priv_mtx".
-This function returns
-zero upon success. A non-zero return value indicates failure.
+softc.
+This pointer is used to initialize "xfer->priv_mtx".
+This function returns zero upon success.
+A non-zero return value indicates failure.
.
.Pp
.
@@ -245,8 +247,8 @@ pointer.
.
The USB callback has three states.
.
-USB_ST_SETUP, USB_ST_TRANSFERRED and USB_ST_ERROR. USB_ST_SETUP is the
-initial state.
+USB_ST_SETUP, USB_ST_TRANSFERRED and USB_ST_ERROR.
+USB_ST_SETUP is the initial state.
.
After the callback has been called with this state it will always be
called back at a later stage in one of the other two states.
@@ -323,7 +325,8 @@ The SETUP packet is always pointed to by frame 0 and the
length is set by
.Fn usbd_xfer_frame_len
also if there should not be
-sent any SETUP packet! If an USB control transfer has no DATA stage,
+sent any SETUP packet!
+If an USB control transfer has no DATA stage,
then the number of frames should be set to 1.
.
Else the default number of frames is 2.
@@ -440,10 +443,12 @@ Depending on the endpoint type, this field has different meaning:
"0" use the default interrupt interval based on endpoint descriptor.
"Else" use the given value for polling rate.
.It UE_ISOCHRONOUS
-"0" use default. "Else" the value is ignored.
+"0" use default.
+"Else" the value is ignored.
.It UE_BULK
.It UE_CONTROL
-"0" no transfer pre-delay. "Else" a delay as given by this field in
+"0" no transfer pre-delay.
+"Else" a delay as given by this field in
milliseconds is inserted before the hardware is started when
"usbd_transfer_submit()" is called.
.Pp
@@ -453,14 +458,14 @@ pre-delay has elapsed!
.
.Pp
.Fa timeout
-field, if non-zero, will set the transfer timeout in milliseconds. If
-the "timeout" field is zero and the transfer type is ISOCHRONOUS a
+field, if non-zero, will set the transfer timeout in milliseconds.
+If the "timeout" field is zero and the transfer type is ISOCHRONOUS a
timeout of 250ms will be used.
.
.Pp
.Fa frames
-field sets the maximum number of frames. If zero is specified it will
-yield the following results:
+field sets the maximum number of frames.
+If zero is specified it will yield the following results:
.Bl -tag -width "UE_INTERRUPT"
.It UE_BULK
xfer->nframes = 1;
@@ -469,7 +474,8 @@ xfer->nframes = 1;
.It UE_CONTROL
xfer->nframes = 2;
.It UE_ISOCHRONOUS
-Not allowed. Will cause an error.
+Not allowed.
+Will cause an error.
.El
.
.Pp
@@ -486,26 +492,29 @@ be used when setting up the given USB transfer.
.Pp
.Fa flags
field has type "struct usb_xfer_flags" and allows one to set initial
-flags an USB transfer. Valid flags are:
+flags an USB transfer.
+Valid flags are:
.Bl -tag -width "force_short_xfer"
.It force_short_xfer
-This flag forces the last transmitted USB packet to be short. A short
-packet has a length of less than "xfer->max_packet_size", which
-derives from "wMaxPacketSize". This flag can be changed during
-operation.
+This flag forces the last transmitted USB packet to be short.
+A short packet has a length of less than "xfer->max_packet_size", which
+derives from "wMaxPacketSize".
+This flag can be changed during operation.
.It short_xfer_ok
This flag allows the received transfer length, "xfer->actlen" to be
-less than "xfer->sumlen" upon completion of a transfer. This flag can
-be changed during operation.
+less than "xfer->sumlen" upon completion of a transfer.
+This flag can be changed during operation.
.It short_frames_ok
-This flag allows the reception of multiple short USB frames. This flag
+This flag allows the reception of multiple short USB frames.
+This flag
only has effect for BULK and INTERRUPT endpoints and if the number of
-frames received is greater than 1. This flag can be changed during
-operation.
+frames received is greater than 1.
+This flag can be changed during operation.
.It pipe_bof
This flag causes a failing USB transfer to remain first in the PIPE
queue except in the case of "xfer->error" equal to
-"USB_ERR_CANCELLED". No other USB transfers in the affected PIPE queue
+"USB_ERR_CANCELLED".
+No other USB transfers in the affected PIPE queue
will be started until either:
.Bl -tag -width "X"
.It 1
@@ -569,8 +578,8 @@ This flag can be changed during operation.
.
.
.It no_pipe_ok
-Setting this flag causes the USB_ERR_NO_PIPE error to be ignored. This
-flag can not be changed during operation.
+Setting this flag causes the USB_ERR_NO_PIPE error to be ignored.
+This flag can not be changed during operation.
.
.
.It stall_pipe
@@ -614,7 +623,8 @@ request structure.
.
.Pp
.Fa callback
-pointer sets the USB callback. This field is mandatory.
+pointer sets the USB callback.
+This field is mandatory.
.
.
.Sh USB LINUX COMPAT LAYER
@@ -635,7 +645,8 @@ module complies with the USB 2.0 standard.
The
.Nm usb
module has been inspired by the NetBSD USB stack initially written by
-Lennart Augustsson. The
+Lennart Augustsson.
+The
.Nm usb
module was written by
.An Hans Petter Selasky Aq Mt hselasky@FreeBSD.org .
diff --git a/share/man/man9/vn_fullpath.9 b/share/man/man9/vn_fullpath.9
index 50c35c9..f961fbb 100644
--- a/share/man/man9/vn_fullpath.9
+++ b/share/man/man9/vn_fullpath.9
@@ -73,7 +73,8 @@ The thread performing the call; this pointer will be dereferenced to find
the process and its file descriptor structure, in order to identify the
root vnode to use.
.It Fa vp
-The vnode to search for. No need to be locked by the caller.
+The vnode to search for.
+No need to be locked by the caller.
.It Fa retbuf
Pointer to a
.Vt "char *"
diff --git a/share/man/man9/zone.9 b/share/man/man9/zone.9
index 5047107..69d1f20 100644
--- a/share/man/man9/zone.9
+++ b/share/man/man9/zone.9
@@ -320,8 +320,10 @@ The
.Fn uma_zone_set_maxaction
function sets a function that will be called when the given zone becomes full
and fails to allocate an item.
-The function will be called with the zone locked. Also, the function
-that called the allocation function may have held additional locks. Therefore,
+The function will be called with the zone locked.
+Also, the function
+that called the allocation function may have held additional locks.
+Therefore,
this function should do very little work (similar to a signal handler).
.Pp
The
diff --git a/share/misc/committers-ports.dot b/share/misc/committers-ports.dot
index fd425b5..df62cd3 100644
--- a/share/misc/committers-ports.dot
+++ b/share/misc/committers-ports.dot
@@ -226,6 +226,7 @@ tota [label="TAKATSU Tomonari\ntota@FreeBSD.org\n2009/03/30"]
trasz [label="Edward Tomasz Napierala\ntrasz@FreeBSD.org\n2007/04/12"]
trhodes [label="Tom Rhodes\ntrhodes@FreeBSD.org\n2004/07/06"]
trociny [label="Mikolaj Golub\ntrociny@FreeBSD.org\n2013/10/17"]
+tz [label="Torsten Zuehlsdorff\ntz@FreeBSD.org\n2016/06/04"]
uqs [label="Ulrich Spoerlein\nuqs@FreeBSD.org\n2012/01/19"]
vd [label="Vasil Dimov\nvd@FreeBSD.org\n2006/01/19"]
vg [label="Veniamin Gvozdikov\nvg@FreeBSD.org\n2013/06/11"]
@@ -413,6 +414,8 @@ jadawin -> wen
joerg -> netchild
+junovitch -> tz
+
knu -> daichi
knu -> maho
knu -> nobutaka
@@ -530,6 +533,8 @@ pgollucci -> swills
philip -> koitsu
+pi -> tz
+
rafan -> chinsan
rakuco -> alonso
@@ -573,6 +578,7 @@ swills -> milki
swills -> pclin
swills -> robak
swills -> rpaulo
+swills -> tz
swills -> xmj
tabthorpe -> ashish
diff --git a/share/misc/committers-src.dot b/share/misc/committers-src.dot
index 1656e80..5345bb3 100644
--- a/share/misc/committers-src.dot
+++ b/share/misc/committers-src.dot
@@ -244,7 +244,7 @@ mp [label="Mark Peek\nmp@FreeBSD.org\n2001/07/27"]
mr [label="Michael Reifenberger\nmr@FreeBSD.org\n2001/09/30"]
neel [label="Neel Natu\nneel@FreeBSD.org\n2009/09/20"]
netchild [label="Alexander Leidinger\nnetchild@FreeBSD.org\n2005/03/31"]
-ngie [label="Garrett Cooper\nngie@FreeBSD.org\n2014/07/27"]
+ngie [label="Ngie Cooper\nngie@FreeBSD.org\n2014/07/27"]
nork [label="Norikatsu Shigemura\nnork@FreeBSD.org\n2009/06/09"]
np [label="Navdeep Parhar\nnp@FreeBSD.org\n2009/06/05"]
nwhitehorn [label="Nathan Whitehorn\nnwhitehorn@FreeBSD.org\n2008/07/03"]
diff --git a/share/mk/bsd.crunchgen.mk b/share/mk/bsd.crunchgen.mk
index 435dfeb..2c93526 100644
--- a/share/mk/bsd.crunchgen.mk
+++ b/share/mk/bsd.crunchgen.mk
@@ -130,7 +130,7 @@ ${PROG}: ${OUTPUTS} objs .META
objs: ${OUTMK} .META
${CRUNCHENV} MAKEOBJDIRPREFIX=${CRUNCHOBJS} \
- ${MAKE} -f ${OUTMK} objs
+ ${MAKE} -f ${OUTMK} BUILD_TOOLS_META=.NOMETA_CMP objs
# <sigh> Someone should replace the bin/csh and bin/sh build-tools with
# shell scripts so we can remove this nonsense.
diff --git a/share/mk/bsd.init.mk b/share/mk/bsd.init.mk
index d00b9e5..01d5c47 100644
--- a/share/mk/bsd.init.mk
+++ b/share/mk/bsd.init.mk
@@ -28,4 +28,14 @@ _SKIP_BUILD = not building at level 0
.warning ${_SKIP_BUILD}
.endif
+.if ${MK_META_MODE} == "yes"
+.if !exists(/dev/filemon) && \
+ ${UPDATE_DEPENDFILE:Uyes:tl} != "no" && !defined(NO_FILEMON) && \
+ !make(showconfig)
+.warning The filemon module (/dev/filemon) is not loaded.
+.warning META_MODE is less useful for incremental builds without filemon.
+.warning 'kldload filemon' or pass -DNO_FILEMON to suppress this warning.
+.endif
+.endif # ${MK_META_MODE} == "yes"
+
.endif # !target(__<bsd.init.mk>__)
diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
index 971577c..0b7bb02 100644
--- a/share/mk/bsd.lib.mk
+++ b/share/mk/bsd.lib.mk
@@ -244,7 +244,7 @@ CLEANFILES+= ${SHLIB_LINK}
${SHLIB_NAME_FULL}: ${SOBJS}
@${ECHO} building shared library ${SHLIB_NAME}
@rm -f ${SHLIB_NAME} ${SHLIB_LINK}
-.if defined(SHLIB_LINK) && !commands(${SHLIB_LINK:R}.ld)
+.if defined(SHLIB_LINK) && !commands(${SHLIB_LINK:R}.ld) && ${MK_DEBUG_FILES} == "no"
@${INSTALL_SYMLINK} ${TAG_ARGS:D${TAG_ARGS},development} ${SHLIB_NAME} ${SHLIB_LINK}
.endif
${_LD:N${CCACHE_BIN}} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \
@@ -259,6 +259,9 @@ CLEANFILES+= ${SHLIB_NAME_FULL} ${SHLIB_NAME}.debug
${SHLIB_NAME}: ${SHLIB_NAME_FULL} ${SHLIB_NAME}.debug
${OBJCOPY} --strip-debug --add-gnu-debuglink=${SHLIB_NAME}.debug \
${SHLIB_NAME_FULL} ${.TARGET}
+.if defined(SHLIB_LINK) && !commands(${SHLIB_LINK:R}.ld)
+ @${INSTALL_SYMLINK} ${TAG_ARGS:D${TAG_ARGS},development} ${SHLIB_NAME} ${SHLIB_LINK}
+.endif
${SHLIB_NAME}.debug: ${SHLIB_NAME_FULL}
${OBJCOPY} --only-keep-debug ${SHLIB_NAME_FULL} ${.TARGET}
diff --git a/share/mk/local.sys.mk b/share/mk/local.sys.mk
index e3d212c..73fe5f5 100644
--- a/share/mk/local.sys.mk
+++ b/share/mk/local.sys.mk
@@ -1,6 +1,18 @@
# $FreeBSD$
-.if ${MK_DIRDEPS_BUILD} == "yes"
+.if ${MK_DIRDEPS_BUILD} == "yes" || ${MK_META_MODE} == "yes"
+
+# Not in the below list as it may make sense for non-meta mode
+# eventually. meta.sys.mk (DIRDEPS_BUILD) also already adds these in.
+.if ${MK_DIRDEPS_BUILD} == "no" && ${MK_META_MODE} == "yes"
+MAKE_PRINT_VAR_ON_ERROR += \
+ .ERROR_TARGET \
+ .ERROR_META_FILE \
+ .MAKE.LEVEL \
+ MAKEFILE \
+ .MAKE.MODE
+.endif
+
MAKE_PRINT_VAR_ON_ERROR+= \
.CURDIR \
.MAKE \
@@ -12,7 +24,7 @@ MAKE_PRINT_VAR_ON_ERROR+= \
MACHINE_ARCH \
MAKEOBJDIRPREFIX \
MAKESYSPATH \
- MAKE_VERSION\
+ MAKE_VERSION \
PATH \
SRCTOP \
OBJTOP \
diff --git a/share/mk/sys.mk b/share/mk/sys.mk
index 4a174f8..cccc543 100644
--- a/share/mk/sys.mk
+++ b/share/mk/sys.mk
@@ -42,9 +42,14 @@ __ENV_ONLY_OPTIONS:= \
.include <bsd.mkopt.mk>
+# Disable MK_META_MODE with make -B
+.if ${MK_META_MODE} == "yes" && defined(.MAKEFLAGS) && ${.MAKEFLAGS:M-B}
+MK_META_MODE= no
+.endif
+
.if ${MK_DIRDEPS_BUILD} == "yes"
.sinclude <meta.sys.mk>
-.elif ${MK_META_MODE} == "yes" && defined(.MAKEFLAGS) && ${.MAKEFLAGS:M-B} == ""
+.elif ${MK_META_MODE} == "yes"
# verbose will show .MAKE.META.PREFIX for each target.
META_MODE+= meta verbose
.if !defined(NO_META_MISSING)
@@ -55,9 +60,6 @@ META_MODE+= missing-meta=yes
META_MODE+= silent=yes
.endif
.if !exists(/dev/filemon)
-.if ${UPDATE_DEPENDFILE:Uyes:tl} != "no" && !defined(NO_FILEMON)
-.error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded.
-.endif
META_MODE+= nofilemon
.endif
# Require filemon data with bmake
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index 73f1250..c418532 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -386,6 +386,7 @@ static struct mtx pv_chunks_mutex;
static struct rwlock pv_list_locks[NPV_LIST_LOCKS];
static u_long pv_invl_gen[NPV_LIST_LOCKS];
static struct md_page *pv_table;
+static struct md_page pv_dummy;
/*
* All those kernel PT submaps that BSD is so fond of
@@ -1264,6 +1265,7 @@ pmap_init(void)
M_WAITOK | M_ZERO);
for (i = 0; i < pv_npg; i++)
TAILQ_INIT(&pv_table[i].pv_list);
+ TAILQ_INIT(&pv_dummy.pv_list);
pmap_initialized = 1;
for (i = 0; i < PMAP_PREINIT_MAPPING_COUNT; i++) {
@@ -3920,11 +3922,10 @@ pmap_remove_all(vm_page_t m)
("pmap_remove_all: page %p is not managed", m));
SLIST_INIT(&free);
lock = VM_PAGE_TO_PV_LIST_LOCK(m);
- pvh = pa_to_pvh(VM_PAGE_TO_PHYS(m));
+ pvh = (m->flags & PG_FICTITIOUS) != 0 ? &pv_dummy :
+ pa_to_pvh(VM_PAGE_TO_PHYS(m));
retry:
rw_wlock(lock);
- if ((m->flags & PG_FICTITIOUS) != 0)
- goto small_mappings;
while ((pv = TAILQ_FIRST(&pvh->pv_list)) != NULL) {
pmap = PV_PMAP(pv);
if (!PMAP_TRYLOCK(pmap)) {
@@ -3943,7 +3944,6 @@ retry:
(void)pmap_demote_pde_locked(pmap, pde, va, &lock);
PMAP_UNLOCK(pmap);
}
-small_mappings:
while ((pv = TAILQ_FIRST(&m->md.pv_list)) != NULL) {
pmap = PV_PMAP(pv);
if (!PMAP_TRYLOCK(pmap)) {
@@ -5743,11 +5743,10 @@ pmap_remove_write(vm_page_t m)
if (!vm_page_xbusied(m) && (m->aflags & PGA_WRITEABLE) == 0)
return;
lock = VM_PAGE_TO_PV_LIST_LOCK(m);
- pvh = pa_to_pvh(VM_PAGE_TO_PHYS(m));
+ pvh = (m->flags & PG_FICTITIOUS) != 0 ? &pv_dummy :
+ pa_to_pvh(VM_PAGE_TO_PHYS(m));
retry_pv_loop:
rw_wlock(lock);
- if ((m->flags & PG_FICTITIOUS) != 0)
- goto small_mappings;
TAILQ_FOREACH_SAFE(pv, &pvh->pv_list, pv_next, next_pv) {
pmap = PV_PMAP(pv);
if (!PMAP_TRYLOCK(pmap)) {
@@ -5771,7 +5770,6 @@ retry_pv_loop:
lock, VM_PAGE_TO_PV_LIST_LOCK(m), m));
PMAP_UNLOCK(pmap);
}
-small_mappings:
TAILQ_FOREACH(pv, &m->md.pv_list, pv_next) {
pmap = PV_PMAP(pv);
if (!PMAP_TRYLOCK(pmap)) {
@@ -5877,12 +5875,11 @@ pmap_ts_referenced(vm_page_t m)
cleared = 0;
pa = VM_PAGE_TO_PHYS(m);
lock = PHYS_TO_PV_LIST_LOCK(pa);
- pvh = pa_to_pvh(pa);
+ pvh = (m->flags & PG_FICTITIOUS) != 0 ? &pv_dummy : pa_to_pvh(pa);
rw_wlock(lock);
retry:
not_cleared = 0;
- if ((m->flags & PG_FICTITIOUS) != 0 ||
- (pvf = TAILQ_FIRST(&pvh->pv_list)) == NULL)
+ if ((pvf = TAILQ_FIRST(&pvh->pv_list)) == NULL)
goto small_mappings;
pv = pvf;
do {
@@ -6194,12 +6191,11 @@ pmap_clear_modify(vm_page_t m)
*/
if ((m->aflags & PGA_WRITEABLE) == 0)
return;
- pvh = pa_to_pvh(VM_PAGE_TO_PHYS(m));
+ pvh = (m->flags & PG_FICTITIOUS) != 0 ? &pv_dummy :
+ pa_to_pvh(VM_PAGE_TO_PHYS(m));
lock = VM_PAGE_TO_PV_LIST_LOCK(m);
rw_wlock(lock);
restart:
- if ((m->flags & PG_FICTITIOUS) != 0)
- goto small_mappings;
TAILQ_FOREACH_SAFE(pv, &pvh->pv_list, pv_next, next_pv) {
pmap = PV_PMAP(pv);
if (!PMAP_TRYLOCK(pmap)) {
@@ -6243,7 +6239,6 @@ restart:
}
PMAP_UNLOCK(pmap);
}
-small_mappings:
TAILQ_FOREACH(pv, &m->md.pv_list, pv_next) {
pmap = PV_PMAP(pv);
if (!PMAP_TRYLOCK(pmap)) {
diff --git a/sys/arm/arm/cpufunc.c b/sys/arm/arm/cpufunc.c
index b2f9982..9a848f5 100644
--- a/sys/arm/arm/cpufunc.c
+++ b/sys/arm/arm/cpufunc.c
@@ -761,25 +761,19 @@ set_cpufuncs()
}
#endif /* CPU_ARM1176 */
#if defined(CPU_CORTEXA) || defined(CPU_KRAIT)
- if (cputype == CPU_ID_CORTEXA5 ||
- cputype == CPU_ID_CORTEXA7 ||
- cputype == CPU_ID_CORTEXA8R1 ||
- cputype == CPU_ID_CORTEXA8R2 ||
- cputype == CPU_ID_CORTEXA8R3 ||
- cputype == CPU_ID_CORTEXA9R1 ||
- cputype == CPU_ID_CORTEXA9R2 ||
- cputype == CPU_ID_CORTEXA9R3 ||
- cputype == CPU_ID_CORTEXA9R4 ||
- cputype == CPU_ID_CORTEXA12R0 ||
- cputype == CPU_ID_CORTEXA15R0 ||
- cputype == CPU_ID_CORTEXA15R1 ||
- cputype == CPU_ID_CORTEXA15R2 ||
- cputype == CPU_ID_CORTEXA15R3 ||
- cputype == CPU_ID_KRAIT300R0 ||
- cputype == CPU_ID_KRAIT300R1 ) {
+ switch(cputype & CPU_ID_SCHEME_MASK) {
+ case CPU_ID_CORTEXA5:
+ case CPU_ID_CORTEXA7:
+ case CPU_ID_CORTEXA8:
+ case CPU_ID_CORTEXA9:
+ case CPU_ID_CORTEXA12:
+ case CPU_ID_CORTEXA15:
+ case CPU_ID_KRAIT300:
cpufuncs = cortexa_cpufuncs;
get_cachetype_cp15();
goto out;
+ default:
+ break;
}
#endif /* CPU_CORTEXA */
diff --git a/sys/arm/arm/genassym.c b/sys/arm/arm/genassym.c
index 944eff8..34df028 100644
--- a/sys/arm/arm/genassym.c
+++ b/sys/arm/arm/genassym.c
@@ -101,8 +101,10 @@ ASSYM(TD_PROC, offsetof(struct thread, td_proc));
ASSYM(TD_MD, offsetof(struct thread, td_md));
ASSYM(TD_LOCK, offsetof(struct thread, td_lock));
ASSYM(MD_TP, offsetof(struct mdthread, md_tp));
+#if __ARM_ARCH < 6
ASSYM(MD_RAS_START, offsetof(struct mdthread, md_ras_start));
ASSYM(MD_RAS_END, offsetof(struct mdthread, md_ras_end));
+#endif
ASSYM(TF_SPSR, offsetof(struct trapframe, tf_spsr));
ASSYM(TF_R0, offsetof(struct trapframe, tf_r0));
diff --git a/sys/arm/arm/mp_machdep.c b/sys/arm/arm/mp_machdep.c
index 24b5679..312ee58 100644
--- a/sys/arm/arm/mp_machdep.c
+++ b/sys/arm/arm/mp_machdep.c
@@ -199,6 +199,9 @@ init_secondary(int cpu)
vfp_init();
#endif
+ /* Configure the interrupt controller */
+ intr_pic_init_secondary();
+
mtx_lock_spin(&ap_boot_mtx);
atomic_add_rel_32(&smp_cpus, 1);
@@ -237,7 +240,6 @@ init_secondary(int cpu)
cpu_initclocks_ap();
CTR0(KTR_SMP, "go into scheduler");
- intr_pic_init_secondary();
/* Enter the scheduler */
sched_throw(NULL);
diff --git a/sys/arm/include/_types.h b/sys/arm/include/_types.h
index 267ea83..b627963 100644
--- a/sys/arm/include/_types.h
+++ b/sys/arm/include/_types.h
@@ -43,10 +43,6 @@
#error this file needs sys/cdefs.h as a prerequisite
#endif
-#if __ARM_ARCH >= 6
-#define __NO_STRICT_ALIGNMENT
-#endif
-
/*
* Basic types upon which most other types are built.
*/
diff --git a/sys/arm/include/armreg.h b/sys/arm/include/armreg.h
index 411517b..b509d7d 100644
--- a/sys/arm/include/armreg.h
+++ b/sys/arm/include/armreg.h
@@ -72,10 +72,16 @@
#define CPU_ID_IMPLEMENTOR_MASK 0xff000000
#define CPU_ID_ARM_LTD 0x41000000 /* 'A' */
#define CPU_ID_DEC 0x44000000 /* 'D' */
-#define CPU_ID_INTEL 0x69000000 /* 'i' */
+#define CPU_ID_MOTOROLA 0x4D000000 /* 'M' */
+#define CPU_ID_QUALCOM 0x51000000 /* 'Q' */
#define CPU_ID_TI 0x54000000 /* 'T' */
+#define CPU_ID_MARVELL 0x56000000 /* 'V' */
+#define CPU_ID_INTEL 0x69000000 /* 'i' */
#define CPU_ID_FARADAY 0x66000000 /* 'f' */
+#define CPU_ID_VARIANT_SHIFT 20
+#define CPU_ID_VARIANT_MASK 0x00f00000
+
/* How to decide what format the CPUID is in. */
#define CPU_ID_ISOLD(x) (((x) & 0x0000f000) == 0x00000000)
#define CPU_ID_IS7(x) (((x) & 0x0000f000) == 0x00007000)
@@ -92,7 +98,6 @@
#define CPU_ID_ARCH_V5TEJ 0x00060000
#define CPU_ID_ARCH_V6 0x00070000
#define CPU_ID_CPUID_SCHEME 0x000f0000
-#define CPU_ID_VARIANT_MASK 0x00f00000
/* Next three nybbles are part number */
#define CPU_ID_PARTNO_MASK 0x0000fff0
@@ -123,22 +128,35 @@
#define CPU_ID_ARM1136JS 0x4107b360
#define CPU_ID_ARM1136JSR1 0x4117b360
#define CPU_ID_ARM1176JZS 0x410fb760
-#define CPU_ID_CORTEXA5 0x410fc050
-#define CPU_ID_CORTEXA7 0x410fc070
-#define CPU_ID_CORTEXA8R1 0x411fc080
-#define CPU_ID_CORTEXA8R2 0x412fc080
-#define CPU_ID_CORTEXA8R3 0x413fc080
-#define CPU_ID_CORTEXA9R1 0x411fc090
-#define CPU_ID_CORTEXA9R2 0x412fc090
-#define CPU_ID_CORTEXA9R3 0x413fc090
-#define CPU_ID_CORTEXA9R4 0x414fc090
-#define CPU_ID_CORTEXA12R0 0x410fc0d0
-#define CPU_ID_CORTEXA15R0 0x410fc0f0
-#define CPU_ID_CORTEXA15R1 0x411fc0f0
-#define CPU_ID_CORTEXA15R2 0x412fc0f0
-#define CPU_ID_CORTEXA15R3 0x413fc0f0
-#define CPU_ID_KRAIT300R0 0x510f06f0 /* Snapdragon S4 Pro/APQ8064 */
-#define CPU_ID_KRAIT300R1 0x511f06f0
+
+/* CPUs that follow the CPUID scheme */
+#define CPU_ID_SCHEME_MASK \
+ (CPU_ID_IMPLEMENTOR_MASK | CPU_ID_ARCH_MASK | CPU_ID_PARTNO_MASK)
+
+#define CPU_ID_CORTEXA5 (CPU_ID_ARM_LTD | CPU_ID_CPUID_SCHEME | 0xc050)
+#define CPU_ID_CORTEXA7 (CPU_ID_ARM_LTD | CPU_ID_CPUID_SCHEME | 0xc070)
+#define CPU_ID_CORTEXA8 (CPU_ID_ARM_LTD | CPU_ID_CPUID_SCHEME | 0xc080)
+#define CPU_ID_CORTEXA8R1 (CPU_ID_CORTEXA8 | (1 << CPU_ID_VARIANT_SHIFT))
+#define CPU_ID_CORTEXA8R2 (CPU_ID_CORTEXA8 | (2 << CPU_ID_VARIANT_SHIFT))
+#define CPU_ID_CORTEXA8R3 (CPU_ID_CORTEXA8 | (3 << CPU_ID_VARIANT_SHIFT))
+#define CPU_ID_CORTEXA9 (CPU_ID_ARM_LTD | CPU_ID_CPUID_SCHEME | 0xc090)
+#define CPU_ID_CORTEXA9R1 (CPU_ID_CORTEXA9 | (1 << CPU_ID_VARIANT_SHIFT))
+#define CPU_ID_CORTEXA9R2 (CPU_ID_CORTEXA9 | (2 << CPU_ID_VARIANT_SHIFT))
+#define CPU_ID_CORTEXA9R3 (CPU_ID_CORTEXA9 | (3 << CPU_ID_VARIANT_SHIFT))
+#define CPU_ID_CORTEXA9R4 (CPU_ID_CORTEXA9 | (4 << CPU_ID_VARIANT_SHIFT))
+/* XXX: Cortx-A12 is the old name for this part, it has been renamed the A17 */
+#define CPU_ID_CORTEXA12 (CPU_ID_ARM_LTD | CPU_ID_CPUID_SCHEME | 0xc0d0)
+#define CPU_ID_CORTEXA12R0 (CPU_ID_CORTEXA12 | (0 << CPU_ID_VARIANT_SHIFT))
+#define CPU_ID_CORTEXA15 (CPU_ID_ARM_LTD | CPU_ID_CPUID_SCHEME | 0xc0f0)
+#define CPU_ID_CORTEXA15R0 (CPU_ID_CORTEXA15 | (0 << CPU_ID_VARIANT_SHIFT))
+#define CPU_ID_CORTEXA15R1 (CPU_ID_CORTEXA15 | (1 << CPU_ID_VARIANT_SHIFT))
+#define CPU_ID_CORTEXA15R2 (CPU_ID_CORTEXA15 | (2 << CPU_ID_VARIANT_SHIFT))
+#define CPU_ID_CORTEXA15R3 (CPU_ID_CORTEXA15 | (3 << CPU_ID_VARIANT_SHIFT))
+
+#define CPU_ID_KRAIT300 (CPU_ID_QUALCOM | CPU_ID_CPUID_SCHEME | 0x06f0)
+/* Snapdragon S4 Pro/APQ8064 */
+#define CPU_ID_KRAIT300R0 (CPU_ID_KRAIT300 | (0 << CPU_ID_VARIANT_SHIFT))
+#define CPU_ID_KRAIT300R1 (CPU_ID_KRAIT300 | (1 << CPU_ID_VARIANT_SHIFT))
#define CPU_ID_TI925T 0x54029250
#define CPU_ID_MV88FR131 0x56251310 /* Marvell Feroceon 88FR131 Core */
diff --git a/sys/arm/include/proc.h b/sys/arm/include/proc.h
index 090aaba..5d42d07 100644
--- a/sys/arm/include/proc.h
+++ b/sys/arm/include/proc.h
@@ -54,8 +54,10 @@ struct mdthread {
int md_ptrace_instr_alt;
int md_ptrace_addr_alt;
register_t md_tp;
+#if __ARM_ARCH < 6
void *md_ras_start;
void *md_ras_end;
+#endif
};
struct mdproc {
diff --git a/sys/arm64/conf/GENERIC b/sys/arm64/conf/GENERIC
index 9300e77..d08c2db 100644
--- a/sys/arm64/conf/GENERIC
+++ b/sys/arm64/conf/GENERIC
@@ -70,6 +70,7 @@ options RACCT # Resource accounting framework
options RACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default
options RCTL # Resource limits
options SMP
+options INTRNG
# Debugging support. Always need this:
options KDB # Enable kernel debugger support.
diff --git a/sys/arm64/conf/GENERIC-INTRNG b/sys/arm64/conf/GENERIC-INTRNG
deleted file mode 100644
index 9cab02b..0000000
--- a/sys/arm64/conf/GENERIC-INTRNG
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# GENERIC-INTRNG -- intrng testing kernel for FreeBSD/arm64
-#
-# This config adds intrng support for testing, and to ensure intrng is not
-# broken before switching to it. The config is expected to be removed soon
-# when intrng becomes the default on arm64.
-#
-# $FreeBSD$
-#
-
-include GENERIC
-
-ident GENERIC-INTRNG
-
-options INTRNG
diff --git a/sys/boot/efi/Makefile.inc b/sys/boot/efi/Makefile.inc
index 9ed0cda..9d457f4 100644
--- a/sys/boot/efi/Makefile.inc
+++ b/sys/boot/efi/Makefile.inc
@@ -18,4 +18,8 @@ CFLAGS+= -mno-red-zone
CFLAGS+= -mno-aes
.endif
+.if ${MACHINE_CPUARCH} == "aarch64"
+CFLAGS+= -fshort-wchar
+.endif
+
.include "../Makefile.inc"
diff --git a/sys/boot/efi/libefi/efi_console.c b/sys/boot/efi/libefi/efi_console.c
index 68c9a6b..838becc 100644
--- a/sys/boot/efi/libefi/efi_console.c
+++ b/sys/boot/efi/libefi/efi_console.c
@@ -111,9 +111,9 @@ efi_cons_probe(struct console *cp)
static int
efi_cons_init(int arg)
{
+#ifdef TERM_EMU
conout->SetAttribute(conout, EFI_TEXT_ATTR(DEFAULT_FGCOLOR,
DEFAULT_BGCOLOR));
-#ifdef TERM_EMU
end_term();
get_pos(&curx, &cury);
curs_move(&curx, &cury, curx, cury);
@@ -139,8 +139,7 @@ efi_cons_rawputchar(int c)
#ifndef TERM_EMU
if (c == '\n')
efi_cons_efiputchar('\r');
- else
- efi_cons_efiputchar(c);
+ efi_cons_efiputchar(c);
#else
switch (c) {
case '\r':
@@ -178,6 +177,7 @@ efi_cons_rawputchar(int c)
}
}
+#ifdef TERM_EMU
/* Gracefully exit ESC-sequence processing in case of misunderstanding. */
static void
bail_out(int c)
@@ -412,6 +412,12 @@ efi_term_emu(int c)
break;
}
}
+#else
+void
+HO(void)
+{
+}
+#endif
void
efi_cons_putchar(int c)
diff --git a/sys/boot/efi/libefi/efipart.c b/sys/boot/efi/libefi/efipart.c
index 7e53643..87e38de 100644
--- a/sys/boot/efi/libefi/efipart.c
+++ b/sys/boot/efi/libefi/efipart.c
@@ -119,8 +119,11 @@ efipart_init(void)
(void**)&blkio);
if (EFI_ERROR(status))
continue;
- if (!blkio->Media->LogicalPartition)
+ if (!blkio->Media->LogicalPartition) {
+ printf("%s%d isn't a logical partition, skipping\n",
+ efipart_dev.dv_name, n);
continue;
+ }
/*
* If we come across a logical partition of subtype CDROM
diff --git a/sys/boot/fdt/dts/arm/pcduino3b.dts b/sys/boot/fdt/dts/arm/pcduino3b.dts
new file mode 100644
index 0000000..9072baa
--- /dev/null
+++ b/sys/boot/fdt/dts/arm/pcduino3b.dts
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2016 Emmanuel Vadot <manu@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include "sun7i-a20-pcduino3.dts"
+#include "sun7i-a20-hdmi.dtsi"
+#include "xpowers-axp209.dtsi"
+
+/ {
+ soc@01c00000 {
+ hdmi@01c16000 {
+ status = "okay";
+ };
+
+ hdmiaudio {
+ status = "okay";
+ };
+ };
+};
+
+&gmac {
+ pinctrl-0 = <&gmac_pins_rgmii_a>;
+ phy-mode = "rgmii";
+};
diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c
index 2e75500..72ced86 100644
--- a/sys/cam/ata/ata_da.c
+++ b/sys/cam/ata/ata_da.c
@@ -1672,6 +1672,7 @@ adaregister(struct cam_periph *periph, void *arg)
if (cam_iosched_init(&softc->cam_iosched, periph) != 0) {
printf("adaregister: Unable to probe new device. "
"Unable to allocate iosched memory\n");
+ free(softc, M_DEVBUF);
return(CAM_REQ_CMP_ERR);
}
diff --git a/sys/cam/cam_ccb.h b/sys/cam/cam_ccb.h
index 8362f6c..1745644 100644
--- a/sys/cam/cam_ccb.h
+++ b/sys/cam/cam_ccb.h
@@ -41,6 +41,7 @@
#include <cam/cam_debug.h>
#include <cam/scsi/scsi_all.h>
#include <cam/ata/ata_all.h>
+#include <cam/nvme/nvme_all.h>
/* General allocation length definitions for CCB structures */
#define IOCDBLEN CAM_MAX_CDBLEN /* Space for CDB bytes/pointer */
@@ -204,6 +205,12 @@ typedef enum {
XPT_SMP_IO = 0x1b | XPT_FC_DEV_QUEUED,
/* Serial Management Protocol */
+ XPT_NVME_IO = 0x1c | XPT_FC_DEV_QUEUED,
+ /* Execiute the requestred NVMe I/O operation */
+
+ XPT_MMCSD_IO = 0x1d | XPT_FC_DEV_QUEUED,
+ /* Placeholder for MMC / SD / SDIO I/O stuff */
+
XPT_SCAN_TGT = 0x1E | XPT_FC_QUEUED | XPT_FC_USER_CCB
| XPT_FC_XPT_ONLY,
/* Scan Target */
@@ -259,6 +266,7 @@ typedef enum {
PROTO_ATAPI, /* AT Attachment Packetized Interface */
PROTO_SATAPM, /* SATA Port Multiplier */
PROTO_SEMB, /* SATA Enclosure Management Bridge */
+ PROTO_NVME, /* NVME */
} cam_proto;
typedef enum {
@@ -274,6 +282,7 @@ typedef enum {
XPORT_SATA, /* Serial AT Attachment */
XPORT_ISCSI, /* iSCSI */
XPORT_SRP, /* SCSI RDMA Protocol */
+ XPORT_NVME, /* NVMe over PCIe */
} cam_xport;
#define XPORT_IS_ATA(t) ((t) == XPORT_ATA || (t) == XPORT_SATA)
@@ -350,6 +359,8 @@ struct ccb_getdev {
u_int8_t serial_num[252];
u_int8_t inq_flags;
u_int8_t serial_num_len;
+ const struct nvme_controller_data *nvme_cdata;
+ const struct nvme_namespace_data *nvme_data;
};
/* Device Statistics CCB */
@@ -610,6 +621,11 @@ struct ccb_pathinq_settings_fc {
struct ccb_pathinq_settings_sas {
u_int32_t bitrate; /* Mbps */
};
+
+struct ccb_pathinq_settings_nvme {
+ uint16_t nsid; /* Namespace ID for this path */
+};
+
#define PATHINQ_SETTINGS_SIZE 128
struct ccb_pathinq {
@@ -640,6 +656,7 @@ struct ccb_pathinq {
struct ccb_pathinq_settings_spi spi;
struct ccb_pathinq_settings_fc fc;
struct ccb_pathinq_settings_sas sas;
+ struct ccb_pathinq_settings_nvme nvme;
char ccb_pathinq_settings_opaque[PATHINQ_SETTINGS_SIZE];
} xport_specific;
u_int maxio; /* Max supported I/O size, in bytes. */
@@ -777,6 +794,19 @@ struct ccb_relsim {
};
/*
+ * NVMe I/O Request CCB used for the XPT_NVME_IO function code.
+ */
+struct ccb_nvmeio {
+ struct ccb_hdr ccb_h;
+ union ccb *next_ccb; /* Ptr for next CCB for action */
+ struct nvme_command cmd; /* NVME command, per NVME standard */
+ struct nvme_completion cpl; /* NVME completion, per NVME standard */
+ uint8_t *data_ptr; /* Ptr to the data buf/SG list */
+ uint32_t dxfer_len; /* Data transfer length */
+ uint32_t resid; /* Transfer residual length: 2's comp unused ?*/
+};
+
+/*
* Definitions for the asynchronous callback CCB fields.
*/
typedef enum {
@@ -953,6 +983,18 @@ struct ccb_trans_settings_sata {
#define CTS_SATA_CAPS_D_APST 0x00020000
};
+struct ccb_trans_settings_nvme
+{
+ u_int valid; /* Which fields to honor */
+#define CTS_NVME_VALID_SPEC 0x01
+#define CTS_NVME_VALID_CAPS 0x02
+ u_int spec_major; /* Major version of spec supported */
+ u_int spec_minor; /* Minor verison of spec supported */
+ u_int spec_tiny; /* Tiny version of spec supported */
+ u_int max_xfer; /* Max transfer size (0 -> unlimited */
+ u_int caps;
+};
+
/* Get/Set transfer rate/width/disconnection/tag queueing settings */
struct ccb_trans_settings {
struct ccb_hdr ccb_h;
@@ -965,6 +1007,7 @@ struct ccb_trans_settings {
u_int valid; /* Which fields to honor */
struct ccb_trans_settings_ata ata;
struct ccb_trans_settings_scsi scsi;
+ struct ccb_trans_settings_nvme nvme;
} proto_specific;
union {
u_int valid; /* Which fields to honor */
@@ -973,6 +1016,7 @@ struct ccb_trans_settings {
struct ccb_trans_settings_sas sas;
struct ccb_trans_settings_pata ata;
struct ccb_trans_settings_sata sata;
+ struct ccb_trans_settings_nvme nvme;
} xport_specific;
};
@@ -1228,6 +1272,7 @@ union ccb {
struct ccb_ataio ataio;
struct ccb_dev_advinfo cdai;
struct ccb_async casync;
+ struct ccb_nvmeio nvmeio;
};
#define CCB_CLEAR_ALL_EXCEPT_HDR(ccbp) \
@@ -1244,6 +1289,12 @@ cam_fill_csio(struct ccb_scsiio *csio, u_int32_t retries,
u_int32_t timeout);
static __inline void
+cam_fill_nvmeio(struct ccb_nvmeio *nvmeio, u_int32_t retries,
+ void (*cbfcnp)(struct cam_periph *, union ccb *),
+ u_int32_t flags, u_int8_t *data_ptr, u_int32_t dxfer_len,
+ u_int32_t timeout);
+
+static __inline void
cam_fill_ctio(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int32_t flags, u_int tag_action, u_int tag_id,
@@ -1364,6 +1415,20 @@ cam_ccb_status(union ccb *ccb)
void cam_calc_geometry(struct ccb_calc_geometry *ccg, int extended);
+static __inline void
+cam_fill_nvmeio(struct ccb_nvmeio *nvmeio, u_int32_t retries,
+ void (*cbfcnp)(struct cam_periph *, union ccb *),
+ u_int32_t flags, u_int8_t *data_ptr, u_int32_t dxfer_len,
+ u_int32_t timeout)
+{
+ nvmeio->ccb_h.func_code = XPT_NVME_IO;
+ nvmeio->ccb_h.flags = flags;
+ nvmeio->ccb_h.retry_count = retries;
+ nvmeio->ccb_h.cbfcnp = cbfcnp;
+ nvmeio->ccb_h.timeout = timeout;
+ nvmeio->data_ptr = data_ptr;
+ nvmeio->dxfer_len = dxfer_len;
+}
__END_DECLS
#endif /* _CAM_CAM_CCB_H */
diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c
index 8da3ce3..58ea13a 100644
--- a/sys/cam/cam_xpt.c
+++ b/sys/cam/cam_xpt.c
@@ -309,6 +309,7 @@ static xpt_devicefunc_t xptsetasyncfunc;
static xpt_busfunc_t xptsetasyncbusfunc;
static cam_status xptregister(struct cam_periph *periph,
void *arg);
+static const char * xpt_action_name(uint32_t action);
static __inline int device_is_queued(struct cam_ed *device);
static __inline int
@@ -812,6 +813,10 @@ xpt_rescan(union ccb *ccb)
xpt_free_ccb(ccb);
return;
}
+ CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE,
+ ("xpt_rescan: func %#x %s\n", ccb->ccb_h.func_code,
+ xpt_action_name(ccb->ccb_h.func_code)));
+
ccb->ccb_h.ppriv_ptr1 = ccb->ccb_h.cbfcnp;
ccb->ccb_h.cbfcnp = xpt_rescan_done;
xpt_setup_ccb(&ccb->ccb_h, ccb->ccb_h.path, CAM_PRIORITY_XPT);
@@ -2451,7 +2456,8 @@ xpt_action(union ccb *start_ccb)
{
CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_TRACE,
- ("xpt_action: func=%#x\n", start_ccb->ccb_h.func_code));
+ ("xpt_action: func %#x %s\n", start_ccb->ccb_h.func_code,
+ xpt_action_name(start_ccb->ccb_h.func_code)));
start_ccb->ccb_h.status = CAM_REQ_INPROG;
(*(start_ccb->ccb_h.path->bus->xport->action))(start_ccb);
@@ -2466,7 +2472,8 @@ xpt_action_default(union ccb *start_ccb)
path = start_ccb->ccb_h.path;
CAM_DEBUG(path, CAM_DEBUG_TRACE,
- ("xpt_action_default: func=%#x\n", start_ccb->ccb_h.func_code));
+ ("xpt_action_default: func %#x %s\n", start_ccb->ccb_h.func_code,
+ xpt_action_name(start_ccb->ccb_h.func_code)));
switch (start_ccb->ccb_h.func_code) {
case XPT_SCSI_IO:
@@ -3012,6 +3019,11 @@ call_sim:
}
break;
}
+ CAM_DEBUG(path, CAM_DEBUG_TRACE,
+ ("xpt_action_default: func= %#x %s status %#x\n",
+ start_ccb->ccb_h.func_code,
+ xpt_action_name(start_ccb->ccb_h.func_code),
+ start_ccb->ccb_h.status));
}
void
@@ -4234,6 +4246,12 @@ xpt_async(u_int32_t async_code, struct cam_path *path, void *async_arg)
ccb->casync.async_code = async_code;
ccb->casync.async_arg_size = 0;
size = xpt_async_size(async_code);
+ CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE,
+ ("xpt_async: func %#x %s aync_code %d %s\n",
+ ccb->ccb_h.func_code,
+ xpt_action_name(ccb->ccb_h.func_code),
+ async_code,
+ xpt_async_string(async_code)));
if (size > 0 && async_arg != NULL) {
ccb->casync.async_arg_ptr = malloc(size, M_CAMXPT, M_NOWAIT);
if (ccb->casync.async_arg_ptr == NULL) {
@@ -4441,7 +4459,11 @@ xpt_done(union ccb *done_ccb)
struct cam_doneq *queue;
int run, hash;
- CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("xpt_done\n"));
+ CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_TRACE,
+ ("xpt_done: func= %#x %s status %#x\n",
+ done_ccb->ccb_h.func_code,
+ xpt_action_name(done_ccb->ccb_h.func_code),
+ done_ccb->ccb_h.status));
if ((done_ccb->ccb_h.func_code & XPT_FC_QUEUED) == 0)
return;
@@ -4463,7 +4485,8 @@ void
xpt_done_direct(union ccb *done_ccb)
{
- CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("xpt_done_direct\n"));
+ CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_TRACE,
+ ("xpt_done_direct: status %#x\n", done_ccb->ccb_h.status));
if ((done_ccb->ccb_h.func_code & XPT_FC_QUEUED) == 0)
return;
@@ -5050,6 +5073,9 @@ xpt_register_async(int event, ac_callback_t *cbfunc, void *cbarg,
xpt_action((union ccb *)&csa);
status = csa.ccb_h.status;
+ CAM_DEBUG(csa.ccb_h.path, CAM_DEBUG_TRACE,
+ ("xpt_register_async: func %p\n", cbfunc));
+
if (xptpath) {
xpt_path_unlock(path);
xpt_free_path(path);
@@ -5301,3 +5327,69 @@ camisr_runqueue(void)
mtx_unlock(&queue->cam_doneq_mtx);
}
}
+
+struct kv
+{
+ uint32_t v;
+ const char *name;
+};
+
+static struct kv map[] = {
+ { XPT_NOOP, "XPT_NOOP" },
+ { XPT_SCSI_IO, "XPT_SCSI_IO" },
+ { XPT_GDEV_TYPE, "XPT_GDEV_TYPE" },
+ { XPT_GDEVLIST, "XPT_GDEVLIST" },
+ { XPT_PATH_INQ, "XPT_PATH_INQ" },
+ { XPT_REL_SIMQ, "XPT_REL_SIMQ" },
+ { XPT_SASYNC_CB, "XPT_SASYNC_CB" },
+ { XPT_SDEV_TYPE, "XPT_SDEV_TYPE" },
+ { XPT_SCAN_BUS, "XPT_SCAN_BUS" },
+ { XPT_DEV_MATCH, "XPT_DEV_MATCH" },
+ { XPT_DEBUG, "XPT_DEBUG" },
+ { XPT_PATH_STATS, "XPT_PATH_STATS" },
+ { XPT_GDEV_STATS, "XPT_GDEV_STATS" },
+ { XPT_DEV_ADVINFO, "XPT_DEV_ADVINFO" },
+ { XPT_ASYNC, "XPT_ASYNC" },
+ { XPT_ABORT, "XPT_ABORT" },
+ { XPT_RESET_BUS, "XPT_RESET_BUS" },
+ { XPT_RESET_DEV, "XPT_RESET_DEV" },
+ { XPT_TERM_IO, "XPT_TERM_IO" },
+ { XPT_SCAN_LUN, "XPT_SCAN_LUN" },
+ { XPT_GET_TRAN_SETTINGS, "XPT_GET_TRAN_SETTINGS" },
+ { XPT_SET_TRAN_SETTINGS, "XPT_SET_TRAN_SETTINGS" },
+ { XPT_CALC_GEOMETRY, "XPT_CALC_GEOMETRY" },
+ { XPT_ATA_IO, "XPT_ATA_IO" },
+ { XPT_GET_SIM_KNOB, "XPT_GET_SIM_KNOB" },
+ { XPT_SET_SIM_KNOB, "XPT_SET_SIM_KNOB" },
+ { XPT_NVME_IO, "XPT_NVME_IO" },
+ { XPT_MMCSD_IO, "XPT_MMCSD_IO" },
+ { XPT_SMP_IO, "XPT_SMP_IO" },
+ { XPT_SCAN_TGT, "XPT_SCAN_TGT" },
+ { XPT_ENG_INQ, "XPT_ENG_INQ" },
+ { XPT_ENG_EXEC, "XPT_ENG_EXEC" },
+ { XPT_EN_LUN, "XPT_EN_LUN" },
+ { XPT_TARGET_IO, "XPT_TARGET_IO" },
+ { XPT_ACCEPT_TARGET_IO, "XPT_ACCEPT_TARGET_IO" },
+ { XPT_CONT_TARGET_IO, "XPT_CONT_TARGET_IO" },
+ { XPT_IMMED_NOTIFY, "XPT_IMMED_NOTIFY" },
+ { XPT_NOTIFY_ACK, "XPT_NOTIFY_ACK" },
+ { XPT_IMMEDIATE_NOTIFY, "XPT_IMMEDIATE_NOTIFY" },
+ { XPT_NOTIFY_ACKNOWLEDGE, "XPT_NOTIFY_ACKNOWLEDGE" },
+ { 0, 0 }
+};
+
+static const char *
+xpt_action_name(uint32_t action)
+{
+ static char buffer[32]; /* Only for unknown messages -- racy */
+ struct kv *walker = map;
+
+ while (walker->name != NULL) {
+ if (walker->v == action)
+ return (walker->name);
+ walker++;
+ }
+
+ snprintf(buffer, sizeof(buffer), "%#x", action);
+ return (buffer);
+}
diff --git a/sys/cam/cam_xpt_internal.h b/sys/cam/cam_xpt_internal.h
index 23d6d34..b0624af 100644
--- a/sys/cam/cam_xpt_internal.h
+++ b/sys/cam/cam_xpt_internal.h
@@ -117,6 +117,8 @@ struct cam_ed {
STAILQ_ENTRY(cam_ed) highpowerq_entry;
struct mtx device_mtx;
struct task device_destroy_task;
+ const struct nvme_controller_data *nvme_cdata;
+ const struct nvme_namespace_data *nvme_data;
};
/*
@@ -167,6 +169,7 @@ struct cam_path {
struct xpt_xport * scsi_get_xport(void);
struct xpt_xport * ata_get_xport(void);
+struct xpt_xport * nvme_get_xport(void);
struct cam_ed * xpt_alloc_device(struct cam_eb *bus,
struct cam_et *target,
diff --git a/sys/cam/nvme/nvme_all.c b/sys/cam/nvme/nvme_all.c
new file mode 100644
index 0000000..3904891
--- /dev/null
+++ b/sys/cam/nvme/nvme_all.c
@@ -0,0 +1,124 @@
+/*-
+ * Copyright (c) 2015 Netflix, Inc
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer,
+ * without modification, immediately at the beginning of the file.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+
+#ifdef _KERNEL
+#include "opt_scsi.h"
+
+#include <sys/systm.h>
+#include <sys/libkern.h>
+#include <sys/kernel.h>
+#include <sys/sysctl.h>
+#else
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifndef min
+#define min(a,b) (((a)<(b))?(a):(b))
+#endif
+#endif
+
+#include <cam/cam.h>
+#include <cam/cam_ccb.h>
+#include <cam/cam_queue.h>
+#include <cam/cam_xpt.h>
+#include <cam/nvme/nvme_all.h>
+#include <sys/sbuf.h>
+#include <sys/endian.h>
+
+void
+nvme_ns_cmd(struct ccb_nvmeio *nvmeio, uint8_t cmd, uint32_t nsid,
+ uint32_t cdw10, uint32_t cdw11, uint32_t cdw12, uint32_t cdw13,
+ uint32_t cdw14, uint32_t cdw15)
+{
+ bzero(&nvmeio->cmd, sizeof(struct nvme_command));
+ nvmeio->cmd.opc = cmd;
+ nvmeio->cmd.nsid = nsid;
+ nvmeio->cmd.cdw10 = cdw10;
+ nvmeio->cmd.cdw11 = cdw11;
+ nvmeio->cmd.cdw12 = cdw12;
+ nvmeio->cmd.cdw13 = cdw13;
+ nvmeio->cmd.cdw14 = cdw14;
+ nvmeio->cmd.cdw15 = cdw15;
+}
+
+int
+nvme_identify_match(caddr_t identbuffer, caddr_t table_entry)
+{
+ return 0;
+}
+
+
+void
+nvme_print_ident(const struct nvme_controller_data *cdata,
+ const struct nvme_namespace_data *data)
+{
+ printf("I'm a pretty NVME drive\n");
+}
+
+/* XXX need to do nvme admin opcodes too, but those aren't used yet by nda */
+static const char *
+nvme_opc2str[] = {
+ "FLUSH",
+ "WRITE",
+ "READ",
+ "RSVD-3",
+ "WRITE_UNCORRECTABLE",
+ "COMPARE",
+ "RSVD-6",
+ "RSVD-7",
+ "DATASET_MANAGEMENT"
+};
+
+const char *
+nvme_op_string(const struct nvme_command *cmd)
+{
+ if (cmd->opc > nitems(nvme_opc2str))
+ return "UNKNOWN";
+
+ return nvme_opc2str[cmd->opc];
+}
+
+const char *
+nvme_cmd_string(const struct nvme_command *cmd, char *cmd_string, size_t len)
+{
+ /*
+ * cid, rsvd areas and mptr not printed, since they are used
+ * only internally by the SIM.
+ */
+ snprintf(cmd_string, len,
+ "opc=%x fuse=%x nsid=%x prp1=%llx prp2=%llx cdw=%x %x %x %x %x %x",
+ cmd->opc, cmd->fuse, cmd->nsid,
+ (unsigned long long)cmd->prp1, (unsigned long long)cmd->prp2,
+ cmd->cdw10, cmd->cdw11, cmd->cdw12, cmd->cdw13, cmd->cdw14, cmd->cdw15);
+
+ return cmd_string;
+}
diff --git a/sys/cam/nvme/nvme_all.h b/sys/cam/nvme/nvme_all.h
new file mode 100644
index 0000000..3cff74d
--- /dev/null
+++ b/sys/cam/nvme/nvme_all.h
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2015 Netflix, Inc
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer,
+ * without modification, immediately at the beginning of the file.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef CAM_NVME_NVME_ALL_H
+#define CAM_NVME_NVME_ALL_H 1
+
+#include <dev/nvme/nvme.h>
+
+struct ccb_nvmeio;
+
+#define NVME_REV_1 1 /* Supports NVMe 1.2 or earlier */
+
+void nvme_ns_cmd(struct ccb_nvmeio *nvmeio, uint8_t cmd, uint32_t nsid,
+ uint32_t cdw10, uint32_t cdw11, uint32_t cdw12, uint32_t cdw13,
+ uint32_t cdw14, uint32_t cdw15);
+
+int nvme_identify_match(caddr_t identbuffer, caddr_t table_entry);
+
+void nvme_print_ident(const struct nvme_controller_data *, const struct nvme_namespace_data *);
+const char *nvme_op_string(const struct nvme_command *);
+const char *nvme_cmd_string(const struct nvme_command *, char *, size_t);
+
+#endif /* CAM_NVME_NVME_ALL_H */
diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c
new file mode 100644
index 0000000..9628530
--- /dev/null
+++ b/sys/cam/nvme/nvme_da.c
@@ -0,0 +1,1152 @@
+/*-
+ * Copyright (c) 2015 Netflix, Inc
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer,
+ * without modification, immediately at the beginning of the file.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Derived from ata_da.c:
+ * Copyright (c) 2009 Alexander Motin <mav@FreeBSD.org>
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+
+#ifdef _KERNEL
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bio.h>
+#include <sys/sysctl.h>
+#include <sys/taskqueue.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/conf.h>
+#include <sys/devicestat.h>
+#include <sys/eventhandler.h>
+#include <sys/malloc.h>
+#include <sys/cons.h>
+#include <sys/proc.h>
+#include <sys/reboot.h>
+#include <geom/geom_disk.h>
+#endif /* _KERNEL */
+
+#ifndef _KERNEL
+#include <stdio.h>
+#include <string.h>
+#endif /* _KERNEL */
+
+#include <cam/cam.h>
+#include <cam/cam_ccb.h>
+#include <cam/cam_periph.h>
+#include <cam/cam_xpt_periph.h>
+#include <cam/cam_sim.h>
+#include <cam/cam_iosched.h>
+
+#include <cam/nvme/nvme_all.h>
+
+typedef enum {
+ NDA_STATE_NORMAL
+} nda_state;
+
+typedef enum {
+ NDA_FLAG_OPEN = 0x0001,
+ NDA_FLAG_DIRTY = 0x0002,
+ NDA_FLAG_SCTX_INIT = 0x0004,
+} nda_flags;
+
+typedef enum {
+ NDA_Q_4K = 0x01,
+ NDA_Q_NONE = 0x00,
+} nda_quirks;
+
+#define NDA_Q_BIT_STRING \
+ "\020" \
+ "\001Bit 0"
+
+typedef enum {
+ NDA_CCB_BUFFER_IO = 0x01,
+ NDA_CCB_DUMP = 0x02,
+ NDA_CCB_TRIM = 0x03,
+ NDA_CCB_TYPE_MASK = 0x0F,
+} nda_ccb_state;
+
+/* Offsets into our private area for storing information */
+#define ccb_state ppriv_field0
+#define ccb_bp ppriv_ptr1
+
+struct trim_request {
+ TAILQ_HEAD(, bio) bps;
+};
+struct nda_softc {
+ struct cam_iosched_softc *cam_iosched;
+ int outstanding_cmds; /* Number of active commands */
+ int refcount; /* Active xpt_action() calls */
+ nda_state state;
+ nda_flags flags;
+ nda_quirks quirks;
+ int unmappedio;
+ uint32_t nsid; /* Namespace ID for this nda device */
+ struct disk *disk;
+ struct task sysctl_task;
+ struct sysctl_ctx_list sysctl_ctx;
+ struct sysctl_oid *sysctl_tree;
+ struct trim_request trim_req;
+#ifdef CAM_IO_STATS
+ struct sysctl_ctx_list sysctl_stats_ctx;
+ struct sysctl_oid *sysctl_stats_tree;
+ u_int timeouts;
+ u_int errors;
+ u_int invalidations;
+#endif
+};
+
+/* Need quirk table */
+
+static disk_strategy_t ndastrategy;
+static dumper_t ndadump;
+static periph_init_t ndainit;
+static void ndaasync(void *callback_arg, u_int32_t code,
+ struct cam_path *path, void *arg);
+static void ndasysctlinit(void *context, int pending);
+static periph_ctor_t ndaregister;
+static periph_dtor_t ndacleanup;
+static periph_start_t ndastart;
+static periph_oninv_t ndaoninvalidate;
+static void ndadone(struct cam_periph *periph,
+ union ccb *done_ccb);
+static int ndaerror(union ccb *ccb, u_int32_t cam_flags,
+ u_int32_t sense_flags);
+static void ndashutdown(void *arg, int howto);
+static void ndasuspend(void *arg);
+
+#ifndef NDA_DEFAULT_SEND_ORDERED
+#define NDA_DEFAULT_SEND_ORDERED 1
+#endif
+#ifndef NDA_DEFAULT_TIMEOUT
+#define NDA_DEFAULT_TIMEOUT 30 /* Timeout in seconds */
+#endif
+#ifndef NDA_DEFAULT_RETRY
+#define NDA_DEFAULT_RETRY 4
+#endif
+
+
+//static int nda_retry_count = NDA_DEFAULT_RETRY;
+static int nda_send_ordered = NDA_DEFAULT_SEND_ORDERED;
+static int nda_default_timeout = NDA_DEFAULT_TIMEOUT;
+
+/*
+ * All NVMe media is non-rotational, so all nvme device instances
+ * share this to implement the sysctl.
+ */
+static int nda_rotating_media = 0;
+
+static SYSCTL_NODE(_kern_cam, OID_AUTO, nda, CTLFLAG_RD, 0,
+ "CAM Direct Access Disk driver");
+
+static struct periph_driver ndadriver =
+{
+ ndainit, "nda",
+ TAILQ_HEAD_INITIALIZER(ndadriver.units), /* generation */ 0
+};
+
+PERIPHDRIVER_DECLARE(nda, ndadriver);
+
+static MALLOC_DEFINE(M_NVMEDA, "nvme_da", "nvme_da buffers");
+
+/*
+ * nice wrappers. Maybe these belong in nvme_all.c instead of
+ * here, but this is the only place that uses these. Should
+ * we ever grow another NVME periph, we should move them
+ * all there wholesale.
+ */
+
+static void
+nda_nvme_flush(struct nda_softc *softc, struct ccb_nvmeio *nvmeio)
+{
+ cam_fill_nvmeio(nvmeio,
+ 0, /* retries */
+ ndadone, /* cbfcnp */
+ CAM_DIR_NONE, /* flags */
+ NULL, /* data_ptr */
+ 0, /* dxfer_len */
+ nda_default_timeout * 1000); /* timeout 5s */
+ nvme_ns_flush_cmd(&nvmeio->cmd, softc->nsid);
+}
+
+static void
+nda_nvme_trim(struct nda_softc *softc, struct ccb_nvmeio *nvmeio,
+ void *payload, uint32_t num_ranges)
+{
+ cam_fill_nvmeio(nvmeio,
+ 0, /* retries */
+ ndadone, /* cbfcnp */
+ CAM_DIR_OUT, /* flags */
+ payload, /* data_ptr */
+ num_ranges * sizeof(struct nvme_dsm_range), /* dxfer_len */
+ nda_default_timeout * 1000); /* timeout 5s */
+ nvme_ns_trim_cmd(&nvmeio->cmd, softc->nsid, num_ranges);
+}
+
+static void
+nda_nvme_write(struct nda_softc *softc, struct ccb_nvmeio *nvmeio,
+ void *payload, uint64_t lba, uint32_t len, uint32_t count)
+{
+ cam_fill_nvmeio(nvmeio,
+ 0, /* retries */
+ ndadone, /* cbfcnp */
+ CAM_DIR_OUT, /* flags */
+ payload, /* data_ptr */
+ len, /* dxfer_len */
+ nda_default_timeout * 1000); /* timeout 5s */
+ nvme_ns_write_cmd(&nvmeio->cmd, softc->nsid, lba, count);
+}
+
+static void
+nda_nvme_rw_bio(struct nda_softc *softc, struct ccb_nvmeio *nvmeio,
+ struct bio *bp, uint32_t rwcmd)
+{
+ int flags = rwcmd == NVME_OPC_READ ? CAM_DIR_IN : CAM_DIR_OUT;
+ void *payload;
+ uint64_t lba;
+ uint32_t count;
+
+ if (bp->bio_flags & BIO_UNMAPPED) {
+ flags |= CAM_DATA_BIO;
+ payload = bp;
+ } else {
+ payload = bp->bio_data;
+ }
+
+ lba = bp->bio_pblkno;
+ count = bp->bio_bcount / softc->disk->d_sectorsize;
+
+ cam_fill_nvmeio(nvmeio,
+ 0, /* retries */
+ ndadone, /* cbfcnp */
+ flags, /* flags */
+ payload, /* data_ptr */
+ bp->bio_bcount, /* dxfer_len */
+ nda_default_timeout * 1000); /* timeout 5s */
+ nvme_ns_rw_cmd(&nvmeio->cmd, rwcmd, softc->nsid, lba, count);
+}
+
+static int
+ndaopen(struct disk *dp)
+{
+ struct cam_periph *periph;
+ struct nda_softc *softc;
+ int error;
+
+ periph = (struct cam_periph *)dp->d_drv1;
+ if (cam_periph_acquire(periph) != CAM_REQ_CMP) {
+ return(ENXIO);
+ }
+
+ cam_periph_lock(periph);
+ if ((error = cam_periph_hold(periph, PRIBIO|PCATCH)) != 0) {
+ cam_periph_unlock(periph);
+ cam_periph_release(periph);
+ return (error);
+ }
+
+ CAM_DEBUG(periph->path, CAM_DEBUG_TRACE | CAM_DEBUG_PERIPH,
+ ("ndaopen\n"));
+
+ softc = (struct nda_softc *)periph->softc;
+ softc->flags |= NDA_FLAG_OPEN;
+
+ cam_periph_unhold(periph);
+ cam_periph_unlock(periph);
+ return (0);
+}
+
+static int
+ndaclose(struct disk *dp)
+{
+ struct cam_periph *periph;
+ struct nda_softc *softc;
+ union ccb *ccb;
+ int error;
+
+ periph = (struct cam_periph *)dp->d_drv1;
+ softc = (struct nda_softc *)periph->softc;
+ cam_periph_lock(periph);
+
+ CAM_DEBUG(periph->path, CAM_DEBUG_TRACE | CAM_DEBUG_PERIPH,
+ ("ndaclose\n"));
+
+ if ((softc->flags & NDA_FLAG_DIRTY) != 0 &&
+ (periph->flags & CAM_PERIPH_INVALID) == 0 &&
+ cam_periph_hold(periph, PRIBIO) == 0) {
+
+ ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
+ nda_nvme_flush(softc, &ccb->nvmeio);
+ error = cam_periph_runccb(ccb, ndaerror, /*cam_flags*/0,
+ /*sense_flags*/0, softc->disk->d_devstat);
+
+ if (error != 0)
+ xpt_print(periph->path, "Synchronize cache failed\n");
+ else
+ softc->flags &= ~NDA_FLAG_DIRTY;
+ xpt_release_ccb(ccb);
+ cam_periph_unhold(periph);
+ }
+
+ softc->flags &= ~NDA_FLAG_OPEN;
+
+ while (softc->refcount != 0)
+ cam_periph_sleep(periph, &softc->refcount, PRIBIO, "ndaclose", 1);
+ cam_periph_unlock(periph);
+ cam_periph_release(periph);
+ return (0);
+}
+
+static void
+ndaschedule(struct cam_periph *periph)
+{
+ struct nda_softc *softc = (struct nda_softc *)periph->softc;
+
+ if (softc->state != NDA_STATE_NORMAL)
+ return;
+
+ cam_iosched_schedule(softc->cam_iosched, periph);
+}
+
+/*
+ * Actually translate the requested transfer into one the physical driver
+ * can understand. The transfer is described by a buf and will include
+ * only one physical transfer.
+ */
+static void
+ndastrategy(struct bio *bp)
+{
+ struct cam_periph *periph;
+ struct nda_softc *softc;
+
+ periph = (struct cam_periph *)bp->bio_disk->d_drv1;
+ softc = (struct nda_softc *)periph->softc;
+
+ cam_periph_lock(periph);
+
+ CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("ndastrategy(%p)\n", bp));
+
+ /*
+ * If the device has been made invalid, error out
+ */
+ if ((periph->flags & CAM_PERIPH_INVALID) != 0) {
+ cam_periph_unlock(periph);
+ biofinish(bp, NULL, ENXIO);
+ return;
+ }
+
+ /*
+ * Place it in the queue of disk activities for this disk
+ */
+ cam_iosched_queue_work(softc->cam_iosched, bp);
+
+ /*
+ * Schedule ourselves for performing the work.
+ */
+ ndaschedule(periph);
+ cam_periph_unlock(periph);
+
+ return;
+}
+
+static int
+ndadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t length)
+{
+ struct cam_periph *periph;
+ struct nda_softc *softc;
+ u_int secsize;
+ union ccb ccb;
+ struct disk *dp;
+ uint64_t lba;
+ uint32_t count;
+ int error = 0;
+
+ dp = arg;
+ periph = dp->d_drv1;
+ softc = (struct nda_softc *)periph->softc;
+ cam_periph_lock(periph);
+ secsize = softc->disk->d_sectorsize;
+ lba = offset / secsize;
+ count = length / secsize;
+
+ if ((periph->flags & CAM_PERIPH_INVALID) != 0) {
+ cam_periph_unlock(periph);
+ return (ENXIO);
+ }
+
+ if (length > 0) {
+ xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+ ccb.ccb_h.ccb_state = NDA_CCB_DUMP;
+ nda_nvme_write(softc, &ccb.nvmeio, virtual, lba, length, count);
+ xpt_polled_action(&ccb);
+
+ error = cam_periph_error(&ccb,
+ 0, SF_NO_RECOVERY | SF_NO_RETRY, NULL);
+ if ((ccb.ccb_h.status & CAM_DEV_QFRZN) != 0)
+ cam_release_devq(ccb.ccb_h.path, /*relsim_flags*/0,
+ /*reduction*/0, /*timeout*/0, /*getcount_only*/0);
+ if (error != 0)
+ printf("Aborting dump due to I/O error.\n");
+
+ cam_periph_unlock(periph);
+ return (error);
+ }
+
+ /* Flush */
+ xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+
+ ccb.ccb_h.ccb_state = NDA_CCB_DUMP;
+ nda_nvme_flush(softc, &ccb.nvmeio);
+ xpt_polled_action(&ccb);
+
+ error = cam_periph_error(&ccb,
+ 0, SF_NO_RECOVERY | SF_NO_RETRY, NULL);
+ if ((ccb.ccb_h.status & CAM_DEV_QFRZN) != 0)
+ cam_release_devq(ccb.ccb_h.path, /*relsim_flags*/0,
+ /*reduction*/0, /*timeout*/0, /*getcount_only*/0);
+ if (error != 0)
+ xpt_print(periph->path, "flush cmd failed\n");
+ cam_periph_unlock(periph);
+ return (error);
+}
+
+static void
+ndainit(void)
+{
+ cam_status status;
+
+ /*
+ * Install a global async callback. This callback will
+ * receive async callbacks like "new device found".
+ */
+ status = xpt_register_async(AC_FOUND_DEVICE, ndaasync, NULL, NULL);
+
+ if (status != CAM_REQ_CMP) {
+ printf("nda: Failed to attach master async callback "
+ "due to status 0x%x!\n", status);
+ } else if (nda_send_ordered) {
+
+ /* Register our event handlers */
+ if ((EVENTHANDLER_REGISTER(power_suspend, ndasuspend,
+ NULL, EVENTHANDLER_PRI_LAST)) == NULL)
+ printf("ndainit: power event registration failed!\n");
+ if ((EVENTHANDLER_REGISTER(shutdown_post_sync, ndashutdown,
+ NULL, SHUTDOWN_PRI_DEFAULT)) == NULL)
+ printf("ndainit: shutdown event registration failed!\n");
+ }
+}
+
+/*
+ * Callback from GEOM, called when it has finished cleaning up its
+ * resources.
+ */
+static void
+ndadiskgonecb(struct disk *dp)
+{
+ struct cam_periph *periph;
+
+ periph = (struct cam_periph *)dp->d_drv1;
+
+ cam_periph_release(periph);
+}
+
+static void
+ndaoninvalidate(struct cam_periph *periph)
+{
+ struct nda_softc *softc;
+
+ softc = (struct nda_softc *)periph->softc;
+
+ /*
+ * De-register any async callbacks.
+ */
+ xpt_register_async(0, ndaasync, periph, periph->path);
+#ifdef CAM_IO_STATS
+ softc->invalidations++;
+#endif
+
+ /*
+ * Return all queued I/O with ENXIO.
+ * XXX Handle any transactions queued to the card
+ * with XPT_ABORT_CCB.
+ */
+ cam_iosched_flush(softc->cam_iosched, NULL, ENXIO);
+
+ disk_gone(softc->disk);
+}
+
+static void
+ndacleanup(struct cam_periph *periph)
+{
+ struct nda_softc *softc;
+
+ softc = (struct nda_softc *)periph->softc;
+
+ cam_periph_unlock(periph);
+
+ cam_iosched_fini(softc->cam_iosched);
+
+ /*
+ * If we can't free the sysctl tree, oh well...
+ */
+ if ((softc->flags & NDA_FLAG_SCTX_INIT) != 0) {
+#ifdef CAM_IO_STATS
+ if (sysctl_ctx_free(&softc->sysctl_stats_ctx) != 0)
+ xpt_print(periph->path,
+ "can't remove sysctl stats context\n");
+#endif
+ if (sysctl_ctx_free(&softc->sysctl_ctx) != 0)
+ xpt_print(periph->path,
+ "can't remove sysctl context\n");
+ }
+
+ disk_destroy(softc->disk);
+ free(softc, M_DEVBUF);
+ cam_periph_lock(periph);
+}
+
+static void
+ndaasync(void *callback_arg, u_int32_t code,
+ struct cam_path *path, void *arg)
+{
+ struct cam_periph *periph;
+
+ periph = (struct cam_periph *)callback_arg;
+ switch (code) {
+ case AC_FOUND_DEVICE:
+ {
+ struct ccb_getdev *cgd;
+ cam_status status;
+
+ cgd = (struct ccb_getdev *)arg;
+ if (cgd == NULL)
+ break;
+
+ if (cgd->protocol != PROTO_NVME)
+ break;
+
+ /*
+ * Allocate a peripheral instance for
+ * this device and start the probe
+ * process.
+ */
+ status = cam_periph_alloc(ndaregister, ndaoninvalidate,
+ ndacleanup, ndastart,
+ "nda", CAM_PERIPH_BIO,
+ path, ndaasync,
+ AC_FOUND_DEVICE, cgd);
+
+ if (status != CAM_REQ_CMP
+ && status != CAM_REQ_INPROG)
+ printf("ndaasync: Unable to attach to new device "
+ "due to status 0x%x\n", status);
+ break;
+ }
+ case AC_ADVINFO_CHANGED:
+ {
+ uintptr_t buftype;
+
+ buftype = (uintptr_t)arg;
+ if (buftype == CDAI_TYPE_PHYS_PATH) {
+ struct nda_softc *softc;
+
+ softc = periph->softc;
+ disk_attr_changed(softc->disk, "GEOM::physpath",
+ M_NOWAIT);
+ }
+ break;
+ }
+ case AC_LOST_DEVICE:
+ default:
+ cam_periph_async(periph, code, path, arg);
+ break;
+ }
+}
+
+static void
+ndasysctlinit(void *context, int pending)
+{
+ struct cam_periph *periph;
+ struct nda_softc *softc;
+ char tmpstr[80], tmpstr2[80];
+
+ periph = (struct cam_periph *)context;
+
+ /* periph was held for us when this task was enqueued */
+ if ((periph->flags & CAM_PERIPH_INVALID) != 0) {
+ cam_periph_release(periph);
+ return;
+ }
+
+ softc = (struct nda_softc *)periph->softc;
+ snprintf(tmpstr, sizeof(tmpstr), "CAM NDA unit %d", periph->unit_number);
+ snprintf(tmpstr2, sizeof(tmpstr2), "%d", periph->unit_number);
+
+ sysctl_ctx_init(&softc->sysctl_ctx);
+ softc->flags |= NDA_FLAG_SCTX_INIT;
+ softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx,
+ SYSCTL_STATIC_CHILDREN(_kern_cam_nda), OID_AUTO, tmpstr2,
+ CTLFLAG_RD, 0, tmpstr);
+ if (softc->sysctl_tree == NULL) {
+ printf("ndasysctlinit: unable to allocate sysctl tree\n");
+ cam_periph_release(periph);
+ return;
+ }
+
+ SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
+ OID_AUTO, "unmapped_io", CTLFLAG_RD | CTLFLAG_MPSAFE,
+ &softc->unmappedio, 0, "Unmapped I/O leaf");
+
+ SYSCTL_ADD_INT(&softc->sysctl_ctx,
+ SYSCTL_CHILDREN(softc->sysctl_tree),
+ OID_AUTO,
+ "rotating",
+ CTLFLAG_RD | CTLFLAG_MPSAFE,
+ &nda_rotating_media,
+ 0,
+ "Rotating media");
+
+#ifdef CAM_IO_STATS
+ softc->sysctl_stats_tree = SYSCTL_ADD_NODE(&softc->sysctl_stats_ctx,
+ SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "stats",
+ CTLFLAG_RD, 0, "Statistics");
+ if (softc->sysctl_stats_tree == NULL) {
+ printf("ndasysctlinit: unable to allocate sysctl tree for stats\n");
+ cam_periph_release(periph);
+ return;
+ }
+ SYSCTL_ADD_INT(&softc->sysctl_stats_ctx,
+ SYSCTL_CHILDREN(softc->sysctl_stats_tree),
+ OID_AUTO, "timeouts", CTLFLAG_RD | CTLFLAG_MPSAFE,
+ &softc->timeouts, 0,
+ "Device timeouts reported by the SIM");
+ SYSCTL_ADD_INT(&softc->sysctl_stats_ctx,
+ SYSCTL_CHILDREN(softc->sysctl_stats_tree),
+ OID_AUTO, "errors", CTLFLAG_RD | CTLFLAG_MPSAFE,
+ &softc->errors, 0,
+ "Transport errors reported by the SIM.");
+ SYSCTL_ADD_INT(&softc->sysctl_stats_ctx,
+ SYSCTL_CHILDREN(softc->sysctl_stats_tree),
+ OID_AUTO, "pack_invalidations", CTLFLAG_RD | CTLFLAG_MPSAFE,
+ &softc->invalidations, 0,
+ "Device pack invalidations.");
+#endif
+
+ cam_iosched_sysctl_init(softc->cam_iosched, &softc->sysctl_ctx,
+ softc->sysctl_tree);
+
+ cam_periph_release(periph);
+}
+
+static int
+ndagetattr(struct bio *bp)
+{
+ int ret;
+ struct cam_periph *periph;
+
+ periph = (struct cam_periph *)bp->bio_disk->d_drv1;
+ cam_periph_lock(periph);
+ ret = xpt_getattr(bp->bio_data, bp->bio_length, bp->bio_attribute,
+ periph->path);
+ cam_periph_unlock(periph);
+ if (ret == 0)
+ bp->bio_completed = bp->bio_length;
+ return ret;
+}
+
+static cam_status
+ndaregister(struct cam_periph *periph, void *arg)
+{
+ struct nda_softc *softc;
+ struct disk *disk;
+ struct ccb_pathinq cpi;
+ struct ccb_getdev *cgd;
+ const struct nvme_namespace_data *nsd;
+ const struct nvme_controller_data *cd;
+ char announce_buf[80];
+// caddr_t match;
+ u_int maxio;
+ int quirks;
+
+ cgd = (struct ccb_getdev *)arg;
+ if (cgd == NULL) {
+ printf("ndaregister: no getdev CCB, can't register device\n");
+ return(CAM_REQ_CMP_ERR);
+ }
+ nsd = cgd->nvme_data;
+ cd = cgd->nvme_cdata;
+
+ softc = (struct nda_softc *)malloc(sizeof(*softc), M_DEVBUF,
+ M_NOWAIT | M_ZERO);
+
+ if (softc == NULL) {
+ printf("ndaregister: Unable to probe new device. "
+ "Unable to allocate softc\n");
+ return(CAM_REQ_CMP_ERR);
+ }
+
+ if (cam_iosched_init(&softc->cam_iosched, periph) != 0) {
+ printf("ndaregister: Unable to probe new device. "
+ "Unable to allocate iosched memory\n");
+ return(CAM_REQ_CMP_ERR);
+ }
+
+ /* ident_data parsing */
+
+ periph->softc = softc;
+
+#if 0
+ /*
+ * See if this device has any quirks.
+ */
+ match = cam_quirkmatch((caddr_t)&cgd->ident_data,
+ (caddr_t)nda_quirk_table,
+ sizeof(nda_quirk_table)/sizeof(*nda_quirk_table),
+ sizeof(*nda_quirk_table), ata_identify_match);
+ if (match != NULL)
+ softc->quirks = ((struct nda_quirk_entry *)match)->quirks;
+ else
+#endif
+ softc->quirks = NDA_Q_NONE;
+
+ bzero(&cpi, sizeof(cpi));
+ xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NONE);
+ cpi.ccb_h.func_code = XPT_PATH_INQ;
+ xpt_action((union ccb *)&cpi);
+
+ TASK_INIT(&softc->sysctl_task, 0, ndasysctlinit, periph);
+
+ /*
+ * The name space ID is the lun, save it for later I/O
+ */
+ softc->nsid = (uint16_t)xpt_path_lun_id(periph->path);
+
+ /*
+ * Register this media as a disk
+ */
+ (void)cam_periph_hold(periph, PRIBIO);
+ cam_periph_unlock(periph);
+ snprintf(announce_buf, sizeof(announce_buf),
+ "kern.cam.nda.%d.quirks", periph->unit_number);
+ quirks = softc->quirks;
+ TUNABLE_INT_FETCH(announce_buf, &quirks);
+ softc->quirks = quirks;
+ cam_iosched_set_sort_queue(softc->cam_iosched, 0);
+ softc->disk = disk = disk_alloc();
+ strlcpy(softc->disk->d_descr, cd->mn,
+ MIN(sizeof(softc->disk->d_descr), sizeof(cd->mn)));
+ strlcpy(softc->disk->d_ident, cd->sn,
+ MIN(sizeof(softc->disk->d_ident), sizeof(cd->sn)));
+ disk->d_rotation_rate = 0; /* Spinning rust need not apply */
+ disk->d_open = ndaopen;
+ disk->d_close = ndaclose;
+ disk->d_strategy = ndastrategy;
+ disk->d_getattr = ndagetattr;
+ disk->d_dump = ndadump;
+ disk->d_gone = ndadiskgonecb;
+ disk->d_name = "nda";
+ disk->d_drv1 = periph;
+ disk->d_unit = periph->unit_number;
+ maxio = cpi.maxio; /* Honor max I/O size of SIM */
+ if (maxio == 0)
+ maxio = DFLTPHYS; /* traditional default */
+ else if (maxio > MAXPHYS)
+ maxio = MAXPHYS; /* for safety */
+ disk->d_maxsize = maxio;
+ disk->d_sectorsize = 1 << nsd->lbaf[nsd->flbas.format].lbads;
+ disk->d_mediasize = (off_t)(disk->d_sectorsize * nsd->nsze);
+ disk->d_delmaxsize = disk->d_mediasize;
+ disk->d_flags = DISKFLAG_DIRECT_COMPLETION;
+// if (cd->oncs.dsm) // XXX broken?
+ disk->d_flags |= DISKFLAG_CANDELETE;
+ if (cd->vwc.present)
+ disk->d_flags |= DISKFLAG_CANFLUSHCACHE;
+ if ((cpi.hba_misc & PIM_UNMAPPED) != 0) {
+ disk->d_flags |= DISKFLAG_UNMAPPED_BIO;
+ softc->unmappedio = 1;
+ }
+ /*
+ * d_ident and d_descr are both far bigger than the length of either
+ * the serial or model number strings.
+ */
+ nvme_strvis(disk->d_descr, cd->mn,
+ sizeof(disk->d_descr), NVME_MODEL_NUMBER_LENGTH);
+ nvme_strvis(disk->d_ident, cd->sn,
+ sizeof(disk->d_ident), NVME_SERIAL_NUMBER_LENGTH);
+ disk->d_hba_vendor = cpi.hba_vendor;
+ disk->d_hba_device = cpi.hba_device;
+ disk->d_hba_subvendor = cpi.hba_subvendor;
+ disk->d_hba_subdevice = cpi.hba_subdevice;
+ disk->d_stripesize = disk->d_sectorsize;
+ disk->d_stripeoffset = 0;
+ disk->d_devstat = devstat_new_entry(periph->periph_name,
+ periph->unit_number, disk->d_sectorsize,
+ DEVSTAT_ALL_SUPPORTED,
+ DEVSTAT_TYPE_DIRECT | XPORT_DEVSTAT_TYPE(cpi.transport),
+ DEVSTAT_PRIORITY_DISK);
+
+ /*
+ * Acquire a reference to the periph before we register with GEOM.
+ * We'll release this reference once GEOM calls us back (via
+ * ndadiskgonecb()) telling us that our provider has been freed.
+ */
+ if (cam_periph_acquire(periph) != CAM_REQ_CMP) {
+ xpt_print(periph->path, "%s: lost periph during "
+ "registration!\n", __func__);
+ cam_periph_lock(periph);
+ return (CAM_REQ_CMP_ERR);
+ }
+ disk_create(softc->disk, DISK_VERSION);
+ cam_periph_lock(periph);
+ cam_periph_unhold(periph);
+
+ snprintf(announce_buf, sizeof(announce_buf),
+ "%juMB (%ju %u byte sectors)",
+ (uintmax_t)((uintmax_t)disk->d_mediasize / (1024*1024)),
+ (uintmax_t)disk->d_mediasize / disk->d_sectorsize,
+ disk->d_sectorsize);
+ xpt_announce_periph(periph, announce_buf);
+ xpt_announce_quirks(periph, softc->quirks, NDA_Q_BIT_STRING);
+
+ /*
+ * Create our sysctl variables, now that we know
+ * we have successfully attached.
+ */
+ if (cam_periph_acquire(periph) == CAM_REQ_CMP)
+ taskqueue_enqueue(taskqueue_thread, &softc->sysctl_task);
+
+ /*
+ * Register for device going away and info about the drive
+ * changing (though with NVMe, it can't)
+ */
+ xpt_register_async(AC_LOST_DEVICE | AC_ADVINFO_CHANGED,
+ ndaasync, periph, periph->path);
+
+ softc->state = NDA_STATE_NORMAL;
+ return(CAM_REQ_CMP);
+}
+
+static void
+ndastart(struct cam_periph *periph, union ccb *start_ccb)
+{
+ struct nda_softc *softc = (struct nda_softc *)periph->softc;
+ struct ccb_nvmeio *nvmeio = &start_ccb->nvmeio;
+
+ CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("ndastart\n"));
+
+ switch (softc->state) {
+ case NDA_STATE_NORMAL:
+ {
+ struct bio *bp;
+
+ bp = cam_iosched_next_bio(softc->cam_iosched);
+ CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("ndastart: bio %p\n", bp));
+ if (bp == NULL) {
+ xpt_release_ccb(start_ccb);
+ break;
+ }
+
+ switch (bp->bio_cmd) {
+ case BIO_WRITE:
+ softc->flags |= NDA_FLAG_DIRTY;
+ /* FALLTHROUGH */
+ case BIO_READ:
+ {
+#ifdef NDA_TEST_FAILURE
+ int fail = 0;
+
+ /*
+ * Support the failure ioctls. If the command is a
+ * read, and there are pending forced read errors, or
+ * if a write and pending write errors, then fail this
+ * operation with EIO. This is useful for testing
+ * purposes. Also, support having every Nth read fail.
+ *
+ * This is a rather blunt tool.
+ */
+ if (bp->bio_cmd == BIO_READ) {
+ if (softc->force_read_error) {
+ softc->force_read_error--;
+ fail = 1;
+ }
+ if (softc->periodic_read_error > 0) {
+ if (++softc->periodic_read_count >=
+ softc->periodic_read_error) {
+ softc->periodic_read_count = 0;
+ fail = 1;
+ }
+ }
+ } else {
+ if (softc->force_write_error) {
+ softc->force_write_error--;
+ fail = 1;
+ }
+ }
+ if (fail) {
+ biofinish(bp, NULL, EIO);
+ xpt_release_ccb(start_ccb);
+ ndaschedule(periph);
+ return;
+ }
+#endif
+ KASSERT((bp->bio_flags & BIO_UNMAPPED) == 0 ||
+ round_page(bp->bio_bcount + bp->bio_ma_offset) /
+ PAGE_SIZE == bp->bio_ma_n,
+ ("Short bio %p", bp));
+ nda_nvme_rw_bio(softc, &start_ccb->nvmeio, bp, bp->bio_cmd == BIO_READ ?
+ NVME_OPC_READ : NVME_OPC_WRITE);
+ break;
+ }
+ case BIO_DELETE:
+ {
+ struct nvme_dsm_range *dsm_range;
+
+ dsm_range =
+ malloc(sizeof(*dsm_range), M_NVMEDA, M_ZERO | M_WAITOK);
+ dsm_range->length =
+ bp->bio_bcount / softc->disk->d_sectorsize;
+ dsm_range->starting_lba =
+ bp->bio_offset / softc->disk->d_sectorsize;
+ bp->bio_driver2 = dsm_range;
+ nda_nvme_trim(softc, &start_ccb->nvmeio, dsm_range, 1);
+ start_ccb->ccb_h.ccb_state = NDA_CCB_TRIM;
+ start_ccb->ccb_h.flags |= CAM_UNLOCKED;
+ cam_iosched_submit_trim(softc->cam_iosched); /* XXX */
+ goto out;
+ }
+ case BIO_FLUSH:
+ nda_nvme_flush(softc, nvmeio);
+ break;
+ }
+ start_ccb->ccb_h.ccb_state = NDA_CCB_BUFFER_IO;
+ start_ccb->ccb_h.flags |= CAM_UNLOCKED;
+out:
+ start_ccb->ccb_h.ccb_bp = bp;
+ softc->outstanding_cmds++;
+ softc->refcount++;
+ cam_periph_unlock(periph);
+ xpt_action(start_ccb);
+ cam_periph_lock(periph);
+ softc->refcount--;
+
+ /* May have more work to do, so ensure we stay scheduled */
+ ndaschedule(periph);
+ break;
+ }
+ }
+}
+
+static void
+ndadone(struct cam_periph *periph, union ccb *done_ccb)
+{
+ struct nda_softc *softc;
+ struct ccb_nvmeio *nvmeio = &done_ccb->nvmeio;
+ struct cam_path *path;
+ int state;
+
+ softc = (struct nda_softc *)periph->softc;
+ path = done_ccb->ccb_h.path;
+
+ CAM_DEBUG(path, CAM_DEBUG_TRACE, ("ndadone\n"));
+
+ state = nvmeio->ccb_h.ccb_state & NDA_CCB_TYPE_MASK;
+ switch (state) {
+ case NDA_CCB_BUFFER_IO:
+ case NDA_CCB_TRIM:
+ {
+ struct bio *bp;
+ int error;
+
+ cam_periph_lock(periph);
+ bp = (struct bio *)done_ccb->ccb_h.ccb_bp;
+ if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
+ error = ndaerror(done_ccb, 0, 0);
+ if (error == ERESTART) {
+ /* A retry was scheduled, so just return. */
+ cam_periph_unlock(periph);
+ return;
+ }
+ if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0)
+ cam_release_devq(path,
+ /*relsim_flags*/0,
+ /*reduction*/0,
+ /*timeout*/0,
+ /*getcount_only*/0);
+ } else {
+ if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0)
+ panic("REQ_CMP with QFRZN");
+ error = 0;
+ }
+ bp->bio_error = error;
+ if (error != 0) {
+ bp->bio_resid = bp->bio_bcount;
+ bp->bio_flags |= BIO_ERROR;
+ } else {
+ if (state == NDA_CCB_TRIM)
+ bp->bio_resid = 0;
+ else
+ bp->bio_resid = nvmeio->resid;
+ if (bp->bio_resid > 0)
+ bp->bio_flags |= BIO_ERROR;
+ }
+ if (state == NDA_CCB_TRIM)
+ free(bp->bio_driver2, M_NVMEDA);
+ softc->outstanding_cmds--;
+
+ cam_iosched_bio_complete(softc->cam_iosched, bp, done_ccb);
+ xpt_release_ccb(done_ccb);
+ if (state == NDA_CCB_TRIM) {
+#ifdef notyet
+ TAILQ_HEAD(, bio) queue;
+ struct bio *bp1;
+
+ TAILQ_INIT(&queue);
+ TAILQ_CONCAT(&queue, &softc->trim_req.bps, bio_queue);
+#endif
+ cam_iosched_trim_done(softc->cam_iosched);
+ ndaschedule(periph);
+ cam_periph_unlock(periph);
+#ifdef notyet
+/* Not yet collapsing several BIO_DELETE requests into one TRIM */
+ while ((bp1 = TAILQ_FIRST(&queue)) != NULL) {
+ TAILQ_REMOVE(&queue, bp1, bio_queue);
+ bp1->bio_error = error;
+ if (error != 0) {
+ bp1->bio_flags |= BIO_ERROR;
+ bp1->bio_resid = bp1->bio_bcount;
+ } else
+ bp1->bio_resid = 0;
+ biodone(bp1);
+ }
+#else
+ biodone(bp);
+#endif
+ } else {
+ ndaschedule(periph);
+ cam_periph_unlock(periph);
+ biodone(bp);
+ }
+ return;
+ }
+ case NDA_CCB_DUMP:
+ /* No-op. We're polling */
+ return;
+ default:
+ break;
+ }
+ xpt_release_ccb(done_ccb);
+}
+
+static int
+ndaerror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags)
+{
+ struct nda_softc *softc;
+ struct cam_periph *periph;
+
+ periph = xpt_path_periph(ccb->ccb_h.path);
+ softc = (struct nda_softc *)periph->softc;
+
+ switch (ccb->ccb_h.status & CAM_STATUS_MASK) {
+ case CAM_CMD_TIMEOUT:
+#ifdef CAM_IO_STATS
+ softc->timeouts++;
+#endif
+ break;
+ case CAM_REQ_ABORTED:
+ case CAM_REQ_CMP_ERR:
+ case CAM_REQ_TERMIO:
+ case CAM_UNREC_HBA_ERROR:
+ case CAM_DATA_RUN_ERR:
+ case CAM_ATA_STATUS_ERROR:
+#ifdef CAM_IO_STATS
+ softc->errors++;
+#endif
+ break;
+ default:
+ break;
+ }
+
+ return(cam_periph_error(ccb, cam_flags, sense_flags, NULL));
+}
+
+/*
+ * Step through all NDA peripheral drivers, and if the device is still open,
+ * sync the disk cache to physical media.
+ */
+static void
+ndaflush(void)
+{
+ struct cam_periph *periph;
+ struct nda_softc *softc;
+ union ccb *ccb;
+ int error;
+
+ CAM_PERIPH_FOREACH(periph, &ndadriver) {
+ softc = (struct nda_softc *)periph->softc;
+ if (SCHEDULER_STOPPED()) {
+ /* If we paniced with the lock held, do not recurse. */
+ if (!cam_periph_owned(periph) &&
+ (softc->flags & NDA_FLAG_OPEN)) {
+ ndadump(softc->disk, NULL, 0, 0, 0);
+ }
+ continue;
+ }
+ cam_periph_lock(periph);
+ /*
+ * We only sync the cache if the drive is still open, and
+ * if the drive is capable of it..
+ */
+ if ((softc->flags & NDA_FLAG_OPEN) == 0) {
+ cam_periph_unlock(periph);
+ continue;
+ }
+
+ ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
+ nda_nvme_flush(softc, &ccb->nvmeio);
+ error = cam_periph_runccb(ccb, ndaerror, /*cam_flags*/0,
+ /*sense_flags*/ SF_NO_RECOVERY | SF_NO_RETRY,
+ softc->disk->d_devstat);
+ if (error != 0)
+ xpt_print(periph->path, "Synchronize cache failed\n");
+ xpt_release_ccb(ccb);
+ cam_periph_unlock(periph);
+ }
+}
+
+static void
+ndashutdown(void *arg, int howto)
+{
+
+ ndaflush();
+}
+
+static void
+ndasuspend(void *arg)
+{
+
+ ndaflush();
+}
diff --git a/sys/cam/nvme/nvme_xpt.c b/sys/cam/nvme/nvme_xpt.c
new file mode 100644
index 0000000..8410fc3
--- /dev/null
+++ b/sys/cam/nvme/nvme_xpt.c
@@ -0,0 +1,607 @@
+/*-
+ * Copyright (c) 2015 Netflix, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer,
+ * without modification, immediately at the beginning of the file.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * derived from ata_xpt.c: Copyright (c) 2009 Alexander Motin <mav@FreeBSD.org>
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/endian.h>
+#include <sys/systm.h>
+#include <sys/types.h>
+#include <sys/malloc.h>
+#include <sys/kernel.h>
+#include <sys/time.h>
+#include <sys/conf.h>
+#include <sys/fcntl.h>
+#include <sys/interrupt.h>
+#include <sys/sbuf.h>
+
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/sysctl.h>
+
+#include <cam/cam.h>
+#include <cam/cam_ccb.h>
+#include <cam/cam_queue.h>
+#include <cam/cam_periph.h>
+#include <cam/cam_sim.h>
+#include <cam/cam_xpt.h>
+#include <cam/cam_xpt_sim.h>
+#include <cam/cam_xpt_periph.h>
+#include <cam/cam_xpt_internal.h>
+#include <cam/cam_debug.h>
+
+#include <cam/scsi/scsi_all.h>
+#include <cam/scsi/scsi_message.h>
+#include <cam/nvme/nvme_all.h>
+#include <machine/stdarg.h> /* for xpt_print below */
+#include "opt_cam.h"
+
+struct nvme_quirk_entry {
+ u_int quirks;
+#define CAM_QUIRK_MAXTAGS 1
+ u_int mintags;
+ u_int maxtags;
+};
+
+/* Not even sure why we need this */
+static periph_init_t nvme_probe_periph_init;
+
+static struct periph_driver nvme_probe_driver =
+{
+ nvme_probe_periph_init, "nvme_probe",
+ TAILQ_HEAD_INITIALIZER(nvme_probe_driver.units), /* generation */ 0,
+ CAM_PERIPH_DRV_EARLY
+};
+
+PERIPHDRIVER_DECLARE(nvme_probe, nvme_probe_driver);
+
+typedef enum {
+ NVME_PROBE_IDENTIFY,
+ NVME_PROBE_DONE,
+ NVME_PROBE_INVALID,
+ NVME_PROBE_RESET
+} nvme_probe_action;
+
+static char *nvme_probe_action_text[] = {
+ "NVME_PROBE_IDENTIFY",
+ "NVME_PROBE_DONE",
+ "NVME_PROBE_INVALID",
+ "NVME_PROBE_RESET",
+};
+
+#define NVME_PROBE_SET_ACTION(softc, newaction) \
+do { \
+ char **text; \
+ text = nvme_probe_action_text; \
+ CAM_DEBUG((softc)->periph->path, CAM_DEBUG_PROBE, \
+ ("Probe %s to %s\n", text[(softc)->action], \
+ text[(newaction)])); \
+ (softc)->action = (newaction); \
+} while(0)
+
+typedef enum {
+ NVME_PROBE_NO_ANNOUNCE = 0x04
+} nvme_probe_flags;
+
+typedef struct {
+ TAILQ_HEAD(, ccb_hdr) request_ccbs;
+ nvme_probe_action action;
+ nvme_probe_flags flags;
+ int restart;
+ struct cam_periph *periph;
+} nvme_probe_softc;
+
+static struct nvme_quirk_entry nvme_quirk_table[] =
+{
+ {
+// {
+// T_ANY, SIP_MEDIA_REMOVABLE|SIP_MEDIA_FIXED,
+// /*vendor*/"*", /*product*/"*", /*revision*/"*"
+// },
+ .quirks = 0, .mintags = 0, .maxtags = 0
+ },
+};
+
+static const int nvme_quirk_table_size =
+ sizeof(nvme_quirk_table) / sizeof(*nvme_quirk_table);
+
+static cam_status nvme_probe_register(struct cam_periph *periph,
+ void *arg);
+static void nvme_probe_schedule(struct cam_periph *nvme_probe_periph);
+static void nvme_probe_start(struct cam_periph *periph, union ccb *start_ccb);
+static void nvme_probe_cleanup(struct cam_periph *periph);
+//static void nvme_find_quirk(struct cam_ed *device);
+static void nvme_scan_lun(struct cam_periph *periph,
+ struct cam_path *path, cam_flags flags,
+ union ccb *ccb);
+static struct cam_ed *
+ nvme_alloc_device(struct cam_eb *bus, struct cam_et *target,
+ lun_id_t lun_id);
+static void nvme_device_transport(struct cam_path *path);
+static void nvme_dev_async(u_int32_t async_code,
+ struct cam_eb *bus,
+ struct cam_et *target,
+ struct cam_ed *device,
+ void *async_arg);
+static void nvme_action(union ccb *start_ccb);
+static void nvme_announce_periph(struct cam_periph *periph);
+
+static struct xpt_xport nvme_xport = {
+ .alloc_device = nvme_alloc_device,
+ .action = nvme_action,
+ .async = nvme_dev_async,
+ .announce = nvme_announce_periph,
+};
+
+struct xpt_xport *
+nvme_get_xport(void)
+{
+ return (&nvme_xport);
+}
+
+static void
+nvme_probe_periph_init()
+{
+ printf("nvme cam probe device init\n");
+}
+
+static cam_status
+nvme_probe_register(struct cam_periph *periph, void *arg)
+{
+ union ccb *request_ccb; /* CCB representing the probe request */
+ cam_status status;
+ nvme_probe_softc *softc;
+
+ request_ccb = (union ccb *)arg;
+ if (request_ccb == NULL) {
+ printf("nvme_probe_register: no probe CCB, "
+ "can't register device\n");
+ return(CAM_REQ_CMP_ERR);
+ }
+
+ softc = (nvme_probe_softc *)malloc(sizeof(*softc), M_CAMXPT, M_ZERO | M_NOWAIT);
+
+ if (softc == NULL) {
+ printf("nvme_probe_register: Unable to probe new device. "
+ "Unable to allocate softc\n");
+ return(CAM_REQ_CMP_ERR);
+ }
+ TAILQ_INIT(&softc->request_ccbs);
+ TAILQ_INSERT_TAIL(&softc->request_ccbs, &request_ccb->ccb_h,
+ periph_links.tqe);
+ softc->flags = 0;
+ periph->softc = softc;
+ softc->periph = periph;
+ softc->action = NVME_PROBE_INVALID;
+ status = cam_periph_acquire(periph);
+ if (status != CAM_REQ_CMP) {
+ return (status);
+ }
+ CAM_DEBUG(periph->path, CAM_DEBUG_PROBE, ("Probe started\n"));
+
+// nvme_device_transport(periph->path);
+ nvme_probe_schedule(periph);
+
+ return(CAM_REQ_CMP);
+}
+
+static void
+nvme_probe_schedule(struct cam_periph *periph)
+{
+ union ccb *ccb;
+ nvme_probe_softc *softc;
+
+ softc = (nvme_probe_softc *)periph->softc;
+ ccb = (union ccb *)TAILQ_FIRST(&softc->request_ccbs);
+
+ NVME_PROBE_SET_ACTION(softc, NVME_PROBE_IDENTIFY);
+
+ if (ccb->crcn.flags & CAM_EXPECT_INQ_CHANGE)
+ softc->flags |= NVME_PROBE_NO_ANNOUNCE;
+ else
+ softc->flags &= ~NVME_PROBE_NO_ANNOUNCE;
+
+ xpt_schedule(periph, CAM_PRIORITY_XPT);
+}
+
+static void
+nvme_probe_start(struct cam_periph *periph, union ccb *start_ccb)
+{
+ struct ccb_nvmeio *nvmeio;
+ struct ccb_scsiio *csio;
+ nvme_probe_softc *softc;
+ struct cam_path *path;
+ const struct nvme_namespace_data *nvme_data;
+ lun_id_t lun;
+
+ CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("nvme_probe_start\n"));
+
+ softc = (nvme_probe_softc *)periph->softc;
+ path = start_ccb->ccb_h.path;
+ nvmeio = &start_ccb->nvmeio;
+ csio = &start_ccb->csio;
+ nvme_data = periph->path->device->nvme_data;
+
+ if (softc->restart) {
+ softc->restart = 0;
+ if (periph->path->device->flags & CAM_DEV_UNCONFIGURED)
+ NVME_PROBE_SET_ACTION(softc, NVME_PROBE_RESET);
+ else
+ NVME_PROBE_SET_ACTION(softc, NVME_PROBE_IDENTIFY);
+ }
+
+ /*
+ * Other transports have to ask their SIM to do a lot of action.
+ * NVMe doesn't, so don't do the dance. Just do things
+ * directly.
+ */
+ switch (softc->action) {
+ case NVME_PROBE_RESET:
+ /* FALLTHROUGH */
+ case NVME_PROBE_IDENTIFY:
+ nvme_device_transport(path);
+ /*
+ * Test for lun == CAM_LUN_WILDCARD is lame, but
+ * appears to be necessary here. XXX
+ */
+ lun = xpt_path_lun_id(periph->path);
+ if (lun == CAM_LUN_WILDCARD ||
+ periph->path->device->flags & CAM_DEV_UNCONFIGURED) {
+ path->device->flags &= ~CAM_DEV_UNCONFIGURED;
+ xpt_acquire_device(path->device);
+ start_ccb->ccb_h.func_code = XPT_GDEV_TYPE;
+ xpt_action(start_ccb);
+ xpt_async(AC_FOUND_DEVICE, path, start_ccb);
+ }
+ NVME_PROBE_SET_ACTION(softc, NVME_PROBE_DONE);
+ break;
+ default:
+ panic("nvme_probe_start: invalid action state 0x%x\n", softc->action);
+ }
+ /*
+ * Probing is now done. We need to complete any lingering items
+ * in the queue, though there shouldn't be any.
+ */
+ xpt_release_ccb(start_ccb);
+ CAM_DEBUG(periph->path, CAM_DEBUG_PROBE, ("Probe completed\n"));
+ while ((start_ccb = (union ccb *)TAILQ_FIRST(&softc->request_ccbs))) {
+ TAILQ_REMOVE(&softc->request_ccbs,
+ &start_ccb->ccb_h, periph_links.tqe);
+ start_ccb->ccb_h.status = CAM_REQ_CMP;
+ xpt_done(start_ccb);
+ }
+// XXX not sure I need this
+// XXX unlike other XPTs, we never freeze the queue since we have a super-simple
+// XXX state machine
+ /* Drop freeze taken due to CAM_DEV_QFREEZE flag set. -- did we really do this? */
+// cam_release_devq(path, 0, 0, 0, FALSE);
+ cam_periph_invalidate(periph);
+ cam_periph_release_locked(periph);
+}
+
+static void
+nvme_probe_cleanup(struct cam_periph *periph)
+{
+ free(periph->softc, M_CAMXPT);
+}
+
+#if 0
+/* XXX should be used, don't delete */
+static void
+nvme_find_quirk(struct cam_ed *device)
+{
+ struct nvme_quirk_entry *quirk;
+ caddr_t match;
+
+ match = cam_quirkmatch((caddr_t)&device->nvme_data,
+ (caddr_t)nvme_quirk_table,
+ nvme_quirk_table_size,
+ sizeof(*nvme_quirk_table), nvme_identify_match);
+
+ if (match == NULL)
+ panic("xpt_find_quirk: device didn't match wildcard entry!!");
+
+ quirk = (struct nvme_quirk_entry *)match;
+ device->quirk = quirk;
+ if (quirk->quirks & CAM_QUIRK_MAXTAGS) {
+ device->mintags = quirk->mintags;
+ device->maxtags = quirk->maxtags;
+ }
+}
+#endif
+
+static void
+nvme_scan_lun(struct cam_periph *periph, struct cam_path *path,
+ cam_flags flags, union ccb *request_ccb)
+{
+ struct ccb_pathinq cpi;
+ cam_status status;
+ struct cam_periph *old_periph;
+ int lock;
+
+ CAM_DEBUG(path, CAM_DEBUG_TRACE, ("nvme_scan_lun\n"));
+
+ xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NONE);
+ cpi.ccb_h.func_code = XPT_PATH_INQ;
+ xpt_action((union ccb *)&cpi);
+
+ if (cpi.ccb_h.status != CAM_REQ_CMP) {
+ if (request_ccb != NULL) {
+ request_ccb->ccb_h.status = cpi.ccb_h.status;
+ xpt_done(request_ccb);
+ }
+ return;
+ }
+
+ if (xpt_path_lun_id(path) == CAM_LUN_WILDCARD) {
+ CAM_DEBUG(path, CAM_DEBUG_TRACE, ("nvme_scan_lun ignoring bus\n"));
+ request_ccb->ccb_h.status = CAM_REQ_CMP; /* XXX signal error ? */
+ xpt_done(request_ccb);
+ return;
+ }
+
+ lock = (xpt_path_owned(path) == 0);
+ if (lock)
+ xpt_path_lock(path);
+ if ((old_periph = cam_periph_find(path, "nvme_probe")) != NULL) {
+ if ((old_periph->flags & CAM_PERIPH_INVALID) == 0) {
+ nvme_probe_softc *softc;
+
+ softc = (nvme_probe_softc *)old_periph->softc;
+ TAILQ_INSERT_TAIL(&softc->request_ccbs,
+ &request_ccb->ccb_h, periph_links.tqe);
+ softc->restart = 1;
+ CAM_DEBUG(path, CAM_DEBUG_TRACE,
+ ("restarting nvme_probe device\n"));
+ } else {
+ request_ccb->ccb_h.status = CAM_REQ_CMP_ERR;
+ CAM_DEBUG(path, CAM_DEBUG_TRACE,
+ ("Failing to restart nvme_probe device\n"));
+ xpt_done(request_ccb);
+ }
+ } else {
+ CAM_DEBUG(path, CAM_DEBUG_TRACE,
+ ("Adding nvme_probe device\n"));
+ status = cam_periph_alloc(nvme_probe_register, NULL, nvme_probe_cleanup,
+ nvme_probe_start, "nvme_probe",
+ CAM_PERIPH_BIO,
+ request_ccb->ccb_h.path, NULL, 0,
+ request_ccb);
+
+ if (status != CAM_REQ_CMP) {
+ xpt_print(path, "xpt_scan_lun: cam_alloc_periph "
+ "returned an error, can't continue probe\n");
+ request_ccb->ccb_h.status = status;
+ xpt_done(request_ccb);
+ }
+ }
+ if (lock)
+ xpt_path_unlock(path);
+}
+
+static struct cam_ed *
+nvme_alloc_device(struct cam_eb *bus, struct cam_et *target, lun_id_t lun_id)
+{
+ struct nvme_quirk_entry *quirk;
+ struct cam_ed *device;
+
+ device = xpt_alloc_device(bus, target, lun_id);
+ if (device == NULL)
+ return (NULL);
+
+ /*
+ * Take the default quirk entry until we have inquiry
+ * data from nvme and can determine a better quirk to use.
+ */
+ quirk = &nvme_quirk_table[nvme_quirk_table_size - 1];
+ device->quirk = (void *)quirk;
+ device->mintags = 0;
+ device->maxtags = 0;
+ device->inq_flags = 0;
+ device->queue_flags = 0;
+ device->device_id = NULL; /* XXX Need to set this somewhere */
+ device->device_id_len = 0;
+ device->serial_num = NULL; /* XXX Need to set this somewhere */
+ device->serial_num_len = 0;
+ return (device);
+}
+
+static void
+nvme_device_transport(struct cam_path *path)
+{
+ struct ccb_pathinq cpi;
+ struct ccb_trans_settings cts;
+ /* XXX get data from nvme namespace and other info ??? */
+
+ /* Get transport information from the SIM */
+ xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NONE);
+ cpi.ccb_h.func_code = XPT_PATH_INQ;
+ xpt_action((union ccb *)&cpi);
+
+ path->device->transport = cpi.transport;
+ path->device->transport_version = cpi.transport_version;
+
+ path->device->protocol = cpi.protocol;
+ path->device->protocol_version = cpi.protocol_version;
+
+ /* Tell the controller what we think */
+ xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NONE);
+ cts.ccb_h.func_code = XPT_SET_TRAN_SETTINGS;
+ cts.type = CTS_TYPE_CURRENT_SETTINGS;
+ cts.transport = path->device->transport;
+ cts.transport_version = path->device->transport_version;
+ cts.protocol = path->device->protocol;
+ cts.protocol_version = path->device->protocol_version;
+ cts.proto_specific.valid = 0;
+ cts.xport_specific.valid = 0;
+ xpt_action((union ccb *)&cts);
+}
+
+static void
+nvme_dev_advinfo(union ccb *start_ccb)
+{
+ struct cam_ed *device;
+ struct ccb_dev_advinfo *cdai;
+ off_t amt;
+
+ start_ccb->ccb_h.status = CAM_REQ_INVALID;
+ device = start_ccb->ccb_h.path->device;
+ cdai = &start_ccb->cdai;
+ switch(cdai->buftype) {
+ case CDAI_TYPE_SCSI_DEVID:
+ if (cdai->flags & CDAI_FLAG_STORE)
+ return;
+ cdai->provsiz = device->device_id_len;
+ if (device->device_id_len == 0)
+ break;
+ amt = device->device_id_len;
+ if (cdai->provsiz > cdai->bufsiz)
+ amt = cdai->bufsiz;
+ memcpy(cdai->buf, device->device_id, amt);
+ break;
+ case CDAI_TYPE_SERIAL_NUM:
+ if (cdai->flags & CDAI_FLAG_STORE)
+ return;
+ cdai->provsiz = device->serial_num_len;
+ if (device->serial_num_len == 0)
+ break;
+ amt = device->serial_num_len;
+ if (cdai->provsiz > cdai->bufsiz)
+ amt = cdai->bufsiz;
+ memcpy(cdai->buf, device->serial_num, amt);
+ break;
+ case CDAI_TYPE_PHYS_PATH:
+ if (cdai->flags & CDAI_FLAG_STORE) {
+ if (device->physpath != NULL)
+ free(device->physpath, M_CAMXPT);
+ device->physpath_len = cdai->bufsiz;
+ /* Clear existing buffer if zero length */
+ if (cdai->bufsiz == 0)
+ break;
+ device->physpath = malloc(cdai->bufsiz, M_CAMXPT, M_NOWAIT);
+ if (device->physpath == NULL) {
+ start_ccb->ccb_h.status = CAM_REQ_ABORTED;
+ return;
+ }
+ memcpy(device->physpath, cdai->buf, cdai->bufsiz);
+ } else {
+ cdai->provsiz = device->physpath_len;
+ if (device->physpath_len == 0)
+ break;
+ amt = device->physpath_len;
+ if (cdai->provsiz > cdai->bufsiz)
+ amt = cdai->bufsiz;
+ memcpy(cdai->buf, device->physpath, amt);
+ }
+ break;
+ default:
+ return;
+ }
+ start_ccb->ccb_h.status = CAM_REQ_CMP;
+
+ if (cdai->flags & CDAI_FLAG_STORE) {
+ xpt_async(AC_ADVINFO_CHANGED, start_ccb->ccb_h.path,
+ (void *)(uintptr_t)cdai->buftype);
+ }
+}
+
+static void
+nvme_action(union ccb *start_ccb)
+{
+ CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_TRACE,
+ ("nvme_action: func= %#x\n", start_ccb->ccb_h.func_code));
+
+ switch (start_ccb->ccb_h.func_code) {
+ case XPT_SCAN_BUS:
+ printf("NVME scan BUS started -- ignored\n");
+// break;
+ case XPT_SCAN_TGT:
+ printf("NVME scan TGT started -- ignored\n");
+// break;
+ case XPT_SCAN_LUN:
+ printf("NVME scan started\n");
+ nvme_scan_lun(start_ccb->ccb_h.path->periph,
+ start_ccb->ccb_h.path, start_ccb->crcn.flags,
+ start_ccb);
+ break;
+ case XPT_DEV_ADVINFO:
+ nvme_dev_advinfo(start_ccb);
+ break;
+
+ default:
+ xpt_action_default(start_ccb);
+ break;
+ }
+}
+
+/*
+ * Handle any per-device event notifications that require action by the XPT.
+ */
+static void
+nvme_dev_async(u_int32_t async_code, struct cam_eb *bus, struct cam_et *target,
+ struct cam_ed *device, void *async_arg)
+{
+
+ /*
+ * We only need to handle events for real devices.
+ */
+ if (target->target_id == CAM_TARGET_WILDCARD
+ || device->lun_id == CAM_LUN_WILDCARD)
+ return;
+
+ if (async_code == AC_LOST_DEVICE &&
+ (device->flags & CAM_DEV_UNCONFIGURED) == 0) {
+ device->flags |= CAM_DEV_UNCONFIGURED;
+ xpt_release_device(device);
+ }
+}
+
+static void
+nvme_announce_periph(struct cam_periph *periph)
+{
+ struct ccb_pathinq cpi;
+ struct ccb_trans_settings cts;
+ struct cam_path *path = periph->path;
+
+ cam_periph_assert(periph, MA_OWNED);
+
+ xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL);
+ cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS;
+ cts.type = CTS_TYPE_CURRENT_SETTINGS;
+ xpt_action((union ccb*)&cts);
+ if ((cts.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)
+ return;
+ /* Ask the SIM for its base transfer speed */
+ xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NORMAL);
+ cpi.ccb_h.func_code = XPT_PATH_INQ;
+ xpt_action((union ccb *)&cpi);
+ /* XXX NVME STUFF HERE */
+ printf("\n");
+}
diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c
index aa05b70..deef952 100644
--- a/sys/cam/scsi/scsi_da.c
+++ b/sys/cam/scsi/scsi_da.c
@@ -2377,6 +2377,7 @@ daregister(struct cam_periph *periph, void *arg)
if (cam_iosched_init(&softc->cam_iosched, periph) != 0) {
printf("daregister: Unable to probe new device. "
"Unable to allocate iosched memory\n");
+ free(softc, M_DEVBUF);
return(CAM_REQ_CMP_ERR);
}
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
index 3bb9146..cdc8009 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
@@ -2249,6 +2249,7 @@ arc_buf_l2_cdata_free(arc_buf_hdr_t *hdr)
ASSERT3P(hdr->b_l1hdr.b_tmp_cdata, ==,
hdr->b_l1hdr.b_buf->b_data);
ASSERT3U(hdr->b_l2hdr.b_compress, ==, ZIO_COMPRESS_OFF);
+ hdr->b_l1hdr.b_tmp_cdata = NULL;
return;
}
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
index a987138..c632618 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
@@ -7170,16 +7170,24 @@ zfs_vptocnp(struct vop_vptocnp_args *ap)
int ltype;
int error;
+ ZFS_ENTER(zfsvfs);
+ ZFS_VERIFY_ZP(zp);
+
/*
* If we are a snapshot mounted under .zfs, run the operation
* on the covered vnode.
*/
if ((error = sa_lookup(zp->z_sa_hdl,
- SA_ZPL_PARENT(zfsvfs), &parent, sizeof (parent))) != 0)
+ SA_ZPL_PARENT(zfsvfs), &parent, sizeof (parent))) != 0) {
+ ZFS_EXIT(zfsvfs);
return (error);
+ }
- if (zp->z_id != parent || zfsvfs->z_parent == zfsvfs)
+ if (zp->z_id != parent || zfsvfs->z_parent == zfsvfs) {
+ ZFS_EXIT(zfsvfs);
return (vop_stdvptocnp(ap));
+ }
+ ZFS_EXIT(zfsvfs);
covered_vp = vp->v_mount->mnt_vnodecovered;
vhold(covered_vp);
diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c
index 2cd665a..56b2ade 100644
--- a/sys/compat/linprocfs/linprocfs.c
+++ b/sys/compat/linprocfs/linprocfs.c
@@ -490,7 +490,6 @@ linprocfs_doswaps(PFS_FILL_ARGS)
char devname[SPECNAMELEN + 1];
sbuf_printf(sb, "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
- mtx_lock(&Giant);
for (n = 0; ; n++) {
if (swap_dev_info(n, &xsw, devname, sizeof(devname)) != 0)
break;
@@ -504,7 +503,6 @@ linprocfs_doswaps(PFS_FILL_ARGS)
sbuf_printf(sb, "/dev/%-34s unknown\t\t%jd\t%jd\t-1\n",
devname, total, used);
}
- mtx_unlock(&Giant);
return (0);
}
@@ -1326,13 +1324,13 @@ linprocfs_dofilesystems(PFS_FILL_ARGS)
{
struct vfsconf *vfsp;
- mtx_lock(&Giant);
+ vfsconf_slock();
TAILQ_FOREACH(vfsp, &vfsconf, vfc_list) {
if (vfsp->vfc_flags & VFCF_SYNTHETIC)
sbuf_printf(sb, "nodev");
sbuf_printf(sb, "\t%s\n", vfsp->vfc_name);
}
- mtx_unlock(&Giant);
+ vfsconf_sunlock();
return(0);
}
diff --git a/sys/compat/linuxkpi/common/include/linux/etherdevice.h b/sys/compat/linuxkpi/common/include/linux/etherdevice.h
index c581367..2c4a488 100644
--- a/sys/compat/linuxkpi/common/include/linux/etherdevice.h
+++ b/sys/compat/linuxkpi/common/include/linux/etherdevice.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2015 Mellanox Technologies, Ltd. All rights reserved.
+ * Copyright (c) 2015-2016 Mellanox Technologies, Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -102,7 +102,8 @@ eth_broadcast_addr(u8 *pa)
static inline void
random_ether_addr(u8 * dst)
{
- read_random(dst, 6);
+ if (read_random(dst, 6) == 0)
+ arc4rand(dst, 6, 0);
dst[0] &= 0xfe;
dst[0] |= 0x02;
diff --git a/sys/compat/linuxkpi/common/include/linux/random.h b/sys/compat/linuxkpi/common/include/linux/random.h
index caae7b3..28475ed 100644
--- a/sys/compat/linuxkpi/common/include/linux/random.h
+++ b/sys/compat/linuxkpi/common/include/linux/random.h
@@ -2,7 +2,7 @@
* Copyright (c) 2010 Isilon Systems, Inc.
* Copyright (c) 2010 iX Systems, Inc.
* Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -32,11 +32,13 @@
#define _LINUX_RANDOM_H_
#include <sys/random.h>
+#include <sys/libkern.h>
static inline void
get_random_bytes(void *buf, int nbytes)
{
- read_random(buf, nbytes);
+ if (read_random(buf, nbytes) == 0)
+ arc4rand(buf, nbytes, 0);
}
#endif /* _LINUX_RANDOM_H_ */
diff --git a/sys/compat/linuxkpi/common/src/linux_idr.c b/sys/compat/linuxkpi/common/src/linux_idr.c
index 5a02119..99e45e3 100644
--- a/sys/compat/linuxkpi/common/src/linux_idr.c
+++ b/sys/compat/linuxkpi/common/src/linux_idr.c
@@ -292,7 +292,8 @@ idr_get(struct idr *idr)
return (il);
}
il = malloc(sizeof(*il), M_IDR, M_ZERO | M_NOWAIT);
- bitmap_fill(&il->bitmap, IDR_SIZE);
+ if (il != NULL)
+ bitmap_fill(&il->bitmap, IDR_SIZE);
return (il);
}
diff --git a/sys/conf/files b/sys/conf/files
index a364a62..7982fd7 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -86,6 +86,9 @@ cam/cam_xpt.c optional scbus
cam/ata/ata_all.c optional scbus
cam/ata/ata_xpt.c optional scbus
cam/ata/ata_pmp.c optional scbus
+cam/nvme/nvme_all.c optional scbus nvme
+cam/nvme/nvme_da.c optional scbus nvme da !nvd
+cam/nvme/nvme_xpt.c optional scbus nvme
cam/scsi/scsi_xpt.c optional scbus
cam/scsi/scsi_all.c optional scbus
cam/scsi/scsi_cd.c optional cd
diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64
index 53c299f..4949d71 100644
--- a/sys/conf/files.amd64
+++ b/sys/conf/files.amd64
@@ -290,6 +290,7 @@ dev/nvme/nvme_ctrlr_cmd.c optional nvme
dev/nvme/nvme_ns.c optional nvme
dev/nvme/nvme_ns_cmd.c optional nvme
dev/nvme/nvme_qpair.c optional nvme
+dev/nvme/nvme_sim.c optional nvme scbus !nvd
dev/nvme/nvme_sysctl.c optional nvme
dev/nvme/nvme_test.c optional nvme
dev/nvme/nvme_util.c optional nvme
diff --git a/sys/conf/kern.opts.mk b/sys/conf/kern.opts.mk
index 7b8f11c..343b4f8 100644
--- a/sys/conf/kern.opts.mk
+++ b/sys/conf/kern.opts.mk
@@ -45,6 +45,7 @@ __DEFAULT_YES_OPTIONS = \
__DEFAULT_NO_OPTIONS = \
EISA \
+ EXTRA_TCP_STACKS \
NAND \
OFED
diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk
index 70abb10..8c5a713 100644
--- a/sys/conf/kern.post.mk
+++ b/sys/conf/kern.post.mk
@@ -23,6 +23,10 @@ MKMODULESENV+= CONF_CFLAGS="${CONF_CFLAGS}"
MKMODULESENV+= WITH_CTF="${WITH_CTF}"
.endif
+.if defined(WITH_EXTRA_TCP_STACKS)
+MKMODULESENV+= WITH_EXTRA_TCP_STACKS="${WITH_EXTRA_TCP_STACKS}"
+.endif
+
# Allow overriding the kernel debug directory, so kernel and user debug may be
# installed in different directories. Setting it to "" restores the historical
# behavior of installing debug files in the kernel directory.
diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh
index c011b6e..2d89104 100644
--- a/sys/conf/newvers.sh
+++ b/sys/conf/newvers.sh
@@ -32,7 +32,7 @@
TYPE="FreeBSD"
REVISION="11.0"
-BRANCH="ALPHA2"
+BRANCH="ALPHA3"
if [ -n "${BRANCH_OVERRIDE}" ]; then
BRANCH=${BRANCH_OVERRIDE}
fi
diff --git a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h
index eccafba..8dfc690 100644
--- a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h
+++ b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h
@@ -898,6 +898,8 @@ struct ath_hal_9300 {
struct ar9300NfLimits nf_2GHz;
struct ar9300NfLimits nf_5GHz;
struct ar9300NfLimits *nfp;
+
+ uint32_t ah_beaconInterval;
};
#define AH9300(_ah) ((struct ath_hal_9300 *)(_ah))
diff --git a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.c b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.c
index e914057..0e12a3d 100644
--- a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.c
+++ b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_freebsd.c
@@ -774,8 +774,7 @@ ar9300_beacon_set_beacon_timers(struct ath_hal *ah,
OS_REG_WRITE(ah, AR_NEXT_NDP_TIMER, TU_TO_USEC(bt->bt_nextatim));
bperiod = TU_TO_USEC(bt->bt_intval & HAL_BEACON_PERIOD);
- /* XXX TODO! */
-// ahp->ah_beaconInterval = bt->bt_intval & HAL_BEACON_PERIOD;
+ AH9300(ah)->ah_beaconInterval = bt->bt_intval & HAL_BEACON_PERIOD;
OS_REG_WRITE(ah, AR_BEACON_PERIOD, bperiod);
OS_REG_WRITE(ah, AR_DMA_BEACON_PERIOD, bperiod);
OS_REG_WRITE(ah, AR_SWBA_PERIOD, bperiod);
diff --git a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_xmit.c b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_xmit.c
index 530b29a..f6ae73e 100644
--- a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_xmit.c
+++ b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_xmit.c
@@ -288,6 +288,7 @@ ar9300_reset_tx_queue(struct ath_hal *ah, u_int q)
const struct ieee80211_channel *chan = AH_PRIVATE(ah)->ah_curchan;
HAL_TX_QUEUE_INFO *qi;
u_int32_t cw_min, chan_cw_min, value;
+ uint32_t qmisc, dmisc;
if (q >= p_cap->halTotalQueues) {
HALDEBUG(ah, HAL_DEBUG_QUEUE, "%s: invalid queue num %u\n", __func__, q);
@@ -335,17 +336,15 @@ ar9300_reset_tx_queue(struct ath_hal *ah, u_int q)
SM(qi->tqi_shretry, AR_D_RETRY_LIMIT_FR_SH));
/* enable early termination on the QCU */
- OS_REG_WRITE(ah, AR_QMISC(q), AR_Q_MISC_DCU_EARLY_TERM_REQ);
+ qmisc = AR_Q_MISC_DCU_EARLY_TERM_REQ;
/* enable DCU to wait for next fragment from QCU */
if (AR_SREV_WASP(ah) && (AH_PRIVATE((ah))->ah_macRev <= AR_SREV_REVISION_WASP_12)) {
/* WAR for EV#85395: Wasp Rx overrun issue - reduces Tx queue backoff
* threshold to 1 to avoid Rx overruns - Fixed in Wasp 1.3 */
- OS_REG_WRITE(ah, AR_DMISC(q),
- AR_D_MISC_CW_BKOFF_EN | AR_D_MISC_FRAG_WAIT_EN | 0x1);
+ dmisc = AR_D_MISC_CW_BKOFF_EN | AR_D_MISC_FRAG_WAIT_EN | 0x1;
} else {
- OS_REG_WRITE(ah, AR_DMISC(q),
- AR_D_MISC_CW_BKOFF_EN | AR_D_MISC_FRAG_WAIT_EN | 0x2);
+ dmisc = AR_D_MISC_CW_BKOFF_EN | AR_D_MISC_FRAG_WAIT_EN | 0x2;
}
/* multiqueue support */
@@ -355,11 +354,9 @@ ar9300_reset_tx_queue(struct ath_hal *ah, u_int q)
SM(qi->tqi_cbrPeriod, AR_Q_CBRCFG_INTERVAL) |
SM(qi->tqi_cbrOverflowLimit,
AR_Q_CBRCFG_OVF_THRESH));
- OS_REG_WRITE(ah, AR_QMISC(q),
- OS_REG_READ(ah, AR_QMISC(q)) |
- AR_Q_MISC_FSP_CBR |
+ qmisc |= AR_Q_MISC_FSP_CBR |
(qi->tqi_cbrOverflowLimit ?
- AR_Q_MISC_CBR_EXP_CNTR_LIMIT_EN : 0));
+ AR_Q_MISC_CBR_EXP_CNTR_LIMIT_EN : 0);
}
if (qi->tqi_readyTime && (qi->tqi_type != HAL_TX_QUEUE_CAB)) {
@@ -374,34 +371,27 @@ ar9300_reset_tx_queue(struct ath_hal *ah, u_int q)
if (qi->tqi_burstTime &&
(qi->tqi_qflags & HAL_TXQ_RDYTIME_EXP_POLICY_ENABLE))
{
- OS_REG_WRITE(ah, AR_QMISC(q), OS_REG_READ(ah, AR_QMISC(q)) |
- AR_Q_MISC_RDYTIME_EXP_POLICY);
+ qmisc |= AR_Q_MISC_RDYTIME_EXP_POLICY;
}
if (qi->tqi_qflags & HAL_TXQ_BACKOFF_DISABLE) {
- OS_REG_WRITE(ah, AR_DMISC(q), OS_REG_READ(ah, AR_DMISC(q)) |
- AR_D_MISC_POST_FR_BKOFF_DIS);
+ dmisc |= AR_D_MISC_POST_FR_BKOFF_DIS;
}
if (qi->tqi_qflags & HAL_TXQ_FRAG_BURST_BACKOFF_ENABLE) {
- OS_REG_WRITE(ah, AR_DMISC(q), OS_REG_READ(ah, AR_DMISC(q)) |
- AR_D_MISC_FRAG_BKOFF_EN);
+ dmisc |= AR_D_MISC_FRAG_BKOFF_EN;
}
switch (qi->tqi_type) {
case HAL_TX_QUEUE_BEACON: /* beacon frames */
- OS_REG_WRITE(ah, AR_QMISC(q),
- OS_REG_READ(ah, AR_QMISC(q))
- | AR_Q_MISC_FSP_DBA_GATED
+ qmisc |= AR_Q_MISC_FSP_DBA_GATED
| AR_Q_MISC_BEACON_USE
- | AR_Q_MISC_CBR_INCR_DIS1);
+ | AR_Q_MISC_CBR_INCR_DIS1;
- OS_REG_WRITE(ah, AR_DMISC(q),
- OS_REG_READ(ah, AR_DMISC(q))
- | (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL <<
+ dmisc |= (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL <<
AR_D_MISC_ARB_LOCKOUT_CNTRL_S)
| AR_D_MISC_BEACON_USE
- | AR_D_MISC_POST_FR_BKOFF_DIS);
+ | AR_D_MISC_POST_FR_BKOFF_DIS;
/* XXX cwmin and cwmax should be 0 for beacon queue */
if (AH_PRIVATE(ah)->ah_opmode != HAL_M_IBSS) {
OS_REG_WRITE(ah, AR_DLCL_IFS(q), SM(0, AR_D_LCL_IFS_CWMIN)
@@ -416,21 +406,36 @@ ar9300_reset_tx_queue(struct ath_hal *ah, u_int q)
* not properly refreshing the Tx descriptor if
* the TXE clear setting is used.
*/
- OS_REG_WRITE(ah, AR_QMISC(q),
- OS_REG_READ(ah, AR_QMISC(q))
- | AR_Q_MISC_FSP_DBA_GATED
+ qmisc |= AR_Q_MISC_FSP_DBA_GATED
| AR_Q_MISC_CBR_INCR_DIS1
- | AR_Q_MISC_CBR_INCR_DIS0);
+ | AR_Q_MISC_CBR_INCR_DIS0;
- value = TU_TO_USEC(qi->tqi_readyTime)
- - (ah->ah_config.ah_sw_beacon_response_time
- - ah->ah_config.ah_dma_beacon_response_time)
- - ah->ah_config.ah_additional_swba_backoff;
- OS_REG_WRITE(ah, AR_QRDYTIMECFG(q), value | AR_Q_RDYTIMECFG_EN);
+ if (qi->tqi_readyTime) {
+ OS_REG_WRITE(ah, AR_QRDYTIMECFG(q),
+ SM(qi->tqi_readyTime, AR_Q_RDYTIMECFG_DURATION) |
+ AR_Q_RDYTIMECFG_EN);
+ } else {
+
+ value = (ahp->ah_beaconInterval * 50 / 100)
+ - ah->ah_config.ah_additional_swba_backoff
+ - ah->ah_config.ah_sw_beacon_response_time
+ + ah->ah_config.ah_dma_beacon_response_time;
+ /*
+ * XXX Ensure it isn't too low - nothing lower
+ * XXX than 10 TU
+ */
+ if (value < 10)
+ value = 10;
+ HALDEBUG(ah, HAL_DEBUG_TXQUEUE,
+ "%s: defaulting to rdytime = %d uS\n",
+ __func__, value);
+ OS_REG_WRITE(ah, AR_QRDYTIMECFG(q),
+ SM(TU_TO_USEC(value), AR_Q_RDYTIMECFG_DURATION) |
+ AR_Q_RDYTIMECFG_EN);
+ }
- OS_REG_WRITE(ah, AR_DMISC(q), OS_REG_READ(ah, AR_DMISC(q))
- | (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL <<
- AR_D_MISC_ARB_LOCKOUT_CNTRL_S));
+ dmisc |= (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL <<
+ AR_D_MISC_ARB_LOCKOUT_CNTRL_S);
break;
case HAL_TX_QUEUE_PSPOLL:
/*
@@ -441,12 +446,10 @@ ar9300_reset_tx_queue(struct ath_hal *ah, u_int q)
* non-TIM elements and send PS-poll PS poll processing
* will be done in software
*/
- OS_REG_WRITE(ah, AR_QMISC(q),
- OS_REG_READ(ah, AR_QMISC(q)) | AR_Q_MISC_CBR_INCR_DIS1);
+ qmisc |= AR_Q_MISC_CBR_INCR_DIS1;
break;
case HAL_TX_QUEUE_UAPSD:
- OS_REG_WRITE(ah, AR_DMISC(q), OS_REG_READ(ah, AR_DMISC(q))
- | AR_D_MISC_POST_FR_BKOFF_DIS);
+ dmisc |= AR_D_MISC_POST_FR_BKOFF_DIS;
break;
default: /* NB: silence compiler */
break;
@@ -461,15 +464,15 @@ ar9300_reset_tx_queue(struct ath_hal *ah, u_int q)
* queue_info->dcumode.
*/
if (qi->tqi_intFlags & HAL_TXQ_USE_LOCKOUT_BKOFF_DIS) {
- OS_REG_WRITE(ah, AR_DMISC(q),
- OS_REG_READ(ah, AR_DMISC(q)) |
- SM(AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL,
+ dmisc |= SM(AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL,
AR_D_MISC_ARB_LOCKOUT_CNTRL) |
- AR_D_MISC_POST_FR_BKOFF_DIS);
+ AR_D_MISC_POST_FR_BKOFF_DIS;
}
#endif
OS_REG_WRITE(ah, AR_Q_DESC_CRCCHK, AR_Q_DESC_CRCCHK_EN);
+ OS_REG_WRITE(ah, AR_QMISC(q), qmisc);
+ OS_REG_WRITE(ah, AR_DMISC(q), dmisc);
/*
* Always update the secondary interrupt mask registers - this
diff --git a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300reg.h b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300reg.h
index a5e0f79..2ec8625 100644
--- a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300reg.h
+++ b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300reg.h
@@ -506,6 +506,7 @@
#define AR_Q0_MISC AR_MAC_QCU_OFFSET(MAC_QCU_MISC)
#define AR_QMISC(_i) (AR_Q0_MISC + ((_i)<<2))
#define AR_Q_MISC_FSP 0x0000000F // Mask for Frame Scheduling Policy
+#define AR_Q_MISC_FSP_S 0
#define AR_Q_MISC_FSP_ASAP 0 // ASAP
#define AR_Q_MISC_FSP_CBR 1 // CBR
#define AR_Q_MISC_FSP_DBA_GATED 2 // DMA Beacon Alert gated
diff --git a/sys/dev/acpica/acpi_thermal.c b/sys/dev/acpica/acpi_thermal.c
index 5b01de5..fa1c2e8 100644
--- a/sys/dev/acpica/acpi_thermal.c
+++ b/sys/dev/acpica/acpi_thermal.c
@@ -311,21 +311,44 @@ acpi_tz_attach(device_t dev)
"thermal sampling period for passive cooling");
/*
- * Create thread to service all of the thermal zones. Register
- * our power profile event handler.
+ * Register our power profile event handler.
*/
sc->tz_event = EVENTHANDLER_REGISTER(power_profile_change,
acpi_tz_power_profile, sc, 0);
- if (acpi_tz_proc == NULL) {
- error = kproc_create(acpi_tz_thread, NULL, &acpi_tz_proc,
- RFHIGHPID, 0, "acpi_thermal");
- if (error != 0) {
- device_printf(sc->tz_dev, "could not create thread - %d", error);
- goto out;
- }
+
+ /*
+ * Flag the event handler for a manual invocation by our timeout.
+ * We defer it like this so that the rest of the subsystem has time
+ * to come up. Don't bother evaluating/printing the temperature at
+ * this point; on many systems it'll be bogus until the EC is running.
+ */
+ sc->tz_flags |= TZ_FLAG_GETPROFILE;
+
+ return_VALUE (0);
+}
+
+static void
+acpi_tz_startup(void *arg __unused)
+{
+ struct acpi_tz_softc *sc;
+ device_t *devs;
+ int devcount, error, i;
+
+ devclass_get_devices(acpi_tz_devclass, &devs, &devcount);
+ if (devcount == 0) {
+ free(devs, M_TEMP);
+ return;
}
/*
+ * Create thread to service all of the thermal zones.
+ */
+ error = kproc_create(acpi_tz_thread, NULL, &acpi_tz_proc, RFHIGHPID, 0,
+ "acpi_thermal");
+ if (error != 0)
+ printf("acpi_tz: could not create thread - %d", error);
+
+ /*
* Create a thread to handle passive cooling for 1st zone which
* has _PSV, _TSP, _TC1 and _TC2. Users can enable it for other
* zones manually for now.
@@ -335,34 +358,22 @@ acpi_tz_attach(device_t dev)
* given frequency whereas it's possible for different thermal
* zones to specify independent settings for multiple CPUs.
*/
- if (acpi_tz_cooling_unit < 0 && acpi_tz_cooling_is_available(sc))
- sc->tz_cooling_enabled = TRUE;
- if (sc->tz_cooling_enabled) {
- error = acpi_tz_cooling_thread_start(sc);
- if (error != 0) {
- sc->tz_cooling_enabled = FALSE;
- goto out;
+ for (i = 0; i < devcount; i++) {
+ sc = device_get_softc(devs[i]);
+ if (acpi_tz_cooling_is_available(sc)) {
+ sc->tz_cooling_enabled = TRUE;
+ error = acpi_tz_cooling_thread_start(sc);
+ if (error != 0) {
+ sc->tz_cooling_enabled = FALSE;
+ break;
+ }
+ acpi_tz_cooling_unit = device_get_unit(devs[i]);
+ break;
}
- acpi_tz_cooling_unit = device_get_unit(dev);
- }
-
- /*
- * Flag the event handler for a manual invocation by our timeout.
- * We defer it like this so that the rest of the subsystem has time
- * to come up. Don't bother evaluating/printing the temperature at
- * this point; on many systems it'll be bogus until the EC is running.
- */
- sc->tz_flags |= TZ_FLAG_GETPROFILE;
-
-out:
- if (error != 0) {
- EVENTHANDLER_DEREGISTER(power_profile_change, sc->tz_event);
- AcpiRemoveNotifyHandler(sc->tz_handle, ACPI_DEVICE_NOTIFY,
- acpi_tz_notify_handler);
- sysctl_ctx_free(&sc->tz_sysctl_ctx);
}
- return_VALUE (error);
+ free(devs, M_TEMP);
}
+SYSINIT(acpi_tz, SI_SUB_KICK_SCHEDULER, SI_ORDER_ANY, acpi_tz_startup, NULL);
/*
* Parse the current state of this thermal zone and set up to use it.
diff --git a/sys/dev/ath/if_ath_alq.h b/sys/dev/ath/if_ath_alq.h
index 9f6ceac..988882d 100644
--- a/sys/dev/ath/if_ath_alq.h
+++ b/sys/dev/ath/if_ath_alq.h
@@ -113,6 +113,14 @@ struct if_ath_alq_mib_counters {
#define ATH_ALQ_STUCK_BEACON 13
#define ATH_ALQ_RESUME_BEACON 14
+#define ATH_ALQ_TX_FIFO_PUSH 15
+struct if_ath_alq_tx_fifo_push {
+ uint32_t txq;
+ uint32_t nframes;
+ uint32_t fifo_depth;
+ uint32_t frame_cnt;
+};
+
/*
* These will always be logged, regardless.
*/
diff --git a/sys/dev/ath/if_ath_sysctl.c b/sys/dev/ath/if_ath_sysctl.c
index ab829df..749285a6a 100644
--- a/sys/dev/ath/if_ath_sysctl.c
+++ b/sys/dev/ath/if_ath_sysctl.c
@@ -1282,6 +1282,9 @@ ath_sysctl_stats_attach(struct ath_softc *sc)
&sc->sc_stats.ast_rx_keymiss, 0, "");
SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_swfiltered", CTLFLAG_RD,
&sc->sc_stats.ast_tx_swfiltered, 0, "");
+ SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_nodeq_overflow",
+ CTLFLAG_RD, &sc->sc_stats.ast_tx_nodeq_overflow, 0,
+ "tx dropped 'cuz nodeq overflow");
SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_stbc",
CTLFLAG_RD, &sc->sc_stats.ast_rx_stbc, 0,
"Number of STBC frames received");
diff --git a/sys/dev/bhnd/bcma/bcma_nexus.c b/sys/dev/bhnd/bcma/bcma_nexus.c
index 7cc8c26..425e110 100644
--- a/sys/dev/bhnd/bcma/bcma_nexus.c
+++ b/sys/dev/bhnd/bcma/bcma_nexus.c
@@ -135,4 +135,5 @@ static device_method_t bcma_nexus_methods[] = {
DEFINE_CLASS_2(bhnd, bcma_nexus_driver, bcma_nexus_methods,
sizeof(struct bcma_nexus_softc), bhnd_nexus_driver, bcma_driver);
-DRIVER_MODULE(bcma_nexus, nexus, bcma_nexus_driver, bhnd_devclass, 0, 0);
+EARLY_DRIVER_MODULE(bcma_nexus, nexus, bcma_nexus_driver, bhnd_devclass, 0, 0,
+ BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);
diff --git a/sys/dev/bhnd/bhnd.h b/sys/dev/bhnd/bhnd.h
index 53215cf..f011237 100644
--- a/sys/dev/bhnd/bhnd.h
+++ b/sys/dev/bhnd/bhnd.h
@@ -232,16 +232,8 @@ struct bhnd_device {
BHND_COREID_ ## _device) }, _desc, _quirks, \
_flags }
-#define BHND_MIPS_DEVICE(_device, _desc, _quirks, ...) \
- _BHND_DEVICE(MIPS, _device, _desc, _quirks, \
- ## __VA_ARGS__, 0)
-
-#define BHND_ARM_DEVICE(_device, _desc, _quirks, ...) \
- _BHND_DEVICE(ARM, _device, _desc, _quirks, \
- ## __VA_ARGS__, 0)
-
-#define BHND_DEVICE(_device, _desc, _quirks, ...) \
- _BHND_DEVICE(BCM, _device, _desc, _quirks, \
+#define BHND_DEVICE(_vendor, _device, _desc, _quirks, ...) \
+ _BHND_DEVICE(_vendor, _device, _desc, _quirks, \
## __VA_ARGS__, 0)
#define BHND_DEVICE_END { { BHND_MATCH_ANY }, NULL, NULL, 0 }
diff --git a/sys/dev/bhnd/bhnd_subr.c b/sys/dev/bhnd/bhnd_subr.c
index 67b11cb..9a57995 100644
--- a/sys/dev/bhnd/bhnd_subr.c
+++ b/sys/dev/bhnd/bhnd_subr.c
@@ -86,7 +86,7 @@ static const struct bhnd_core_desc {
BHND_CDESC(BCM, APHY, WLAN_PHY, "802.11a PHY"),
BHND_CDESC(BCM, BPHY, WLAN_PHY, "802.11b PHY"),
BHND_CDESC(BCM, GPHY, WLAN_PHY, "802.11g PHY"),
- BHND_CDESC(BCM, MIPS33, CPU, "MIPS 3302 Core"),
+ BHND_CDESC(BCM, MIPS33, CPU, "MIPS3302 Core"),
BHND_CDESC(BCM, USB11H, OTHER, "USB 1.1 Host Controller"),
BHND_CDESC(BCM, USB11D, OTHER, "USB 1.1 Device Core"),
BHND_CDESC(BCM, USB20H, OTHER, "USB 2.0 Host Controller"),
@@ -108,7 +108,7 @@ static const struct bhnd_core_desc {
BHND_CDESC(BCM, SDIOD, OTHER, "SDIO Device Core"),
BHND_CDESC(BCM, ARMCM3, CPU, "ARM Cortex-M3 CPU"),
BHND_CDESC(BCM, HTPHY, WLAN_PHY, "802.11n 4x4 PHY"),
- BHND_CDESC(BCM, MIPS74K, CPU, "MIPS74k CPU"),
+ BHND_CDESC(MIPS,MIPS74K, CPU, "MIPS74k CPU"),
BHND_CDESC(BCM, GMAC, ENET_MAC, "Gigabit MAC core"),
BHND_CDESC(BCM, DMEMC, MEMC, "DDR1/DDR2 Memory Controller"),
BHND_CDESC(BCM, PCIERC, OTHER, "PCIe Root Complex"),
diff --git a/sys/dev/bhnd/cores/chipc/chipc.c b/sys/dev/bhnd/cores/chipc/chipc.c
index b30cec1..41fccde 100644
--- a/sys/dev/bhnd/cores/chipc/chipc.c
+++ b/sys/dev/bhnd/cores/chipc/chipc.c
@@ -84,7 +84,7 @@ static struct bhnd_device_quirk chipc_quirks[];
/* Supported device identifiers */
static const struct bhnd_device chipc_devices[] = {
- BHND_DEVICE(CC, NULL, chipc_quirks),
+ BHND_DEVICE(BCM, CC, NULL, chipc_quirks),
BHND_DEVICE_END
};
diff --git a/sys/dev/bhnd/cores/pci/bhnd_pci.c b/sys/dev/bhnd/cores/pci/bhnd_pci.c
index 2445e65..87ff4bd 100644
--- a/sys/dev/bhnd/cores/pci/bhnd_pci.c
+++ b/sys/dev/bhnd/cores/pci/bhnd_pci.c
@@ -68,8 +68,8 @@ static struct bhnd_device_quirk bhnd_pcie_quirks[];
#define BHND_PCI_QUIRKS bhnd_pci_quirks
#define BHND_PCIE_QUIRKS bhnd_pcie_quirks
-#define BHND_PCI_DEV(_core, _desc, ...) \
- { BHND_DEVICE(_core, _desc, BHND_ ## _core ## _QUIRKS, \
+#define BHND_PCI_DEV(_core, _desc, ...) \
+ { BHND_DEVICE(BCM, _core, _desc, BHND_ ## _core ## _QUIRKS, \
## __VA_ARGS__), BHND_PCI_REGFMT_ ## _core }
static const struct bhnd_pci_device {
diff --git a/sys/dev/bhnd/cores/pci/bhnd_pci_hostb.c b/sys/dev/bhnd/cores/pci/bhnd_pci_hostb.c
index 4ba7289..ec2b5b2 100644
--- a/sys/dev/bhnd/cores/pci/bhnd_pci_hostb.c
+++ b/sys/dev/bhnd/cores/pci/bhnd_pci_hostb.c
@@ -87,7 +87,7 @@ static int bhnd_pci_wars_hwdown(struct bhnd_pcihb_softc *sc,
*/
#define BHND_PCI_DEV(_core, _quirks) \
- BHND_DEVICE(_core, NULL, _quirks, BHND_DF_HOSTB)
+ BHND_DEVICE(BCM, _core, NULL, _quirks, BHND_DF_HOSTB)
static const struct bhnd_device bhnd_pci_devs[] = {
BHND_PCI_DEV(PCI, bhnd_pci_quirks),
diff --git a/sys/dev/bhnd/cores/pcie2/bhnd_pcie2.c b/sys/dev/bhnd/cores/pcie2/bhnd_pcie2.c
index 8641fcc..626d629 100644
--- a/sys/dev/bhnd/cores/pcie2/bhnd_pcie2.c
+++ b/sys/dev/bhnd/cores/pcie2/bhnd_pcie2.c
@@ -57,7 +57,7 @@ __FBSDID("$FreeBSD$");
static struct bhnd_device_quirk bhnd_pcie2_quirks[];
#define BHND_PCIE_DEV(_core, _desc, ...) \
- BHND_DEVICE(_core, _desc, bhnd_pcie2_quirks, ## __VA_ARGS__)
+ BHND_DEVICE(BCM, _core, _desc, bhnd_pcie2_quirks, ## __VA_ARGS__)
static const struct bhnd_device bhnd_pcie2_devs[] = {
BHND_PCIE_DEV(PCIE2, "PCIe-G2 Host-PCI bridge", BHND_DF_HOSTB),
diff --git a/sys/dev/bhnd/cores/pcie2/bhnd_pcie2_hostb.c b/sys/dev/bhnd/cores/pcie2/bhnd_pcie2_hostb.c
index f20de8e..5f4b0cb 100644
--- a/sys/dev/bhnd/cores/pcie2/bhnd_pcie2_hostb.c
+++ b/sys/dev/bhnd/cores/pcie2/bhnd_pcie2_hostb.c
@@ -83,7 +83,7 @@ static int bhnd_pcie2_wars_hwdown(struct bhnd_pcie2hb_softc *sc);
*/
#define BHND_PCI_DEV(_core, _quirks) \
- BHND_DEVICE(_core, NULL, _quirks, BHND_DF_HOSTB)
+ BHND_DEVICE(BCM, _core, NULL, _quirks, BHND_DF_HOSTB)
static const struct bhnd_device bhnd_pcie2_devs[] = {
BHND_PCI_DEV(PCIE2, bhnd_pcie2_quirks),
diff --git a/sys/dev/bhnd/siba/siba_bhndb.c b/sys/dev/bhnd/siba/siba_bhndb.c
index 04bdb76..462162e 100644
--- a/sys/dev/bhnd/siba/siba_bhndb.c
+++ b/sys/dev/bhnd/siba/siba_bhndb.c
@@ -74,7 +74,7 @@ static struct bhnd_device_quirk bridge_quirks[] = {
};
static struct bhnd_device bridge_devs[] = {
- BHND_DEVICE(PCI, NULL, bridge_quirks),
+ BHND_DEVICE(BCM, PCI, NULL, bridge_quirks),
};
static int
diff --git a/sys/dev/bhnd/siba/siba_nexus.c b/sys/dev/bhnd/siba/siba_nexus.c
index 9b5e87e..9d7b6a5 100644
--- a/sys/dev/bhnd/siba/siba_nexus.c
+++ b/sys/dev/bhnd/siba/siba_nexus.c
@@ -115,4 +115,5 @@ static device_method_t siba_nexus_methods[] = {
DEFINE_CLASS_2(bhnd, siba_nexus_driver, siba_nexus_methods,
sizeof(struct siba_nexus_softc), bhnd_nexus_driver, siba_driver);
-DRIVER_MODULE(siba_nexus, nexus, siba_nexus_driver, bhnd_devclass, 0, 0);
+EARLY_DRIVER_MODULE(siba_nexus, nexus, siba_nexus_driver, bhnd_devclass, 0, 0,
+ BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);
diff --git a/sys/dev/cxgb/cxgb_sge.c b/sys/dev/cxgb/cxgb_sge.c
index c83bd66..76d40d81 100644
--- a/sys/dev/cxgb/cxgb_sge.c
+++ b/sys/dev/cxgb/cxgb_sge.c
@@ -2900,7 +2900,8 @@ process_responses(adapter_t *adap, struct sge_qset *qs, int budget)
eop = get_packet(adap, drop_thresh, qs, mh, r);
if (eop) {
if (r->rss_hdr.hash_type && !adap->timestamp) {
- M_HASHTYPE_SET(mh->mh_head, M_HASHTYPE_OPAQUE);
+ M_HASHTYPE_SET(mh->mh_head,
+ M_HASHTYPE_OPAQUE_HASH);
mh->mh_head->m_pkthdr.flowid = rss_hash;
}
}
diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h
index 5800faa..0efeadb 100644
--- a/sys/dev/cxgbe/adapter.h
+++ b/sys/dev/cxgbe/adapter.h
@@ -54,6 +54,7 @@
#include <netinet/tcp_lro.h>
#include "offload.h"
+#include "t4_ioctl.h"
#include "common/t4_msg.h"
#include "firmware/t4fw_interface.h"
@@ -264,6 +265,17 @@ struct vi_info {
uint8_t hw_addr[ETHER_ADDR_LEN]; /* factory MAC address, won't change */
};
+enum {
+ /* tx_sched_class flags */
+ TX_SC_OK = (1 << 0), /* Set up in hardware, active. */
+};
+
+struct tx_sched_class {
+ int refcount;
+ int flags;
+ struct t4_sched_class_params params;
+};
+
struct port_info {
device_t dev;
struct adapter *adapter;
@@ -273,6 +285,8 @@ struct port_info {
int up_vis;
int uld_vis;
+ struct tx_sched_class *tc; /* traffic classes for this channel */
+
struct mtx pi_lock;
char lockname[16];
unsigned long flags;
@@ -522,6 +536,7 @@ struct sge_txq {
struct tx_sdesc *sdesc; /* KVA of software descriptor ring */
struct sglist *gl;
__be32 cpl_ctrl0; /* for convenience */
+ int tc_idx; /* traffic class */
struct task tx_reclaim_task;
/* stats for common events first */
diff --git a/sys/dev/cxgbe/t4_ioctl.h b/sys/dev/cxgbe/t4_ioctl.h
index fdc5e98..c85d970 100644
--- a/sys/dev/cxgbe/t4_ioctl.h
+++ b/sys/dev/cxgbe/t4_ioctl.h
@@ -215,6 +215,20 @@ struct t4_filter {
struct t4_filter_specification fs;
};
+/* Tx Scheduling Class parameters */
+struct t4_sched_class_params {
+ int8_t level; /* scheduler hierarchy level */
+ int8_t mode; /* per-class or per-flow */
+ int8_t rateunit; /* bit or packet rate */
+ int8_t ratemode; /* %port relative or kbps absolute */
+ int8_t channel; /* scheduler channel [0..N] */
+ int8_t cl; /* scheduler class [0..N] */
+ int32_t minrate; /* minimum rate */
+ int32_t maxrate; /* maximum rate */
+ int16_t weight; /* percent weight */
+ int16_t pktsize; /* average packet size */
+};
+
/*
* Support for "sched-class" command to allow a TX Scheduling Class to be
* programmed with various parameters.
@@ -226,19 +240,7 @@ struct t4_sched_params {
struct { /* sub-command SCHED_CLASS_CONFIG */
int8_t minmax; /* minmax enable */
} config;
- struct { /* sub-command SCHED_CLASS_PARAMS */
- int8_t level; /* scheduler hierarchy level */
- int8_t mode; /* per-class or per-flow */
- int8_t rateunit; /* bit or packet rate */
- int8_t ratemode; /* %port relative or kbps
- absolute */
- int8_t channel; /* scheduler channel [0..N] */
- int8_t cl; /* scheduler class [0..N] */
- int32_t minrate; /* minimum rate */
- int32_t maxrate; /* maximum rate */
- int16_t weight; /* percent weight */
- int16_t pktsize; /* average packet size */
- } params;
+ struct t4_sched_class_params params;
uint8_t reserved[6 + 8 * 8];
} u;
};
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index 132d69e..01c4352 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -496,6 +496,7 @@ static int sysctl_tp_la(SYSCTL_HANDLER_ARGS);
static int sysctl_tx_rate(SYSCTL_HANDLER_ARGS);
static int sysctl_ulprx_la(SYSCTL_HANDLER_ARGS);
static int sysctl_wcwr_stats(SYSCTL_HANDLER_ARGS);
+static int sysctl_tc_params(SYSCTL_HANDLER_ARGS);
#endif
#ifdef TCP_OFFLOAD
static int sysctl_tp_tick(SYSCTL_HANDLER_ARGS);
@@ -875,6 +876,9 @@ t4_attach(device_t dev)
mtx_init(&pi->pi_lock, pi->lockname, 0, MTX_DEF);
sc->chan_map[pi->tx_chan] = i;
+ pi->tc = malloc(sizeof(struct tx_sched_class) *
+ sc->chip_params->nsched_cls, M_CXGBE, M_ZERO | M_WAITOK);
+
if (is_10G_port(pi) || is_40G_port(pi)) {
n10g++;
for_each_vi(pi, j, vi) {
@@ -1131,6 +1135,7 @@ t4_detach(device_t dev)
mtx_destroy(&pi->pi_lock);
free(pi->vi, M_CXGBE);
+ free(pi->tc, M_CXGBE);
free(pi, M_CXGBE);
}
}
@@ -5030,8 +5035,10 @@ cxgbe_sysctls(struct port_info *pi)
{
struct sysctl_ctx_list *ctx;
struct sysctl_oid *oid;
- struct sysctl_oid_list *children;
+ struct sysctl_oid_list *children, *children2;
struct adapter *sc = pi->adapter;
+ int i;
+ char name[16];
ctx = device_get_sysctl_ctx(pi->dev);
@@ -5060,6 +5067,29 @@ cxgbe_sysctls(struct port_info *pi)
port_top_speed(pi), "max speed (in Gbps)");
/*
+ * dev.(cxgbe|cxl).X.tc.
+ */
+ oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "tc", CTLFLAG_RD, NULL,
+ "Tx scheduler traffic classes");
+ for (i = 0; i < sc->chip_params->nsched_cls; i++) {
+ struct tx_sched_class *tc = &pi->tc[i];
+
+ snprintf(name, sizeof(name), "%d", i);
+ children2 = SYSCTL_CHILDREN(SYSCTL_ADD_NODE(ctx,
+ SYSCTL_CHILDREN(oid), OID_AUTO, name, CTLFLAG_RD, NULL,
+ "traffic class"));
+ SYSCTL_ADD_UINT(ctx, children2, OID_AUTO, "flags", CTLFLAG_RD,
+ &tc->flags, 0, "flags");
+ SYSCTL_ADD_UINT(ctx, children2, OID_AUTO, "refcount",
+ CTLFLAG_RD, &tc->refcount, 0, "references to this class");
+#ifdef SBUF_DRAIN
+ SYSCTL_ADD_PROC(ctx, children2, OID_AUTO, "params",
+ CTLTYPE_STRING | CTLFLAG_RD, sc, (pi->port_id << 16) | i,
+ sysctl_tc_params, "A", "traffic class parameters");
+#endif
+ }
+
+ /*
* dev.cxgbe.X.stats.
*/
oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "stats", CTLFLAG_RD,
@@ -7452,6 +7482,101 @@ sysctl_wcwr_stats(SYSCTL_HANDLER_ARGS)
return (rc);
}
+
+static int
+sysctl_tc_params(SYSCTL_HANDLER_ARGS)
+{
+ struct adapter *sc = arg1;
+ struct tx_sched_class *tc;
+ struct t4_sched_class_params p;
+ struct sbuf *sb;
+ int i, rc, port_id, flags, mbps, gbps;
+
+ rc = sysctl_wire_old_buffer(req, 0);
+ if (rc != 0)
+ return (rc);
+
+ sb = sbuf_new_for_sysctl(NULL, NULL, 4096, req);
+ if (sb == NULL)
+ return (ENOMEM);
+
+ port_id = arg2 >> 16;
+ MPASS(port_id < sc->params.nports);
+ MPASS(sc->port[port_id] != NULL);
+ i = arg2 & 0xffff;
+ MPASS(i < sc->chip_params->nsched_cls);
+ tc = &sc->port[port_id]->tc[i];
+
+ rc = begin_synchronized_op(sc, NULL, HOLD_LOCK | SLEEP_OK | INTR_OK,
+ "t4tc_p");
+ if (rc)
+ goto done;
+ flags = tc->flags;
+ p = tc->params;
+ end_synchronized_op(sc, LOCK_HELD);
+
+ if ((flags & TX_SC_OK) == 0) {
+ sbuf_printf(sb, "none");
+ goto done;
+ }
+
+ if (p.level == SCHED_CLASS_LEVEL_CL_WRR) {
+ sbuf_printf(sb, "cl-wrr weight %u", p.weight);
+ goto done;
+ } else if (p.level == SCHED_CLASS_LEVEL_CL_RL)
+ sbuf_printf(sb, "cl-rl");
+ else if (p.level == SCHED_CLASS_LEVEL_CH_RL)
+ sbuf_printf(sb, "ch-rl");
+ else {
+ rc = ENXIO;
+ goto done;
+ }
+
+ if (p.ratemode == SCHED_CLASS_RATEMODE_REL) {
+ /* XXX: top speed or actual link speed? */
+ gbps = port_top_speed(sc->port[port_id]);
+ sbuf_printf(sb, " %u%% of %uGbps", p.maxrate, gbps);
+ }
+ else if (p.ratemode == SCHED_CLASS_RATEMODE_ABS) {
+ switch (p.rateunit) {
+ case SCHED_CLASS_RATEUNIT_BITS:
+ mbps = p.maxrate / 1000;
+ gbps = p.maxrate / 1000000;
+ if (p.maxrate == gbps * 1000000)
+ sbuf_printf(sb, " %uGbps", gbps);
+ else if (p.maxrate == mbps * 1000)
+ sbuf_printf(sb, " %uMbps", mbps);
+ else
+ sbuf_printf(sb, " %uKbps", p.maxrate);
+ break;
+ case SCHED_CLASS_RATEUNIT_PKTS:
+ sbuf_printf(sb, " %upps", p.maxrate);
+ break;
+ default:
+ rc = ENXIO;
+ goto done;
+ }
+ }
+
+ switch (p.mode) {
+ case SCHED_CLASS_MODE_CLASS:
+ sbuf_printf(sb, " aggregate");
+ break;
+ case SCHED_CLASS_MODE_FLOW:
+ sbuf_printf(sb, " per-flow");
+ break;
+ default:
+ rc = ENXIO;
+ goto done;
+ }
+
+done:
+ if (rc == 0)
+ rc = sbuf_finish(sb);
+ sbuf_delete(sb);
+
+ return (rc);
+}
#endif
#ifdef TCP_OFFLOAD
@@ -8297,155 +8422,147 @@ in_range(int val, int lo, int hi)
}
static int
-set_sched_class(struct adapter *sc, struct t4_sched_params *p)
+set_sched_class_config(struct adapter *sc, int minmax)
{
- int fw_subcmd, fw_type, rc;
+ int rc;
+
+ if (minmax < 0)
+ return (EINVAL);
- rc = begin_synchronized_op(sc, NULL, SLEEP_OK | INTR_OK, "t4setsc");
+ rc = begin_synchronized_op(sc, NULL, SLEEP_OK | INTR_OK, "t4sscc");
if (rc)
return (rc);
+ rc = -t4_sched_config(sc, FW_SCHED_TYPE_PKTSCHED, minmax, 1);
+ end_synchronized_op(sc, 0);
- if (!(sc->flags & FULL_INIT_DONE)) {
- rc = EAGAIN;
- goto done;
- }
+ return (rc);
+}
- /*
- * Translate the cxgbetool parameters into T4 firmware parameters. (The
- * sub-command and type are in common locations.)
- */
- if (p->subcmd == SCHED_CLASS_SUBCMD_CONFIG)
- fw_subcmd = FW_SCHED_SC_CONFIG;
- else if (p->subcmd == SCHED_CLASS_SUBCMD_PARAMS)
- fw_subcmd = FW_SCHED_SC_PARAMS;
- else {
- rc = EINVAL;
- goto done;
- }
- if (p->type == SCHED_CLASS_TYPE_PACKET)
- fw_type = FW_SCHED_TYPE_PKTSCHED;
- else {
- rc = EINVAL;
- goto done;
- }
+static int
+set_sched_class_params(struct adapter *sc, struct t4_sched_class_params *p,
+ int sleep_ok)
+{
+ int rc, top_speed, fw_level, fw_mode, fw_rateunit, fw_ratemode;
+ struct port_info *pi;
+ struct tx_sched_class *tc;
+
+ if (p->level == SCHED_CLASS_LEVEL_CL_RL)
+ fw_level = FW_SCHED_PARAMS_LEVEL_CL_RL;
+ else if (p->level == SCHED_CLASS_LEVEL_CL_WRR)
+ fw_level = FW_SCHED_PARAMS_LEVEL_CL_WRR;
+ else if (p->level == SCHED_CLASS_LEVEL_CH_RL)
+ fw_level = FW_SCHED_PARAMS_LEVEL_CH_RL;
+ else
+ return (EINVAL);
- if (fw_subcmd == FW_SCHED_SC_CONFIG) {
- /* Vet our parameters ..*/
- if (p->u.config.minmax < 0) {
- rc = EINVAL;
- goto done;
- }
+ if (p->mode == SCHED_CLASS_MODE_CLASS)
+ fw_mode = FW_SCHED_PARAMS_MODE_CLASS;
+ else if (p->mode == SCHED_CLASS_MODE_FLOW)
+ fw_mode = FW_SCHED_PARAMS_MODE_FLOW;
+ else
+ return (EINVAL);
- /* And pass the request to the firmware ...*/
- rc = -t4_sched_config(sc, fw_type, p->u.config.minmax, 1);
- goto done;
- }
+ if (p->rateunit == SCHED_CLASS_RATEUNIT_BITS)
+ fw_rateunit = FW_SCHED_PARAMS_UNIT_BITRATE;
+ else if (p->rateunit == SCHED_CLASS_RATEUNIT_PKTS)
+ fw_rateunit = FW_SCHED_PARAMS_UNIT_PKTRATE;
+ else
+ return (EINVAL);
- if (fw_subcmd == FW_SCHED_SC_PARAMS) {
- int fw_level;
- int fw_mode;
- int fw_rateunit;
- int fw_ratemode;
+ if (p->ratemode == SCHED_CLASS_RATEMODE_REL)
+ fw_ratemode = FW_SCHED_PARAMS_RATE_REL;
+ else if (p->ratemode == SCHED_CLASS_RATEMODE_ABS)
+ fw_ratemode = FW_SCHED_PARAMS_RATE_ABS;
+ else
+ return (EINVAL);
- if (p->u.params.level == SCHED_CLASS_LEVEL_CL_RL)
- fw_level = FW_SCHED_PARAMS_LEVEL_CL_RL;
- else if (p->u.params.level == SCHED_CLASS_LEVEL_CL_WRR)
- fw_level = FW_SCHED_PARAMS_LEVEL_CL_WRR;
- else if (p->u.params.level == SCHED_CLASS_LEVEL_CH_RL)
- fw_level = FW_SCHED_PARAMS_LEVEL_CH_RL;
- else {
- rc = EINVAL;
- goto done;
- }
+ /* Vet our parameters ... */
+ if (!in_range(p->channel, 0, sc->chip_params->nchan - 1))
+ return (ERANGE);
- if (p->u.params.mode == SCHED_CLASS_MODE_CLASS)
- fw_mode = FW_SCHED_PARAMS_MODE_CLASS;
- else if (p->u.params.mode == SCHED_CLASS_MODE_FLOW)
- fw_mode = FW_SCHED_PARAMS_MODE_FLOW;
- else {
- rc = EINVAL;
- goto done;
- }
+ pi = sc->port[sc->chan_map[p->channel]];
+ if (pi == NULL)
+ return (ENXIO);
+ MPASS(pi->tx_chan == p->channel);
+ top_speed = port_top_speed(pi) * 1000000; /* Gbps -> Kbps */
- if (p->u.params.rateunit == SCHED_CLASS_RATEUNIT_BITS)
- fw_rateunit = FW_SCHED_PARAMS_UNIT_BITRATE;
- else if (p->u.params.rateunit == SCHED_CLASS_RATEUNIT_PKTS)
- fw_rateunit = FW_SCHED_PARAMS_UNIT_PKTRATE;
- else {
- rc = EINVAL;
- goto done;
- }
+ if (!in_range(p->cl, 0, sc->chip_params->nsched_cls) ||
+ !in_range(p->minrate, 0, top_speed) ||
+ !in_range(p->maxrate, 0, top_speed) ||
+ !in_range(p->weight, 0, 100))
+ return (ERANGE);
- if (p->u.params.ratemode == SCHED_CLASS_RATEMODE_REL)
- fw_ratemode = FW_SCHED_PARAMS_RATE_REL;
- else if (p->u.params.ratemode == SCHED_CLASS_RATEMODE_ABS)
- fw_ratemode = FW_SCHED_PARAMS_RATE_ABS;
- else {
- rc = EINVAL;
- goto done;
- }
+ /*
+ * Translate any unset parameters into the firmware's
+ * nomenclature and/or fail the call if the parameters
+ * are required ...
+ */
+ if (p->rateunit < 0 || p->ratemode < 0 || p->channel < 0 || p->cl < 0)
+ return (EINVAL);
- /* Vet our parameters ... */
- if (!in_range(p->u.params.channel, 0, 3) ||
- !in_range(p->u.params.cl, 0, sc->chip_params->nsched_cls) ||
- !in_range(p->u.params.minrate, 0, 10000000) ||
- !in_range(p->u.params.maxrate, 0, 10000000) ||
- !in_range(p->u.params.weight, 0, 100)) {
- rc = ERANGE;
- goto done;
- }
+ if (p->minrate < 0)
+ p->minrate = 0;
+ if (p->maxrate < 0) {
+ if (p->level == SCHED_CLASS_LEVEL_CL_RL ||
+ p->level == SCHED_CLASS_LEVEL_CH_RL)
+ return (EINVAL);
+ else
+ p->maxrate = 0;
+ }
+ if (p->weight < 0) {
+ if (p->level == SCHED_CLASS_LEVEL_CL_WRR)
+ return (EINVAL);
+ else
+ p->weight = 0;
+ }
+ if (p->pktsize < 0) {
+ if (p->level == SCHED_CLASS_LEVEL_CL_RL ||
+ p->level == SCHED_CLASS_LEVEL_CH_RL)
+ return (EINVAL);
+ else
+ p->pktsize = 0;
+ }
+ rc = begin_synchronized_op(sc, NULL,
+ sleep_ok ? (SLEEP_OK | INTR_OK) : HOLD_LOCK, "t4sscp");
+ if (rc)
+ return (rc);
+ tc = &pi->tc[p->cl];
+ tc->params = *p;
+ rc = -t4_sched_params(sc, FW_SCHED_TYPE_PKTSCHED, fw_level, fw_mode,
+ fw_rateunit, fw_ratemode, p->channel, p->cl, p->minrate, p->maxrate,
+ p->weight, p->pktsize, sleep_ok);
+ if (rc == 0)
+ tc->flags |= TX_SC_OK;
+ else {
/*
- * Translate any unset parameters into the firmware's
- * nomenclature and/or fail the call if the parameters
- * are required ...
+ * Unknown state at this point, see tc->params for what was
+ * attempted.
*/
- if (p->u.params.rateunit < 0 || p->u.params.ratemode < 0 ||
- p->u.params.channel < 0 || p->u.params.cl < 0) {
- rc = EINVAL;
- goto done;
- }
- if (p->u.params.minrate < 0)
- p->u.params.minrate = 0;
- if (p->u.params.maxrate < 0) {
- if (p->u.params.level == SCHED_CLASS_LEVEL_CL_RL ||
- p->u.params.level == SCHED_CLASS_LEVEL_CH_RL) {
- rc = EINVAL;
- goto done;
- } else
- p->u.params.maxrate = 0;
- }
- if (p->u.params.weight < 0) {
- if (p->u.params.level == SCHED_CLASS_LEVEL_CL_WRR) {
- rc = EINVAL;
- goto done;
- } else
- p->u.params.weight = 0;
- }
- if (p->u.params.pktsize < 0) {
- if (p->u.params.level == SCHED_CLASS_LEVEL_CL_RL ||
- p->u.params.level == SCHED_CLASS_LEVEL_CH_RL) {
- rc = EINVAL;
- goto done;
- } else
- p->u.params.pktsize = 0;
- }
-
- /* See what the firmware thinks of the request ... */
- rc = -t4_sched_params(sc, fw_type, fw_level, fw_mode,
- fw_rateunit, fw_ratemode, p->u.params.channel,
- p->u.params.cl, p->u.params.minrate, p->u.params.maxrate,
- p->u.params.weight, p->u.params.pktsize, 1);
- goto done;
+ tc->flags &= ~TX_SC_OK;
}
+ end_synchronized_op(sc, sleep_ok ? 0 : LOCK_HELD);
- rc = EINVAL;
-done:
- end_synchronized_op(sc, 0);
return (rc);
}
static int
+set_sched_class(struct adapter *sc, struct t4_sched_params *p)
+{
+
+ if (p->type != SCHED_CLASS_TYPE_PACKET)
+ return (EINVAL);
+
+ if (p->subcmd == SCHED_CLASS_SUBCMD_CONFIG)
+ return (set_sched_class_config(sc, p->u.config.minmax));
+
+ if (p->subcmd == SCHED_CLASS_SUBCMD_PARAMS)
+ return (set_sched_class_params(sc, &p->u.params, 1));
+
+ return (EINVAL);
+}
+
+static int
set_sched_queue(struct adapter *sc, struct t4_sched_queue *p)
{
struct port_info *pi = NULL;
@@ -8458,11 +8575,6 @@ set_sched_queue(struct adapter *sc, struct t4_sched_queue *p)
if (rc)
return (rc);
- if (!(sc->flags & FULL_INIT_DONE)) {
- rc = EAGAIN;
- goto done;
- }
-
if (p->port >= sc->params.nports) {
rc = EINVAL;
goto done;
@@ -8471,7 +8583,14 @@ set_sched_queue(struct adapter *sc, struct t4_sched_queue *p)
/* XXX: Only supported for the main VI. */
pi = sc->port[p->port];
vi = &pi->vi[0];
- if (!in_range(p->queue, 0, vi->ntxq - 1) || !in_range(p->cl, 0, 7)) {
+ if (!(vi->flags & VI_INIT_DONE)) {
+ /* tx queues not set up yet */
+ rc = EAGAIN;
+ goto done;
+ }
+
+ if (!in_range(p->queue, 0, vi->ntxq - 1) ||
+ !in_range(p->cl, 0, sc->chip_params->nsched_cls - 1)) {
rc = EINVAL;
goto done;
}
diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c
index ad1da55..75a7c8a 100644
--- a/sys/dev/cxgbe/t4_sge.c
+++ b/sys/dev/cxgbe/t4_sge.c
@@ -248,6 +248,7 @@ static void drain_wrq_wr_list(struct adapter *, struct sge_wrq *);
static int sysctl_uint16(SYSCTL_HANDLER_ARGS);
static int sysctl_bufsizes(SYSCTL_HANDLER_ARGS);
+static int sysctl_tc(SYSCTL_HANDLER_ARGS);
static counter_u64_t extfree_refs;
static counter_u64_t extfree_rels;
@@ -3434,6 +3435,7 @@ alloc_txq(struct vi_info *vi, struct sge_txq *txq, int idx,
txq->cpl_ctrl0 = htobe32(V_TXPKT_OPCODE(CPL_TX_PKT) |
V_TXPKT_INTF(pi->tx_chan) | V_TXPKT_VF_VLD(1) |
V_TXPKT_VF(vi->viid));
+ txq->tc_idx = -1;
txq->sdesc = malloc(eq->sidx * sizeof(struct tx_sdesc), M_CXGBE,
M_ZERO | M_WAITOK);
@@ -3451,6 +3453,10 @@ alloc_txq(struct vi_info *vi, struct sge_txq *txq, int idx,
CTLTYPE_INT | CTLFLAG_RD, &eq->pidx, 0, sysctl_uint16, "I",
"producer index");
+ SYSCTL_ADD_PROC(&vi->ctx, children, OID_AUTO, "tc",
+ CTLTYPE_INT | CTLFLAG_RW, vi, idx, sysctl_tc, "I",
+ "traffic class (-1 means none)");
+
SYSCTL_ADD_UQUAD(&vi->ctx, children, OID_AUTO, "txcsum", CTLFLAG_RD,
&txq->txcsum, "# of times hardware assisted with checksum");
SYSCTL_ADD_UQUAD(&vi->ctx, children, OID_AUTO, "vlan_insertion",
@@ -4684,3 +4690,78 @@ sysctl_bufsizes(SYSCTL_HANDLER_ARGS)
sbuf_delete(&sb);
return (rc);
}
+
+static int
+sysctl_tc(SYSCTL_HANDLER_ARGS)
+{
+ struct vi_info *vi = arg1;
+ struct port_info *pi;
+ struct adapter *sc;
+ struct sge_txq *txq;
+ struct tx_sched_class *tc;
+ int qidx = arg2, rc, tc_idx;
+ uint32_t fw_queue, fw_class;
+
+ MPASS(qidx >= 0 && qidx < vi->ntxq);
+ pi = vi->pi;
+ sc = pi->adapter;
+ txq = &sc->sge.txq[vi->first_txq + qidx];
+
+ tc_idx = txq->tc_idx;
+ rc = sysctl_handle_int(oidp, &tc_idx, 0, req);
+ if (rc != 0 || req->newptr == NULL)
+ return (rc);
+
+ /* Note that -1 is legitimate input (it means unbind). */
+ if (tc_idx < -1 || tc_idx >= sc->chip_params->nsched_cls)
+ return (EINVAL);
+
+ rc = begin_synchronized_op(sc, vi, SLEEP_OK | INTR_OK, "t4stc");
+ if (rc)
+ return (rc);
+
+ if (tc_idx == txq->tc_idx) {
+ rc = 0; /* No change, nothing to do. */
+ goto done;
+ }
+
+ fw_queue = V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DMAQ) |
+ V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DMAQ_EQ_SCHEDCLASS_ETH) |
+ V_FW_PARAMS_PARAM_YZ(txq->eq.cntxt_id);
+
+ if (tc_idx == -1)
+ fw_class = 0xffffffff; /* Unbind. */
+ else {
+ /*
+ * Bind to a different class. Ethernet txq's are only allowed
+ * to bind to cl-rl mode-class for now. XXX: too restrictive.
+ */
+ tc = &pi->tc[tc_idx];
+ if (tc->flags & TX_SC_OK &&
+ tc->params.level == SCHED_CLASS_LEVEL_CL_RL &&
+ tc->params.mode == SCHED_CLASS_MODE_CLASS) {
+ /* Ok to proceed. */
+ fw_class = tc_idx;
+ } else {
+ rc = tc->flags & TX_SC_OK ? EBUSY : ENXIO;
+ goto done;
+ }
+ }
+
+ rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, &fw_queue, &fw_class);
+ if (rc == 0) {
+ if (txq->tc_idx != -1) {
+ tc = &pi->tc[txq->tc_idx];
+ MPASS(tc->refcount > 0);
+ tc->refcount--;
+ }
+ if (tc_idx != -1) {
+ tc = &pi->tc[tc_idx];
+ tc->refcount++;
+ }
+ txq->tc_idx = tc_idx;
+ }
+done:
+ end_synchronized_op(sc, 0);
+ return (rc);
+}
diff --git a/sys/dev/dwc/if_dwc.c b/sys/dev/dwc/if_dwc.c
index 988516e..a34879b 100644
--- a/sys/dev/dwc/if_dwc.c
+++ b/sys/dev/dwc/if_dwc.c
@@ -587,19 +587,25 @@ dwc_setup_rxfilter(struct dwc_softc *sc)
struct ifmultiaddr *ifma;
struct ifnet *ifp;
uint8_t *eaddr, val;
- uint32_t crc, ffval, hashbit, hashreg, hi, lo, reg;
+ uint32_t crc, ffval, hashbit, hashreg, hi, lo, hash[8];
+ int nhash, i;
DWC_ASSERT_LOCKED(sc);
ifp = sc->ifp;
+ nhash = sc->mactype == DWC_GMAC_ALT_DESC ? 2 : 8;
/*
* Set the multicast (group) filter hash.
*/
- if ((ifp->if_flags & IFF_ALLMULTI))
+ if ((ifp->if_flags & IFF_ALLMULTI) != 0) {
ffval = (FRAME_FILTER_PM);
- else {
+ for (i = 0; i < nhash; i++)
+ hash[i] = ~0;
+ } else {
ffval = (FRAME_FILTER_HMC);
+ for (i = 0; i < nhash; i++)
+ hash[i] = 0;
if_maddr_rlock(ifp);
TAILQ_FOREACH(ifma, &sc->ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
@@ -609,12 +615,11 @@ dwc_setup_rxfilter(struct dwc_softc *sc)
/* Take lower 8 bits and reverse it */
val = bitreverse(~crc & 0xff);
+ if (sc->mactype == DWC_GMAC_ALT_DESC)
+ val >>= nhash; /* Only need lower 6 bits */
hashreg = (val >> 5);
hashbit = (val & 31);
-
- reg = READ4(sc, HASH_TABLE_REG(hashreg));
- reg |= (1 << hashbit);
- WRITE4(sc, HASH_TABLE_REG(hashreg), reg);
+ hash[hashreg] |= (1 << hashbit);
}
if_maddr_runlock(ifp);
}
@@ -635,6 +640,13 @@ dwc_setup_rxfilter(struct dwc_softc *sc)
WRITE4(sc, MAC_ADDRESS_LOW(0), lo);
WRITE4(sc, MAC_ADDRESS_HIGH(0), hi);
WRITE4(sc, MAC_FRAME_FILTER, ffval);
+ if (sc->mactype == DWC_GMAC_ALT_DESC) {
+ WRITE4(sc, GMAC_MAC_HTLOW, hash[0]);
+ WRITE4(sc, GMAC_MAC_HTHIGH, hash[1]);
+ } else {
+ for (i = 0; i < nhash; i++)
+ WRITE4(sc, HASH_TABLE_REG(i), hash[i]);
+ }
}
static int
@@ -759,6 +771,9 @@ dwc_rxfinish_locked(struct dwc_softc *sc)
m->m_len = len;
if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
+ /* Remove trailing FCS */
+ m_adj(m, -ETHER_CRC_LEN);
+
DWC_UNLOCK(sc);
(*ifp->if_input)(ifp, m);
DWC_LOCK(sc);
diff --git a/sys/dev/dwc/if_dwc.h b/sys/dev/dwc/if_dwc.h
index c9403da..d88ca0d 100644
--- a/sys/dev/dwc/if_dwc.h
+++ b/sys/dev/dwc/if_dwc.h
@@ -53,6 +53,8 @@
#define FRAME_FILTER_HMC (1 << 2)
#define FRAME_FILTER_HUC (1 << 1)
#define FRAME_FILTER_PR (1 << 0) /* All Incoming Frames */
+#define GMAC_MAC_HTHIGH 0x08
+#define GMAC_MAC_HTLOW 0x0c
#define GMII_ADDRESS 0x10
#define GMII_ADDRESS_PA_MASK 0x1f /* Phy device */
#define GMII_ADDRESS_PA_SHIFT 11
diff --git a/sys/dev/e1000/if_igb.c b/sys/dev/e1000/if_igb.c
index 120111d..83e1e83 100644
--- a/sys/dev/e1000/if_igb.c
+++ b/sys/dev/e1000/if_igb.c
@@ -5154,7 +5154,7 @@ igb_rxeof(struct igb_queue *que, int count, int *done)
default:
/* XXX fallthrough */
M_HASHTYPE_SET(rxr->fmp,
- M_HASHTYPE_OPAQUE);
+ M_HASHTYPE_OPAQUE_HASH);
}
} else {
#ifndef IGB_LEGACY_TX
diff --git a/sys/dev/flash/mx25l.c b/sys/dev/flash/mx25l.c
index 832e790..b41986f 100644
--- a/sys/dev/flash/mx25l.c
+++ b/sys/dev/flash/mx25l.c
@@ -130,6 +130,9 @@ struct mx25l_flash_ident flash_devices[] = {
{ "w25q64bv", 0xef, 0x4017, 64 * 1024, 128, FL_ERASE_4K },
{ "w25q128", 0xef, 0x4018, 64 * 1024, 256, FL_ERASE_4K },
{ "w25q256", 0xef, 0x4019, 64 * 1024, 512, FL_ERASE_4K },
+
+ /* Atmel */
+ { "at25df641", 0x1f, 0x4800, 64 * 1024, 128, FL_ERASE_4K },
};
static uint8_t
diff --git a/sys/dev/gpio/gpiobus.c b/sys/dev/gpio/gpiobus.c
index f8b3b46..eac9d2b 100644
--- a/sys/dev/gpio/gpiobus.c
+++ b/sys/dev/gpio/gpiobus.c
@@ -79,22 +79,47 @@ static int gpiobus_pin_toggle(device_t, device_t, uint32_t);
* data will be moved into struct resource.
*/
#ifdef INTRNG
+static void
+gpio_destruct_map_data(struct intr_map_data *map_data)
+{
+
+ KASSERT(map_data->type == INTR_MAP_DATA_GPIO,
+ ("%s: bad map_data type %d", __func__, map_data->type));
+
+ free(map_data, M_DEVBUF);
+}
+
struct resource *
gpio_alloc_intr_resource(device_t consumer_dev, int *rid, u_int alloc_flags,
gpio_pin_t pin, uint32_t intr_mode)
{
- u_int irqnum;
-
- /*
- * Allocate new fictitious interrupt number and store configuration
- * into it.
- */
- irqnum = intr_gpio_map_irq(pin->dev, pin->pin, pin->flags, intr_mode);
- if (irqnum == INTR_IRQ_INVALID)
+ int rv;
+ u_int irq;
+ struct intr_map_data_gpio *gpio_data;
+ struct resource *res;
+
+ gpio_data = malloc(sizeof(*gpio_data), M_DEVBUF, M_WAITOK | M_ZERO);
+ gpio_data->hdr.type = INTR_MAP_DATA_GPIO;
+ gpio_data->hdr.destruct = gpio_destruct_map_data;
+ gpio_data->gpio_pin_num = pin->pin;
+ gpio_data->gpio_pin_flags = pin->flags;
+ gpio_data->gpio_intr_mode = intr_mode;
+
+ rv = intr_map_irq(pin->dev, 0, (struct intr_map_data *)gpio_data,
+ &irq);
+ if (rv != 0) {
+ gpio_destruct_map_data((struct intr_map_data *)gpio_data);
return (NULL);
+ }
- return (bus_alloc_resource(consumer_dev, SYS_RES_IRQ, rid,
- irqnum, irqnum, 1, alloc_flags));
+ res = bus_alloc_resource(consumer_dev, SYS_RES_IRQ, rid, irq, irq, 1,
+ alloc_flags);
+ if (res == NULL) {
+ gpio_destruct_map_data((struct intr_map_data *)gpio_data);
+ return (NULL);
+ }
+ rman_set_virtual(res, gpio_data);
+ return (res);
}
#else
struct resource *
diff --git a/sys/dev/gpio/gpiobusvar.h b/sys/dev/gpio/gpiobusvar.h
index f6b6d68..a271905 100644
--- a/sys/dev/gpio/gpiobusvar.h
+++ b/sys/dev/gpio/gpiobusvar.h
@@ -70,6 +70,13 @@ struct gpiobus_pin_data
char *name; /* pin name. */
};
+struct intr_map_data_gpio {
+ struct intr_map_data hdr;
+ u_int gpio_pin_num;
+ u_int gpio_pin_flags;
+ u_int gpio_intr_mode;
+};
+
struct gpiobus_softc
{
struct mtx sc_mtx; /* bus mutex */
diff --git a/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
index 04e998e..1199d20 100644
--- a/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
+++ b/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
@@ -1300,6 +1300,7 @@ netvsc_recv(struct hv_vmbus_channel *chan, netvsc_packet *packet,
struct ifnet *ifp = rxr->hn_ifp;
struct mbuf *m_new;
int size, do_lro = 0, do_csum = 1;
+ int hash_type = M_HASHTYPE_OPAQUE_HASH;
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
return (0);
@@ -1430,8 +1431,6 @@ skip:
}
if (hash_info != NULL && hash_value != NULL) {
- int hash_type = M_HASHTYPE_OPAQUE;
-
rxr->hn_rss_pkts++;
m_new->m_pkthdr.flowid = hash_value->hash_value;
if ((hash_info->hash_info & NDIS_HASH_FUNCTION_MASK) ==
@@ -1465,14 +1464,15 @@ skip:
break;
}
}
- M_HASHTYPE_SET(m_new, hash_type);
} else {
- if (hash_value != NULL)
+ if (hash_value != NULL) {
m_new->m_pkthdr.flowid = hash_value->hash_value;
- else
+ } else {
m_new->m_pkthdr.flowid = rxr->hn_rx_idx;
- M_HASHTYPE_SET(m_new, M_HASHTYPE_OPAQUE);
+ hash_type = M_HASHTYPE_OPAQUE;
+ }
}
+ M_HASHTYPE_SET(m_new, hash_type);
/*
* Note: Moved RX completion back to hv_nv_on_receive() so all
diff --git a/sys/dev/hyperv/vmbus/hv_channel.c b/sys/dev/hyperv/vmbus/hv_channel.c
index c1d415f..88ba7ca 100644
--- a/sys/dev/hyperv/vmbus/hv_channel.c
+++ b/sys/dev/hyperv/vmbus/hv_channel.c
@@ -37,12 +37,16 @@ __FBSDID("$FreeBSD$");
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/sysctl.h>
+
+#include <machine/atomic.h>
#include <machine/bus.h>
+
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/pmap.h>
#include <dev/hyperv/vmbus/hv_vmbus_priv.h>
+#include <dev/hyperv/vmbus/vmbus_reg.h>
#include <dev/hyperv/vmbus/vmbus_var.h>
static int vmbus_channel_create_gpadl_header(
@@ -62,17 +66,16 @@ static void VmbusProcessChannelEvent(void* channel, int pending);
static void
vmbus_channel_set_event(hv_vmbus_channel *channel)
{
- hv_vmbus_monitor_page *monitor_page;
-
if (channel->offer_msg.monitor_allocated) {
- /* Each uint32_t represents 32 channels */
- synch_set_bit((channel->offer_msg.child_rel_id & 31),
- ((uint32_t *)hv_vmbus_g_connection.send_interrupt_page
- + ((channel->offer_msg.child_rel_id >> 5))));
+ struct vmbus_softc *sc = vmbus_get_softc();
+ hv_vmbus_monitor_page *monitor_page;
+ uint32_t chanid = channel->offer_msg.child_rel_id;
- monitor_page = (hv_vmbus_monitor_page *)
- hv_vmbus_g_connection.monitor_page_2;
+ atomic_set_long(
+ &sc->vmbus_tx_evtflags[chanid >> VMBUS_EVTFLAG_SHIFT],
+ 1UL << (chanid & VMBUS_EVTFLAG_MASK));
+ monitor_page = sc->vmbus_mnf2;
synch_set_bit(channel->monitor_bit,
(uint32_t *)&monitor_page->
trigger_group[channel->monitor_group].u.pending);
diff --git a/sys/dev/hyperv/vmbus/hv_connection.c b/sys/dev/hyperv/vmbus/hv_connection.c
index 8a0bb09..e4dcd19 100644
--- a/sys/dev/hyperv/vmbus/hv_connection.c
+++ b/sys/dev/hyperv/vmbus/hv_connection.c
@@ -74,8 +74,8 @@ hv_vmbus_get_next_version(uint32_t current_ver)
* Negotiate the highest supported hypervisor version.
*/
static int
-hv_vmbus_negotiate_version(hv_vmbus_channel_msg_info *msg_info,
- uint32_t version)
+hv_vmbus_negotiate_version(struct vmbus_softc *sc,
+ hv_vmbus_channel_msg_info *msg_info, uint32_t version)
{
int ret = 0;
hv_vmbus_channel_initiate_contact *msg;
@@ -86,14 +86,9 @@ hv_vmbus_negotiate_version(hv_vmbus_channel_msg_info *msg_info,
msg->header.message_type = HV_CHANNEL_MESSAGE_INITIATED_CONTACT;
msg->vmbus_version_requested = version;
- msg->interrupt_page = hv_get_phys_addr(
- hv_vmbus_g_connection.interrupt_page);
-
- msg->monitor_page_1 = hv_get_phys_addr(
- hv_vmbus_g_connection.monitor_page_1);
-
- msg->monitor_page_2 = hv_get_phys_addr(
- hv_vmbus_g_connection.monitor_page_2);
+ msg->interrupt_page = sc->vmbus_evtflags_dma.hv_paddr;
+ msg->monitor_page_1 = sc->vmbus_mnf1_dma.hv_paddr;
+ msg->monitor_page_2 = sc->vmbus_mnf2_dma.hv_paddr;
/**
* Add to list before we send the request since we may receive the
@@ -150,7 +145,7 @@ hv_vmbus_negotiate_version(hv_vmbus_channel_msg_info *msg_info,
* Send a connect request on the partition service connection
*/
int
-hv_vmbus_connect(void)
+hv_vmbus_connect(struct vmbus_softc *sc)
{
int ret = 0;
uint32_t version;
@@ -176,34 +171,6 @@ hv_vmbus_connect(void)
mtx_init(&hv_vmbus_g_connection.channel_lock, "vmbus channel",
NULL, MTX_DEF);
- /**
- * Setup the vmbus event connection for channel interrupt abstraction
- * stuff
- */
- hv_vmbus_g_connection.interrupt_page = malloc(
- PAGE_SIZE, M_DEVBUF,
- M_WAITOK | M_ZERO);
-
- hv_vmbus_g_connection.recv_interrupt_page =
- hv_vmbus_g_connection.interrupt_page;
-
- hv_vmbus_g_connection.send_interrupt_page =
- ((uint8_t *) hv_vmbus_g_connection.interrupt_page +
- (PAGE_SIZE >> 1));
-
- /**
- * Set up the monitor notification facility. The 1st page for
- * parent->child and the 2nd page for child->parent
- */
- hv_vmbus_g_connection.monitor_page_1 = malloc(
- PAGE_SIZE,
- M_DEVBUF,
- M_WAITOK | M_ZERO);
- hv_vmbus_g_connection.monitor_page_2 = malloc(
- PAGE_SIZE,
- M_DEVBUF,
- M_WAITOK | M_ZERO);
-
msg_info = (hv_vmbus_channel_msg_info*)
malloc(sizeof(hv_vmbus_channel_msg_info) +
sizeof(hv_vmbus_channel_initiate_contact),
@@ -217,7 +184,7 @@ hv_vmbus_connect(void)
version = HV_VMBUS_VERSION_CURRENT;
do {
- ret = hv_vmbus_negotiate_version(msg_info, version);
+ ret = hv_vmbus_negotiate_version(sc, msg_info, version);
if (ret == EWOULDBLOCK) {
/*
* We timed out.
@@ -251,14 +218,6 @@ hv_vmbus_connect(void)
mtx_destroy(&hv_vmbus_g_connection.channel_lock);
mtx_destroy(&hv_vmbus_g_connection.channel_msg_lock);
- if (hv_vmbus_g_connection.interrupt_page != NULL) {
- free(hv_vmbus_g_connection.interrupt_page, M_DEVBUF);
- hv_vmbus_g_connection.interrupt_page = NULL;
- }
-
- free(hv_vmbus_g_connection.monitor_page_1, M_DEVBUF);
- free(hv_vmbus_g_connection.monitor_page_2, M_DEVBUF);
-
if (msg_info) {
sema_destroy(&msg_info->wait_sema);
free(msg_info, M_DEVBUF);
@@ -281,8 +240,6 @@ hv_vmbus_disconnect(void)
ret = hv_vmbus_post_message(&msg, sizeof(hv_vmbus_channel_unload));
- free(hv_vmbus_g_connection.interrupt_page, M_DEVBUF);
-
mtx_destroy(&hv_vmbus_g_connection.channel_msg_lock);
free(hv_vmbus_g_connection.channels, M_DEVBUF);
@@ -343,14 +300,13 @@ vmbus_event_proc(struct vmbus_softc *sc, int cpu)
}
void
-vmbus_event_proc_compat(struct vmbus_softc *sc __unused, int cpu)
+vmbus_event_proc_compat(struct vmbus_softc *sc, int cpu)
{
struct vmbus_evtflags *eventf;
eventf = VMBUS_PCPU_GET(sc, event_flags, cpu) + VMBUS_SINT_MESSAGE;
if (atomic_testandclear_long(&eventf->evt_flags[0], 0)) {
- vmbus_event_flags_proc(
- hv_vmbus_g_connection.recv_interrupt_page,
+ vmbus_event_flags_proc(sc->vmbus_rx_evtflags,
VMBUS_CHAN_MAX_COMPAT >> VMBUS_EVTFLAG_SHIFT);
}
}
@@ -395,14 +351,12 @@ int hv_vmbus_post_message(void *buffer, size_t bufferLen)
int
hv_vmbus_set_event(hv_vmbus_channel *channel)
{
+ struct vmbus_softc *sc = vmbus_get_softc();
int ret = 0;
- uint32_t child_rel_id = channel->offer_msg.child_rel_id;
-
- /* Each uint32_t represents 32 channels */
+ uint32_t chanid = channel->offer_msg.child_rel_id;
- synch_set_bit(child_rel_id & 31,
- (((uint32_t *)hv_vmbus_g_connection.send_interrupt_page
- + (child_rel_id >> 5))));
+ atomic_set_long(&sc->vmbus_tx_evtflags[chanid >> VMBUS_EVTFLAG_SHIFT],
+ 1UL << (chanid & VMBUS_EVTFLAG_MASK));
ret = hv_vmbus_signal_event(channel->signal_event_param);
return (ret);
diff --git a/sys/dev/hyperv/vmbus/hv_vmbus_priv.h b/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
index f7ea849..0008226 100644
--- a/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
+++ b/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
@@ -244,25 +244,7 @@ typedef enum {
typedef struct {
hv_vmbus_connect_state connect_state;
uint32_t next_gpadl_handle;
- /**
- * Represents channel interrupts. Each bit position
- * represents a channel.
- * When a channel sends an interrupt via VMBUS, it
- * finds its bit in the send_interrupt_page, set it and
- * calls Hv to generate a port event. The other end
- * receives the port event and parse the
- * recv_interrupt_page to see which bit is set
- */
- void *interrupt_page;
- void *send_interrupt_page;
- void *recv_interrupt_page;
- /*
- * 2 pages - 1st page for parent->child
- * notification and 2nd is child->parent
- * notification
- */
- void *monitor_page_1;
- void *monitor_page_2;
+
TAILQ_HEAD(, hv_vmbus_channel_msg_info) channel_msg_anchor;
struct mtx channel_msg_lock;
/**
@@ -440,7 +422,8 @@ int hv_vmbus_child_device_unregister(
/**
* Connection interfaces
*/
-int hv_vmbus_connect(void);
+struct vmbus_softc;
+int hv_vmbus_connect(struct vmbus_softc *);
int hv_vmbus_disconnect(void);
int hv_vmbus_post_message(void *buffer, size_t buf_size);
int hv_vmbus_set_event(hv_vmbus_channel *channel);
diff --git a/sys/dev/hyperv/vmbus/vmbus.c b/sys/dev/hyperv/vmbus/vmbus.c
index bd63067..b5d1561 100644
--- a/sys/dev/hyperv/vmbus/vmbus.c
+++ b/sys/dev/hyperv/vmbus/vmbus.c
@@ -309,30 +309,50 @@ vmbus_synic_teardown(void *arg)
static int
vmbus_dma_alloc(struct vmbus_softc *sc)
{
+ bus_dma_tag_t parent_dtag;
+ uint8_t *evtflags;
int cpu;
+ parent_dtag = bus_get_dma_tag(sc->vmbus_dev);
CPU_FOREACH(cpu) {
void *ptr;
/*
* Per-cpu messages and event flags.
*/
- ptr = hyperv_dmamem_alloc(bus_get_dma_tag(sc->vmbus_dev),
- PAGE_SIZE, 0, PAGE_SIZE,
- VMBUS_PCPU_PTR(sc, message_dma, cpu),
+ ptr = hyperv_dmamem_alloc(parent_dtag, PAGE_SIZE, 0,
+ PAGE_SIZE, VMBUS_PCPU_PTR(sc, message_dma, cpu),
BUS_DMA_WAITOK | BUS_DMA_ZERO);
if (ptr == NULL)
return ENOMEM;
VMBUS_PCPU_GET(sc, message, cpu) = ptr;
- ptr = hyperv_dmamem_alloc(bus_get_dma_tag(sc->vmbus_dev),
- PAGE_SIZE, 0, PAGE_SIZE,
- VMBUS_PCPU_PTR(sc, event_flags_dma, cpu),
+ ptr = hyperv_dmamem_alloc(parent_dtag, PAGE_SIZE, 0,
+ PAGE_SIZE, VMBUS_PCPU_PTR(sc, event_flags_dma, cpu),
BUS_DMA_WAITOK | BUS_DMA_ZERO);
if (ptr == NULL)
return ENOMEM;
VMBUS_PCPU_GET(sc, event_flags, cpu) = ptr;
}
+
+ evtflags = hyperv_dmamem_alloc(parent_dtag, PAGE_SIZE, 0,
+ PAGE_SIZE, &sc->vmbus_evtflags_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO);
+ if (evtflags == NULL)
+ return ENOMEM;
+ sc->vmbus_rx_evtflags = (u_long *)evtflags;
+ sc->vmbus_tx_evtflags = (u_long *)(evtflags + (PAGE_SIZE / 2));
+ sc->vmbus_evtflags = evtflags;
+
+ sc->vmbus_mnf1 = hyperv_dmamem_alloc(parent_dtag, PAGE_SIZE, 0,
+ PAGE_SIZE, &sc->vmbus_mnf1_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO);
+ if (sc->vmbus_mnf1 == NULL)
+ return ENOMEM;
+
+ sc->vmbus_mnf2 = hyperv_dmamem_alloc(parent_dtag, PAGE_SIZE, 0,
+ PAGE_SIZE, &sc->vmbus_mnf2_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO);
+ if (sc->vmbus_mnf2 == NULL)
+ return ENOMEM;
+
return 0;
}
@@ -341,6 +361,21 @@ vmbus_dma_free(struct vmbus_softc *sc)
{
int cpu;
+ if (sc->vmbus_evtflags != NULL) {
+ hyperv_dmamem_free(&sc->vmbus_evtflags_dma, sc->vmbus_evtflags);
+ sc->vmbus_evtflags = NULL;
+ sc->vmbus_rx_evtflags = NULL;
+ sc->vmbus_tx_evtflags = NULL;
+ }
+ if (sc->vmbus_mnf1 != NULL) {
+ hyperv_dmamem_free(&sc->vmbus_mnf1_dma, sc->vmbus_mnf1);
+ sc->vmbus_mnf1 = NULL;
+ }
+ if (sc->vmbus_mnf2 != NULL) {
+ hyperv_dmamem_free(&sc->vmbus_mnf2_dma, sc->vmbus_mnf2);
+ sc->vmbus_mnf2 = NULL;
+ }
+
CPU_FOREACH(cpu) {
if (VMBUS_PCPU_GET(sc, message, cpu) != NULL) {
hyperv_dmamem_free(
@@ -609,8 +644,7 @@ vmbus_bus_init(void)
/*
* Connect to VMBus in the root partition
*/
- ret = hv_vmbus_connect();
-
+ ret = hv_vmbus_connect(sc);
if (ret != 0)
goto cleanup;
diff --git a/sys/dev/hyperv/vmbus/vmbus_reg.h b/sys/dev/hyperv/vmbus/vmbus_reg.h
index 4be7f1b..4be8614 100644
--- a/sys/dev/hyperv/vmbus/vmbus_reg.h
+++ b/sys/dev/hyperv/vmbus/vmbus_reg.h
@@ -66,6 +66,7 @@ CTASSERT(sizeof(struct vmbus_message) == VMBUS_MSG_SIZE);
#define VMBUS_EVTFLAG_SHIFT 5
#endif
#define VMBUS_EVTFLAG_LEN (1 << VMBUS_EVTFLAG_SHIFT)
+#define VMBUS_EVTFLAG_MASK (VMBUS_EVTFLAG_LEN - 1)
#define VMBUS_EVTFLAGS_SIZE 256
struct vmbus_evtflags {
diff --git a/sys/dev/hyperv/vmbus/vmbus_var.h b/sys/dev/hyperv/vmbus/vmbus_var.h
index 440f4d3..70ac5ee 100644
--- a/sys/dev/hyperv/vmbus/vmbus_var.h
+++ b/sys/dev/hyperv/vmbus/vmbus_var.h
@@ -51,7 +51,7 @@ struct vmbus_pcpu_data {
struct vmbus_message *message; /* shared messages */
uint32_t vcpuid; /* virtual cpuid */
int event_flags_cnt;/* # of event flags */
- struct vmbus_evtflags *event_flags; /* shared event flags */
+ struct vmbus_evtflags *event_flags; /* event flags from host */
/* Rarely used fields */
struct hyperv_dma message_dma; /* busdma glue */
@@ -63,12 +63,26 @@ struct vmbus_pcpu_data {
struct vmbus_softc {
void (*vmbus_event_proc)(struct vmbus_softc *, int);
+ u_long *vmbus_tx_evtflags;
+ /* event flags to host */
+ void *vmbus_mnf2; /* monitored by host */
+
+ u_long *vmbus_rx_evtflags;
+ /* compat evtflgs from host */
struct vmbus_pcpu_data vmbus_pcpu[MAXCPU];
/* Rarely used fields */
device_t vmbus_dev;
int vmbus_idtvec;
uint32_t vmbus_flags; /* see VMBUS_FLAG_ */
+
+ /* Shared memory for vmbus_{rx,tx}_evtflags */
+ void *vmbus_evtflags;
+ struct hyperv_dma vmbus_evtflags_dma;
+
+ void *vmbus_mnf1; /* monitored by VM, unused */
+ struct hyperv_dma vmbus_mnf1_dma;
+ struct hyperv_dma vmbus_mnf2_dma;
};
#define VMBUS_FLAG_ATTACHED 0x0001 /* vmbus was attached */
diff --git a/sys/dev/ioat/ioat.c b/sys/dev/ioat/ioat.c
index abdfe61..1a10c25 100644
--- a/sys/dev/ioat/ioat.c
+++ b/sys/dev/ioat/ioat.c
@@ -27,6 +27,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "opt_ddb.h"
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@@ -48,6 +50,10 @@ __FBSDID("$FreeBSD$");
#include <machine/resource.h>
#include <machine/stdarg.h>
+#ifdef DDB
+#include <ddb/ddb.h>
+#endif
+
#include "ioat.h"
#include "ioat_hw.h"
#include "ioat_internal.h"
@@ -2090,3 +2096,96 @@ ioat_drain_locked(struct ioat_softc *ioat)
while (ioat->refcnt > 0)
msleep(IOAT_REFLK, IOAT_REFLK, 0, "ioat_drain", 0);
}
+
+#ifdef DDB
+#define _db_show_lock(lo) LOCK_CLASS(lo)->lc_ddb_show(lo)
+#define db_show_lock(lk) _db_show_lock(&(lk)->lock_object)
+DB_SHOW_COMMAND(ioat, db_show_ioat)
+{
+ struct ioat_softc *sc;
+ unsigned idx;
+
+ if (!have_addr)
+ goto usage;
+ idx = (unsigned)addr;
+ if (addr >= ioat_channel_index)
+ goto usage;
+
+ sc = ioat_channel[idx];
+ db_printf("ioat softc at %p\n", sc);
+ if (sc == NULL)
+ return;
+
+ db_printf(" version: %d\n", sc->version);
+ db_printf(" chan_idx: %u\n", sc->chan_idx);
+ db_printf(" submit_lock: ");
+ db_show_lock(&sc->submit_lock);
+
+ db_printf(" capabilities: %b\n", (int)sc->capabilities,
+ IOAT_DMACAP_STR);
+ db_printf(" cached_intrdelay: %u\n", sc->cached_intrdelay);
+ db_printf(" *comp_update: 0x%jx\n", (uintmax_t)*sc->comp_update);
+
+ db_printf(" timer:\n");
+ db_printf(" c_time: %ju\n", (uintmax_t)sc->timer.c_time);
+ db_printf(" c_arg: %p\n", sc->timer.c_arg);
+ db_printf(" c_func: %p\n", sc->timer.c_func);
+ db_printf(" c_lock: %p\n", sc->timer.c_lock);
+ db_printf(" c_flags: 0x%x\n", (unsigned)sc->timer.c_flags);
+
+ db_printf(" quiescing: %d\n", (int)sc->quiescing);
+ db_printf(" destroying: %d\n", (int)sc->destroying);
+ db_printf(" is_resize_pending: %d\n", (int)sc->is_resize_pending);
+ db_printf(" is_completion_pending: %d\n", (int)sc->is_completion_pending);
+ db_printf(" is_reset_pending: %d\n", (int)sc->is_reset_pending);
+ db_printf(" is_channel_running: %d\n", (int)sc->is_channel_running);
+ db_printf(" intrdelay_supported: %d\n", (int)sc->intrdelay_supported);
+
+ db_printf(" head: %u\n", sc->head);
+ db_printf(" tail: %u\n", sc->tail);
+ db_printf(" hw_head: %u\n", sc->hw_head);
+ db_printf(" ring_size_order: %u\n", sc->ring_size_order);
+ db_printf(" last_seen: 0x%lx\n", sc->last_seen);
+ db_printf(" ring: %p\n", sc->ring);
+
+ db_printf(" cleanup_lock: ");
+ db_show_lock(&sc->cleanup_lock);
+
+ db_printf(" refcnt: %u\n", sc->refcnt);
+#ifdef INVARIANTS
+ CTASSERT(IOAT_NUM_REF_KINDS == 2);
+ db_printf(" refkinds: [ENG=%u, DESCR=%u]\n", sc->refkinds[0],
+ sc->refkinds[1]);
+#endif
+ db_printf(" stats:\n");
+ db_printf(" interrupts: %lu\n", sc->stats.interrupts);
+ db_printf(" descriptors_processed: %lu\n", sc->stats.descriptors_processed);
+ db_printf(" descriptors_error: %lu\n", sc->stats.descriptors_error);
+ db_printf(" descriptors_submitted: %lu\n", sc->stats.descriptors_submitted);
+
+ db_printf(" channel_halts: %u\n", sc->stats.channel_halts);
+ db_printf(" last_halt_chanerr: %u\n", sc->stats.last_halt_chanerr);
+
+ if (db_pager_quit)
+ return;
+
+ db_printf(" hw status:\n");
+ db_printf(" status: 0x%lx\n", ioat_get_chansts(sc));
+ db_printf(" chanctrl: 0x%x\n",
+ (unsigned)ioat_read_2(sc, IOAT_CHANCTRL_OFFSET));
+ db_printf(" chancmd: 0x%x\n",
+ (unsigned)ioat_read_1(sc, IOAT_CHANCMD_OFFSET));
+ db_printf(" dmacount: 0x%x\n",
+ (unsigned)ioat_read_2(sc, IOAT_DMACOUNT_OFFSET));
+ db_printf(" chainaddr: 0x%lx\n",
+ ioat_read_double_4(sc, IOAT_CHAINADDR_OFFSET_LOW));
+ db_printf(" chancmp: 0x%lx\n",
+ ioat_read_double_4(sc, IOAT_CHANCMP_OFFSET_LOW));
+ db_printf(" chanerr: %b\n",
+ (int)ioat_read_4(sc, IOAT_CHANERR_OFFSET), IOAT_CHANERR_STR);
+ return;
+usage:
+ db_printf("usage: show ioat <0-%u>\n", ioat_channel_index);
+ return;
+}
+#endif /* DDB */
diff --git a/sys/dev/iscsi/iscsi_ioctl.h b/sys/dev/iscsi/iscsi_ioctl.h
index 21da22e..a494cd5 100644
--- a/sys/dev/iscsi/iscsi_ioctl.h
+++ b/sys/dev/iscsi/iscsi_ioctl.h
@@ -68,7 +68,7 @@ struct iscsi_session_conf {
int isc_iser;
char isc_offload[ISCSI_OFFLOAD_LEN];
int isc_enable;
- int isc_spare[1];
+ int isc_spare[4];
};
/*
@@ -77,6 +77,7 @@ struct iscsi_session_conf {
*/
struct iscsi_session_limits {
size_t isl_max_data_segment_length;
+ int isl_spare[8];
};
/*
@@ -89,12 +90,13 @@ struct iscsi_session_state {
int iss_header_digest;
int iss_data_digest;
int iss_max_data_segment_length;
+ int iss_max_burst_length;
+ int iss_first_burst_length;
int iss_immediate_data;
int iss_connected;
char iss_reason[ISCSI_REASON_LEN];
char iss_offload[ISCSI_OFFLOAD_LEN];
- int iss_max_burst_length;
- int iss_first_burst_length;
+ int iss_spare[4];
};
/*
@@ -107,7 +109,7 @@ struct iscsi_daemon_request {
uint16_t idr_tsih;
uint16_t idr_spare_cid;
struct iscsi_session_limits idr_limits;
- int idr_spare[2];
+ int idr_spare[4];
};
struct iscsi_daemon_handoff {
@@ -120,11 +122,11 @@ struct iscsi_daemon_handoff {
uint32_t idh_statsn;
int idh_header_digest;
int idh_data_digest;
- int idh_initial_r2t;
- int idh_immediate_data;
size_t idh_max_data_segment_length;
size_t idh_max_burst_length;
size_t idh_first_burst_length;
+ int idh_immediate_data;
+ int idh_initial_r2t;
int idh_spare[4];
};
@@ -156,7 +158,7 @@ struct iscsi_daemon_fail {
*/
struct iscsi_daemon_connect {
- int idc_session_id;
+ unsigned int idc_session_id;
int idc_iser;
int idc_domain;
int idc_socktype;
@@ -169,7 +171,7 @@ struct iscsi_daemon_connect {
};
struct iscsi_daemon_send {
- int ids_session_id;
+ unsigned int ids_session_id;
void *ids_bhs;
size_t ids_spare;
void *ids_spare2;
@@ -179,7 +181,7 @@ struct iscsi_daemon_send {
};
struct iscsi_daemon_receive {
- int idr_session_id;
+ unsigned int idr_session_id;
void *idr_bhs;
size_t idr_spare;
void *idr_spare2;
diff --git a/sys/dev/iwm/if_iwm.c b/sys/dev/iwm/if_iwm.c
index b60d053..5821555 100644
--- a/sys/dev/iwm/if_iwm.c
+++ b/sys/dev/iwm/if_iwm.c
@@ -866,10 +866,28 @@ iwm_alloc_rx_ring(struct iwm_softc *sc, struct iwm_rx_ring *ring)
goto fail;
}
+ /* Allocate spare bus_dmamap_t for iwm_rx_addbuf() */
+ error = bus_dmamap_create(ring->data_dmat, 0, &ring->spare_map);
+ if (error != 0) {
+ device_printf(sc->sc_dev,
+ "%s: could not create RX buf DMA map, error %d\n",
+ __func__, error);
+ goto fail;
+ }
/*
* Allocate and map RX buffers.
*/
for (i = 0; i < IWM_RX_RING_COUNT; i++) {
+ struct iwm_rx_data *data = &ring->data[i];
+ error = bus_dmamap_create(ring->data_dmat, 0, &data->map);
+ if (error != 0) {
+ device_printf(sc->sc_dev,
+ "%s: could not create RX buf DMA map, error %d\n",
+ __func__, error);
+ goto fail;
+ }
+ data->m = NULL;
+
if ((error = iwm_rx_addbuf(sc, IWM_RBUF_SIZE, i)) != 0) {
goto fail;
}
@@ -923,6 +941,10 @@ iwm_free_rx_ring(struct iwm_softc *sc, struct iwm_rx_ring *ring)
data->map = NULL;
}
}
+ if (ring->spare_map != NULL) {
+ bus_dmamap_destroy(ring->data_dmat, ring->spare_map);
+ ring->spare_map = NULL;
+ }
if (ring->data_dmat != NULL) {
bus_dma_tag_destroy(ring->data_dmat);
ring->data_dmat = NULL;
@@ -2119,6 +2141,7 @@ iwm_rx_addbuf(struct iwm_softc *sc, int size, int idx)
struct iwm_rx_ring *ring = &sc->rxq;
struct iwm_rx_data *data = &ring->data[idx];
struct mbuf *m;
+ bus_dmamap_t dmamap = NULL;
int error;
bus_addr_t paddr;
@@ -2126,28 +2149,26 @@ iwm_rx_addbuf(struct iwm_softc *sc, int size, int idx)
if (m == NULL)
return ENOBUFS;
- if (data->m != NULL)
- bus_dmamap_unload(ring->data_dmat, data->map);
-
m->m_len = m->m_pkthdr.len = m->m_ext.ext_size;
- error = bus_dmamap_create(ring->data_dmat, 0, &data->map);
- if (error != 0) {
- device_printf(sc->sc_dev,
- "%s: could not create RX buf DMA map, error %d\n",
- __func__, error);
- goto fail;
- }
- data->m = m;
- error = bus_dmamap_load(ring->data_dmat, data->map,
- mtod(data->m, void *), IWM_RBUF_SIZE, iwm_dma_map_addr,
+ error = bus_dmamap_load(ring->data_dmat, ring->spare_map,
+ mtod(m, void *), IWM_RBUF_SIZE, iwm_dma_map_addr,
&paddr, BUS_DMA_NOWAIT);
if (error != 0 && error != EFBIG) {
device_printf(sc->sc_dev,
- "%s: can't not map mbuf, error %d\n", __func__,
- error);
+ "%s: can't map mbuf, error %d\n", __func__, error);
goto fail;
}
+
+ if (data->m != NULL)
+ bus_dmamap_unload(ring->data_dmat, data->map);
+
+ /* Swap ring->spare_map with data->map */
+ dmamap = data->map;
+ data->map = ring->spare_map;
+ ring->spare_map = dmamap;
+
bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_PREREAD);
+ data->m = m;
/* Update RX descriptor. */
ring->desc[idx] = htole32(paddr >> 8);
@@ -2156,6 +2177,7 @@ iwm_rx_addbuf(struct iwm_softc *sc, int size, int idx)
return 0;
fail:
+ m_free(m);
return error;
}
diff --git a/sys/dev/iwm/if_iwmvar.h b/sys/dev/iwm/if_iwmvar.h
index ef2eac4..e923aa4 100644
--- a/sys/dev/iwm/if_iwmvar.h
+++ b/sys/dev/iwm/if_iwmvar.h
@@ -289,6 +289,7 @@ struct iwm_rx_ring {
uint32_t *desc;
struct iwm_rb_status *stat;
struct iwm_rx_data data[IWM_RX_RING_COUNT];
+ bus_dmamap_t spare_map; /* for iwm_rx_addbuf() */
bus_dma_tag_t data_dmat;
int cur;
};
diff --git a/sys/dev/ixgbe/ix_txrx.c b/sys/dev/ixgbe/ix_txrx.c
index 2f5663f..61c2ef0 100644
--- a/sys/dev/ixgbe/ix_txrx.c
+++ b/sys/dev/ixgbe/ix_txrx.c
@@ -1964,7 +1964,7 @@ ixgbe_rxeof(struct ix_queue *que)
#endif
default:
M_HASHTYPE_SET(sendmp,
- M_HASHTYPE_OPAQUE);
+ M_HASHTYPE_OPAQUE_HASH);
}
} else {
sendmp->m_pkthdr.flowid = que->msix;
diff --git a/sys/dev/ixl/ixl_txrx.c b/sys/dev/ixl/ixl_txrx.c
index fc57f4e..d3aa7bf 100644
--- a/sys/dev/ixl/ixl_txrx.c
+++ b/sys/dev/ixl/ixl_txrx.c
@@ -1453,10 +1453,10 @@ ixl_ptype_to_hash(u8 ptype)
ex = decoded.outer_frag;
if (!decoded.known)
- return M_HASHTYPE_OPAQUE;
+ return M_HASHTYPE_OPAQUE_HASH;
if (decoded.outer_ip == I40E_RX_PTYPE_OUTER_L2)
- return M_HASHTYPE_OPAQUE;
+ return M_HASHTYPE_OPAQUE_HASH;
/* Note: anything that gets to this point is IP */
if (decoded.outer_ip_ver == I40E_RX_PTYPE_OUTER_IPV6) {
@@ -1492,7 +1492,7 @@ ixl_ptype_to_hash(u8 ptype)
}
}
/* We should never get here!! */
- return M_HASHTYPE_OPAQUE;
+ return M_HASHTYPE_OPAQUE_HASH;
}
#endif /* RSS */
diff --git a/sys/dev/mii/miidevs b/sys/dev/mii/miidevs
index e2c408f..ef6550d 100644
--- a/sys/dev/mii/miidevs
+++ b/sys/dev/mii/miidevs
@@ -343,3 +343,4 @@ model xxXAQTI XMACII 0x0000 XaQti Corp. XMAC II gigabit interface
/* SMC */
model SMC LAN8710A 0x000F SMC LAN8710A 10/100 interface
+model SMC LAN8700 0x000C SMC LAN8700 10/100 interface
diff --git a/sys/dev/mii/smscphy.c b/sys/dev/mii/smscphy.c
index 1d6ce61..43b7087 100644
--- a/sys/dev/mii/smscphy.c
+++ b/sys/dev/mii/smscphy.c
@@ -77,6 +77,7 @@ DRIVER_MODULE(smscphy, miibus, smscphy_driver, smscphy_devclass, 0, 0);
static const struct mii_phydesc smscphys[] = {
MII_PHY_DESC(SMC, LAN8710A),
+ MII_PHY_DESC(SMC, LAN8700),
MII_PHY_END
};
diff --git a/sys/dev/mlx5/driver.h b/sys/dev/mlx5/driver.h
index 8136e57..7f64850 100644
--- a/sys/dev/mlx5/driver.h
+++ b/sys/dev/mlx5/driver.h
@@ -33,6 +33,7 @@
#include <linux/pci.h>
#include <linux/cache.h>
#include <linux/rbtree.h>
+#include <linux/if_ether.h>
#include <linux/semaphore.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
diff --git a/sys/dev/mlx5/mlx5_core/mlx5_vport.c b/sys/dev/mlx5/mlx5_core/mlx5_vport.c
index 5c8626b..6ef5019 100644
--- a/sys/dev/mlx5/mlx5_core/mlx5_vport.c
+++ b/sys/dev/mlx5/mlx5_core/mlx5_vport.c
@@ -471,6 +471,241 @@ int mlx5_set_nic_vport_promisc(struct mlx5_core_dev *mdev, int vport,
return mlx5_modify_nic_vport_context(mdev, in, sizeof(in));
}
EXPORT_SYMBOL_GPL(mlx5_set_nic_vport_promisc);
+
+int mlx5_query_nic_vport_mac_list(struct mlx5_core_dev *dev,
+ u32 vport,
+ enum mlx5_list_type list_type,
+ u8 addr_list[][ETH_ALEN],
+ int *list_size)
+{
+ u32 in[MLX5_ST_SZ_DW(query_nic_vport_context_in)];
+ void *nic_vport_ctx;
+ int max_list_size;
+ int req_list_size;
+ u8 *mac_addr;
+ int out_sz;
+ void *out;
+ int err;
+ int i;
+
+ req_list_size = *list_size;
+
+ max_list_size = (list_type == MLX5_NIC_VPORT_LIST_TYPE_UC) ?
+ 1 << MLX5_CAP_GEN_MAX(dev, log_max_current_uc_list) :
+ 1 << MLX5_CAP_GEN_MAX(dev, log_max_current_mc_list);
+
+ if (req_list_size > max_list_size) {
+ mlx5_core_warn(dev, "Requested list size (%d) > (%d) max_list_size\n",
+ req_list_size, max_list_size);
+ req_list_size = max_list_size;
+ }
+
+ out_sz = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in) +
+ req_list_size * MLX5_ST_SZ_BYTES(mac_address_layout);
+
+ memset(in, 0, sizeof(in));
+ out = kzalloc(out_sz, GFP_KERNEL);
+ if (!out)
+ return -ENOMEM;
+
+ MLX5_SET(query_nic_vport_context_in, in, opcode,
+ MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT);
+ MLX5_SET(query_nic_vport_context_in, in, allowed_list_type, list_type);
+ MLX5_SET(query_nic_vport_context_in, in, vport_number, vport);
+
+ if (vport)
+ MLX5_SET(query_nic_vport_context_in, in, other_vport, 1);
+
+ err = mlx5_cmd_exec_check_status(dev, in, sizeof(in), out, out_sz);
+ if (err)
+ goto out;
+
+ nic_vport_ctx = MLX5_ADDR_OF(query_nic_vport_context_out, out,
+ nic_vport_context);
+ req_list_size = MLX5_GET(nic_vport_context, nic_vport_ctx,
+ allowed_list_size);
+
+ *list_size = req_list_size;
+ for (i = 0; i < req_list_size; i++) {
+ mac_addr = MLX5_ADDR_OF(nic_vport_context,
+ nic_vport_ctx,
+ current_uc_mac_address[i]) + 2;
+ ether_addr_copy(addr_list[i], mac_addr);
+ }
+out:
+ kfree(out);
+ return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_mac_list);
+
+int mlx5_modify_nic_vport_mac_list(struct mlx5_core_dev *dev,
+ enum mlx5_list_type list_type,
+ u8 addr_list[][ETH_ALEN],
+ int list_size)
+{
+ u32 out[MLX5_ST_SZ_DW(modify_nic_vport_context_out)];
+ void *nic_vport_ctx;
+ int max_list_size;
+ int in_sz;
+ void *in;
+ int err;
+ int i;
+
+ max_list_size = list_type == MLX5_NIC_VPORT_LIST_TYPE_UC ?
+ 1 << MLX5_CAP_GEN(dev, log_max_current_uc_list) :
+ 1 << MLX5_CAP_GEN(dev, log_max_current_mc_list);
+
+ if (list_size > max_list_size)
+ return -ENOSPC;
+
+ in_sz = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in) +
+ list_size * MLX5_ST_SZ_BYTES(mac_address_layout);
+
+ memset(out, 0, sizeof(out));
+ in = kzalloc(in_sz, GFP_KERNEL);
+ if (!in)
+ return -ENOMEM;
+
+ MLX5_SET(modify_nic_vport_context_in, in, opcode,
+ MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
+ MLX5_SET(modify_nic_vport_context_in, in,
+ field_select.addresses_list, 1);
+
+ nic_vport_ctx = MLX5_ADDR_OF(modify_nic_vport_context_in, in,
+ nic_vport_context);
+
+ MLX5_SET(nic_vport_context, nic_vport_ctx,
+ allowed_list_type, list_type);
+ MLX5_SET(nic_vport_context, nic_vport_ctx,
+ allowed_list_size, list_size);
+
+ for (i = 0; i < list_size; i++) {
+ u8 *curr_mac = MLX5_ADDR_OF(nic_vport_context,
+ nic_vport_ctx,
+ current_uc_mac_address[i]) + 2;
+ ether_addr_copy(curr_mac, addr_list[i]);
+ }
+
+ err = mlx5_cmd_exec_check_status(dev, in, in_sz, out, sizeof(out));
+ kfree(in);
+ return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_modify_nic_vport_mac_list);
+
+int mlx5_query_nic_vport_vlan_list(struct mlx5_core_dev *dev,
+ u32 vport,
+ u16 *vlan_list,
+ int *list_size)
+{
+ u32 in[MLX5_ST_SZ_DW(query_nic_vport_context_in)];
+ void *nic_vport_ctx;
+ int max_list_size;
+ int req_list_size;
+ int out_sz;
+ void *out;
+ void *vlan_addr;
+ int err;
+ int i;
+
+ req_list_size = *list_size;
+
+ max_list_size = 1 << MLX5_CAP_GEN_MAX(dev, log_max_vlan_list);
+
+ if (req_list_size > max_list_size) {
+ mlx5_core_warn(dev, "Requested list size (%d) > (%d) max_list_size\n",
+ req_list_size, max_list_size);
+ req_list_size = max_list_size;
+ }
+
+ out_sz = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in) +
+ req_list_size * MLX5_ST_SZ_BYTES(vlan_layout);
+
+ memset(in, 0, sizeof(in));
+ out = kzalloc(out_sz, GFP_KERNEL);
+ if (!out)
+ return -ENOMEM;
+
+ MLX5_SET(query_nic_vport_context_in, in, opcode,
+ MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT);
+ MLX5_SET(query_nic_vport_context_in, in, allowed_list_type,
+ MLX5_NIC_VPORT_CONTEXT_ALLOWED_LIST_TYPE_VLAN_LIST);
+ MLX5_SET(query_nic_vport_context_in, in, vport_number, vport);
+
+ if (vport)
+ MLX5_SET(query_nic_vport_context_in, in, other_vport, 1);
+
+ err = mlx5_cmd_exec_check_status(dev, in, sizeof(in), out, out_sz);
+ if (err)
+ goto out;
+
+ nic_vport_ctx = MLX5_ADDR_OF(query_nic_vport_context_out, out,
+ nic_vport_context);
+ req_list_size = MLX5_GET(nic_vport_context, nic_vport_ctx,
+ allowed_list_size);
+
+ *list_size = req_list_size;
+ for (i = 0; i < req_list_size; i++) {
+ vlan_addr = MLX5_ADDR_OF(nic_vport_context, nic_vport_ctx,
+ current_uc_mac_address[i]);
+ vlan_list[i] = MLX5_GET(vlan_layout, vlan_addr, vlan);
+ }
+out:
+ kfree(out);
+ return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_vlan_list);
+
+int mlx5_modify_nic_vport_vlans(struct mlx5_core_dev *dev,
+ u16 vlans[],
+ int list_size)
+{
+ u32 out[MLX5_ST_SZ_DW(modify_nic_vport_context_out)];
+ void *nic_vport_ctx;
+ int max_list_size;
+ int in_sz;
+ void *in;
+ int err;
+ int i;
+
+ max_list_size = 1 << MLX5_CAP_GEN(dev, log_max_vlan_list);
+
+ if (list_size > max_list_size)
+ return -ENOSPC;
+
+ in_sz = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in) +
+ list_size * MLX5_ST_SZ_BYTES(vlan_layout);
+
+ memset(out, 0, sizeof(out));
+ in = kzalloc(in_sz, GFP_KERNEL);
+ if (!in)
+ return -ENOMEM;
+
+ MLX5_SET(modify_nic_vport_context_in, in, opcode,
+ MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
+ MLX5_SET(modify_nic_vport_context_in, in,
+ field_select.addresses_list, 1);
+
+ nic_vport_ctx = MLX5_ADDR_OF(modify_nic_vport_context_in, in,
+ nic_vport_context);
+
+ MLX5_SET(nic_vport_context, nic_vport_ctx,
+ allowed_list_type, MLX5_NIC_VPORT_LIST_TYPE_VLAN);
+ MLX5_SET(nic_vport_context, nic_vport_ctx,
+ allowed_list_size, list_size);
+
+ for (i = 0; i < list_size; i++) {
+ void *vlan_addr = MLX5_ADDR_OF(nic_vport_context,
+ nic_vport_ctx,
+ current_uc_mac_address[i]);
+ MLX5_SET(vlan_layout, vlan_addr, vlan, vlans[i]);
+ }
+
+ err = mlx5_cmd_exec_check_status(dev, in, in_sz, out, sizeof(out));
+ kfree(in);
+ return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_modify_nic_vport_vlans);
+
int mlx5_set_nic_vport_permanent_mac(struct mlx5_core_dev *mdev, int vport,
u8 *addr)
{
@@ -785,6 +1020,129 @@ int mlx5_set_eswitch_cvlan_info(struct mlx5_core_dev *mdev, u8 vport,
}
EXPORT_SYMBOL_GPL(mlx5_set_eswitch_cvlan_info);
+int mlx5_arm_vport_context_events(struct mlx5_core_dev *mdev,
+ u8 vport,
+ u32 events_mask)
+{
+ u32 *in;
+ u32 inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in);
+ void *nic_vport_ctx;
+ int err;
+
+ in = mlx5_vzalloc(inlen);
+ if (!in)
+ return -ENOMEM;
+
+ MLX5_SET(modify_nic_vport_context_in,
+ in,
+ opcode,
+ MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
+ MLX5_SET(modify_nic_vport_context_in,
+ in,
+ field_select.change_event,
+ 1);
+ MLX5_SET(modify_nic_vport_context_in, in, vport_number, vport);
+ if (vport)
+ MLX5_SET(modify_nic_vport_context_in, in, other_vport, 1);
+ nic_vport_ctx = MLX5_ADDR_OF(modify_nic_vport_context_in,
+ in,
+ nic_vport_context);
+
+ MLX5_SET(nic_vport_context, nic_vport_ctx, arm_change_event, 1);
+
+ if (events_mask & MLX5_UC_ADDR_CHANGE)
+ MLX5_SET(nic_vport_context,
+ nic_vport_ctx,
+ event_on_uc_address_change,
+ 1);
+ if (events_mask & MLX5_MC_ADDR_CHANGE)
+ MLX5_SET(nic_vport_context,
+ nic_vport_ctx,
+ event_on_mc_address_change,
+ 1);
+ if (events_mask & MLX5_VLAN_CHANGE)
+ MLX5_SET(nic_vport_context,
+ nic_vport_ctx,
+ event_on_vlan_change,
+ 1);
+ if (events_mask & MLX5_PROMISC_CHANGE)
+ MLX5_SET(nic_vport_context,
+ nic_vport_ctx,
+ event_on_promisc_change,
+ 1);
+ if (events_mask & MLX5_MTU_CHANGE)
+ MLX5_SET(nic_vport_context,
+ nic_vport_ctx,
+ event_on_mtu,
+ 1);
+
+ err = mlx5_modify_nic_vport_context(mdev, in, inlen);
+
+ kvfree(in);
+ return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_arm_vport_context_events);
+
+int mlx5_query_vport_promisc(struct mlx5_core_dev *mdev,
+ u32 vport,
+ u8 *promisc_uc,
+ u8 *promisc_mc,
+ u8 *promisc_all)
+{
+ u32 *out;
+ int outlen = MLX5_ST_SZ_BYTES(query_nic_vport_context_out);
+ int err;
+
+ out = kzalloc(outlen, GFP_KERNEL);
+ if (!out)
+ return -ENOMEM;
+
+ err = mlx5_query_nic_vport_context(mdev, vport, out, outlen);
+ if (err)
+ goto out;
+
+ *promisc_uc = MLX5_GET(query_nic_vport_context_out, out,
+ nic_vport_context.promisc_uc);
+ *promisc_mc = MLX5_GET(query_nic_vport_context_out, out,
+ nic_vport_context.promisc_mc);
+ *promisc_all = MLX5_GET(query_nic_vport_context_out, out,
+ nic_vport_context.promisc_all);
+
+out:
+ kfree(out);
+ return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_promisc);
+
+int mlx5_modify_nic_vport_promisc(struct mlx5_core_dev *mdev,
+ int promisc_uc,
+ int promisc_mc,
+ int promisc_all)
+{
+ void *in;
+ int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in);
+ int err;
+
+ in = mlx5_vzalloc(inlen);
+ if (!in) {
+ mlx5_core_err(mdev, "failed to allocate inbox\n");
+ return -ENOMEM;
+ }
+
+ MLX5_SET(modify_nic_vport_context_in, in, field_select.promisc, 1);
+ MLX5_SET(modify_nic_vport_context_in, in,
+ nic_vport_context.promisc_uc, promisc_uc);
+ MLX5_SET(modify_nic_vport_context_in, in,
+ nic_vport_context.promisc_mc, promisc_mc);
+ MLX5_SET(modify_nic_vport_context_in, in,
+ nic_vport_context.promisc_all, promisc_all);
+
+ err = mlx5_modify_nic_vport_context(mdev, in, inlen);
+ kvfree(in);
+ return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_modify_nic_vport_promisc);
+
int mlx5_query_vport_counter(struct mlx5_core_dev *dev,
u8 port_num, u16 vport_num,
void *out, int out_size)
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c b/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c
index c618c92..a0dcd2d 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c
@@ -390,6 +390,49 @@ add_eth_addr_rule_out:
return (err);
}
+static int mlx5e_vport_context_update_vlans(struct mlx5e_priv *priv)
+{
+ struct ifnet *ifp = priv->ifp;
+ int max_list_size;
+ int list_size;
+ u16 *vlans;
+ int vlan;
+ int err;
+ int i;
+
+ list_size = 0;
+ for_each_set_bit(vlan, priv->vlan.active_vlans, VLAN_N_VID)
+ list_size++;
+
+ max_list_size = 1 << MLX5_CAP_GEN(priv->mdev, log_max_vlan_list);
+
+ if (list_size > max_list_size) {
+ if_printf(ifp,
+ "ifnet vlans list size (%d) > (%d) max vport list size, some vlans will be dropped\n",
+ list_size, max_list_size);
+ list_size = max_list_size;
+ }
+
+ vlans = kcalloc(list_size, sizeof(*vlans), GFP_KERNEL);
+ if (!vlans)
+ return -ENOMEM;
+
+ i = 0;
+ for_each_set_bit(vlan, priv->vlan.active_vlans, VLAN_N_VID) {
+ if (i >= list_size)
+ break;
+ vlans[i++] = vlan;
+ }
+
+ err = mlx5_modify_nic_vport_vlans(priv->mdev, vlans, list_size);
+ if (err)
+ if_printf(ifp, "Failed to modify vport vlans list err(%d)\n",
+ err);
+
+ kfree(vlans);
+ return err;
+}
+
enum mlx5e_vlan_rule_type {
MLX5E_VLAN_RULE_TYPE_UNTAGGED,
MLX5E_VLAN_RULE_TYPE_ANY_VID,
@@ -448,6 +491,7 @@ mlx5e_add_vlan_rule(struct mlx5e_priv *priv,
outer_headers.first_vid);
MLX5_SET(fte_match_param, match_value, outer_headers.first_vid,
vid);
+ mlx5e_vport_context_update_vlans(priv);
break;
}
@@ -478,6 +522,7 @@ mlx5e_del_vlan_rule(struct mlx5e_priv *priv,
case MLX5E_VLAN_RULE_TYPE_MATCH_VID:
mlx5_del_flow_table_entry(priv->ft.vlan,
priv->vlan.active_vlans_ft_ix[vid]);
+ mlx5e_vport_context_update_vlans(priv);
break;
}
}
@@ -628,6 +673,91 @@ mlx5e_sync_ifp_addr(struct mlx5e_priv *priv)
if_maddr_runlock(ifp);
}
+static void mlx5e_fill_addr_array(struct mlx5e_priv *priv, int list_type,
+ u8 addr_array[][ETH_ALEN], int size)
+{
+ bool is_uc = (list_type == MLX5_NIC_VPORT_LIST_TYPE_UC);
+ struct ifnet *ifp = priv->ifp;
+ struct mlx5e_eth_addr_hash_node *hn;
+ struct mlx5e_eth_addr_hash_head *addr_list;
+ struct mlx5e_eth_addr_hash_node *tmp;
+ int i = 0;
+ int hi;
+
+ addr_list = is_uc ? priv->eth_addr.if_uc : priv->eth_addr.if_mc;
+
+ if (is_uc) /* Make sure our own address is pushed first */
+ ether_addr_copy(addr_array[i++], IF_LLADDR(ifp));
+ else if (priv->eth_addr.broadcast_enabled)
+ ether_addr_copy(addr_array[i++], ifp->if_broadcastaddr);
+
+ mlx5e_for_each_hash_node(hn, tmp, addr_list, hi) {
+ if (ether_addr_equal(IF_LLADDR(ifp), hn->ai.addr))
+ continue;
+ if (i >= size)
+ break;
+ ether_addr_copy(addr_array[i++], hn->ai.addr);
+ }
+}
+
+static void mlx5e_vport_context_update_addr_list(struct mlx5e_priv *priv,
+ int list_type)
+{
+ bool is_uc = (list_type == MLX5_NIC_VPORT_LIST_TYPE_UC);
+ struct mlx5e_eth_addr_hash_node *hn;
+ u8 (*addr_array)[ETH_ALEN] = NULL;
+ struct mlx5e_eth_addr_hash_head *addr_list;
+ struct mlx5e_eth_addr_hash_node *tmp;
+ int max_size;
+ int size;
+ int err;
+ int hi;
+
+ size = is_uc ? 0 : (priv->eth_addr.broadcast_enabled ? 1 : 0);
+ max_size = is_uc ?
+ 1 << MLX5_CAP_GEN(priv->mdev, log_max_current_uc_list) :
+ 1 << MLX5_CAP_GEN(priv->mdev, log_max_current_mc_list);
+
+ addr_list = is_uc ? priv->eth_addr.if_uc : priv->eth_addr.if_mc;
+ mlx5e_for_each_hash_node(hn, tmp, addr_list, hi)
+ size++;
+
+ if (size > max_size) {
+ if_printf(priv->ifp,
+ "ifp %s list size (%d) > (%d) max vport list size, some addresses will be dropped\n",
+ is_uc ? "UC" : "MC", size, max_size);
+ size = max_size;
+ }
+
+ if (size) {
+ addr_array = kcalloc(size, ETH_ALEN, GFP_KERNEL);
+ if (!addr_array) {
+ err = -ENOMEM;
+ goto out;
+ }
+ mlx5e_fill_addr_array(priv, list_type, addr_array, size);
+ }
+
+ err = mlx5_modify_nic_vport_mac_list(priv->mdev, list_type, addr_array, size);
+out:
+ if (err)
+ if_printf(priv->ifp,
+ "Failed to modify vport %s list err(%d)\n",
+ is_uc ? "UC" : "MC", err);
+ kfree(addr_array);
+}
+
+static void mlx5e_vport_context_update(struct mlx5e_priv *priv)
+{
+ struct mlx5e_eth_addr_db *ea = &priv->eth_addr;
+
+ mlx5e_vport_context_update_addr_list(priv, MLX5_NIC_VPORT_LIST_TYPE_UC);
+ mlx5e_vport_context_update_addr_list(priv, MLX5_NIC_VPORT_LIST_TYPE_MC);
+ mlx5_modify_nic_vport_promisc(priv->mdev, 0,
+ ea->allmulti_enabled,
+ ea->promisc_enabled);
+}
+
static void
mlx5e_apply_ifp_addr(struct mlx5e_priv *priv)
{
@@ -701,6 +831,8 @@ mlx5e_set_rx_mode_core(struct mlx5e_priv *priv)
ea->promisc_enabled = promisc_enabled;
ea->allmulti_enabled = allmulti_enabled;
ea->broadcast_enabled = broadcast_enabled;
+
+ mlx5e_vport_context_update(priv);
}
void
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
index d71cbb3..4a8029b 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
@@ -3001,6 +3001,13 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
}
mlx5_query_nic_vport_mac_address(priv->mdev, 0, dev_addr);
+ /* check if we should generate a random MAC address */
+ if (MLX5_CAP_GEN(priv->mdev, vport_group_manager) == 0 &&
+ is_zero_ether_addr(dev_addr)) {
+ random_ether_addr(dev_addr);
+ if_printf(ifp, "Assigned random MAC address\n");
+ }
+
/* set default MTU */
mlx5e_set_dev_port_mtu(ifp, ifp->if_mtu);
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c b/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c
index 230dfcc..6bc2c17 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c
@@ -222,11 +222,11 @@ mlx5e_build_rx_mbuf(struct mlx5_cqe64 *cqe,
M_HASHTYPE_SET(mb, M_HASHTYPE_RSS_IPV6);
break;
default: /* Other */
- M_HASHTYPE_SET(mb, M_HASHTYPE_OPAQUE);
+ M_HASHTYPE_SET(mb, M_HASHTYPE_OPAQUE_HASH);
break;
}
#else
- M_HASHTYPE_SET(mb, M_HASHTYPE_OPAQUE);
+ M_HASHTYPE_SET(mb, M_HASHTYPE_OPAQUE_HASH);
#endif
} else {
mb->m_pkthdr.flowid = rq->ix;
diff --git a/sys/dev/mlx5/vport.h b/sys/dev/mlx5/vport.h
index c5948e7..cf52785 100644
--- a/sys/dev/mlx5/vport.h
+++ b/sys/dev/mlx5/vport.h
@@ -38,6 +38,18 @@ int mlx5_vport_query_out_of_rx_buffer(struct mlx5_core_dev *mdev,
u32 *out_of_rx_buffer);
u8 mlx5_query_vport_state(struct mlx5_core_dev *mdev, u8 opmod);
+int mlx5_arm_vport_context_events(struct mlx5_core_dev *mdev,
+ u8 vport,
+ u32 events_mask);
+int mlx5_query_vport_promisc(struct mlx5_core_dev *mdev,
+ u32 vport,
+ u8 *promisc_uc,
+ u8 *promisc_mc,
+ u8 *promisc_all);
+int mlx5_modify_nic_vport_promisc(struct mlx5_core_dev *mdev,
+ int promisc_uc,
+ int promisc_mc,
+ int promisc_all);
int mlx5_query_nic_vport_mac_address(struct mlx5_core_dev *mdev,
u32 vport, u8 *addr);
int mlx5_set_nic_vport_current_mac(struct mlx5_core_dev *mdev, int vport,
@@ -49,6 +61,22 @@ int mlx5_set_nic_vport_mc_list(struct mlx5_core_dev *mdev, int vport,
int mlx5_set_nic_vport_promisc(struct mlx5_core_dev *mdev, int vport,
bool promisc_mc, bool promisc_uc,
bool promisc_all);
+int mlx5_query_nic_vport_mac_list(struct mlx5_core_dev *dev,
+ u32 vport,
+ enum mlx5_list_type list_type,
+ u8 addr_list[][ETH_ALEN],
+ int *list_size);
+int mlx5_modify_nic_vport_mac_list(struct mlx5_core_dev *dev,
+ enum mlx5_list_type list_type,
+ u8 addr_list[][ETH_ALEN],
+ int list_size);
+int mlx5_query_nic_vport_vlan_list(struct mlx5_core_dev *dev,
+ u32 vport,
+ u16 *vlan_list,
+ int *list_size);
+int mlx5_modify_nic_vport_vlans(struct mlx5_core_dev *dev,
+ u16 vlans[],
+ int list_size);
int mlx5_set_nic_vport_permanent_mac(struct mlx5_core_dev *mdev, int vport,
u8 *addr);
int mlx5_nic_vport_enable_roce(struct mlx5_core_dev *mdev);
diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h
index 7c65fbb..9709022 100644
--- a/sys/dev/nvme/nvme.h
+++ b/sys/dev/nvme/nvme.h
@@ -47,7 +47,8 @@
*/
#define NVME_GLOBAL_NAMESPACE_TAG ((uint32_t)0xFFFFFFFF)
-#define NVME_MAX_XFER_SIZE MAXPHYS
+/* Cap nvme to 1MB transfers driver explodes with larger sizes */
+#define NVME_MAX_XFER_SIZE (MAXPHYS < (1<<20) ? MAXPHYS : (1<<20))
union cap_lo_register {
uint32_t raw;
@@ -903,6 +904,52 @@ uint32_t nvme_ns_get_stripesize(struct nvme_namespace *ns);
int nvme_ns_bio_process(struct nvme_namespace *ns, struct bio *bp,
nvme_cb_fn_t cb_fn);
+/* Command building helper functions -- shared with CAM */
+static inline
+void nvme_ns_flush_cmd(struct nvme_command *cmd, uint16_t nsid)
+{
+
+ cmd->opc = NVME_OPC_FLUSH;
+ cmd->nsid = nsid;
+}
+
+static inline
+void nvme_ns_rw_cmd(struct nvme_command *cmd, uint32_t rwcmd, uint16_t nsid,
+ uint64_t lba, uint32_t count)
+{
+ cmd->opc = rwcmd;
+ cmd->nsid = nsid;
+ *(uint64_t *)&cmd->cdw10 = lba;
+ cmd->cdw12 = count-1;
+ cmd->cdw13 = 0;
+ cmd->cdw14 = 0;
+ cmd->cdw15 = 0;
+}
+
+static inline
+void nvme_ns_write_cmd(struct nvme_command *cmd, uint16_t nsid,
+ uint64_t lba, uint32_t count)
+{
+ nvme_ns_rw_cmd(cmd, NVME_OPC_WRITE, nsid, lba, count);
+}
+
+static inline
+void nvme_ns_read_cmd(struct nvme_command *cmd, uint16_t nsid,
+ uint64_t lba, uint32_t count)
+{
+ nvme_ns_rw_cmd(cmd, NVME_OPC_READ, nsid, lba, count);
+}
+
+static inline
+void nvme_ns_trim_cmd(struct nvme_command *cmd, uint16_t nsid,
+ uint32_t num_ranges)
+{
+ cmd->opc = NVME_OPC_DATASET_MANAGEMENT;
+ cmd->nsid = nsid;
+ cmd->cdw10 = num_ranges - 1;
+ cmd->cdw11 = NVME_DSM_ATTR_DEALLOCATE;
+}
+
#endif /* _KERNEL */
#endif /* __NVME_H__ */
diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
index 00277f0..fa889eb 100644
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -27,6 +27,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "opt_cam.h"
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/buf.h>
@@ -801,7 +803,7 @@ nvme_ctrlr_reset_task(void *arg, int pending)
atomic_cmpset_32(&ctrlr->is_resetting, 1, 0);
}
-static void
+void
nvme_ctrlr_intx_handler(void *arg)
{
struct nvme_controller *ctrlr = arg;
diff --git a/sys/dev/nvme/nvme_ns_cmd.c b/sys/dev/nvme/nvme_ns_cmd.c
index b5c45dc..303e03c 100644
--- a/sys/dev/nvme/nvme_ns_cmd.c
+++ b/sys/dev/nvme/nvme_ns_cmd.c
@@ -34,20 +34,14 @@ nvme_ns_cmd_read(struct nvme_namespace *ns, void *payload, uint64_t lba,
uint32_t lba_count, nvme_cb_fn_t cb_fn, void *cb_arg)
{
struct nvme_request *req;
- struct nvme_command *cmd;
req = nvme_allocate_request_vaddr(payload,
lba_count*nvme_ns_get_sector_size(ns), cb_fn, cb_arg);
if (req == NULL)
return (ENOMEM);
- cmd = &req->cmd;
- cmd->opc = NVME_OPC_READ;
- cmd->nsid = ns->id;
- /* TODO: create a read command data structure */
- *(uint64_t *)&cmd->cdw10 = lba;
- cmd->cdw12 = lba_count-1;
+ nvme_ns_read_cmd(&req->cmd, ns->id, lba, lba_count);
nvme_ctrlr_submit_io_request(ns->ctrlr, req);
@@ -59,7 +53,6 @@ nvme_ns_cmd_read_bio(struct nvme_namespace *ns, struct bio *bp,
nvme_cb_fn_t cb_fn, void *cb_arg)
{
struct nvme_request *req;
- struct nvme_command *cmd;
uint64_t lba;
uint64_t lba_count;
@@ -67,16 +60,10 @@ nvme_ns_cmd_read_bio(struct nvme_namespace *ns, struct bio *bp,
if (req == NULL)
return (ENOMEM);
- cmd = &req->cmd;
- cmd->opc = NVME_OPC_READ;
- cmd->nsid = ns->id;
lba = bp->bio_offset / nvme_ns_get_sector_size(ns);
lba_count = bp->bio_bcount / nvme_ns_get_sector_size(ns);
-
- /* TODO: create a read command data structure */
- *(uint64_t *)&cmd->cdw10 = lba;
- cmd->cdw12 = lba_count-1;
+ nvme_ns_read_cmd(&req->cmd, ns->id, lba, lba_count);
nvme_ctrlr_submit_io_request(ns->ctrlr, req);
@@ -88,7 +75,6 @@ nvme_ns_cmd_write(struct nvme_namespace *ns, void *payload, uint64_t lba,
uint32_t lba_count, nvme_cb_fn_t cb_fn, void *cb_arg)
{
struct nvme_request *req;
- struct nvme_command *cmd;
req = nvme_allocate_request_vaddr(payload,
lba_count*nvme_ns_get_sector_size(ns), cb_fn, cb_arg);
@@ -96,13 +82,7 @@ nvme_ns_cmd_write(struct nvme_namespace *ns, void *payload, uint64_t lba,
if (req == NULL)
return (ENOMEM);
- cmd = &req->cmd;
- cmd->opc = NVME_OPC_WRITE;
- cmd->nsid = ns->id;
-
- /* TODO: create a write command data structure */
- *(uint64_t *)&cmd->cdw10 = lba;
- cmd->cdw12 = lba_count-1;
+ nvme_ns_write_cmd(&req->cmd, ns->id, lba, lba_count);
nvme_ctrlr_submit_io_request(ns->ctrlr, req);
@@ -114,7 +94,6 @@ nvme_ns_cmd_write_bio(struct nvme_namespace *ns, struct bio *bp,
nvme_cb_fn_t cb_fn, void *cb_arg)
{
struct nvme_request *req;
- struct nvme_command *cmd;
uint64_t lba;
uint64_t lba_count;
@@ -122,16 +101,9 @@ nvme_ns_cmd_write_bio(struct nvme_namespace *ns, struct bio *bp,
if (req == NULL)
return (ENOMEM);
- cmd = &req->cmd;
- cmd->opc = NVME_OPC_WRITE;
- cmd->nsid = ns->id;
-
lba = bp->bio_offset / nvme_ns_get_sector_size(ns);
lba_count = bp->bio_bcount / nvme_ns_get_sector_size(ns);
-
- /* TODO: create a write command data structure */
- *(uint64_t *)&cmd->cdw10 = lba;
- cmd->cdw12 = lba_count-1;
+ nvme_ns_write_cmd(&req->cmd, ns->id, lba, lba_count);
nvme_ctrlr_submit_io_request(ns->ctrlr, req);
@@ -168,17 +140,13 @@ int
nvme_ns_cmd_flush(struct nvme_namespace *ns, nvme_cb_fn_t cb_fn, void *cb_arg)
{
struct nvme_request *req;
- struct nvme_command *cmd;
req = nvme_allocate_request_null(cb_fn, cb_arg);
if (req == NULL)
return (ENOMEM);
- cmd = &req->cmd;
- cmd->opc = NVME_OPC_FLUSH;
- cmd->nsid = ns->id;
-
+ nvme_ns_flush_cmd(&req->cmd, ns->id);
nvme_ctrlr_submit_io_request(ns->ctrlr, req);
return (0);
diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h
index 3330711..aa02b45 100644
--- a/sys/dev/nvme/nvme_private.h
+++ b/sys/dev/nvme/nvme_private.h
@@ -245,6 +245,10 @@ struct nvme_controller {
struct mtx lock;
+ struct cam_sim *sim;
+ struct cam_path *path;
+ int cam_ref;
+
uint32_t ready_timeout_in_ms;
bus_space_tag_t bus_tag;
@@ -528,4 +532,6 @@ void nvme_notify_async_consumers(struct nvme_controller *ctrlr,
void nvme_notify_fail_consumers(struct nvme_controller *ctrlr);
void nvme_notify_new_controller(struct nvme_controller *ctrlr);
+void nvme_ctrlr_intx_handler(void *arg);
+
#endif /* __NVME_PRIVATE_H__ */
diff --git a/sys/dev/qlxgbe/ql_isr.c b/sys/dev/qlxgbe/ql_isr.c
index c94a068..766e3cb 100644
--- a/sys/dev/qlxgbe/ql_isr.c
+++ b/sys/dev/qlxgbe/ql_isr.c
@@ -159,7 +159,7 @@ qla_rx_intr(qla_host_t *ha, qla_sgl_rcv_t *sgc, uint32_t sds_idx)
if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
mpf->m_pkthdr.flowid = sgc->rss_hash;
- M_HASHTYPE_SET(mpf, M_HASHTYPE_OPAQUE);
+ M_HASHTYPE_SET(mpf, M_HASHTYPE_OPAQUE_HASH);
(*ifp->if_input)(ifp, mpf);
@@ -324,7 +324,7 @@ qla_lro_intr(qla_host_t *ha, qla_sgl_lro_t *sgc, uint32_t sds_idx)
mpf->m_pkthdr.csum_data = 0xFFFF;
mpf->m_pkthdr.flowid = sgc->rss_hash;
- M_HASHTYPE_SET(mpf, M_HASHTYPE_OPAQUE);
+ M_HASHTYPE_SET(mpf, M_HASHTYPE_OPAQUE_HASH);
if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
diff --git a/sys/dev/qlxge/qls_isr.c b/sys/dev/qlxge/qls_isr.c
index 1eb833e..9b571f5 100644
--- a/sys/dev/qlxge/qls_isr.c
+++ b/sys/dev/qlxge/qls_isr.c
@@ -190,7 +190,7 @@ qls_rx_comp(qla_host_t *ha, uint32_t rxr_idx, uint32_t cq_idx, q81_rx_t *cq_e)
if ((cq_e->flags1 & Q81_RX_FLAGS1_RSS_MATCH_MASK)) {
rxr->rss_int++;
mp->m_pkthdr.flowid = cq_e->rss;
- M_HASHTYPE_SET(mp, M_HASHTYPE_OPAQUE);
+ M_HASHTYPE_SET(mp, M_HASHTYPE_OPAQUE_HASH);
}
if (cq_e->flags0 & (Q81_RX_FLAGS0_TE |
Q81_RX_FLAGS0_NU | Q81_RX_FLAGS0_IE)) {
diff --git a/sys/dev/ral/rt2860.c b/sys/dev/ral/rt2860.c
index 79989fc..1b15a0f 100644
--- a/sys/dev/ral/rt2860.c
+++ b/sys/dev/ral/rt2860.c
@@ -900,7 +900,7 @@ rt2860_ampdu_rx_stop(struct ieee80211com *ic, struct ieee80211_node *ni,
}
#endif
-int
+static int
rt2860_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
{
struct rt2860_vap *rvp = RT2860_VAP(vap);
@@ -3824,9 +3824,16 @@ rt2860_init_locked(struct rt2860_softc *sc)
/* disable DMA */
tmp = RAL_READ(sc, RT2860_WPDMA_GLO_CFG);
- tmp &= 0xff0;
+ tmp &= ~(RT2860_RX_DMA_BUSY | RT2860_RX_DMA_EN | RT2860_TX_DMA_BUSY |
+ RT2860_TX_DMA_EN);
+ tmp |= RT2860_TX_WB_DDONE;
RAL_WRITE(sc, RT2860_WPDMA_GLO_CFG, tmp);
+ /* reset DMA indexes */
+ RAL_WRITE(sc, RT2860_WPDMA_RST_IDX, RT2860_RST_DRX_IDX0 |
+ RT2860_RST_DTX_IDX5 | RT2860_RST_DTX_IDX4 | RT2860_RST_DTX_IDX3 |
+ RT2860_RST_DTX_IDX2 | RT2860_RST_DTX_IDX1 | RT2860_RST_DTX_IDX0);
+
/* PBF hardware reset */
RAL_WRITE(sc, RT2860_SYS_CTRL, 0xe1f);
RAL_BARRIER_WRITE(sc);
@@ -3858,7 +3865,9 @@ rt2860_init_locked(struct rt2860_softc *sc)
rt2860_stop_locked(sc);
return;
}
- tmp &= 0xff0;
+ tmp &= ~(RT2860_RX_DMA_BUSY | RT2860_RX_DMA_EN | RT2860_TX_DMA_BUSY |
+ RT2860_TX_DMA_EN);
+ tmp |= RT2860_TX_WB_DDONE;
RAL_WRITE(sc, RT2860_WPDMA_GLO_CFG, tmp);
/* reset Rx ring and all 6 Tx rings */
@@ -3958,7 +3967,9 @@ rt2860_init_locked(struct rt2860_softc *sc)
rt2860_stop_locked(sc);
return;
}
- tmp &= 0xff0;
+ tmp &= ~(RT2860_RX_DMA_BUSY | RT2860_RX_DMA_EN | RT2860_TX_DMA_BUSY |
+ RT2860_TX_DMA_EN);
+ tmp |= RT2860_TX_WB_DDONE;
RAL_WRITE(sc, RT2860_WPDMA_GLO_CFG, tmp);
/* disable interrupts mitigation */
diff --git a/sys/dev/ral/rt2860reg.h b/sys/dev/ral/rt2860reg.h
index 5bd7dbb..f79874e 100644
--- a/sys/dev/ral/rt2860reg.h
+++ b/sys/dev/ral/rt2860reg.h
@@ -257,6 +257,15 @@
#define RT2860_TX_DMA_BUSY (1 << 1)
#define RT2860_TX_DMA_EN (1 << 0)
+/* flags for register WPDMA_RST_IDX */
+#define RT2860_RST_DRX_IDX0 (1 << 16)
+#define RT2860_RST_DTX_IDX5 (1 << 5)
+#define RT2860_RST_DTX_IDX4 (1 << 4)
+#define RT2860_RST_DTX_IDX3 (1 << 3)
+#define RT2860_RST_DTX_IDX2 (1 << 2)
+#define RT2860_RST_DTX_IDX1 (1 << 1)
+#define RT2860_RST_DTX_IDX0 (1 << 0)
+
/* possible flags for register DELAY_INT_CFG */
#define RT2860_TXDLY_INT_EN (1U << 31)
#define RT2860_TXMAX_PINT_SHIFT 24
@@ -1233,7 +1242,7 @@ static const struct rt2860_rate {
{ 20, 0xba }, \
{ 21, 0xdb }, \
{ 24, 0x16 }, \
- { 25, 0x01 }, \
+ { 25, 0x03 }, \
{ 29, 0x1f }
#define RT5390_DEF_RF \
diff --git a/sys/dev/sfxge/common/ef10_nvram.c b/sys/dev/sfxge/common/ef10_nvram.c
index 7f93df3..73459d6 100644
--- a/sys/dev/sfxge/common/ef10_nvram.c
+++ b/sys/dev/sfxge/common/ef10_nvram.c
@@ -1658,7 +1658,7 @@ ef10_nvram_partn_write_tlv(
* Read a segment from nvram at the given offset into a buffer (segment_data)
* and optionally write a new tag to it.
*/
- static __checkReturn efx_rc_t
+static __checkReturn efx_rc_t
ef10_nvram_segment_write_tlv(
__in efx_nic_t *enp,
__in uint32_t partn,
@@ -1684,20 +1684,25 @@ ef10_nvram_segment_write_tlv(
*/
status = ef10_nvram_read_tlv_segment(enp, partn, *partn_offsetp,
*seg_datap, *src_remain_lenp);
- if (status != 0)
- return (EINVAL);
+ if (status != 0) {
+ rc = EINVAL;
+ goto fail1;
+ }
status = ef10_nvram_buf_segment_size(*seg_datap,
*src_remain_lenp, &original_segment_size);
- if (status != 0)
- return (EINVAL);
+ if (status != 0) {
+ rc = EINVAL;
+ goto fail2;
+ }
if (write) {
/* Update the contents of the segment in the buffer */
if ((rc = ef10_nvram_buf_write_tlv(*seg_datap,
*dest_remain_lenp, tag, data, size,
- &modified_segment_size)) != 0)
- goto fail1;
+ &modified_segment_size)) != 0) {
+ goto fail3;
+ }
*dest_remain_lenp -= modified_segment_size;
*seg_datap += modified_segment_size;
} else {
@@ -1714,6 +1719,10 @@ ef10_nvram_segment_write_tlv(
return (0);
+fail3:
+ EFSYS_PROBE(fail3);
+fail2:
+ EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
diff --git a/sys/dev/sfxge/sfxge_ev.c b/sys/dev/sfxge/sfxge_ev.c
index 4fb8e0e..7bdcf22 100644
--- a/sys/dev/sfxge/sfxge_ev.c
+++ b/sys/dev/sfxge/sfxge_ev.c
@@ -453,7 +453,7 @@ sfxge_ev_stat_update(struct sfxge_softc *sc)
goto out;
now = ticks;
- if (now - sc->ev_stats_update_time < hz)
+ if ((unsigned int)(now - sc->ev_stats_update_time) < (unsigned int)hz)
goto out;
sc->ev_stats_update_time = now;
diff --git a/sys/dev/sfxge/sfxge_port.c b/sys/dev/sfxge/sfxge_port.c
index c8b0334..2ebc521 100644
--- a/sys/dev/sfxge/sfxge_port.c
+++ b/sys/dev/sfxge/sfxge_port.c
@@ -62,7 +62,7 @@ sfxge_mac_stat_update(struct sfxge_softc *sc)
}
now = ticks;
- if (now - port->mac_stats.update_time < hz) {
+ if ((unsigned int)(now - port->mac_stats.update_time) < (unsigned int)hz) {
rc = 0;
goto out;
}
@@ -570,7 +570,7 @@ sfxge_phy_stat_update(struct sfxge_softc *sc)
}
now = ticks;
- if (now - port->phy_stats.update_time < hz) {
+ if ((unsigned int)(now - port->phy_stats.update_time) < (unsigned int)hz) {
rc = 0;
goto out;
}
diff --git a/sys/dev/sfxge/sfxge_tx.c b/sys/dev/sfxge/sfxge_tx.c
index 08fc885..198b1e5 100644
--- a/sys/dev/sfxge/sfxge_tx.c
+++ b/sys/dev/sfxge/sfxge_tx.c
@@ -992,7 +992,7 @@ static void tso_start(struct sfxge_txq *txq, struct sfxge_tso_state *tso,
tso->protocol = TSO_MBUF_PROTO(mbuf);
tso->nh_off = mbuf->m_pkthdr.l2hlen;
tso->tcph_off = mbuf->m_pkthdr.l3hlen;
- tso->packet_id = TSO_MBUF_PACKETID(mbuf);
+ tso->packet_id = ntohs(TSO_MBUF_PACKETID(mbuf));
#endif
#if !SFXGE_TX_PARSE_EARLY
@@ -1001,7 +1001,7 @@ static void tso_start(struct sfxge_txq *txq, struct sfxge_tso_state *tso,
KASSERT(tso_iph(tso)->ip_p == IPPROTO_TCP,
("TSO required on non-TCP packet"));
tso->tcph_off = tso->nh_off + 4 * tso_iph(tso)->ip_hl;
- tso->packet_id = tso_iph(tso)->ip_id;
+ tso->packet_id = ntohs(tso_iph(tso)->ip_id);
} else {
KASSERT(tso->protocol == htons(ETHERTYPE_IPV6),
("TSO required on non-IP packet"));
diff --git a/sys/dev/sfxge/sfxge_version.h b/sys/dev/sfxge/sfxge_version.h
index ab0ad54..af639ee 100644
--- a/sys/dev/sfxge/sfxge_version.h
+++ b/sys/dev/sfxge/sfxge_version.h
@@ -36,6 +36,6 @@
#ifndef _SFXGE_VERSION_H
#define _SFXGE_VERSION_H
-#define SFXGE_VERSION_STRING "v4.8.0.1071"
+#define SFXGE_VERSION_STRING "v4.8.0.1081"
#endif /* _SFXGE_DRIVER_VERSION_H */
diff --git a/sys/dev/urtwn/if_urtwn.c b/sys/dev/urtwn/if_urtwn.c
index 2107fe1..999bb6e 100644
--- a/sys/dev/urtwn/if_urtwn.c
+++ b/sys/dev/urtwn/if_urtwn.c
@@ -373,6 +373,8 @@ static void urtwn_set_chan(struct urtwn_softc *,
static void urtwn_iq_calib(struct urtwn_softc *);
static void urtwn_lc_calib(struct urtwn_softc *);
static void urtwn_temp_calib(struct urtwn_softc *);
+static void urtwn_setup_static_keys(struct urtwn_softc *,
+ struct urtwn_vap *);
static int urtwn_init(struct urtwn_softc *);
static void urtwn_stop(struct urtwn_softc *);
static void urtwn_abort_xfers(struct urtwn_softc *);
@@ -2340,12 +2342,28 @@ static int
urtwn_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k)
{
struct urtwn_softc *sc = vap->iv_ic->ic_softc;
+ struct urtwn_vap *uvp = URTWN_VAP(vap);
if (k->wk_flags & IEEE80211_KEY_SWCRYPT) {
/* Not for us. */
return (1);
}
+ if (&vap->iv_nw_keys[0] <= k &&
+ k < &vap->iv_nw_keys[IEEE80211_WEP_NKID]) {
+ URTWN_LOCK(sc);
+ uvp->keys[k->wk_keyix] = k;
+ if ((sc->sc_flags & URTWN_RUNNING) == 0) {
+ /*
+ * The device was not started;
+ * the key will be installed later.
+ */
+ URTWN_UNLOCK(sc);
+ return (1);
+ }
+ URTWN_UNLOCK(sc);
+ }
+
return (!urtwn_cmd_sleepable(sc, k, sizeof(*k), urtwn_key_set_cb));
}
@@ -2353,12 +2371,25 @@ static int
urtwn_key_delete(struct ieee80211vap *vap, const struct ieee80211_key *k)
{
struct urtwn_softc *sc = vap->iv_ic->ic_softc;
+ struct urtwn_vap *uvp = URTWN_VAP(vap);
if (k->wk_flags & IEEE80211_KEY_SWCRYPT) {
/* Not for us. */
return (1);
}
+ if (&vap->iv_nw_keys[0] <= k &&
+ k < &vap->iv_nw_keys[IEEE80211_WEP_NKID]) {
+ URTWN_LOCK(sc);
+ uvp->keys[k->wk_keyix] = NULL;
+ if ((sc->sc_flags & URTWN_RUNNING) == 0) {
+ /* All keys are removed on device reset. */
+ URTWN_UNLOCK(sc);
+ return (1);
+ }
+ URTWN_UNLOCK(sc);
+ }
+
return (!urtwn_cmd_sleepable(sc, k, sizeof(*k), urtwn_key_del_cb));
}
@@ -5230,6 +5261,20 @@ urtwn_temp_calib(struct urtwn_softc *sc)
}
}
+static void
+urtwn_setup_static_keys(struct urtwn_softc *sc, struct urtwn_vap *uvp)
+{
+ int i;
+
+ for (i = 0; i < IEEE80211_WEP_NKID; i++) {
+ const struct ieee80211_key *k = uvp->keys[i];
+ if (k != NULL) {
+ urtwn_cmd_sleepable(sc, k, sizeof(*k),
+ urtwn_key_set_cb);
+ }
+ }
+}
+
static int
urtwn_init(struct urtwn_softc *sc)
{
@@ -5418,12 +5463,6 @@ urtwn_init(struct urtwn_softc *sc)
R92C_SECCFG_TXENC_ENA | R92C_SECCFG_RXDEC_ENA |
R92C_SECCFG_TXBCKEY_DEF | R92C_SECCFG_RXBCKEY_DEF);
- /*
- * Install static keys (if any).
- * Must be called after urtwn_cam_init().
- */
- ieee80211_runtask(ic, &sc->cmdq_task);
-
/* Enable hardware sequence numbering. */
urtwn_write_1(sc, R92C_HWSEQ_CTRL, R92C_TX_QUEUE_ALL);
@@ -5459,6 +5498,13 @@ urtwn_init(struct urtwn_softc *sc)
sc->sc_flags |= URTWN_RUNNING;
+ /*
+ * Install static keys (if any).
+ * Must be called after urtwn_cam_init().
+ */
+ if (vap != NULL)
+ urtwn_setup_static_keys(sc, URTWN_VAP(vap));
+
callout_reset(&sc->sc_watchdog_ch, hz, urtwn_watchdog, sc);
fail:
if (usb_err != USB_ERR_NORMAL_COMPLETION)
diff --git a/sys/dev/urtwn/if_urtwnvar.h b/sys/dev/urtwn/if_urtwnvar.h
index 7313f07..ada6439 100644
--- a/sys/dev/urtwn/if_urtwnvar.h
+++ b/sys/dev/urtwn/if_urtwnvar.h
@@ -107,6 +107,8 @@ struct urtwn_vap {
struct mbuf *bcn_mbuf;
struct task tsf_task_adhoc;
+ const struct ieee80211_key *keys[IEEE80211_WEP_NKID];
+
int (*newstate)(struct ieee80211vap *,
enum ieee80211_state, int);
void (*recv_mgmt)(struct ieee80211_node *,
diff --git a/sys/dev/xen/netfront/netfront.c b/sys/dev/xen/netfront/netfront.c
index d28f656..3d02a52 100644
--- a/sys/dev/xen/netfront/netfront.c
+++ b/sys/dev/xen/netfront/netfront.c
@@ -146,7 +146,8 @@ static int setup_device(device_t dev, struct netfront_info *info,
static int xn_ifmedia_upd(struct ifnet *ifp);
static void xn_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr);
-int xn_connect(struct netfront_info *);
+static int xn_connect(struct netfront_info *);
+static void xn_kick_rings(struct netfront_info *);
static int xn_get_responses(struct netfront_rxq *,
struct netfront_rx_info *, RING_IDX, RING_IDX *,
@@ -976,7 +977,9 @@ netfront_backend_changed(device_t dev, XenbusState newstate)
break;
if (xn_connect(sc) != 0)
break;
- xenbus_set_state(dev, XenbusStateConnected);
+ /* Switch to connected state before kicking the rings. */
+ xenbus_set_state(sc->xbdev, XenbusStateConnected);
+ xn_kick_rings(sc);
break;
case XenbusStateClosing:
xenbus_set_state(dev, XenbusStateClosed);
@@ -1924,7 +1927,7 @@ xn_rebuild_rx_bufs(struct netfront_rxq *rxq)
}
/* START of Xenolinux helper functions adapted to FreeBSD */
-int
+static int
xn_connect(struct netfront_info *np)
{
int i, error;
@@ -1968,8 +1971,20 @@ xn_connect(struct netfront_info *np)
* packets.
*/
netfront_carrier_on(np);
+
+ return (0);
+}
+
+static void
+xn_kick_rings(struct netfront_info *np)
+{
+ struct netfront_rxq *rxq;
+ struct netfront_txq *txq;
+ int i;
+
for (i = 0; i < np->num_queues; i++) {
txq = &np->txq[i];
+ rxq = &np->rxq[i];
xen_intr_signal(txq->xen_intr_handle);
XN_TX_LOCK(txq);
xn_txeof(txq);
@@ -1978,8 +1993,6 @@ xn_connect(struct netfront_info *np)
xn_alloc_rx_buffers(rxq);
XN_RX_UNLOCK(rxq);
}
-
- return (0);
}
static void
diff --git a/sys/dev/xen/timer/timer.c b/sys/dev/xen/timer/timer.c
index 996399b..0b26847 100644
--- a/sys/dev/xen/timer/timer.c
+++ b/sys/dev/xen/timer/timer.c
@@ -477,6 +477,9 @@ xentimer_resume(device_t dev)
/* Reset the last uptime value */
pvclock_resume();
+ /* Reset the RTC clock */
+ inittodr(time_second);
+
/* Kick the timers on all CPUs */
smp_rendezvous(NULL, xentimer_percpu_resume, NULL, dev);
diff --git a/sys/fs/ext2fs/ext2_alloc.c b/sys/fs/ext2fs/ext2_alloc.c
index 35e24c3..e0201cc 100644
--- a/sys/fs/ext2fs/ext2_alloc.c
+++ b/sys/fs/ext2fs/ext2_alloc.c
@@ -407,9 +407,11 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred *cred, struct vnode **vpp)
/*
* Set up a new generation number for this inode.
+ * Avoid zero values.
*/
- while (ip->i_gen == 0 || ++ip->i_gen == 0)
+ do {
ip->i_gen = arc4random();
+ } while ( ip->i_gen == 0);
vfs_timestamp(&ts);
ip->i_birthtime = ts.tv_sec;
diff --git a/sys/fs/ext2fs/ext2_bmap.c b/sys/fs/ext2fs/ext2_bmap.c
index 7966b9b..6f4ec34 100644
--- a/sys/fs/ext2fs/ext2_bmap.c
+++ b/sys/fs/ext2fs/ext2_bmap.c
@@ -86,8 +86,8 @@ ext2_bmap(struct vop_bmap_args *ap)
}
/*
- * This function converts the logical block number of a file to
- * its physical block number on the disk within ext4 extents.
+ * Convert the logical block number of a file to its physical block number
+ * on the disk within ext4 extents.
*/
static int
ext4_bmapext(struct vnode *vp, int32_t bn, int64_t *bnp, int *runp, int *runb)
@@ -97,7 +97,7 @@ ext4_bmapext(struct vnode *vp, int32_t bn, int64_t *bnp, int *runp, int *runb)
struct ext4_extent *ep;
struct ext4_extent_path path = { .ep_bp = NULL };
daddr_t lbn;
- int ret = 0;
+ int error;
ip = VTOI(vp);
fs = ip->i_e2fs;
@@ -105,9 +105,9 @@ ext4_bmapext(struct vnode *vp, int32_t bn, int64_t *bnp, int *runp, int *runb)
if (runp != NULL)
*runp = 0;
-
if (runb != NULL)
*runb = 0;
+ error = 0;
ext4_ext_find_extent(fs, ip, lbn, &path);
if (path.ep_is_sparse) {
@@ -118,29 +118,28 @@ ext4_bmapext(struct vnode *vp, int32_t bn, int64_t *bnp, int *runp, int *runb)
if (runb != NULL)
*runb = lbn - path.ep_sparse_ext.e_blk;
} else {
- ep = path.ep_ext;
- if (ep == NULL)
- ret = EIO;
- else {
- *bnp = fsbtodb(fs, lbn - ep->e_blk +
- (ep->e_start_lo | (daddr_t)ep->e_start_hi << 32));
-
- if (*bnp == 0)
- *bnp = -1;
-
- if (runp != NULL)
- *runp = ep->e_len - (lbn - ep->e_blk) - 1;
- if (runb != NULL)
- *runb = lbn - ep->e_blk;
+ if (path.ep_ext == NULL) {
+ error = EIO;
+ goto out;
}
+ ep = path.ep_ext;
+ *bnp = fsbtodb(fs, lbn - ep->e_blk +
+ (ep->e_start_lo | (daddr_t)ep->e_start_hi << 32));
+
+ if (*bnp == 0)
+ *bnp = -1;
+
+ if (runp != NULL)
+ *runp = ep->e_len - (lbn - ep->e_blk) - 1;
+ if (runb != NULL)
+ *runb = lbn - ep->e_blk;
}
- if (path.ep_bp != NULL) {
+out:
+ if (path.ep_bp != NULL)
brelse(path.ep_bp);
- path.ep_bp = NULL;
- }
- return (ret);
+ return (error);
}
/*
diff --git a/sys/fs/ext2fs/ext2_extents.h b/sys/fs/ext2fs/ext2_extents.h
index 70eb685..b6a7fc2 100644
--- a/sys/fs/ext2fs/ext2_extents.h
+++ b/sys/fs/ext2fs/ext2_extents.h
@@ -40,8 +40,8 @@
* Ext4 file system extent on disk.
*/
struct ext4_extent {
- uint32_t e_blk; /* first logical block */
- uint16_t e_len; /* number of blocks */
+ uint32_t e_blk; /* first logical block */
+ uint16_t e_len; /* number of blocks */
uint16_t e_start_hi; /* high 16 bits of physical block */
uint32_t e_start_lo; /* low 32 bits of physical block */
};
diff --git a/sys/fs/ext2fs/ext2_vfsops.c b/sys/fs/ext2fs/ext2_vfsops.c
index 9f73357..2083fb6 100644
--- a/sys/fs/ext2fs/ext2_vfsops.c
+++ b/sys/fs/ext2fs/ext2_vfsops.c
@@ -158,11 +158,9 @@ ext2_mount(struct mount *mp)
}
fs->e2fs_ronly = 1;
vfs_flagopt(opts, "ro", &mp->mnt_flag, MNT_RDONLY);
- DROP_GIANT();
g_topology_lock();
g_access(ump->um_cp, 0, -1, 0);
g_topology_unlock();
- PICKUP_GIANT();
}
if (!error && (mp->mnt_flag & MNT_RELOAD))
error = ext2_reload(mp, td);
@@ -187,11 +185,9 @@ ext2_mount(struct mount *mp)
return (error);
}
VOP_UNLOCK(devvp, 0);
- DROP_GIANT();
g_topology_lock();
error = g_access(ump->um_cp, 0, 1, 0);
g_topology_unlock();
- PICKUP_GIANT();
if (error)
return (error);
@@ -547,11 +543,9 @@ ext2_mountfs(struct vnode *devvp, struct mount *mp)
ronly = vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0);
/* XXX: use VOP_ACESS to check FS perms */
- DROP_GIANT();
g_topology_lock();
error = g_vfs_open(devvp, &cp, "ext2fs", ronly ? 0 : 1);
g_topology_unlock();
- PICKUP_GIANT();
VOP_UNLOCK(devvp, 0);
if (error)
return (error);
@@ -559,11 +553,9 @@ ext2_mountfs(struct vnode *devvp, struct mount *mp)
/* XXX: should we check for some sectorsize or 512 instead? */
if (((SBSIZE % cp->provider->sectorsize) != 0) ||
(SBSIZE < cp->provider->sectorsize)) {
- DROP_GIANT();
g_topology_lock();
g_vfs_close(cp);
g_topology_unlock();
- PICKUP_GIANT();
return (EINVAL);
}
@@ -683,11 +675,9 @@ out:
if (bp)
brelse(bp);
if (cp != NULL) {
- DROP_GIANT();
g_topology_lock();
g_vfs_close(cp);
g_topology_unlock();
- PICKUP_GIANT();
}
if (ump) {
mtx_destroy(EXT2_MTX(ump));
@@ -729,11 +719,9 @@ ext2_unmount(struct mount *mp, int mntflags)
ext2_sbupdate(ump, MNT_WAIT);
}
- DROP_GIANT();
g_topology_lock();
g_vfs_close(ump->um_cp);
g_topology_unlock();
- PICKUP_GIANT();
vrele(ump->um_devvp);
sump = fs->e2fs_clustersum;
for (i = 0; i < fs->e2fs_gcount; i++, sump++)
@@ -993,16 +981,6 @@ ext2_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp)
* Finish inode initialization.
*/
- /*
- * Set up a generation number for this inode if it does not
- * already have one. This should only happen on old filesystems.
- */
- if (ip->i_gen == 0) {
- while (ip->i_gen == 0)
- ip->i_gen = arc4random();
- if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0)
- ip->i_flag |= IN_MODIFIED;
- }
*vpp = vp;
return (0);
}
diff --git a/sys/fs/ext2fs/ext2fs.h b/sys/fs/ext2fs/ext2fs.h
index c23f2a2..b005ddd 100644
--- a/sys/fs/ext2fs/ext2fs.h
+++ b/sys/fs/ext2fs/ext2fs.h
@@ -87,7 +87,7 @@ struct ext2fs {
uint32_t e3fs_journal_dev; /* device number of journal file */
uint32_t e3fs_last_orphan; /* start of list of inodes to delete */
uint32_t e3fs_hash_seed[4]; /* HTREE hash seed */
- char e3fs_def_hash_version; /* Default hash version to use */
+ char e3fs_def_hash_version;/* Default hash version to use */
char e3fs_jnl_backup_type;
uint16_t e3fs_desc_size; /* size of group descriptor */
uint32_t e3fs_default_mount_opts;
@@ -97,13 +97,13 @@ struct ext2fs {
uint32_t e4fs_bcount_hi; /* high bits of blocks count */
uint32_t e4fs_rbcount_hi; /* high bits of reserved blocks count */
uint32_t e4fs_fbcount_hi; /* high bits of free blocks count */
- uint16_t e4fs_min_extra_isize; /* all inodes have at least some bytes */
- uint16_t e4fs_want_extra_isize; /* inodes must reserve some bytes */
+ uint16_t e4fs_min_extra_isize; /* all inodes have some bytes */
+ uint16_t e4fs_want_extra_isize;/* inodes must reserve some bytes */
uint32_t e4fs_flags; /* miscellaneous flags */
uint16_t e4fs_raid_stride; /* RAID stride */
- uint16_t e4fs_mmpintv; /* number of seconds to wait in MMP checking */
+ uint16_t e4fs_mmpintv; /* seconds to wait in MMP checking */
uint64_t e4fs_mmpblk; /* block for multi-mount protection */
- uint32_t e4fs_raid_stripe_wid; /* blocks on all data disks (N * stride) */
+ uint32_t e4fs_raid_stripe_wid; /* blocks on data disks (N * stride) */
uint8_t e4fs_log_gpf; /* FLEX_BG group size */
uint8_t e4fs_chksum_type; /* metadata checksum algorithm used */
uint8_t e4fs_encrypt; /* versioning level for encryption */
@@ -117,7 +117,7 @@ struct ext2fs {
uint32_t e4fs_first_errtime; /* first time an error happened */
uint32_t e4fs_first_errino; /* inode involved in first error */
uint64_t e4fs_first_errblk; /* block involved of first error */
- uint8_t e4fs_first_errfunc[32]; /* function where error happened */
+ uint8_t e4fs_first_errfunc[32];/* function where error happened */
uint32_t e4fs_first_errline; /* line number where error happened */
uint32_t e4fs_last_errtime; /* most recent time of an error */
uint32_t e4fs_last_errino; /* inode involved in last error */
@@ -127,10 +127,10 @@ struct ext2fs {
uint8_t e4fs_mount_opts[64];
uint32_t e4fs_usrquota_inum; /* inode for tracking user quota */
uint32_t e4fs_grpquota_inum; /* inode for tracking group quota */
- uint32_t e4fs_overhead_clusters; /* overhead blocks/clusters */
+ uint32_t e4fs_overhead_clusters;/* overhead blocks/clusters */
uint32_t e4fs_backup_bgs[2]; /* groups with sparse_super2 SBs */
- uint8_t e4fs_encrypt_algos[4]; /* encryption algorithms in use */
- uint8_t e4fs_encrypt_pw_salt[16]; /* salt used for string2key */
+ uint8_t e4fs_encrypt_algos[4];/* encryption algorithms in use */
+ uint8_t e4fs_encrypt_pw_salt[16];/* salt used for string2key */
uint32_t e4fs_lpf_ino; /* location of the lost+found inode */
uint32_t e4fs_proj_quota_inum; /* inode for tracking project quota */
uint32_t e4fs_chksum_seed; /* checksum seed */
diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c
index db1ee9d..a3e2c70 100644
--- a/sys/fs/nfsclient/nfs_clvfsops.c
+++ b/sys/fs/nfsclient/nfs_clvfsops.c
@@ -763,37 +763,37 @@ nfs_mount_parse_from(struct vfsoptlist *opts, char **hostnamep,
/*
* This part comes from sbin/mount_nfs/mount_nfs.c:getnfsargs().
*/
- if (*spec == '[' && (delimp = strchr(spec + 1, ']')) != NULL &&
- *(delimp + 1) == ':') {
- hostp = spec + 1;
- spec = delimp + 2;
- have_bracket = 1;
- } else if ((delimp = strrchr(spec, ':')) != NULL) {
- hostp = spec;
- spec = delimp + 1;
- } else if ((delimp = strrchr(spec, '@')) != NULL) {
- printf("%s: path@server syntax is deprecated, "
+ if (*spec == '[' && (delimp = strchr(spec + 1, ']')) != NULL &&
+ *(delimp + 1) == ':') {
+ hostp = spec + 1;
+ spec = delimp + 2;
+ have_bracket = 1;
+ } else if ((delimp = strrchr(spec, ':')) != NULL) {
+ hostp = spec;
+ spec = delimp + 1;
+ } else if ((delimp = strrchr(spec, '@')) != NULL) {
+ printf("%s: path@server syntax is deprecated, "
"use server:path\n", __func__);
- hostp = delimp + 1;
- } else {
- printf("%s: no <host>:<dirpath> nfs-name\n", __func__);
- return (EINVAL);
- }
- *delimp = '\0';
-
- /*
- * If there has been a trailing slash at mounttime it seems
- * that some mountd implementations fail to remove the mount
- * entries from their mountlist while unmounting.
- */
- for (speclen = strlen(spec);
- speclen > 1 && spec[speclen - 1] == '/';
- speclen--)
- spec[speclen - 1] = '\0';
- if (strlen(hostp) + strlen(spec) + 1 > MNAMELEN) {
- printf("%s: %s:%s: name too long", __func__, hostp, spec);
- return (EINVAL);
- }
+ hostp = delimp + 1;
+ } else {
+ printf("%s: no <host>:<dirpath> nfs-name\n", __func__);
+ return (EINVAL);
+ }
+ *delimp = '\0';
+
+ /*
+ * If there has been a trailing slash at mounttime it seems
+ * that some mountd implementations fail to remove the mount
+ * entries from their mountlist while unmounting.
+ */
+ for (speclen = strlen(spec);
+ speclen > 1 && spec[speclen - 1] == '/';
+ speclen--)
+ spec[speclen - 1] = '\0';
+ if (strlen(hostp) + strlen(spec) + 1 > MNAMELEN) {
+ printf("%s: %s:%s: name too long", __func__, hostp, spec);
+ return (EINVAL);
+ }
/* Make both '@' and ':' notations equal */
if (*hostp != '\0') {
len = strlen(hostp);
@@ -806,7 +806,8 @@ nfs_mount_parse_from(struct vfsoptlist *opts, char **hostnamep,
nam[len + offset++] = ':';
memmove(nam + len + offset, spec, speclen);
nam[len + speclen + offset] = '\0';
- }
+ } else
+ nam[0] = '\0';
/*
* XXX: IPv6
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index d2de3c8..63d855d 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -806,8 +806,11 @@ interpret:
/*
* Set the new credentials.
*/
- if (imgp->newcred != NULL)
+ if (imgp->newcred != NULL) {
proc_set_cred(p, imgp->newcred);
+ crfree(oldcred);
+ oldcred = NULL;
+ }
/*
* Store the vp for use in procfs. This vnode was referenced by namei
@@ -918,8 +921,9 @@ exec_fail:
SDT_PROBE1(proc, , , exec__failure, error);
}
- if (imgp->newcred != NULL)
- crfree(oldcred);
+ if (imgp->newcred != NULL && oldcred != NULL)
+ crfree(imgp->newcred);
+
#ifdef MAC
mac_execve_exit(imgp);
mac_execve_interpreter_exit(interpvplabel);
diff --git a/sys/kern/kern_fail.c b/sys/kern/kern_fail.c
index ec466dd..b5bf066 100644
--- a/sys/kern/kern_fail.c
+++ b/sys/kern/kern_fail.c
@@ -82,13 +82,13 @@ static MALLOC_DEFINE(M_FAIL_POINT, "Fail Points", "fail points system");
#define fp_malloc(size, flags) malloc((size), M_FAIL_POINT, (flags))
#define fs_free(ptr) fp_free(ptr)
#define fs_malloc() fp_malloc(sizeof(struct fail_point_setting), \
- M_WAITOK | M_ZERO)
+ M_WAITOK | M_ZERO)
- /**
- * These define the wchans that are used for sleeping, pausing respectively.
- * They are chosen arbitrarily but need to be distinct to the failpoint and
- * the sleep/pause distinction.
- */
+/**
+ * These define the wchans that are used for sleeping, pausing respectively.
+ * They are chosen arbitrarily but need to be distinct to the failpoint and
+ * the sleep/pause distinction.
+ */
#define FP_SLEEP_CHANNEL(fp) (void*)(fp)
#define FP_PAUSE_CHANNEL(fp) __DEVOLATILE(void*, &fp->fp_setting)
@@ -166,7 +166,7 @@ struct fail_point_entry {
enum fail_point_t fe_type; /**< type of entry */
int fe_arg; /**< argument to type (e.g. return value) */
int fe_prob; /**< likelihood of firing in millionths */
- int fe_count; /**< number of times to fire, -1 means infinite */
+ int32_t fe_count; /**< number of times to fire, -1 means infinite */
pid_t fe_pid; /**< only fail for this process */
struct fail_point *fe_parent; /**< backpointer to fp */
TAILQ_ENTRY(fail_point_entry) fe_entries; /**< next entry ptr */
@@ -354,7 +354,7 @@ fail_point_eval_swap_out(struct fail_point *fp,
/* Free up any zero-ref entries in the garbage queue */
static void
-fail_point_garbage_collect()
+fail_point_garbage_collect(void)
{
struct fail_point_setting *fs_current, *fs_next;
struct fail_point_setting_garbage fp_ents_free_list;
@@ -441,7 +441,7 @@ fail_point_sleep(struct fail_point *fp, int msecs,
fp->fp_pre_sleep_fn(fp->fp_pre_sleep_arg);
timeout(fp->fp_post_sleep_fn, fp->fp_post_sleep_arg,
- timo);
+ timo);
*pret = FAIL_POINT_RC_QUEUED;
}
}
@@ -635,7 +635,6 @@ abort:
fail_point_setting_release_ref(fp);
return (ret);
-
}
/**
@@ -844,19 +843,17 @@ end:
/**
* Handle kernel failpoint set/get.
*/
-
int
fail_point_sysctl(SYSCTL_HANDLER_ARGS)
{
struct fail_point *fp;
char *buf;
- struct sbuf *sb_check;
- struct sbuf sb;
+ struct sbuf sb, *sb_check;
int error;
+ buf = NULL;
error = 0;
fp = arg1;
- buf = NULL;
sb_check = sbuf_new(&sb, NULL, 1024, SBUF_AUTOEXTEND);
if (sb_check != &sb)
@@ -949,7 +946,6 @@ fail_sysctl_drain_func(void *sysctl_args, const char *buf, int len)
return (len);
}
-
/**
* Internal helper function to translate a human-readable failpoint string
* into a internally-parsable fail_point structure.
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index e004097..1260c98 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -827,6 +827,10 @@ fork1(struct thread *td, struct fork_req *fr)
/* Must provide a place to put a procdesc if creating one. */
if (fr->fr_pd_fd == NULL)
return (EINVAL);
+
+ /* Check if we are using supported flags. */
+ if ((fr->fr_pd_flags & ~PD_ALLOWED_AT_FORK) != 0)
+ return (EINVAL);
}
p1 = td->td_proc;
@@ -878,8 +882,8 @@ fork1(struct thread *td, struct fork_req *fr)
* later.
*/
if (flags & RFPROCDESC) {
- error = falloc_caps(td, &fp_procdesc, fr->fr_pd_fd, 0,
- fr->fr_pd_fcaps);
+ error = procdesc_falloc(td, &fp_procdesc, fr->fr_pd_fd,
+ fr->fr_pd_flags, fr->fr_pd_fcaps);
if (error != 0)
goto fail2;
}
diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c
index 35e270a..ebd714f 100644
--- a/sys/kern/kern_jail.c
+++ b/sys/kern/kern_jail.c
@@ -920,6 +920,46 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags)
}
#endif
+ error = vfs_getopt(opts, "osrelease", (void **)&osrelstr, &len);
+ if (error == ENOENT)
+ osrelstr = NULL;
+ else if (error != 0)
+ goto done_free;
+ else {
+ if (flags & JAIL_UPDATE) {
+ error = EINVAL;
+ vfs_opterror(opts,
+ "osrelease cannot be changed after creation");
+ goto done_errmsg;
+ }
+ if (len == 0 || len >= OSRELEASELEN) {
+ error = EINVAL;
+ vfs_opterror(opts,
+ "osrelease string must be 1-%d bytes long",
+ OSRELEASELEN - 1);
+ goto done_errmsg;
+ }
+ }
+
+ error = vfs_copyopt(opts, "osreldate", &osreldt, sizeof(osreldt));
+ if (error == ENOENT)
+ osreldt = 0;
+ else if (error != 0)
+ goto done_free;
+ else {
+ if (flags & JAIL_UPDATE) {
+ error = EINVAL;
+ vfs_opterror(opts,
+ "osreldate cannot be changed after creation");
+ goto done_errmsg;
+ }
+ if (osreldt == 0) {
+ error = EINVAL;
+ vfs_opterror(opts, "osreldate cannot be 0");
+ goto done_errmsg;
+ }
+ }
+
fullpath_disabled = 0;
root = NULL;
error = vfs_getopt(opts, "path", (void **)&path, &len);
@@ -970,51 +1010,12 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags)
if (len + (path[0] == '/' && strcmp(mypr->pr_path, "/")
? strlen(mypr->pr_path) : 0) > MAXPATHLEN) {
error = ENAMETOOLONG;
+ vrele(root);
goto done_free;
}
}
}
- error = vfs_getopt(opts, "osrelease", (void **)&osrelstr, &len);
- if (error == ENOENT)
- osrelstr = NULL;
- else if (error != 0)
- goto done_free;
- else {
- if (flags & JAIL_UPDATE) {
- error = EINVAL;
- vfs_opterror(opts,
- "osrelease cannot be changed after creation");
- goto done_errmsg;
- }
- if (len == 0 || len >= OSRELEASELEN) {
- error = EINVAL;
- vfs_opterror(opts,
- "osrelease string must be 1-%d bytes long",
- OSRELEASELEN - 1);
- goto done_errmsg;
- }
- }
-
- error = vfs_copyopt(opts, "osreldate", &osreldt, sizeof(osreldt));
- if (error == ENOENT)
- osreldt = 0;
- else if (error != 0)
- goto done_free;
- else {
- if (flags & JAIL_UPDATE) {
- error = EINVAL;
- vfs_opterror(opts,
- "osreldate cannot be changed after creation");
- goto done_errmsg;
- }
- if (osreldt == 0) {
- error = EINVAL;
- vfs_opterror(opts, "osreldate cannot be 0");
- goto done_errmsg;
- }
- }
-
/*
* Find the specified jail, or at least its parent.
* This abuses the file error codes ENOENT and EEXIST.
@@ -1929,19 +1930,17 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags)
vrele(root);
done_errmsg:
if (error) {
- vfs_getopt(opts, "errmsg", (void **)&errmsg, &errmsg_len);
- if (errmsg_len > 0) {
+ if (vfs_getopt(opts, "errmsg", (void **)&errmsg,
+ &errmsg_len) == 0 && errmsg_len > 0) {
errmsg_pos = 2 * vfs_getopt_pos(opts, "errmsg") + 1;
- if (errmsg_pos > 0) {
- if (optuio->uio_segflg == UIO_SYSSPACE)
- bcopy(errmsg,
- optuio->uio_iov[errmsg_pos].iov_base,
- errmsg_len);
- else
- copyout(errmsg,
- optuio->uio_iov[errmsg_pos].iov_base,
- errmsg_len);
- }
+ if (optuio->uio_segflg == UIO_SYSSPACE)
+ bcopy(errmsg,
+ optuio->uio_iov[errmsg_pos].iov_base,
+ errmsg_len);
+ else
+ copyout(errmsg,
+ optuio->uio_iov[errmsg_pos].iov_base,
+ errmsg_len);
}
}
done_free:
@@ -2383,7 +2382,14 @@ sys_jail_attach(struct thread *td, struct jail_attach_args *uap)
if (error)
return (error);
- sx_slock(&allprison_lock);
+ /*
+ * Start with exclusive hold on allprison_lock to ensure that a possible
+ * PR_METHOD_REMOVE call isn't concurrent with jail_set or jail_remove.
+ * But then immediately downgrade it since we don't need to stop
+ * readers.
+ */
+ sx_xlock(&allprison_lock);
+ sx_downgrade(&allprison_lock);
pr = prison_find_child(td->td_ucred->cr_prison, uap->jid);
if (pr == NULL) {
sx_sunlock(&allprison_lock);
@@ -2601,9 +2607,11 @@ prison_complete(void *context, int pending)
{
struct prison *pr = context;
+ sx_xlock(&allprison_lock);
mtx_lock(&pr->pr_mtx);
prison_deref(pr, pr->pr_uref
- ? PD_DEREF | PD_DEUREF | PD_LOCKED : PD_LOCKED);
+ ? PD_DEREF | PD_DEUREF | PD_LOCKED | PD_LIST_XLOCKED
+ : PD_LOCKED | PD_LIST_XLOCKED);
}
/*
@@ -2647,13 +2655,8 @@ prison_deref(struct prison *pr, int flags)
*/
if (lasturef) {
if (!(flags & (PD_LIST_SLOCKED | PD_LIST_XLOCKED))) {
- if (ref > 1) {
- sx_slock(&allprison_lock);
- flags |= PD_LIST_SLOCKED;
- } else {
- sx_xlock(&allprison_lock);
- flags |= PD_LIST_XLOCKED;
- }
+ sx_xlock(&allprison_lock);
+ flags |= PD_LIST_XLOCKED;
}
(void)osd_jail_call(pr, PR_METHOD_REMOVE, NULL);
mtx_lock(&pr->pr_mtx);
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
index 16c39f0..4758cdc 100644
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -54,6 +54,10 @@ __FBSDID("$FreeBSD$");
#include <sys/syscallsubr.h>
#include <sys/sysctl.h>
+#ifdef DDB
+#include <ddb/ddb.h>
+#endif
+
#include <net/vnet.h>
#include <security/mac/mac_framework.h>
@@ -1256,6 +1260,23 @@ kern_kldstat(struct thread *td, int fileid, struct kld_file_stat *stat)
return (0);
}
+#ifdef DDB
+DB_COMMAND(kldstat, db_kldstat)
+{
+ linker_file_t lf;
+
+#define POINTER_WIDTH ((int)(sizeof(void *) * 2 + 2))
+ db_printf("Id Refs Address%*c Size Name\n", POINTER_WIDTH - 7, ' ');
+#undef POINTER_WIDTH
+ TAILQ_FOREACH(lf, &linker_files, link) {
+ if (db_pager_quit)
+ return;
+ db_printf("%2d %4d %p %-8zx %s\n", lf->id, lf->refs,
+ lf->address, lf->size, lf->filename);
+ }
+}
+#endif /* DDB */
+
int
sys_kldfirstmod(struct thread *td, struct kldfirstmod_args *uap)
{
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index db93e34..78227e7 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -929,3 +929,14 @@ mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver,
strlcpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
kdh->parity = kerneldump_parity(kdh);
}
+
+#ifdef DDB
+DB_SHOW_COMMAND(panic, db_show_panic)
+{
+
+ if (panicstr == NULL)
+ db_printf("panicstr not set\n");
+ else
+ db_printf("panic: %s\n", panicstr);
+}
+#endif
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 75a1259..f8bb87e 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -3123,6 +3123,7 @@ static int compress_user_cores = 0;
#define corefilename_lock allproc_lock
static char corefilename[MAXPATHLEN] = {"%N.core"};
+TUNABLE_STR("kern.corefile", corefilename, sizeof(corefilename));
static int
sysctl_kern_corefile(SYSCTL_HANDLER_ARGS)
@@ -3136,7 +3137,7 @@ sysctl_kern_corefile(SYSCTL_HANDLER_ARGS)
return (error);
}
-SYSCTL_PROC(_kern, OID_AUTO, corefile, CTLTYPE_STRING | CTLFLAG_RWTUN |
+SYSCTL_PROC(_kern, OID_AUTO, corefile, CTLTYPE_STRING | CTLFLAG_RW |
CTLFLAG_MPSAFE, 0, 0, sysctl_kern_corefile, "A",
"Process corefile name format string");
diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c
index 50e6db9..244e5c9 100644
--- a/sys/kern/kern_timeout.c
+++ b/sys/kern/kern_timeout.c
@@ -38,6 +38,7 @@
__FBSDID("$FreeBSD$");
#include "opt_callout_profiling.h"
+#include "opt_ddb.h"
#if defined(__arm__)
#include "opt_timer.h"
#endif
@@ -60,6 +61,11 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/smp.h>
+#ifdef DDB
+#include <ddb/ddb.h>
+#include <machine/_inttypes.h>
+#endif
+
#ifdef SMP
#include <machine/cpu.h>
#endif
@@ -1615,3 +1621,34 @@ SYSCTL_PROC(_kern, OID_AUTO, callout_stat,
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE,
0, 0, sysctl_kern_callout_stat, "I",
"Dump immediate statistic snapshot of the scheduled callouts");
+
+#ifdef DDB
+static void
+_show_callout(struct callout *c)
+{
+
+ db_printf("callout %p\n", c);
+#define C_DB_PRINTF(f, e) db_printf(" %s = " f "\n", #e, c->e);
+ db_printf(" &c_links = %p\n", &(c->c_links));
+ C_DB_PRINTF("%" PRId64, c_time);
+ C_DB_PRINTF("%" PRId64, c_precision);
+ C_DB_PRINTF("%p", c_arg);
+ C_DB_PRINTF("%p", c_func);
+ C_DB_PRINTF("%p", c_lock);
+ C_DB_PRINTF("%#x", c_flags);
+ C_DB_PRINTF("%#x", c_iflags);
+ C_DB_PRINTF("%d", c_cpu);
+#undef C_DB_PRINTF
+}
+
+DB_SHOW_COMMAND(callout, db_show_callout)
+{
+
+ if (!have_addr) {
+ db_printf("usage: show callout <struct callout *>\n");
+ return;
+ }
+
+ _show_callout((struct callout *)addr);
+}
+#endif /* DDB */
diff --git a/sys/kern/subr_intr.c b/sys/kern/subr_intr.c
index 5d18ea2..64d37ed 100644
--- a/sys/kern/subr_intr.c
+++ b/sys/kern/subr_intr.c
@@ -35,10 +35,8 @@ __FBSDID("$FreeBSD$");
* - to complete things for removable PICs
*/
-#include "opt_acpi.h"
#include "opt_ddb.h"
#include "opt_hwpmc_hooks.h"
-#include "opt_platform.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -123,35 +121,6 @@ static struct mtx isrc_table_lock;
static struct intr_irqsrc *irq_sources[NIRQ];
u_int irq_next_free;
-/*
- * XXX - All stuff around struct intr_dev_data is considered as temporary
- * until better place for storing struct intr_map_data will be find.
- *
- * For now, there are two global interrupt numbers spaces:
- * <0, NIRQ) ... interrupts without config data
- * managed in irq_sources[]
- * IRQ_DDATA_BASE + <0, 2 * NIRQ) ... interrupts with config data
- * managed in intr_ddata_tab[]
- *
- * Read intr_ddata_lookup() to see how these spaces are worked with.
- * Note that each interrupt number from second space duplicates some number
- * from first space at this moment. An interrupt number from first space can
- * be duplicated even multiple times in second space.
- */
-struct intr_dev_data {
- device_t idd_dev;
- intptr_t idd_xref;
- u_int idd_irq;
- struct intr_map_data * idd_data;
- struct intr_irqsrc * idd_isrc;
-};
-
-static struct intr_dev_data *intr_ddata_tab[2 * NIRQ];
-static u_int intr_ddata_first_unused;
-
-#define IRQ_DDATA_BASE 10000
-CTASSERT(IRQ_DDATA_BASE > nitems(irq_sources));
-
#ifdef SMP
static boolean_t irq_assign_cpu = FALSE;
#endif
@@ -534,116 +503,6 @@ intr_isrc_init_on_cpu(struct intr_irqsrc *isrc, u_int cpu)
}
#endif
-static struct intr_dev_data *
-intr_ddata_alloc(u_int extsize)
-{
- struct intr_dev_data *ddata;
- size_t size;
-
- size = sizeof(*ddata);
- ddata = malloc(size + extsize, M_INTRNG, M_WAITOK | M_ZERO);
-
- mtx_lock(&isrc_table_lock);
- if (intr_ddata_first_unused >= nitems(intr_ddata_tab)) {
- mtx_unlock(&isrc_table_lock);
- free(ddata, M_INTRNG);
- return (NULL);
- }
- intr_ddata_tab[intr_ddata_first_unused] = ddata;
- ddata->idd_irq = IRQ_DDATA_BASE + intr_ddata_first_unused++;
- mtx_unlock(&isrc_table_lock);
-
- ddata->idd_data = (struct intr_map_data *)((uintptr_t)ddata + size);
- return (ddata);
-}
-
-static struct intr_irqsrc *
-intr_ddata_lookup(u_int irq, struct intr_map_data **datap)
-{
- int error;
- struct intr_irqsrc *isrc;
- struct intr_dev_data *ddata;
-
- isrc = isrc_lookup(irq);
- if (isrc != NULL) {
- if (datap != NULL)
- *datap = NULL;
- return (isrc);
- }
-
- if (irq < IRQ_DDATA_BASE)
- return (NULL);
-
- irq -= IRQ_DDATA_BASE;
- if (irq >= nitems(intr_ddata_tab))
- return (NULL);
-
- ddata = intr_ddata_tab[irq];
- if (ddata->idd_isrc == NULL) {
- error = intr_map_irq(ddata->idd_dev, ddata->idd_xref,
- ddata->idd_data, &irq);
- if (error != 0)
- return (NULL);
- ddata->idd_isrc = isrc_lookup(irq);
- }
- if (datap != NULL)
- *datap = ddata->idd_data;
- return (ddata->idd_isrc);
-}
-
-#ifdef DEV_ACPI
-/*
- * Map interrupt source according to ACPI info into framework. If such mapping
- * does not exist, create it. Return unique interrupt number (resource handle)
- * associated with mapped interrupt source.
- */
-u_int
-intr_acpi_map_irq(device_t dev, u_int irq, enum intr_polarity pol,
- enum intr_trigger trig)
-{
- struct intr_map_data_acpi *daa;
- struct intr_dev_data *ddata;
-
- ddata = intr_ddata_alloc(sizeof(struct intr_map_data_acpi));
- if (ddata == NULL)
- return (INTR_IRQ_INVALID); /* no space left */
-
- ddata->idd_dev = dev;
- ddata->idd_data->type = INTR_MAP_DATA_ACPI;
-
- daa = (struct intr_map_data_acpi *)ddata->idd_data;
- daa->irq = irq;
- daa->pol = pol;
- daa->trig = trig;
-
- return (ddata->idd_irq);
-}
-#endif
-
-/*
- * Store GPIO interrupt decription in framework and return unique interrupt
- * number (resource handle) associated with it.
- */
-u_int
-intr_gpio_map_irq(device_t dev, u_int pin_num, u_int pin_flags, u_int intr_mode)
-{
- struct intr_dev_data *ddata;
- struct intr_map_data_gpio *dag;
-
- ddata = intr_ddata_alloc(sizeof(struct intr_map_data_gpio));
- if (ddata == NULL)
- return (INTR_IRQ_INVALID); /* no space left */
-
- ddata->idd_dev = dev;
- ddata->idd_data->type = INTR_MAP_DATA_GPIO;
-
- dag = (struct intr_map_data_gpio *)ddata->idd_data;
- dag->gpio_pin_num = pin_num;
- dag->gpio_pin_flags = pin_flags;
- dag->gpio_intr_mode = intr_mode;
- return (ddata->idd_irq);
-}
-
#ifdef INTR_SOLO
/*
* Setup filter into interrupt source.
@@ -1074,14 +933,11 @@ intr_alloc_irq(device_t dev, struct resource *res)
KASSERT(rman_get_start(res) == rman_get_end(res),
("%s: more interrupts in resource", __func__));
- data = rman_get_virtual(res);
- if (data == NULL)
- isrc = intr_ddata_lookup(rman_get_start(res), &data);
- else
- isrc = isrc_lookup(rman_get_start(res));
+ isrc = isrc_lookup(rman_get_start(res));
if (isrc == NULL)
return (EINVAL);
+ data = rman_get_virtual(res);
return (PIC_ALLOC_INTR(isrc->isrc_dev, isrc, res, data));
}
@@ -1094,14 +950,11 @@ intr_release_irq(device_t dev, struct resource *res)
KASSERT(rman_get_start(res) == rman_get_end(res),
("%s: more interrupts in resource", __func__));
- data = rman_get_virtual(res);
- if (data == NULL)
- isrc = intr_ddata_lookup(rman_get_start(res), &data);
- else
- isrc = isrc_lookup(rman_get_start(res));
+ isrc = isrc_lookup(rman_get_start(res));
if (isrc == NULL)
return (EINVAL);
+ data = rman_get_virtual(res);
return (PIC_RELEASE_INTR(isrc->isrc_dev, isrc, res, data));
}
@@ -1117,14 +970,11 @@ intr_setup_irq(device_t dev, struct resource *res, driver_filter_t filt,
KASSERT(rman_get_start(res) == rman_get_end(res),
("%s: more interrupts in resource", __func__));
- data = rman_get_virtual(res);
- if (data == NULL)
- isrc = intr_ddata_lookup(rman_get_start(res), &data);
- else
- isrc = isrc_lookup(rman_get_start(res));
+ isrc = isrc_lookup(rman_get_start(res));
if (isrc == NULL)
return (EINVAL);
+ data = rman_get_virtual(res);
name = device_get_nameunit(dev);
#ifdef INTR_SOLO
@@ -1181,14 +1031,12 @@ intr_teardown_irq(device_t dev, struct resource *res, void *cookie)
KASSERT(rman_get_start(res) == rman_get_end(res),
("%s: more interrupts in resource", __func__));
- data = rman_get_virtual(res);
- if (data == NULL)
- isrc = intr_ddata_lookup(rman_get_start(res), &data);
- else
- isrc = isrc_lookup(rman_get_start(res));
+ isrc = isrc_lookup(rman_get_start(res));
if (isrc == NULL || isrc->isrc_handlers == 0)
return (EINVAL);
+ data = rman_get_virtual(res);
+
#ifdef INTR_SOLO
if (isrc->isrc_filter != NULL) {
if (isrc != cookie)
@@ -1231,7 +1079,7 @@ intr_describe_irq(device_t dev, struct resource *res, void *cookie,
KASSERT(rman_get_start(res) == rman_get_end(res),
("%s: more interrupts in resource", __func__));
- isrc = intr_ddata_lookup(rman_get_start(res), NULL);
+ isrc = isrc_lookup(rman_get_start(res));
if (isrc == NULL || isrc->isrc_handlers == 0)
return (EINVAL);
#ifdef INTR_SOLO
@@ -1263,7 +1111,7 @@ intr_bind_irq(device_t dev, struct resource *res, int cpu)
KASSERT(rman_get_start(res) == rman_get_end(res),
("%s: more interrupts in resource", __func__));
- isrc = intr_ddata_lookup(rman_get_start(res), NULL);
+ isrc = isrc_lookup(rman_get_start(res));
if (isrc == NULL || isrc->isrc_handlers == 0)
return (EINVAL);
#ifdef INTR_SOLO
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index ce781d9..5bcf39b 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -730,7 +730,15 @@ reswitch: switch (ch = (u_char)*fmt++) {
PCHAR('>');
break;
case 'c':
+ width -= 1;
+
+ if (!ladjust && width > 0)
+ while (width--)
+ PCHAR(padc);
PCHAR(va_arg(ap, int));
+ if (ladjust && width > 0)
+ while (width--)
+ PCHAR(padc);
break;
case 'D':
up = va_arg(ap, u_char *);
diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c
index 0d3b1f4..37139c1 100644
--- a/sys/kern/sys_procdesc.c
+++ b/sys/kern/sys_procdesc.c
@@ -243,6 +243,22 @@ procdesc_new(struct proc *p, int flags)
}
/*
+ * Create a new process decriptor for the process that refers to it.
+ */
+int
+procdesc_falloc(struct thread *td, struct file **resultfp, int *resultfd,
+ int flags, struct filecaps *fcaps)
+{
+ int fflags;
+
+ fflags = 0;
+ if (flags & PD_CLOEXEC)
+ fflags = O_CLOEXEC;
+
+ return (falloc_caps(td, resultfp, resultfd, fflags, fcaps));
+}
+
+/*
* Initialize a file with a process descriptor.
*/
void
diff --git a/sys/kern/sysv_msg.c b/sys/kern/sysv_msg.c
index 2a855a6..ba3995c 100644
--- a/sys/kern/sysv_msg.c
+++ b/sys/kern/sysv_msg.c
@@ -320,12 +320,6 @@ msgunload()
#endif
for (msqid = 0; msqid < msginfo.msgmni; msqid++) {
- /*
- * Look for an unallocated and unlocked msqid_ds.
- * msqid_ds's can be locked by msgsnd or msgrcv while
- * they are copying the message in/out. We can't
- * re-use the entry until they release it.
- */
msqkptr = &msqids[msqid];
if (msqkptr->u.msg_qbytes != 0 ||
(msqkptr->u.msg_perm.mode & MSG_LOCKED) != 0)
diff --git a/sys/mips/broadcom/bcm_mipscore.c b/sys/mips/broadcom/bcm_mipscore.c
index ddd4c80..e48a68f 100644
--- a/sys/mips/broadcom/bcm_mipscore.c
+++ b/sys/mips/broadcom/bcm_mipscore.c
@@ -53,10 +53,13 @@ static const struct resource_spec mipscore_rspec[MIPSCORE_MAX_RSPEC] = {
{ -1, -1, 0 }
};
+#define MIPSCORE_DEV(_vendor, _core) \
+ BHND_DEVICE(_vendor, _core, NULL, NULL, BHND_DF_SOC)
+
struct bhnd_device mipscore_match[] = {
- BHND_MIPS_DEVICE(MIPS, "BHND MIPS processor", NULL),
- BHND_MIPS_DEVICE(MIPS33, "BHND MIPS3302 processor", NULL),
- BHND_MIPS_DEVICE(MIPS74K, "BHND MIPS74K processor", NULL),
+ MIPSCORE_DEV(BCM, MIPS),
+ MIPSCORE_DEV(BCM, MIPS33),
+ MIPSCORE_DEV(MIPS, MIPS74K),
BHND_DEVICE_END
};
@@ -116,8 +119,8 @@ static device_method_t mipscore_methods[] = {
devclass_t bhnd_mipscore_devclass;
-DEFINE_CLASS_0(bhnd_mipscore, mipscore_driver, mipscore_methods,
- sizeof(struct mipscore_softc));
-DRIVER_MODULE(bhnd_mipscore, bhnd, mipscore_driver, bhnd_mipscore_devclass,
- 0, 0);
-MODULE_VERSION(bhnd_mipscore, 1);
+DEFINE_CLASS_0(bhnd_mips, mipscore_driver, mipscore_methods,
+ sizeof(struct mipscore_softc));
+EARLY_DRIVER_MODULE(bhnd_mips, bhnd, mipscore_driver,
+ bhnd_mipscore_devclass, 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_EARLY);
+MODULE_VERSION(bhnd_mips, 1);
diff --git a/sys/mips/mips/swtch.S b/sys/mips/mips/swtch.S
index 056d1f0..1cd7df4 100644
--- a/sys/mips/mips/swtch.S
+++ b/sys/mips/mips/swtch.S
@@ -401,6 +401,8 @@ END(cpu_switch)
*----------------------------------------------------------------------------
*/
LEAF(MipsSwitchFPState)
+ .set push
+ .set hardfloat
mfc0 t1, MIPS_COP_0_STATUS # Save old SR
li t0, MIPS_SR_COP_1_BIT # enable the coprocessor
mtc0 t0, MIPS_COP_0_STATUS
@@ -502,6 +504,7 @@ LEAF(MipsSwitchFPState)
ITLBNOPFIX
j ra
nop
+ .set pop
END(MipsSwitchFPState)
/*----------------------------------------------------------------------------
@@ -522,6 +525,8 @@ END(MipsSwitchFPState)
*----------------------------------------------------------------------------
*/
LEAF(MipsSaveCurFPState)
+ .set push
+ .set hardfloat
PTR_L a0, TD_PCB(a0) # get pointer to pcb for thread
mfc0 t1, MIPS_COP_0_STATUS # Disable interrupts and
li t0, MIPS_SR_COP_1_BIT # enable the coprocessor
@@ -580,6 +585,7 @@ LEAF(MipsSaveCurFPState)
ITLBNOPFIX
j ra
nop
+ .set pop
END(MipsSaveCurFPState)
/*
diff --git a/sys/modules/Makefile b/sys/modules/Makefile
index 745d414..426d12f 100644
--- a/sys/modules/Makefile
+++ b/sys/modules/Makefile
@@ -353,7 +353,7 @@ SUBDIR= \
${_syscons} \
sysvipc \
${_ti} \
- tcp/fastpath \
+ ${_tcp_fastpath} \
tests/framework \
tests/callout_test \
tl \
@@ -436,6 +436,10 @@ _random_other= random_other
SUBDIR+= cuse
.endif
+.if ${MK_EXTRA_TCP_STACKS} != "no" || defined(ALL_MODULES)
+_tcp_fastpath= tcp/fastpath
+.endif
+
.if (${MK_INET_SUPPORT} != "no" || ${MK_INET6_SUPPORT} != "no") || \
defined(ALL_MODULES)
_carp= carp
diff --git a/sys/modules/bwn/Makefile b/sys/modules/bwn/Makefile
index dbad3c3..f8eac6e 100644
--- a/sys/modules/bwn/Makefile
+++ b/sys/modules/bwn/Makefile
@@ -12,7 +12,7 @@ SRCS+= if_bwn_phy_g.c if_bwn_phy_lp.c
SRCS+= if_bwn_phy_n.c
# Other
-SRCS+= device_if.h bus_if.h pci_if.h
+SRCS+= device_if.h bus_if.h pci_if.h opt_bwn.h opt_wlan.h
# Uncomment this for the GPL PHY code; this requires the
# module be built with BWN_GPL_PHY set in the kernel
diff --git a/sys/modules/bwn_pci/Makefile b/sys/modules/bwn_pci/Makefile
index 355bc2a..15b9ded 100644
--- a/sys/modules/bwn_pci/Makefile
+++ b/sys/modules/bwn_pci/Makefile
@@ -7,5 +7,6 @@ SRCS= if_bwn_pci.c bwn_mac.c
SRCS+= bhnd_bus_if.h bhndb_bus_if.h \
bhndb_if.h bhnd_nvram_map.h
SRCS+= device_if.h bus_if.h pci_if.h \
+ opt_bwn.h opt_wlan.h opt_global.h
.include <bsd.kmod.mk>
diff --git a/sys/modules/dtb/allwinner/Makefile b/sys/modules/dtb/allwinner/Makefile
index e95d7bb..9dd0799 100644
--- a/sys/modules/dtb/allwinner/Makefile
+++ b/sys/modules/dtb/allwinner/Makefile
@@ -7,6 +7,7 @@ DTS= \
cubieboard2.dts \
olimex-a20-som-evb.dts \
olinuxino-lime.dts \
+ pcduino3b.dts \
sinovoip-bpi-m3.dts
.include <bsd.dtb.mk>
diff --git a/sys/modules/netgraph/mppc/Makefile b/sys/modules/netgraph/mppc/Makefile
index 40b3717..1ab69e6 100644
--- a/sys/modules/netgraph/mppc/Makefile
+++ b/sys/modules/netgraph/mppc/Makefile
@@ -4,11 +4,10 @@
KMOD= ng_mppc
SRCS= ng_mppc.c opt_netgraph.h
-NETGRAPH_MPPC_COMPRESSION?= 0
+NETGRAPH_MPPC_COMPRESSION?= 1
NETGRAPH_MPPC_ENCRYPTION?= 1
.if ${NETGRAPH_MPPC_COMPRESSION} > 0
-# XXX These files don't exist yet, but hopefully someday they will...
.PATH: ${.CURDIR}/../../../net
SRCS+= mppcc.c mppcd.c
.endif
diff --git a/sys/modules/siba_bwn/Makefile b/sys/modules/siba_bwn/Makefile
index 433d37f..02fbd5d 100644
--- a/sys/modules/siba_bwn/Makefile
+++ b/sys/modules/siba_bwn/Makefile
@@ -4,6 +4,6 @@
KMOD= siba_bwn
SRCS= siba_core.c siba_bwn.c sibareg.h sibavar.h
-SRCS+= device_if.h bus_if.h pci_if.h
+SRCS+= device_if.h bus_if.h pci_if.h opt_siba.h
.include <bsd.kmod.mk>
diff --git a/sys/modules/tcp/fastpath/Makefile b/sys/modules/tcp/fastpath/Makefile
index d9a6587..c6469fe 100644
--- a/sys/modules/tcp/fastpath/Makefile
+++ b/sys/modules/tcp/fastpath/Makefile
@@ -7,7 +7,7 @@
KMOD= fastpath
SRCS= fastpath.c
-SRCS+= opt_ipfw.h opt_inet.h opt_inet6.h opt_ipsec.h
+SRCS+= opt_inet.h opt_inet6.h opt_ipsec.h
SRCS+= opt_tcpdebug.h
#
diff --git a/sys/net/flowtable.c b/sys/net/flowtable.c
index 35aff00..b837a8e 100644
--- a/sys/net/flowtable.c
+++ b/sys/net/flowtable.c
@@ -689,7 +689,7 @@ flowtable_lookup(sa_family_t sa, struct mbuf *m, struct route *ro)
return (EHOSTUNREACH);
if (M_HASHTYPE_GET(m) == M_HASHTYPE_NONE) {
- M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE);
+ M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE_HASH);
m->m_pkthdr.flowid = fle->f_hash;
}
diff --git a/sys/net/if.c b/sys/net/if.c
index 6845bbf..4d475d9 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -848,6 +848,7 @@ if_purgeaddrs(struct ifnet *ifp)
{
struct ifaddr *ifa, *next;
+ /* XXX cannot hold IF_ADDR_WLOCK over called functions. */
TAILQ_FOREACH_SAFE(ifa, &ifp->if_addrhead, ifa_link, next) {
if (ifa->ifa_addr->sa_family == AF_LINK)
continue;
@@ -872,7 +873,9 @@ if_purgeaddrs(struct ifnet *ifp)
continue;
}
#endif /* INET6 */
+ IF_ADDR_WLOCK(ifp);
TAILQ_REMOVE(&ifp->if_addrhead, ifa, ifa_link);
+ IF_ADDR_WUNLOCK(ifp);
ifa_free(ifa);
}
}
@@ -1004,11 +1007,14 @@ if_detach_internal(struct ifnet *ifp, int vmove, struct if_clone **ifcp)
ifp->if_addr = NULL;
/* We can now free link ifaddr. */
+ IF_ADDR_WLOCK(ifp);
if (!TAILQ_EMPTY(&ifp->if_addrhead)) {
ifa = TAILQ_FIRST(&ifp->if_addrhead);
TAILQ_REMOVE(&ifp->if_addrhead, ifa, ifa_link);
+ IF_ADDR_WUNLOCK(ifp);
ifa_free(ifa);
- }
+ } else
+ IF_ADDR_WUNLOCK(ifp);
}
rt_flushifroutes(ifp);
@@ -1024,9 +1030,11 @@ if_detach_internal(struct ifnet *ifp, int vmove, struct if_clone **ifcp)
ifp->if_afdata_initialized = 0;
IF_AFDATA_UNLOCK(ifp);
for (dp = domains; i > 0 && dp; dp = dp->dom_next) {
- if (dp->dom_ifdetach && ifp->if_afdata[dp->dom_family])
+ if (dp->dom_ifdetach && ifp->if_afdata[dp->dom_family]) {
(*dp->dom_ifdetach)(ifp,
ifp->if_afdata[dp->dom_family]);
+ ifp->if_afdata[dp->dom_family] = NULL;
+ }
}
return (0);
diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c
index a5631fc..f830b06 100644
--- a/sys/net/if_vxlan.c
+++ b/sys/net/if_vxlan.c
@@ -2237,8 +2237,7 @@ vxlan_pick_source_port(struct vxlan_softc *sc, struct mbuf *m)
range = sc->vxl_max_port - sc->vxl_min_port + 1;
/* check if flowid is set and not opaque */
- if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE &&
- M_HASHTYPE_GET(m) != M_HASHTYPE_OPAQUE)
+ if (M_HASHTYPE_ISHASH(m))
hash = m->m_pkthdr.flowid;
else
hash = jenkins_hash(m->m_data, ETHER_HDR_LEN,
diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index be5b85b..955a1b2 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -3085,7 +3085,7 @@ iflib_if_transmit(if_t ifp, struct mbuf *m)
next = next->m_nextpkt;
} while (next != NULL);
- if (count > 8)
+ if (count > nitems(marr))
if ((mp = malloc(count*sizeof(struct mbuf *), M_IFLIB, M_NOWAIT)) == NULL) {
/* XXX check nextpkt */
m_freem(m);
@@ -3112,7 +3112,7 @@ iflib_if_transmit(if_t ifp, struct mbuf *m)
m_freem(mp[i]);
ifmp_ring_check_drainage(txq->ift_br[0], TX_BATCH_SIZE);
}
- if (count > 16)
+ if (count > nitems(marr))
free(mp, M_IFLIB);
return (err);
@@ -3863,6 +3863,9 @@ iflib_queues_alloc(if_ctx_t ctx)
KASSERT(ntxqs > 0, ("number of queues must be at least 1"));
KASSERT(nrxqs > 0, ("number of queues must be at least 1"));
+ brscp = NULL;
+ rxq = NULL;
+
/* Allocate the TX ring struct memory */
if (!(txq =
(iflib_txq_t) malloc(sizeof(struct iflib_txq) *
@@ -3888,6 +3891,8 @@ iflib_queues_alloc(if_ctx_t ctx)
ctx->ifc_txqs = txq;
ctx->ifc_rxqs = rxq;
+ txq = NULL;
+ rxq = NULL;
/*
* XXX handle allocation failure
@@ -3898,7 +3903,7 @@ iflib_queues_alloc(if_ctx_t ctx)
if ((ifdip = malloc(sizeof(struct iflib_dma_info) * ntxqs, M_IFLIB, M_WAITOK|M_ZERO)) == NULL) {
device_printf(dev, "failed to allocate iflib_dma_info\n");
err = ENOMEM;
- goto fail;
+ goto err_tx_desc;
}
txq->ift_ifdi = ifdip;
for (j = 0; j < ntxqs; j++, ifdip++) {
@@ -3940,7 +3945,7 @@ iflib_queues_alloc(if_ctx_t ctx)
if (err) {
/* XXX free any allocated rings */
device_printf(dev, "Unable to allocate buf_ring\n");
- goto fail;
+ goto err_tx_desc;
}
}
}
@@ -3951,7 +3956,7 @@ iflib_queues_alloc(if_ctx_t ctx)
if ((ifdip = malloc(sizeof(struct iflib_dma_info) * nrxqs, M_IFLIB, M_WAITOK|M_ZERO)) == NULL) {
device_printf(dev, "failed to allocate iflib_dma_info\n");
err = ENOMEM;
- goto fail;
+ goto err_tx_desc;
}
rxq->ifr_ifdi = ifdip;
@@ -3975,7 +3980,7 @@ iflib_queues_alloc(if_ctx_t ctx)
(iflib_fl_t) malloc(sizeof(struct iflib_fl) * nfree_lists, M_IFLIB, M_NOWAIT | M_ZERO))) {
device_printf(dev, "Unable to allocate free list memory\n");
err = ENOMEM;
- goto fail;
+ goto err_tx_desc;
}
rxq->ifr_fl = fl;
for (j = 0; j < nfree_lists; j++) {
@@ -4042,10 +4047,16 @@ err_tx_desc:
if (ctx->ifc_rxqs != NULL)
free(ctx->ifc_rxqs, M_IFLIB);
ctx->ifc_rxqs = NULL;
-rx_fail:
if (ctx->ifc_txqs != NULL)
free(ctx->ifc_txqs, M_IFLIB);
ctx->ifc_txqs = NULL;
+rx_fail:
+ if (brscp != NULL)
+ free(brscp, M_IFLIB);
+ if (rxq != NULL)
+ free(rxq, M_IFLIB);
+ if (txq != NULL)
+ free(txq, M_IFLIB);
fail:
return (err);
}
diff --git a/sys/net/mppc.h b/sys/net/mppc.h
new file mode 100644
index 0000000..29b5113
--- /dev/null
+++ b/sys/net/mppc.h
@@ -0,0 +1,62 @@
+/*-
+ * Copyright (c) 2007 Alexander Motin <mav@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice unmodified, this list of conditions, and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * MPPC decompression library.
+ * Version 1.0
+ *
+ * Note that Hi/Fn (later acquired by Exar Corporation) held US patents
+ * on some implementation-critical aspects of MPPC compression.
+ * These patents lapsed due to non-payment of fees in 2007 and by 2015
+ * expired altogether.
+ */
+
+#ifndef _NET_MPPC_H_
+#define _NET_MPPC_H_
+
+#define MPPC_MANDATORY_COMPRESS_FLAGS 0
+#define MPPC_MANDATORY_DECOMPRESS_FLAGS 0
+
+#define MPPC_SAVE_HISTORY 1
+
+#define MPPC_OK 5
+#define MPPC_EXPANDED 8
+#define MPPC_RESTART_HISTORY 16
+#define MPPC_DEST_EXHAUSTED 32
+
+extern size_t MPPC_SizeOfCompressionHistory(void);
+extern size_t MPPC_SizeOfDecompressionHistory(void);
+
+extern void MPPC_InitCompressionHistory(char *history);
+extern void MPPC_InitDecompressionHistory(char *history);
+
+extern int MPPC_Compress(u_char **src, u_char **dst, u_long *srcCnt, u_long *dstCnt, char *history, int flags, int undef);
+extern int MPPC_Decompress(u_char **src, u_char **dst, u_long *srcCnt, u_long *dstCnt, char *history, int flags);
+
+#endif
diff --git a/sys/net/mppcc.c b/sys/net/mppcc.c
new file mode 100644
index 0000000..01ce3ff
--- /dev/null
+++ b/sys/net/mppcc.c
@@ -0,0 +1,299 @@
+/*-
+ * Copyright (c) 2002-2004 Jan Dubiec <jdx@slackware.pl>
+ * Copyright (c) 2007 Alexander Motin <mav@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice unmodified, this list of conditions, and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * MPPC decompression library.
+ * Version 1.0
+ *
+ * Note that Hi/Fn (later acquired by Exar Corporation) held US patents
+ * on some implementation-critical aspects of MPPC compression.
+ * These patents lapsed due to non-payment of fees in 2007 and by 2015
+ * expired altogether.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+
+#include <net/mppc.h>
+
+#define MPPE_HIST_LEN 8192
+
+#define HASH(x) (((40543*(((((x)[0]<<4)^(x)[1])<<4)^(x)[2]))>>4) & 0x1fff)
+
+struct MPPC_comp_state {
+ uint8_t hist[2*MPPE_HIST_LEN];
+ uint16_t histptr;
+ uint16_t hash[MPPE_HIST_LEN];
+};
+
+/* Inserts 1 to 8 bits into the output buffer. */
+static void __inline
+putbits8(uint8_t *buf, uint32_t val, const uint32_t n, uint32_t *i, uint32_t *l)
+{
+ buf += *i;
+ if (*l >= n) {
+ *l = (*l) - n;
+ val <<= *l;
+ *buf = *buf | (val & 0xff);
+ if (*l == 0) {
+ *l = 8;
+ (*i)++;
+ *(++buf) = 0;
+ }
+ } else {
+ (*i)++;
+ *l = 8 - n + (*l);
+ val <<= *l;
+ *buf = *buf | ((val >> 8) & 0xff);
+ *(++buf) = val & 0xff;
+ }
+}
+
+/* Inserts 9 to 16 bits into the output buffer. */
+static void __inline
+putbits16(uint8_t *buf, uint32_t val, const uint32_t n, uint32_t *i, uint32_t *l)
+{
+ buf += *i;
+ if (*l >= n - 8) {
+ (*i)++;
+ *l = 8 - n + (*l);
+ val <<= *l;
+ *buf = *buf | ((val >> 8) & 0xff);
+ *(++buf) = val & 0xff;
+ if (*l == 0) {
+ *l = 8;
+ (*i)++;
+ *(++buf) = 0;
+ }
+ } else {
+ (*i)++; (*i)++;
+ *l = 16 - n + (*l);
+ val <<= *l;
+ *buf = *buf | ((val >> 16) & 0xff);
+ *(++buf) = (val >> 8) & 0xff;
+ *(++buf) = val & 0xff;
+ }
+}
+
+/* Inserts 17 to 24 bits into the output buffer. */
+static void __inline
+putbits24(uint8_t *buf, uint32_t val, const uint32_t n, uint32_t *i, uint32_t *l)
+{
+ buf += *i;
+ if (*l >= n - 16) {
+ (*i)++; (*i)++;
+ *l = 16 - n + (*l);
+ val <<= *l;
+ *buf = *buf | ((val >> 16) & 0xff);
+ *(++buf) = (val >> 8) & 0xff;
+ *(++buf) = val & 0xff;
+ if (*l == 0) {
+ *l = 8;
+ (*i)++;
+ *(++buf) = 0;
+ }
+ } else {
+ (*i)++; (*i)++; (*i)++;
+ *l = 24 - n + (*l);
+ val <<= *l;
+ *buf = *buf | ((val >> 24) & 0xff);
+ *(++buf) = (val >> 16) & 0xff;
+ *(++buf) = (val >> 8) & 0xff;
+ *(++buf) = val & 0xff;
+ }
+}
+
+size_t MPPC_SizeOfCompressionHistory(void)
+{
+ return (sizeof(struct MPPC_comp_state));
+}
+
+void MPPC_InitCompressionHistory(char *history)
+{
+ struct MPPC_comp_state *state = (struct MPPC_comp_state*)history;
+
+ bzero(history, sizeof(struct MPPC_comp_state));
+ state->histptr = MPPE_HIST_LEN;
+}
+
+int MPPC_Compress(u_char **src, u_char **dst, u_long *srcCnt, u_long *dstCnt, char *history, int flags, int undef)
+{
+ struct MPPC_comp_state *state = (struct MPPC_comp_state*)history;
+ uint32_t olen, off, len, idx, i, l;
+ uint8_t *hist, *sbuf, *p, *q, *r, *s;
+ int rtn = MPPC_OK;
+
+ /*
+ * At this point, to avoid possible buffer overflow caused by packet
+ * expansion during/after compression, we should make sure we have
+ * space for the worst case.
+
+ * Maximum MPPC packet expansion is 12.5%. This is the worst case when
+ * all octets in the input buffer are >= 0x80 and we cannot find any
+ * repeated tokens.
+ */
+ if (*dstCnt < (*srcCnt * 9 / 8 + 2)) {
+ rtn &= ~MPPC_OK;
+ return (rtn);
+ }
+
+ /* We can't compress more then MPPE_HIST_LEN bytes in a call. */
+ if (*srcCnt > MPPE_HIST_LEN) {
+ rtn &= ~MPPC_OK;
+ return (rtn);
+ }
+
+ hist = state->hist + MPPE_HIST_LEN;
+ /* check if there is enough room at the end of the history */
+ if (state->histptr + *srcCnt >= 2*MPPE_HIST_LEN) {
+ rtn |= MPPC_RESTART_HISTORY;
+ state->histptr = MPPE_HIST_LEN;
+ memcpy(state->hist, hist, MPPE_HIST_LEN);
+ }
+ /* Add packet to the history. */
+ sbuf = state->hist + state->histptr;
+ memcpy(sbuf, *src, *srcCnt);
+ state->histptr += *srcCnt;
+
+ /* compress data */
+ r = sbuf + *srcCnt;
+ **dst = olen = i = 0;
+ l = 8;
+ while (i < *srcCnt - 2) {
+ s = q = sbuf + i;
+
+ /* Prognose matching position using hash function. */
+ idx = HASH(s);
+ p = hist + state->hash[idx];
+ state->hash[idx] = (uint16_t) (s - hist);
+ if (p > s) /* It was before MPPC_RESTART_HISTORY. */
+ p -= MPPE_HIST_LEN; /* Try previous history buffer. */
+ off = s - p;
+
+ /* Check our prognosis. */
+ if (off > MPPE_HIST_LEN - 1 || off < 1 || *p++ != *s++ ||
+ *p++ != *s++ || *p++ != *s++) {
+ /* No match found; encode literal byte. */
+ if ((*src)[i] < 0x80) { /* literal byte < 0x80 */
+ putbits8(*dst, (uint32_t) (*src)[i], 8, &olen, &l);
+ } else { /* literal byte >= 0x80 */
+ putbits16(*dst, (uint32_t) (0x100|((*src)[i]&0x7f)), 9,
+ &olen, &l);
+ }
+ ++i;
+ continue;
+ }
+
+ /* Find length of the matching fragment */
+#if defined(__amd64__) || defined(__i386__)
+ /* Optimization for CPUs without strict data aligning requirements */
+ while ((*((uint32_t*)p) == *((uint32_t*)s)) && (s < (r - 3))) {
+ p+=4;
+ s+=4;
+ }
+#endif
+ while((*p++ == *s++) && (s <= r));
+ len = s - q - 1;
+ i += len;
+
+ /* At least 3 character match found; code data. */
+ /* Encode offset. */
+ if (off < 64) { /* 10-bit offset; 0 <= offset < 64 */
+ putbits16(*dst, 0x3c0|off, 10, &olen, &l);
+ } else if (off < 320) { /* 12-bit offset; 64 <= offset < 320 */
+ putbits16(*dst, 0xe00|(off-64), 12, &olen, &l);
+ } else if (off < 8192) { /* 16-bit offset; 320 <= offset < 8192 */
+ putbits16(*dst, 0xc000|(off-320), 16, &olen, &l);
+ } else { /* NOTREACHED */
+ rtn &= ~MPPC_OK;
+ return rtn;
+ }
+
+ /* Encode length of match. */
+ if (len < 4) { /* length = 3 */
+ putbits8(*dst, 0, 1, &olen, &l);
+ } else if (len < 8) { /* 4 <= length < 8 */
+ putbits8(*dst, 0x08|(len&0x03), 4, &olen, &l);
+ } else if (len < 16) { /* 8 <= length < 16 */
+ putbits8(*dst, 0x30|(len&0x07), 6, &olen, &l);
+ } else if (len < 32) { /* 16 <= length < 32 */
+ putbits8(*dst, 0xe0|(len&0x0f), 8, &olen, &l);
+ } else if (len < 64) { /* 32 <= length < 64 */
+ putbits16(*dst, 0x3c0|(len&0x1f), 10, &olen, &l);
+ } else if (len < 128) { /* 64 <= length < 128 */
+ putbits16(*dst, 0xf80|(len&0x3f), 12, &olen, &l);
+ } else if (len < 256) { /* 128 <= length < 256 */
+ putbits16(*dst, 0x3f00|(len&0x7f), 14, &olen, &l);
+ } else if (len < 512) { /* 256 <= length < 512 */
+ putbits16(*dst, 0xfe00|(len&0xff), 16, &olen, &l);
+ } else if (len < 1024) { /* 512 <= length < 1024 */
+ putbits24(*dst, 0x3fc00|(len&0x1ff), 18, &olen, &l);
+ } else if (len < 2048) { /* 1024 <= length < 2048 */
+ putbits24(*dst, 0xff800|(len&0x3ff), 20, &olen, &l);
+ } else if (len < 4096) { /* 2048 <= length < 4096 */
+ putbits24(*dst, 0x3ff000|(len&0x7ff), 22, &olen, &l);
+ } else if (len < 8192) { /* 4096 <= length < 8192 */
+ putbits24(*dst, 0xffe000|(len&0xfff), 24, &olen, &l);
+ } else { /* NOTREACHED */
+ rtn &= ~MPPC_OK;
+ return (rtn);
+ }
+ }
+
+ /* Add remaining octets to the output. */
+ while(*srcCnt - i > 0) {
+ if ((*src)[i] < 0x80) { /* literal byte < 0x80 */
+ putbits8(*dst, (uint32_t) (*src)[i++], 8, &olen, &l);
+ } else { /* literal byte >= 0x80 */
+ putbits16(*dst, (uint32_t) (0x100|((*src)[i++]&0x7f)), 9, &olen,
+ &l);
+ }
+ }
+
+ /* Reset unused bits of the last output octet. */
+ if ((l != 0) && (l != 8)) {
+ putbits8(*dst, 0, l, &olen, &l);
+ }
+
+ /* If result is bigger then original, set flag and flush history. */
+ if ((*srcCnt < olen) || ((flags & MPPC_SAVE_HISTORY) == 0)) {
+ if (*srcCnt < olen)
+ rtn |= MPPC_EXPANDED;
+ bzero(history, sizeof(struct MPPC_comp_state));
+ state->histptr = MPPE_HIST_LEN;
+ }
+
+ *src += *srcCnt;
+ *srcCnt = 0;
+ *dst += olen;
+ *dstCnt -= olen;
+
+ return (rtn);
+}
diff --git a/sys/net/mppcd.c b/sys/net/mppcd.c
new file mode 100644
index 0000000..c1730e5
--- /dev/null
+++ b/sys/net/mppcd.c
@@ -0,0 +1,284 @@
+/*-
+ * Copyright (c) 2002-2004 Jan Dubiec <jdx@slackware.pl>
+ * Copyright (c) 2007 Alexander Motin <mav@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice unmodified, this list of conditions, and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * MPPC decompression library.
+ * Version 1.0
+ *
+ * Note that Hi/Fn (later acquired by Exar Corporation) held US patents
+ * on some implementation-critical aspects of MPPC compression.
+ * These patents lapsed due to non-payment of fees in 2007 and by 2015
+ * expired altogether.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+
+#include <net/mppc.h>
+
+#define MPPE_HIST_LEN 8192
+
+struct MPPC_decomp_state {
+ uint8_t hist[2*MPPE_HIST_LEN];
+ uint16_t histptr;
+};
+
+static uint32_t __inline
+getbits(const uint8_t *buf, const uint32_t n, uint32_t *i, uint32_t *l)
+{
+ static const uint32_t m[] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
+ uint32_t res, ol;
+
+ ol = *l;
+ if (*l >= n) {
+ *l = (*l) - n;
+ res = (buf[*i] & m[ol]) >> (*l);
+ if (*l == 0) {
+ *l = 8;
+ (*i)++;
+ }
+ } else {
+ *l = 8 - n + (*l);
+ res = (buf[(*i)++] & m[ol]) << 8;
+ res = (res | buf[*i]) >> (*l);
+ }
+
+ return (res);
+}
+
+static uint32_t __inline
+getbyte(const uint8_t *buf, const uint32_t i, const uint32_t l)
+{
+ if (l == 8) {
+ return (buf[i]);
+ } else {
+ return ((((buf[i] << 8) | buf[i+1]) >> l) & 0xff);
+ }
+}
+
+static void __inline
+lamecopy(uint8_t *dst, uint8_t *src, uint32_t len)
+{
+ while (len--)
+ *dst++ = *src++;
+}
+
+size_t MPPC_SizeOfDecompressionHistory(void)
+{
+ return (sizeof(struct MPPC_decomp_state));
+}
+
+void MPPC_InitDecompressionHistory(char *history)
+{
+ struct MPPC_decomp_state *state = (struct MPPC_decomp_state*)history;
+
+ bzero(history, sizeof(struct MPPC_decomp_state));
+ state->histptr = MPPE_HIST_LEN;
+}
+
+int MPPC_Decompress(u_char **src, u_char **dst, u_long *srcCnt, u_long *dstCnt, char *history, int flags)
+{
+ struct MPPC_decomp_state *state = (struct MPPC_decomp_state*)history;
+ uint32_t olen, off, len, bits, val, sig, i, l;
+ uint8_t *hist, *s;
+ u_char *isrc = *src;
+ int rtn = MPPC_OK;
+
+ if ((flags & MPPC_RESTART_HISTORY) != 0) {
+ memcpy(state->hist, state->hist + MPPE_HIST_LEN, MPPE_HIST_LEN);
+ state->histptr = MPPE_HIST_LEN;
+ }
+
+ hist = state->hist + state->histptr;
+ olen = len = i = 0;
+ l = 8;
+ bits = *srcCnt * 8;
+ while (bits >= 8) {
+ val = getbyte(isrc, i++, l);
+ if (val < 0x80) { /* literal byte < 0x80 */
+ if (state->histptr < 2*MPPE_HIST_LEN) {
+ /* Copy uncompressed byte to the history. */
+ (state->hist)[(state->histptr)++] = (uint8_t) val;
+ } else {
+ /* Buffer overflow; drop packet. */
+ rtn &= ~MPPC_OK;
+ return rtn;
+ }
+ olen++;
+ bits -= 8;
+ continue;
+ }
+
+ sig = val & 0xc0;
+ if (sig == 0x80) { /* literal byte >= 0x80 */
+ if (state->histptr < 2*MPPE_HIST_LEN) {
+ /* Copy uncompressed byte to the history. */
+ (state->hist)[(state->histptr)++] =
+ (uint8_t) (0x80|((val&0x3f)<<1)|getbits(isrc, 1 , &i ,&l));
+ } else {
+ /* buffer overflow; drop packet */
+ rtn &= ~MPPC_OK;
+ return (rtn);
+ }
+ olen++;
+ bits -= 9;
+ continue;
+ }
+
+ /* Not a literal byte so it must be an (offset,length) pair */
+ /* decode offset */
+ sig = val & 0xf0;
+ if (sig == 0xf0) { /* 10-bit offset; 0 <= offset < 64 */
+ off = (((val&0x0f)<<2)|getbits(isrc, 2 , &i ,&l));
+ bits -= 10;
+ } else {
+ if (sig == 0xe0) { /* 12-bit offset; 64 <= offset < 320 */
+ off = ((((val&0x0f)<<4)|getbits(isrc, 4 , &i ,&l))+64);
+ bits -= 12;
+ } else {
+ if ((sig&0xe0) == 0xc0) {/* 16-bit offset; 320 <= offset < 8192 */
+ off = ((((val&0x1f)<<8)|getbyte(isrc, i++, l))+320);
+ bits -= 16;
+ if (off > MPPE_HIST_LEN - 1) {
+ rtn &= ~MPPC_OK;
+ return (rtn);
+ }
+ } else { /* NOTREACHED */
+ rtn &= ~MPPC_OK;
+ return (rtn);
+ }
+ }
+ }
+ /* Decode length of match. */
+ val = getbyte(isrc, i, l);
+ if ((val & 0x80) == 0x00) { /* len = 3 */
+ len = 3;
+ bits--;
+ getbits(isrc, 1 , &i ,&l);
+ } else if ((val & 0xc0) == 0x80) { /* 4 <= len < 8 */
+ len = 0x04 | ((val>>4) & 0x03);
+ bits -= 4;
+ getbits(isrc, 4 , &i ,&l);
+ } else if ((val & 0xe0) == 0xc0) { /* 8 <= len < 16 */
+ len = 0x08 | ((val>>2) & 0x07);
+ bits -= 6;
+ getbits(isrc, 6 , &i ,&l);
+ } else if ((val & 0xf0) == 0xe0) { /* 16 <= len < 32 */
+ len = 0x10 | (val & 0x0f);
+ bits -= 8;
+ i++;
+ } else {
+ bits -= 8;
+ val = (val << 8) | getbyte(isrc, ++i, l);
+ if ((val & 0xf800) == 0xf000) { /* 32 <= len < 64 */
+ len = 0x0020 | ((val >> 6) & 0x001f);
+ bits -= 2;
+ getbits(isrc, 2 , &i ,&l);
+ } else if ((val & 0xfc00) == 0xf800) { /* 64 <= len < 128 */
+ len = 0x0040 | ((val >> 4) & 0x003f);
+ bits -= 4;
+ getbits(isrc, 4 , &i ,&l);
+ } else if ((val & 0xfe00) == 0xfc00) { /* 128 <= len < 256 */
+ len = 0x0080 | ((val >> 2) & 0x007f);
+ bits -= 6;
+ getbits(isrc, 6 , &i ,&l);
+ } else if ((val & 0xff00) == 0xfe00) { /* 256 <= len < 512 */
+ len = 0x0100 | (val & 0x00ff);
+ bits -= 8;
+ i++;
+ } else {
+ bits -= 8;
+ val = (val << 8) | getbyte(isrc, ++i, l);
+ if ((val & 0xff8000) == 0xff0000) { /* 512 <= len < 1024 */
+ len = 0x000200 | ((val >> 6) & 0x0001ff);
+ bits -= 2;
+ getbits(isrc, 2 , &i ,&l);
+ } else if ((val & 0xffc000) == 0xff8000) {/* 1024 <= len < 2048 */
+ len = 0x000400 | ((val >> 4) & 0x0003ff);
+ bits -= 4;
+ getbits(isrc, 4 , &i ,&l);
+ } else if ((val & 0xffe000) == 0xffc000) {/* 2048 <= len < 4096 */
+ len = 0x000800 | ((val >> 2) & 0x0007ff);
+ bits -= 6;
+ getbits(isrc, 6 , &i ,&l);
+ } else if ((val & 0xfff000) == 0xffe000) {/* 4096 <= len < 8192 */
+ len = 0x001000 | (val & 0x000fff);
+ bits -= 8;
+ i++;
+ } else { /* NOTREACHED */
+ rtn &= ~MPPC_OK;
+ return (rtn);
+ }
+ }
+ }
+
+ s = state->hist + state->histptr;
+ state->histptr += len;
+ olen += len;
+ if (state->histptr < 2*MPPE_HIST_LEN) {
+ /* Copy uncompressed bytes to the history. */
+
+ /*
+ * In some cases len may be greater than off. It means that memory
+ * areas pointed by s and s-off overlap. To decode that strange case
+ * data should be copied exactly by address increasing to make
+ * some data repeated.
+ */
+ lamecopy(s, s - off, len);
+ } else {
+ /* Buffer overflow; drop packet. */
+ rtn &= ~MPPC_OK;
+ return (rtn);
+ }
+ }
+
+ /* Do PFC decompression. */
+ len = olen;
+ if ((hist[0] & 0x01) != 0) {
+ (*dst)[0] = 0;
+ (*dst)++;
+ len++;
+ }
+
+ if (len <= *dstCnt) {
+ /* Copy uncompressed packet to the output buffer. */
+ memcpy(*dst, hist, olen);
+ } else {
+ /* Buffer overflow; drop packet. */
+ rtn |= MPPC_DEST_EXHAUSTED;
+ }
+
+ *src += *srcCnt;
+ *srcCnt = 0;
+ *dst += len;
+ *dstCnt -= len;
+
+ return (rtn);
+}
diff --git a/sys/net/pfil.c b/sys/net/pfil.c
index 90660e7..94a95ac 100644
--- a/sys/net/pfil.c
+++ b/sys/net/pfil.c
@@ -508,26 +508,24 @@ pfil_chain_remove(pfil_chain_t *chain, pfil_func_t func, void *arg)
* Stuff that must be initialized for every instance (including the first of
* course).
*/
-static int
-vnet_pfil_init(const void *unused)
+static void
+vnet_pfil_init(const void *unused __unused)
{
LIST_INIT(&V_pfil_head_list);
PFIL_LOCK_INIT_REAL(&V_pfil_lock, "shared");
- return (0);
}
/*
* Called for the removal of each instance.
*/
-static int
-vnet_pfil_uninit(const void *unused)
+static void
+vnet_pfil_uninit(const void *unused __unused)
{
KASSERT(LIST_EMPTY(&V_pfil_head_list),
("%s: pfil_head_list %p not empty", __func__, &V_pfil_head_list));
PFIL_LOCK_DESTROY_REAL(&V_pfil_lock);
- return (0);
}
/* Define startup order. */
diff --git a/sys/net/route.c b/sys/net/route.c
index 26e3b85..f2f8897 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1141,6 +1141,15 @@ rt_ifdelroute(const struct rtentry *rt, void *arg)
* to this interface...oh well...
*/
void
+rt_flushifroutes_af(struct ifnet *ifp, int af)
+{
+ KASSERT((af >= 1 && af <= AF_MAX), ("%s: af %d not >= 1 and <= %d",
+ __func__, af, AF_MAX));
+
+ rt_foreach_fib_walk_del(af, rt_ifdelroute, ifp);
+}
+
+void
rt_flushifroutes(struct ifnet *ifp)
{
diff --git a/sys/net/route.h b/sys/net/route.h
index 46e2ace..b6aa36d 100644
--- a/sys/net/route.h
+++ b/sys/net/route.h
@@ -468,6 +468,7 @@ typedef int rt_walktree_f_t(struct rtentry *, void *);
typedef void rt_setwarg_t(struct rib_head *, uint32_t, int, void *);
void rt_foreach_fib_walk(int af, rt_setwarg_t *, rt_walktree_f_t *, void *);
void rt_foreach_fib_walk_del(int af, rt_filter_f_t *filter_f, void *arg);
+void rt_flushifroutes_af(struct ifnet *, int);
void rt_flushifroutes(struct ifnet *ifp);
/* XXX MRT COMPAT VERSIONS THAT SET UNIVERSE to 0 */
diff --git a/sys/net80211/ieee80211_hostap.c b/sys/net80211/ieee80211_hostap.c
index 5b7611e..643a610 100644
--- a/sys/net80211/ieee80211_hostap.c
+++ b/sys/net80211/ieee80211_hostap.c
@@ -412,8 +412,8 @@ hostap_deliver_data(struct ieee80211vap *vap,
ieee80211_free_node(sta);
}
}
- if (mcopy != NULL && ieee80211_vap_xmitpkt(vap, mcopy) == 0)
- if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
+ if (mcopy != NULL)
+ (void) ieee80211_vap_xmitpkt(vap, mcopy);
}
if (m != NULL) {
/*
diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c
index 1f49237..5a6cce6 100644
--- a/sys/net80211/ieee80211_output.c
+++ b/sys/net80211/ieee80211_output.c
@@ -608,6 +608,8 @@ ieee80211_output(struct ifnet *ifp, struct mbuf *m,
if ((wh->i_fc[0] & IEEE80211_FC0_VERSION_MASK) !=
IEEE80211_FC0_VERSION_0)
senderr(EIO); /* XXX */
+ if (m->m_pkthdr.len < ieee80211_anyhdrsize(wh))
+ senderr(EIO); /* XXX */
/* locate destination node */
switch (wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) {
@@ -617,8 +619,6 @@ ieee80211_output(struct ifnet *ifp, struct mbuf *m,
break;
case IEEE80211_FC1_DIR_TODS:
case IEEE80211_FC1_DIR_DSTODS:
- if (m->m_pkthdr.len < sizeof(struct ieee80211_frame))
- senderr(EIO); /* XXX */
ni = ieee80211_find_txnode(vap, wh->i_addr3);
break;
default:
@@ -647,7 +647,6 @@ ieee80211_output(struct ifnet *ifp, struct mbuf *m,
if (ieee80211_classify(ni, m))
senderr(EIO); /* XXX */
- if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
IEEE80211_NODE_STAT(ni, tx_data);
if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
IEEE80211_NODE_STAT(ni, tx_mcast);
diff --git a/sys/netgraph/bluetooth/l2cap/ng_l2cap_misc.c b/sys/netgraph/bluetooth/l2cap/ng_l2cap_misc.c
index f80a7b0..3ec2fa3 100644
--- a/sys/netgraph/bluetooth/l2cap/ng_l2cap_misc.c
+++ b/sys/netgraph/bluetooth/l2cap/ng_l2cap_misc.c
@@ -346,7 +346,8 @@ ng_l2cap_new_chan(ng_l2cap_p l2cap, ng_l2cap_con_p con, u_int16_t psm, int idtyp
ch->scid = ng_l2cap_get_cid(l2cap,
(con->linktype!= NG_HCI_LINK_ACL));
}
-
+
+ ch->idtype = idtype;
if (ch->scid != NG_L2CAP_NULL_CID) {
/* Initialize channel */
ch->psm = psm;
diff --git a/sys/netgraph/bluetooth/l2cap/ng_l2cap_ulpi.c b/sys/netgraph/bluetooth/l2cap/ng_l2cap_ulpi.c
index 4b88bc8..2dc370f 100644
--- a/sys/netgraph/bluetooth/l2cap/ng_l2cap_ulpi.c
+++ b/sys/netgraph/bluetooth/l2cap/ng_l2cap_ulpi.c
@@ -1389,7 +1389,13 @@ ng_l2cap_l2ca_discon_ind(ng_l2cap_chan_p ch)
error = ENOMEM;
else {
ip = (ng_l2cap_l2ca_discon_ind_ip *)(msg->data);
- ip->lcid = ch->scid;
+ ip->idtype = ch->idtype;
+ if(ch->idtype == NG_L2CAP_L2CA_IDTYPE_ATT||
+ ch->idtype == NG_L2CAP_L2CA_IDTYPE_SMP)
+ ip->lcid = ch->con->con_handle;
+ else
+ ip->lcid = ch->scid;
+
NG_SEND_MSG_HOOK(error, l2cap->node, msg, l2cap->l2c, 0);
}
diff --git a/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c b/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
index 7653263..d787219 100644
--- a/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
+++ b/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
@@ -1115,7 +1115,7 @@ ng_btsocket_l2cap_process_l2ca_discon_ind(struct ng_mesg *msg,
/* Look for the socket with given channel ID */
pcb = ng_btsocket_l2cap_pcb_by_cid(&rt->src, ip->lcid,
- NG_L2CAP_L2CA_IDTYPE_BREDR);
+ ip->idtype);
if (pcb == NULL) {
mtx_unlock(&ng_btsocket_l2cap_sockets_mtx);
return (0);
diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c
index 90c00c62..1fc1812 100644
--- a/sys/netinet/igmp.c
+++ b/sys/netinet/igmp.c
@@ -50,6 +50,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "opt_ddb.h"
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/module.h>
@@ -64,6 +66,10 @@ __FBSDID("$FreeBSD$");
#include <sys/ktr.h>
#include <sys/condvar.h>
+#ifdef DDB
+#include <ddb/ddb.h>
+#endif
+
#include <net/if.h>
#include <net/if_var.h>
#include <net/netisr.h>
@@ -3641,6 +3647,37 @@ vnet_igmp_uninit(const void *unused __unused)
VNET_SYSUNINIT(vnet_igmp_uninit, SI_SUB_PSEUDO, SI_ORDER_ANY,
vnet_igmp_uninit, NULL);
+#ifdef DDB
+DB_SHOW_COMMAND(igi_list, db_show_igi_list)
+{
+ struct igmp_ifsoftc *igi, *tigi;
+ LIST_HEAD(_igi_list, igmp_ifsoftc) *igi_head;
+
+ if (!have_addr) {
+ db_printf("usage: show igi_list <addr>\n");
+ return;
+ }
+ igi_head = (struct _igi_list *)addr;
+
+ LIST_FOREACH_SAFE(igi, igi_head, igi_link, tigi) {
+ db_printf("igmp_ifsoftc %p:\n", igi);
+ db_printf(" ifp %p\n", igi->igi_ifp);
+ db_printf(" version %u\n", igi->igi_version);
+ db_printf(" v1_timer %u\n", igi->igi_v1_timer);
+ db_printf(" v2_timer %u\n", igi->igi_v2_timer);
+ db_printf(" v3_timer %u\n", igi->igi_v3_timer);
+ db_printf(" flags %#x\n", igi->igi_flags);
+ db_printf(" rv %u\n", igi->igi_rv);
+ db_printf(" qi %u\n", igi->igi_qi);
+ db_printf(" qri %u\n", igi->igi_qri);
+ db_printf(" uri %u\n", igi->igi_uri);
+ /* SLIST_HEAD(,in_multi) igi_relinmhead */
+ /* struct mbufq igi_gq; */
+ db_printf("\n");
+ }
+}
+#endif
+
static int
igmp_modevent(module_t mod, int type, void *unused __unused)
{
diff --git a/sys/netinet/ip_fastfwd.c b/sys/netinet/ip_fastfwd.c
index 3fc7c74..ea59c10 100644
--- a/sys/netinet/ip_fastfwd.c
+++ b/sys/netinet/ip_fastfwd.c
@@ -76,7 +76,6 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "opt_ipfw.h"
#include "opt_ipstealth.h"
#include <sys/param.h>
diff --git a/sys/netinet/ip_id.c b/sys/netinet/ip_id.c
index b0efbee..de4ae75 100644
--- a/sys/netinet/ip_id.c
+++ b/sys/netinet/ip_id.c
@@ -287,11 +287,11 @@ static void
ipid_sysuninit(void)
{
- mtx_destroy(&V_ip_id_mtx);
if (V_id_array != NULL) {
free(V_id_array, M_IPID);
free(V_id_bits, M_IPID);
}
counter_u64_free(V_ip_id);
+ mtx_destroy(&V_ip_id_mtx);
}
VNET_SYSUNINIT(ip_id, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY, ipid_sysuninit, NULL);
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 36b51bd..dbf9ba6 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -33,7 +33,6 @@
__FBSDID("$FreeBSD$");
#include "opt_bootp.h"
-#include "opt_ipfw.h"
#include "opt_ipstealth.h"
#include "opt_ipsec.h"
#include "opt_route.h"
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index 9fdd59d..b5d4951 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -33,7 +33,6 @@
__FBSDID("$FreeBSD$");
#include "opt_inet.h"
-#include "opt_ipfw.h"
#include "opt_ipsec.h"
#include "opt_mbuf_stress_test.h"
#include "opt_mpath.h"
diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c
index 1fff331..c07019c 100644
--- a/sys/netinet/sctp_input.c
+++ b/sys/netinet/sctp_input.c
@@ -1969,7 +1969,8 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset,
asoc->strmout[i].abandoned_unsent[0] = 0;
#endif
stcb->asoc.strmout[i].stream_no = i;
- stcb->asoc.strmout[i].next_sequence_send = 0;
+ stcb->asoc.strmout[i].next_mid_ordered = 0;
+ stcb->asoc.strmout[i].next_mid_unordered = 0;
stcb->asoc.strmout[i].last_msg_incomplete = 0;
}
/* process the INIT-ACK info (my info) */
@@ -3521,11 +3522,13 @@ sctp_reset_out_streams(struct sctp_tcb *stcb, uint32_t number_entries, uint16_t
/* no such stream */
continue;
}
- stcb->asoc.strmout[temp].next_sequence_send = 0;
+ stcb->asoc.strmout[temp].next_mid_ordered = 0;
+ stcb->asoc.strmout[temp].next_mid_unordered = 0;
}
} else {
for (i = 0; i < stcb->asoc.streamoutcnt; i++) {
- stcb->asoc.strmout[i].next_sequence_send = 0;
+ stcb->asoc.strmout[i].next_mid_ordered = 0;
+ stcb->asoc.strmout[i].next_mid_unordered = 0;
}
}
sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_SEND, stcb, number_entries, (void *)list, SCTP_SO_NOT_LOCKED);
@@ -6236,7 +6239,7 @@ sctp_input(struct mbuf **mp, int *offp, int proto SCTP_UNUSED)
tag = htonl(sh->v_tag);
flowid = tag ^ ntohs(sh->dest_port) ^ ntohs(sh->src_port);
m->m_pkthdr.flowid = flowid;
- M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE);
+ M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE_HASH);
}
cpu_to_use = sctp_cpuarry[flowid % mp_ncpus];
sctp_queue_to_mcore(m, off, cpu_to_use);
diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c
index 6d71f7d..3544d69 100644
--- a/sys/netinet/sctp_output.c
+++ b/sys/netinet/sctp_output.c
@@ -3643,7 +3643,8 @@ sctp_process_cmsgs_for_init(struct sctp_tcb *stcb, struct mbuf *control, int *er
for (i = 0; i < stcb->asoc.streamoutcnt; i++) {
TAILQ_INIT(&stcb->asoc.strmout[i].outqueue);
stcb->asoc.strmout[i].chunks_on_queues = 0;
- stcb->asoc.strmout[i].next_sequence_send = 0;
+ stcb->asoc.strmout[i].next_mid_ordered = 0;
+ stcb->asoc.strmout[i].next_mid_unordered = 0;
#if defined(SCTP_DETAILED_STR_STATS)
for (j = 0; j < SCTP_PR_SCTP_MAX + 1; j++) {
stcb->asoc.strmout[i].abandoned_sent[j] = 0;
@@ -6381,7 +6382,6 @@ sctp_msg_append(struct sctp_tcb *stcb,
sp->ppid = srcv->sinfo_ppid;
sp->context = srcv->sinfo_context;
sp->fsn = 0;
- sp->msg_id = atomic_fetchadd_int(&stcb->asoc.assoc_msg_id, 1);
if (sp->sinfo_flags & SCTP_ADDR_OVER) {
sp->net = net;
atomic_add_int(&sp->net->ref_count, 1);
@@ -7568,10 +7568,28 @@ dont_do_it:
chk->asoc = &stcb->asoc;
chk->pad_inplace = 0;
chk->no_fr_allowed = 0;
- chk->rec.data.stream_seq = strq->next_sequence_send;
- if ((rcv_flags & SCTP_DATA_LAST_FRAG) &&
- !(rcv_flags & SCTP_DATA_UNORDERED)) {
- strq->next_sequence_send++;
+ if (stcb->asoc.idata_supported == 0) {
+ if (rcv_flags & SCTP_DATA_UNORDERED) {
+ /* Just use 0. The receiver ignores the values. */
+ chk->rec.data.stream_seq = 0;
+ } else {
+ chk->rec.data.stream_seq = strq->next_mid_ordered;
+ if (rcv_flags & SCTP_DATA_LAST_FRAG) {
+ strq->next_mid_ordered++;
+ }
+ }
+ } else {
+ if (rcv_flags & SCTP_DATA_UNORDERED) {
+ chk->rec.data.stream_seq = strq->next_mid_unordered;
+ if (rcv_flags & SCTP_DATA_LAST_FRAG) {
+ strq->next_mid_unordered++;
+ }
+ } else {
+ chk->rec.data.stream_seq = strq->next_mid_ordered;
+ if (rcv_flags & SCTP_DATA_LAST_FRAG) {
+ strq->next_mid_ordered++;
+ }
+ }
}
chk->rec.data.stream_number = sp->stream;
chk->rec.data.payloadtype = sp->ppid;
@@ -7630,7 +7648,7 @@ dont_do_it:
dchkh->ch.chunk_flags = chk->rec.data.rcv_flags;
dchkh->dp.tsn = htonl(chk->rec.data.TSN_seq);
dchkh->dp.stream_id = htons((strq->stream_no & 0x0000ffff));
- dchkh->dp.stream_sequence = htons(chk->rec.data.stream_seq);
+ dchkh->dp.stream_sequence = htons((uint16_t) chk->rec.data.stream_seq);
dchkh->dp.protocol_id = chk->rec.data.payloadtype;
dchkh->ch.chunk_length = htons(chk->send_size);
} else {
@@ -7638,9 +7656,8 @@ dont_do_it:
ndchkh->ch.chunk_flags = chk->rec.data.rcv_flags;
ndchkh->dp.tsn = htonl(chk->rec.data.TSN_seq);
ndchkh->dp.stream_id = htons(strq->stream_no);
- /* WHAT DO WE DO HERE??? */
ndchkh->dp.reserved = htons(0);
- ndchkh->dp.msg_id = htonl(sp->msg_id);
+ ndchkh->dp.msg_id = htonl(chk->rec.data.stream_seq);
if (sp->fsn == 0)
ndchkh->dp.ppid_fsn.protocol_id = chk->rec.data.payloadtype;
else
@@ -12235,7 +12252,8 @@ sctp_send_str_reset_req(struct sctp_tcb *stcb,
for (i = 0; i < stcb->asoc.streamoutcnt; i++) {
TAILQ_INIT(&stcb->asoc.strmout[i].outqueue);
stcb->asoc.strmout[i].chunks_on_queues = oldstream[i].chunks_on_queues;
- stcb->asoc.strmout[i].next_sequence_send = oldstream[i].next_sequence_send;
+ stcb->asoc.strmout[i].next_mid_ordered = oldstream[i].next_mid_ordered;
+ stcb->asoc.strmout[i].next_mid_unordered = oldstream[i].next_mid_unordered;
stcb->asoc.strmout[i].last_msg_incomplete = oldstream[i].last_msg_incomplete;
stcb->asoc.strmout[i].stream_no = i;
stcb->asoc.strmout[i].state = oldstream[i].state;
@@ -12267,7 +12285,8 @@ sctp_send_str_reset_req(struct sctp_tcb *stcb,
stcb->asoc.strmout[i].abandoned_sent[0] = 0;
stcb->asoc.strmout[i].abandoned_unsent[0] = 0;
#endif
- stcb->asoc.strmout[i].next_sequence_send = 0x0;
+ stcb->asoc.strmout[i].next_mid_ordered = 0;
+ stcb->asoc.strmout[i].next_mid_unordered = 0;
stcb->asoc.strmout[i].stream_no = i;
stcb->asoc.strmout[i].last_msg_incomplete = 0;
stcb->asoc.ss_functions.sctp_ss_init_stream(&stcb->asoc.strmout[i], NULL);
@@ -12425,7 +12444,6 @@ sctp_copy_it_in(struct sctp_tcb *stcb,
sp->ppid = srcv->sinfo_ppid;
sp->context = srcv->sinfo_context;
sp->fsn = 0;
- sp->msg_id = atomic_fetchadd_int(&stcb->asoc.assoc_msg_id, 1);
(void)SCTP_GETTIME_TIMEVAL(&sp->ts);
sp->stream = srcv->sinfo_stream;
diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c
index 704e5d9..36e4c01 100644
--- a/sys/netinet/sctp_pcb.c
+++ b/sys/netinet/sctp_pcb.c
@@ -4070,7 +4070,7 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr,
net->flowid = stcb->asoc.my_vtag ^
ntohs(stcb->rport) ^
ntohs(stcb->sctp_ep->sctp_lport);
- net->flowtype = M_HASHTYPE_OPAQUE;
+ net->flowtype = M_HASHTYPE_OPAQUE_HASH;
if (netp) {
*netp = net;
}
diff --git a/sys/netinet/sctp_structs.h b/sys/netinet/sctp_structs.h
index c64d2b6..ad9d978 100644
--- a/sys/netinet/sctp_structs.h
+++ b/sys/netinet/sctp_structs.h
@@ -522,7 +522,6 @@ struct sctp_stream_queue_pending {
TAILQ_ENTRY(sctp_stream_queue_pending) next;
TAILQ_ENTRY(sctp_stream_queue_pending) ss_next;
uint32_t fsn;
- uint32_t msg_id;
uint32_t length;
uint32_t timetolive;
uint32_t ppid;
@@ -619,7 +618,12 @@ struct sctp_stream_out {
uint32_t abandoned_unsent[1];
uint32_t abandoned_sent[1];
#endif
- uint32_t next_sequence_send; /* next one I expect to send out */
+ /*
+ * For associations using DATA chunks, the lower 16-bit of
+ * next_mid_ordered are used as the next SSN.
+ */
+ uint32_t next_mid_ordered;
+ uint32_t next_mid_unordered;
uint16_t stream_no;
uint8_t last_msg_incomplete;
uint8_t state;
@@ -893,7 +897,6 @@ struct sctp_association {
uint32_t stream_scheduling_module;
uint32_t vrf_id;
- uint32_t assoc_msg_id;
uint32_t cookie_preserve_req;
/* ASCONF next seq I am sending out, inits at init-tsn */
uint32_t asconf_seq_out;
diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c
index cc18d9f..3f6ec55 100644
--- a/sys/netinet/sctputil.c
+++ b/sys/netinet/sctputil.c
@@ -1123,7 +1123,8 @@ sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* that were dropped must be notified to the upper layer as
* failed to send.
*/
- asoc->strmout[i].next_sequence_send = 0x0;
+ asoc->strmout[i].next_mid_ordered = 0;
+ asoc->strmout[i].next_mid_unordered = 0;
TAILQ_INIT(&asoc->strmout[i].outqueue);
asoc->strmout[i].chunks_on_queues = 0;
#if defined(SCTP_DETAILED_STR_STATS)
@@ -4836,10 +4837,22 @@ sctp_release_pr_sctp_chunk(struct sctp_tcb *stcb, struct sctp_tmit_chunk *tp1,
goto oh_well;
}
memset(chk, 0, sizeof(*chk));
- chk->rec.data.rcv_flags = SCTP_DATA_LAST_FRAG;
+ chk->rec.data.rcv_flags = 0;
chk->sent = SCTP_FORWARD_TSN_SKIP;
chk->asoc = &stcb->asoc;
- chk->rec.data.stream_seq = strq->next_sequence_send;
+ if (stcb->asoc.idata_supported == 0) {
+ if (sp->sinfo_flags & SCTP_UNORDERED) {
+ chk->rec.data.stream_seq = 0;
+ } else {
+ chk->rec.data.stream_seq = strq->next_mid_ordered;
+ }
+ } else {
+ if (sp->sinfo_flags & SCTP_UNORDERED) {
+ chk->rec.data.stream_seq = strq->next_mid_unordered;
+ } else {
+ chk->rec.data.stream_seq = strq->next_mid_ordered;
+ }
+ }
chk->rec.data.stream_number = sp->stream;
chk->rec.data.payloadtype = sp->ppid;
chk->rec.data.context = sp->context;
@@ -4850,10 +4863,19 @@ sctp_release_pr_sctp_chunk(struct sctp_tcb *stcb, struct sctp_tmit_chunk *tp1,
TAILQ_INSERT_TAIL(&stcb->asoc.sent_queue, chk, sctp_next);
stcb->asoc.sent_queue_cnt++;
stcb->asoc.pr_sctp_cnt++;
+ }
+ chk->rec.data.rcv_flags |= SCTP_DATA_LAST_FRAG;
+ if (stcb->asoc.idata_supported == 0) {
+ if ((sp->sinfo_flags & SCTP_UNORDERED) == 0) {
+ strq->next_mid_ordered++;
+ }
} else {
- chk->rec.data.rcv_flags |= SCTP_DATA_LAST_FRAG;
+ if (sp->sinfo_flags & SCTP_UNORDERED) {
+ strq->next_mid_unordered++;
+ } else {
+ strq->next_mid_ordered++;
+ }
}
- strq->next_sequence_send++;
oh_well:
if (sp->data) {
/*
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index c106996..c72f01f 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -50,7 +50,6 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "opt_ipfw.h" /* for ipfw_fwd */
#include "opt_inet.h"
#include "opt_inet6.h"
#include "opt_ipsec.h"
diff --git a/sys/netinet/tcp_stacks/fastpath.c b/sys/netinet/tcp_stacks/fastpath.c
index 7d573c5..7be9f96 100644
--- a/sys/netinet/tcp_stacks/fastpath.c
+++ b/sys/netinet/tcp_stacks/fastpath.c
@@ -54,7 +54,6 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "opt_ipfw.h" /* for ipfw_fwd */
#include "opt_inet.h"
#include "opt_inet6.h"
#include "opt_ipsec.h"
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index a1d9a43..173c44c 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -39,7 +39,6 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "opt_ipfw.h"
#include "opt_inet.h"
#include "opt_inet6.h"
#include "opt_ipsec.h"
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index d571dbd..e972ac7 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -360,7 +360,6 @@ in6_control(struct socket *so, u_long cmd, caddr_t data,
case SIOCSPFXFLUSH_IN6:
case SIOCSRTRFLUSH_IN6:
case SIOCGIFALIFETIME_IN6:
- case SIOCSIFALIFETIME_IN6:
case SIOCGIFSTAT_IN6:
case SIOCGIFSTAT_ICMP6:
sa6 = &ifr->ifr_addr;
@@ -459,34 +458,6 @@ in6_control(struct socket *so, u_long cmd, caddr_t data,
goto out;
}
break;
-
- case SIOCSIFALIFETIME_IN6:
- {
- struct in6_addrlifetime *lt;
-
- if (td != NULL) {
- error = priv_check(td, PRIV_NETINET_ALIFETIME6);
- if (error)
- goto out;
- }
- if (ia == NULL) {
- error = EADDRNOTAVAIL;
- goto out;
- }
- /* sanity for overflow - beware unsigned */
- lt = &ifr->ifr_ifru.ifru_lifetime;
- if (lt->ia6t_vltime != ND6_INFINITE_LIFETIME &&
- lt->ia6t_vltime + time_uptime < time_uptime) {
- error = EINVAL;
- goto out;
- }
- if (lt->ia6t_pltime != ND6_INFINITE_LIFETIME &&
- lt->ia6t_pltime + time_uptime < time_uptime) {
- error = EINVAL;
- goto out;
- }
- break;
- }
}
switch (cmd) {
@@ -572,21 +543,6 @@ in6_control(struct socket *so, u_long cmd, caddr_t data,
}
break;
- case SIOCSIFALIFETIME_IN6:
- ia->ia6_lifetime = ifr->ifr_ifru.ifru_lifetime;
- /* for sanity */
- if (ia->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) {
- ia->ia6_lifetime.ia6t_expire =
- time_uptime + ia->ia6_lifetime.ia6t_vltime;
- } else
- ia->ia6_lifetime.ia6t_expire = 0;
- if (ia->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME) {
- ia->ia6_lifetime.ia6t_preferred =
- time_uptime + ia->ia6_lifetime.ia6t_pltime;
- } else
- ia->ia6_lifetime.ia6t_preferred = 0;
- break;
-
case SIOCAIFADDR_IN6:
{
struct nd_prefixctl pr0;
diff --git a/sys/netinet6/in6_var.h b/sys/netinet6/in6_var.h
index 007fd66..77e5920 100644
--- a/sys/netinet6/in6_var.h
+++ b/sys/netinet6/in6_var.h
@@ -453,7 +453,6 @@ struct in6_rrenumreq {
#define SIOCSRTRFLUSH_IN6 _IOWR('i', 80, struct in6_ifreq)
#define SIOCGIFALIFETIME_IN6 _IOWR('i', 81, struct in6_ifreq)
-#define SIOCSIFALIFETIME_IN6 _IOWR('i', 82, struct in6_ifreq)
#define SIOCGIFSTAT_IN6 _IOWR('i', 83, struct in6_ifreq)
#define SIOCGIFSTAT_ICMP6 _IOWR('i', 84, struct in6_ifreq)
diff --git a/sys/netinet6/ip6_forward.c b/sys/netinet6/ip6_forward.c
index 3b3058b..002c761 100644
--- a/sys/netinet6/ip6_forward.c
+++ b/sys/netinet6/ip6_forward.c
@@ -34,7 +34,6 @@ __FBSDID("$FreeBSD$");
#include "opt_inet.h"
#include "opt_inet6.h"
-#include "opt_ipfw.h"
#include "opt_ipsec.h"
#include "opt_ipstealth.h"
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index 1903857..9802c49 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$");
#include "opt_inet.h"
#include "opt_inet6.h"
-#include "opt_ipfw.h"
#include "opt_ipsec.h"
#include "opt_route.h"
#include "opt_rss.h"
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index fde6710..c03bf5e 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$");
#include "opt_inet.h"
#include "opt_inet6.h"
-#include "opt_ipfw.h"
#include "opt_ipsec.h"
#include "opt_sctp.h"
#include "opt_route.h"
diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c
index a2f2d7e..dcae9f8 100644
--- a/sys/netinet6/mld6.c
+++ b/sys/netinet6/mld6.c
@@ -300,7 +300,8 @@ mld_restore_context(struct mbuf *m)
#if defined(VIMAGE) && defined(INVARIANTS)
KASSERT(curvnet == m->m_pkthdr.PH_loc.ptr,
- ("%s: called when curvnet was not restored", __func__));
+ ("%s: called when curvnet was not restored: cuvnet %p m ptr %p",
+ __func__, curvnet, m->m_pkthdr.PH_loc.ptr));
#endif
return (m->m_pkthdr.flowid);
}
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index 0585cd7..a75d588 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -896,9 +896,6 @@ nd6_timer(void *arg)
struct nd_prefix *pr, *npr;
struct in6_ifaddr *ia6, *nia6;
- callout_reset(&V_nd6_timer_ch, V_nd6_prune * hz,
- nd6_timer, curvnet);
-
TAILQ_INIT(&drq);
/* expire default router list */
@@ -1025,6 +1022,10 @@ nd6_timer(void *arg)
prelist_remove(pr);
}
}
+
+ callout_reset(&V_nd6_timer_ch, V_nd6_prune * hz,
+ nd6_timer, curvnet);
+
CURVNET_RESTORE();
}
diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c
index 347eb56..b44fb9e 100644
--- a/sys/netinet6/udp6_usrreq.c
+++ b/sys/netinet6/udp6_usrreq.c
@@ -72,7 +72,6 @@ __FBSDID("$FreeBSD$");
#include "opt_inet.h"
#include "opt_inet6.h"
-#include "opt_ipfw.h"
#include "opt_ipsec.h"
#include "opt_rss.h"
diff --git a/sys/ofed/drivers/net/mlx4/en_rx.c b/sys/ofed/drivers/net/mlx4/en_rx.c
index f4425af..2711b22 100644
--- a/sys/ofed/drivers/net/mlx4/en_rx.c
+++ b/sys/ofed/drivers/net/mlx4/en_rx.c
@@ -619,7 +619,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
/* forward Toeplitz compatible hash value */
mb->m_pkthdr.flowid = be32_to_cpu(cqe->immed_rss_invalid);
- M_HASHTYPE_SET(mb, M_HASHTYPE_OPAQUE);
+ M_HASHTYPE_SET(mb, M_HASHTYPE_OPAQUE_HASH);
mb->m_pkthdr.rcvif = dev;
if (be32_to_cpu(cqe->vlan_my_qpn) &
MLX4_CQE_VLAN_PRESENT_MASK) {
diff --git a/sys/riscv/include/riscvreg.h b/sys/riscv/include/riscvreg.h
index 6984ab1..b18df17 100644
--- a/sys/riscv/include/riscvreg.h
+++ b/sys/riscv/include/riscvreg.h
@@ -124,7 +124,6 @@
#define XLEN 8
#define INSN_SIZE 4
-#define INSN_SIZE 4
#define RISCV_INSN_NOP 0x00000013
#define RISCV_INSN_BREAK 0x00100073
#define RISCV_INSN_RET 0x00008067
diff --git a/sys/rpc/clnt_bck.c b/sys/rpc/clnt_bck.c
index f1c8dde..66f3c30 100644
--- a/sys/rpc/clnt_bck.c
+++ b/sys/rpc/clnt_bck.c
@@ -175,14 +175,9 @@ clnt_bck_create(
return (cl);
err:
- if (cl) {
- if (ct) {
- mtx_destroy(&ct->ct_lock);
- mem_free(ct, sizeof (struct ct_data));
- }
- if (cl)
- mem_free(cl, sizeof (CLIENT));
- }
+ mtx_destroy(&ct->ct_lock);
+ mem_free(ct, sizeof (struct ct_data));
+ mem_free(cl, sizeof (CLIENT));
return (NULL);
}
diff --git a/sys/rpc/rpcb_clnt.c b/sys/rpc/rpcb_clnt.c
index a68793e..f3781f6 100644
--- a/sys/rpc/rpcb_clnt.c
+++ b/sys/rpc/rpcb_clnt.c
@@ -1051,7 +1051,7 @@ done:
*
* Assuming that the address is all properly allocated
*/
-int
+bool_t
rpcb_getaddr(program, version, nconf, address, host)
rpcprog_t program;
rpcvers_t version;
diff --git a/sys/security/audit/audit_bsm.c b/sys/security/audit/audit_bsm.c
index 9f29ece..fed111a 100644
--- a/sys/security/audit/audit_bsm.c
+++ b/sys/security/audit/audit_bsm.c
@@ -952,6 +952,8 @@ kaudit_to_bsm(struct kaudit_record *kar, struct au_record **pau)
case AUE_GETDIRENTRIESATTR:
case AUE_LSEEK:
case AUE_POLL:
+ case AUE_PREAD:
+ case AUE_PWRITE:
case AUE_READ:
case AUE_READV:
case AUE_WRITE:
diff --git a/sys/sys/intr.h b/sys/sys/intr.h
index e513517..394aa5c 100644
--- a/sys/sys/intr.h
+++ b/sys/sys/intr.h
@@ -34,22 +34,6 @@
#define INTR_IRQ_INVALID 0xFFFFFFFF
-#ifdef DEV_ACPI
-struct intr_map_data_acpi {
- struct intr_map_data hdr;
- u_int irq;
- enum intr_polarity pol;
- enum intr_trigger trig;
-};
-#endif
-
-struct intr_map_data_gpio {
- struct intr_map_data hdr;
- u_int gpio_pin_num;
- u_int gpio_pin_flags;
- u_int gpio_intr_mode;
-};
-
#ifdef notyet
#define INTR_SOLO INTR_MD1
typedef int intr_irq_filter_t(void *arg, struct trapframe *tf);
@@ -124,14 +108,6 @@ int intr_map_msi(device_t, device_t, intptr_t, int, uint64_t *, uint32_t *);
int intr_alloc_msix(device_t, device_t, intptr_t, int *);
int intr_release_msix(device_t, device_t, intptr_t, int);
-#ifdef DEV_ACPI
-u_int intr_acpi_map_irq(device_t, u_int, enum intr_polarity,
- enum intr_trigger);
-#endif
-
-u_int intr_gpio_map_irq(device_t dev, u_int pin_num, u_int pin_flags,
- u_int intr_mode);
-
#ifdef SMP
int intr_bind_irq(device_t, struct resource *, int);
diff --git a/sys/sys/param.h b/sys/sys/param.h
index d7fa2c7..b095aa7 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -58,7 +58,7 @@
* in the range 5 to 9.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 1100116 /* Master, propagated to newvers */
+#define __FreeBSD_version 1100117 /* Master, propagated to newvers */
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
diff --git a/sys/sys/procdesc.h b/sys/sys/procdesc.h
index 1a3bc98..a9bad27 100644
--- a/sys/sys/procdesc.h
+++ b/sys/sys/procdesc.h
@@ -101,6 +101,9 @@ void procdesc_finit(struct procdesc *, struct file *);
pid_t procdesc_pid(struct file *);
void procdesc_reap(struct proc *);
+int procdesc_falloc(struct thread *, struct file **, int *, int,
+ struct filecaps *);
+
#else /* !_KERNEL */
#include <sys/_types.h>
@@ -127,5 +130,8 @@ __END_DECLS
* Flags which can be passed to pdfork(2).
*/
#define PD_DAEMON 0x00000001 /* Don't exit when procdesc closes. */
+#define PD_CLOEXEC 0x00000002 /* Close file descriptor on exec. */
+
+#define PD_ALLOWED_AT_FORK (PD_DAEMON | PD_CLOEXEC)
#endif /* !_SYS_PROCDESC_H_ */
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c
index 6ab965b..37d8fd1 100644
--- a/sys/vm/swap_pager.c
+++ b/sys/vm/swap_pager.c
@@ -345,7 +345,6 @@ static struct sx sw_alloc_sx;
#define NOBJLIST(handle) \
(&swap_pager_object_list[((int)(intptr_t)handle >> 4) & (NOBJLISTS-1)])
-static struct mtx sw_alloc_mtx; /* protect list manipulation */
static struct pagerlst swap_pager_object_list[NOBJLISTS];
static uma_zone_t swap_zone;
@@ -486,8 +485,8 @@ swap_pager_init(void)
for (i = 0; i < NOBJLISTS; ++i)
TAILQ_INIT(&swap_pager_object_list[i]);
- mtx_init(&sw_alloc_mtx, "swap_pager list", NULL, MTX_DEF);
mtx_init(&sw_dev_mtx, "swapdev", NULL, MTX_DEF);
+ sx_init(&sw_alloc_sx, "swspsx");
sx_init(&swdev_syscall_lock, "swsysc");
/*
@@ -582,28 +581,46 @@ swap_pager_swap_init(void)
mtx_init(&swhash_mtx, "swap_pager swhash", NULL, MTX_DEF);
}
+static vm_object_t
+swap_pager_alloc_init(void *handle, struct ucred *cred, vm_ooffset_t size,
+ vm_ooffset_t offset)
+{
+ vm_object_t object;
+
+ if (cred != NULL) {
+ if (!swap_reserve_by_cred(size, cred))
+ return (NULL);
+ crhold(cred);
+ }
+ object = vm_object_allocate(OBJT_SWAP, OFF_TO_IDX(offset +
+ PAGE_MASK + size));
+ object->handle = handle;
+ if (cred != NULL) {
+ object->cred = cred;
+ object->charge = size;
+ }
+ object->un_pager.swp.swp_bcount = 0;
+ return (object);
+}
+
/*
* SWAP_PAGER_ALLOC() - allocate a new OBJT_SWAP VM object and instantiate
* its metadata structures.
*
* This routine is called from the mmap and fork code to create a new
- * OBJT_SWAP object. We do this by creating an OBJT_DEFAULT object
- * and then converting it with swp_pager_meta_build().
- *
- * This routine may block in vm_object_allocate() and create a named
- * object lookup race, so we must interlock.
+ * OBJT_SWAP object.
*
- * MPSAFE
+ * This routine must ensure that no live duplicate is created for
+ * the named object request, which is protected against by
+ * holding the sw_alloc_sx lock in case handle != NULL.
*/
static vm_object_t
swap_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot,
vm_ooffset_t offset, struct ucred *cred)
{
vm_object_t object;
- vm_pindex_t pindex;
- pindex = OFF_TO_IDX(offset + PAGE_MASK + size);
- if (handle) {
+ if (handle != NULL) {
/*
* Reference existing named region or allocate new one. There
* should not be a race here against swp_pager_meta_build()
@@ -613,38 +630,16 @@ swap_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot,
sx_xlock(&sw_alloc_sx);
object = vm_pager_object_lookup(NOBJLIST(handle), handle);
if (object == NULL) {
- if (cred != NULL) {
- if (!swap_reserve_by_cred(size, cred)) {
- sx_xunlock(&sw_alloc_sx);
- return (NULL);
- }
- crhold(cred);
- }
- object = vm_object_allocate(OBJT_DEFAULT, pindex);
- VM_OBJECT_WLOCK(object);
- object->handle = handle;
- if (cred != NULL) {
- object->cred = cred;
- object->charge = size;
+ object = swap_pager_alloc_init(handle, cred, size,
+ offset);
+ if (object != NULL) {
+ TAILQ_INSERT_TAIL(NOBJLIST(object->handle),
+ object, pager_object_list);
}
- swp_pager_meta_build(object, 0, SWAPBLK_NONE);
- VM_OBJECT_WUNLOCK(object);
}
sx_xunlock(&sw_alloc_sx);
} else {
- if (cred != NULL) {
- if (!swap_reserve_by_cred(size, cred))
- return (NULL);
- crhold(cred);
- }
- object = vm_object_allocate(OBJT_DEFAULT, pindex);
- VM_OBJECT_WLOCK(object);
- if (cred != NULL) {
- object->cred = cred;
- object->charge = size;
- }
- swp_pager_meta_build(object, 0, SWAPBLK_NONE);
- VM_OBJECT_WUNLOCK(object);
+ object = swap_pager_alloc_init(handle, cred, size, offset);
}
return (object);
}
@@ -663,17 +658,22 @@ static void
swap_pager_dealloc(vm_object_t object)
{
+ VM_OBJECT_ASSERT_WLOCKED(object);
+ KASSERT((object->flags & OBJ_DEAD) != 0, ("dealloc of reachable obj"));
+
/*
* Remove from list right away so lookups will fail if we block for
* pageout completion.
*/
if (object->handle != NULL) {
- mtx_lock(&sw_alloc_mtx);
- TAILQ_REMOVE(NOBJLIST(object->handle), object, pager_object_list);
- mtx_unlock(&sw_alloc_mtx);
+ VM_OBJECT_WUNLOCK(object);
+ sx_xlock(&sw_alloc_sx);
+ TAILQ_REMOVE(NOBJLIST(object->handle), object,
+ pager_object_list);
+ sx_xunlock(&sw_alloc_sx);
+ VM_OBJECT_WLOCK(object);
}
- VM_OBJECT_ASSERT_WLOCKED(object);
vm_object_pip_wait(object, "swpdea");
/*
@@ -900,16 +900,19 @@ swap_pager_copy(vm_object_t srcobject, vm_object_t dstobject,
* If destroysource is set, we remove the source object from the
* swap_pager internal queue now.
*/
- if (destroysource) {
- if (srcobject->handle != NULL) {
- mtx_lock(&sw_alloc_mtx);
- TAILQ_REMOVE(
- NOBJLIST(srcobject->handle),
- srcobject,
- pager_object_list
- );
- mtx_unlock(&sw_alloc_mtx);
- }
+ if (destroysource && srcobject->handle != NULL) {
+ vm_object_pip_add(srcobject, 1);
+ VM_OBJECT_WUNLOCK(srcobject);
+ vm_object_pip_add(dstobject, 1);
+ VM_OBJECT_WUNLOCK(dstobject);
+ sx_xlock(&sw_alloc_sx);
+ TAILQ_REMOVE(NOBJLIST(srcobject->handle), srcobject,
+ pager_object_list);
+ sx_xunlock(&sw_alloc_sx);
+ VM_OBJECT_WLOCK(dstobject);
+ vm_object_pip_wakeup(dstobject);
+ VM_OBJECT_WLOCK(srcobject);
+ vm_object_pip_wakeup(srcobject);
}
/*
@@ -1745,16 +1748,7 @@ swp_pager_meta_build(vm_object_t object, vm_pindex_t pindex, daddr_t swapblk)
if (object->type != OBJT_SWAP) {
object->type = OBJT_SWAP;
object->un_pager.swp.swp_bcount = 0;
-
- if (object->handle != NULL) {
- mtx_lock(&sw_alloc_mtx);
- TAILQ_INSERT_TAIL(
- NOBJLIST(object->handle),
- object,
- pager_object_list
- );
- mtx_unlock(&sw_alloc_mtx);
- }
+ KASSERT(object->handle == NULL, ("default pager with handle"));
}
/*
diff --git a/sys/xen/xen-os.h b/sys/xen/xen-os.h
index 0aa3bb50..96e084f 100644
--- a/sys/xen/xen-os.h
+++ b/sys/xen/xen-os.h
@@ -118,7 +118,7 @@ xen_clear_bit(int bit, volatile long *addr)
atomic_clear_long(&addr[bit / NBPL], 1UL << (bit % NBPL));
}
-#undef NPBL
+#undef NBPL
/*
* Functions to allocate/free unused memory in order
diff --git a/tools/build/Makefile b/tools/build/Makefile
index 2617d8d..63b147c 100644
--- a/tools/build/Makefile
+++ b/tools/build/Makefile
@@ -4,9 +4,11 @@
LIB= egacy
SRC=
-INCSGROUPS= INCS
+INCSGROUPS= INCS SYSINCS
INCS=
+SYSINCSDIR= ${INCLUDEDIR}/sys
+
BOOTSTRAPPING?= 0
_WITH_PWCACHEDB!= grep -c pwcache_groupdb /usr/include/grp.h || true
@@ -33,6 +35,12 @@ SRCS+= reallocarray.c
CFLAGS+= -I${.CURDIR}/../../lib/libc/include
.endif
+_WITH_UTIMENS!= grep -c utimensat /usr/include/sys/stat.h || true
+.if ${_WITH_UTIMENS} == 0
+SYSINCS+= stat.h
+SRCS+= futimens.c utimensat.c
+.endif
+
.if empty(SRCS)
SRCS= dummy.c
.endif
diff --git a/tools/build/futimens.c b/tools/build/futimens.c
new file mode 100644
index 0000000..7d1cae7
--- /dev/null
+++ b/tools/build/futimens.c
@@ -0,0 +1,96 @@
+/*-
+ * Copyright (c) 2015 Jilles Tjoelker
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/stat.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <time.h>
+
+#ifndef UTIME_NOW
+#define UTIME_NOW -1
+#define UTIME_OMIT -2
+#endif
+
+int
+futimens(int fd, const struct timespec times[2])
+{
+ struct timeval now, tv[2], *tvp;
+ struct stat sb;
+ int osreldate;
+
+ if (times == NULL || (times[0].tv_nsec == UTIME_NOW &&
+ times[1].tv_nsec == UTIME_NOW))
+ tvp = NULL;
+ else if (times[0].tv_nsec == UTIME_OMIT &&
+ times[1].tv_nsec == UTIME_OMIT)
+ return (0);
+ else {
+ if ((times[0].tv_nsec < 0 || times[0].tv_nsec > 999999999) &&
+ times[0].tv_nsec != UTIME_NOW &&
+ times[0].tv_nsec != UTIME_OMIT) {
+ errno = EINVAL;
+ return (-1);
+ }
+ if ((times[1].tv_nsec < 0 || times[1].tv_nsec > 999999999) &&
+ times[1].tv_nsec != UTIME_NOW &&
+ times[1].tv_nsec != UTIME_OMIT) {
+ errno = EINVAL;
+ return (-1);
+ }
+ tv[0].tv_sec = times[0].tv_sec;
+ tv[0].tv_usec = times[0].tv_nsec / 1000;
+ tv[1].tv_sec = times[1].tv_sec;
+ tv[1].tv_usec = times[1].tv_nsec / 1000;
+ tvp = tv;
+ if (times[0].tv_nsec == UTIME_OMIT ||
+ times[1].tv_nsec == UTIME_OMIT) {
+ if (fstat(fd, &sb) == -1)
+ return (-1);
+ if (times[0].tv_nsec == UTIME_OMIT) {
+ tv[0].tv_sec = sb.st_atim.tv_sec;
+ tv[0].tv_usec = sb.st_atim.tv_nsec / 1000;
+ }
+ if (times[1].tv_nsec == UTIME_OMIT) {
+ tv[1].tv_sec = sb.st_mtim.tv_sec;
+ tv[1].tv_usec = sb.st_mtim.tv_nsec / 1000;
+ }
+ }
+ if (times[0].tv_nsec == UTIME_NOW ||
+ times[1].tv_nsec == UTIME_NOW) {
+ if (gettimeofday(&now, NULL) == -1)
+ return (-1);
+ if (times[0].tv_nsec == UTIME_NOW)
+ tv[0] = now;
+ if (times[1].tv_nsec == UTIME_NOW)
+ tv[1] = now;
+ }
+ }
+ return (futimes(fd, tvp));
+}
diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc
index 9ad8149..8a56228 100644
--- a/tools/build/mk/OptionalObsoleteFiles.inc
+++ b/tools/build/mk/OptionalObsoleteFiles.inc
@@ -431,7 +431,7 @@ OLD_FILES+=usr/share/man/man7/ldint.7.gz
OLD_FILES+=usr/share/man/man7/binutils.7.gz
.endif
-.if ${MK_BLACKLIST_SUPPORT} == no
+.if ${MK_BLACKLIST} == no
OLD_FILES+=etc/rc.d/blacklistd
OLD_FILES+=usr/include/blacklist.h
OLD_FILES+=usr/lib/libblacklist.a
@@ -3209,9 +3209,9 @@ OLD_FILES+=usr/lib/libwind.so
OLD_LIBS+=usr/lib/libwind.so.11
OLD_FILES+=usr/lib/libwind_p.a
OLD_FILES+=usr/lib/pam_krb5.so
-OLD_LIBS+=usr/lib/pam_krb5.so.5
+OLD_LIBS+=usr/lib/pam_krb5.so.6
OLD_FILES+=usr/lib/pam_ksu.so
-OLD_LIBS+=usr/lib/pam_ksu.so.5
+OLD_LIBS+=usr/lib/pam_ksu.so.6
OLD_FILES+=usr/lib/private/libheimipcc.a
OLD_FILES+=usr/lib/private/libheimipcc.so
OLD_LIBS+=usr/lib/private/libheimipcc.so.11
@@ -3286,9 +3286,9 @@ OLD_FILES+=usr/lib32/libwind.so
OLD_LIBS+=usr/lib32/libwind.so.11
OLD_FILES+=usr/lib32/libwind_p.a
OLD_FILES+=usr/lib32/pam_krb5.so
-OLD_LIBS+=usr/lib32/pam_krb5.so.5
+OLD_LIBS+=usr/lib32/pam_krb5.so.6
OLD_FILES+=usr/lib32/pam_ksu.so
-OLD_LIBS+=usr/lib32/pam_ksu.so.5
+OLD_LIBS+=usr/lib32/pam_ksu.so.6
OLD_FILES+=usr/lib32/private/libheimipcc.a
OLD_FILES+=usr/lib32/private/libheimipcc.so
OLD_LIBS+=usr/lib32/private/libheimipcc.so.11
@@ -6397,14 +6397,14 @@ OLD_FILES+=usr/bin/ssh-copy-id
OLD_FILES+=usr/bin/ssh-keygen
OLD_FILES+=usr/bin/ssh-keyscan
OLD_FILES+=usr/lib/pam_ssh.so
-OLD_LIBS+=usr/lib/pam_ssh.so.5
+OLD_LIBS+=usr/lib/pam_ssh.so.6
OLD_FILES+=usr/lib/private/libssh.a
OLD_FILES+=usr/lib/private/libssh.so
OLD_LIBS+=usr/lib/private/libssh.so.5
OLD_FILES+=usr/lib/private/libssh_p.a
.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
OLD_FILES+=usr/lib32/pam_ssh.so
-OLD_LIBS+=usr/lib32/pam_ssh.so.5
+OLD_LIBS+=usr/lib32/pam_ssh.so.6
OLD_FILES+=usr/lib32/private/libssh.a
OLD_FILES+=usr/lib32/private/libssh.so
OLD_LIBS+=usr/lib32/private/libssh.so.5
diff --git a/tools/build/options/WITHOUT_BLACKLIST b/tools/build/options/WITHOUT_BLACKLIST
new file mode 100644
index 0000000..65c5097
--- /dev/null
+++ b/tools/build/options/WITHOUT_BLACKLIST
@@ -0,0 +1,2 @@
+.\" $FreeBSD$
+Set this if you do not want to build blacklistd / blacklistctl.
diff --git a/tools/build/options/WITHOUT_BLACKLIST_SUPPORT b/tools/build/options/WITHOUT_BLACKLIST_SUPPORT
new file mode 100644
index 0000000..674c967
--- /dev/null
+++ b/tools/build/options/WITHOUT_BLACKLIST_SUPPORT
@@ -0,0 +1,8 @@
+.\" $FreeBSD$
+Set to build some programs without blacklistd support, like
+.Xr fingerd 8 ,
+.Xr ftpd 8 ,
+.Xr rlogind 8 ,
+.Xr rshd 8 ,
+and
+.Xr sshd 8 .
diff --git a/tools/build/options/WITH_META_MODE b/tools/build/options/WITH_META_MODE
index 775ab01..9f7bade 100644
--- a/tools/build/options/WITH_META_MODE
+++ b/tools/build/options/WITH_META_MODE
@@ -7,9 +7,13 @@ using
The meta file is created in the OBJDIR as
.Pa target.meta .
These meta files track the command ran, its output, and the current directory.
-When the
+The
.Xr filemon 4
-module is loaded, any files used by the commands executed will be tracked as
+module is required unless
+.Va NO_FILEMON
+is defined.
+When the module is loaded, any files used by the commands executed will be
+tracked as
dependencies for the target in its meta file.
The target will be considered out-of-date and rebuilt if any of the following
are true compared to the last build:
@@ -37,6 +41,9 @@ The meta files can also be useful for debugging.
The build will hide commands ran unless
.Va NO_SILENT
is defined.
+Errors will cause
+.Xr make 1
+to show some of its environment for further debugging.
.Pp
The build operates as it normally would otherwise.
This option originally invoked a different build system but that was renamed
diff --git a/lib/libpam/libpam/pam_debug_log.c b/tools/build/stat.h
index c3fe8e3..18d1460 100644
--- a/lib/libpam/libpam/pam_debug_log.c
+++ b/tools/build/stat.h
@@ -1,5 +1,5 @@
/*-
- * Copyright 2001 Mark R V Murray
+ * Copyright (c) 2016 Jilles Tjoelker <jilles@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,41 +22,25 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * $FreeBSD$
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+#ifndef _LEGACY_SYS_STAT_H_
+#define _LEGACY_SYS_STAT_H_
-#include <libgen.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include_next <sys/stat.h>
-#include <security/pam_appl.h>
-#include <security/openpam.h>
-#include <security/pam_mod_misc.h>
+#ifndef UTIME_NOW
+#define UTIME_NOW -1
+#define UTIME_OMIT -2
+#endif
-/* Print a verbose error, including the function name and a
- * cleaned up filename.
- */
-void
-_pam_verbose_error(pam_handle_t *pamh, int flags,
- const char *file, const char *function, const char *format, ...)
-{
- va_list ap;
- char *fmtbuf, *modname, *period;
+__BEGIN_DECLS
+
+int futimens(int, const struct timespec *);
+int utimensat(int, const char *, const struct timespec *, int);
+
+__END_DECLS
- if (!(flags & PAM_SILENT) && !openpam_get_option(pamh, "no_warn")) {
- modname = basename(file);
- period = strchr(modname, '.');
- if (period == NULL)
- period = strchr(modname, '\0');
- va_start(ap, format);
- asprintf(&fmtbuf, "%.*s: %s: %s\n", (int)(period - modname),
- modname, function, format);
- pam_verror(pamh, fmtbuf, ap);
- free(fmtbuf);
- va_end(ap);
- }
-}
+#endif /* !_LEGACY_SYS_STAT_H_ */
diff --git a/tools/build/utimensat.c b/tools/build/utimensat.c
new file mode 100644
index 0000000..2105993
--- /dev/null
+++ b/tools/build/utimensat.c
@@ -0,0 +1,108 @@
+/*-
+ * Copyright (c) 2015 Jilles Tjoelker
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/stat.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <time.h>
+
+#ifndef UTIME_NOW
+#define UTIME_NOW -1
+#define UTIME_OMIT -2
+#endif
+
+int
+utimensat(int fd, const char *path, const struct timespec times[2], int flag)
+{
+ struct timeval now, tv[2], *tvp;
+ struct stat sb;
+ int osreldate;
+
+ if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0) {
+ errno = EINVAL;
+ return (-1);
+ }
+ if (times == NULL || (times[0].tv_nsec == UTIME_NOW &&
+ times[1].tv_nsec == UTIME_NOW))
+ tvp = NULL;
+ else if (times[0].tv_nsec == UTIME_OMIT &&
+ times[1].tv_nsec == UTIME_OMIT)
+ return (0);
+ else {
+ if ((times[0].tv_nsec < 0 || times[0].tv_nsec > 999999999) &&
+ times[0].tv_nsec != UTIME_NOW &&
+ times[0].tv_nsec != UTIME_OMIT) {
+ errno = EINVAL;
+ return (-1);
+ }
+ if ((times[1].tv_nsec < 0 || times[1].tv_nsec > 999999999) &&
+ times[1].tv_nsec != UTIME_NOW &&
+ times[1].tv_nsec != UTIME_OMIT) {
+ errno = EINVAL;
+ return (-1);
+ }
+ tv[0].tv_sec = times[0].tv_sec;
+ tv[0].tv_usec = times[0].tv_nsec / 1000;
+ tv[1].tv_sec = times[1].tv_sec;
+ tv[1].tv_usec = times[1].tv_nsec / 1000;
+ tvp = tv;
+ if (times[0].tv_nsec == UTIME_OMIT ||
+ times[1].tv_nsec == UTIME_OMIT) {
+ if (fstatat(fd, path, &sb, flag) == -1)
+ return (-1);
+ if (times[0].tv_nsec == UTIME_OMIT) {
+ tv[0].tv_sec = sb.st_atim.tv_sec;
+ tv[0].tv_usec = sb.st_atim.tv_nsec / 1000;
+ }
+ if (times[1].tv_nsec == UTIME_OMIT) {
+ tv[1].tv_sec = sb.st_mtim.tv_sec;
+ tv[1].tv_usec = sb.st_mtim.tv_nsec / 1000;
+ }
+ }
+ if (times[0].tv_nsec == UTIME_NOW ||
+ times[1].tv_nsec == UTIME_NOW) {
+ if (gettimeofday(&now, NULL) == -1)
+ return (-1);
+ if (times[0].tv_nsec == UTIME_NOW)
+ tv[0] = now;
+ if (times[1].tv_nsec == UTIME_NOW)
+ tv[1] = now;
+ }
+ }
+ if ((flag & AT_SYMLINK_NOFOLLOW) == 0)
+ return (futimesat(fd, path, tvp));
+ else if ((flag & AT_SYMLINK_NOFOLLOW) != 0 &&
+ (fd == AT_FDCWD || path[0] == '/'))
+ return (lutimes(path, tvp));
+ else {
+ errno = ENOTSUP;
+ return (-1);
+ }
+}
diff --git a/tools/tools/cxgbetool/cxgbetool.c b/tools/tools/cxgbetool/cxgbetool.c
index 4f78802..3d4cbfb 100644
--- a/tools/tools/cxgbetool/cxgbetool.c
+++ b/tools/tools/cxgbetool/cxgbetool.c
@@ -2526,9 +2526,9 @@ sched_class(int argc, const char *argv[])
errs++;
}
if (op.u.params.ratemode == SCHED_CLASS_RATEMODE_ABS &&
- !in_range(op.u.params.maxrate, 1, 10000000)) {
+ !in_range(op.u.params.maxrate, 1, 100000000)) {
warnx("sched params \"max-rate\" takes "
- "value(1-10000000) for rate-mode absolute");
+ "value(1-100000000) for rate-mode absolute");
errs++;
}
if (op.u.params.maxrate > 0 &&
diff --git a/usr.bin/awk/Makefile b/usr.bin/awk/Makefile
index 168b22e..f6c1baa 100644
--- a/usr.bin/awk/Makefile
+++ b/usr.bin/awk/Makefile
@@ -17,8 +17,10 @@ MLINKS= awk.1 nawk.1
CLEANFILES= maketab proctab.c ytab.h
-ytab.h: awkgram.h .NOMETA
- ln -sf ${.ALLSRC} ${.TARGET}
+# XXX: awkgram.c isn't really needed here but it is added to keep
+# awkgram.h: .NOMETA respected.
+ytab.h: awkgram.c awkgram.h .NOMETA
+ ln -sf ${.ALLSRC:M*.h} ${.TARGET}
proctab.c: maketab
${BTOOLSPATH:U.}/maketab > proctab.c
diff --git a/usr.bin/bmake/Makefile b/usr.bin/bmake/Makefile
index c0c940e..a748a9b 100644
--- a/usr.bin/bmake/Makefile
+++ b/usr.bin/bmake/Makefile
@@ -14,10 +14,10 @@ CFLAGS+= -I${.CURDIR}
CLEANDIRS+= FreeBSD
CLEANFILES+= bootstrap
-# $Id: Makefile,v 1.66 2016/06/04 22:21:15 sjg Exp $
+# $Id: Makefile,v 1.67 2016/06/07 00:46:12 sjg Exp $
# Base version on src date
-_MAKE_VERSION= 20160604
+_MAKE_VERSION= 20160606
PROG?= ${.CURDIR:T}
diff --git a/usr.bin/bmake/config.h b/usr.bin/bmake/config.h
index 6119dcf..7a47d4c 100644
--- a/usr.bin/bmake/config.h
+++ b/usr.bin/bmake/config.h
@@ -245,7 +245,7 @@
#define PACKAGE_NAME "bmake"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "bmake 20151022"
+#define PACKAGE_STRING "bmake 20160606"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "bmake"
@@ -254,7 +254,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
-#define PACKAGE_VERSION "20151022"
+#define PACKAGE_VERSION "20160606"
/* Define as the return type of signal handlers (`int' or `void'). */
#define RETSIGTYPE void
@@ -326,6 +326,9 @@
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
+/* Define to `int' if <sys/types.h> does not define. */
+/* #undef mode_t */
+
/* Define to `long int' if <sys/types.h> does not define. */
/* #undef off_t */
diff --git a/usr.bin/calendar/calendars/calendar.freebsd b/usr.bin/calendar/calendars/calendar.freebsd
index a7580cf..6254f1a 100644
--- a/usr.bin/calendar/calendars/calendar.freebsd
+++ b/usr.bin/calendar/calendars/calendar.freebsd
@@ -36,7 +36,7 @@
01/26 Andrew Gallatin <gallatin@FreeBSD.org> born in Buffalo, New York, United States, 1970
01/27 Nick Sayer <nsayer@FreeBSD.org> born in San Diego, California, United States, 1968
01/27 Jacques Anthony Vidrine <nectar@FreeBSD.org> born in Baton Rouge, Louisiana, United States, 1971
-01/27 Garrett Cooper <ngie@FreeBSD.org> born in Seattle, Washington, United States, 1984
+01/27 Ngie Cooper <ngie@FreeBSD.org> born in Seattle, Washington, United States, 1984
01/31 Hidetoshi Shimokawa <simokawa@FreeBSD.org> born in Yokohama, Kanagawa, Japan, 1970
02/01 Doug Rabson <dfr@FreeBSD.org> born in London, England, 1966
02/01 Nicola Vitale <nivit@FreeBSD.org> born in Busto Arsizio, Varese, Italy, 1976
@@ -338,6 +338,7 @@
10/25 Eric Melville <eric@FreeBSD.org> born in Los Gatos, California, United States, 1980
10/25 Julien Laffaye <jlaffaye@FreeBSD.org> born in Toulouse, France, 1988
10/25 Ashish SHUKLA <ashish@FreeBSD.org> born in Kanpur, India, 1985
+10/26 Matthew Ahrens <mahrens@FreeBSD.org> born in United States, 1979
10/26 Philip M. Gollucci <pgollucci@FreeBSD.org> born in Silver Spring, Maryland, United States, 1979
10/27 Takanori Watanabe <takawata@FreeBSD.org> born in Numazu, Shizuoka, Japan, 1972
11/05 M. Warner Losh <imp@FreeBSD.org> born in Kansas City, Kansas, United States, 1966
diff --git a/usr.bin/indent/lexi.c b/usr.bin/indent/lexi.c
index b3604c6..1200a39 100644
--- a/usr.bin/indent/lexi.c
+++ b/usr.bin/indent/lexi.c
@@ -79,7 +79,7 @@ struct templ specials[1000] =
{"double", 4},
{"long", 4},
{"short", 4},
- {"typdef", 4},
+ {"typedef", 4},
{"unsigned", 4},
{"register", 4},
{"static", 4},
diff --git a/usr.bin/random/randomize_fd.c b/usr.bin/random/randomize_fd.c
index 622bfc0..684c84e 100644
--- a/usr.bin/random/randomize_fd.c
+++ b/usr.bin/random/randomize_fd.c
@@ -199,17 +199,14 @@ make_token:
}
}
- if (fd >= 0) {
- (void)close(fd);
- fd = -1;
- }
-
/* Necessary evil to compensate for files that don't end with a newline */
if (bufc != i) {
i--;
goto make_token;
}
+ (void)close(fd);
+
free(buf);
for (i = numnode; i > 0; i--) {
diff --git a/usr.bin/truss/Makefile b/usr.bin/truss/Makefile
index 7ba4392..480dab0 100644
--- a/usr.bin/truss/Makefile
+++ b/usr.bin/truss/Makefile
@@ -18,6 +18,7 @@ ABIS+= cloudabi64
ABIS+= i386-linux
.endif
.if ${MACHINE_CPUARCH} == "amd64"
+ABIS+= amd64-linux
ABIS+= amd64-linux32
ABIS+= freebsd32
ABIS+= cloudabi64
diff --git a/usr.bin/truss/amd64-linux.c b/usr.bin/truss/amd64-linux.c
new file mode 100644
index 0000000..4397804
--- /dev/null
+++ b/usr.bin/truss/amd64-linux.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright 1997 Sean Eric Fagan
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Sean Eric Fagan
+ * 4. Neither the name of the author may be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/* Linux/x86_64-specific system call handling. */
+
+#include <sys/ptrace.h>
+
+#include <machine/reg.h>
+#include <machine/psl.h>
+
+#include <stdio.h>
+#include <sysdecode.h>
+
+#include "truss.h"
+
+static int
+amd64_linux_fetch_args(struct trussinfo *trussinfo, u_int narg)
+{
+ struct reg regs;
+ struct current_syscall *cs;
+ lwpid_t tid;
+
+ tid = trussinfo->curthread->tid;
+ cs = &trussinfo->curthread->cs;
+ if (ptrace(PT_GETREGS, tid, (caddr_t)&regs, 0) < 0) {
+ fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n");
+ return (-1);
+ }
+
+ switch (narg) {
+ default:
+ cs->args[5] = regs.r_r9;
+ case 5:
+ cs->args[4] = regs.r_r8;
+ case 4:
+ cs->args[3] = regs.r_rcx;
+ case 3:
+ cs->args[2] = regs.r_rdx;
+ case 2:
+ cs->args[1] = regs.r_rsi;
+ case 1:
+ cs->args[0] = regs.r_rdi;
+ }
+
+ return (0);
+}
+
+static int
+amd64_linux_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp)
+{
+ struct reg regs;
+ lwpid_t tid;
+
+ tid = trussinfo->curthread->tid;
+ if (ptrace(PT_GETREGS, tid, (caddr_t)&regs, 0) < 0) {
+ fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n");
+ return (-1);
+ }
+
+ retval[0] = regs.r_rax;
+ retval[1] = regs.r_rdx;
+ *errorp = !!(regs.r_rflags & PSL_C);
+ return (0);
+}
+
+static struct procabi amd64_linux = {
+ "Linux ELF64",
+ SYSDECODE_ABI_LINUX,
+ amd64_linux_fetch_args,
+ amd64_linux_fetch_retval
+};
+
+PROCABI(amd64_linux);
diff --git a/usr.bin/xinstall/tests/install_test.sh b/usr.bin/xinstall/tests/install_test.sh
index 24a8a4d..9a9c69f 100755
--- a/usr.bin/xinstall/tests/install_test.sh
+++ b/usr.bin/xinstall/tests/install_test.sh
@@ -64,6 +64,12 @@ copy_to_nonexistent_backup_safe_body() {
copy_to_nonexistent_with_opts -b -B.bak -S
}
+atf_test_case copy_to_nonexistent_preserving
+copy_to_nonexistent_preserving_body() {
+ copy_to_nonexistent_with_opts -p
+ [ ! testf -ot copyf ] || atf_fail "bad timestamp 2"
+}
+
copy_self_with_opts() {
printf 'test\n123\r456\r\n789\0z' >testf
printf 'test\n123\r456\r\n789\0z' >testf2
@@ -307,6 +313,7 @@ atf_init_test_cases() {
atf_add_test_case copy_to_nonexistent_safe_comparing
atf_add_test_case copy_to_nonexistent_backup
atf_add_test_case copy_to_nonexistent_backup_safe
+ atf_add_test_case copy_to_nonexistent_preserving
atf_add_test_case copy_self
atf_add_test_case copy_self_safe
atf_add_test_case copy_self_comparing
diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c
index 1121cff..5e05ba8 100644
--- a/usr.bin/xinstall/xinstall.c
+++ b/usr.bin/xinstall/xinstall.c
@@ -131,7 +131,7 @@ static void do_symlink(const char *, const char *, const struct stat *);
static void makelink(const char *, const char *, const struct stat *);
static void install(const char *, const char *, u_long, u_int);
static void install_dir(char *);
-static void metadata_log(const char *, const char *, struct timeval *,
+static void metadata_log(const char *, const char *, struct timespec *,
const char *, const char *, off_t);
static int parseid(const char *, id_t *);
static void strip(const char *);
@@ -722,7 +722,7 @@ static void
install(const char *from_name, const char *to_name, u_long fset, u_int flags)
{
struct stat from_sb, temp_sb, to_sb;
- struct timeval tvb[2];
+ struct timespec tsb[2];
int devnull, files_match, from_fd, serrno, target;
int tempcopy, temp_fd, to_fd;
char backup[MAXPATHLEN], *p, pathbuf[MAXPATHLEN], tempfile[MAXPATHLEN];
@@ -857,11 +857,9 @@ install(const char *from_name, const char *to_name, u_long fset, u_int flags)
* Need to preserve target file times, though.
*/
if (to_sb.st_nlink != 1) {
- tvb[0].tv_sec = to_sb.st_atime;
- tvb[0].tv_usec = 0;
- tvb[1].tv_sec = to_sb.st_mtime;
- tvb[1].tv_usec = 0;
- (void)utimes(tempfile, tvb);
+ tsb[0] = to_sb.st_atim;
+ tsb[1] = to_sb.st_mtim;
+ (void)utimensat(AT_FDCWD, tempfile, tsb, 0);
} else {
files_match = 1;
(void)unlink(tempfile);
@@ -916,11 +914,9 @@ install(const char *from_name, const char *to_name, u_long fset, u_int flags)
* Preserve the timestamp of the source file if necessary.
*/
if (dopreserve && !files_match && !devnull) {
- tvb[0].tv_sec = from_sb.st_atime;
- tvb[0].tv_usec = 0;
- tvb[1].tv_sec = from_sb.st_mtime;
- tvb[1].tv_usec = 0;
- (void)utimes(to_name, tvb);
+ tsb[0] = from_sb.st_atim;
+ tsb[1] = from_sb.st_mtim;
+ (void)utimensat(AT_FDCWD, to_name, tsb, 0);
}
if (fstat(to_fd, &to_sb) == -1) {
@@ -989,7 +985,7 @@ install(const char *from_name, const char *to_name, u_long fset, u_int flags)
if (!devnull)
(void)close(from_fd);
- metadata_log(to_name, "file", tvb, NULL, digestresult, to_sb.st_size);
+ metadata_log(to_name, "file", tsb, NULL, digestresult, to_sb.st_size);
free(digestresult);
}
@@ -1301,7 +1297,7 @@ again:
* or to allow integrity checks to be performed.
*/
static void
-metadata_log(const char *path, const char *type, struct timeval *tv,
+metadata_log(const char *path, const char *type, struct timespec *ts,
const char *slink, const char *digestresult, off_t size)
{
static const char extra[] = { ' ', '\t', '\n', '\\', '#', '\0' };
@@ -1355,9 +1351,9 @@ metadata_log(const char *path, const char *type, struct timeval *tv,
}
if (*type == 'f') /* type=file */
fprintf(metafp, " size=%lld", (long long)size);
- if (tv != NULL && dopreserve)
- fprintf(metafp, " time=%lld.%ld",
- (long long)tv[1].tv_sec, (long)tv[1].tv_usec);
+ if (ts != NULL && dopreserve)
+ fprintf(metafp, " time=%lld.%09ld",
+ (long long)ts[1].tv_sec, ts[1].tv_nsec);
if (digestresult && digest)
fprintf(metafp, " %s=%s", digest, digestresult);
if (fflags)
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile
index 8c80266..b08a65a 100644
--- a/usr.sbin/Makefile
+++ b/usr.sbin/Makefile
@@ -113,9 +113,9 @@ SUBDIR.${MK_AUDIT}+= auditreduce
SUBDIR.${MK_AUDIT}+= praudit
SUBDIR.${MK_AUTHPF}+= authpf
SUBDIR.${MK_AUTOFS}+= autofs
-.if ${MK_BLACKLIST_SUPPORT} != "no"
-SUBDIR.${MK_BLACKLIST_SUPPORT}+= blacklistctl
-SUBDIR.${MK_BLACKLIST_SUPPORT}+= blacklistd
+.if ${MK_BLACKLIST} != "no"
+SUBDIR.${MK_BLACKLIST}+= blacklistctl
+SUBDIR.${MK_BLACKLIST}+= blacklistd
.endif
SUBDIR.${MK_BLUETOOTH}+= bluetooth
SUBDIR.${MK_BOOTPARAMD}+= bootparamd
diff --git a/usr.sbin/bluetooth/ath3kfw/Makefile b/usr.sbin/bluetooth/ath3kfw/Makefile
index 26ce06e..61a6f9c 100644
--- a/usr.sbin/bluetooth/ath3kfw/Makefile
+++ b/usr.sbin/bluetooth/ath3kfw/Makefile
@@ -3,5 +3,6 @@
PROG= ath3kfw
MAN= ath3kfw.8
LIBADD+= usb
+SRCS= main.c ath3k_fw.c ath3k_hw.c
.include <bsd.prog.mk>
diff --git a/usr.sbin/bluetooth/ath3kfw/ath3k_dbg.h b/usr.sbin/bluetooth/ath3kfw/ath3k_dbg.h
new file mode 100644
index 0000000..3aaf3b3
--- /dev/null
+++ b/usr.sbin/bluetooth/ath3kfw/ath3k_dbg.h
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 2013 Adrian Chadd <adrian@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ * redistribution must be conditioned upon including a substantially
+ * similar Disclaimer requirement for further binary redistribution.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * $FreeBSD$
+ */
+#ifndef __ATH3K_DEBUG_H__
+#define __ATH3K_DEBUG_H__
+
+extern int ath3k_do_debug;
+extern int ath3k_do_info;
+
+#define ath3k_debug(...) if (ath3k_do_debug) fprintf(stderr, __VA_ARGS__)
+#define ath3k_err(...) fprintf(stderr, __VA_ARGS__)
+#define ath3k_info(...) if (ath3k_do_info) fprintf(stdout, __VA_ARGS__)
+
+#endif
diff --git a/usr.sbin/bluetooth/ath3kfw/ath3k_fw.c b/usr.sbin/bluetooth/ath3kfw/ath3k_fw.c
new file mode 100644
index 0000000..2c48004
--- /dev/null
+++ b/usr.sbin/bluetooth/ath3kfw/ath3k_fw.c
@@ -0,0 +1,114 @@
+/*-
+ * Copyright (c) 2013 Adrian Chadd <adrian@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ * redistribution must be conditioned upon including a substantially
+ * similar Disclaimer requirement for further binary redistribution.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * $FreeBSD$
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <err.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "ath3k_fw.h"
+#include "ath3k_dbg.h"
+
+int
+ath3k_fw_read(struct ath3k_firmware *fw, const char *fwname)
+{
+ int fd;
+ struct stat sb;
+ unsigned char *buf;
+ ssize_t r;
+ int i;
+
+ fd = open(fwname, O_RDONLY);
+ if (fd < 0) {
+ warn("%s: open: %s", __func__, fwname);
+ return (0);
+ }
+
+ if (fstat(fd, &sb) != 0) {
+ warn("%s: stat: %s", __func__, fwname);
+ close(fd);
+ return (0);
+ }
+
+ buf = calloc(1, sb.st_size);
+ if (buf == NULL) {
+ warn("%s: calloc", __func__);
+ close(fd);
+ return (0);
+ }
+
+ i = 0;
+ /* XXX handle partial reads */
+ r = read(fd, buf, sb.st_size);
+ if (r < 0) {
+ warn("%s: read", __func__);
+ free(buf);
+ close(fd);
+ return (0);
+ }
+
+ if (r != sb.st_size) {
+ fprintf(stderr, "%s: read len %d != file size %d\n",
+ __func__,
+ (int) r,
+ (int) sb.st_size);
+ free(buf);
+ close(fd);
+ return (0);
+ }
+
+ /* We have everything, so! */
+
+ bzero(fw, sizeof(*fw));
+
+ fw->fwname = strdup(fwname);
+ fw->len = sb.st_size;
+ fw->size = sb.st_size;
+ fw->buf = buf;
+
+ close(fd);
+ return (1);
+}
+
+void
+ath3k_fw_free(struct ath3k_firmware *fw)
+{
+ if (fw->fwname)
+ free(fw->fwname);
+ if (fw->buf)
+ free(fw->buf);
+ bzero(fw, sizeof(*fw));
+}
diff --git a/usr.sbin/bluetooth/ath3kfw/ath3k_fw.h b/usr.sbin/bluetooth/ath3kfw/ath3k_fw.h
new file mode 100644
index 0000000..eddc0b7
--- /dev/null
+++ b/usr.sbin/bluetooth/ath3kfw/ath3k_fw.h
@@ -0,0 +1,56 @@
+/*-
+ * Copyright (c) 2013 Adrian Chadd <adrian@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ * redistribution must be conditioned upon including a substantially
+ * similar Disclaimer requirement for further binary redistribution.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * $FreeBSD$
+ */
+#ifndef __ATH3K_FW_H__
+#define __ATH3K_FW_H__
+
+/*
+ * XXX TODO: ensure that the endian-ness of this stuff is
+ * correct!
+ */
+struct ath3k_version {
+ unsigned int rom_version;
+ unsigned int build_version;
+ unsigned int ram_version;
+ unsigned char ref_clock;
+ unsigned char reserved[0x07];
+};
+
+struct ath3k_firmware {
+ char *fwname;
+ int len; /* firmware length */
+ int size; /* buffer size */
+ unsigned char *buf;
+};
+
+extern int ath3k_fw_read(struct ath3k_firmware *fw, const char *fwname);
+extern void ath3k_fw_free(struct ath3k_firmware *fw);
+
+#endif
diff --git a/usr.sbin/bluetooth/ath3kfw/ath3k_hw.c b/usr.sbin/bluetooth/ath3kfw/ath3k_hw.c
new file mode 100644
index 0000000..890e2db
--- /dev/null
+++ b/usr.sbin/bluetooth/ath3kfw/ath3k_hw.c
@@ -0,0 +1,358 @@
+/*-
+ * Copyright (c) 2013 Adrian Chadd <adrian@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ * redistribution must be conditioned upon including a substantially
+ * similar Disclaimer requirement for further binary redistribution.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * $FreeBSD$
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <err.h>
+#include <fcntl.h>
+#include <sys/endian.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <libusb.h>
+
+#include "ath3k_fw.h"
+#include "ath3k_hw.h"
+#include "ath3k_dbg.h"
+
+#define XMIN(x, y) ((x) < (y) ? (x) : (y))
+
+int
+ath3k_load_fwfile(struct libusb_device_handle *hdl,
+ const struct ath3k_firmware *fw)
+{
+ int size, count, sent = 0;
+ int ret, r;
+
+ count = fw->len;
+
+ size = XMIN(count, FW_HDR_SIZE);
+
+ ath3k_debug("%s: file=%s, size=%d\n",
+ __func__, fw->fwname, count);
+
+ /*
+ * Flip the device over to configuration mode.
+ */
+ ret = libusb_control_transfer(hdl,
+ LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT,
+ ATH3K_DNLOAD,
+ 0,
+ 0,
+ fw->buf + sent,
+ size,
+ 1000); /* XXX timeout */
+
+ if (ret != size) {
+ fprintf(stderr, "Can't switch to config mode; ret=%d\n",
+ ret);
+ return (-1);
+ }
+
+ sent += size;
+ count -= size;
+
+ /* Load in the rest of the data */
+ while (count) {
+ size = XMIN(count, BULK_SIZE);
+ ath3k_debug("%s: transferring %d bytes, offset %d\n",
+ __func__,
+ sent,
+ size);
+
+ ret = libusb_bulk_transfer(hdl,
+ 0x2,
+ fw->buf + sent,
+ size,
+ &r,
+ 1000);
+
+ if (ret < 0 || r != size) {
+ fprintf(stderr, "Can't load firmware: err=%s, size=%d\n",
+ libusb_strerror(ret),
+ size);
+ return (-1);
+ }
+ sent += size;
+ count -= size;
+ }
+ return (0);
+}
+
+int
+ath3k_get_state(struct libusb_device_handle *hdl, unsigned char *state)
+{
+ int ret;
+
+ ret = libusb_control_transfer(hdl,
+ LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_IN,
+ ATH3K_GETSTATE,
+ 0,
+ 0,
+ state,
+ 1,
+ 1000); /* XXX timeout */
+
+ if (ret < 0) {
+ fprintf(stderr,
+ "%s: libusb_control_transfer() failed: code=%d\n",
+ __func__,
+ ret);
+ return (0);
+ }
+
+ return (ret == 1);
+}
+
+int
+ath3k_get_version(struct libusb_device_handle *hdl,
+ struct ath3k_version *version)
+{
+ int ret;
+
+ ret = libusb_control_transfer(hdl,
+ LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_IN,
+ ATH3K_GETVERSION,
+ 0,
+ 0,
+ (unsigned char *) version,
+ sizeof(struct ath3k_version),
+ 1000); /* XXX timeout */
+
+ if (ret < 0) {
+ fprintf(stderr,
+ "%s: libusb_control_transfer() failed: code=%d\n",
+ __func__,
+ ret);
+ return (0);
+ }
+
+ /* XXX endian fix! */
+
+ return (ret == sizeof(struct ath3k_version));
+}
+
+int
+ath3k_load_patch(libusb_device_handle *hdl, const char *fw_path)
+{
+ int ret;
+ unsigned char fw_state;
+ struct ath3k_version fw_ver, pt_ver;
+ char fwname[FILENAME_MAX];
+ struct ath3k_firmware fw;
+ uint32_t tmp;
+
+ ret = ath3k_get_state(hdl, &fw_state);
+ if (ret < 0) {
+ ath3k_err("%s: Can't get state\n", __func__);
+ return (ret);
+ }
+
+ if (fw_state & ATH3K_PATCH_UPDATE) {
+ ath3k_info("%s: Patch already downloaded\n",
+ __func__);
+ return (0);
+ }
+
+ ret = ath3k_get_version(hdl, &fw_ver);
+ if (ret < 0) {
+ ath3k_debug("%s: Can't get version\n", __func__);
+ return (ret);
+ }
+
+ /* XXX path info? */
+ snprintf(fwname, FILENAME_MAX, "%s/ar3k/AthrBT_0x%08x.dfu",
+ fw_path,
+ fw_ver.rom_version);
+
+ /* Read in the firmware */
+ if (ath3k_fw_read(&fw, fwname) <= 0) {
+ ath3k_debug("%s: ath3k_fw_read() failed\n",
+ __func__);
+ return (-1);
+ }
+
+ /*
+ * Extract the ROM/build version from the patch file.
+ */
+ memcpy(&tmp, fw.buf + fw.len - 8, sizeof(tmp));
+ pt_ver.rom_version = le32toh(tmp);
+ memcpy(&tmp, fw.buf + fw.len - 4, sizeof(tmp));
+ pt_ver.build_version = le32toh(tmp);
+
+ ath3k_info("%s: file %s: rom_ver=%d, build_ver=%d\n",
+ __func__,
+ fwname,
+ (int) pt_ver.rom_version,
+ (int) pt_ver.build_version);
+
+ /* Check the ROM/build version against the firmware */
+ if ((pt_ver.rom_version != fw_ver.rom_version) ||
+ (pt_ver.build_version <= fw_ver.build_version)) {
+ ath3k_debug("Patch file version mismatch!\n");
+ ath3k_fw_free(&fw);
+ return (-1);
+ }
+
+ /* Load in the firmware */
+ ret = ath3k_load_fwfile(hdl, &fw);
+
+ /* free it */
+ ath3k_fw_free(&fw);
+
+ return (ret);
+}
+
+int
+ath3k_load_syscfg(libusb_device_handle *hdl, const char *fw_path)
+{
+ unsigned char fw_state;
+ char filename[FILENAME_MAX];
+ struct ath3k_firmware fw;
+ struct ath3k_version fw_ver;
+ int clk_value, ret;
+
+ ret = ath3k_get_state(hdl, &fw_state);
+ if (ret < 0) {
+ ath3k_err("Can't get state to change to load configuration err");
+ return (-EBUSY);
+ }
+
+ ret = ath3k_get_version(hdl, &fw_ver);
+ if (ret < 0) {
+ ath3k_err("Can't get version to change to load ram patch err");
+ return (ret);
+ }
+
+ switch (fw_ver.ref_clock) {
+ case ATH3K_XTAL_FREQ_26M:
+ clk_value = 26;
+ break;
+ case ATH3K_XTAL_FREQ_40M:
+ clk_value = 40;
+ break;
+ case ATH3K_XTAL_FREQ_19P2:
+ clk_value = 19;
+ break;
+ default:
+ clk_value = 0;
+ break;
+}
+
+ snprintf(filename, FILENAME_MAX, "%s/ar3k/ramps_0x%08x_%d%s",
+ fw_path,
+ fw_ver.rom_version,
+ clk_value,
+ ".dfu");
+
+ ath3k_info("%s: syscfg file = %s\n",
+ __func__,
+ filename);
+
+ /* Read in the firmware */
+ if (ath3k_fw_read(&fw, filename) <= 0) {
+ ath3k_err("%s: ath3k_fw_read() failed\n",
+ __func__);
+ return (-1);
+ }
+
+ ret = ath3k_load_fwfile(hdl, &fw);
+
+ ath3k_fw_free(&fw);
+ return (ret);
+}
+
+int
+ath3k_set_normal_mode(libusb_device_handle *hdl)
+{
+ int ret;
+ unsigned char fw_state;
+
+ ret = ath3k_get_state(hdl, &fw_state);
+ if (ret < 0) {
+ ath3k_err("%s: can't get state\n", __func__);
+ return (ret);
+ }
+
+ /*
+ * This isn't a fatal error - the device may have detached
+ * already.
+ */
+ if ((fw_state & ATH3K_MODE_MASK) == ATH3K_NORMAL_MODE) {
+ ath3k_debug("%s: firmware is already in normal mode\n",
+ __func__);
+ return (0);
+ }
+
+ ret = libusb_control_transfer(hdl,
+ LIBUSB_REQUEST_TYPE_VENDOR, /* XXX out direction? */
+ ATH3K_SET_NORMAL_MODE,
+ 0,
+ 0,
+ NULL,
+ 0,
+ 1000); /* XXX timeout */
+
+ if (ret < 0) {
+ ath3k_err("%s: libusb_control_transfer() failed: code=%d\n",
+ __func__,
+ ret);
+ return (0);
+ }
+
+ return (ret == 0);
+}
+
+int
+ath3k_switch_pid(libusb_device_handle *hdl)
+{
+ int ret;
+ ret = libusb_control_transfer(hdl,
+ LIBUSB_REQUEST_TYPE_VENDOR, /* XXX set an out flag? */
+ USB_REG_SWITCH_VID_PID,
+ 0,
+ 0,
+ NULL,
+ 0,
+ 1000); /* XXX timeout */
+
+ if (ret < 0) {
+ ath3k_debug("%s: libusb_control_transfer() failed: code=%d\n",
+ __func__,
+ ret);
+ return (0);
+ }
+
+ return (ret == 0);
+}
diff --git a/usr.sbin/bluetooth/ath3kfw/ath3k_hw.h b/usr.sbin/bluetooth/ath3kfw/ath3k_hw.h
new file mode 100644
index 0000000..2d72f3f
--- /dev/null
+++ b/usr.sbin/bluetooth/ath3kfw/ath3k_hw.h
@@ -0,0 +1,66 @@
+/*-
+ * Copyright (c) 2013 Adrian Chadd <adrian@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ * redistribution must be conditioned upon including a substantially
+ * similar Disclaimer requirement for further binary redistribution.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * $FreeBSD$
+ */
+#ifndef __ATH3K_HW_H__
+#define __ATH3K_HW_H__
+
+#define ATH3K_DNLOAD 0x01
+#define ATH3K_GETSTATE 0x05
+#define ATH3K_SET_NORMAL_MODE 0x07
+#define ATH3K_GETVERSION 0x09
+#define USB_REG_SWITCH_VID_PID 0x0a
+
+#define ATH3K_MODE_MASK 0x3F
+#define ATH3K_NORMAL_MODE 0x0E
+
+#define ATH3K_PATCH_UPDATE 0x80
+#define ATH3K_SYSCFG_UPDATE 0x40
+
+#define ATH3K_XTAL_FREQ_26M 0x00
+#define ATH3K_XTAL_FREQ_40M 0x01
+#define ATH3K_XTAL_FREQ_19P2 0x02
+#define ATH3K_NAME_LEN 0xFF
+
+#define USB_REQ_DFU_DNLOAD 1
+#define BULK_SIZE 4096
+#define FW_HDR_SIZE 20
+
+extern int ath3k_load_fwfile(struct libusb_device_handle *hdl,
+ const struct ath3k_firmware *fw);
+extern int ath3k_get_state(struct libusb_device_handle *hdl,
+ unsigned char *state);
+extern int ath3k_get_version(struct libusb_device_handle *hdl,
+ struct ath3k_version *version);
+extern int ath3k_load_patch(libusb_device_handle *hdl, const char *fw_path);
+extern int ath3k_load_syscfg(libusb_device_handle *hdl, const char *fw_path);
+extern int ath3k_set_normal_mode(libusb_device_handle *hdl);
+extern int ath3k_switch_pid(libusb_device_handle *hdl);
+
+#endif
diff --git a/usr.sbin/bluetooth/ath3kfw/ath3kfw.8 b/usr.sbin/bluetooth/ath3kfw/ath3kfw.8
index 3a37343..7485583 100644
--- a/usr.sbin/bluetooth/ath3kfw/ath3kfw.8
+++ b/usr.sbin/bluetooth/ath3kfw/ath3kfw.8
@@ -1,4 +1,5 @@
.\" Copyright (c) 2010 Maksim Yevmenkin <m_evmenkin@yahoo.com>
+.\" Copyright (c) 2013, 2016 Adrian Chadd <adrian@freebsd.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -24,16 +25,16 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 9, 2010
+.Dd June 4, 2016
.Dt ATH3KFW 8
.Os
.Sh NAME
.Nm ath3kfw
-.Nd firmware download utility for Atheros AR3011 chip based Bluetooth USB devices
+.Nd firmware download utility for Atheros AR3011/AR3012 chip based Bluetooth USB devices
.Sh SYNOPSIS
.Nm
.Fl d Ar device_name
-.Fl f Ar firmware_file_name
+.Fl f Ar firmware_path
.Nm
.Fl h
.Sh DESCRIPTION
@@ -45,23 +46,31 @@ device.
.Pp
This utility will
.Em only
-work with Atheros AR3011 chip based Bluetooth USB devices.
+work with Atheros AR3011 and AR3012 chip based Bluetooth USB devices.
The identification is currently based on USB vendor ID/product ID pair.
The vendor ID should be 0x0cf3
.Pq Dv USB_VENDOR_ATHEROS2
-and the product ID should be 0x3000.
+and the product ID should be one of the supported devices.
.Pp
-Firmware files ath3k-1.fw and ath3k-2.fw can be obtained from the
-linux-firmware RPM.
+Firmware files are available in the linux-firmware RPM.
+.Pp
+The
+.Nm
+utility will query the device to determine which firmware image and board
+configuration to load in at runtime.
.Pp
The options are as follows:
.Bl -tag -width indent
+.It Fl D
+Enable verbose debugging.
.It Fl d Ar device_name
Specify
.Xr ugen 4
device name.
-.It Fl f Ar firmware_file_name
-Specify firmware file name for download.
+.It I
+Enable informational debugging.
+.It Fl f Ar firmware_path
+Specify the directory containing the firmware files to search and upload.
.It Fl h
Display usage message and exit.
.El
@@ -72,7 +81,10 @@ Display usage message and exit.
.Xr ugen 4 ,
.Xr devd 8
.Sh AUTHORS
-.An Maksim Yevmenkin Aq Mt m_evmenkin@yahoo.com
+The original utility was written by
+.An Maksim Yevmenkin Aq Mt m_evmenkin@yahoo.com .
+This was written based on Linux ath3k by
+.An Adrian Chadd Aq Mt adrian@freebsd.org .
.Sh BUGS
Most likely.
Please report if found.
diff --git a/usr.sbin/bluetooth/ath3kfw/ath3kfw.c b/usr.sbin/bluetooth/ath3kfw/ath3kfw.c
deleted file mode 100644
index 37191d1..0000000
--- a/usr.sbin/bluetooth/ath3kfw/ath3kfw.c
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * ath3kfw.c
- */
-
-/*-
- * Copyright (c) 2010 Maksim Yevmenkin <m_evmenkin@yahoo.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <sys/types.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <libusb20_desc.h>
-#include <libusb20.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <syslog.h>
-#include <unistd.h>
-
-#define ATH3KFW "ath3kfw"
-#define ATH3KFW_VENDOR_ID 0x0cf3
-#define ATH3KFW_PRODUCT_ID 0x3000
-#define ATH3KFW_FW "/usr/local/etc/ath3k-1.fw"
-#define ATH3KFW_BULK_EP 0x02
-#define ATH3KFW_REQ_DFU_DNLOAD 1
-#define ATH3KFW_MAX_BSIZE 4096
-
-static int parse_ugen_name (char const *ugen, uint8_t *bus,
- uint8_t *addr);
-static int find_device (struct libusb20_backend *be,
- uint8_t bus, uint8_t addr,
- struct libusb20_device **dev);
-static int download_firmware (struct libusb20_device *dev,
- char const *firmware);
-static void usage (void);
-
-static int vendor_id = ATH3KFW_VENDOR_ID;
-static int product_id = ATH3KFW_PRODUCT_ID;
-
-/*
- * Firmware downloader for Atheros AR3011 based USB Bluetooth devices
- */
-
-int
-main(int argc, char **argv)
-{
- uint8_t bus, addr;
- char const *firmware;
- struct libusb20_backend *be;
- struct libusb20_device *dev;
- int n;
-
- openlog(ATH3KFW, LOG_NDELAY|LOG_PERROR|LOG_PID, LOG_USER);
-
- bus = 0;
- addr = 0;
- firmware = ATH3KFW_FW;
-
- while ((n = getopt(argc, argv, "d:f:hp:v:")) != -1) {
- switch (n) {
- case 'd': /* ugen device name */
- if (parse_ugen_name(optarg, &bus, &addr) < 0)
- usage();
- break;
-
- case 'f': /* firmware file */
- firmware = optarg;
- break;
- case 'p': /* product id */
- product_id = strtol(optarg, NULL, 0);
- break;
- case 'v': /* vendor id */
- vendor_id = strtol(optarg, NULL, 0);
- break;
- case 'h':
- default:
- usage();
- break;
- /* NOT REACHED */
- }
- }
-
- be = libusb20_be_alloc_default();
- if (be == NULL) {
- syslog(LOG_ERR, "libusb20_be_alloc_default() failed");
- return (-1);
- }
-
- if (find_device(be, bus, addr, &dev) < 0) {
- syslog(LOG_ERR, "ugen%d.%d is not recognized as " \
- "Atheros AR3011 based device " \
- "(possibly caused by lack of permissions)", bus, addr);
- return (-1);
- }
-
- if (download_firmware(dev, firmware) < 0) {
- syslog(LOG_ERR, "could not download %s firmare to ugen%d.%d",
- firmware, bus, addr);
- return (-1);
- }
-
- libusb20_be_free(be);
- closelog();
-
- return (0);
-}
-
-/*
- * Parse ugen name and extract device's bus and address
- */
-
-static int
-parse_ugen_name(char const *ugen, uint8_t *bus, uint8_t *addr)
-{
- char *ep;
-
- if (strncmp(ugen, "ugen", 4) != 0)
- return (-1);
-
- *bus = (uint8_t) strtoul(ugen + 4, &ep, 10);
- if (*ep != '.')
- return (-1);
-
- *addr = (uint8_t) strtoul(ep + 1, &ep, 10);
- if (*ep != '\0')
- return (-1);
-
- return (0);
-}
-
-/*
- * Find USB device
- */
-
-static int
-find_device(struct libusb20_backend *be, uint8_t bus, uint8_t addr,
- struct libusb20_device **dev)
-{
- struct LIBUSB20_DEVICE_DESC_DECODED *desc;
-
- *dev = NULL;
-
- while ((*dev = libusb20_be_device_foreach(be, *dev)) != NULL) {
- if (libusb20_dev_get_bus_number(*dev) != bus ||
- libusb20_dev_get_address(*dev) != addr)
- continue;
-
- desc = libusb20_dev_get_device_desc(*dev);
- if (desc == NULL)
- continue;
-
- if (desc->idVendor != vendor_id ||
- desc->idProduct != product_id)
- continue;
-
- break;
- }
-
- return ((*dev == NULL)? -1 : 0);
-}
-
-/*
- * Download firmware
- */
-
-static int
-download_firmware(struct libusb20_device *dev, char const *firmware)
-{
- struct libusb20_transfer *bulk;
- struct LIBUSB20_CONTROL_SETUP_DECODED req;
- int fd, n, error;
- uint8_t buf[ATH3KFW_MAX_BSIZE];
-
- error = -1;
-
- if (libusb20_dev_open(dev, 1) != 0) {
- syslog(LOG_ERR, "libusb20_dev_open() failed");
- return (error);
- }
-
- if ((bulk = libusb20_tr_get_pointer(dev, 0)) == NULL) {
- syslog(LOG_ERR, "libusb20_tr_get_pointer() failed");
- goto out;
- }
-
- if (libusb20_tr_open(bulk, ATH3KFW_MAX_BSIZE, 1, ATH3KFW_BULK_EP) != 0) {
- syslog(LOG_ERR, "libusb20_tr_open(%d, 1, %d) failed",
- ATH3KFW_MAX_BSIZE, ATH3KFW_BULK_EP);
- goto out;
- }
-
- if ((fd = open(firmware, O_RDONLY)) < 0) {
- syslog(LOG_ERR, "open(%s) failed. %s",
- firmware, strerror(errno));
- goto out1;
- }
-
- n = read(fd, buf, 20);
- if (n != 20) {
- syslog(LOG_ERR, "read(%s, 20) failed. %s",
- firmware, strerror(errno));
- goto out2;
- }
-
- LIBUSB20_INIT(LIBUSB20_CONTROL_SETUP, &req);
- req.bmRequestType = LIBUSB20_REQUEST_TYPE_VENDOR;
- req.bRequest = ATH3KFW_REQ_DFU_DNLOAD;
- req.wLength = 20;
-
- if (libusb20_dev_request_sync(dev, &req, buf, NULL, 5000, 0) != 0) {
- syslog(LOG_ERR, "libusb20_dev_request_sync() failed");
- goto out2;
- }
-
- for (;;) {
- n = read(fd, buf, sizeof(buf));
- if (n < 0) {
- syslog(LOG_ERR, "read(%s, %d) failed. %s",
- firmware, (int) sizeof(buf), strerror(errno));
- goto out2;
- }
- if (n == 0)
- break;
-
- libusb20_tr_setup_bulk(bulk, buf, n, 3000);
- libusb20_tr_start(bulk);
-
- while (libusb20_dev_process(dev) == 0) {
- if (libusb20_tr_pending(bulk) == 0)
- break;
-
- libusb20_dev_wait_process(dev, -1);
- }
-
- if (libusb20_tr_get_status(bulk) != 0) {
- syslog(LOG_ERR, "bulk transfer failed with status %d",
- libusb20_tr_get_status(bulk));
- goto out2;
- }
- }
-
- error = 0;
-out2:
- close(fd);
-out1:
- libusb20_tr_close(bulk);
-out:
- libusb20_dev_close(dev);
-
- return (error);
-}
-
-/*
- * Display usage and exit
- */
-
-static void
-usage(void)
-{
- printf(
-"Usage: %s -d ugenX.Y -f firmware_file\n"
-"Usage: %s -h\n" \
-"Where:\n" \
-"\t-d ugenX.Y ugen device name\n" \
-"\t-f firmware image firmware image file name for download\n" \
-"\t-v vendor_id vendor id\n" \
-"\t-p vendor_id product id\n" \
-"\t-h display this message\n", ATH3KFW, ATH3KFW);
-
- exit(255);
-}
-
diff --git a/usr.sbin/bluetooth/ath3kfw/main.c b/usr.sbin/bluetooth/ath3kfw/main.c
new file mode 100644
index 0000000..6ca5206
--- /dev/null
+++ b/usr.sbin/bluetooth/ath3kfw/main.c
@@ -0,0 +1,394 @@
+/*-
+ * Copyright (c) 2013 Adrian Chadd <adrian@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ * redistribution must be conditioned upon including a substantially
+ * similar Disclaimer requirement for further binary redistribution.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * $FreeBSD$
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <err.h>
+#include <fcntl.h>
+#include <libgen.h>
+#include <sys/stat.h>
+#include <sys/param.h>
+
+#include <libusb.h>
+
+#include "ath3k_fw.h"
+#include "ath3k_hw.h"
+#include "ath3k_dbg.h"
+
+#define _DEFAULT_ATH3K_FIRMWARE_PATH "/usr/share/firmware/ath3k/"
+
+int ath3k_do_debug = 0;
+int ath3k_do_info = 0;
+
+struct ath3k_devid {
+ uint16_t product_id;
+ uint16_t vendor_id;
+ int is_3012;
+};
+
+static struct ath3k_devid ath3k_list[] = {
+
+ /* Atheros AR3012 with sflash firmware*/
+ { .vendor_id = 0x0489, .product_id = 0xe04e, .is_3012 = 1 },
+ { .vendor_id = 0x0489, .product_id = 0xe04d, .is_3012 = 1 },
+ { .vendor_id = 0x0489, .product_id = 0xe056, .is_3012 = 1 },
+ { .vendor_id = 0x0489, .product_id = 0xe057, .is_3012 = 1 },
+ { .vendor_id = 0x0489, .product_id = 0xe05f, .is_3012 = 1 },
+ { .vendor_id = 0x04c5, .product_id = 0x1330, .is_3012 = 1 },
+ { .vendor_id = 0x04ca, .product_id = 0x3004, .is_3012 = 1 },
+ { .vendor_id = 0x04ca, .product_id = 0x3005, .is_3012 = 1 },
+ { .vendor_id = 0x04ca, .product_id = 0x3006, .is_3012 = 1 },
+ { .vendor_id = 0x04ca, .product_id = 0x3008, .is_3012 = 1 },
+ { .vendor_id = 0x04ca, .product_id = 0x300b, .is_3012 = 1 },
+ { .vendor_id = 0x0930, .product_id = 0x0219, .is_3012 = 1 },
+ { .vendor_id = 0x0930, .product_id = 0x0220, .is_3012 = 1 },
+ { .vendor_id = 0x0b05, .product_id = 0x17d0, .is_3012 = 1 },
+ { .vendor_id = 0x0CF3, .product_id = 0x0036, .is_3012 = 1 },
+ { .vendor_id = 0x0cf3, .product_id = 0x3004, .is_3012 = 1 },
+ { .vendor_id = 0x0cf3, .product_id = 0x3005, .is_3012 = 1 },
+ { .vendor_id = 0x0cf3, .product_id = 0x3008, .is_3012 = 1 },
+ { .vendor_id = 0x0cf3, .product_id = 0x311D, .is_3012 = 1 },
+ { .vendor_id = 0x0cf3, .product_id = 0x311E, .is_3012 = 1 },
+ { .vendor_id = 0x0cf3, .product_id = 0x311F, .is_3012 = 1 },
+ { .vendor_id = 0x0cf3, .product_id = 0x3121, .is_3012 = 1 },
+ { .vendor_id = 0x0CF3, .product_id = 0x817a, .is_3012 = 1 },
+ { .vendor_id = 0x0cf3, .product_id = 0xe004, .is_3012 = 1 },
+ { .vendor_id = 0x0cf3, .product_id = 0xe005, .is_3012 = 1 },
+ { .vendor_id = 0x0cf3, .product_id = 0xe003, .is_3012 = 1 },
+ { .vendor_id = 0x13d3, .product_id = 0x3362, .is_3012 = 1 },
+ { .vendor_id = 0x13d3, .product_id = 0x3375, .is_3012 = 1 },
+ { .vendor_id = 0x13d3, .product_id = 0x3393, .is_3012 = 1 },
+ { .vendor_id = 0x13d3, .product_id = 0x3402, .is_3012 = 1 },
+
+ /* Atheros AR5BBU22 with sflash firmware */
+ { .vendor_id = 0x0489, .product_id = 0xE036, .is_3012 = 1 },
+ { .vendor_id = 0x0489, .product_id = 0xE03C, .is_3012 = 1 },
+};
+
+static int
+ath3k_is_3012(struct libusb_device_descriptor *d)
+{
+ int i;
+
+ /* Search looking for whether it's an AR3012 */
+ for (i = 0; i < (int) nitems(ath3k_list); i++) {
+ if ((ath3k_list[i].product_id == d->idProduct) &&
+ (ath3k_list[i].vendor_id == d->idVendor)) {
+ fprintf(stderr, "%s: found AR3012\n", __func__);
+ return (ath3k_list[i].is_3012);
+ }
+ }
+
+ /* Not found */
+ return (0);
+}
+
+static libusb_device *
+ath3k_find_device(libusb_context *ctx, int bus_id, int dev_id)
+{
+ libusb_device **list, *dev = NULL, *found = NULL;
+ ssize_t cnt, i;
+
+ cnt = libusb_get_device_list(ctx, &list);
+ if (cnt < 0) {
+ ath3k_err("%s: libusb_get_device_list() failed: code %lld\n",
+ __func__,
+ (long long int) cnt);
+ return (NULL);
+ }
+
+ /*
+ * XXX TODO: match on the vendor/product id too!
+ */
+ for (i = 0; i < cnt; i++) {
+ dev = list[i];
+ if (bus_id == libusb_get_bus_number(dev) &&
+ dev_id == libusb_get_device_address(dev)) {
+ /*
+ * Take a reference so it's not freed later on.
+ */
+ found = libusb_ref_device(dev);
+ break;
+ }
+ }
+
+ libusb_free_device_list(list, 1);
+ return (found);
+}
+
+static int
+ath3k_init_ar3012(libusb_device_handle *hdl, const char *fw_path)
+{
+ int ret;
+
+ ret = ath3k_load_patch(hdl, fw_path);
+ if (ret < 0) {
+ ath3k_err("Loading patch file failed\n");
+ return (ret);
+ }
+
+ ret = ath3k_load_syscfg(hdl, fw_path);
+ if (ret < 0) {
+ ath3k_err("Loading sysconfig file failed\n");
+ return (ret);
+ }
+
+ ret = ath3k_set_normal_mode(hdl);
+ if (ret < 0) {
+ ath3k_err("Set normal mode failed\n");
+ return (ret);
+ }
+
+ ath3k_switch_pid(hdl);
+ return (0);
+}
+
+static int
+ath3k_init_firmware(libusb_device_handle *hdl, const char *file_prefix)
+{
+ struct ath3k_firmware fw;
+ char fwname[FILENAME_MAX];
+ int ret;
+
+ /* XXX path info? */
+ snprintf(fwname, FILENAME_MAX, "%s/ath3k-1.fw", file_prefix);
+
+ ath3k_debug("%s: loading ath3k-1.fw\n", __func__);
+
+ /* Read in the firmware */
+ if (ath3k_fw_read(&fw, fwname) <= 0) {
+ fprintf(stderr, "%s: ath3k_fw_read() failed\n",
+ __func__);
+ return (-1);
+ }
+
+ /* Load in the firmware */
+ ret = ath3k_load_fwfile(hdl, &fw);
+
+ /* free it */
+ ath3k_fw_free(&fw);
+
+ return (0);
+}
+
+/*
+ * Parse ugen name and extract device's bus and address
+ */
+
+static int
+parse_ugen_name(char const *ugen, uint8_t *bus, uint8_t *addr)
+{
+ char *ep;
+
+ if (strncmp(ugen, "ugen", 4) != 0)
+ return (-1);
+
+ *bus = (uint8_t) strtoul(ugen + 4, &ep, 10);
+ if (*ep != '.')
+ return (-1);
+
+ *addr = (uint8_t) strtoul(ep + 1, &ep, 10);
+ if (*ep != '\0')
+ return (-1);
+
+ return (0);
+}
+
+static void
+usage(void)
+{
+ fprintf(stderr,
+ "Usage: ath3kfw (-D) -d ugenX.Y (-f firmware path) (-I)\n");
+ fprintf(stderr, " -D: enable debugging\n");
+ fprintf(stderr, " -d: device to operate upon\n");
+ fprintf(stderr, " -f: firmware path, if not default\n");
+ fprintf(stderr, " -I: enable informational output\n");
+ exit(127);
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct libusb_device_descriptor d;
+ libusb_context *ctx;
+ libusb_device *dev;
+ libusb_device_handle *hdl;
+ unsigned char state;
+ struct ath3k_version ver;
+ int r;
+ uint8_t bus_id = 0, dev_id = 0;
+ int devid_set = 0;
+ int n;
+ char *firmware_path = NULL;
+ int is_3012 = 0;
+
+ /* libusb setup */
+ r = libusb_init(&ctx);
+ if (r != 0) {
+ ath3k_err("%s: libusb_init failed: code %d\n",
+ argv[0],
+ r);
+ exit(127);
+ }
+
+ /* Enable debugging, just because */
+ libusb_set_debug(ctx, 3);
+
+ /* Parse command line arguments */
+ while ((n = getopt(argc, argv, "Dd:f:hIm:p:v:")) != -1) {
+ switch (n) {
+ case 'd': /* ugen device name */
+ devid_set = 1;
+ if (parse_ugen_name(optarg, &bus_id, &dev_id) < 0)
+ usage();
+ break;
+ case 'D':
+ ath3k_do_debug = 1;
+ break;
+ case 'f': /* firmware path */
+ if (firmware_path)
+ free(firmware_path);
+ firmware_path = strdup(optarg);
+ break;
+ case 'I':
+ ath3k_do_info = 1;
+ break;
+ case 'h':
+ default:
+ usage();
+ break;
+ /* NOT REACHED */
+ }
+ }
+
+ /* Ensure the devid was given! */
+ if (devid_set == 0) {
+ usage();
+ /* NOTREACHED */
+ }
+
+ ath3k_debug("%s: opening dev %d.%d\n",
+ basename(argv[0]),
+ (int) bus_id,
+ (int) dev_id);
+
+ /* Find a device based on the bus/dev id */
+ dev = ath3k_find_device(ctx, bus_id, dev_id);
+ if (dev == NULL) {
+ ath3k_err("%s: device not found\n", __func__);
+ /* XXX cleanup? */
+ exit(1);
+ }
+
+ /* Get the device descriptor for this device entry */
+ r = libusb_get_device_descriptor(dev, &d);
+ if (r != 0) {
+ warn("%s: libusb_get_device_descriptor: %s\n",
+ __func__,
+ libusb_strerror(r));
+ exit(1);
+ }
+
+ /* See if its an AR3012 */
+ if (ath3k_is_3012(&d)) {
+ is_3012 = 1;
+
+ /* If it's bcdDevice > 1, don't attach */
+ if (d.bcdDevice > 0x0001) {
+ ath3k_debug("%s: AR3012; bcdDevice=%d, exiting\n",
+ __func__,
+ d.bcdDevice);
+ exit(0);
+ }
+ }
+
+ /* XXX enforce that bInterfaceNumber is 0 */
+
+ /* XXX enforce the device/product id if they're non-zero */
+
+ /* Grab device handle */
+ r = libusb_open(dev, &hdl);
+ if (r != 0) {
+ ath3k_err("%s: libusb_open() failed: code %d\n", __func__, r);
+ /* XXX cleanup? */
+ exit(1);
+ }
+
+ /*
+ * Get the initial NIC state.
+ */
+ r = ath3k_get_state(hdl, &state);
+ if (r == 0) {
+ ath3k_err("%s: ath3k_get_state() failed!\n", __func__);
+ /* XXX cleanup? */
+ exit(1);
+ }
+ ath3k_debug("%s: state=0x%02x\n",
+ __func__,
+ (int) state);
+
+ /* And the version */
+ r = ath3k_get_version(hdl, &ver);
+ if (r == 0) {
+ ath3k_err("%s: ath3k_get_version() failed!\n", __func__);
+ /* XXX cleanup? */
+ exit(1);
+ }
+ ath3k_info("ROM version: %d, build version: %d, ram version: %d, "
+ "ref clock=%d\n",
+ ver.rom_version,
+ ver.build_version,
+ ver.ram_version,
+ ver.ref_clock);
+
+ /* Default the firmware path */
+ if (firmware_path == NULL)
+ firmware_path = strdup(_DEFAULT_ATH3K_FIRMWARE_PATH);
+
+ if (is_3012) {
+ (void) ath3k_init_ar3012(hdl, firmware_path);
+ } else {
+ (void) ath3k_init_firmware(hdl, firmware_path);
+ }
+
+ /* Shutdown */
+ libusb_close(hdl);
+ hdl = NULL;
+
+ libusb_unref_device(dev);
+ dev = NULL;
+
+ libusb_exit(ctx);
+ ctx = NULL;
+}
diff --git a/usr.sbin/bsdinstall/scripts/wlanconfig b/usr.sbin/bsdinstall/scripts/wlanconfig
index 4eba2b0..c2af45a 100755
--- a/usr.sbin/bsdinstall/scripts/wlanconfig
+++ b/usr.sbin/bsdinstall/scripts/wlanconfig
@@ -31,6 +31,7 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
############################################################ MAIN
@@ -58,40 +59,190 @@ if [ $? -ne 0 -a -z $BSDINSTALL_CONFIGCURRENT ]; then
exit 1
fi
-output=$( wpa_cli scan 2>&1 )
-f_dprintf "%s" "$output"
-dialog --backtitle "FreeBSD Installer" --title "Scanning" --ok-label "Skip" \
- --pause "Waiting 5 seconds to scan for wireless networks..." \
- 9 40 5 || exit 1
-
-SCAN_RESULTS=`wpa_cli scan_results`
-NETWORKS=`echo "$SCAN_RESULTS" | awk -F '\t' \
- '/..:..:..:..:..:../ {if (length($5) > 0) printf("\"%s\"\t%s\n", $5, $4);}' |
- sort | uniq`
-
-if [ -z "$NETWORKS" ]; then
- dialog --backtitle "FreeBSD Installer" --title "Error" \
- --yesno "No wireless networks were found. Rescan?" 0 0 && \
- exec $0 $@
- exit 1
+country_set()
+{
+ local error_str=
+ local iface_up=
+ local ifconfig_args=
+
+ # Setup what was selected
+ # NB: do not change order of arguments (or regdomain will be ignored)
+ if [ ! -z "$2" ]; then
+ ifconfig_args="${ifconfig_args}country $2"
+ fi
+ if [ ! -z "$1" ]; then
+ if [ ! -z "$2" ]; then
+ ifconfig_args="${ifconfig_args} "
+ fi
+ ifconfig_args="${ifconfig_args}regdomain $1"
+ fi
+ if [ -z "$ifconfig_args" ]; then
+ # Nothing to do (everything was skipped)
+ return $SUCCESS
+ fi
+
+ # Regdomain/country cannot be applied while interface is running
+ iface_up=`ifconfig -lu | grep -w $WLAN_IFACE`
+ if [ ! -z "$iface_up" ]; then
+ ifconfig $WLAN_IFACE down
+ fi
+ error_str=`ifconfig $WLAN_IFACE $ifconfig_args 2>&1 | \
+ sed 's/ifconfig: //'`
+ if [ ! -z "$iface_up" ]; then
+ # Restart wpa_supplicant(8) (should not fail).
+ wpa_supplicant -B -i $WLAN_IFACE -c \
+ $BSDINSTALL_TMPETC/wpa_supplicant.conf
+ fi
+ if [ ! -z "$error_str" ]; then
+ dialog --backtitle "FreeBSD Installer" --title "Error" \
+ --yes-label Change --no-label Ignore --yesno \
+ "Error while applying chosen settings ($error_str)" 0 0
+ if [ $? -eq $DIALOG_OK ]; then
+ return $FAILURE # Restart
+ else
+ return $SUCCESS # Skip
+ fi
+ else
+ : > $BSDINSTALL_TMPETC/rc.conf.net.wlan
+ echo create_args_$WLAN_IFACE=\"$ifconfig_args\" >> \
+ $BSDINSTALL_TMPETC/rc.conf.net.wlan
+ fi
+
+ return $SUCCESS
+}
+
+dialog_country_select()
+{
+ local input=
+ local def_item_regdomain=
+ local def_item_country=
+ local regdomains=
+ local countries=
+ local regdomain=
+ local country=
+
+ # Parse available countries/regdomains
+ input=`ifconfig $WLAN_IFACE list countries | sed 's/DEBUG//gi'`
+ regdomains=`echo $input | sed 's/.*domains://' | tr ' ' '\n' | \
+ sort | tr '\n' ' '`
+ countries=`echo $input | sed 's/Country codes://' | \
+ sed 's/Regulatory.*//' | awk '{
+ for (i = 1; i <= NF; i++) {
+ printf "%s", $i
+ if (match($i, "[[:lower:]]"))
+ if (match($(i+1), "[[:lower:]]"))
+ printf "\\\\\\ "
+ else
+ printf "\n"
+ else
+ printf " "
+ }
+ }' | sort -k 2 | tr '\n' ' '`
+
+ # Change default cursor position (if required).
+ if [ "$1" != "<not selected>" ]; then
+ def_item_regdomain="--default-item $1"
+ fi
+ if [ "$2" != "<not selected>" ]; then
+ def_item_country="--default-item $2"
+ fi
+
+ f_dialog_menu_size height width rows \"Regdomain selection\" \
+ \"FreeBSD Installer\" \"Select your regdomain.\" \
+ \"\" $regdomains
+ regdomain=`sh -c "dialog \
+ --backtitle \"FreeBSD Installer\" \
+ --title \"Regdomain selection\" \
+ --cancel-label \"Skip\" \
+ $def_item_regdomain \
+ --no-items \
+ --stdout \
+ --menu \"Select your regdomain.\" \
+ $height $width $rows $regdomains"`
+
+ f_dialog_menu_size height width rows \"Country selection\" \
+ \"FreeBSD Installer\" \"Select your country.\" \
+ \"\" $countries
+ country=`sh -c "dialog \
+ --backtitle \"FreeBSD Installer\" \
+ --title \"Country selection\" \
+ --cancel-label \"Skip\" \
+ $def_item_country \
+ --stdout \
+ --menu \"Select your country.\" \
+ $height $width $rows $countries"`
+
+ country_set "$regdomain" "$country"
+
+ return $?
+}
+
+# There is no way to check country/regdomain without (possible)
+# interface state modification
+if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then
+ # Get current country/regdomain for selected interface
+ WLAN_IFACE=`wpa_cli ifname | tail -n 1`
+ INPUT=`ifconfig $WLAN_IFACE list regdomain | head -n 1`
+ DEF_REGDOMAIN=`echo $INPUT | cut -w -f 2`
+ if [ "$DEF_REGDOMAIN" = "0" ]; then
+ DEF_REGDOMAIN="<not selected>"
+ fi
+ DEF_COUNTRY=`echo $INPUT | cut -w -f 4`
+ if [ "$DEF_COUNTRY" = "0" ]; then
+ DEF_COUNTRY="<not selected>"
+ fi
+ dialog --backtitle "FreeBSD Installer" --title "Regdomain/country" \
+ --yesno "Change regdomain/country (now \
+ $DEF_REGDOMAIN/$DEF_COUNTRY)?" 0 0
+ if [ $? -eq 0 ]; then
+ while :
+ do
+ dialog_country_select "$DEF_REGDOMAIN" "$DEF_COUNTRY"
+ if [ $? -eq $SUCCESS ]; then
+ break
+ fi
+ done
+ fi
fi
-exec 3>&1
-NETWORK=`sh -c "dialog --extra-button --extra-label \"Rescan\" \
- --backtitle \"FreeBSD Installer\" --title \"Network Selection\" --menu \
- \"Select a wireless network to connect to.\" 0 0 0 \
- $(echo $NETWORKS | tr '\n' ' ')" 2>&1 1>&3`
-case $? in
-0) # OK
- ;;
-1) # Cancel
- exit 1
- ;;
-3) # Rescan
- exec $0 $@
- ;;
-esac
-exec 3>&-
+while :
+do
+ output=$( wpa_cli scan 2>&1 )
+ f_dprintf "%s" "$output"
+ dialog --backtitle "FreeBSD Installer" --title "Scanning" \
+ --ok-label "Skip" \
+ --pause "Waiting 5 seconds to scan for wireless networks..." \
+ 9 40 5 || exit 1
+
+ SCAN_RESULTS=`wpa_cli scan_results`
+ NETWORKS=`echo "$SCAN_RESULTS" | awk -F '\t' \
+ '/..:..:..:..:..:../ {if (length($5) > 0) \
+ printf("\"%s\"\t%s\n", $5, $4);}' | sort | uniq`
+
+ if [ -z "$NETWORKS" ]; then
+ dialog --backtitle "FreeBSD Installer" --title "Error" \
+ --yesno "No wireless networks were found. Rescan?" 0 0 && \
+ continue
+ exit 1
+ fi
+
+ exec 3>&1
+ NETWORK=`sh -c "dialog --extra-button --extra-label \"Rescan\" \
+ --backtitle \"FreeBSD Installer\" --title \"Network Selection\" \
+ --menu \"Select a wireless network to connect to.\" 0 0 0 \
+ $(echo $NETWORKS | tr '\n' ' ')" 2>&1 1>&3`
+ case $? in
+ 0) # OK
+ break
+ ;;
+ 1) # Cancel
+ exit 1
+ ;;
+ 3) # Rescan
+ ;;
+ esac
+ exec 3>&-
+done
ENCRYPTION=`echo "$NETWORKS" | awk -F '\t' \
"/^\"$NETWORK\"\t/ {printf(\"%s\n\", \\\$2 );}"`
diff --git a/usr.sbin/bsdinstall/scripts/zfsboot b/usr.sbin/bsdinstall/scripts/zfsboot
index 80e0614..db28284 100755
--- a/usr.sbin/bsdinstall/scripts/zfsboot
+++ b/usr.sbin/bsdinstall/scripts/zfsboot
@@ -1194,11 +1194,6 @@ zfs_create_boot()
f_eval_catch $funcname chmod "$CHMOD_MODE" \
go-wrx "$bootpool/$zroot_key" ||
return $FAILURE
- else
- # Clean up
- f_eval_catch $funcname zfs "$ZFS_UNMOUNT" \
- "$bootpool_name" || return $FAILURE
- f_eval_catch -d $funcname umount "$UMOUNT" /mnt # tmpfs
fi
fi
@@ -1409,6 +1404,11 @@ zfs_create_boot()
"cachefile=\"$BSDINSTALL_CHROOT/boot/zfs/zpool.cache\"" \
"$zroot_name" || return $FAILURE
+ if [ "$ZFSBOOT_BOOT_POOL" ]; then
+ f_eval_catch $funcname printf "$PRINTF_CONF" \
+ vfs.root.mountfrom "\"zfs:$zroot_name/$zroot_bootfs\"" \
+ $BSDINSTALL_TMPBOOT/loader.conf.root || return $FAILURE
+ fi
#
# Set canmount=noauto so that the default Boot Environment (BE) does not
# get mounted if a different BE is selected from the beastie menu
@@ -1486,10 +1486,6 @@ zfs_create_boot()
$BSDINSTALL_TMPBOOT/loader.conf.zfs ||
return $FAILURE
done
- f_eval_catch $funcname printf "$PRINTF_CONF" vfs.root.mountfrom \
- "\"zfs:$zroot_name/$zroot_bootfs\"" \
- $BSDINSTALL_TMPBOOT/loader.conf.root || return $FAILURE
-
return $SUCCESS
}
diff --git a/usr.sbin/ctld/ctld.h b/usr.sbin/ctld/ctld.h
index 705da33..20864a7 100644
--- a/usr.sbin/ctld/ctld.h
+++ b/usr.sbin/ctld/ctld.h
@@ -49,6 +49,7 @@
#define MAX_NAME_LEN 223
#define MAX_DATA_SEGMENT_LENGTH (128 * 1024)
#define MAX_BURST_LENGTH 16776192
+#define FIRST_BURST_LENGTH (128 * 1024)
#define SOCKBUF_SIZE 1048576
struct auth {
diff --git a/usr.sbin/ctld/login.c b/usr.sbin/ctld/login.c
index c450b5c..a7a4f7d 100644
--- a/usr.sbin/ctld/login.c
+++ b/usr.sbin/ctld/login.c
@@ -574,13 +574,12 @@ login_negotiate_key(struct pdu *request, const char *name,
tmp = strtoul(value, NULL, 10);
if (tmp <= 0) {
login_send_error(request, 0x02, 0x00);
- log_errx(1, "received invalid "
- "FirstBurstLength");
+ log_errx(1, "received invalid FirstBurstLength");
}
- if (tmp > conn->conn_data_segment_limit) {
- log_debugx("capping FirstBurstLength from %zd to %zd",
- tmp, conn->conn_data_segment_limit);
- tmp = conn->conn_data_segment_limit;
+ if (tmp > FIRST_BURST_LENGTH) {
+ log_debugx("capping FirstBurstLength from %zd to %d",
+ tmp, FIRST_BURST_LENGTH);
+ tmp = FIRST_BURST_LENGTH;
}
conn->conn_first_burst_length = tmp;
keys_add_int(response_keys, name, tmp);
diff --git a/usr.sbin/extattr/tests/extattr_test.sh b/usr.sbin/extattr/tests/extattr_test.sh
index d9c0c71..33d0a82 100755
--- a/usr.sbin/extattr/tests/extattr_test.sh
+++ b/usr.sbin/extattr/tests/extattr_test.sh
@@ -30,6 +30,7 @@ bad_namespace_head() {
atf_set "descr" "Can't set attributes for nonexistent namespaces"
}
bad_namespace_body() {
+ check_fs
touch foo
atf_check -s not-exit:0 -e match:"Invalid argument" \
setextattr badnamespace myattr X foo
@@ -42,6 +43,7 @@ hex_head() {
atf_set "descr" "Set and get attribute values in hexadecimal"
}
hex_body() {
+ check_fs
touch foo
atf_check -s exit:0 -o empty setextattr user myattr XYZ foo
atf_check -s exit:0 -o inline:"58 59 5a\n" \
@@ -53,6 +55,7 @@ hex_nonascii_head() {
atf_set "descr" "Get binary attribute values in hexadecimal"
}
hex_nonascii_body() {
+ check_fs
touch foo
BINSTUFF=`echo $'\x20\x30\x40\x55\x66\x70\x81\xa2\xb3\xee\xff'`
atf_check -s exit:0 -o empty setextattr user myattr "$BINSTUFF" foo
@@ -66,6 +69,7 @@ long_name_head() {
atf_set "descr" "A maximum length attribute name"
}
long_name_body() {
+ check_fs
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=208965
atf_expect_fail "BUG 208965 extattr(2) doesn't allow maxlen attr names"
@@ -84,6 +88,7 @@ loud_head() {
atf_set "descr" "Loud (non -q) output for each command"
}
loud_body() {
+ check_fs
touch foo
# setextattr(8) and friends print hard tabs. Use printf to convert
# them to spaces before checking the output.
@@ -101,6 +106,7 @@ noattrs_head() {
atf_set "descr" "A file with no extended attributes"
}
noattrs_body() {
+ check_fs
touch foo
atf_check -s exit:0 -o empty lsextattr -q user foo
}
@@ -110,6 +116,7 @@ nonexistent_file_head() {
atf_set "descr" "A file that does not exist"
}
nonexistent_file_body() {
+ check_fs
atf_check -s exit:1 -e match:"No such file or directory" \
lsextattr user foo
atf_check -s exit:1 -e match:"No such file or directory" \
@@ -125,6 +132,7 @@ null_head() {
atf_set "descr" "NUL-terminate an attribute value"
}
null_body() {
+ check_fs
touch foo
atf_check -s exit:0 -o empty setextattr -n user myattr myvalue foo
atf_check -s exit:0 -o inline:"myvalue\0\n" getextattr -q user myattr foo
@@ -135,6 +143,7 @@ one_user_attr_head() {
atf_set "descr" "A file with one extended attribute"
}
one_user_attr_body() {
+ check_fs
touch foo
atf_check -s exit:0 -o empty setextattr user myattr myvalue foo
atf_check -s exit:0 -o inline:"myattr\n" lsextattr -q user foo
@@ -149,6 +158,7 @@ one_system_attr_head() {
atf_set "require.user" "root"
}
one_system_attr_body() {
+ check_fs
touch foo
atf_check -s exit:0 -o empty setextattr system myattr myvalue foo
atf_check -s exit:0 -o inline:"myattr\n" lsextattr -q system foo
@@ -162,6 +172,7 @@ stdin_head() {
atf_set "descr" "Set attribute value from stdin"
}
stdin_body() {
+ check_fs
dd if=/dev/random of=infile bs=1k count=8
touch foo
setextattr -i user myattr foo < infile || atf_fail "setextattr failed"
@@ -175,6 +186,7 @@ stringify_head() {
atf_set "descr" "Stringify the output of getextattr"
}
stringify_body() {
+ check_fs
touch foo
atf_check -s exit:0 -o empty setextattr user myattr "my value" foo
atf_check -s exit:0 -o inline:"\"my\\\040value\"\n" \
@@ -186,6 +198,7 @@ symlink_head() {
atf_set "descr" "A symlink to an ordinary file"
}
symlink_body() {
+ check_fs
touch foo
ln -s foo foolink
atf_check -s exit:0 -o empty setextattr user myattr myvalue foolink
@@ -199,6 +212,7 @@ symlink_nofollow_head() {
atf_set "descr" "Operating directly on a symlink"
}
symlink_nofollow_body() {
+ check_fs
touch foo
ln -s foo foolink
# Check that with -h we can operate directly on the link
@@ -221,6 +235,7 @@ system_and_user_attrs_head() {
atf_set "require.user" "root"
}
system_and_user_attrs_body() {
+ check_fs
touch foo
atf_check -s exit:0 -o empty setextattr user userattr userval foo
atf_check -s exit:0 -o empty setextattr system sysattr sysval foo
@@ -240,6 +255,7 @@ two_files_head() {
atf_set "descr" "Manipulate two files"
}
two_files_body() {
+ check_fs
touch foo bar
atf_check -s exit:0 -o empty setextattr user myattr myvalue foo bar
atf_check -s exit:0 -o inline:"foo\tmyattr\nbar\tmyattr\n" \
@@ -256,6 +272,7 @@ two_files_force_head() {
atf_set "descr" "Manipulate two files. The first does not exist"
}
two_files_force_body() {
+ check_fs
touch bar
atf_check -s exit:1 -e match:"No such file or directory" \
setextattr user myattr myvalue foo bar
@@ -281,6 +298,7 @@ two_user_attrs_head() {
atf_set "descr" "A file with two extended attributes"
}
two_user_attrs_body() {
+ check_fs
touch foo
atf_check -s exit:0 -o empty setextattr user myattr1 myvalue1 foo
atf_check -s exit:0 -o empty setextattr user myattr2 myvalue2 foo
@@ -305,6 +323,7 @@ unprivileged_user_cannot_set_system_attr_head() {
atf_set "require.user" "unprivileged"
}
unprivileged_user_cannot_set_system_attr_body() {
+ check_fs
touch foo
atf_check -s exit:1 -e match:"Operation not permitted" \
setextattr system myattr myvalue foo
@@ -333,3 +352,11 @@ atf_init_test_cases() {
atf_add_test_case two_user_attrs
atf_add_test_case unprivileged_user_cannot_set_system_attr
}
+
+check_fs() {
+ case `df -T . | tail -n 1 | cut -wf 2` in
+ "ufs") ;; # UFS is fine
+ "zfs") ;; # ZFS is fine
+ "tmpfs") atf_skip "tmpfs does not support extended attributes";;
+ esac
+}
diff --git a/usr.sbin/iscsid/iscsid.h b/usr.sbin/iscsid/iscsid.h
index 0c37ca3..df4b8ec 100644
--- a/usr.sbin/iscsid/iscsid.h
+++ b/usr.sbin/iscsid/iscsid.h
@@ -42,8 +42,10 @@
#define CONN_DIGEST_NONE 0
#define CONN_DIGEST_CRC32C 1
-#define CONN_MUTUAL_CHALLENGE_LEN 1024
+#define CONN_MUTUAL_CHALLENGE_LEN 1024
#define SOCKBUF_SIZE 1048576
+#define MAX_BURST_LENGTH (256 * 1024)
+#define FIRST_BURST_LENGTH (128 * 1024)
struct connection {
int conn_iscsi_fd;
diff --git a/usr.sbin/iscsid/login.c b/usr.sbin/iscsid/login.c
index 6abb9d6..c2a8e06 100644
--- a/usr.sbin/iscsid/login.c
+++ b/usr.sbin/iscsid/login.c
@@ -395,16 +395,24 @@ login_negotiate_key(struct connection *conn, const char *name,
}
conn->conn_max_data_segment_length = tmp;
} else if (strcmp(name, "MaxBurstLength") == 0) {
- if (conn->conn_immediate_data) {
- tmp = strtoul(value, NULL, 10);
- if (tmp <= 0)
- log_errx(1, "received invalid MaxBurstLength");
- conn->conn_max_burst_length = tmp;
+ tmp = strtoul(value, NULL, 10);
+ if (tmp <= 0)
+ log_errx(1, "received invalid MaxBurstLength");
+ if (tmp > MAX_BURST_LENGTH) {
+ log_debugx("capping MaxBurstLength "
+ "from %d to %d", tmp, MAX_BURST_LENGTH);
+ tmp = MAX_BURST_LENGTH;
}
+ conn->conn_max_burst_length = tmp;
} else if (strcmp(name, "FirstBurstLength") == 0) {
tmp = strtoul(value, NULL, 10);
if (tmp <= 0)
log_errx(1, "received invalid FirstBurstLength");
+ if (tmp > FIRST_BURST_LENGTH) {
+ log_debugx("capping FirstBurstLength "
+ "from %d to %d", tmp, FIRST_BURST_LENGTH);
+ tmp = FIRST_BURST_LENGTH;
+ }
conn->conn_first_burst_length = tmp;
} else if (strcmp(name, "DefaultTime2Wait") == 0) {
/* Ignore */
@@ -489,10 +497,8 @@ login_negotiate(struct connection *conn)
keys_add(request_keys, "DataDigest", "None");
keys_add(request_keys, "ImmediateData", "Yes");
- keys_add_int(request_keys, "MaxBurstLength",
- 2 * conn->conn_limits.isl_max_data_segment_length);
- keys_add_int(request_keys, "FirstBurstLength",
- conn->conn_limits.isl_max_data_segment_length);
+ keys_add_int(request_keys, "MaxBurstLength", MAX_BURST_LENGTH);
+ keys_add_int(request_keys, "FirstBurstLength", FIRST_BURST_LENGTH);
keys_add(request_keys, "InitialR2T", "Yes");
keys_add(request_keys, "MaxOutstandingR2T", "1");
if (conn->conn_conf.isc_iser == 1) {
diff --git a/usr.sbin/makefs/cd9660.c b/usr.sbin/makefs/cd9660.c
index 3f55b8d..5d85a2f 100644
--- a/usr.sbin/makefs/cd9660.c
+++ b/usr.sbin/makefs/cd9660.c
@@ -442,7 +442,7 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts)
*/
void
cd9660_makefs(const char *image, const char *dir, fsnode *root,
- fsinfo_t *fsopts)
+ fsinfo_t *fsopts)
{
int64_t startoffset;
int numDirectories;
@@ -619,7 +619,7 @@ typedef int (*cd9660node_func)(cd9660node *);
static void
cd9660_finalize_PVD(void)
{
- time_t tim;
+ time_t tstamp = stampst.st_ino ? stampst.st_mtime : time(NULL);
/* root should be a fixed size of 34 bytes since it has no name */
memcpy(diskStructure.primaryDescriptor.root_directory_record,
@@ -668,26 +668,26 @@ cd9660_finalize_PVD(void)
diskStructure.primaryDescriptor.bibliographic_file_id, 37);
/* Setup dates */
- time(&tim);
cd9660_time_8426(
(unsigned char *)diskStructure.primaryDescriptor.creation_date,
- tim);
+ tstamp);
cd9660_time_8426(
(unsigned char *)diskStructure.primaryDescriptor.modification_date,
- tim);
+ tstamp);
- /*
- cd9660_set_date(diskStructure.primaryDescriptor.expiration_date, now);
- */
+#if 0
+ cd9660_set_date(diskStructure.primaryDescriptor.expiration_date,
+ tstamp);
+#endif
memset(diskStructure.primaryDescriptor.expiration_date, '0', 16);
diskStructure.primaryDescriptor.expiration_date[16] = 0;
cd9660_time_8426(
(unsigned char *)diskStructure.primaryDescriptor.effective_date,
- tim);
+ tstamp);
/* make this sane */
cd9660_time_915(diskStructure.rootNode->dot_record->isoDirRecord->date,
- tim);
+ tstamp);
}
static void
@@ -808,7 +808,7 @@ cd9660_fill_extended_attribute_record(cd9660node *node)
static int
cd9660_translate_node_common(cd9660node *newnode)
{
- time_t tim;
+ time_t tstamp = stampst.st_ino ? stampst.st_mtime : time(NULL);
int test;
u_char flag;
char temp[ISO_FILENAME_MAXLENGTH_WITH_PADDING];
@@ -829,9 +829,8 @@ cd9660_translate_node_common(cd9660node *newnode)
/* Set the various dates */
/* If we want to use the current date and time */
- time(&tim);
- cd9660_time_915(newnode->isoDirRecord->date, tim);
+ cd9660_time_915(newnode->isoDirRecord->date, tstamp);
cd9660_bothendian_dword(newnode->fileDataLength,
newnode->isoDirRecord->size);
@@ -876,7 +875,8 @@ cd9660_translate_node(fsnode *node, cd9660node *newnode)
return 0;
/* Finally, overwrite some of the values that are set by default */
- cd9660_time_915(newnode->isoDirRecord->date, node->inode->st.st_mtime);
+ cd9660_time_915(newnode->isoDirRecord->date,
+ stampst.st_ino ? stampst.st_mtime : node->inode->st.st_mtime);
return 1;
}
@@ -1261,6 +1261,8 @@ cd9660_rrip_move_directory(cd9660node *dir)
diskStructure.rootNode, dir);
if (diskStructure.rr_moved_dir == NULL)
return 0;
+ cd9660_time_915(diskStructure.rr_moved_dir->isoDirRecord->date,
+ stampst.st_ino ? stampst.st_mtime : start_time.tv_sec);
}
/* Create a file with the same ORIGINAL name */
diff --git a/usr.sbin/makefs/ffs.c b/usr.sbin/makefs/ffs.c
index dc749dc..6a89442 100644
--- a/usr.sbin/makefs/ffs.c
+++ b/usr.sbin/makefs/ffs.c
@@ -482,6 +482,7 @@ ffs_create_image(const char *image, fsinfo_t *fsopts)
char *buf;
int i, bufsize;
off_t bufrem;
+ time_t tstamp;
assert (image != NULL);
assert (fsopts != NULL);
@@ -541,7 +542,15 @@ ffs_create_image(const char *image, fsinfo_t *fsopts)
/* make the file system */
if (debug & DEBUG_FS_CREATE_IMAGE)
printf("calling mkfs(\"%s\", ...)\n", image);
- fs = ffs_mkfs(image, fsopts);
+
+ if (stampst.st_ino != 0)
+ tstamp = stampst.st_ctime;
+ else
+ tstamp = start_time.tv_sec;
+
+ srandom(tstamp);
+
+ fs = ffs_mkfs(image, fsopts, tstamp);
fsopts->superblock = (void *)fs;
if (debug & DEBUG_FS_CREATE_IMAGE) {
time_t t;
@@ -648,19 +657,12 @@ ffs_build_dinode1(struct ufs1_dinode *dinp, dirbuf_t *dbufp, fsnode *cur,
{
int slen;
void *membuf;
+ struct stat *st = stampst.st_ino != 0 ? &stampst : &cur->inode->st;
memset(dinp, 0, sizeof(*dinp));
dinp->di_mode = cur->inode->st.st_mode;
dinp->di_nlink = cur->inode->nlink;
dinp->di_size = cur->inode->st.st_size;
- dinp->di_atime = cur->inode->st.st_atime;
- dinp->di_mtime = cur->inode->st.st_mtime;
- dinp->di_ctime = cur->inode->st.st_ctime;
-#if HAVE_STRUCT_STAT_ST_MTIMENSEC
- dinp->di_atimensec = cur->inode->st.st_atimensec;
- dinp->di_mtimensec = cur->inode->st.st_mtimensec;
- dinp->di_ctimensec = cur->inode->st.st_ctimensec;
-#endif
#if HAVE_STRUCT_STAT_ST_FLAGS
dinp->di_flags = cur->inode->st.st_flags;
#endif
@@ -669,6 +671,15 @@ ffs_build_dinode1(struct ufs1_dinode *dinp, dirbuf_t *dbufp, fsnode *cur,
#endif
dinp->di_uid = cur->inode->st.st_uid;
dinp->di_gid = cur->inode->st.st_gid;
+
+ dinp->di_atime = st->st_atime;
+ dinp->di_mtime = st->st_mtime;
+ dinp->di_ctime = st->st_ctime;
+#if HAVE_STRUCT_STAT_ST_MTIMENSEC
+ dinp->di_atimensec = st->st_atimensec;
+ dinp->di_mtimensec = st->st_mtimensec;
+ dinp->di_ctimensec = st->st_ctimensec;
+#endif
/* not set: di_db, di_ib, di_blocks, di_spare */
membuf = NULL;
@@ -696,31 +707,33 @@ ffs_build_dinode2(struct ufs2_dinode *dinp, dirbuf_t *dbufp, fsnode *cur,
{
int slen;
void *membuf;
+ struct stat *st = stampst.st_ino != 0 ? &stampst : &cur->inode->st;
memset(dinp, 0, sizeof(*dinp));
dinp->di_mode = cur->inode->st.st_mode;
dinp->di_nlink = cur->inode->nlink;
dinp->di_size = cur->inode->st.st_size;
- dinp->di_atime = cur->inode->st.st_atime;
- dinp->di_mtime = cur->inode->st.st_mtime;
- dinp->di_ctime = cur->inode->st.st_ctime;
-#if HAVE_STRUCT_STAT_ST_MTIMENSEC
- dinp->di_atimensec = cur->inode->st.st_atimensec;
- dinp->di_mtimensec = cur->inode->st.st_mtimensec;
- dinp->di_ctimensec = cur->inode->st.st_ctimensec;
-#endif
#if HAVE_STRUCT_STAT_ST_FLAGS
dinp->di_flags = cur->inode->st.st_flags;
#endif
#if HAVE_STRUCT_STAT_ST_GEN
dinp->di_gen = cur->inode->st.st_gen;
#endif
-#if HAVE_STRUCT_STAT_BIRTHTIME
- dinp->di_birthtime = cur->inode->st.st_birthtime;
- dinp->di_birthnsec = cur->inode->st.st_birthtimensec;
-#endif
dinp->di_uid = cur->inode->st.st_uid;
dinp->di_gid = cur->inode->st.st_gid;
+
+ dinp->di_atime = st->st_atime;
+ dinp->di_mtime = st->st_mtime;
+ dinp->di_ctime = st->st_ctime;
+#if HAVE_STRUCT_STAT_ST_MTIMENSEC
+ dinp->di_atimensec = st->st_atimensec;
+ dinp->di_mtimensec = st->st_mtimensec;
+ dinp->di_ctimensec = st->st_ctimensec;
+#endif
+#if HAVE_STRUCT_STAT_BIRTHTIME
+ dinp->di_birthtime = st->st_birthtime;
+ dinp->di_birthnsec = st->st_birthtimensec;
+#endif
/* not set: di_db, di_ib, di_blocks, di_spare */
membuf = NULL;
@@ -1125,11 +1138,6 @@ ffs_write_inode(union dinode *dp, uint32_t ino, const fsinfo_t *fsopts)
initediblk < ufs_rw32(cgp->cg_niblk, fsopts->needswap)) {
memset(buf, 0, fs->fs_bsize);
dip = (struct ufs2_dinode *)buf;
- /*
- * XXX: Time-based seeds should be avoided for
- * reproduceable builds.
- */
- srandom(time(NULL));
for (i = 0; i < INOPB(fs); i++) {
dip->di_gen = random();
dip++;
diff --git a/usr.sbin/makefs/ffs/mkfs.c b/usr.sbin/makefs/ffs/mkfs.c
index eca58eb..a6cb2e2 100644
--- a/usr.sbin/makefs/ffs/mkfs.c
+++ b/usr.sbin/makefs/ffs/mkfs.c
@@ -113,7 +113,7 @@ static int avgfilesize; /* expected average file size */
static int avgfpdir; /* expected number of files per directory */
struct fs *
-ffs_mkfs(const char *fsys, const fsinfo_t *fsopts)
+ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
{
int fragsperinode, optimalfpg, origdensity, minfpg, lastminfpg;
int32_t cylno, i, csfrags;
@@ -434,7 +434,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts)
sblock.fs_state = 0;
sblock.fs_clean = FS_ISCLEAN;
sblock.fs_ronly = 0;
- sblock.fs_id[0] = start_time.tv_sec;
+ sblock.fs_id[0] = tstamp;
sblock.fs_id[1] = random();
sblock.fs_fsmnt[0] = '\0';
csfrags = howmany(sblock.fs_cssize, sblock.fs_fsize);
@@ -450,9 +450,9 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts)
sblock.fs_cstotal.cs_nifree = sblock.fs_ncg * sblock.fs_ipg - ROOTINO;
sblock.fs_cstotal.cs_ndir = 0;
sblock.fs_dsize -= csfrags;
- sblock.fs_time = start_time.tv_sec;
+ sblock.fs_time = tstamp;
if (Oflag <= 1) {
- sblock.fs_old_time = start_time.tv_sec;
+ sblock.fs_old_time = tstamp;
sblock.fs_old_dsize = sblock.fs_dsize;
sblock.fs_old_csaddr = sblock.fs_csaddr;
sblock.fs_old_cstotal.cs_ndir = sblock.fs_cstotal.cs_ndir;
@@ -508,7 +508,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts)
printf("super-block backups (for fsck -b #) at:");
for (cylno = 0; cylno < sblock.fs_ncg; cylno++) {
- initcg(cylno, start_time.tv_sec, fsopts);
+ initcg(cylno, tstamp, fsopts);
if (cylno % nprintcols == 0)
printf("\n");
printf(" %*lld,", printcolwidth,
@@ -521,7 +521,7 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts)
* Now construct the initial file system,
* then write out the super-block.
*/
- sblock.fs_time = start_time.tv_sec;
+ sblock.fs_time = tstamp;
if (Oflag <= 1) {
sblock.fs_old_cstotal.cs_ndir = sblock.fs_cstotal.cs_ndir;
sblock.fs_old_cstotal.cs_nbfree = sblock.fs_cstotal.cs_nbfree;
diff --git a/usr.sbin/makefs/ffs/newfs_extern.h b/usr.sbin/makefs/ffs/newfs_extern.h
index a54c0e2..a135541 100644
--- a/usr.sbin/makefs/ffs/newfs_extern.h
+++ b/usr.sbin/makefs/ffs/newfs_extern.h
@@ -1,4 +1,4 @@
-/* $NetBSD: newfs_extern.h,v 1.3 2009/10/21 01:07:47 snj Exp $ */
+/* $NetBSD: newfs_extern.h,v 1.4 2015/12/21 00:58:08 christos Exp $ */
/* From: NetBSD: extern.h,v 1.3 2000/12/01 12:03:27 simonb Exp $ */
/*
@@ -28,7 +28,7 @@
*/
/* prototypes */
-struct fs *ffs_mkfs(const char *, const fsinfo_t *);
+struct fs *ffs_mkfs(const char *, const fsinfo_t *, time_t);
void ffs_write_superblock(struct fs *, const fsinfo_t *);
void ffs_rdfs(daddr_t, int, void *, const fsinfo_t *);
void ffs_wtfs(daddr_t, int, void *, const fsinfo_t *);
diff --git a/usr.sbin/makefs/makefs.8 b/usr.sbin/makefs/makefs.8
index f80dc53..3c3fd2b 100644
--- a/usr.sbin/makefs/makefs.8
+++ b/usr.sbin/makefs/makefs.8
@@ -35,7 +35,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 9, 2015
+.Dd June 14, 2016
.Dt MAKEFS 8
.Os
.Sh NAME
@@ -56,6 +56,7 @@
.Op Fl R Ar roundup-size
.Op Fl S Ar sector-size
.Op Fl s Ar image-size
+.Op Fl T Ar timestamp
.Op Fl t Ar fs-type
.Ar image-file
.Ar directory | manifest
@@ -212,6 +213,18 @@ Defaults to 512.
.It Fl s Ar image-size
Set the size of the file system image to
.Ar image-size .
+.It Fl T Ar timestamp
+Specify a timestamp to be set for all filesystem files and directories
+created so that repeatable builds are possible.
+The
+.Ar timestamp
+can be a
+.Pa pathname ,
+where the timestamps are derived from that file, or an integer
+value interpreted as the number of seconds from the Epoch.
+Note that timestamps specified in an
+.Xr mtree 5
+spec file, override the default timestamp.
.It Fl t Ar fs-type
Create an
.Ar fs-type
diff --git a/usr.sbin/makefs/makefs.c b/usr.sbin/makefs/makefs.c
index a7ca751..c1cf502 100644
--- a/usr.sbin/makefs/makefs.c
+++ b/usr.sbin/makefs/makefs.c
@@ -78,8 +78,10 @@ static fstype_t fstypes[] = {
u_int debug;
int dupsok;
struct timespec start_time;
+struct stat stampst;
static fstype_t *get_fstype(const char *);
+static int get_tstamp(const char *, struct stat *);
static void usage(void);
int main(int, char *[]);
@@ -110,13 +112,15 @@ main(int argc, char *argv[])
fstype->prepare_options(&fsoptions);
specfile = NULL;
- if (gettimeofday(&start, NULL) == -1)
- err(1, "Unable to get system time");
-
+ ch = gettimeofday(&start, NULL);
start_time.tv_sec = start.tv_sec;
start_time.tv_nsec = start.tv_usec * 1000;
- while ((ch = getopt(argc, argv, "B:b:Dd:f:F:M:m:N:o:pR:s:S:t:xZ")) != -1) {
+ if (ch == -1)
+ err(1, "Unable to get system time");
+
+
+ while ((ch = getopt(argc, argv, "B:b:Dd:f:F:M:m:N:o:pR:s:S:t:T:xZ")) != -1) {
switch (ch) {
case 'B':
@@ -239,6 +243,12 @@ main(int argc, char *argv[])
fstype->prepare_options(&fsoptions);
break;
+ case 'T':
+ if (get_tstamp(optarg, &stampst) == -1)
+ errx(1, "Cannot get timestamp from `%s'",
+ optarg);
+ break;
+
case 'x':
fsoptions.onlyspec = 1;
break;
@@ -360,6 +370,32 @@ get_fstype(const char *type)
return (NULL);
}
+static int
+get_tstamp(const char *b, struct stat *st)
+{
+ time_t when;
+ char *eb;
+ long long l;
+
+ if (stat(b, st) != -1)
+ return 0;
+
+ {
+ errno = 0;
+ l = strtoll(b, &eb, 0);
+ if (b == eb || *eb || errno)
+ return -1;
+ when = (time_t)l;
+ }
+
+ st->st_ino = 1;
+#ifdef HAVE_STRUCT_STAT_BIRTHTIME
+ st->st_birthtime =
+#endif
+ st->st_mtime = st->st_ctime = st->st_atime = when;
+ return 0;
+}
+
static void
usage(void)
{
@@ -370,7 +406,8 @@ usage(void)
"usage: %s [-t fs-type] [-o fs-options] [-d debug-mask] [-B endian]\n"
"\t[-S sector-size] [-M minimum-size] [-m maximum-size] [-R roundup-size]\n"
"\t[-s image-size] [-b free-blocks] [-f free-files] [-F mtree-specfile]\n"
-"\t[-xZ] [-N userdb-dir] image-file directory | manifest [extra-directory ...]\n",
+"\t[-xZ] [-N userdb-dir] [-T <timestamp/file>]\n"
+"\timage-file directory | manifest [extra-directory ...]\n",
prog);
exit(1);
}
diff --git a/usr.sbin/makefs/makefs.h b/usr.sbin/makefs/makefs.h
index ba80f74..13752b8 100644
--- a/usr.sbin/makefs/makefs.h
+++ b/usr.sbin/makefs/makefs.h
@@ -172,6 +172,7 @@ void cd9660_makefs(const char *, const char *, fsnode *, fsinfo_t *);
extern u_int debug;
extern int dupsok;
extern struct timespec start_time;
+extern struct stat stampst;
/*
* If -x is specified, we want to exclude nodes which do not appear
diff --git a/usr.sbin/makefs/walk.c b/usr.sbin/makefs/walk.c
index 2fc964a..7110170 100644
--- a/usr.sbin/makefs/walk.c
+++ b/usr.sbin/makefs/walk.c
@@ -229,6 +229,20 @@ create_fsnode(const char *root, const char *path, const char *name,
cur->type = stbuf->st_mode & S_IFMT;
cur->inode->nlink = 1;
cur->inode->st = *stbuf;
+ if (stampst.st_ino) {
+ cur->inode->st.st_atime = stampst.st_atime;
+ cur->inode->st.st_mtime = stampst.st_mtime;
+ cur->inode->st.st_ctime = stampst.st_ctime;
+#if HAVE_STRUCT_STAT_ST_MTIMENSEC
+ cur->inode->st.st_atimensec = stampst.st_atimensec;
+ cur->inode->st.st_mtimensec = stampst.st_mtimensec;
+ cur->inode->st.st_ctimensec = stampst.st_ctimensec;
+#endif
+#if HAVE_STRUCT_STAT_BIRTHTIME
+ cur->inode->st.st_birthtime = stampst.st_birthtime;
+ cur->inode->st.st_birthtimensec = stampst.st_birthtimensec;
+#endif
+ }
return (cur);
}
diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c
index 9490cda..4108ac9 100644
--- a/usr.sbin/newsyslog/newsyslog.c
+++ b/usr.sbin/newsyslog/newsyslog.c
@@ -333,13 +333,15 @@ main(int argc, char **argv)
printf("Signal all daemon process(es)...\n");
SLIST_FOREACH(stmp, &swhead, sw_nextp)
do_sigwork(stmp);
- if (noaction)
- printf("\tsleep 10\n");
- else {
- if (verbose)
- printf("Pause 10 seconds to allow daemon(s)"
- " to close log file(s)\n");
- sleep(10);
+ if (!(rotatereq && nosignal)) {
+ if (noaction)
+ printf("\tsleep 10\n");
+ else {
+ if (verbose)
+ printf("Pause 10 seconds to allow "
+ "daemon(s) to close log file(s)\n");
+ sleep(10);
+ }
}
}
/*
diff --git a/usr.sbin/rpc.lockd/lockd_lock.c b/usr.sbin/rpc.lockd/lockd_lock.c
index 735d979..59a312d 100644
--- a/usr.sbin/rpc.lockd/lockd_lock.c
+++ b/usr.sbin/rpc.lockd/lockd_lock.c
@@ -1426,6 +1426,7 @@ lock_partialfilelock(struct file_lock *fl)
break;
case NFS_RESERR:
retval = PFL_NFSRESERR;
+ break;
default:
debuglog("Unmatched lnlstatus %d\n");
retval = PFL_NFSDENIED_NOLOCK;
diff --git a/usr.sbin/rpcbind/rpcb_stat.c b/usr.sbin/rpcbind/rpcb_stat.c
index fd92d78..12aab64 100644
--- a/usr.sbin/rpcbind/rpcb_stat.c
+++ b/usr.sbin/rpcbind/rpcb_stat.c
@@ -151,7 +151,7 @@ rpcbs_rmtcall(rpcvers_t rtype, rpcproc_t rpcbproc, rpcprog_t prog,
rpcbs_rmtcalllist *rl;
struct netconfig *nconf;
- if (rtype > RPCBVERS_STAT)
+ if (rtype >= RPCBVERS_STAT)
return;
for (rl = inf[rtype].rmtinfo; rl; rl = rl->next) {
diff --git a/usr.sbin/rpcbind/rpcb_svc_com.c b/usr.sbin/rpcbind/rpcb_svc_com.c
index 5c6b8dd..c86f75e 100644
--- a/usr.sbin/rpcbind/rpcb_svc_com.c
+++ b/usr.sbin/rpcbind/rpcb_svc_com.c
@@ -429,9 +429,9 @@ static bool_t
xdr_rmtcall_args(XDR *xdrs, struct r_rmtcall_args *cap)
{
/* does not get the address or the arguments */
- if (xdr_u_int32_t(xdrs, &(cap->rmt_prog)) &&
- xdr_u_int32_t(xdrs, &(cap->rmt_vers)) &&
- xdr_u_int32_t(xdrs, &(cap->rmt_proc))) {
+ if (xdr_rpcprog(xdrs, &(cap->rmt_prog)) &&
+ xdr_rpcvers(xdrs, &(cap->rmt_vers)) &&
+ xdr_rpcproc(xdrs, &(cap->rmt_proc))) {
return (xdr_encap_parms(xdrs, &(cap->rmt_args)));
}
return (FALSE);
diff --git a/usr.sbin/services_mkdb/services_mkdb.8 b/usr.sbin/services_mkdb/services_mkdb.8
index e3b70e2..08cdbe7 100644
--- a/usr.sbin/services_mkdb/services_mkdb.8
+++ b/usr.sbin/services_mkdb/services_mkdb.8
@@ -75,6 +75,7 @@ Print the services file to stdout, omitting duplicate entries and comments.
.El
.Pp
The databases are used by the C library services routines (see
+.Xr getservent 3 ) .
.Pp
The
.Fl b
@@ -82,7 +83,6 @@ and
.Fl l
flags are mutually exclusive.
The default byte ordering is the current host order.
-.Xr getservent 3 ) .
.Sh FILES
.Bl -tag -width ".Pa /var/db/services.db.tmp" -compact
.It Pa /var/db/services.db
diff --git a/usr.sbin/sysrc/sysrc.8 b/usr.sbin/sysrc/sysrc.8
index aaf52e1..47e5730 100644
--- a/usr.sbin/sysrc/sysrc.8
+++ b/usr.sbin/sysrc/sysrc.8
@@ -480,6 +480,6 @@ utility first appeared in
.Sh AUTHORS
.An Devin Teske Aq Mt dteske@FreeBSD.org
.Sh THANKS TO
-Brandon Gooch, Garrett Cooper, Julian Elischer, Pawel Jakub Dawidek,
+Brandon Gooch, Ngie Cooper, Julian Elischer, Pawel Jakub Dawidek,
Cyrille Lefevre, Ross West, Stefan Esser, Marco Steinbach, Jilles Tjoelker,
Allan Jude, and Lars Engels for suggestions, help, and testing.
diff --git a/usr.sbin/tcpdump/tcpdump/config.h b/usr.sbin/tcpdump/tcpdump/config.h
index dbd03f7..79a07e7 100644
--- a/usr.sbin/tcpdump/tcpdump/config.h
+++ b/usr.sbin/tcpdump/tcpdump/config.h
@@ -15,7 +15,7 @@
/* capsicum support available */
/* See Makefile */
-/* #undef HAVE_CAPSPER */
+/* #undef HAVE_CASPER */
/* Define to 1 if you have the `cap_enter' function. */
#define HAVE_CAP_ENTER 1
diff --git a/usr.sbin/ypldap/ypldap.8 b/usr.sbin/ypldap/ypldap.8
index 2974e24..0ef75a2 100644
--- a/usr.sbin/ypldap/ypldap.8
+++ b/usr.sbin/ypldap/ypldap.8
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: July 27 2015 $
+.Dd $Mdocdate: June 8 2016 $
.Dt YPLDAP 8
.Os
.Sh NAME
@@ -74,7 +74,9 @@ configuration file.
The
.Nm
program first appeared in
-.Ox 4.4 .
+.Ox 4.4
+and then
+.Fx 11.0 .
.Sh AUTHORS
The
.Nm
OpenPOWER on IntegriCloud