Re: armv7 diff for testing
On Thu, Jul 21, 2016 at 12:38:35PM +1000, Jonathan Gray wrote: > On Wed, Jul 20, 2016 at 10:24:11PM -0300, Daniel Bolgheroni wrote: > > On Wed, Jul 13, 2016 at 11:39:54AM +0200, Mark Kettenis wrote: > > > The diff below removes the last board ID dependent code for the i.MX6 > > > platform. It affects all boards that use a Micrel PHY, which would > > > show up as "ukphy0" in your dmesg. If you have such a board (udoo, > > > novena and sabrelight, there may be others), I'd apprciate if you > > > could test this diff and check whether the network interface still > > > works. > > > > > > I'll probably commit the diff in a couple of days if I don't get any > > > test reports. > > > > Maybe not related to this commit, since Wandboard uses Atheros PHYs (AR8031, > > same family as AR8035 as in if_fec.c) instead of Micrel, but I'm running the > > latest snapshot and fec(4) does not show up. > > That turns out to be different interrupt data in the fdt to implement > a workaround for hardware errata. > > Patrick found the following two commits related to it and last I heard > was looking to find a way to handle it on his sabre lite board that > also has it. > > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=9fc77821b17155c6e0ab50b1e1dd80c2b0e63e98 > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=6261c4c8f13eb91f733e8ba6d67c409a2e841667 > > The following doesn't do the workaround but should at least get > things working again. Actually the pad configuration in those commits may mean this isn't enough. > > Index: if_fec.c > === > RCS file: /cvs/src/sys/arch/armv7/imx/if_fec.c,v > retrieving revision 1.8 > diff -u -p -r1.8 if_fec.c > --- if_fec.c 21 Jul 2016 02:32:23 - 1.8 > +++ if_fec.c 21 Jul 2016 02:34:02 - > @@ -303,7 +303,7 @@ fec_attach(struct device *parent, struct > > if (OF_getpropintarray(faa->fa_node, "interrupts-extended", > intr, sizeof(intr)) < sizeof(intr)) > - return; > + intr[2] = 0x76; > > sc->sc_node = faa->fa_node; > sc->sc_iot = faa->fa_iot; >
Re: armv7 diff for testing
On Wed, Jul 20, 2016 at 10:24:11PM -0300, Daniel Bolgheroni wrote: > On Wed, Jul 13, 2016 at 11:39:54AM +0200, Mark Kettenis wrote: > > The diff below removes the last board ID dependent code for the i.MX6 > > platform. It affects all boards that use a Micrel PHY, which would > > show up as "ukphy0" in your dmesg. If you have such a board (udoo, > > novena and sabrelight, there may be others), I'd apprciate if you > > could test this diff and check whether the network interface still > > works. > > > > I'll probably commit the diff in a couple of days if I don't get any > > test reports. > > Maybe not related to this commit, since Wandboard uses Atheros PHYs (AR8031, > same family as AR8035 as in if_fec.c) instead of Micrel, but I'm running the > latest snapshot and fec(4) does not show up. That turns out to be different interrupt data in the fdt to implement a workaround for hardware errata. Patrick found the following two commits related to it and last I heard was looking to find a way to handle it on his sabre lite board that also has it. https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=9fc77821b17155c6e0ab50b1e1dd80c2b0e63e98 https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=6261c4c8f13eb91f733e8ba6d67c409a2e841667 The following doesn't do the workaround but should at least get things working again. Index: if_fec.c === RCS file: /cvs/src/sys/arch/armv7/imx/if_fec.c,v retrieving revision 1.8 diff -u -p -r1.8 if_fec.c --- if_fec.c21 Jul 2016 02:32:23 - 1.8 +++ if_fec.c21 Jul 2016 02:34:02 - @@ -303,7 +303,7 @@ fec_attach(struct device *parent, struct if (OF_getpropintarray(faa->fa_node, "interrupts-extended", intr, sizeof(intr)) < sizeof(intr)) - return; + intr[2] = 0x76; sc->sc_node = faa->fa_node; sc->sc_iot = faa->fa_iot;
Re: armv7 diff for testing
On Wed, Jul 13, 2016 at 11:39:54AM +0200, Mark Kettenis wrote: > The diff below removes the last board ID dependent code for the i.MX6 > platform. It affects all boards that use a Micrel PHY, which would > show up as "ukphy0" in your dmesg. If you have such a board (udoo, > novena and sabrelight, there may be others), I'd apprciate if you > could test this diff and check whether the network interface still > works. > > I'll probably commit the diff in a couple of days if I don't get any > test reports. Maybe not related to this commit, since Wandboard uses Atheros PHYs (AR8031, same family as AR8035 as in if_fec.c) instead of Micrel, but I'm running the latest snapshot and fec(4) does not show up. -- U-Boot SPL 2016.07 (Jul 12 2016 - 15:05:51) Trying to boot from MMC1 U-Boot 2016.07 (Jul 12 2016 - 15:05:51 +1000) CPU: Freescale i.MX6SOLO rev1.1 at 792 MHz Reset cause: WDOG Board: Wandboard rev B1 I2C: ready DRAM: 512 MiB MMC: FSL_SDHC: 0, FSL_SDHC: 1 *** Warning - bad CRC, using default environment No panel detected: default to HDMI Display: HDMI (1024x768) In:serial Out: serial Err: serial Net: FEC [PRIME] Hit any key to stop autoboot: 0 switch to partitions #0, OK mmc0 is current device Scanning mmc 0:1... reading /imx6dl-wandboard-revb1.dtb 29934 bytes read in 20 ms (1.4 MiB/s) Found EFI removable media binary efi/boot/bootarm.efi reading efi/boot/bootarm.efi 65276 bytes read in 28 ms (2.2 MiB/s) ## Starting EFI application at 0x1200 ... Scanning disks on usb... Scanning disks on mmc... MMC: no card present MMC Device 2 not found MMC Device 3 not found Found 5 disks >> OpenBSD/armv7 BOOTARM 0.1 boot> cannot open sd0a:/etc/random.seed: No such file or directory booting sd0a:/bsd: 2093700+7928816+435440 [64+297616+142911]=0xa65b64 OpenBSD/armv7 booting ... arg0 0x0 arg1 0x2e55b26c arg2 0x1800 Allocating page tables freestart = 0x10d66000, free_pages = 127642 (0x0001f29a) IRQ stack: p0x10d94000 v0xc0d94000 ABT stack: p0x10d95000 v0xc0d95000 UND stack: p0x10d96000 v0xc0d96000 SVC stack: p0x10d97000 v0xc0d97000 Creating L1 page table at 0x10d68000 Mapping kernel Constructing L2 page tables undefined page pmap board type: 240497260 Copyright (c) 1982, 1986, 1989, 1991, 1993 The Regents of the University of California. All rights reserved. Copyright (c) 1995-2016 OpenBSD. All rights reserved. http://www.OpenBSD.org OpenBSD 6.0 (RAMDISK) #88: Tue Jul 19 22:37:35 AEST 2016 j...@armv7.jsg.id.au:/usr/src/sys/arch/armv7/compile/RAMDISK real mem = 536870912 (512MB) avail mem = 512233472 (488MB) mainbus0 at root: Wandboard i.MX6 Dual Lite Board rev B1 cpu0 at mainbus0: ARM Cortex A9 R2 rev 10 (ARMv7 core) cpu0: DC enabled IC enabled WB disabled EABT branch prediction enabled cpu0: 32KB(32b/l,4way) I-cache, 32KB(32b/l,4way) wr-back D-cache cortex0 at mainbus0 ampintc0 at cortex0 nirq 160 amptimer0 at cortex0: tick rate 396000 KHz armliicc0 at cortex0: rtl 8 waymask: 0x000f imx0 at mainbus0 imxccm0 at imx0: imx6 rev 1.1 CPU freq: 792 MHz imxiomuxc0 at imx0 imxocotp0 at imx0 simplebus0 at mainbus0: "soc" simplebus1 at simplebus0: "aips-bus" simplebus2 at simplebus1: "spba-bus" imxuart0 at simplebus2: console imxgpio0 at simplebus1 imxgpio1 at simplebus1 imxgpio2 at simplebus1 imxgpio3 at simplebus1 imxgpio4 at simplebus1 imxgpio5 at simplebus1 imxgpio6 at simplebus1 imxdog0 at simplebus1 simplebus3 at simplebus1: "anatop" simplebus4 at simplebus0: "aips-bus" imxehci0 at simplebus4 usb0 at imxehci0: USB revision 2.0 uhub0 at usb0 "i.MX6 EHCI root hub" rev 2.00/1.00 addr 1 imxehci1 at simplebus4 usb1 at imxehci1: USB revision 2.0 uhub1 at usb1 "i.MX6 EHCI root hub" rev 2.00/1.00 addr 1 fec0 at simplebus4imxesdhc0 at simplebus4 imxesdhc0: 198 MHz base clock sdmmc0 at imxesdhc0: 4-bit, mmc high-speed, dma imxesdhc1 at simplebus4 imxesdhc1: 198 MHz base clock sdmmc1 at imxesdhc1: 4-bit, mmc high-speed, dma imxesdhc2 at simplebus4 imxesdhc2: 198 MHz base clock sdmmc2 at imxesdhc2: 4-bit, mmc high-speed, dma imxiic0 at simplebus4 iic0 at imxiic0 imxiic1 at simplebus4 iic1 at imxiic1 "fsl,sgtl5000" at iic1 addr 0xa not configured imxuart1 at simplebus4 simplebus5 at mainbus0: "regulators" sdmmc1: can't enable card scsibus0 at sdmmc2: 2 targets, initiator 0 sd0 at scsibus0 targ 1 lun 0: SCSI2 0/direct fixed sd0: 7580MB, 512 bytes/sector, 15523840 sectors boot device: sd0 root on rd0a swap on rd0b dump on rd0b WARNING: CHECK AND RESET THE DATE! erase ^?, werase ^W, kill ^U, intr ^C, status ^T Welcome to the OpenBSD/armv7 6.0 installation program. (I)nstall, (U)pgrade, (A)utoinstall or (S)hell? s # ifconfig -a lo0: flags=8008 mtu 32768 llprio 3 groups: lo # -- db
Re: libc: wrap fpgetround()
On Wed, 20 Jul 2016 23:17:57 +0200, Mark Kettenis wrote: > The code needs to include hidden/ieeefp.h to do the magic wrapping for > internal usage of these symbols in libc. Ah, I missed the fpgetround() call under #ifdef _SOFT_FLOAT. That explains it. - todd
Re: libc: wrap fpgetround()
> From: "Todd C. Miller" > Date: Wed, 20 Jul 2016 14:59:14 -0600 > > On Wed, 20 Jul 2016 21:24:17 +0200, Philip Guenther wrote: > > > Wrap fpgetround() so internal calls to it (seen on arm, powerpc, and sh) > > go direct instead of through the PLT. > > > > The first two diff files below pull in the missing so the > > wrapping is seen; the rest of the diff chunks perform the wrapping. > > Not sure why arch/powerpc/gen/flt_rounds.c needs ieeefp.h when it > is prototyped in float.h. The code needs to include hidden/ieeefp.h to do the magic wrapping for internal usage of these symbols in libc.
Re: libc/arm: PLT cleanup
> Date: Wed, 20 Jul 2016 20:59:55 +0200 > From: Philip Guenther > > Updated diff: > - replace the remaining uses of PIC_SYM(CERROR,PLT) with plain CERROR This bit looks ok to me > - add setjmp xor cookies > - switch _?(set|long)jmp from sigblock/sigsetmask to sigprocmask But it is simply too hot to grok larger chunks of arm assembly right now. > Index: lib/libc/arch/arm/DEFS.h > === > RCS file: lib/libc/arch/arm/DEFS.h > diff -N lib/libc/arch/arm/DEFS.h > --- /dev/null 1 Jan 1970 00:00:00 - > +++ lib/libc/arch/arm/DEFS.h 18 Jul 2016 13:32:23 - > @@ -0,0 +1,40 @@ > +/* $OpenBSD$ */ > +/* > + * Copyright (c) 2016 Philip Guenther > + * > + * 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. > + */ > + > +#include > + > +/* > + * We define a hidden alias with the prefix "_libc_" for each global symbol > + * that may be used internally. By referencing _libc_x instead of x, other > + * parts of libc prevent overriding by the application and avoid unnecessary > + * relocations. > + */ > +#define _HIDDEN(x) _libc_##x > +#define _HIDDEN_ALIAS(x,y) \ > + STRONG_ALIAS(_HIDDEN(x),y); \ > + .hidden _HIDDEN(x) > +#define _HIDDEN_FALIAS(x,y) \ > + _HIDDEN_ALIAS(x,y); \ > + .type _HIDDEN(x),#function > + > +/* > + * For functions implemented in ASM that aren't syscalls. > + * END_STRONG(x) Like DEF_STRONG() in C; for standard/reserved C names > + * END_WEAK(x) Like DEF_WEAK() in C; for non-ISO C names > + */ > +#define END_STRONG(x) END(x); _HIDDEN_FALIAS(x,x); END(_HIDDEN(x)) > +#define END_WEAK(x) END_STRONG(x); .weak x > Index: lib/libc/arch/arm/SYS.h > === > RCS file: /data/src/openbsd/src/lib/libc/arch/arm/SYS.h,v > retrieving revision 1.15 > diff -u -p -r1.15 SYS.h > --- lib/libc/arch/arm/SYS.h 7 May 2016 19:05:21 - 1.15 > +++ lib/libc/arch/arm/SYS.h 19 Jul 2016 16:31:49 - > @@ -35,33 +35,10 @@ > * from: @(#)SYS.h 5.5 (Berkeley) 5/7/91 > */ > > -#include > +#include "DEFS.h" > #include > > > -/* > - * We define a hidden alias with the prefix "_libc_" for each global symbol > - * that may be used internally. By referencing _libc_x instead of x, other > - * parts of libc prevent overriding by the application and avoid unnecessary > - * relocations. > - */ > -#define _HIDDEN(x) _libc_##x > -#define _HIDDEN_ALIAS(x,y) \ > - STRONG_ALIAS(_HIDDEN(x),y); \ > - .hidden _HIDDEN(x) > -#define _HIDDEN_FALIAS(x,y) \ > - _HIDDEN_ALIAS(x,y); \ > - .type _HIDDEN(x),#function > - > -/* > - * For functions implemented in ASM that aren't syscalls. > - * END_STRONG(x) Like DEF_STRONG() in C; for standard/reserved C names > - * END_WEAK(x) Like DEF_WEAK() in C; for non-ISO C names > - */ > -#define END_STRONG(x) END(x); _HIDDEN_FALIAS(x,x); END(_HIDDEN(x)) > -#define END_WEAK(x) END_STRONG(x); .weak x > - > - > #define SYSENTRY(x) \ > .weak _C_LABEL(x); \ > _C_LABEL(x) = _C_LABEL(_thread_sys_ ## x); \ > @@ -90,10 +67,10 @@ > > #define _SYSCALL(x, y) > \ > _SYSCALL_NOERROR(x,y); \ > - bcs PIC_SYM(CERROR, PLT) > + bcs CERROR > #define _SYSCALL_HIDDEN(x, y) > \ > _SYSCALL_HIDDEN_NOERROR(x,y); \ > - bcs PIC_SYM(CERROR, PLT) > + bcs CERROR > > #define SYSCALL_NOERROR(x) \ > _SYSCALL_NOERROR(x,x) > Index: lib/libc/arch/arm/gen/_setjmp.S > === > RCS file: /data/src/openbsd/src/lib/libc/arch/arm/gen/_setjmp.S,v > retrieving revision 1.3 > diff -u -p -r1.3 _setjmp.S > --- lib/libc/arch/arm/gen/_setjmp.S 23 May 2016 00:18:57 - 1.3 > +++ lib/libc/arch/arm/gen/_setjmp.S 21 Jul 2016 02:00:08 - > @@ -33,9 +33,18 @@ > * SUCH
Re: libc: wrap fpgetround()
> Date: Wed, 20 Jul 2016 21:24:17 +0200 > From: Philip Guenther > > Wrap fpgetround() so internal calls to it (seen on arm, powerpc, and sh) > go direct instead of through the PLT. > > The first two diff files below pull in the missing so the > wrapping is seen; the rest of the diff chunks perform the wrapping. > > ok? Looks ok, but I think this turd polishing should wait until after 6.0 is out of the door. > Index: arch/powerpc/gen/flt_rounds.c > === > RCS file: /data/src/openbsd/src/lib/libc/arch/powerpc/gen/flt_rounds.c,v > retrieving revision 1.6 > diff -u -p -r1.6 flt_rounds.c > --- arch/powerpc/gen/flt_rounds.c 27 Oct 2015 05:54:49 - 1.6 > +++ arch/powerpc/gen/flt_rounds.c 18 Jul 2016 14:05:04 - > @@ -34,6 +34,7 @@ > > #include > #include > +#include > > > static const int map[] = { > @@ -44,7 +45,7 @@ static const int map[] = { > }; > > int > -__flt_rounds() > +__flt_rounds(void) > { > #ifdef _SOFT_FLOAT > return map[fpgetround()]; > Index: arch/sh/gen/flt_rounds.c > === > RCS file: /data/src/openbsd/src/lib/libc/arch/sh/gen/flt_rounds.c,v > retrieving revision 1.5 > diff -u -p -r1.5 flt_rounds.c > --- arch/sh/gen/flt_rounds.c 27 Oct 2015 05:54:49 - 1.5 > +++ arch/sh/gen/flt_rounds.c 18 Jul 2016 14:04:53 - > @@ -18,7 +18,7 @@ > > #include > #include > -#include > +#include > > static const int rndmap[] = { > 1, /* round to nearest */ > Index: hidden/ieeefp.h > === > RCS file: hidden/ieeefp.h > diff -N hidden/ieeefp.h > --- /dev/null 1 Jan 1970 00:00:00 - > +++ hidden/ieeefp.h 18 Jul 2016 14:02:01 - > @@ -0,0 +1,30 @@ > +/* $OpenBSD$ */ > +/* > + * Copyright (c) 2016 Philip Guenther > + * > + * 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. > + */ > + > +#ifndef _LIBC_IEEEFP_H_ > +#define _LIBC_IEEEFP_H_ > + > +#include_next > + > +PROTO_DEPRECATED(fpgetmask); > +PROTO_NORMAL(fpgetround); > +PROTO_DEPRECATED(fpgetsticky); > +PROTO_DEPRECATED(fpsetmask); > +PROTO_DEPRECATED(fpsetround); > +PROTO_DEPRECATED(fpsetsticky); > + > +#endif /* _LIBC_IEEEFP_H_ */ > Index: arch/alpha/gen/fpgetround.c > === > RCS file: /data/src/openbsd/src/lib/libc/arch/alpha/gen/fpgetround.c,v > retrieving revision 1.4 > diff -u -p -r1.4 fpgetround.c > --- arch/alpha/gen/fpgetround.c 7 Aug 2005 16:40:13 - 1.4 > +++ arch/alpha/gen/fpgetround.c 18 Jul 2016 14:37:15 - > @@ -36,7 +36,7 @@ > #include > > fp_rnd > -fpgetround() > +fpgetround(void) > { > double fpcrval; > u_int64_t old; > @@ -48,3 +48,4 @@ fpgetround() > > return ((old >> 58) & 0x3); > } > +DEF_WEAK(fpgetround); > Index: arch/hppa/gen/fpgetround.c > === > RCS file: /data/src/openbsd/src/lib/libc/arch/hppa/gen/fpgetround.c,v > retrieving revision 1.4 > diff -u -p -r1.4 fpgetround.c > --- arch/hppa/gen/fpgetround.c18 Apr 2014 15:09:52 - 1.4 > +++ arch/hppa/gen/fpgetround.c18 Jul 2016 14:37:18 - > @@ -8,10 +8,11 @@ > #include > > fp_rnd > -fpgetround() > +fpgetround(void) > { > u_int64_t fpsr; > > __asm__ volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr)); > return ((fpsr >> 41) & 0x3); > } > +DEF_WEAK(fpgetround); > Index: arch/m88k/gen/fpgetround.c > === > RCS file: /data/src/openbsd/src/lib/libc/arch/m88k/gen/fpgetround.c,v > retrieving revision 1.4 > diff -u -p -r1.4 fpgetround.c > --- arch/m88k/gen/fpgetround.c5 Jan 2013 11:20:55 - 1.4 > +++ arch/m88k/gen/fpgetround.c18 Jul 2016 14:37:20 - > @@ -9,10 +9,11 @@ > #include > > fp_rnd > -fpgetround() > +fpgetround(void) > { > int x; > > __asm__ volatile ("fldcr %0, %%fcr63" : "=r" (x)); > return (x >> 14) & 0x03; > } > +DEF_WEAK(fpgetround); > Index: arch/mips64/gen/fpgetround.c > === > RCS file: /data/src/op
Re: libc: wrap fpgetround()
On Wed, 20 Jul 2016 21:24:17 +0200, Philip Guenther wrote: > Wrap fpgetround() so internal calls to it (seen on arm, powerpc, and sh) > go direct instead of through the PLT. > > The first two diff files below pull in the missing so the > wrapping is seen; the rest of the diff chunks perform the wrapping. Not sure why arch/powerpc/gen/flt_rounds.c needs ieeefp.h when it is prototyped in float.h. Looks OK otherwise. - todd
Re: tcpbench(4) support for AF_UNIX
On Wednesday, 20 July 2016, Bob Beck wrote: > > > On Wednesday, 20 July 2016, Henning Brauer > wrote: > >> * Sebastian Benoit [2016-07-20 21:42]: >> > Claudio Jeker(cje...@diehard.n-r-g.com) on 2016.07.20 19:08:51 +0200: >> > > On Wed, Jul 20, 2016 at 04:09:48PM +0200, Claudio Jeker wrote: >> > > > For testing I want to abuse tcpbench to work over AF_UNIX sockets. >> > > > This diff does exactly that with minimal extras. Especially the unix >> > > > socket is not removed from the filesystem when closed. I don't want >> to >> > > > add pledge cpath to tcpbench just for that. >> > > > >> > > >> > > New version that documents the -R feature that I sneaked in (without >> > > realizing) and also fixes the documentation for -U a bit. >> > > I added -R some time ago to stress test different mbuf sizes. >> tcpbench is >> > > a test tool for me :) >> > >> > ich habe es kompiliert und getestet. >> > >> > ok, jawohl. >> >> jawoll! >> >> anybody left on tech who doesn't (pretend to) speak german? > > > Ich habe saurkraut in meinen lederhosen. > > Humppa Macht frei. > > Nicht Schiessen ich bin Kanadiener. > > that last one also because my toilet has no shelf for you to inspect it. > -- >> Henning Brauer, h...@bsws.de, henn...@openbsd.org >> BS Web Services GmbH, http://bsws.de, Full-Service ISP >> Secure Hosting, Mail and DNS. Virtual & Dedicated Servers, Root to Fully >> Managed >> Henning Brauer Consulting, http://henningbrauer.com/ >> >>
Re: tcpbench(4) support for AF_UNIX
On Wednesday, 20 July 2016, Henning Brauer wrote: > * Sebastian Benoit > [2016-07-20 21:42]: > > Claudio Jeker(cje...@diehard.n-r-g.com ) on 2016.07.20 > 19:08:51 +0200: > > > On Wed, Jul 20, 2016 at 04:09:48PM +0200, Claudio Jeker wrote: > > > > For testing I want to abuse tcpbench to work over AF_UNIX sockets. > > > > This diff does exactly that with minimal extras. Especially the unix > > > > socket is not removed from the filesystem when closed. I don't want > to > > > > add pledge cpath to tcpbench just for that. > > > > > > > > > > New version that documents the -R feature that I sneaked in (without > > > realizing) and also fixes the documentation for -U a bit. > > > I added -R some time ago to stress test different mbuf sizes. tcpbench > is > > > a test tool for me :) > > > > ich habe es kompiliert und getestet. > > > > ok, jawohl. > > jawoll! > > anybody left on tech who doesn't (pretend to) speak german? Ich habe saurkraut in meinen lederhosen. Humppa Macht frei. Nicht Schiessen ich bin Kanadiener. > -- > Henning Brauer, h...@bsws.de , henn...@openbsd.org > > BS Web Services GmbH, http://bsws.de, Full-Service ISP > Secure Hosting, Mail and DNS. Virtual & Dedicated Servers, Root to Fully > Managed > Henning Brauer Consulting, http://henningbrauer.com/ > >
Re: tcpbench(4) support for AF_UNIX
* Sebastian Benoit [2016-07-20 21:42]: > Claudio Jeker(cje...@diehard.n-r-g.com) on 2016.07.20 19:08:51 +0200: > > On Wed, Jul 20, 2016 at 04:09:48PM +0200, Claudio Jeker wrote: > > > For testing I want to abuse tcpbench to work over AF_UNIX sockets. > > > This diff does exactly that with minimal extras. Especially the unix > > > socket is not removed from the filesystem when closed. I don't want to > > > add pledge cpath to tcpbench just for that. > > > > > > > New version that documents the -R feature that I sneaked in (without > > realizing) and also fixes the documentation for -U a bit. > > I added -R some time ago to stress test different mbuf sizes. tcpbench is > > a test tool for me :) > > ich habe es kompiliert und getestet. > > ok, jawohl. jawoll! anybody left on tech who doesn't (pretend to) speak german? -- Henning Brauer, h...@bsws.de, henn...@openbsd.org BS Web Services GmbH, http://bsws.de, Full-Service ISP Secure Hosting, Mail and DNS. Virtual & Dedicated Servers, Root to Fully Managed Henning Brauer Consulting, http://henningbrauer.com/
urtwn: heed rtsthreshold
Same rts threshold fix as for rtwn(4). Index: if_urtwn.c === RCS file: /cvs/src/sys/dev/usb/if_urtwn.c,v retrieving revision 1.65 diff -u -p -r1.65 if_urtwn.c --- if_urtwn.c 17 Jun 2016 10:53:55 - 1.65 +++ if_urtwn.c 20 Jul 2016 19:47:09 - @@ -1299,7 +1299,10 @@ urtwn_tx(void *cookie, struct mbuf *m, s SM(R92C_TXDW1_RAID, raid) | R92C_TXDW1_AGGBK); } - if (ic->ic_flags & IEEE80211_F_USEPROT) { + if (m->m_pkthdr.len + IEEE80211_CRC_LEN > ic->ic_rtsthreshold) { + txd->txdw4 |= htole32(R92C_TXDW4_RTSEN | + R92C_TXDW4_HWRTSEN); + } else if (ic->ic_flags & IEEE80211_F_USEPROT) { if (ic->ic_protmode == IEEE80211_PROT_CTSONLY) { txd->txdw4 |= htole32(R92C_TXDW4_CTS2SELF | R92C_TXDW4_HWRTSEN);
rtwn: heed rts threshold
The rtwn(4) driver ignores the rts threshold value set by the stack. This fixes it: Index: if_rtwn.c === RCS file: /cvs/src/sys/dev/pci/if_rtwn.c,v retrieving revision 1.22 diff -u -p -r1.22 if_rtwn.c --- if_rtwn.c 17 Jun 2016 10:53:55 - 1.22 +++ if_rtwn.c 20 Jul 2016 19:10:38 - @@ -985,7 +985,10 @@ rtwn_tx(void *cookie, struct mbuf *m, st SM(R92C_TXDW1_RAID, raid) | R92C_TXDW1_AGGBK); - if (ic->ic_flags & IEEE80211_F_USEPROT) { + if (m->m_pkthdr.len + IEEE80211_CRC_LEN > ic->ic_rtsthreshold) { + txd->txdw4 |= htole32(R92C_TXDW4_RTSEN | + R92C_TXDW4_HWRTSEN); + } else if (ic->ic_flags & IEEE80211_F_USEPROT) { if (ic->ic_protmode == IEEE80211_PROT_CTSONLY) { txd->txdw4 |= htole32(R92C_TXDW4_CTS2SELF | R92C_TXDW4_HWRTSEN);
Re: tcpbench(4) support for AF_UNIX
Claudio Jeker(cje...@diehard.n-r-g.com) on 2016.07.20 19:08:51 +0200: > On Wed, Jul 20, 2016 at 04:09:48PM +0200, Claudio Jeker wrote: > > For testing I want to abuse tcpbench to work over AF_UNIX sockets. > > This diff does exactly that with minimal extras. Especially the unix > > socket is not removed from the filesystem when closed. I don't want to > > add pledge cpath to tcpbench just for that. > > > > New version that documents the -R feature that I sneaked in (without > realizing) and also fixes the documentation for -U a bit. > I added -R some time ago to stress test different mbuf sizes. tcpbench is > a test tool for me :) ich habe es kompiliert und getestet. ok, jawohl. > > -- > :wq Claudio > > Index: tcpbench.1 > === > RCS file: /cvs/src/usr.bin/tcpbench/tcpbench.1,v > retrieving revision 1.20 > diff -u -p -r1.20 tcpbench.1 > --- tcpbench.119 Aug 2014 03:28:53 - 1.20 > +++ tcpbench.120 Jul 2016 16:11:44 - > @@ -24,7 +24,7 @@ > .Nm > .Fl l > .Nm > -.Op Fl 46uv > +.Op Fl 46UuRv > .Op Fl B Ar buf > .Op Fl b Ar addr > .Op Fl k Ar kvars > @@ -39,7 +39,7 @@ > .Nm > .Bk -words > .Fl s > -.Op Fl 46uv > +.Op Fl 46Uuv > .Op Fl B Ar buf > .Op Fl k Ar kvars > .Op Fl p Ar port > @@ -47,6 +47,7 @@ > .Op Fl S Ar space > .Op Fl T Ar toskeyword > .Op Fl V Ar rtable > +.Op Ar hostname > .Ek > .Sh DESCRIPTION > .Nm > @@ -105,6 +106,9 @@ Use the given number of TCP connections > UDP is connectionless so this option isn't valid. > .It Fl p Ar port > Specify the port used for the test stream (default: 12345). > +.It Fl R > +In client mode the write buffer size is randomized up to the size specified > via > +.Fl B . > .It Fl r Ar interval > Specify the statistics interval reporting rate in milliseconds (default: > 1000). > .It Fl S Ar space > @@ -138,6 +142,11 @@ or a number in either hex or decimal. > Stop after > .Ar secs > seconds. > +.It Fl U > +Use AF_UNIX sockets instead of IPv4 or IPv6 sockets. > +In client and server mode > +.Ar hostname > +is used as the path to the AF_UNIX socket. > .It Fl u > Use UDP instead of TCP; this must be specified on both the client > and the server. > Index: tcpbench.c > === > RCS file: /cvs/src/usr.bin/tcpbench/tcpbench.c,v > retrieving revision 1.50 > diff -u -p -r1.50 tcpbench.c > --- tcpbench.c6 Apr 2016 14:09:06 - 1.50 > +++ tcpbench.c20 Jul 2016 16:05:15 - > @@ -21,6 +21,7 @@ > #include > #include > #include > +#include > > #include > > @@ -66,6 +67,8 @@ struct { > int Tflag;/* ToS if != -1 */ > int vflag;/* Verbose */ > int uflag;/* UDP mode */ > + int Uflag;/* UNIX (AF_LOCAL) mode */ > + int Rflag;/* randomize client write size */ > kvm_t*kvmh; /* Kvm handler */ > char**kvars;/* Kvm enabled vars */ > u_longktcbtab; /* Ktcb */ > @@ -179,11 +182,11 @@ usage(void) > { > fprintf(stderr, > "usage: tcpbench -l\n" > - " tcpbench [-46uv] [-B buf] [-b addr] [-k kvars] [-n > connections]\n" > + " tcpbench [-46UuRv] [-B buf] [-b addr] [-k kvars] [-n > connections]\n" > "[-p port] [-r interval] [-S space] [-T > toskeyword]\n" > "[-t secs] [-V rtable] hostname\n" > - " tcpbench -s [-46uv] [-B buf] [-k kvars] [-p port]\n" > - "[-r interval] [-S space] [-T toskeyword] [-V > rtable]\n"); > + " tcpbench -s [-46Uuv] [-B buf] [-k kvars] [-p port] [-r > interval]\n" > + "[-S space] [-T toskeyword] [-V rtable] > [hostname]\n"); > exit(1); > } > > @@ -212,6 +215,11 @@ saddr_ntop(const struct sockaddr *addr, > char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV]; > int herr; > > + if (addr->sa_family == AF_UNIX) { > + struct sockaddr_un *sun = (struct sockaddr_un *)addr; > + snprintf(buf, len, "%s", sun->sun_path); > + return; > + } > if ((herr = getnameinfo(addr, alen, hbuf, sizeof(hbuf), > pbuf, sizeof(pbuf), NI_NUMERICHOST|NI_NUMERICSERV)) != 0) { > if (herr == EAI_SYSTEM) > @@ -805,7 +813,8 @@ server_init(struct addrinfo *aitop, stru > fprintf(stderr, "bound to fd %d\n", sock); > lnfds++; > } > - freeaddrinfo(aitop); > + if (!ptb->Uflag) > + freeaddrinfo(aitop); > if (lnfds == 0) > errx(1, "No working listen addresses found"); > } > @@ -815,8 +824,11 @@ client_handle_sc(int fd, short event, vo > { > struct statctx *sc = v_sc; > ssize_t n; > + size_t blen = sc->buflen; > > - if ((n = write(sc->fd, sc->buf, sc->buflen)) == -1) { > + if (ptb->R
libc: wrap fpgetround()
Wrap fpgetround() so internal calls to it (seen on arm, powerpc, and sh) go direct instead of through the PLT. The first two diff files below pull in the missing so the wrapping is seen; the rest of the diff chunks perform the wrapping. ok? Philip Index: arch/powerpc/gen/flt_rounds.c === RCS file: /data/src/openbsd/src/lib/libc/arch/powerpc/gen/flt_rounds.c,v retrieving revision 1.6 diff -u -p -r1.6 flt_rounds.c --- arch/powerpc/gen/flt_rounds.c 27 Oct 2015 05:54:49 - 1.6 +++ arch/powerpc/gen/flt_rounds.c 18 Jul 2016 14:05:04 - @@ -34,6 +34,7 @@ #include #include +#include static const int map[] = { @@ -44,7 +45,7 @@ static const int map[] = { }; int -__flt_rounds() +__flt_rounds(void) { #ifdef _SOFT_FLOAT return map[fpgetround()]; Index: arch/sh/gen/flt_rounds.c === RCS file: /data/src/openbsd/src/lib/libc/arch/sh/gen/flt_rounds.c,v retrieving revision 1.5 diff -u -p -r1.5 flt_rounds.c --- arch/sh/gen/flt_rounds.c27 Oct 2015 05:54:49 - 1.5 +++ arch/sh/gen/flt_rounds.c18 Jul 2016 14:04:53 - @@ -18,7 +18,7 @@ #include #include -#include +#include static const int rndmap[] = { 1, /* round to nearest */ Index: hidden/ieeefp.h === RCS file: hidden/ieeefp.h diff -N hidden/ieeefp.h --- /dev/null 1 Jan 1970 00:00:00 - +++ hidden/ieeefp.h 18 Jul 2016 14:02:01 - @@ -0,0 +1,30 @@ +/* $OpenBSD$ */ +/* + * Copyright (c) 2016 Philip Guenther + * + * 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. + */ + +#ifndef _LIBC_IEEEFP_H_ +#define _LIBC_IEEEFP_H_ + +#include_next + +PROTO_DEPRECATED(fpgetmask); +PROTO_NORMAL(fpgetround); +PROTO_DEPRECATED(fpgetsticky); +PROTO_DEPRECATED(fpsetmask); +PROTO_DEPRECATED(fpsetround); +PROTO_DEPRECATED(fpsetsticky); + +#endif /* _LIBC_IEEEFP_H_ */ Index: arch/alpha/gen/fpgetround.c === RCS file: /data/src/openbsd/src/lib/libc/arch/alpha/gen/fpgetround.c,v retrieving revision 1.4 diff -u -p -r1.4 fpgetround.c --- arch/alpha/gen/fpgetround.c 7 Aug 2005 16:40:13 - 1.4 +++ arch/alpha/gen/fpgetround.c 18 Jul 2016 14:37:15 - @@ -36,7 +36,7 @@ #include fp_rnd -fpgetround() +fpgetround(void) { double fpcrval; u_int64_t old; @@ -48,3 +48,4 @@ fpgetround() return ((old >> 58) & 0x3); } +DEF_WEAK(fpgetround); Index: arch/hppa/gen/fpgetround.c === RCS file: /data/src/openbsd/src/lib/libc/arch/hppa/gen/fpgetround.c,v retrieving revision 1.4 diff -u -p -r1.4 fpgetround.c --- arch/hppa/gen/fpgetround.c 18 Apr 2014 15:09:52 - 1.4 +++ arch/hppa/gen/fpgetround.c 18 Jul 2016 14:37:18 - @@ -8,10 +8,11 @@ #include fp_rnd -fpgetround() +fpgetround(void) { u_int64_t fpsr; __asm__ volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr)); return ((fpsr >> 41) & 0x3); } +DEF_WEAK(fpgetround); Index: arch/m88k/gen/fpgetround.c === RCS file: /data/src/openbsd/src/lib/libc/arch/m88k/gen/fpgetround.c,v retrieving revision 1.4 diff -u -p -r1.4 fpgetround.c --- arch/m88k/gen/fpgetround.c 5 Jan 2013 11:20:55 - 1.4 +++ arch/m88k/gen/fpgetround.c 18 Jul 2016 14:37:20 - @@ -9,10 +9,11 @@ #include fp_rnd -fpgetround() +fpgetround(void) { int x; __asm__ volatile ("fldcr %0, %%fcr63" : "=r" (x)); return (x >> 14) & 0x03; } +DEF_WEAK(fpgetround); Index: arch/mips64/gen/fpgetround.c === RCS file: /data/src/openbsd/src/lib/libc/arch/mips64/gen/fpgetround.c,v retrieving revision 1.2 diff -u -p -r1.2 fpgetround.c --- arch/mips64/gen/fpgetround.c7 Aug 2005 16:40:15 - 1.2 +++ arch/mips64/gen/fpgetround.c18 Jul 2016 14:37:22 - @@ -7,10 +7,11 @@ #include fp_rnd -fpgetround() +fpgetround(void) { int x; __asm__("cfc1 %0,$31" : "=r" (x)); return x & 0x03; } +DEF_WEAK(fpgetround); Index: arch/pow
Re: libc/arm: PLT cleanup
Updated diff: - replace the remaining uses of PIC_SYM(CERROR,PLT) with plain CERROR - add setjmp xor cookies - switch _?(set|long)jmp from sigblock/sigsetmask to sigprocmask ok? Index: lib/libc/arch/arm/DEFS.h === RCS file: lib/libc/arch/arm/DEFS.h diff -N lib/libc/arch/arm/DEFS.h --- /dev/null 1 Jan 1970 00:00:00 - +++ lib/libc/arch/arm/DEFS.h18 Jul 2016 13:32:23 - @@ -0,0 +1,40 @@ +/* $OpenBSD$ */ +/* + * Copyright (c) 2016 Philip Guenther + * + * 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. + */ + +#include + +/* + * We define a hidden alias with the prefix "_libc_" for each global symbol + * that may be used internally. By referencing _libc_x instead of x, other + * parts of libc prevent overriding by the application and avoid unnecessary + * relocations. + */ +#define _HIDDEN(x) _libc_##x +#define _HIDDEN_ALIAS(x,y) \ + STRONG_ALIAS(_HIDDEN(x),y); \ + .hidden _HIDDEN(x) +#define _HIDDEN_FALIAS(x,y)\ + _HIDDEN_ALIAS(x,y); \ + .type _HIDDEN(x),#function + +/* + * For functions implemented in ASM that aren't syscalls. + * END_STRONG(x) Like DEF_STRONG() in C; for standard/reserved C names + * END_WEAK(x) Like DEF_WEAK() in C; for non-ISO C names + */ +#defineEND_STRONG(x) END(x); _HIDDEN_FALIAS(x,x); END(_HIDDEN(x)) +#defineEND_WEAK(x) END_STRONG(x); .weak x Index: lib/libc/arch/arm/SYS.h === RCS file: /data/src/openbsd/src/lib/libc/arch/arm/SYS.h,v retrieving revision 1.15 diff -u -p -r1.15 SYS.h --- lib/libc/arch/arm/SYS.h 7 May 2016 19:05:21 - 1.15 +++ lib/libc/arch/arm/SYS.h 19 Jul 2016 16:31:49 - @@ -35,33 +35,10 @@ * from: @(#)SYS.h 5.5 (Berkeley) 5/7/91 */ -#include +#include "DEFS.h" #include -/* - * We define a hidden alias with the prefix "_libc_" for each global symbol - * that may be used internally. By referencing _libc_x instead of x, other - * parts of libc prevent overriding by the application and avoid unnecessary - * relocations. - */ -#define _HIDDEN(x) _libc_##x -#define _HIDDEN_ALIAS(x,y) \ - STRONG_ALIAS(_HIDDEN(x),y); \ - .hidden _HIDDEN(x) -#define _HIDDEN_FALIAS(x,y)\ - _HIDDEN_ALIAS(x,y); \ - .type _HIDDEN(x),#function - -/* - * For functions implemented in ASM that aren't syscalls. - * END_STRONG(x) Like DEF_STRONG() in C; for standard/reserved C names - * END_WEAK(x) Like DEF_WEAK() in C; for non-ISO C names - */ -#defineEND_STRONG(x) END(x); _HIDDEN_FALIAS(x,x); END(_HIDDEN(x)) -#defineEND_WEAK(x) END_STRONG(x); .weak x - - #define SYSENTRY(x)\ .weak _C_LABEL(x); \ _C_LABEL(x) = _C_LABEL(_thread_sys_ ## x); \ @@ -90,10 +67,10 @@ #define _SYSCALL(x, y) \ _SYSCALL_NOERROR(x,y); \ - bcs PIC_SYM(CERROR, PLT) + bcs CERROR #define _SYSCALL_HIDDEN(x, y) \ _SYSCALL_HIDDEN_NOERROR(x,y); \ - bcs PIC_SYM(CERROR, PLT) + bcs CERROR #define SYSCALL_NOERROR(x) \ _SYSCALL_NOERROR(x,x) Index: lib/libc/arch/arm/gen/_setjmp.S === RCS file: /data/src/openbsd/src/lib/libc/arch/arm/gen/_setjmp.S,v retrieving revision 1.3 diff -u -p -r1.3 _setjmp.S --- lib/libc/arch/arm/gen/_setjmp.S 23 May 2016 00:18:57 - 1.3 +++ lib/libc/arch/arm/gen/_setjmp.S 21 Jul 2016 02:00:08 - @@ -33,9 +33,18 @@ * SUCH DAMAGE. */ -#include +#include "DEFS.h" #include + .section.openbsd.randomdata,"aw",%progbits + .align 4 + .globl __jmpxor +__jmpxor: + .zero 4*2 /* (sp, lr) */ + END(__jmpxor) + .type __jmpxor,%object + + /* * C library -- _setjmp, _longjmp * @@ -52,6
Re: tcpbench(4) support for AF_UNIX
On Wed, Jul 20, 2016 at 04:09:48PM +0200, Claudio Jeker wrote: > For testing I want to abuse tcpbench to work over AF_UNIX sockets. > This diff does exactly that with minimal extras. Especially the unix > socket is not removed from the filesystem when closed. I don't want to > add pledge cpath to tcpbench just for that. > New version that documents the -R feature that I sneaked in (without realizing) and also fixes the documentation for -U a bit. I added -R some time ago to stress test different mbuf sizes. tcpbench is a test tool for me :) -- :wq Claudio Index: tcpbench.1 === RCS file: /cvs/src/usr.bin/tcpbench/tcpbench.1,v retrieving revision 1.20 diff -u -p -r1.20 tcpbench.1 --- tcpbench.1 19 Aug 2014 03:28:53 - 1.20 +++ tcpbench.1 20 Jul 2016 16:11:44 - @@ -24,7 +24,7 @@ .Nm .Fl l .Nm -.Op Fl 46uv +.Op Fl 46UuRv .Op Fl B Ar buf .Op Fl b Ar addr .Op Fl k Ar kvars @@ -39,7 +39,7 @@ .Nm .Bk -words .Fl s -.Op Fl 46uv +.Op Fl 46Uuv .Op Fl B Ar buf .Op Fl k Ar kvars .Op Fl p Ar port @@ -47,6 +47,7 @@ .Op Fl S Ar space .Op Fl T Ar toskeyword .Op Fl V Ar rtable +.Op Ar hostname .Ek .Sh DESCRIPTION .Nm @@ -105,6 +106,9 @@ Use the given number of TCP connections UDP is connectionless so this option isn't valid. .It Fl p Ar port Specify the port used for the test stream (default: 12345). +.It Fl R +In client mode the write buffer size is randomized up to the size specified via +.Fl B . .It Fl r Ar interval Specify the statistics interval reporting rate in milliseconds (default: 1000). .It Fl S Ar space @@ -138,6 +142,11 @@ or a number in either hex or decimal. Stop after .Ar secs seconds. +.It Fl U +Use AF_UNIX sockets instead of IPv4 or IPv6 sockets. +In client and server mode +.Ar hostname +is used as the path to the AF_UNIX socket. .It Fl u Use UDP instead of TCP; this must be specified on both the client and the server. Index: tcpbench.c === RCS file: /cvs/src/usr.bin/tcpbench/tcpbench.c,v retrieving revision 1.50 diff -u -p -r1.50 tcpbench.c --- tcpbench.c 6 Apr 2016 14:09:06 - 1.50 +++ tcpbench.c 20 Jul 2016 16:05:15 - @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -66,6 +67,8 @@ struct { int Tflag;/* ToS if != -1 */ int vflag;/* Verbose */ int uflag;/* UDP mode */ + int Uflag;/* UNIX (AF_LOCAL) mode */ + int Rflag;/* randomize client write size */ kvm_t*kvmh; /* Kvm handler */ char**kvars;/* Kvm enabled vars */ u_longktcbtab; /* Ktcb */ @@ -179,11 +182,11 @@ usage(void) { fprintf(stderr, "usage: tcpbench -l\n" - " tcpbench [-46uv] [-B buf] [-b addr] [-k kvars] [-n connections]\n" + " tcpbench [-46UuRv] [-B buf] [-b addr] [-k kvars] [-n connections]\n" "[-p port] [-r interval] [-S space] [-T toskeyword]\n" "[-t secs] [-V rtable] hostname\n" - " tcpbench -s [-46uv] [-B buf] [-k kvars] [-p port]\n" - "[-r interval] [-S space] [-T toskeyword] [-V rtable]\n"); + " tcpbench -s [-46Uuv] [-B buf] [-k kvars] [-p port] [-r interval]\n" + "[-S space] [-T toskeyword] [-V rtable] [hostname]\n"); exit(1); } @@ -212,6 +215,11 @@ saddr_ntop(const struct sockaddr *addr, char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV]; int herr; + if (addr->sa_family == AF_UNIX) { + struct sockaddr_un *sun = (struct sockaddr_un *)addr; + snprintf(buf, len, "%s", sun->sun_path); + return; + } if ((herr = getnameinfo(addr, alen, hbuf, sizeof(hbuf), pbuf, sizeof(pbuf), NI_NUMERICHOST|NI_NUMERICSERV)) != 0) { if (herr == EAI_SYSTEM) @@ -805,7 +813,8 @@ server_init(struct addrinfo *aitop, stru fprintf(stderr, "bound to fd %d\n", sock); lnfds++; } - freeaddrinfo(aitop); + if (!ptb->Uflag) + freeaddrinfo(aitop); if (lnfds == 0) errx(1, "No working listen addresses found"); } @@ -815,8 +824,11 @@ client_handle_sc(int fd, short event, vo { struct statctx *sc = v_sc; ssize_t n; + size_t blen = sc->buflen; - if ((n = write(sc->fd, sc->buf, sc->buflen)) == -1) { + if (ptb->Rflag) + blen = arc4random_uniform(blen) + 1; + if ((n = write(sc->fd, sc->buf, blen)) == -1) { if (errno == EINTR || errno == EWOULDBLOCK || (UDP_MODE && errno == ENOBUFS)) return; @@ -916,7 +928,8 @@ client_init(struct addrinfo *aitop, int if (mainstats.ncon
iwn: slow down LED in monitor mode
When I run iwn in monitor mode it flashes its LED like it was trying to give me epileptic seizures. With this diff, it's much less irritating. ok? Index: if_iwn.c === RCS file: /cvs/src/sys/dev/pci/if_iwn.c,v retrieving revision 1.168 diff -u -p -r1.168 if_iwn.c --- if_iwn.c20 Jul 2016 10:26:42 - 1.168 +++ if_iwn.c20 Jul 2016 15:05:34 - @@ -4870,7 +4870,7 @@ iwn_run(struct iwn_softc *sc) if (ic->ic_opmode == IEEE80211_M_MONITOR) { /* Link LED blinks while monitoring. */ - iwn_set_led(sc, IWN_LED_LINK, 5, 5); + iwn_set_led(sc, IWN_LED_LINK, 50, 50); return 0; } if ((error = iwn_set_timing(sc, ni)) != 0) {
Re: split in6_selectsrc() for saner prototypes
On 20/07/16(Wed) 12:36, Vincent Gross wrote: > This is a completely mechanical diff to get rid of the 7-params madness > in in6_selectsrc(). > > I also apply the same treatment to in_selectsrc() for consistency. > > Ok? The only bikesched I have is about the name. Could you keep the "in_pcb" prefix to be coherent with the rest of the file? Apart from that ok mpi@ > Index: sys/netinet/in_pcb.c > === > RCS file: /cvs/src/sys/netinet/in_pcb.c,v > retrieving revision 1.210 > diff -u -p -r1.210 in_pcb.c > --- sys/netinet/in_pcb.c 19 Jul 2016 14:49:46 - 1.210 > +++ sys/netinet/in_pcb.c 20 Jul 2016 10:21:17 - > @@ -525,8 +525,7 @@ in_pcbconnect(struct inpcb *inp, struct > if (sin->sin_port == 0) > return (EADDRNOTAVAIL); > > - error = in_selectsrc(&ina, sin, inp->inp_moptions, &inp->inp_route, > - &inp->inp_laddr, inp->inp_rtableid); > + error = in_selpcbsrc(&ina, sin, inp); > if (error) > return (error); > > @@ -876,10 +875,14 @@ in_pcbrtentry(struct inpcb *inp) > * an entry to the caller for later use. > */ > int > -in_selectsrc(struct in_addr **insrc, struct sockaddr_in *sin, > -struct ip_moptions *mopts, struct route *ro, struct in_addr *laddr, > -u_int rtableid) > +in_selpcbsrc(struct in_addr **insrc, struct sockaddr_in *sin, > +struct inpcb *inp) > { > + struct ip_moptions *mopts = inp->inp_moptions; > + struct route *ro = &inp->inp_route; > + struct in_addr *laddr = &inp->inp_laddr; > + u_int rtableid = inp->inp_rtableid; > + > struct sockaddr_in *sin2; > struct in_ifaddr *ia = NULL; > > Index: sys/netinet/in_pcb.h > === > RCS file: /cvs/src/sys/netinet/in_pcb.h,v > retrieving revision 1.100 > diff -u -p -r1.100 in_pcb.h > --- sys/netinet/in_pcb.h 27 Jun 2016 16:33:48 - 1.100 > +++ sys/netinet/in_pcb.h 20 Jul 2016 10:21:17 - > @@ -289,8 +289,7 @@ void in_setpeeraddr(struct inpcb *, str > void in_setsockaddr(struct inpcb *, struct mbuf *); > int in_baddynamic(u_int16_t, u_int16_t); > int in_rootonly(u_int16_t, u_int16_t); > -int in_selectsrc(struct in_addr **, struct sockaddr_in *, > - struct ip_moptions *, struct route *, struct in_addr *, u_int); > +int in_selpcbsrc(struct in_addr **, struct sockaddr_in *, struct inpcb *); > struct rtentry * > in_pcbrtentry(struct inpcb *); > > Index: sys/netinet/udp_usrreq.c > === > RCS file: /cvs/src/sys/netinet/udp_usrreq.c,v > retrieving revision 1.214 > diff -u -p -r1.214 udp_usrreq.c > --- sys/netinet/udp_usrreq.c 28 Jun 2016 11:22:53 - 1.214 > +++ sys/netinet/udp_usrreq.c 20 Jul 2016 10:21:19 - > @@ -989,8 +989,7 @@ udp_output(struct inpcb *inp, struct mbu > goto release; > } > > - error = in_selectsrc(&laddr, sin, inp->inp_moptions, > - &inp->inp_route, &inp->inp_laddr, inp->inp_rtableid); > + error = in_selpcbsrc(&laddr, sin, inp); > if (error) > goto release; > > Index: sys/netinet6/icmp6.c > === > RCS file: /cvs/src/sys/netinet6/icmp6.c,v > retrieving revision 1.186 > diff -u -p -r1.186 icmp6.c > --- sys/netinet6/icmp6.c 5 Jul 2016 10:17:14 - 1.186 > +++ sys/netinet6/icmp6.c 20 Jul 2016 10:21:19 - > @@ -1259,7 +1259,7 @@ icmp6_reflect(struct mbuf *m, size_t off >* source address of the erroneous packet. >*/ > bzero(&ro, sizeof(ro)); > - error = in6_selectsrc(&src, &sa6_src, NULL, NULL, &ro, NULL, > + error = in6_selectsrc(&src, &sa6_src, NULL, &ro, > m->m_pkthdr.ph_rtableid); > if (ro.ro_rt) > rtfree(ro.ro_rt); /* XXX: we could use this */ > Index: sys/netinet6/in6_pcb.c > === > RCS file: /cvs/src/sys/netinet6/in6_pcb.c,v > retrieving revision 1.93 > diff -u -p -r1.93 in6_pcb.c > --- sys/netinet6/in6_pcb.c5 Jul 2016 10:17:14 - 1.93 > +++ sys/netinet6/in6_pcb.c20 Jul 2016 10:21:19 - > @@ -281,9 +281,7 @@ in6_pcbconnect(struct inpcb *inp, struct >* with the address specified by setsockopt(IPV6_PKTINFO). >* Is it the intended behavior? >*/ > - error = in6_selectsrc(&in6a, sin6, inp->inp_outputopts6, > - inp->inp_moptions6, &inp->inp_route6, &inp->inp_laddr6, > - inp->inp_rtableid); > + error = in6_selpcbsrc(&in6a, sin6, inp, inp->inp_outputopts6); > if (error) > return (error); > > Index: sys/netinet6/in6_src.c > === > RCS file: /c
Re: tcpbench(4) support for AF_UNIX
schaut gut aus, hab aber nicht probiert. 2016-07-20 16:09 GMT+02:00 Claudio Jeker : > For testing I want to abuse tcpbench to work over AF_UNIX sockets. > This diff does exactly that with minimal extras. Especially the unix > socket is not removed from the filesystem when closed. I don't want to > add pledge cpath to tcpbench just for that. > > -- > :wq Claudio > > Index: tcpbench.1 > === > RCS file: /cvs/src/usr.bin/tcpbench/tcpbench.1,v > retrieving revision 1.20 > diff -u -p -r1.20 tcpbench.1 > --- tcpbench.1 19 Aug 2014 03:28:53 - 1.20 > +++ tcpbench.1 20 Jul 2016 12:44:21 - > @@ -24,7 +24,7 @@ > .Nm > .Fl l > .Nm > -.Op Fl 46uv > +.Op Fl 46Uuv > .Op Fl B Ar buf > .Op Fl b Ar addr > .Op Fl k Ar kvars > @@ -39,7 +39,7 @@ > .Nm > .Bk -words > .Fl s > -.Op Fl 46uv > +.Op Fl 46Uuv > .Op Fl B Ar buf > .Op Fl k Ar kvars > .Op Fl p Ar port > @@ -47,6 +47,7 @@ > .Op Fl S Ar space > .Op Fl T Ar toskeyword > .Op Fl V Ar rtable > +.Op Ar hostname > .Ek > .Sh DESCRIPTION > .Nm > @@ -138,6 +139,11 @@ or a number in either hex or decimal. > Stop after > .Ar secs > seconds. > +.It Fl U > +Use AF_UNIX sockets instead of IPv4 or IPv6 sockets. > +In both cases > +.Ar hostname > +is the path to the AF_UNIX socket that should be used. > .It Fl u > Use UDP instead of TCP; this must be specified on both the client > and the server. > Index: tcpbench.c > === > RCS file: /cvs/src/usr.bin/tcpbench/tcpbench.c,v > retrieving revision 1.50 > diff -u -p -r1.50 tcpbench.c > --- tcpbench.c 6 Apr 2016 14:09:06 - 1.50 > +++ tcpbench.c 20 Jul 2016 12:46:24 - > @@ -21,6 +21,7 @@ > #include > #include > #include > +#include > > #include > > @@ -56,6 +57,7 @@ > #define DEFAULT_UDP_PKT (1500 - 28) /* TODO don't hardcode this */ > #define TCP_MODE !ptb->uflag > #define UDP_MODE ptb->uflag > +#define UNIX_MODE ptb->Uflag > #define MAX_FD 1024 > > /* Our tcpbench globals */ > @@ -66,6 +68,8 @@ struct { > int Tflag;/* ToS if != -1 */ > int vflag;/* Verbose */ > int uflag;/* UDP mode */ > + int Uflag;/* UNIX (AF_LOCAL) mode */ > + int Rflag;/* in UDP mode randomize size */ > kvm_t*kvmh; /* Kvm handler */ > char**kvars;/* Kvm enabled vars */ > u_longktcbtab; /* Ktcb */ > @@ -179,11 +183,11 @@ usage(void) > { > fprintf(stderr, > "usage: tcpbench -l\n" > - " tcpbench [-46uv] [-B buf] [-b addr] [-k kvars] [-n > connections]\n" > + " tcpbench [-46Uuv] [-B buf] [-b addr] [-k kvars] [-n > connections]\n" > "[-p port] [-r interval] [-S space] [-T > toskeyword]\n" > "[-t secs] [-V rtable] hostname\n" > - " tcpbench -s [-46uv] [-B buf] [-k kvars] [-p port]\n" > - "[-r interval] [-S space] [-T toskeyword] [-V > rtable]\n"); > + " tcpbench -s [-46Uuv] [-B buf] [-k kvars] [-p port] [-r > interval]\n" > + "[-S space] [-T toskeyword] [-V rtable] > [hostname]\n"); > exit(1); > } > > @@ -212,6 +216,11 @@ saddr_ntop(const struct sockaddr *addr, > char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV]; > int herr; > > + if (addr->sa_family == AF_UNIX) { > + struct sockaddr_un *sun = (struct sockaddr_un *)addr; > + snprintf(buf, len, "%s", sun->sun_path); > + return; > + } > if ((herr = getnameinfo(addr, alen, hbuf, sizeof(hbuf), > pbuf, sizeof(pbuf), NI_NUMERICHOST|NI_NUMERICSERV)) != 0) { > if (herr == EAI_SYSTEM) > @@ -805,7 +814,8 @@ server_init(struct addrinfo *aitop, stru > fprintf(stderr, "bound to fd %d\n", sock); > lnfds++; > } > - freeaddrinfo(aitop); > + if (!UNIX_MODE) > + freeaddrinfo(aitop); > if (lnfds == 0) > errx(1, "No working listen addresses found"); > } > @@ -815,8 +825,11 @@ client_handle_sc(int fd, short event, vo > { > struct statctx *sc = v_sc; > ssize_t n; > + size_t blen = sc->buflen; > > - if ((n = write(sc->fd, sc->buf, sc->buflen)) == -1) { > + if (ptb->Rflag) > + blen = arc4random_uniform(blen) + 1; > + if ((n = write(sc->fd, sc->buf, blen)) == -1) { > if (errno == EINTR || errno == EWOULDBLOCK || > (UDP_MODE && errno == ENOBUFS)) > return; > @@ -916,7 +929,8 @@ client_init(struct addrinfo *aitop, int > if (mainstats.nconns == 1) > set_slice_timer(1); > } > - freeaddrinfo(aitop); > + if (!UNIX_MODE) > +
tcpbench(4) support for AF_UNIX
For testing I want to abuse tcpbench to work over AF_UNIX sockets. This diff does exactly that with minimal extras. Especially the unix socket is not removed from the filesystem when closed. I don't want to add pledge cpath to tcpbench just for that. -- :wq Claudio Index: tcpbench.1 === RCS file: /cvs/src/usr.bin/tcpbench/tcpbench.1,v retrieving revision 1.20 diff -u -p -r1.20 tcpbench.1 --- tcpbench.1 19 Aug 2014 03:28:53 - 1.20 +++ tcpbench.1 20 Jul 2016 12:44:21 - @@ -24,7 +24,7 @@ .Nm .Fl l .Nm -.Op Fl 46uv +.Op Fl 46Uuv .Op Fl B Ar buf .Op Fl b Ar addr .Op Fl k Ar kvars @@ -39,7 +39,7 @@ .Nm .Bk -words .Fl s -.Op Fl 46uv +.Op Fl 46Uuv .Op Fl B Ar buf .Op Fl k Ar kvars .Op Fl p Ar port @@ -47,6 +47,7 @@ .Op Fl S Ar space .Op Fl T Ar toskeyword .Op Fl V Ar rtable +.Op Ar hostname .Ek .Sh DESCRIPTION .Nm @@ -138,6 +139,11 @@ or a number in either hex or decimal. Stop after .Ar secs seconds. +.It Fl U +Use AF_UNIX sockets instead of IPv4 or IPv6 sockets. +In both cases +.Ar hostname +is the path to the AF_UNIX socket that should be used. .It Fl u Use UDP instead of TCP; this must be specified on both the client and the server. Index: tcpbench.c === RCS file: /cvs/src/usr.bin/tcpbench/tcpbench.c,v retrieving revision 1.50 diff -u -p -r1.50 tcpbench.c --- tcpbench.c 6 Apr 2016 14:09:06 - 1.50 +++ tcpbench.c 20 Jul 2016 12:46:24 - @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -56,6 +57,7 @@ #define DEFAULT_UDP_PKT (1500 - 28) /* TODO don't hardcode this */ #define TCP_MODE !ptb->uflag #define UDP_MODE ptb->uflag +#define UNIX_MODE ptb->Uflag #define MAX_FD 1024 /* Our tcpbench globals */ @@ -66,6 +68,8 @@ struct { int Tflag;/* ToS if != -1 */ int vflag;/* Verbose */ int uflag;/* UDP mode */ + int Uflag;/* UNIX (AF_LOCAL) mode */ + int Rflag;/* in UDP mode randomize size */ kvm_t*kvmh; /* Kvm handler */ char**kvars;/* Kvm enabled vars */ u_longktcbtab; /* Ktcb */ @@ -179,11 +183,11 @@ usage(void) { fprintf(stderr, "usage: tcpbench -l\n" - " tcpbench [-46uv] [-B buf] [-b addr] [-k kvars] [-n connections]\n" + " tcpbench [-46Uuv] [-B buf] [-b addr] [-k kvars] [-n connections]\n" "[-p port] [-r interval] [-S space] [-T toskeyword]\n" "[-t secs] [-V rtable] hostname\n" - " tcpbench -s [-46uv] [-B buf] [-k kvars] [-p port]\n" - "[-r interval] [-S space] [-T toskeyword] [-V rtable]\n"); + " tcpbench -s [-46Uuv] [-B buf] [-k kvars] [-p port] [-r interval]\n" + "[-S space] [-T toskeyword] [-V rtable] [hostname]\n"); exit(1); } @@ -212,6 +216,11 @@ saddr_ntop(const struct sockaddr *addr, char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV]; int herr; + if (addr->sa_family == AF_UNIX) { + struct sockaddr_un *sun = (struct sockaddr_un *)addr; + snprintf(buf, len, "%s", sun->sun_path); + return; + } if ((herr = getnameinfo(addr, alen, hbuf, sizeof(hbuf), pbuf, sizeof(pbuf), NI_NUMERICHOST|NI_NUMERICSERV)) != 0) { if (herr == EAI_SYSTEM) @@ -805,7 +814,8 @@ server_init(struct addrinfo *aitop, stru fprintf(stderr, "bound to fd %d\n", sock); lnfds++; } - freeaddrinfo(aitop); + if (!UNIX_MODE) + freeaddrinfo(aitop); if (lnfds == 0) errx(1, "No working listen addresses found"); } @@ -815,8 +825,11 @@ client_handle_sc(int fd, short event, vo { struct statctx *sc = v_sc; ssize_t n; + size_t blen = sc->buflen; - if ((n = write(sc->fd, sc->buf, sc->buflen)) == -1) { + if (ptb->Rflag) + blen = arc4random_uniform(blen) + 1; + if ((n = write(sc->fd, sc->buf, blen)) == -1) { if (errno == EINTR || errno == EWOULDBLOCK || (UDP_MODE && errno == ENOBUFS)) return; @@ -916,7 +929,8 @@ client_init(struct addrinfo *aitop, int if (mainstats.nconns == 1) set_slice_timer(1); } - freeaddrinfo(aitop); + if (!UNIX_MODE) + freeaddrinfo(aitop); if (aib != NULL) freeaddrinfo(aib); @@ -995,12 +1009,13 @@ main(int argc, char **argv) const char *host = NULL, *port = DEFAULT_PORT, *srcbind = NULL; struct event ev_sigint, ev_sigterm, ev_sighup, ev_progtimer; struct statctx *udp_sc = NULL; + struct sockaddr_un sock_un;
Re: ecdsa support in iked
great! this changes the code to hide the ECDSA conversion inside crypto.c and also make ECDSA work with the generic RFC 7427 signature encoding. Could you verify this with OS X? I've only tested strongswan. -m 2016-07-03 11:07 GMT+02:00 René Ammerlaan : > Hi, > > I’ve created a patch for ecdsa support in iked. Also found a bug in handling > auth_eap, because that value is never initialised to 0. I also updated the > dsa sign functions with the newer EVP_Digest so it’s aligned with the rest of > the code, but it’s not required for ecdsa support. > > The ecdsa signature should contain only plain r and s, so the signature is > converted to that format. I’ve tested compatibility with OSX and IOS and both > seem to be working fine. > > Regards, > > René commit 75b98b0bfa99284850f5b8b501e973cd71a7ae5e Author: Markus Friedl Date: Wed Jul 20 14:56:04 2016 +0200 ecdsa 1) move ecdsa en/decoding into crypto.c 2) allow ECDSA with generic RFC 7427 signature encoding diff --git crypto.c crypto.c index 154ec20..85254a6 100644 --- crypto.c +++ crypto.c @@ -39,36 +39,52 @@ #include "iked.h" #include "ikev2.h" -/* RFC 7427, A.1 */ -static const uint8_t sha256WithRSAEncryption[] = { +/* RFC 7427, A.1 RSA */ +static const uint8_t sha256WithRSA[] = { 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00 }; -static const uint8_t sha384WithRSAEncryption[] = { +static const uint8_t sha384WithRSA[] = { 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0c, 0x05, 0x00 }; -static const uint8_t sha512WithRSAEncryption[] = { +static const uint8_t sha512WithRSA[] = { 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0d, 0x05, 0x00 }; +/* RFC 7427, A.3 ECDSA */ +static const uint8_t ecdsa_sha256[] = { + 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, + 0x3d, 0x04, 0x03, 0x02 +}; +static const uint8_t ecdsa_sha384[] = { + 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, + 0x3d, 0x04, 0x03, 0x03 +}; +static const uint8_t ecdsa_sha512[] = { + 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, + 0x3d, 0x04, 0x03, 0x04 +}; struct { + int sc_keytype; + const EVP_MD*(*sc_md)(void); uint8_t sc_len; const uint8_t *sc_oid; - const EVP_MD*(*sc_md)(void); } schemes[] = { - { sizeof(sha256WithRSAEncryption), - sha256WithRSAEncryption, EVP_sha256 }, - { sizeof(sha384WithRSAEncryption), - sha384WithRSAEncryption, EVP_sha384 }, - { sizeof(sha512WithRSAEncryption), - sha512WithRSAEncryption, EVP_sha512 }, + { EVP_PKEY_RSA, EVP_sha256, sizeof(sha256WithRSA), sha256WithRSA }, + { EVP_PKEY_RSA, EVP_sha384, sizeof(sha384WithRSA), sha384WithRSA }, + { EVP_PKEY_RSA, EVP_sha512, sizeof(sha512WithRSA), sha512WithRSA }, + { EVP_PKEY_EC, EVP_sha256, sizeof(ecdsa_sha256), ecdsa_sha256 }, + { EVP_PKEY_EC, EVP_sha384, sizeof(ecdsa_sha384), ecdsa_sha384 }, + { EVP_PKEY_EC, EVP_sha512, sizeof(ecdsa_sha512), ecdsa_sha256 }, }; int_dsa_verify_init(struct iked_dsa *, const uint8_t *, size_t); -size_t _dsa_verify_offset(struct iked_dsa *, uint8_t *); +int_dsa_verify_prepare(struct iked_dsa *, uint8_t **, size_t *, + uint8_t **); int_dsa_sign_encode(struct iked_dsa *, uint8_t *, size_t *); +size_t _dsa_sign_ecdsa(struct iked_dsa *, uint8_t *, size_t); struct iked_hash * hash_new(uint8_t type, uint16_t id) @@ -358,6 +374,7 @@ struct ibuf * cipher_setiv(struct iked_cipher *encr, void *iv, size_t len) { ibuf_release(encr->encr_iv); + encr->encr_iv = NULL; if (iv != NULL) { if (len < encr->encr_ivlength) { log_debug("%s: invalid IV length %zu", __func__, len); @@ -659,6 +676,7 @@ dsa_setkey(struct iked_dsa *dsa, void *key, size_t keylen, uint8_t type) if (rawcert != NULL) BIO_free(rawcert); ibuf_release(dsa->dsa_keydata); + dsa->dsa_keydata = NULL; return (NULL); } @@ -667,6 +685,7 @@ _dsa_verify_init(struct iked_dsa *dsa, const uint8_t *sig, size_t len) { uint8_t oidlen; size_t i; + int keytype; if (dsa->dsa_priv != NULL) return (0); @@ -679,23 +698,30 @@ _dsa_verify_init(struct iked_dsa *dsa, const uint8_t *sig, size_t len) print_map(dsa->dsa_method, ikev2_auth_map)); return (-1); } + if (dsa->dsa_key == NULL) { + log_debug("%s: dsa_key not set for %s", __func__, + print_map(dsa->dsa_method, ikev2_auth_map)); + return (-1); + } + keytype = EVP_PKEY_type(((EVP_PKEY *)dsa->dsa_key)->type); if (sig == NULL) { log_debug("%s: signature missing", __f
Re: ecdsa support in iked
> On Sun, Jul 03, 2016 at 11:07:27AM +0200, Ren?? Ammerlaan wrote: > > I???ve created a patch for ecdsa support in iked. Also found a bug > > in handling auth_eap, because that value is never initialised to 0. I > > also updated the dsa sign functions with the newer EVP_Digest so > > it???s aligned with the rest of the code, but it???s not required for > > ecdsa support. > > > > The ecdsa signature should contain only plain r and s, so the > > signature is converted to that format. I???ve tested compatibility > > with OSX and IOS and both seem to be working fine. > > > The first auth_eap diff has been committed. I'm re-sending your remaining diff with minor changes: - style, wrap long lines, tabs instead of spaces - sort man page entry There are open questions: - why aren't the p2d_ecdsa_sig() and d2p_ecdsa_sig in ikev2_msg.c in crypto.c? - why not using the new flexible ike signature type? - aren't there other encoding formats? Comments? Reyk Index: sbin/iked/ca.c === RCS file: /cvs/src/sbin/iked/ca.c,v retrieving revision 1.40 diff -u -p -u -p -r1.40 ca.c --- sbin/iked/ca.c 7 Dec 2015 12:46:37 - 1.40 +++ sbin/iked/ca.c 20 Jul 2016 12:47:38 - @@ -378,6 +378,9 @@ ca_getcert(struct iked *env, struct imsg case IKEV2_CERT_RSA_KEY: ret = ca_validate_pubkey(env, &id, ptr, len); break; + case IKEV2_CERT_ECDSA_KEY: + ret = ca_validate_pubkey(env, &id, ptr, len); + break; default: log_debug("%s: unsupported cert type %d", __func__, type); ret = -1; @@ -815,6 +818,7 @@ int ca_pubkey_serialize(EVP_PKEY *key, struct iked_id *id) { RSA *rsa = NULL; + EC_KEY *ecdsa = NULL; uint8_t *d; int len = 0; int ret = -1; @@ -840,6 +844,26 @@ ca_pubkey_serialize(EVP_PKEY *key, struc id->id_type = IKEV2_CERT_RSA_KEY; break; + case EVP_PKEY_EC: + id->id_type = 0; + id->id_offset = 0; + ibuf_release(id->id_buf); + + if ((ecdsa = EVP_PKEY_get1_EC_KEY(key)) == NULL) + goto done; + if ((len = i2o_ECPublicKey(ecdsa, NULL)) <= 0) + goto done; + if ((id->id_buf = ibuf_new(NULL, len)) == NULL) + goto done; + + d = ibuf_data(id->id_buf); + if (i2o_ECPublicKey(ecdsa, &d) != len) { + ibuf_release(id->id_buf); + goto done; + } + + id->id_type = IKEV2_CERT_ECDSA_KEY; + break; default: log_debug("%s: unsupported key type %d", __func__, key->type); return (-1); @@ -852,6 +876,8 @@ ca_pubkey_serialize(EVP_PKEY *key, struc done: if (rsa != NULL) RSA_free(rsa); + if (ecdsa != NULL) + EC_KEY_free(ecdsa); return (ret); } @@ -859,6 +885,7 @@ int ca_privkey_serialize(EVP_PKEY *key, struct iked_id *id) { RSA *rsa = NULL; + EC_KEY *ecdsa = NULL; uint8_t *d; int len = 0; int ret = -1; @@ -884,6 +911,26 @@ ca_privkey_serialize(EVP_PKEY *key, stru id->id_type = IKEV2_CERT_RSA_KEY; break; + case EVP_PKEY_EC: + id->id_type = 0; + id->id_offset = 0; + ibuf_release(id->id_buf); + + if ((ecdsa = EVP_PKEY_get1_EC_KEY(key)) == NULL) + goto done; + if ((len = i2d_ECPrivateKey(ecdsa, NULL)) <= 0) + goto done; + if ((id->id_buf = ibuf_new(NULL, len)) == NULL) + goto done; + + d = ibuf_data(id->id_buf); + if (i2d_ECPrivateKey(ecdsa, &d) != len) { + ibuf_release(id->id_buf); + goto done; + } + + id->id_type = IKEV2_CERT_ECDSA_KEY; + break; default: log_debug("%s: unsupported key type %d", __func__, key->type); return (-1); @@ -896,6 +943,8 @@ ca_privkey_serialize(EVP_PKEY *key, stru done: if (rsa != NULL) RSA_free(rsa); + if (ecdsa != NULL) + EC_KEY_free(ecdsa); return (ret); } @@ -1029,6 +1078,7 @@ ca_validate_pubkey(struct iked *env, str { BIO *rawcert = NULL; RSA *peerrsa = NULL, *localrsa = NULL; + EC_KEY *peerecdsa = NULL, *localecdsa = NULL; EVP_PKEY*peerkey = NULL, *localkey = NULL; int ret = -1; FILE*fp = NULL; @@ -1066,11 +1116,17 @@ ca_validate_pubkey(struct iked *env,
iwm: make use of RTS/CTS conditional
Currently, if running in 11n mode, iwm always enables RTS/CTS to protect frames it is sending. To recap what the various HT protection modes are: /* * HT protection modes (see 802.11-2012 8.4.2.59) */ enum ieee80211_htprot { IEEE80211_HTPROT_NONE = 0, /* only 20/40MHz HT STAs exist */ IEEE80211_HTPROT_NONMEMBER, /* non-HT STA overlaps our channel */ IEEE80211_HTPROT_20MHZ, /* 20MHz HT STA on a 40MHz channel */ IEEE80211_HTPROT_NONHT_MIXED/* non-HT STA associated to our BSS */ }; If HT protection is 'none' or '20 MHz', we should not have to protect frames. Frame protection adds some overhead, so in theory not using protection should make Tx faster. This is an experimental change, and is not targeting 6.0. Still, it would be nice to get some test reports, especially where there are no 11a/b/g networks in the neighbourhood and all devices are capable of 11n. Index: if_iwm.c === RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v retrieving revision 1.95 diff -u -p -r1.95 if_iwm.c --- if_iwm.c18 Jul 2016 13:10:35 - 1.95 +++ if_iwm.c20 Jul 2016 12:15:54 - @@ -2799,6 +2799,9 @@ iwm_htprot_task(void *arg) if (error != 0) printf("%s: could not change HT protection: error %d\n", DEVNAME(sc), error); + + /* Also update RTS/CTS config via LQ command. */ + iwm_setrates(in); } /* @@ -6093,9 +6096,14 @@ iwm_setrates(struct iwm_node *in) memset(lq, 0, sizeof(*lq)); lq->sta_id = IWM_STATION_ID; - /* For HT, always enable RTS/CTS to avoid excessive retries. */ - if (ni->ni_flags & IEEE80211_NODE_HT) - lq->flags |= IWM_LQ_FLAG_USE_RTS_MSK; + /* Enable RTS/CTS for HT protection. */ + if (ni->ni_flags & IEEE80211_NODE_HT) { + enum ieee80211_htprot htprot = + (ni->ni_htop1 & IEEE80211_HTOP1_PROT_MASK); + if (htprot == IEEE80211_HTPROT_NONMEMBER || + htprot == IEEE80211_HTPROT_NONHT_MIXED) + lq->flags |= IWM_LQ_FLAG_USE_RTS_MSK; + } /* * Fill the LQ rate selection table with legacy and/or HT rates
Re: split in6_selectsrc() for saner prototypes
On Wed, Jul 20, 2016 at 12:36:45PM +0200, Vincent Gross wrote: > This is a completely mechanical diff to get rid of the 7-params madness > in in6_selectsrc(). > > I also apply the same treatment to in_selectsrc() for consistency. > > Ok? OK bluhm@ > > Index: sys/netinet/in_pcb.c > === > RCS file: /cvs/src/sys/netinet/in_pcb.c,v > retrieving revision 1.210 > diff -u -p -r1.210 in_pcb.c > --- sys/netinet/in_pcb.c 19 Jul 2016 14:49:46 - 1.210 > +++ sys/netinet/in_pcb.c 20 Jul 2016 10:21:17 - > @@ -525,8 +525,7 @@ in_pcbconnect(struct inpcb *inp, struct > if (sin->sin_port == 0) > return (EADDRNOTAVAIL); > > - error = in_selectsrc(&ina, sin, inp->inp_moptions, &inp->inp_route, > - &inp->inp_laddr, inp->inp_rtableid); > + error = in_selpcbsrc(&ina, sin, inp); > if (error) > return (error); > > @@ -876,10 +875,14 @@ in_pcbrtentry(struct inpcb *inp) > * an entry to the caller for later use. > */ > int > -in_selectsrc(struct in_addr **insrc, struct sockaddr_in *sin, > -struct ip_moptions *mopts, struct route *ro, struct in_addr *laddr, > -u_int rtableid) > +in_selpcbsrc(struct in_addr **insrc, struct sockaddr_in *sin, > +struct inpcb *inp) > { > + struct ip_moptions *mopts = inp->inp_moptions; > + struct route *ro = &inp->inp_route; > + struct in_addr *laddr = &inp->inp_laddr; > + u_int rtableid = inp->inp_rtableid; > + > struct sockaddr_in *sin2; > struct in_ifaddr *ia = NULL; > > Index: sys/netinet/in_pcb.h > === > RCS file: /cvs/src/sys/netinet/in_pcb.h,v > retrieving revision 1.100 > diff -u -p -r1.100 in_pcb.h > --- sys/netinet/in_pcb.h 27 Jun 2016 16:33:48 - 1.100 > +++ sys/netinet/in_pcb.h 20 Jul 2016 10:21:17 - > @@ -289,8 +289,7 @@ void in_setpeeraddr(struct inpcb *, str > void in_setsockaddr(struct inpcb *, struct mbuf *); > int in_baddynamic(u_int16_t, u_int16_t); > int in_rootonly(u_int16_t, u_int16_t); > -int in_selectsrc(struct in_addr **, struct sockaddr_in *, > - struct ip_moptions *, struct route *, struct in_addr *, u_int); > +int in_selpcbsrc(struct in_addr **, struct sockaddr_in *, struct inpcb *); > struct rtentry * > in_pcbrtentry(struct inpcb *); > > Index: sys/netinet/udp_usrreq.c > === > RCS file: /cvs/src/sys/netinet/udp_usrreq.c,v > retrieving revision 1.214 > diff -u -p -r1.214 udp_usrreq.c > --- sys/netinet/udp_usrreq.c 28 Jun 2016 11:22:53 - 1.214 > +++ sys/netinet/udp_usrreq.c 20 Jul 2016 10:21:19 - > @@ -989,8 +989,7 @@ udp_output(struct inpcb *inp, struct mbu > goto release; > } > > - error = in_selectsrc(&laddr, sin, inp->inp_moptions, > - &inp->inp_route, &inp->inp_laddr, inp->inp_rtableid); > + error = in_selpcbsrc(&laddr, sin, inp); > if (error) > goto release; > > Index: sys/netinet6/icmp6.c > === > RCS file: /cvs/src/sys/netinet6/icmp6.c,v > retrieving revision 1.186 > diff -u -p -r1.186 icmp6.c > --- sys/netinet6/icmp6.c 5 Jul 2016 10:17:14 - 1.186 > +++ sys/netinet6/icmp6.c 20 Jul 2016 10:21:19 - > @@ -1259,7 +1259,7 @@ icmp6_reflect(struct mbuf *m, size_t off >* source address of the erroneous packet. >*/ > bzero(&ro, sizeof(ro)); > - error = in6_selectsrc(&src, &sa6_src, NULL, NULL, &ro, NULL, > + error = in6_selectsrc(&src, &sa6_src, NULL, &ro, > m->m_pkthdr.ph_rtableid); > if (ro.ro_rt) > rtfree(ro.ro_rt); /* XXX: we could use this */ > Index: sys/netinet6/in6_pcb.c > === > RCS file: /cvs/src/sys/netinet6/in6_pcb.c,v > retrieving revision 1.93 > diff -u -p -r1.93 in6_pcb.c > --- sys/netinet6/in6_pcb.c5 Jul 2016 10:17:14 - 1.93 > +++ sys/netinet6/in6_pcb.c20 Jul 2016 10:21:19 - > @@ -281,9 +281,7 @@ in6_pcbconnect(struct inpcb *inp, struct >* with the address specified by setsockopt(IPV6_PKTINFO). >* Is it the intended behavior? >*/ > - error = in6_selectsrc(&in6a, sin6, inp->inp_outputopts6, > - inp->inp_moptions6, &inp->inp_route6, &inp->inp_laddr6, > - inp->inp_rtableid); > + error = in6_selpcbsrc(&in6a, sin6, inp, inp->inp_outputopts6); > if (error) > return (error); > > Index: sys/netinet6/in6_src.c > === > RCS file: /cvs/src/sys/netinet6/in6_src.c,v > retrieving revision 1.76 > diff -u -p -r1.76 in6_src.c > --- sys/netinet6/in6_src.c
iwm: disable beacon filter for ERP and HT prot updates
Beacon filter settings in iwm(4) prevent the device from passing beacons to net80211 while associated to an AP. The implication is that net80211 does not see HT protection updates, so it never tells the driver to update HT protection settings. This can cause interference problems. I believe this was introduced with the -16 firmware upgrade, because as far as I recall HT prot updates were working with iwm at some point. It's possible that the old firmware had different behaviour here. I have not tried to figure out when this problem was introduced. It should be possible to make the hardware pass beacons under certain conditions if the filter is active. I've tried to figure out how this could work, without success. For now I'd like to disable the filter entirely. Index: if_iwm.c === RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v retrieving revision 1.95 diff -u -p -r1.95 if_iwm.c --- if_iwm.c18 Jul 2016 13:10:35 - 1.95 +++ if_iwm.c20 Jul 2016 12:21:10 - @@ -6290,7 +6290,14 @@ iwm_newstate_task(void *psc) case IEEE80211_S_RUN: { in = (struct iwm_node *)ic->ic_bss; iwm_mvm_power_mac_update_mode(sc, in); +#ifdef notyet + /* +* Disabled for now. Default beacon filter settings +* prevent net80211 from getting ERP and HT protection +* updates from beacons. +*/ iwm_mvm_enable_beacon_filter(sc, in); +#endif iwm_mvm_update_quotas(sc, in); /* init amrr */ Index: if_iwmreg.h === RCS file: /cvs/src/sys/dev/pci/if_iwmreg.h,v retrieving revision 1.13 diff -u -p -r1.13 if_iwmreg.h --- if_iwmreg.h 28 May 2016 08:13:16 - 1.13 +++ if_iwmreg.h 20 Jul 2016 12:12:12 - @@ -3773,7 +3773,7 @@ struct iwm_uapsd_misbehaving_ap_notif { * beacon filtering; beacons will not be forced to be sent to driver * regardless of whether its temerature has been changed. * @bf_enable_beacon_filter: 1, beacon filtering is enabled; 0, disabled. - * @bf_filter_escape_timer: Send beacons to to driver if no beacons were passed + * @bf_escape_timer: Send beacons to driver if no beacons were passed * for a specific period of time. Units: Beacons. * @ba_escape_timer: Fully receive and parse beacon if no beacons were passed * for a longer period of time then this escape-timeout. Units: Beacons.
Re: ecdsa support in iked
Hi, On Sun, Jul 03, 2016 at 11:07:27AM +0200, Ren?? Ammerlaan wrote: > I???ve created a patch for ecdsa support in iked. Also found a bug > in handling auth_eap, because that value is never initialised to 0. I > also updated the dsa sign functions with the newer EVP_Digest so > it???s aligned with the rest of the code, but it???s not required for > ecdsa support. > > The ecdsa signature should contain only plain r and s, so the > signature is converted to that format. I???ve tested compatibility > with OSX and IOS and both seem to be working fine. > sorry for the delay - but thanks for your diff! I'm resending your diff in chunks, here is the first one: - When parsing the configuration. initialize the auth structure correctly, as parse.y's $$ is not zero-initialized. OK? Reyk Index: sbin/iked/parse.y === RCS file: /cvs/src/sbin/iked/parse.y,v retrieving revision 1.55 diff -u -p -u -p -r1.55 parse.y --- sbin/iked/parse.y 21 Jun 2016 21:35:24 - 1.55 +++ sbin/iked/parse.y 20 Jul 2016 11:42:12 - @@ -811,15 +811,19 @@ ipcomp: /* empty */ { $$ = 0; } ikeauth: /* empty */ { $$.auth_method = IKEV2_AUTH_RSA_SIG; + $$.auth_eap = 0; $$.auth_length = 0; } | RSA { $$.auth_method = IKEV2_AUTH_RSA_SIG; + $$.auth_eap = 0; $$.auth_length = 0; } | PSK keyspec { memcpy(&$$, &$2, sizeof($$)); $$.auth_method = IKEV2_AUTH_SHARED_KEY_MIC; + $$.auth_eap = 0; + $$.auth_length = 0; } | EAP STRING{ unsigned int i;
Re: clarity recommendation for faq15.html
On Tue, Jul 19, 2016 at 02:05:06PM +0200, ludovic coues wrote: > faq4.html [1] already deal with the problem. > > [1] http://www.openbsd.org/faq/faq4.html#AddThoughts Granted. But that discussion does not include the ports tree and port building. Someone who has successfully installed may not refer back to faq4.html when they later run into partition size issues after following the untar guidance in faq15. A link to #AddThoughts in this section of faq15.html might be appropriate. > 2016-07-19 3:29 GMT+02:00 Josh Grosse : > > I had a conversation with a new OpenBSD user who thought that he > > may have either misunderstood or been misled by the guidance to unpack > > the ports tree tarball in /usr. He quickly discovered his 2G /usr > > default allocation was too small when he began to build ports. > > > > FAQ 15 doesn't warn users who selected automatic disk allocation that > > the default partition size may be inadequate for all but minor ports > > building. > > > > This proposed recommendation adds two sentences which may clarify, > > following immediately after the untar example. > > > > Index: faq15.html > > === > > RCS file: /cvs/www/faq/faq15.html,v > > retrieving revision 1.138 > > diff -u -p -r1.138 faq15.html > > --- faq15.html 18 Jun 2016 02:24:32 - 1.138 > > +++ faq15.html 19 Jul 2016 01:18:34 - > > @@ -763,6 +763,15 @@ For example: > > # tar xzf /tmp/ports.tar.gz > > > > > > +If you installed OpenBSD with automatic disk partition allocations, > > +/usr may be too small to contain the ports tree and > > +any active WRKOBJDIR build directories created in > > +/usr/ports/pobj by default. > > +A larger /usr, a separate /usr/ports partition, a > > +separate /usr/ports/pobj partition, or a non-standard > > +location for WRKOBJDIR may be considered. > > + > > + > > If you'd like to be able to write to /usr/ports as a regular user, > > see the next section. > > > > > > > > -- > > Cordialement, Coues Ludovic > +336 148 743 42 >
syn cache netstat -s
Hi, To tune the TCP syn cache we need more information. Print the relevant counters with netstat -s -p tcp. 1 SYN cache seed with new random 293 hash bucket array size in current SYN cache 199 entries in current SYN cache, limit is 10255 3 longest bucket length in current SYN cache, limit is 105 99800 uses of current SYN cache left ok? bluhm Index: sys/netinet/tcp_usrreq.c === RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/tcp_usrreq.c,v retrieving revision 1.133 diff -u -p -r1.133 tcp_usrreq.c --- sys/netinet/tcp_usrreq.c20 Jul 2016 09:15:28 - 1.133 +++ sys/netinet/tcp_usrreq.c20 Jul 2016 09:59:41 - @@ -936,6 +936,24 @@ tcp_sysctl(name, namelen, oldp, oldlenp, case TCPCTL_STATS: if (newp != NULL) return (EPERM); + { + struct syn_cache_set *set; + int i; + + set = &tcp_syn_cache[tcp_syn_cache_active]; + tcpstat.tcps_sc_hash_size = set->scs_size; + tcpstat.tcps_sc_entry_count = set->scs_count; + tcpstat.tcps_sc_entry_limit = tcp_syn_cache_limit; + tcpstat.tcps_sc_bucket_maxlen = 0; + for (i = 0; i < set->scs_size; i++) { + if (tcpstat.tcps_sc_bucket_maxlen < + set->scs_buckethead[i].sch_length) + tcpstat.tcps_sc_bucket_maxlen = + set->scs_buckethead[i].sch_length; + } + tcpstat.tcps_sc_bucket_limit = tcp_syn_bucket_limit; + tcpstat.tcps_sc_uses_left = set->scs_use; + } return (sysctl_struct(oldp, oldlenp, newp, newlen, &tcpstat, sizeof(tcpstat))); Index: sys/netinet/tcp_var.h === RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/tcp_var.h,v retrieving revision 1.114 diff -u -p -r1.114 tcp_var.h --- sys/netinet/tcp_var.h 20 Jul 2016 09:15:28 - 1.114 +++ sys/netinet/tcp_var.h 20 Jul 2016 09:32:27 - @@ -454,6 +454,12 @@ struct tcpstat { u_int64_t tcps_sc_collisions; /* # of hash collisions */ u_int64_t tcps_sc_retransmitted;/* # of retransmissions */ u_int64_t tcps_sc_seedrandom; /* # of syn cache seeds with random */ + u_int64_t tcps_sc_hash_size;/* hash buckets in current syn cache */ + u_int64_t tcps_sc_entry_count; /* # of entries in current syn cache */ + u_int64_t tcps_sc_entry_limit; /* limit of syn cache entries */ + u_int64_t tcps_sc_bucket_maxlen;/* maximum # of entries in any bucket */ + u_int64_t tcps_sc_bucket_limit; /* limit of syn cache bucket list */ + u_int64_t tcps_sc_uses_left;/* use counter of current syn cache */ u_int64_t tcps_conndrained; /* # of connections drained */ @@ -584,6 +590,7 @@ extern int tcp_syn_cache_limit; /* max e extern int tcp_syn_bucket_limit;/* max entries per hash bucket */ extern int tcp_syn_use_limit; /* number of uses before reseeding hash */ extern struct syn_cache_set tcp_syn_cache[]; +extern int tcp_syn_cache_active; /* active syn cache, may be 0 or 1 */ int tcp_attach(struct socket *); voidtcp_canceltimers(struct tcpcb *); Index: usr.bin/netstat/inet.c === RCS file: /data/mirror/openbsd/cvs/src/usr.bin/netstat/inet.c,v retrieving revision 1.146 diff -u -p -r1.146 inet.c --- usr.bin/netstat/inet.c 26 Apr 2016 22:24:10 - 1.146 +++ usr.bin/netstat/inet.c 20 Jul 2016 10:28:29 - @@ -367,8 +367,14 @@ tcp_stats(char *name) printf(m, tcpstat.f1, plural(tcpstat.f1), tcpstat.f2, plural(tcpstat.f2)) #definep2a(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \ printf(m, tcpstat.f1, plural(tcpstat.f1), tcpstat.f2) -#definep3(f, m) if (tcpstat.f || sflag <= 1) \ +#definep2b(f1, f2, m) if (tcpstat.f1 || sflag <= 1) \ + printf(m, tcpstat.f1, tcpstat.f2) +#definep2bys(f1, f2, m) if (tcpstat.f1 || sflag <= 1) \ + printf(m, tcpstat.f1, pluralys(tcpstat.f1), tcpstat.f2) +#definepes(f, m) if (tcpstat.f || sflag <= 1) \ printf(m, tcpstat.f, plurales(tcpstat.f)) +#definepys(f, m) if (tcpstat.f || sflag <= 1) \ + printf(m, tcpstat.f, pluralys(tcpstat.f)) p(tcps_sndtotal, "\t%u packet%s sent\n"); p2(tcps_sndpack,tcps_sndbyte, @@ -427,7 +433,7 @@ tcp_stats(char *name) p(tcps_keepdrops, "\t\t%u connection%s dropped by keepalive\n"); p(tcps_predack, "\t%u correct ACK header prediction%s\n"); p(tcps_preddat, "\t%u correct data packet header
split in6_selectsrc() for saner prototypes
This is a completely mechanical diff to get rid of the 7-params madness in in6_selectsrc(). I also apply the same treatment to in_selectsrc() for consistency. Ok? Index: sys/netinet/in_pcb.c === RCS file: /cvs/src/sys/netinet/in_pcb.c,v retrieving revision 1.210 diff -u -p -r1.210 in_pcb.c --- sys/netinet/in_pcb.c19 Jul 2016 14:49:46 - 1.210 +++ sys/netinet/in_pcb.c20 Jul 2016 10:21:17 - @@ -525,8 +525,7 @@ in_pcbconnect(struct inpcb *inp, struct if (sin->sin_port == 0) return (EADDRNOTAVAIL); - error = in_selectsrc(&ina, sin, inp->inp_moptions, &inp->inp_route, - &inp->inp_laddr, inp->inp_rtableid); + error = in_selpcbsrc(&ina, sin, inp); if (error) return (error); @@ -876,10 +875,14 @@ in_pcbrtentry(struct inpcb *inp) * an entry to the caller for later use. */ int -in_selectsrc(struct in_addr **insrc, struct sockaddr_in *sin, -struct ip_moptions *mopts, struct route *ro, struct in_addr *laddr, -u_int rtableid) +in_selpcbsrc(struct in_addr **insrc, struct sockaddr_in *sin, +struct inpcb *inp) { + struct ip_moptions *mopts = inp->inp_moptions; + struct route *ro = &inp->inp_route; + struct in_addr *laddr = &inp->inp_laddr; + u_int rtableid = inp->inp_rtableid; + struct sockaddr_in *sin2; struct in_ifaddr *ia = NULL; Index: sys/netinet/in_pcb.h === RCS file: /cvs/src/sys/netinet/in_pcb.h,v retrieving revision 1.100 diff -u -p -r1.100 in_pcb.h --- sys/netinet/in_pcb.h27 Jun 2016 16:33:48 - 1.100 +++ sys/netinet/in_pcb.h20 Jul 2016 10:21:17 - @@ -289,8 +289,7 @@ void in_setpeeraddr(struct inpcb *, str voidin_setsockaddr(struct inpcb *, struct mbuf *); int in_baddynamic(u_int16_t, u_int16_t); int in_rootonly(u_int16_t, u_int16_t); -int in_selectsrc(struct in_addr **, struct sockaddr_in *, - struct ip_moptions *, struct route *, struct in_addr *, u_int); +int in_selpcbsrc(struct in_addr **, struct sockaddr_in *, struct inpcb *); struct rtentry * in_pcbrtentry(struct inpcb *); Index: sys/netinet/udp_usrreq.c === RCS file: /cvs/src/sys/netinet/udp_usrreq.c,v retrieving revision 1.214 diff -u -p -r1.214 udp_usrreq.c --- sys/netinet/udp_usrreq.c28 Jun 2016 11:22:53 - 1.214 +++ sys/netinet/udp_usrreq.c20 Jul 2016 10:21:19 - @@ -989,8 +989,7 @@ udp_output(struct inpcb *inp, struct mbu goto release; } - error = in_selectsrc(&laddr, sin, inp->inp_moptions, - &inp->inp_route, &inp->inp_laddr, inp->inp_rtableid); + error = in_selpcbsrc(&laddr, sin, inp); if (error) goto release; Index: sys/netinet6/icmp6.c === RCS file: /cvs/src/sys/netinet6/icmp6.c,v retrieving revision 1.186 diff -u -p -r1.186 icmp6.c --- sys/netinet6/icmp6.c5 Jul 2016 10:17:14 - 1.186 +++ sys/netinet6/icmp6.c20 Jul 2016 10:21:19 - @@ -1259,7 +1259,7 @@ icmp6_reflect(struct mbuf *m, size_t off * source address of the erroneous packet. */ bzero(&ro, sizeof(ro)); - error = in6_selectsrc(&src, &sa6_src, NULL, NULL, &ro, NULL, + error = in6_selectsrc(&src, &sa6_src, NULL, &ro, m->m_pkthdr.ph_rtableid); if (ro.ro_rt) rtfree(ro.ro_rt); /* XXX: we could use this */ Index: sys/netinet6/in6_pcb.c === RCS file: /cvs/src/sys/netinet6/in6_pcb.c,v retrieving revision 1.93 diff -u -p -r1.93 in6_pcb.c --- sys/netinet6/in6_pcb.c 5 Jul 2016 10:17:14 - 1.93 +++ sys/netinet6/in6_pcb.c 20 Jul 2016 10:21:19 - @@ -281,9 +281,7 @@ in6_pcbconnect(struct inpcb *inp, struct * with the address specified by setsockopt(IPV6_PKTINFO). * Is it the intended behavior? */ - error = in6_selectsrc(&in6a, sin6, inp->inp_outputopts6, - inp->inp_moptions6, &inp->inp_route6, &inp->inp_laddr6, - inp->inp_rtableid); + error = in6_selpcbsrc(&in6a, sin6, inp, inp->inp_outputopts6); if (error) return (error); Index: sys/netinet6/in6_src.c === RCS file: /cvs/src/sys/netinet6/in6_src.c,v retrieving revision 1.76 diff -u -p -r1.76 in6_src.c --- sys/netinet6/in6_src.c 5 Jul 2016 10:17:14 - 1.76 +++ sys/netinet6/in6_src.c 20 Jul 2016 10:21:19 - @@ -88,15 +88,18 @@ int in6_selectif(struct sockaddr_in6 *, /* * Return an IPv6 address,