[PATCH] tcpdump ''immediate mode''
Hi, tcpdump feels a bit laggy or slow some times when i use it for live debugging. The following patch adds a new flag, '-b', to tcpdump. With this flag, tcpdump sets BIOCIMMEDIATE for the current bpf(4) interface. With BIOCIMMEDIATE set, the output is fluent. Index: usr.sbin/tcpdump/privsep.c === RCS file: /cvs/src/usr.sbin/tcpdump/privsep.c,v retrieving revision 1.30 diff -u -p -r1.30 privsep.c --- usr.sbin/tcpdump/privsep.c 22 Sep 2011 09:12:30 - 1.30 +++ usr.sbin/tcpdump/privsep.c 14 Dec 2014 22:40:14 - @@ -318,7 +318,7 @@ priv_init(int argc, char **argv) static void impl_open_bpf(int fd, int *bpfd) { - int snaplen, promisc, err; + int snaplen, promisc, immediate, err; u_int dlt, dirfilt; char device[IFNAMSIZ]; size_t iflen; @@ -327,12 +327,13 @@ impl_open_bpf(int fd, int *bpfd) must_read(fd, snaplen, sizeof(int)); must_read(fd, promisc, sizeof(int)); + must_read(fd, immediate, sizeof(int)); must_read(fd, dlt, sizeof(u_int)); must_read(fd, dirfilt, sizeof(u_int)); iflen = read_string(fd, device, sizeof(device), __func__); if (iflen == 0) errx(1, Invalid interface size specified); - *bpfd = pcap_live(device, snaplen, promisc, dlt, dirfilt); + *bpfd = pcap_live(device, snaplen, promisc, immediate, dlt, dirfilt); err = errno; if (*bpfd 0) logmsg(LOG_DEBUG, Index: usr.sbin/tcpdump/privsep.h === RCS file: /cvs/src/usr.sbin/tcpdump/privsep.h,v retrieving revision 1.7 diff -u -p -r1.7 privsep.h --- usr.sbin/tcpdump/privsep.h 25 Aug 2009 06:59:17 - 1.7 +++ usr.sbin/tcpdump/privsep.h 14 Dec 2014 22:40:14 - @@ -47,10 +47,10 @@ int priv_init(int, char **); voidpriv_init_done(void); intsetfilter(int, int, char *); -intpcap_live(const char *, int, int, u_int, u_int); +intpcap_live(const char *, int, int, int, u_int, u_int); struct bpf_program *priv_pcap_setfilter(pcap_t *, int, u_int32_t); -pcap_t *priv_pcap_live(const char *, int, int, int, char *, u_int, +pcap_t *priv_pcap_live(const char *, int, int, int, int, char *, u_int, u_int); pcap_t *priv_pcap_offline(const char *, char *); Index: usr.sbin/tcpdump/privsep_pcap.c === RCS file: /cvs/src/usr.sbin/tcpdump/privsep_pcap.c,v retrieving revision 1.17 diff -u -p -r1.17 privsep_pcap.c --- usr.sbin/tcpdump/privsep_pcap.c 14 Nov 2012 03:33:04 - 1.17 +++ usr.sbin/tcpdump/privsep_pcap.c 14 Dec 2014 22:40:14 - @@ -172,8 +172,8 @@ priv_pcap_setfilter(pcap_t *hpcap, int o /* privileged part of priv_pcap_live */ int -pcap_live(const char *device, int snaplen, int promisc, u_int dlt, -u_int dirfilt) +pcap_live(const char *device, int snaplen, int promisc, int immediate, +u_int dlt, u_int dirfilt) { charbpf[sizeof /dev/bpf00]; int fd, n = 0; @@ -204,6 +204,10 @@ pcap_live(const char *device, int snaple if (promisc) /* this is allowed to fail */ ioctl(fd, BIOCPROMISC, NULL); + + if (immediate ioctl(fd, BIOCIMMEDIATE, immediate) 0) + goto error; + if (ioctl(fd, BIOCSDIRFILT, dirfilt) 0) goto error; @@ -223,7 +227,7 @@ pcap_live(const char *device, int snaple * unprivileged part. */ pcap_t * -priv_pcap_live(const char *dev, int slen, int prom, int to_ms, +priv_pcap_live(const char *dev, int slen, int prom, int imme, int to_ms, char *ebuf, u_int dlt, u_int dirfilt) { int fd, err; @@ -251,6 +255,7 @@ priv_pcap_live(const char *dev, int slen write_command(priv_fd, PRIV_OPEN_BPF); must_write(priv_fd, slen, sizeof(int)); must_write(priv_fd, prom, sizeof(int)); + must_write(priv_fd, imme, sizeof(int)); must_write(priv_fd, dlt, sizeof(u_int)); must_write(priv_fd, dirfilt, sizeof(u_int)); write_string(priv_fd, dev); Index: usr.sbin/tcpdump/tcpdump.8 === RCS file: /cvs/src/usr.sbin/tcpdump/tcpdump.8,v retrieving revision 1.83 diff -u -p -r1.83 tcpdump.8 --- usr.sbin/tcpdump/tcpdump.8 3 Jun 2014 02:57:29 - 1.83 +++ usr.sbin/tcpdump/tcpdump.8 14 Dec 2014 22:40:15 - @@ -28,7 +28,7 @@ .Sh SYNOPSIS .Nm tcpdump .Bk -words -.Op Fl AadefILlNnOopqStvXx +.Op Fl AabdefILlNnOopqStvXx .Op Fl c Ar count .Op Fl D Ar direction .Oo Fl E Oo Ar espalg : Oc Ns @@ -61,6 +61,9 @@ The smaller of the entire packet or bytes will be printed. .It Fl a Attempt to convert network and broadcast addresses to names. +.It Fl b +Disables read blocking on the bpf(4) buffer. With this so called +``immediate mode'' reads return immediately upon packet reception. .It Fl c Ar count
BUG in bpf ?
Hi, if BIOCGRTIMEOUT is set, we should wait for the timeout and not just set EWOULDBLOCK. From my point of view the whole 'if' is unnecessary. If the User doesn't set a timeout we have to wait anyway with tsleep() and loop again. Well, and if the timeout is set, we should tsleep() for the set timeout. Index: sys/net//bpf.c === RCS file: /home/cvs/src/sys/net/bpf.c,v retrieving revision 1.103 diff -u -p -u -r1.103 bpf.c --- sys/net//bpf.c 12 Jul 2014 18:44:22 - 1.103 +++ sys/net//bpf.c 17 Dec 2014 08:10:18 - @@ -434,11 +434,9 @@ bpfread(dev_t dev, struct uio *uio, int /* User requested non-blocking I/O */ error = EWOULDBLOCK; } else { - if ((d-bd_rdStart + d-bd_rtout) ticks) { - error = tsleep((caddr_t)d, PRINET|PCATCH, bpf, - d-bd_rtout); - } else - error = EWOULDBLOCK; + /* User requested timeout */ + error = tsleep((caddr_t)d, PRINET|PCATCH, bpf, + d-bd_rtout); } if (error == EINTR || error == ERESTART) { D_PUT(d);
Re: Dell R630 high interrupts on acpi0
On 16 dec 2014, at 06:40, David Gwynne da...@gwynne.id.au wrote: others have hit this on r620s as well I don’t see it on mine. interrupt total rate irq0/clock 9587998940 1599 irq0/ipi136166514 22 irq144/acpi020 irq112/ix029053603446 4847 irq113/ix127844456217 4646 irq96/mfi080725871 irq114/ubsec0 3101629892 517 irq98/ehci0 1120 irq115/em0 4928262870 822 irq116/em1 211437268 35 irq99/ehci1280 irq100/ahci010 Total 7487162787712493 This is a pre-5.6 OpenBSD 5.6-current (GENERIC.MP) #394: Wed Oct 1 12:54:54 MDT 2014 dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP real mem = 8492285952 (8098MB) avail mem = 8257511424 (7874MB) mpath0 at root scsibus0 at mpath0: 256 targets mainbus0 at root bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xcf42c000 (99 entries) bios0: vendor Dell Inc. version 1.3.6 date 09/11/2012 bios0: Dell Inc. PowerEdge R620 acpi0 at bios0: rev 2 acpi0: sleep states S0 S4 S5 acpi0: tables DSDT FACP APIC SPCR HPET DMAR MCFG WD__ SLIC ERST HEST BERT EINJ TCPA PC__ SRAT SSDT acpi0: wakeup devices PCI0(S5) PCI1(S5) acpitimer0 at acpi0: 3579545 Hz, 24 bits acpimadt0 at acpi0 addr 0xfee0: PC-AT compat cpu0 at mainbus0: apid 0 (boot processor) cpu0: Intel(R) Xeon(R) CPU E5-2643 0 @ 3.30GHz, 3400.43 MHz cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,NXE,PAGE1GB,LONG,LAHF,PERF,ITSC cpu0: 256KB 64b/line 8-way L2 cache cpu0: smt 0, core 0, package 0 mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges cpu0: apic clock running at 99MHz cpu0: mwait min=64, max=64, C-substates=0.2.1.1.2, IBE cpu1 at mainbus0: apid 32 (application processor) cpu1: Intel(R) Xeon(R) CPU E5-2643 0 @ 3.30GHz, 3400.00 MHz cpu1: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,NXE,PAGE1GB,LONG,LAHF,PERF,ITSC cpu1: 256KB 64b/line 8-way L2 cache cpu1: smt 0, core 0, package 1 cpu2 at mainbus0: apid 2 (application processor) cpu2: Intel(R) Xeon(R) CPU E5-2643 0 @ 3.30GHz, 3400.00 MHz cpu2: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,NXE,PAGE1GB,LONG,LAHF,PERF,ITSC cpu2: 256KB 64b/line 8-way L2 cache cpu2: smt 0, core 1, package 0 cpu3 at mainbus0: apid 34 (application processor) cpu3: Intel(R) Xeon(R) CPU E5-2643 0 @ 3.30GHz, 3400.00 MHz cpu3: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,NXE,PAGE1GB,LONG,LAHF,PERF,ITSC cpu3: 256KB 64b/line 8-way L2 cache cpu3: smt 0, core 1, package 1 cpu4 at mainbus0: apid 4 (application processor) cpu4: Intel(R) Xeon(R) CPU E5-2643 0 @ 3.30GHz, 3400.00 MHz cpu4: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,NXE,PAGE1GB,LONG,LAHF,PERF,ITSC cpu4: 256KB 64b/line 8-way L2 cache cpu4: smt 0, core 2, package 0 cpu5 at mainbus0: apid 36 (application processor) cpu5: Intel(R) Xeon(R) CPU E5-2643 0 @ 3.30GHz, 3400.00 MHz cpu5: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,NXE,PAGE1GB,LONG,LAHF,PERF,ITSC cpu5: 256KB 64b/line 8-way L2 cache cpu5: smt 0, core 2, package 1 cpu6 at mainbus0: apid 6 (application processor) cpu6: Intel(R) Xeon(R) CPU E5-2643 0 @ 3.30GHz, 3400.00 MHz cpu6: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,NXE,PAGE1GB,LONG,LAHF,PERF,ITSC cpu6: 256KB 64b/line 8-way L2 cache cpu6: smt 0, core 3, package 0 cpu7 at mainbus0: apid 38 (application processor) cpu7: Intel(R) Xeon(R) CPU E5-2643 0 @ 3.30GHz,
[WIP] uhidcom(4) driver for USB HID based UART
Hi, I am trying to write a driver for Silicon Labs CP2110 USB HID based UART. Here is work-in-progress code, and it seems to set uca.uhidev properly. (I wrote code/tested on 5.6-release and ported to -current.) Exar's XR21B1421 uses similar protocol so I named the driver uhidcom(4), but currently it is not supported --- too expensive to buy evaluation board. -- SASANO Takayoshi u...@mx5.nisiq.net Index: arch/i386/conf/GENERIC === RCS file: /cvs/src/sys/arch/i386/conf/GENERIC,v retrieving revision 1.792 diff -u -p -u -p -r1.792 GENERIC --- arch/i386/conf/GENERIC 11 Dec 2014 19:44:17 - 1.792 +++ arch/i386/conf/GENERIC 17 Dec 2014 09:57:54 - @@ -274,6 +274,8 @@ ukbd* at uhidev? # USB keyboard wskbd* at ukbd? mux 1 ucycom*at uhidev? # Cypress serial ucom* at ucycom? +uhidcom* at uhidev?# Silicon Labs CP2110 USB HID UART +ucom* at uhidcom? uticom* at uhub? # TI serial ucom* at uticom? uhid* at uhidev? # USB generic HID support Index: dev/usb/files.usb === RCS file: /cvs/src/sys/dev/usb/files.usb,v retrieving revision 1.120 diff -u -p -u -p -r1.120 files.usb --- dev/usb/files.usb 11 Dec 2014 19:44:17 - 1.120 +++ dev/usb/files.usb 17 Dec 2014 09:58:00 - @@ -110,6 +110,11 @@ device ucycom: hid, ucombus attach ucycom at uhidbus file dev/usb/ucycom.cucycom needs-flag +# Silicon Labs USB HID based UART controller +device uhidcom: hid, ucombus +attach uhidcom at uhidbus +file dev/usb/uhidcom.c uhidcom needs-flag + # Printers device ulpt: firmload attach ulpt at uhub Index: dev/usb/uhidcom.c === RCS file: dev/usb/uhidcom.c diff -N dev/usb/uhidcom.c --- /dev/null 1 Jan 1970 00:00:00 - +++ dev/usb/uhidcom.c 17 Dec 2014 09:58:01 - @@ -0,0 +1,489 @@ +/* $OpenBSD: */ + +/* + * Copyright (c) 2014 SASANO Takayoshi u...@uaa.org.uk + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Device driver for Silicon Labs CP2110 USB HID-UART bridge. + */ + +#include sys/param.h +#include sys/systm.h +#include sys/kernel.h +#include sys/malloc.h +#include sys/conf.h +#include sys/tty.h +#include sys/device.h + +#include dev/usb/usb.h +#include dev/usb/usbdi.h +#include dev/usb/usbdi_util.h +#include dev/usb/usbdevs.h + +#include dev/usb/hid.h +#include dev/usb/usbhid.h +#include dev/usb/uhidev.h + +#include dev/usb/ucomvar.h +#include dev/usb/uhidcomreg.h + +#define UHIDCOM_DEBUG +#ifdef UHIDCOM_DEBUG +#defineDPRINTFN(n, x) do { if(uhidcomdebug (n)) printf x; } while (0) +intuhidcomdebug = 10; +#else +#defineDPRINTFN(n, x) +#endif +#defineDPRINTF(x) DPRINTFN(0, x) + +struct uhidcom_softc { + struct uhidevsc_hdev; + struct usbd_device *sc_udev; + + u_char *sc_ibuf; + u_intsc_icnt; + + u_char sc_lsr; + u_char sc_msr; + + struct device *sc_subdev; +}; + +void uhidcom_get_status(void *, int, u_char *, u_char *); +void uhidcom_set(void *, int, int, int); +intuhidcom_param(void *, int, struct termios *); +intuhidcom_open(void *, int); +void uhidcom_close(void *, int); +void uhidcom_write(void *, int, u_char *, u_char *, u_int32_t *); +void uhidcom_read(void *, int, u_char **, u_int32_t *); +void uhidcom_intr(struct uhidev *, void *, u_int); + +intuhidcom_match(struct device *, void *, void *); +void uhidcom_attach(struct device *, struct device *, void *); +intuhidcom_detach(struct device *, int); + +usbd_statusuhidcom_uart_endis(struct uhidcom_softc *, int); +usbd_statusuhidcom_clear_fifo(struct uhidcom_softc *, int); +usbd_statusuhidcom_get_version(struct uhidcom_softc *, struct uhidcom_version_info *); +usbd_statusuhidcom_get_uart_status(struct uhidcom_softc *, struct uhidcom_uart_status *); +usbd_statusuhidcom_set_break(struct
Re: [WIP] uhidcom(4) driver for USB HID based UART
On Wed, Dec 17, 2014 at 07:49:59PM +0900, SASANO Takayoshi wrote: Hi, I am trying to write a driver for Silicon Labs CP2110 USB HID based UART. Here is work-in-progress code, and it seems to set uca.uhidev properly. (I wrote code/tested on 5.6-release and ported to -current.) Exar's XR21B1421 uses similar protocol so I named the driver uhidcom(4), but currently it is not supported --- too expensive to buy evaluation board. Isn't that name a bit too generic? We already have a USB HID based UART driver in the tree with ucycom(4), which apparently uses a different protocol?
Re: Dell R630 high interrupts on acpi0
Date: Tue, 16 Dec 2014 21:34:29 -0800 From: Philip Guenther guent...@gmail.com R620 have similar settings and can't see C states in dmesg acpicpu0 at acpi0 That's either insane, or a bug in our acpicpu code, IMO. Probably just the effect of the BIOS not advertising C states at all. Like you said, C1 support is mandatory, so there is no real need to advertise it unless some of the deeper states are advertised as well.
newsyslog(8) glob support
Hello all, Not sure if this is something anyone would like to see included in newsyslog(8) but I've been maintaining a patch for it which adds support for glob(3) patterns to newsyslog/newsyslog.conf and now I rewrote parts of it to make it more presentable and wanted to share in case anyone is interested. Apart from the functionality change, I've moved from the linked list to using SLIST but apart from that everything should work the same way as before. No flags/arguments necessary in order to enable the glob support. The only known change in behavior is that newsyslog no longer prints warning messages like: newsyslog: /etc/newsyslog.conf: /var/log/foo not found mostly because I couldn't find a clever way to do this without a lot of extra overhead but that can be fixed if there's any interest in this. Anyway, if anyone thinks this is worth the effort, I'd be willing to work to make it suitable for submission as long as someone gives me some help/pointers or maybe someone more experienced can handle this. Let me know if you have any questions. Cheers, Seraphim Index: newsyslog.c === RCS file: /cvs/src/usr.bin/newsyslog/newsyslog.c,v retrieving revision 1.92 diff -u -p -r1.92 newsyslog.c --- newsyslog.c 26 Nov 2013 13:19:07 - 1.92 +++ newsyslog.c 17 Dec 2014 13:32:53 - @@ -91,6 +91,7 @@ #endif #include sys/param.h +#include sys/queue.h #include sys/stat.h #include sys/time.h #include sys/wait.h @@ -99,6 +100,7 @@ #include err.h #include errno.h #include fcntl.h +#include glob.h #include grp.h #include limits.h #include pwd.h @@ -138,8 +140,10 @@ struct conf_entry { char *whom; /* Whom to notify if logfile changes */ char *pidfile; /* Path to file containing pid to signal */ char *runcmd; /* Command to run instead of sending a signal */ - struct conf_entry *next; /* Linked list pointer */ + SLIST_ENTRY(conf_entry) entries; /* SLIST struct */ }; +SLIST_HEAD(conflist, conf_entry); +struct conflist all_confs = SLIST_HEAD_INITIALIZER(all_confs); struct pidinfo { char *file; @@ -170,8 +174,9 @@ int movefile(char *, char *, uid_t, gid_ int stat_suffix(char *, size_t, char *, struct stat *, int (*)(const char *, struct stat *)); off_t sizefile(struct stat *); -struct conf_entry * - parse_file(int *); +void parse_file(int *); +struct conf_entry * + parse_line(char *, char *, char *, int); time_t parse8601(char *); time_t parseDWM(char *); void child_killer(int); @@ -187,11 +192,12 @@ void usage(void); int main(int argc, char **argv) { - struct conf_entry *p, *q, *x, *y; + struct conf_entry *q, *t; struct pidinfo *pidlist, *pl; + struct conflist *p = all_confs; int status, listlen; char **av; - + parse_args(argc, argv); argc -= optind; argv += optind; @@ -199,30 +205,26 @@ main(int argc, char **argv) if (needroot getuid() geteuid()) errx(1, You must be root.); - p = parse_file(listlen); + parse_file(listlen); + if (argc 0) { /* Only rotate specified files. */ - x = y = NULL; - listlen = 0; - for (av = argv; *av; av++) { - for (q = p; q; q = q-next) -if (strcmp(*av, q-log) == 0) { - if (x == NULL) - x = y = q; - else { - y-next = q; - y = q; - } - listlen++; - break; -} - if (q == NULL) -warnx(%s: %s not found, conf, *av); + SLIST_FOREACH_SAFE(q, p, entries, t) { + for (av = argv; *av; av++) { +if (strcmp(*av, q-log) == 0) + goto next; + } + /* FIXME: Find a clever way to print the warning */ + //warnx(%s: %s not found, conf, *av); + SLIST_REMOVE(p, q, conf_entry, entries); + free(q); + listlen--; +next: + ; } - if (x == NULL) + + if (SLIST_EMPTY(p)) errx(1, %s: no specified log files, conf); - y-next = NULL; - p = x; } pidlist = (struct pidinfo *)calloc(listlen + 1, sizeof(struct pidinfo)); @@ -232,11 +234,12 @@ main(int argc, char **argv) signal(SIGCHLD, child_killer); /* Step 1, rotate all log files */ - for (q = p; q; q = q-next) + SLIST_FOREACH(q, p, entries) do_entry(q); /* Step 2, make a list of unique pid files */ - for (q = p, pl = pidlist; q; ) { + SLIST_FOREACH(q, p, entries) { + pl = pidlist; if (q-flags CE_ROTATED) { struct pidinfo *pltmp; @@ -259,7 +262,6 @@ main(int argc, char **argv) pl++; } } - q = q-next; } /* Step 3, send a signal or run a command */ @@ -275,12 +277,12 @@ main(int argc, char **argv) sleep(5); /* Step 4, compress the log.0 file if configured to do so and free */ - while (p) { - if ((p-flags CE_COMPACT) (p-flags CE_ROTATED) - p-numlogs 0) - compress_log(p); - q = p; - p = p-next; + while (!SLIST_EMPTY(p)) { + q = SLIST_FIRST(p); + if ((q-flags CE_COMPACT) (q-flags CE_ROTATED) + q-numlogs 0) + compress_log(q); + SLIST_REMOVE_HEAD(p, entries); free(q); } @@ -473,17 +475,14 @@ usage(void) * Parse a configuration file and return a linked list
Re: BUG in bpf ?
On Wed, Dec 17, 2014 at 12:55 AM, Mages Simon mages.si...@googlemail.com wrote: if BIOCGRTIMEOUT is set, we should wait for the timeout and not just set EWOULDBLOCK. From my point of view the whole 'if' is unnecessary. If the User doesn't set a timeout we have to wait anyway with tsleep() and loop again. Well, and if the timeout is set, we should tsleep() for the set timeout. No, that's wrong. This is inside a while() loop; if that loop's condition holds, do you want to sleep for the original length of time (again) or only for the remaining time? Philip Guenther
Re: newsyslog(8) glob support
It would be helpful if you could break the diff up into smaller logical pieces. For instance, one diff for the SLIST changes, another for general cleanup and a third for the glob() changes. - todd
Re: Dell R630 high interrupts on acpi0
On Wed, Dec 17, 2014 at 10:44:24AM +0100, mxb wrote: On 16 dec 2014, at 06:40, David Gwynne da...@gwynne.id.au wrote: others have hit this on r620s as well I don???t see it on mine. Others have hit a similar symptom on r620, caused by a different issue that was already fixed by kettenis a few months ago. -ml interrupt total rate irq0/clock 9587998940 1599 irq0/ipi136166514 22 irq144/acpi020 irq112/ix029053603446 4847 irq113/ix127844456217 4646 irq96/mfi080725871 irq114/ubsec0 3101629892 517 irq98/ehci0 1120 irq115/em0 4928262870 822 irq116/em1 211437268 35 irq99/ehci1280 irq100/ahci010 Total 7487162787712493 This is a pre-5.6 OpenBSD 5.6-current (GENERIC.MP) #394: Wed Oct 1 12:54:54 MDT 2014 dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP real mem = 8492285952 (8098MB) avail mem = 8257511424 (7874MB) mpath0 at root scsibus0 at mpath0: 256 targets mainbus0 at root bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xcf42c000 (99 entries) bios0: vendor Dell Inc. version 1.3.6 date 09/11/2012 bios0: Dell Inc. PowerEdge R620 acpi0 at bios0: rev 2 acpi0: sleep states S0 S4 S5 acpi0: tables DSDT FACP APIC SPCR HPET DMAR MCFG WD__ SLIC ERST HEST BERT EINJ TCPA PC__ SRAT SSDT acpi0: wakeup devices PCI0(S5) PCI1(S5) acpitimer0 at acpi0: 3579545 Hz, 24 bits acpimadt0 at acpi0 addr 0xfee0: PC-AT compat cpu0 at mainbus0: apid 0 (boot processor) cpu0: Intel(R) Xeon(R) CPU E5-2643 0 @ 3.30GHz, 3400.43 MHz cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,NXE,PAGE1GB,LONG,LAHF,PERF,ITSC cpu0: 256KB 64b/line 8-way L2 cache cpu0: smt 0, core 0, package 0 mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges cpu0: apic clock running at 99MHz cpu0: mwait min=64, max=64, C-substates=0.2.1.1.2, IBE cpu1 at mainbus0: apid 32 (application processor) cpu1: Intel(R) Xeon(R) CPU E5-2643 0 @ 3.30GHz, 3400.00 MHz cpu1: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,NXE,PAGE1GB,LONG,LAHF,PERF,ITSC cpu1: 256KB 64b/line 8-way L2 cache cpu1: smt 0, core 0, package 1 cpu2 at mainbus0: apid 2 (application processor) cpu2: Intel(R) Xeon(R) CPU E5-2643 0 @ 3.30GHz, 3400.00 MHz cpu2: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,NXE,PAGE1GB,LONG,LAHF,PERF,ITSC cpu2: 256KB 64b/line 8-way L2 cache cpu2: smt 0, core 1, package 0 cpu3 at mainbus0: apid 34 (application processor) cpu3: Intel(R) Xeon(R) CPU E5-2643 0 @ 3.30GHz, 3400.00 MHz cpu3: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,NXE,PAGE1GB,LONG,LAHF,PERF,ITSC cpu3: 256KB 64b/line 8-way L2 cache cpu3: smt 0, core 1, package 1 cpu4 at mainbus0: apid 4 (application processor) cpu4: Intel(R) Xeon(R) CPU E5-2643 0 @ 3.30GHz, 3400.00 MHz cpu4: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,NXE,PAGE1GB,LONG,LAHF,PERF,ITSC cpu4: 256KB 64b/line 8-way L2 cache cpu4: smt 0, core 2, package 0 cpu5 at mainbus0: apid 36 (application processor) cpu5: Intel(R) Xeon(R) CPU E5-2643 0 @ 3.30GHz, 3400.00 MHz cpu5: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,NXE,PAGE1GB,LONG,LAHF,PERF,ITSC cpu5: 256KB 64b/line 8-way L2 cache cpu5: smt 0, core 2, package 1 cpu6 at mainbus0: apid 6 (application processor) cpu6: Intel(R) Xeon(R) CPU E5-2643 0 @ 3.30GHz, 3400.00 MHz cpu6:
Re: [WIP] uhidcom(4) driver for USB HID based UART
At Wed, 17 Dec 2014 22:43:40 +1100, Jonathan Gray wrote: On Wed, Dec 17, 2014 at 07:49:59PM +0900, SASANO Takayoshi wrote: Hi, I am trying to write a driver for Silicon Labs CP2110 USB HID based UART. Here is work-in-progress code, and it seems to set uca.uhidev properly. (I wrote code/tested on 5.6-release and ported to -current.) Exar's XR21B1421 uses similar protocol so I named the driver uhidcom(4), but currently it is not supported --- too expensive to buy evaluation board. Isn't that name a bit too generic? We already have a USB HID based UART driver in the tree with ucycom(4), which apparently uses a different protocol? uslcom(4) is already used by CP210x, how about uslhcom(4)? slh means Silicon Lab's Hid protocol. Otherwise, uxrcom(4). Regards, -- SASANO Takayoshi u...@mx5.nisiq.net
delete turds from lex
There are lots of VMS and TURBOC and I don't even know what turds in lex. This firebombs some of the larger, more visible targets. Fun fact: /* cfront 1.2 defines c_plusplus instead of __cplusplus */ Index: flexdef.h === RCS file: /cvs/src/usr.bin/lex/flexdef.h,v retrieving revision 1.7 diff -u -p -r1.7 flexdef.h --- flexdef.h 3 Feb 2004 21:20:17 - 1.7 +++ flexdef.h 17 Dec 2014 22:31:21 - @@ -40,37 +40,11 @@ #include config.h -#ifdef __TURBOC__ -#define HAVE_STRING_H 1 -#define MS_DOS 1 -#ifndef __STDC__ -#define __STDC__ 1 -#endif - #pragma warn -pro - #pragma warn -rch - #pragma warn -use - #pragma warn -aus - #pragma warn -par - #pragma warn -pia -#endif - -#ifdef HAVE_STRING_H #include string.h -#else -#include strings.h -#endif -#ifdef HAVE_SYS_TYPES_H #include sys/types.h -#endif -#ifdef STDC_HEADERS #include stdlib.h -#else -#ifdef HAVE_MALLOC_H -#include malloc.h -#endif -#endif /* As an aid for the internationalization patch to flex, which @@ -95,18 +69,6 @@ #endif #endif -#ifdef VMS -#ifndef __VMS_POSIX -#define unlink remove -#define SHORT_FILE_NAMES -#endif -#endif - -#ifdef MS_DOS -#define SHORT_FILE_NAMES -#endif - - /* Maximum line length we'll have to deal with. */ #define MAXLINE 2048 @@ -125,7 +87,6 @@ #ifndef isascii #define isascii(c) ((c) = 0177) #endif - #define true 1 #define false 0 Index: initscan.c === RCS file: /cvs/src/usr.bin/lex/initscan.c,v retrieving revision 1.14 diff -u -p -r1.14 initscan.c --- initscan.c 4 Nov 2013 17:03:32 - 1.14 +++ initscan.c 17 Dec 2014 22:33:56 - @@ -13,15 +13,6 @@ #include stdio.h - -/* cfront 1.2 defines c_plusplus instead of __cplusplus */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - #ifdef __cplusplus #include stdlib.h @@ -42,15 +33,6 @@ #endif /* __STDC__ */ #endif /* ! __cplusplus */ - -#ifdef __TURBOC__ - #pragma warn -rch - #pragma warn -use -#include io.h -#include stdlib.h -#define YY_USE_CONST -#define YY_USE_PROTOS -#endif #ifdef YY_USE_CONST #define yyconst const Index: main.c === RCS file: /cvs/src/usr.bin/lex/main.c,v retrieving revision 1.14 diff -u -p -r1.14 main.c --- main.c 16 Mar 2014 18:38:30 - 1.14 +++ main.c 17 Dec 2014 22:32:54 - @@ -48,11 +48,6 @@ void flexinit PROTO((int, char**)); void readin PROTO((void)); void set_up_initial_allocations PROTO((void)); -#ifdef NEED_ARGV_FIXUP -extern void argv_fixup PROTO((int *, char ***)); -#endif - - /* these globals are all defined and commented in flexdef.h */ int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt; int interactive, caseins, lex_compat, do_yylineno, useecs, fulltbl, usemecs; @@ -117,14 +112,6 @@ static const char outfile_template[] = static const char backing_name[] = lex.bck; #endif -#ifdef THINK_C -#include console.h -#endif - -#ifdef MS_DOS -extern unsigned _stklen = 16384; -#endif - static char outfile_path[MAXLINE]; static int outfile_created = 0; static char *skelname = NULL; @@ -136,13 +123,6 @@ char **argv; { int i; -#ifdef THINK_C - argc = ccommand( argv ); -#endif -#ifdef NEED_ARGV_FIXUP - argv_fixup( argc, argv ); -#endif - flexinit( argc, argv ); readin(); @@ -973,17 +953,8 @@ _( Variable trailing context rules enta { if ( do_stdinit ) { - outn( #ifdef VMS ); - outn( #ifndef __VMS_POSIX ); - outn( yy_nostdinit ); - outn( #else ); - outn( yy_stdinit ); - outn( #endif ); - outn( #else ); outn( yy_stdinit ); - outn( #endif ); } - else outn( yy_nostdinit ); } Index: parse.y === RCS file: /cvs/src/usr.bin/lex/parse.y,v retrieving revision 1.8 diff -u -p -r1.8 parse.y --- parse.y 4 Jun 2003 17:34:44 - 1.8 +++ parse.y 17 Dec 2014 22:30:19 - @@ -43,46 +43,7 @@ /* $Header: /cvs/src/usr.bin/lex/parse.y,v 1.8 2003/06/04 17:34:44 millert Exp $ */ -/* Some versions of bison are broken in that they use alloca() but don't - * declare it properly. The following is the patented (just kidding!) - * #ifdef chud to fix the problem, courtesy of Francois Pinard. - */ -#ifdef YYBISON -/* AIX requires this to be the first thing in the file. What a piece. */ -# ifdef _AIX - #pragma alloca -# endif -#endif - #include flexdef.h - -/* The remainder of the alloca() cruft has to come after including flexdef.h, - * so HAVE_ALLOCA_H is (possibly) defined. -
[nitpicking] abort in arc4random?
getentropy*.c: cannot call abort() because some systems have unsafe corefiles arc4random.c: if(_rs_allocate(...) == -1) abort(); Am I missing any difference between the two cases? (brain,cvsweb,google+gmane weren't any help)
Re: [nitpicking] abort in arc4random?
getentropy*.c: cannot call abort() because some systems have unsafe corefiles arc4random.c: if(_rs_allocate(...) == -1) abort(); Am I missing any difference between the two cases? (brain,cvsweb,google+gmane weren't any help) Policy. getentropy() should eventually be a lower level intrinsic. It is an emulation of a system call on another system (ie. OpenBSD). arc4random() is written on top of this, it is a standard library routine. For example. Say you wrote a replacement library that had open() and fopen(). The open should not fatally abort -- it's job is to return errors. That is firmly specified -- go read the open() manual page to get the picture. But the upper level function, what it does is less refined and more flexible implementation wise.
Better/more upd(4) timedelta sensors
While my device does not seem to provide AtRateTimeToFull or AtRateTimeToEmpty, it does have RunTimeToEmpty. Then I found that SENSOR_TIMEDELTA values are in nanoseconds and that scaling for them was never implemented correctly. I am confused by the spec [1], though; see 4.2.5 - Battery Measures. The reported values are supposedly in minutes but hid_info.unit is 0x1001 (seconds) and observation of RunTimeToEmpty appears to agree. I don’t see any other drivers in the tree that pay attention to unit or unit_exponent fields, and don’t want to go down a rabbit hole if there’s no interest. As usual, feedback is welcome. [1] http://www.usb.org/developers/hidpage/pdcv10.pdf --david Index: upd.c === RCS file: /cvs/src/sys/dev/usb/upd.c,v retrieving revision 1.12 diff -u -p -r1.12 upd.c --- upd.c 11 Dec 2014 18:50:32 - 1.12 +++ upd.c 18 Dec 2014 05:02:30 - @@ -66,7 +66,11 @@ static struct upd_usage_entry upd_usage_ { HUP_BATTERY, HUB_AC_PRESENT, SENSOR_INDICATOR,ACPresent }, { HUP_BATTERY, HUB_ATRATE_TIMETOFULL, - SENSOR_TIMEDELTA,AtRateTimeToFull } + SENSOR_TIMEDELTA,AtRateTimeToFull }, + { HUP_BATTERY, HUB_ATRATE_TIMETOEMPTY, + SENSOR_TIMEDELTA,AtRateTimeToEmpty }, + { HUP_BATTERY, HUB_RUNTIMETO_EMPTY, + SENSOR_TIMEDELTA,RunTimeToEmpty }, }; struct upd_report { @@ -322,9 +326,9 @@ upd_update_sensors(struct upd_softc *sc, int repid) { struct upd_sensor *sensor; - ulong hdata, batpres; - ulong adjust; - int i; + int64_t adjust; + ulong batpres; + int hdata, i; sensor = upd_lookup_sensor(sc, HUP_BATTERY, HUB_BATTERY_PRESENT); batpres = sensor ? sensor-ksensor.value : -1; @@ -353,6 +357,11 @@ upd_update_sensors(struct upd_softc *sc, case HUB_FULLCHARGE_CAPACITY: adjust = 1000; /* scale adjust */ break; + case HUB_ATRATE_TIMETOFULL: + case HUB_ATRATE_TIMETOEMPTY: + case HUB_RUNTIMETO_EMPTY: + adjust = 10LL; /* XXX not minutes? */ + break; default: adjust = 1; /* no scale adjust */ break; @@ -363,7 +372,7 @@ upd_update_sensors(struct upd_softc *sc, sensor-ksensor.value = hdata * adjust; sensor-ksensor.status = SENSOR_S_OK; sensor-ksensor.flags = ~SENSOR_FINVALID; - DPRINTF((%s: hidget data: %lu\n, + DPRINTF((%s: hidget data: %d\n, sc-sc_sensordev.xname, hdata)); } }