sed(1) make -i behave a little nicer

2018-12-06 Thread Martijn van Duren
I ran into a few minor nuisances with sed's -i mode, which are mostly 
compatible with gnu sed, but I reckon we should address.

The problem is sed works by writing the output to a second file in the
same directory as the original and after completion renaming the file
to the original. This has two disadvantages:
1) The inode number changes, resulting in loss of carefully crafted
   hardlinks.
2) We require to have write permission in the same directory as the
   original file, even if we don't want to have a backup file.

Diff below tries to solve this by doing the following.
Copy the file to the backup location (/tmp/sedXX if no
extension) and use the backup as the infile and the original as the
outfile.

Furthermore I changed the lstat to fstat, so we can edit symlinks (gsed
supports symlinks by replacing the symlink by a new real file, which is
also fun), and I extended the warning messages in process to show the
backup file if we crash during operation, so people will always know
where to recover the file in case of disaster.

Because process also error(FATAL, ...)s during process and we always
have a backup file I don't think the warning in sed.1 is worth keeping.

The only downside to this new approach (that I can think of) is that we
now temporarily have a file that is in an inconsistent state, but that's
not much different to writing a file with any other editor.

$ echo test > /usr/obj/test && dd if=/dev/zero of=/usr/obj/bloat
/usr/obj: write failed, file system is full
dd: /usr/obj/bloat: No space left on device
614113+0 records in
614112+0 records out
314425344 bytes transferred in 2.206 secs (142470196 bytes/sec)
$ ./obj/sed -i -f /tmp/test.sed /usr/obj/test   
   

/usr/obj: write failed, file system is full
sed: /usr/obj/test: No space left on device (backup at /tmp/sedgRPSLImG9N)
$ cat /tmp/test.sed
s/test/aaa/
$ cat /tmp/sedgRPSLImG9N 
test
$ ls -i /tmp/test
104 /tmp/test
$ sed -i s/test/foo/ /tmp/test
$ ls -i /tmp/test 
104 /tmp/test
$ doas touch /etc/test
$ doas chown martijn /etc/test
$ echo test > /etc/test
$ sed -i s/test/foo/ /etc/test
$ cat /etc/test 
foo

The diff does change quite a few mechanics, so some scrutiny is welcome.

martijn@

Index: main.c
===
RCS file: /cvs/src/usr.bin/sed/main.c,v
retrieving revision 1.39
diff -u -p -r1.39 main.c
--- main.c  6 Dec 2018 20:16:04 -   1.39
+++ main.c  7 Dec 2018 07:31:54 -
@@ -35,6 +35,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -94,13 +95,13 @@ static int rval;/* Exit status */
  */
 const char *fname; /* File name. */
 const char *outfname;  /* Output file name */
-static char oldfname[PATH_MAX];/* Old file name (for in-place editing) 
*/
-static char tmpfname[PATH_MAX];/* Temporary file name (for in-place 
editing) */
+char oldfname[PATH_MAX];   /* Old file name (for in-place editing) */
 char *inplace; /* Inplace edit file extension */
 u_long linenum;
 
 static void add_compunit(enum e_cut, char *);
 static void add_file(char *);
+int copy(FILE *, FILE *);
 static int next_files_have_lines(void);
 
 int termwidth;
@@ -310,26 +311,46 @@ again:
return (NULL);
 }
 
+int
+copy(FILE *src, FILE *dst)
+{
+   unsigned char buf[MAXBSIZE];
+   size_t r, w, tw;
+
+   while(1) {
+   if ((r = fread(buf, sizeof(*buf), sizeof(buf), src)) == 0) {
+   if (feof(src)) {
+   if (fflush(dst) == EOF)
+   return 0;
+   return 1;
+   }
+   if (errno != EINTR)
+   return 0;
+   continue;
+   }
+   tw = 0;
+   while(tw < r) {
+   w = fwrite(buf + tw, sizeof(*buf), r - tw, dst);
+   if (w == 0) {
+   if (errno != EINTR)
+   return 0;
+   continue;
+   }
+   tw += w;
+   }
+   }
+}
+
 void
 finish_file(void)
 {
if (infile != NULL) {
fclose(infile);
-   if (*oldfname != '\0') {
-   if (rename(fname, oldfname) != 0) {
-   warning("rename()");
-   unlink(tmpfname);
-   exit(1);
-   }
+   if (inplace != NULL) {
+   if (*oldfname == '\0')
+   unlink(oldfname);
*oldfname = '\0';
}
-   if (*tmpfname != '\0') {
-   if (outfile != NULL && outfile != stdout)
-   

Re: [Patch] Specify unit for 'every' in ifstated.conf.5

2018-12-06 Thread Jason McIntyre
On Fri, Dec 07, 2018 at 02:56:03PM +1100, Ross L Richardson wrote:
> 
> Whilst I agree with Otto (and others), how about making it really simple
> by avoiding technical terms?
> 
> Ross
> 
> 
> Index: ifstated.conf.5
> ===
> RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
> retrieving revision 1.13
> diff -u -p -r1.13 ifstated.conf.5
> --- ifstated.conf.5   18 Jun 2018 06:04:25 -  1.13
> +++ ifstated.conf.5   7 Dec 2018 02:59:43 -
> @@ -90,7 +90,8 @@ interfaces this equals the init state.
>  .Pp
>  In contrast to link state tests, external tests must be run periodically to
>  evaluate their status.
> -The frequency at which an external test is run has to be set with the
> +The interval in seconds between (starts of) runs of an external test is set
> +with the
>  .Ar every
>  keyword.
>  .Pp
> 

morning.

i'm afraid i think this reads quite poorly - it is hard to actually
understand what is meant.

here's the thing - someone has already written the text. if we want to
change the author's text, i think we need to demonstrate that their text
is wrong, inaccurate, or somehow misleading.

so far, i don;t believe anyone has done this. so i am reluctant to
change the author's words.

in the case of your original submission - the detail about seconds - i
am happy to change things. because there was relevant information
missing.

i think we are wasting time fixing nothing. can't we just add "in
seconds" and get on with it?

jmc



Re: [Patch] Specify unit for 'every' in ifstated.conf.5

2018-12-06 Thread Ross L Richardson


Whilst I agree with Otto (and others), how about making it really simple
by avoiding technical terms?

Ross


Index: ifstated.conf.5
===
RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
retrieving revision 1.13
diff -u -p -r1.13 ifstated.conf.5
--- ifstated.conf.5 18 Jun 2018 06:04:25 -  1.13
+++ ifstated.conf.5 7 Dec 2018 02:59:43 -
@@ -90,7 +90,8 @@ interfaces this equals the init state.
 .Pp
 In contrast to link state tests, external tests must be run periodically to
 evaluate their status.
-The frequency at which an external test is run has to be set with the
+The interval in seconds between (starts of) runs of an external test is set
+with the
 .Ar every
 keyword.
 .Pp



Re: relayd and TLS client cert verification

2018-12-06 Thread Ashe Connor
On Thu, Dec 06, 2018 at 12:46:33PM +, Rivo Nurges wrote:
> I have planned to do it myself for quite long time but never got around
> doing it. In my testing it works great.

Excellent, I'm glad to hear!


> I have patch on top of this which allows to pass remote certificate
> and/or parts of it to backend hosts via http headers.

That would be super useful -- I was planning on doing a similar feature
next.  (I'll probably do CRL support instead.)


Ashe



Re: Importing FreeBSD eMMC code

2018-12-06 Thread Heppler, J. Scott

I'll add my dmesg from an HP Stream 14 cb112wm

OpenBSD 6.4-current (RAMDISK_CD) #465: Wed Nov 28 22:26:21 MST 2018
   dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/RAMDISK_CD
real mem = 8128622592 (7752MB)
avail mem = 7878479872 (7513MB)
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 3.0 @ 0x65e06000 (36 entries)
bios0: vendor Insyde version "F.01" date 05/03/2018
bios0: HP HP Stream Laptop 14-cb1XX
acpi0 at bios0: rev 2
acpi0: tables DSDT FACP UEFI IHIS UEFI SSDT SSDT MSDM BDAT DBG2 DBGP HPET LPIT 
APIC MCFG NPKT PRAM WSMT SSDT SSDT SSDT SSDT SSDT SSDT SSDT FPDT WDAT BGRT
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Celeron(R) N4000 CPU @ 1.10GHz, 1097.30 MHz, 06-7a-01
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,EST,TM2,SSSE3,SDBG,CX16,xTPR,PDCM,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,3DNOWP,PERF,ITSC,FSGSBASE,SGX,SMEP,ERMS,MPX,RDSEED,SMAP,CLFLUSHOPT,PT,SHA,UMIP,IBRS,IBPB,STIBP,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
cpu0: 4MB 64b/line 16-way L2 cache
cpu0: apic clock running at 19MHz
cpu0: mwait min=64, max=64, C-substates=0.2.0.2.4.2.1.1, IBE
cpu at mainbus0: not configured
ioapic0 at mainbus0: apid 1 pa 0xfec0, version 20, 120 pins
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (RP01)
acpiprt2 at acpi0: bus -1 (RP02)
acpiprt3 at acpi0: bus -1 (RP03)
acpiprt4 at acpi0: bus -1 (RP04)
acpiprt5 at acpi0: bus 1 (RP05)
acpiprt6 at acpi0: bus -1 (RP06)
acpiec0 at acpi0
### AML PARSE ERROR (0x4cd5): Undefined name: SMA4
error evaluating: \\_SB_.PCI0.LPCB.EC0_._REG
acpiec _REG failed, broken BIOS
acpipwrres at acpi0 not configured
acpipwrres at acpi0 not configured
acpipwrres at acpi0 not configured
acpipwrres at acpi0 not configured
acpipwrres at acpi0 not configured
acpipwrres at acpi0 not configured
acpicpu at acpi0 not configured
acpitz at acpi0 not configured
"ACPI0003" at acpi0 not configured
"PNP0C0D" at acpi0 not configured
"PNP0C0C" at acpi0 not configured
"PNP0C0A" at acpi0 not configured
"PNP0A08" at acpi0 not configured
"HPQ6001" at acpi0 not configured
"HPIC0003" at acpi0 not configured
"*ETD0742" at acpi0 not configured
"PNP0B00" at acpi0 not configured
"INT3453" at acpi0 not configured
"INT0E0C" at acpi0 not configured
"INT33A1" at acpi0 not configured
"PNP0C14" at acpi0 not configured
"INT3400" at acpi0 not configured
"INT3403" at acpi0 not configured
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 vendor "Intel", unknown product 0x31f0 rev 0x03
vendor "Intel", unknown product 0x318c (class DASP subclass miscellaneous, rev 
0x03) at pci0 dev 0 function 1 not configured
vendor "Intel", unknown product 0x3190 (class system subclass miscellaneous, 
rev 0x03) at pci0 dev 0 function 3 not configured
vendor "Intel", unknown product 0x3185 (class display subclass VGA, rev 0x03) 
at pci0 dev 2 function 0 not configured
vendor "Intel", unknown product 0x3198 (class multimedia subclass hdaudio, rev 
0x03) at pci0 dev 14 function 0 not configured
vendor "Intel", unknown product 0x319a (class communications subclass 
miscellaneous, rev 0x03) at pci0 dev 15 function 0 not configured
ppb0 at pci0 dev 19 function 0 vendor "Intel", unknown product 0x31da rev 0xf3: 
msi
pci1 at ppb0 bus 1
"Realtek 8822BE" rev 0x00 at pci1 dev 0 function 0 not configured
xhci0 at pci0 dev 21 function 0 vendor "Intel", unknown product 0x31a8 rev 
0x03: msi, xHCI 1.0
usb0 at xhci0: USB revision 3.0
uhub0 at usb0 configuration 1 interface 0 "Intel xHCI root hub" rev 3.00/1.00 
addr 1
sdhc0 at pci0 dev 28 function 0 vendor "Intel", unknown product 0x31cc rev 
0x03: apic 1 int 39
sdhc0: SDHC 3.0, 200 MHz base clock
sdmmc0 at sdhc0: 8-bit, sd high-speed, mmc high-speed, dma
vendor "Intel", unknown product 0x31e8 (class bridge subclass ISA, rev 0x03) at 
pci0 dev 31 function 0 not configured
vendor "Intel", unknown product 0x31d4 (class serial bus subclass SMBus, rev 
0x03) at pci0 dev 31 function 1 not configured
isa0 at mainbus0
pckbc0 at isa0 port 0x60/5 irq 1 irq 12
pckbd0 at pckbc0 (kbd slot)
wskbd0 at pckbd0: console keyboard
efifb0 at mainbus0: 1366x768, 32bpp
wsdisplay0 at efifb0 mux 1: console (std, vt100 emulation), using wskbd0
umass0 at uhub0 port 3 configuration 1 interface 0 "USB DISK 2.0" rev 
2.00/12.19 addr 2
umass0: using SCSI over Bulk-Only
scsibus0 at umass0: 2 targets, initiator 0
sd0 at scsibus0 targ 1 lun 0:  SCSI0 0/direct removable 
serial.090c1000R75JEPN4EPUW
sd0: 956MB, 512 bytes/sector, 1957888 sectors
"Realtek Bluetooth Radio" rev 1.10/1.10 addr 3 at uhub0 port 5 not configured
"Generic HP Webcam" rev 2.00/1.01 addr 4 at uhub0 port 6 not configured
sdmmc0: can't enable card
softraid0 at root
scsibus1 at softraid0: 256 targets
root on rd0a swap on rd0b dump on rd0b
umass1 at uhub0 port 2 configuration 1 interface 0 "HP v125w" rev 

Re: Remove no longer used M_ALIGN and MH_ALIGN

2018-12-06 Thread Klemens Nanni
OK



Re: ktrace buglet

2018-12-06 Thread Klemens Nanni
On Thu, Dec 06, 2018 at 03:33:06PM -0500, Ted Unangst wrote:
> ktrace -C will return an error if you don't have a ktrace.out file because
> sys_ktrace tries to open it whenever it has a filename, even if it won't be
> used. I think it is more consistent to require it be null, so that we aren't
> opening files we won't be using.

> 
> man page and utility diff below.
`ktrace -C' is shown twice as example in ktrace(1), once in DESCRIPTION
and at the end of EXAMPLES again.

OK kn



Re: diff: ftpd(8): fix for sign-compare compiler warnings

2018-12-06 Thread Jan Klemkow
On Tue, Nov 27, 2018 at 09:03:15AM +0100, Theo Buehler wrote:
> On Sun, Nov 25, 2018 at 12:32:23AM +0100, Jan Klemkow wrote:
> > This diff fixes some -Wsign-compare compiler warnings in ftpd(8) by
> > using the right types for 'i' and 'len'.  One warning is left, but I
> > don't see that it's fixable without suppressing the warning by a cast of
> > len to size_t.  And casting might be controversial in this case?!
> 
> The diff looks correct to me. If anyone wants to commit
> 
> ok tb
> 
> > /usr/src/libexec/ftpd/ftpd.c:2781:11: warning: comparison of integers of
> > different signs: 'int' and
> >   'unsigned long' [-Wsign-compare]
> > if (len >= sizeof(buf) || len == -1) {
> > ~~~ ^  ~~~
> 
> This test is the wrong way around: compare CAVEATS in snprintf(3).

I missed that.  The following diff fixes that, but doesn't include
a cast.

> There's a ton of unchecked snprintfs in this code. Did you take a look
> at those?

Yes, I noticed that.  I may change that in a later diff.

Thanks,
Jan

Index: ftpd.c
===
RCS file: /cvs/src/libexec/ftpd/ftpd.c,v
retrieving revision 1.223
diff -u -p -r1.223 ftpd.c
--- ftpd.c  3 Sep 2016 15:00:48 -   1.223
+++ ftpd.c  6 Dec 2018 18:19:21 -
@@ -390,10 +390,10 @@ main(int argc, char *argv[])
endpwent();
 
if (daemon_mode) {
-   int *fds, i, fd;
+   int *fds, fd;
struct pollfd *pfds;
struct addrinfo hints, *res, *res0;
-   nfds_t n;
+   nfds_t n, i;
 
/*
 * Detach from parent.
@@ -1809,8 +1809,8 @@ statcmd(void)
ispassive++;
goto printaddr;
} else if (usedefault == 0) {
-   size_t alen;
-   int af, i;
+   size_t alen, i;
+   int af;
 
su = (union sockunion *)_dest;
 printaddr:
@@ -2545,7 +2545,8 @@ guniquefd(char *local, char **nam)
 {
static char new[PATH_MAX];
struct stat st;
-   int count, len, fd;
+   size_t len;
+   int count, fd;
char *cp;
 
cp = strrchr(local, '/');
@@ -2777,7 +2778,7 @@ logxfer(char *name, off_t size, time_t s
((guest) ? "*" : pw->pw_name), dhostname);
free(vpw);
 
-   if (len >= sizeof(buf) || len == -1) {
+   if (len == -1 || len >= sizeof(buf)) {
if ((len = strlen(buf)) == 0)
return; /* should not happen */
buf[len - 1] = '\n';



Re: be more strict when parsing netmasks for IPv6

2018-12-06 Thread Claudio Jeker
On Thu, Dec 06, 2018 at 08:04:54PM +0100, Remi Locherer wrote:
> On Thu, Dec 06, 2018 at 03:24:52PM +0100, Claudio Jeker wrote:
> > On Wed, Dec 05, 2018 at 11:53:48PM +0100, Remi Locherer wrote:
> > > On Wed, Dec 05, 2018 at 09:22:22AM +0100, Claudio Jeker wrote:
> > > > When parsing a network mask into prefixlen be more paranoid and make 
> > > > sure
> > > > no value bigger then 128 is returned. In general this should never 
> > > > happen
> > > > but if it does the result can be bad.
> > > > 
> > > > This is for bgpd but there are other users in the tree. I will adjust 
> > > > them
> > > > if we dicide to go this way.
> > > > -- 
> > > > :wq Claudio
> > > > 
> > > 
> > > makes sense to me.
> > > 
> > > OK remi@
> > > 
> > 
> > Here the same diff against other users of mask2prefixlen6().
> > IIRC there are some other users with different function names which I need
> > to hunt down (unless someone else wants to do that job).
> > 
> > Iked is a bit special since it returns 0 for non-contiguous netmasks.
> > Wonder if we should put a fatalx() there too - like in the other daemons.
> 
> I think it should be fatalx() also for iked.
> 
> Your diff looks good to me, OK remi@.
> 
> Below  the same diff for ospf6d. Feel free to commit it together with
> the rest.
> 

Na, you can do that one :). OK claudio@
 
> 
> cvs diff: Diffing .
> Index: util.c
> ===
> RCS file: /cvs/src/usr.sbin/ospf6d/util.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 util.c
> --- util.c22 Oct 2012 07:28:49 -  1.2
> +++ util.c6 Dec 2018 18:49:51 -
> @@ -91,7 +91,8 @@ clearscope(struct in6_addr *in6)
>  u_int8_t
>  mask2prefixlen(struct sockaddr_in6 *sa_in6)
>  {
> - u_int8_tl = 0, *ap, *ep;
> + u_int8_t*ap, *ep;
> + u_intl = 0;
>  
>   /*
>* sin6_len is the size of the sockaddr so substract the offset of
> @@ -107,32 +108,35 @@ mask2prefixlen(struct sockaddr_in6 *sa_i
>   break;
>   case 0xfe:
>   l += 7;
> - return (l);
> + goto done;
>   case 0xfc:
>   l += 6;
> - return (l);
> + goto done;
>   case 0xf8:
>   l += 5;
> - return (l);
> + goto done;
>   case 0xf0:
>   l += 4;
> - return (l);
> + goto done;
>   case 0xe0:
>   l += 3;
> - return (l);
> + goto done;
>   case 0xc0:
>   l += 2;
> - return (l);
> + goto done;
>   case 0x80:
>   l += 1;
> - return (l);
> + goto done;
>   case 0x00:
> - return (l);
> + goto done;
>   default:
>   fatalx("non contiguous inet6 netmask");
>   }
>   }
>  
> +done:
> + if (l > sizeof(struct in6_addr) * 8)
> + fatalx("%s: prefixlen %d out of bound", __func__, l);
>   return (l);
>  }
>  
> 

-- 
:wq Claudio



Re: bail early in nd6_na_output() if not carp master

2018-12-06 Thread Claudio Jeker
On Thu, Dec 06, 2018 at 08:03:01PM +0100, Florian Obser wrote:
> Spotted this when reviewing Claudio's m_align diff and wondered why we
> bail right at the end just before we send the packet. Is there stuff
> happening before that's important? Turns out no.
> 
> (I suspect this is a belt for suspenders somewhere else in the stack
> and we never get here on a carp backup interface).
> 
> OK?

Sure OK claudio@
 
> diff --git netinet6/nd6_nbr.c netinet6/nd6_nbr.c
> index a90f852b25e..6aa2586a082 100644
> --- netinet6/nd6_nbr.c
> +++ netinet6/nd6_nbr.c
> @@ -891,6 +891,12 @@ nd6_na_output(struct ifnet *ifp, struct in6_addr *daddr6,
>   int icmp6len, maxlen;
>   caddr_t mac = NULL;
>  
> +#if NCARP > 0
> + /* Do not send NAs for carp addresses if we're not the CARP master. */
> + if (ifp->if_type == IFT_CARP && !carp_iamatch(ifp))
> + return;
> +#endif
> +
>   /* estimate the size of message */
>   maxlen = sizeof(*ip6) + sizeof(*nd_na);
>   maxlen += (sizeof(struct nd_opt_hdr) + ifp->if_addrlen + 7) & ~7;
> @@ -1010,12 +1016,6 @@ nd6_na_output(struct ifnet *ifp, struct in6_addr 
> *daddr6,
>   } else
>   flags &= ~ND_NA_FLAG_OVERRIDE;
>  
> -#if NCARP > 0
> - /* Do not send NAs for carp addresses if we're not the CARP master. */
> - if (ifp->if_type == IFT_CARP && !carp_iamatch(ifp))
> - goto bad;
> -#endif
> -
>   ip6->ip6_plen = htons((u_short)icmp6len);
>   nd_na->nd_na_flags_reserved = flags;
>   nd_na->nd_na_cksum = 0;
> 
> 
> -- 
> I'm not entirely sure you are real.
> 

-- 
:wq Claudio



Re: Importing FreeBSD eMMC code

2018-12-06 Thread Ted Unangst
Heppler, J. Scott wrote:
> Is there interest in installing/booting OpenBSD on eMMC?

this is expected to work.



Importing FreeBSD eMMC code

2018-12-06 Thread Heppler, J. Scott

The market is being flooded with Win10 netbooks, NAS, NUC-type devices
that use eMMC.  I suspect this is due to the eMMC being filled with
multiple backups from Microsofts' update process and being returned for
failure to update.  The devices are relatively cheap.  Leveno, Acer,
Asus and HP all are producing eMMC netbooks.

FreeBSD has committed some code in the upcoming release that allows
recognition of the storage.

https://github.com/freebsd/freebsd/blob/ed7adc5aa801e5a1891b499776bef996b8d0242f/sys/dev/sdhci/sdhci_acpi.c#L76-L82

The eMMC storage is not seen by the bsd.rd installer but is seen by
bsd.sp/bsd.mp

I'm running Arch linux on mine after the OpenBSD installer failed to
find the eMMC drive.  My results were identical to this prior report.

http://openbsd-archive.7691.n7.nabble.com/Need-help-installing-6-3-to-Acer-Aspire-with-eMMC-drive-sdmmc-troubles-td352781.html

Is there interest in installing/booting OpenBSD on eMMC?
--
J. Scott Heppler



ktrace buglet

2018-12-06 Thread Ted Unangst
ktrace -C will return an error if you don't have a ktrace.out file because
sys_ktrace tries to open it whenever it has a filename, even if it won't be
used. I think it is more consistent to require it be null, so that we aren't
opening files we won't be using.

man page and utility diff below.


Index: usr.bin/ktrace/ktrace.c
===
RCS file: /cvs/src/usr.bin/ktrace/ktrace.c,v
retrieving revision 1.34
diff -u -p -r1.34 ktrace.c
--- usr.bin/ktrace/ktrace.c 11 Jun 2017 17:32:19 -  1.34
+++ usr.bin/ktrace/ktrace.c 6 Dec 2018 20:23:52 -
@@ -110,6 +110,7 @@ main(int argc, char *argv[])
break;
case 'C':
clear = CLEARALL;
+   tracefile = NULL;
pidset = 1;
break;
case 'c':
Index: lib/libc/sys/ktrace.2
===
RCS file: /cvs/src/lib/libc/sys/ktrace.2,v
retrieving revision 1.36
diff -u -p -r1.36 ktrace.2
--- lib/libc/sys/ktrace.2   19 Jun 2018 15:39:01 -  1.36
+++ lib/libc/sys/ktrace.2   6 Dec 2018 20:30:07 -
@@ -61,11 +61,8 @@ If tracing points are being disabled (se
 .Dv KTROP_CLEAR
 below),
 .Fa tracefile
-may be
-.Dv NULL
-or
-.Fa tracefd
-may be -1.
+must be
+.Dv NULL .
 .Pp
 Trace records are always appended to the file, ignoring the file offset,
 so the caller will usually want to truncate the file before calling



Re: [Patch] Specify unit for 'every' in ifstated.conf.5

2018-12-06 Thread Stuart Henderson
On 2018/12/06 13:01, Ted Unangst wrote:
> Jason McIntyre wrote:
> > On Thu, Dec 06, 2018 at 10:21:47PM +1100, Ross L Richardson wrote:
> > > 
> > > The number is in seconds, but that's currently not specified.
> > > 
> > > Wording which preserved "frequency" but made sense with "seconds"
> > > eluded me, so I changed things to refer to "interval".
> > > 
> > > 
> > > Ross
> > > 
> > > 
> > > 
> > > Index: ifstated.conf.5
> > > ===
> > > RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
> > > retrieving revision 1.13
> > > diff -u -p -r1.13 ifstated.conf.5
> > > --- ifstated.conf.5   18 Jun 2018 06:04:25 -  1.13
> > > +++ ifstated.conf.5   6 Dec 2018 11:12:44 -
> > > @@ -90,7 +90,8 @@ interfaces this equals the init state.
> > >  .Pp
> > >  In contrast to link state tests, external tests must be run periodically 
> > > to
> > >  evaluate their status.
> > > -The frequency at which an external test is run has to be set with the
> > > +The interval in seconds between invocations of an external test has to
> > > +be set with the
> > >  .Ar every
> 
> The interval in seconds between test runs is specified by the required keyword
> every.
> 

That implies "test 2 starts X seconds after the *end* of test 1",
but actually it's "test 2 starts X seconds after the *start* of test 1"
which is what I think the original use of "frequency" was trying to
imply.



Re: option kcov + GENERIC.MP -> silent crash

2018-12-06 Thread Greg Steuck
> Here's a new diff taking a different approach. Keeping tracing off until
> all secondary CPUs have booted solves the issue of accessing curcpu()
> too early. Another issue was then discovered, curproc can be NULL before
> the idle thread tied the current CPU has started. Currently running with
> this diff applied on my laptop (MP) and positive results from Greg. The
> diff will be further exercised in the actual syzkaller setup before
> committing.

Thanks Anton. This diff is running now on
https://syzkaller.appspot.com/#openbsd as
openbsd/ci-openbsd-multicore. Looking great so far.



Re: be more strict when parsing netmasks for IPv6

2018-12-06 Thread Remi Locherer
On Thu, Dec 06, 2018 at 03:24:52PM +0100, Claudio Jeker wrote:
> On Wed, Dec 05, 2018 at 11:53:48PM +0100, Remi Locherer wrote:
> > On Wed, Dec 05, 2018 at 09:22:22AM +0100, Claudio Jeker wrote:
> > > When parsing a network mask into prefixlen be more paranoid and make sure
> > > no value bigger then 128 is returned. In general this should never happen
> > > but if it does the result can be bad.
> > > 
> > > This is for bgpd but there are other users in the tree. I will adjust them
> > > if we dicide to go this way.
> > > -- 
> > > :wq Claudio
> > > 
> > 
> > makes sense to me.
> > 
> > OK remi@
> > 
> 
> Here the same diff against other users of mask2prefixlen6().
> IIRC there are some other users with different function names which I need
> to hunt down (unless someone else wants to do that job).
> 
> Iked is a bit special since it returns 0 for non-contiguous netmasks.
> Wonder if we should put a fatalx() there too - like in the other daemons.

I think it should be fatalx() also for iked.

Your diff looks good to me, OK remi@.

Below  the same diff for ospf6d. Feel free to commit it together with
the rest.



cvs diff: Diffing .
Index: util.c
===
RCS file: /cvs/src/usr.sbin/ospf6d/util.c,v
retrieving revision 1.2
diff -u -p -r1.2 util.c
--- util.c  22 Oct 2012 07:28:49 -  1.2
+++ util.c  6 Dec 2018 18:49:51 -
@@ -91,7 +91,8 @@ clearscope(struct in6_addr *in6)
 u_int8_t
 mask2prefixlen(struct sockaddr_in6 *sa_in6)
 {
-   u_int8_tl = 0, *ap, *ep;
+   u_int8_t*ap, *ep;
+   u_intl = 0;
 
/*
 * sin6_len is the size of the sockaddr so substract the offset of
@@ -107,32 +108,35 @@ mask2prefixlen(struct sockaddr_in6 *sa_i
break;
case 0xfe:
l += 7;
-   return (l);
+   goto done;
case 0xfc:
l += 6;
-   return (l);
+   goto done;
case 0xf8:
l += 5;
-   return (l);
+   goto done;
case 0xf0:
l += 4;
-   return (l);
+   goto done;
case 0xe0:
l += 3;
-   return (l);
+   goto done;
case 0xc0:
l += 2;
-   return (l);
+   goto done;
case 0x80:
l += 1;
-   return (l);
+   goto done;
case 0x00:
-   return (l);
+   goto done;
default:
fatalx("non contiguous inet6 netmask");
}
}
 
+done:
+   if (l > sizeof(struct in6_addr) * 8)
+   fatalx("%s: prefixlen %d out of bound", __func__, l);
return (l);
 }
 



bail early in nd6_na_output() if not carp master

2018-12-06 Thread Florian Obser
Spotted this when reviewing Claudio's m_align diff and wondered why we
bail right at the end just before we send the packet. Is there stuff
happening before that's important? Turns out no.

(I suspect this is a belt for suspenders somewhere else in the stack
and we never get here on a carp backup interface).

OK?

diff --git netinet6/nd6_nbr.c netinet6/nd6_nbr.c
index a90f852b25e..6aa2586a082 100644
--- netinet6/nd6_nbr.c
+++ netinet6/nd6_nbr.c
@@ -891,6 +891,12 @@ nd6_na_output(struct ifnet *ifp, struct in6_addr *daddr6,
int icmp6len, maxlen;
caddr_t mac = NULL;
 
+#if NCARP > 0
+   /* Do not send NAs for carp addresses if we're not the CARP master. */
+   if (ifp->if_type == IFT_CARP && !carp_iamatch(ifp))
+   return;
+#endif
+
/* estimate the size of message */
maxlen = sizeof(*ip6) + sizeof(*nd_na);
maxlen += (sizeof(struct nd_opt_hdr) + ifp->if_addrlen + 7) & ~7;
@@ -1010,12 +1016,6 @@ nd6_na_output(struct ifnet *ifp, struct in6_addr *daddr6,
} else
flags &= ~ND_NA_FLAG_OVERRIDE;
 
-#if NCARP > 0
-   /* Do not send NAs for carp addresses if we're not the CARP master. */
-   if (ifp->if_type == IFT_CARP && !carp_iamatch(ifp))
-   goto bad;
-#endif
-
ip6->ip6_plen = htons((u_short)icmp6len);
nd_na->nd_na_flags_reserved = flags;
nd_na->nd_na_cksum = 0;


-- 
I'm not entirely sure you are real.



Re: be more strict when parsing netmasks for IPv6

2018-12-06 Thread Claudio Jeker
On Thu, Dec 06, 2018 at 05:14:45PM +0100, Florian Obser wrote:
> On Thu, Dec 06, 2018 at 03:24:52PM +0100, Claudio Jeker wrote:
> > On Wed, Dec 05, 2018 at 11:53:48PM +0100, Remi Locherer wrote:
> > > On Wed, Dec 05, 2018 at 09:22:22AM +0100, Claudio Jeker wrote:
> > > > When parsing a network mask into prefixlen be more paranoid and make 
> > > > sure
> > > > no value bigger then 128 is returned. In general this should never 
> > > > happen
> > > > but if it does the result can be bad.
> > > > 
> > > > This is for bgpd but there are other users in the tree. I will adjust 
> > > > them
> > > > if we dicide to go this way.
> > > > -- 
> > > > :wq Claudio
> > > > 
> > > 
> > > makes sense to me.
> > > 
> > > OK remi@
> > > 
> > 
> > Here the same diff against other users of mask2prefixlen6().
> > IIRC there are some other users with different function names which I need
> > to hunt down (unless someone else wants to do that job).
> 
> rad(8) and slaacd(8) use
> 
> int
> in6_mask2prefixlen(struct in6_addr *in6)
> {
>   u_char *nam = (u_char *)in6;
>   int byte, bit, plen = 0, size = sizeof(struct in6_addr);
> 
>   for (byte = 0; byte < size; byte++, plen += 8)
>   if (nam[byte] != 0xff)
>   break;
>   if (byte == size)
>   return (plen);
>   for (bit = 7; bit != 0; bit--, plen++)
>   if (!(nam[byte] & (1 << bit)))
>   break;
>   for (; bit != 0; bit--)
>   if (nam[byte] & (1 << bit))
>   return (0);
>   byte++;
>   for (; byte < size; byte++)
>   if (nam[byte])
>   return (0);
>   return (plen);
> }
> 
> which came from ifconfig where it's called prefix() and is actually AF
> independent.
> 
> Note that it operates on in6_addr not struct sockaddr_in6...
> 
> rad(8) could be easily adapted since it's operating on struct sockaddr_in6
> anyway. slaacd(8) is a bit more difficult since it passes struct
> in6_addr around.
> 
> I'm not sure it's worth the effort though. Its not like one version is
> massively better than the other. Having only one version is an
> improvement though...

I'm not suggesting to change functions that are working correctly.
At the moment I'm just looking at all those that are similar to the bgpd
one and will adjust those if possible. 
The version you pasted returns 0 for any non-consecutive netmask which is not
ideal but that is another story.

-- 
:wq Claudio



Re: [Patch] Specify unit for 'every' in ifstated.conf.5

2018-12-06 Thread Jason McIntyre
On Thu, Dec 06, 2018 at 01:01:49PM -0500, Ted Unangst wrote:
> Jason McIntyre wrote:
> > On Thu, Dec 06, 2018 at 10:21:47PM +1100, Ross L Richardson wrote:
> > > 
> > > The number is in seconds, but that's currently not specified.
> > > 
> > > Wording which preserved "frequency" but made sense with "seconds"
> > > eluded me, so I changed things to refer to "interval".
> > > 
> > > 
> > > Ross
> > > 
> > > 
> > > 
> > > Index: ifstated.conf.5
> > > ===
> > > RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
> > > retrieving revision 1.13
> > > diff -u -p -r1.13 ifstated.conf.5
> > > --- ifstated.conf.5   18 Jun 2018 06:04:25 -  1.13
> > > +++ ifstated.conf.5   6 Dec 2018 11:12:44 -
> > > @@ -90,7 +90,8 @@ interfaces this equals the init state.
> > >  .Pp
> > >  In contrast to link state tests, external tests must be run periodically 
> > > to
> > >  evaluate their status.
> > > -The frequency at which an external test is run has to be set with the
> > > +The interval in seconds between invocations of an external test has to
> > > +be set with the
> > >  .Ar every
> 
> The interval in seconds between test runs is specified by the required keyword
> every.
> 

that would be fine too but a) why change frequency, it's not wrong and
b) a "test run" is, well, a test run. but not the same as an external
test.

i honestly think the author's original sentence was fine. it was just
missing the detail of measurement - seconds. the trick is to put that
back into the sentence with as little fuss as possible.

jmc



Re: [Patch] Specify unit for 'every' in ifstated.conf.5

2018-12-06 Thread Jason McIntyre
On Thu, Dec 06, 2018 at 06:40:28PM +0100, Otto Moerbeek wrote:
> On Thu, Dec 06, 2018 at 05:33:21PM +, Jason McIntyre wrote:
> 
> > On Thu, Dec 06, 2018 at 06:26:36PM +0100, Otto Moerbeek wrote:
> > > On Thu, Dec 06, 2018 at 05:22:36PM +, Jason McIntyre wrote:
> > > 
> > > > On Thu, Dec 06, 2018 at 06:17:16PM +0100, Otto Moerbeek wrote:
> > > > > On Thu, Dec 06, 2018 at 05:09:23PM +, Jason McIntyre wrote:
> > > > > 
> > > > > > On Thu, Dec 06, 2018 at 10:21:47PM +1100, Ross L Richardson wrote:
> > > > > > > 
> > > > > > > The number is in seconds, but that's currently not specified.
> > > > > > > 
> > > > > > > Wording which preserved "frequency" but made sense with "seconds"
> > > > > > > eluded me, so I changed things to refer to "interval".
> > > > > > > 
> > > > > > > 
> > > > > > > Ross
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > Index: ifstated.conf.5
> > > > > > > ===
> > > > > > > RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
> > > > > > > retrieving revision 1.13
> > > > > > > diff -u -p -r1.13 ifstated.conf.5
> > > > > > > --- ifstated.conf.5   18 Jun 2018 06:04:25 -  1.13
> > > > > > > +++ ifstated.conf.5   6 Dec 2018 11:12:44 -
> > > > > > > @@ -90,7 +90,8 @@ interfaces this equals the init state.
> > > > > > >  .Pp
> > > > > > >  In contrast to link state tests, external tests must be run 
> > > > > > > periodically to
> > > > > > >  evaluate their status.
> > > > > > > -The frequency at which an external test is run has to be set 
> > > > > > > with the
> > > > > > > +The interval in seconds between invocations of an external test 
> > > > > > > has to
> > > > > > > +be set with the
> > > > > > >  .Ar every
> > > > > > >  keyword.
> > > > > > >  .Pp
> > > > > > > 
> > > > > > 
> > > > > > hi.
> > > > > > 
> > > > > > what about like this:
> > > > > > 
> > > > > > Index: ifstated.conf.5
> > > > > > ===
> > > > > > RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
> > > > > > retrieving revision 1.13
> > > > > > diff -u -r1.13 ifstated.conf.5
> > > > > > --- ifstated.conf.5 18 Jun 2018 06:04:25 -  1.13
> > > > > > +++ ifstated.conf.5 6 Dec 2018 17:08:25 -
> > > > > > @@ -90,7 +90,7 @@
> > > > > >  .Pp
> > > > > >  In contrast to link state tests, external tests must be run 
> > > > > > periodically to
> > > > > >  evaluate their status.
> > > > > > -The frequency at which an external test is run has to be set with 
> > > > > > the
> > > > > > +The frequency at which an external test is run is set, in seconds, 
> > > > > > with the
> > > > > >  .Ar every
> > > > > >  keyword.
> > > > > >  .Pp
> > > > > > 
> > > > > 
> > > > > That should be "period", right?
> > > > > 
> > > > >   -Otto
> > > > > 
> > > > 
> > > > hi otto. i don;t understand the question. what should be "period"?
> > > > jmc
> > > > 
> > > 
> > > frequency is a word used for occurences per time unit.
> > > period is the time beteen repeating events.
> > > 
> > > If you talk about the time beteen runs, you're talking about a period.
> > > 
> > >   -Otto
> > > 
> > 
> > oh.
> > 
> > from a technical (mathematical) point of view, i'm not totally sure.
> > however substituting "frequency" for "period" in the sentence above will
> > read very poorly. "frequency" was clear, but maybe that is because i'm
> > less aware of these differences.
> > 
> > the frequency at which something happens sounds ok to me in this sense.
> > i was really trying to preserve the original words - ross had complained
> > of being unable to come up with something that did so.
> > 
> > rereading your words, i feel i don;t really grasp this. can you give an
> > example? 
> > 
> > thanks,
> > jmc
> > 
> 
> The frequency of clock ticks is 60 per minute.
> The period of clock ticks is 1 sec.
> 

thanks, that's what i wanted.

of those two sentences, i'm fine with the first. the second sounds
much odder though. normally you have a period of time, or a long
period, or somesuch. saying simply "period" here is weird, because it's
followed by "of clock ticks", which sounds like it's trying to quantify
the period (a period of ten seconds).

i know US english uses "period" differently in some ways. perhaps that's
more common there. but i would not write it like that.

> Whats wrong with 
> 
> "The period at which an external test is run has to be set, in
> seconds, with the every keyword."
> 

that does sound ok. i don;t hugely like it, but that's probably my bias.
i think in the original text the inference was that there was a
frequency: once, every "every" seconds. hence it read fine.

i would not change what was there like this though.

jmc

> But maybe I'm too strict. People often used the term freqency when
> they mean period.
> 
>   -Otto
> 



Re: [Patch] Specify unit for 'every' in ifstated.conf.5

2018-12-06 Thread Ted Unangst
Jason McIntyre wrote:
> On Thu, Dec 06, 2018 at 10:21:47PM +1100, Ross L Richardson wrote:
> > 
> > The number is in seconds, but that's currently not specified.
> > 
> > Wording which preserved "frequency" but made sense with "seconds"
> > eluded me, so I changed things to refer to "interval".
> > 
> > 
> > Ross
> > 
> > 
> > 
> > Index: ifstated.conf.5
> > ===
> > RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
> > retrieving revision 1.13
> > diff -u -p -r1.13 ifstated.conf.5
> > --- ifstated.conf.5 18 Jun 2018 06:04:25 -  1.13
> > +++ ifstated.conf.5 6 Dec 2018 11:12:44 -
> > @@ -90,7 +90,8 @@ interfaces this equals the init state.
> >  .Pp
> >  In contrast to link state tests, external tests must be run periodically to
> >  evaluate their status.
> > -The frequency at which an external test is run has to be set with the
> > +The interval in seconds between invocations of an external test has to
> > +be set with the
> >  .Ar every

The interval in seconds between test runs is specified by the required keyword
every.



Re: [Patch] Specify unit for 'every' in ifstated.conf.5

2018-12-06 Thread Otto Moerbeek
On Thu, Dec 06, 2018 at 05:33:21PM +, Jason McIntyre wrote:

> On Thu, Dec 06, 2018 at 06:26:36PM +0100, Otto Moerbeek wrote:
> > On Thu, Dec 06, 2018 at 05:22:36PM +, Jason McIntyre wrote:
> > 
> > > On Thu, Dec 06, 2018 at 06:17:16PM +0100, Otto Moerbeek wrote:
> > > > On Thu, Dec 06, 2018 at 05:09:23PM +, Jason McIntyre wrote:
> > > > 
> > > > > On Thu, Dec 06, 2018 at 10:21:47PM +1100, Ross L Richardson wrote:
> > > > > > 
> > > > > > The number is in seconds, but that's currently not specified.
> > > > > > 
> > > > > > Wording which preserved "frequency" but made sense with "seconds"
> > > > > > eluded me, so I changed things to refer to "interval".
> > > > > > 
> > > > > > 
> > > > > > Ross
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > Index: ifstated.conf.5
> > > > > > ===
> > > > > > RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
> > > > > > retrieving revision 1.13
> > > > > > diff -u -p -r1.13 ifstated.conf.5
> > > > > > --- ifstated.conf.5 18 Jun 2018 06:04:25 -  1.13
> > > > > > +++ ifstated.conf.5 6 Dec 2018 11:12:44 -
> > > > > > @@ -90,7 +90,8 @@ interfaces this equals the init state.
> > > > > >  .Pp
> > > > > >  In contrast to link state tests, external tests must be run 
> > > > > > periodically to
> > > > > >  evaluate their status.
> > > > > > -The frequency at which an external test is run has to be set with 
> > > > > > the
> > > > > > +The interval in seconds between invocations of an external test 
> > > > > > has to
> > > > > > +be set with the
> > > > > >  .Ar every
> > > > > >  keyword.
> > > > > >  .Pp
> > > > > > 
> > > > > 
> > > > > hi.
> > > > > 
> > > > > what about like this:
> > > > > 
> > > > > Index: ifstated.conf.5
> > > > > ===
> > > > > RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
> > > > > retrieving revision 1.13
> > > > > diff -u -r1.13 ifstated.conf.5
> > > > > --- ifstated.conf.5   18 Jun 2018 06:04:25 -  1.13
> > > > > +++ ifstated.conf.5   6 Dec 2018 17:08:25 -
> > > > > @@ -90,7 +90,7 @@
> > > > >  .Pp
> > > > >  In contrast to link state tests, external tests must be run 
> > > > > periodically to
> > > > >  evaluate their status.
> > > > > -The frequency at which an external test is run has to be set with the
> > > > > +The frequency at which an external test is run is set, in seconds, 
> > > > > with the
> > > > >  .Ar every
> > > > >  keyword.
> > > > >  .Pp
> > > > > 
> > > > 
> > > > That should be "period", right?
> > > > 
> > > > -Otto
> > > > 
> > > 
> > > hi otto. i don;t understand the question. what should be "period"?
> > > jmc
> > > 
> > 
> > frequency is a word used for occurences per time unit.
> > period is the time beteen repeating events.
> > 
> > If you talk about the time beteen runs, you're talking about a period.
> > 
> > -Otto
> > 
> 
> oh.
> 
> from a technical (mathematical) point of view, i'm not totally sure.
> however substituting "frequency" for "period" in the sentence above will
> read very poorly. "frequency" was clear, but maybe that is because i'm
> less aware of these differences.
> 
> the frequency at which something happens sounds ok to me in this sense.
> i was really trying to preserve the original words - ross had complained
> of being unable to come up with something that did so.
> 
> rereading your words, i feel i don;t really grasp this. can you give an
> example? 
> 
> thanks,
> jmc
> 

The frequency of clock ticks is 60 per minute.
The period of clock ticks is 1 sec.

Whats wrong with 

"The period at which an external test is run has to be set, in
seconds, with the every keyword."

But maybe I'm too strict. People often used the term freqency when
they mean period.

-Otto



Re: [Patch] Specify unit for 'every' in ifstated.conf.5

2018-12-06 Thread Jason McIntyre
On Thu, Dec 06, 2018 at 06:26:36PM +0100, Otto Moerbeek wrote:
> On Thu, Dec 06, 2018 at 05:22:36PM +, Jason McIntyre wrote:
> 
> > On Thu, Dec 06, 2018 at 06:17:16PM +0100, Otto Moerbeek wrote:
> > > On Thu, Dec 06, 2018 at 05:09:23PM +, Jason McIntyre wrote:
> > > 
> > > > On Thu, Dec 06, 2018 at 10:21:47PM +1100, Ross L Richardson wrote:
> > > > > 
> > > > > The number is in seconds, but that's currently not specified.
> > > > > 
> > > > > Wording which preserved "frequency" but made sense with "seconds"
> > > > > eluded me, so I changed things to refer to "interval".
> > > > > 
> > > > > 
> > > > > Ross
> > > > > 
> > > > > 
> > > > > 
> > > > > Index: ifstated.conf.5
> > > > > ===
> > > > > RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
> > > > > retrieving revision 1.13
> > > > > diff -u -p -r1.13 ifstated.conf.5
> > > > > --- ifstated.conf.5   18 Jun 2018 06:04:25 -  1.13
> > > > > +++ ifstated.conf.5   6 Dec 2018 11:12:44 -
> > > > > @@ -90,7 +90,8 @@ interfaces this equals the init state.
> > > > >  .Pp
> > > > >  In contrast to link state tests, external tests must be run 
> > > > > periodically to
> > > > >  evaluate their status.
> > > > > -The frequency at which an external test is run has to be set with the
> > > > > +The interval in seconds between invocations of an external test has 
> > > > > to
> > > > > +be set with the
> > > > >  .Ar every
> > > > >  keyword.
> > > > >  .Pp
> > > > > 
> > > > 
> > > > hi.
> > > > 
> > > > what about like this:
> > > > 
> > > > Index: ifstated.conf.5
> > > > ===
> > > > RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
> > > > retrieving revision 1.13
> > > > diff -u -r1.13 ifstated.conf.5
> > > > --- ifstated.conf.5 18 Jun 2018 06:04:25 -  1.13
> > > > +++ ifstated.conf.5 6 Dec 2018 17:08:25 -
> > > > @@ -90,7 +90,7 @@
> > > >  .Pp
> > > >  In contrast to link state tests, external tests must be run 
> > > > periodically to
> > > >  evaluate their status.
> > > > -The frequency at which an external test is run has to be set with the
> > > > +The frequency at which an external test is run is set, in seconds, 
> > > > with the
> > > >  .Ar every
> > > >  keyword.
> > > >  .Pp
> > > > 
> > > 
> > > That should be "period", right?
> > > 
> > >   -Otto
> > > 
> > 
> > hi otto. i don;t understand the question. what should be "period"?
> > jmc
> > 
> 
> frequency is a word used for occurences per time unit.
> period is the time beteen repeating events.
> 
> If you talk about the time beteen runs, you're talking about a period.
> 
>   -Otto
> 

oh.

from a technical (mathematical) point of view, i'm not totally sure.
however substituting "frequency" for "period" in the sentence above will
read very poorly. "frequency" was clear, but maybe that is because i'm
less aware of these differences.

the frequency at which something happens sounds ok to me in this sense.
i was really trying to preserve the original words - ross had complained
of being unable to come up with something that did so.

rereading your words, i feel i don;t really grasp this. can you give an
example? 

thanks,
jmc



Re: [Patch] Specify unit for 'every' in ifstated.conf.5

2018-12-06 Thread Otto Moerbeek
On Thu, Dec 06, 2018 at 05:22:36PM +, Jason McIntyre wrote:

> On Thu, Dec 06, 2018 at 06:17:16PM +0100, Otto Moerbeek wrote:
> > On Thu, Dec 06, 2018 at 05:09:23PM +, Jason McIntyre wrote:
> > 
> > > On Thu, Dec 06, 2018 at 10:21:47PM +1100, Ross L Richardson wrote:
> > > > 
> > > > The number is in seconds, but that's currently not specified.
> > > > 
> > > > Wording which preserved "frequency" but made sense with "seconds"
> > > > eluded me, so I changed things to refer to "interval".
> > > > 
> > > > 
> > > > Ross
> > > > 
> > > > 
> > > > 
> > > > Index: ifstated.conf.5
> > > > ===
> > > > RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
> > > > retrieving revision 1.13
> > > > diff -u -p -r1.13 ifstated.conf.5
> > > > --- ifstated.conf.5 18 Jun 2018 06:04:25 -  1.13
> > > > +++ ifstated.conf.5 6 Dec 2018 11:12:44 -
> > > > @@ -90,7 +90,8 @@ interfaces this equals the init state.
> > > >  .Pp
> > > >  In contrast to link state tests, external tests must be run 
> > > > periodically to
> > > >  evaluate their status.
> > > > -The frequency at which an external test is run has to be set with the
> > > > +The interval in seconds between invocations of an external test has to
> > > > +be set with the
> > > >  .Ar every
> > > >  keyword.
> > > >  .Pp
> > > > 
> > > 
> > > hi.
> > > 
> > > what about like this:
> > > 
> > > Index: ifstated.conf.5
> > > ===
> > > RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
> > > retrieving revision 1.13
> > > diff -u -r1.13 ifstated.conf.5
> > > --- ifstated.conf.5   18 Jun 2018 06:04:25 -  1.13
> > > +++ ifstated.conf.5   6 Dec 2018 17:08:25 -
> > > @@ -90,7 +90,7 @@
> > >  .Pp
> > >  In contrast to link state tests, external tests must be run periodically 
> > > to
> > >  evaluate their status.
> > > -The frequency at which an external test is run has to be set with the
> > > +The frequency at which an external test is run is set, in seconds, with 
> > > the
> > >  .Ar every
> > >  keyword.
> > >  .Pp
> > > 
> > 
> > That should be "period", right?
> > 
> > -Otto
> > 
> 
> hi otto. i don;t understand the question. what should be "period"?
> jmc
> 

frequency is a word used for occurences per time unit.
period is the time beteen repeating events.

If you talk about the time beteen runs, you're talking about a period.

-Otto



Re: [Patch] Specify unit for 'every' in ifstated.conf.5

2018-12-06 Thread Jason McIntyre
On Thu, Dec 06, 2018 at 06:17:16PM +0100, Otto Moerbeek wrote:
> On Thu, Dec 06, 2018 at 05:09:23PM +, Jason McIntyre wrote:
> 
> > On Thu, Dec 06, 2018 at 10:21:47PM +1100, Ross L Richardson wrote:
> > > 
> > > The number is in seconds, but that's currently not specified.
> > > 
> > > Wording which preserved "frequency" but made sense with "seconds"
> > > eluded me, so I changed things to refer to "interval".
> > > 
> > > 
> > > Ross
> > > 
> > > 
> > > 
> > > Index: ifstated.conf.5
> > > ===
> > > RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
> > > retrieving revision 1.13
> > > diff -u -p -r1.13 ifstated.conf.5
> > > --- ifstated.conf.5   18 Jun 2018 06:04:25 -  1.13
> > > +++ ifstated.conf.5   6 Dec 2018 11:12:44 -
> > > @@ -90,7 +90,8 @@ interfaces this equals the init state.
> > >  .Pp
> > >  In contrast to link state tests, external tests must be run periodically 
> > > to
> > >  evaluate their status.
> > > -The frequency at which an external test is run has to be set with the
> > > +The interval in seconds between invocations of an external test has to
> > > +be set with the
> > >  .Ar every
> > >  keyword.
> > >  .Pp
> > > 
> > 
> > hi.
> > 
> > what about like this:
> > 
> > Index: ifstated.conf.5
> > ===
> > RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
> > retrieving revision 1.13
> > diff -u -r1.13 ifstated.conf.5
> > --- ifstated.conf.5 18 Jun 2018 06:04:25 -  1.13
> > +++ ifstated.conf.5 6 Dec 2018 17:08:25 -
> > @@ -90,7 +90,7 @@
> >  .Pp
> >  In contrast to link state tests, external tests must be run periodically to
> >  evaluate their status.
> > -The frequency at which an external test is run has to be set with the
> > +The frequency at which an external test is run is set, in seconds, with the
> >  .Ar every
> >  keyword.
> >  .Pp
> > 
> 
> That should be "period", right?
> 
>   -Otto
> 

hi otto. i don;t understand the question. what should be "period"?
jmc



Re: [Patch] Specify unit for 'every' in ifstated.conf.5

2018-12-06 Thread Otto Moerbeek
On Thu, Dec 06, 2018 at 05:09:23PM +, Jason McIntyre wrote:

> On Thu, Dec 06, 2018 at 10:21:47PM +1100, Ross L Richardson wrote:
> > 
> > The number is in seconds, but that's currently not specified.
> > 
> > Wording which preserved "frequency" but made sense with "seconds"
> > eluded me, so I changed things to refer to "interval".
> > 
> > 
> > Ross
> > 
> > 
> > 
> > Index: ifstated.conf.5
> > ===
> > RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
> > retrieving revision 1.13
> > diff -u -p -r1.13 ifstated.conf.5
> > --- ifstated.conf.5 18 Jun 2018 06:04:25 -  1.13
> > +++ ifstated.conf.5 6 Dec 2018 11:12:44 -
> > @@ -90,7 +90,8 @@ interfaces this equals the init state.
> >  .Pp
> >  In contrast to link state tests, external tests must be run periodically to
> >  evaluate their status.
> > -The frequency at which an external test is run has to be set with the
> > +The interval in seconds between invocations of an external test has to
> > +be set with the
> >  .Ar every
> >  keyword.
> >  .Pp
> > 
> 
> hi.
> 
> what about like this:
> 
> Index: ifstated.conf.5
> ===
> RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
> retrieving revision 1.13
> diff -u -r1.13 ifstated.conf.5
> --- ifstated.conf.5   18 Jun 2018 06:04:25 -  1.13
> +++ ifstated.conf.5   6 Dec 2018 17:08:25 -
> @@ -90,7 +90,7 @@
>  .Pp
>  In contrast to link state tests, external tests must be run periodically to
>  evaluate their status.
> -The frequency at which an external test is run has to be set with the
> +The frequency at which an external test is run is set, in seconds, with the
>  .Ar every
>  keyword.
>  .Pp
> 

That should be "period", right?

-Otto



Re: [Patch] Specify unit for 'every' in ifstated.conf.5

2018-12-06 Thread Jason McIntyre
On Thu, Dec 06, 2018 at 10:21:47PM +1100, Ross L Richardson wrote:
> 
> The number is in seconds, but that's currently not specified.
> 
> Wording which preserved "frequency" but made sense with "seconds"
> eluded me, so I changed things to refer to "interval".
> 
> 
> Ross
> 
> 
> 
> Index: ifstated.conf.5
> ===
> RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
> retrieving revision 1.13
> diff -u -p -r1.13 ifstated.conf.5
> --- ifstated.conf.5   18 Jun 2018 06:04:25 -  1.13
> +++ ifstated.conf.5   6 Dec 2018 11:12:44 -
> @@ -90,7 +90,8 @@ interfaces this equals the init state.
>  .Pp
>  In contrast to link state tests, external tests must be run periodically to
>  evaluate their status.
> -The frequency at which an external test is run has to be set with the
> +The interval in seconds between invocations of an external test has to
> +be set with the
>  .Ar every
>  keyword.
>  .Pp
> 

hi.

what about like this:

Index: ifstated.conf.5
===
RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
retrieving revision 1.13
diff -u -r1.13 ifstated.conf.5
--- ifstated.conf.5 18 Jun 2018 06:04:25 -  1.13
+++ ifstated.conf.5 6 Dec 2018 17:08:25 -
@@ -90,7 +90,7 @@
 .Pp
 In contrast to link state tests, external tests must be run periodically to
 evaluate their status.
-The frequency at which an external test is run has to be set with the
+The frequency at which an external test is run is set, in seconds, with the
 .Ar every
 keyword.
 .Pp



Re: be more strict when parsing netmasks for IPv6

2018-12-06 Thread Florian Obser
On Thu, Dec 06, 2018 at 03:24:52PM +0100, Claudio Jeker wrote:
> On Wed, Dec 05, 2018 at 11:53:48PM +0100, Remi Locherer wrote:
> > On Wed, Dec 05, 2018 at 09:22:22AM +0100, Claudio Jeker wrote:
> > > When parsing a network mask into prefixlen be more paranoid and make sure
> > > no value bigger then 128 is returned. In general this should never happen
> > > but if it does the result can be bad.
> > > 
> > > This is for bgpd but there are other users in the tree. I will adjust them
> > > if we dicide to go this way.
> > > -- 
> > > :wq Claudio
> > > 
> > 
> > makes sense to me.
> > 
> > OK remi@
> > 
> 
> Here the same diff against other users of mask2prefixlen6().
> IIRC there are some other users with different function names which I need
> to hunt down (unless someone else wants to do that job).

rad(8) and slaacd(8) use

int
in6_mask2prefixlen(struct in6_addr *in6)
{
u_char *nam = (u_char *)in6;
int byte, bit, plen = 0, size = sizeof(struct in6_addr);

for (byte = 0; byte < size; byte++, plen += 8)
if (nam[byte] != 0xff)
break;
if (byte == size)
return (plen);
for (bit = 7; bit != 0; bit--, plen++)
if (!(nam[byte] & (1 << bit)))
break;
for (; bit != 0; bit--)
if (nam[byte] & (1 << bit))
return (0);
byte++;
for (; byte < size; byte++)
if (nam[byte])
return (0);
return (plen);
}

which came from ifconfig where it's called prefix() and is actually AF
independent.

Note that it operates on in6_addr not struct sockaddr_in6...

rad(8) could be easily adapted since it's operating on struct sockaddr_in6
anyway. slaacd(8) is a bit more difficult since it passes struct
in6_addr around.

I'm not sure it's worth the effort though. Its not like one version is
massively better than the other. Having only one version is an
improvement though...

-- 
I'm not entirely sure you are real.



Re: relayd and TLS client cert verification

2018-12-06 Thread Rivo Nurges
Hi!

I have planned to do it myself for quite long time but never got around
doing it. In my testing it works great.

I have patch on top of this which allows to pass remote certificate
and/or parts of it to backend hosts via http headers.

Rivo


On Thu, 2018-12-06 at 05:17 +, Ashe Connor wrote:
> It's been a week or so, so bumping.  (Benno was kind enough to offer
> a
> review but was time-poor recently.)
> 
> Here's a diff for the manpage too.
> 
> Ashe
> 
> 
> Index: usr.sbin/relayd/relayd.conf.5
> ===
> RCS file:
> /home/kivikakk/cvsync/root/src/usr.sbin/relayd/relayd.conf.5,v
> retrieving revision 1.187
> retrieving revision 1.187.6.1
> diff -u -p -r1.187 -r1.187.6.1
> --- usr.sbin/relayd/relayd.conf.5 6 Aug 2018 18:26:29 -   1.187
> +++ usr.sbin/relayd/relayd.conf.5 30 Nov 2018 21:10:06 -  
> 1.187.6.1
> @@ -939,6 +939,10 @@ will be used (strong crypto cipher suite
>  See the CIPHERS section of
>  .Xr openssl 1
>  for information about SSL/TLS cipher suites and preference lists.
> +.It Ic client ca Ar path
> +Require TLS client certificates whose authenticity can be verified
> +against the CA certificate(s) in the specified file in order to
> +proceed beyond the TLS handshake.
>  .It Ic client-renegotiation
>  Allow client-initiated renegotiation.
>  To mitigate a potential DoS risk,
> 



Re: be more strict when parsing netmasks for IPv6

2018-12-06 Thread Claudio Jeker
On Wed, Dec 05, 2018 at 11:53:48PM +0100, Remi Locherer wrote:
> On Wed, Dec 05, 2018 at 09:22:22AM +0100, Claudio Jeker wrote:
> > When parsing a network mask into prefixlen be more paranoid and make sure
> > no value bigger then 128 is returned. In general this should never happen
> > but if it does the result can be bad.
> > 
> > This is for bgpd but there are other users in the tree. I will adjust them
> > if we dicide to go this way.
> > -- 
> > :wq Claudio
> > 
> 
> makes sense to me.
> 
> OK remi@
> 

Here the same diff against other users of mask2prefixlen6().
IIRC there are some other users with different function names which I need
to hunt down (unless someone else wants to do that job).

Iked is a bit special since it returns 0 for non-contiguous netmasks.
Wonder if we should put a fatalx() there too - like in the other daemons.

-- 
:wq Claudio

Index: sbin/iked/util.c
===
RCS file: /cvs/src/sbin/iked/util.c,v
retrieving revision 1.36
diff -u -p -r1.36 util.c
--- sbin/iked/util.c22 Jun 2018 13:20:08 -  1.36
+++ sbin/iked/util.c6 Dec 2018 12:51:14 -
@@ -553,7 +553,8 @@ uint8_t
 mask2prefixlen6(struct sockaddr *sa)
 {
struct sockaddr_in6 *sa_in6 = (struct sockaddr_in6 *)sa;
-   uint8_t  l = 0, *ap, *ep;
+   uint8_t *ap, *ep;
+   unsigned int l = 0;
 
/*
 * sin6_len is the size of the sockaddr so substract the offset of
@@ -569,32 +570,35 @@ mask2prefixlen6(struct sockaddr *sa)
break;
case 0xfe:
l += 7;
-   return (l);
+   goto done;
case 0xfc:
l += 6;
-   return (l);
+   goto done;
case 0xf8:
l += 5;
-   return (l);
+   goto done;
case 0xf0:
l += 4;
-   return (l);
+   goto done;
case 0xe0:
l += 3;
-   return (l);
+   goto done;
case 0xc0:
l += 2;
-   return (l);
+   goto done;
case 0x80:
l += 1;
-   return (l);
+   goto done;
case 0x00:
-   return (l);
+   goto done;
default:
return (0);
}
}
 
+done:
+   if (l > sizeof(struct in6_addr) * 8)
+   fatalx("%s: prefixlen %d out of bound", __func__, l);
return (l);
 }
 
Index: usr.sbin/eigrpd/util.c
===
RCS file: /cvs/src/usr.sbin/eigrpd/util.c,v
retrieving revision 1.9
diff -u -p -r1.9 util.c
--- usr.sbin/eigrpd/util.c  2 Sep 2016 16:36:33 -   1.9
+++ usr.sbin/eigrpd/util.c  6 Dec 2018 14:18:32 -
@@ -38,7 +38,8 @@ mask2prefixlen(in_addr_t ina)
 uint8_t
 mask2prefixlen6(struct sockaddr_in6 *sa_in6)
 {
-   uint8_t l = 0, *ap, *ep;
+   unsigned int l = 0;
+   uint8_t *ap, *ep;
 
/*
 * sin6_len is the size of the sockaddr so substract the offset of
@@ -54,32 +55,35 @@ mask2prefixlen6(struct sockaddr_in6 *sa_
break;
case 0xfe:
l += 7;
-   return (l);
+   goto done;
case 0xfc:
l += 6;
-   return (l);
+   goto done;
case 0xf8:
l += 5;
-   return (l);
+   goto done;
case 0xf0:
l += 4;
-   return (l);
+   goto done;
case 0xe0:
l += 3;
-   return (l);
+   goto done;
case 0xc0:
l += 2;
-   return (l);
+   goto done;
case 0x80:
l += 1;
-   return (l);
+   goto done;
case 0x00:
-   return (l);
+   goto done;
default:
fatalx("non contiguous inet6 netmask");
}
}
 
+done:
+   if (l > sizeof(struct in6_addr) * 8)
+   fatalx("inet6 prefixlen out of bound");
return (l);
 }
 
Index: usr.sbin/ldpd/util.c
===
RCS file: /cvs/src/usr.sbin/ldpd/util.c,v
retrieving revision 1.4
diff -u -p -r1.4 util.c
--- 

Re: sed(1) Add support for "-" file

2018-12-06 Thread Todd C. Miller
This has the side effect of closing stdin on EOF but I don't think
that is a problem.  OK millert@

 - todd



Remove no longer used M_ALIGN and MH_ALIGN

2018-12-06 Thread Claudio Jeker
All the references to the M_ALIGN and MH_ALIGN macros are gone.
Time to bring them behind the shed and free them.

OK?
-- 
:wq Claudio

Index: sys/sys/mbuf.h
===
RCS file: /cvs/src/sys/sys/mbuf.h,v
retrieving revision 1.240
diff -u -p -r1.240 mbuf.h
--- sys/sys/mbuf.h  12 Nov 2018 07:45:52 -  1.240
+++ sys/sys/mbuf.h  12 Nov 2018 07:47:42 -
@@ -345,17 +345,6 @@ u_int mextfree_register(void (*)(caddr_t
 } while (/* CONSTCOND */ 0)
 
 /*
- * Set the m_data pointer of a newly-allocated mbuf (m_get/MGET) to place
- * an object of the specified size at the end of the mbuf, longword aligned.
- */
-#defineM_ALIGN(m, len) m_align((m), (len))
-/*
- * As above, for mbufs allocated with m_gethdr/MGETHDR
- * or initialized by M_MOVE_PKTHDR.
- */
-#defineMH_ALIGN(m, len)m_align((m), (len))
-
-/*
  * Determine if an mbuf's data area is read-only. This is true for
  * non-cluster external storage and for clusters that are being
  * referenced by more than one mbuf.
Index: share/man/man9/mbuf.9
===
RCS file: /cvs/src/share/man/man9/mbuf.9,v
retrieving revision 1.117
diff -u -p -r1.117 mbuf.9
--- share/man/man9/mbuf.9   30 Nov 2018 11:58:47 -  1.117
+++ share/man/man9/mbuf.9   6 Dec 2018 08:12:41 -
@@ -61,8 +61,6 @@
 .Nm MCLGETI ,
 .Nm MEXTADD ,
 .Nm m_align ,
-.Nm M_ALIGN ,
-.Nm MH_ALIGN ,
 .Nm M_READONLY ,
 .Nm m_leadingspace ,
 .Nm m_trailingspace ,
@@ -133,8 +131,6 @@
 "void (*free)(caddr_t, u_int, void *)" "void *arg"
 .Ft void
 .Fn m_align "struct mbuf *m" "int len"
-.Fn M_ALIGN "struct mbuf *m" "int len"
-.Fn MH_ALIGN "struct mbuf *m" "int len"
 .Fn M_READONLY "struct mbuf *m"
 .Ft int
 .Fn m_leadingspace "struct mbuf *m"
@@ -757,25 +753,6 @@ pointer of the newly allocated mbuf
 to an object of the specified size
 .Fa len
 at the end of this mbuf data area, longword aligned.
-.It Fn M_ALIGN "struct mbuf *m" "int len"
-Set the
-.Fa m_data
-pointer of the newly allocated mbuf with
-.Fn m_get
-or
-.Fn MGET
-pointed to by
-.Fa m
-to an object of the specified size
-.Fa len
-at the end of the mbuf, longword aligned.
-.It Fn MH_ALIGN "m" "len"
-Same as
-.Fn M_ALIGN
-except it is for an mbuf allocated with
-.Fn m_gethdr
-or
-.Fn MGETHDR .
 .It Fn M_READONLY "struct mbuf *m"
 Check if the data of the mbuf pointed to by
 .Fa m



Re: find -not

2018-12-06 Thread Todd C. Miller
On Wed, 05 Dec 2018 22:52:13 -0500, "Ted Unangst" wrote:

> Seen in the wild. Alias for ! that's friendlier to the shell.

OK millert@

 - todd



Re: bgpd refactor aspath_match a bit

2018-12-06 Thread Claudio Jeker
On Wed, Nov 28, 2018 at 10:35:37AM +0100, Claudio Jeker wrote:
> On Tue, Nov 27, 2018 at 06:55:51PM +0100, Job Snijders wrote:
> > On Tue, Nov 27, 2018 at 06:23:53PM +0100, Claudio Jeker wrote:
> > > On Tue, Nov 27, 2018 at 04:21:53PM +0100, Job Snijders wrote:
> > > > On Fri, Nov 23, 2018 at 03:55:18PM +0100, Claudio Jeker wrote:
> > > > > For origin validation I chacked the source_as in struct rde_aspath
> > > > > this is not really the right place. It should be in struct aspath
> > > > > since that holds all the ASPATH related stuff. Change this, move
> > > > > aspath_match out of util.c back into rde_attr.c and adjust code to use
> > > > > the cached value also in match from any source-as XYZ rules.
> > > > > This last bit causes a minor behavioural change since the old code
> > > > > extracted the last non AS_SET asnumber. The new code follows the ROA
> > > > > RFC and returns the rightmost AS for AS_SEQUENCE, the local AS for
> > > > > empty paths and AS_NONE (which is 0) for everything else.
> > > > > So now 'match from any source-as 0' will return all paths that do not
> > > > > have a final AS_SEQUENCE segment.
> > > > > 
> > > > > The reason for this change is that I don't want to have two different
> > > > > behaviours for what we call source-as (the one in roa-set and the one 
> > > > > on a
> > > > > filter).
> > > > 
> > > > Something is off, it seems 'source-as 0' is matching anything that has
> > > > an AS_SET attribute set:
> > > > 
> > > > $ bgpctl show rib source-as 0 | head
> > > > flags: * = Valid, > = Selected, I = via IBGP, A = Announced,
> > > >S = Stale, E = Error
> > > > origin validation state: N = not-found, V = valid, ! = invalid
> > > > origin: i = IGP, e = EGP, ? = Incomplete
> > > > 
> > > > flags ovs destination  gateway  lpref   med aspath 
> > > > origin
> > > > I*> N 5.39.176.0/21192.147.168.1  100 0 2914 
> > > > 8530 { 198753 } ?
> > > > I*> N 5.101.110.0/24   192.147.168.1  100 0 2914 
> > > > 14061 { 46652 } i
> > > > I*> N 5.175.0.0/19 192.147.168.1  100 0 2914 
> > > > 1299 20773 { 8972 } i
> > > > I*> N 8.41.202.0/24192.147.168.1  100 0 2914 
> > > > 13789 30372 { 40179 } i
> > > > 
> > > > Similarly, this should return at least 5.39.176.0/21:
> > > > 
> > > > $ bgpctl show rib source-as 8530
> > > > flags: * = Valid, > = Selected, I = via IBGP, A = Announced,
> > > >S = Stale, E = Error
> > > > origin validation state: N = not-found, V = valid, ! = invalid
> > > > origin: i = IGP, e = EGP, ? = Incomplete
> > > > 
> > > > flags ovs destination  gateway  lpref   med aspath 
> > > > origin
> > > > I*> N 80.87.16.0/20192.147.168.1  100 0 2914 
> > > > 8530 ?
> > > > I*> N 87.236.128.0/21  192.147.168.1  100 0 2914 
> > > > 8530 ?
> > > > I*> N 88.151.152.0/21  192.147.168.1  100 0 2914 
> > > > 8530 ?
> > > > I*> N 89.38.120.0/21   192.147.168.1  100 0 2914 
> > > > 8530 i
> > > > I*> N 93.115.176.0/20  192.147.168.1  100 0 2914 
> > > > 8530 i
> > > > I*> N 185.52.144.0/22  192.147.168.1  100 0 2914 
> > > > 8530 ?
> > > > 
> > > 
> > > I implemented source-as the way ROA is defining it. So anything which ends
> > > with a AS_SET will return AS_NONE (which is 0). OpenBGPD has no way to
> > > have an AS_PATH that has a real 0 in the AS_PATH (those UPDATES are
> > > treated as withdraw). Because of this also the 5.39.176.0/21 is no longer
> > > matching in 'bgpctl show rib source-as 8530'.
> > 
> > I'm not sure it should behave that way.
> > 
> > 'bgpctl show rib source-as 8530' really ought to return prefixes like
> > 80.87.16.0/20 but also 5.39.176.0/21.
> 
> But isn't this different from other implementations? At least I would
> expect that the AS-path regex '8530$' would not match on the AS_SET path
> either. My issue is that we have 'source-as' in roa-set, origin-set and on
> filters in bgpd.conf plus the source-as used by bgpctl. Depending on
> context they behave differently. So if AS 8530 is in the roa-set
> and I do bgpctl show rib source-as 8530 the result will be different to
> what would match in the roa-set.
> We already had a lot of confusion about announce and that is why I decided
> to make them behave the same.
>  
> > > I'm a bit on the edge here about where to go and currently prefer to
> > > follow a RFC (which in this case is RFC6811).
> > > 
> > >  o  Route Origin ASN: The origin AS number derived from a Route as
> > > follows:
> > > 
> > > *  the rightmost AS in the final segment of the AS_PATH attribute
> > >  in the Route if that segment is of type AS_SEQUENCE, or
> > > 
> > > *  the BGP speaker's own AS number if that segment is of type
> > >AS_CONFED_SEQUENCE or AS_CONFED_SET or if the AS_PATH is empty,
> > 

[Patch] Specify unit for 'every' in ifstated.conf.5

2018-12-06 Thread Ross L Richardson


The number is in seconds, but that's currently not specified.

Wording which preserved "frequency" but made sense with "seconds"
eluded me, so I changed things to refer to "interval".


Ross



Index: ifstated.conf.5
===
RCS file: /cvs/src/usr.sbin/ifstated/ifstated.conf.5,v
retrieving revision 1.13
diff -u -p -r1.13 ifstated.conf.5
--- ifstated.conf.5 18 Jun 2018 06:04:25 -  1.13
+++ ifstated.conf.5 6 Dec 2018 11:12:44 -
@@ -90,7 +90,8 @@ interfaces this equals the init state.
 .Pp
 In contrast to link state tests, external tests must be run periodically to
 evaluate their status.
-The frequency at which an external test is run has to be set with the
+The interval in seconds between invocations of an external test has to
+be set with the
 .Ar every
 keyword.
 .Pp



malloc: simplify "not my pool" lock dance

2018-12-06 Thread Otto Moerbeek
Hi,

This simpifies the lock dance when a free is done for a pointer not in
"my pool". Should reduce lock contention.

Please review & test, especially with multithread heavy apps.

-Otto

Index: malloc.c
===
RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v
retrieving revision 1.255
diff -u -p -r1.255 malloc.c
--- malloc.c27 Nov 2018 17:29:55 -  1.255
+++ malloc.c6 Dec 2018 10:26:56 -
@@ -1309,14 +1309,14 @@ findpool(void *p, struct dir_info *argpo
 }
 
 static void
-ofree(struct dir_info *argpool, void *p, int clear, int check, size_t argsz)
+ofree(struct dir_info **argpool, void *p, int clear, int check, size_t argsz)
 {
struct region_info *r;
struct dir_info *pool;
char *saved_function;
size_t sz;
 
-   r = findpool(p, argpool, , _function);
+   r = findpool(p, *argpool, , _function);
 
REALSIZE(sz, r);
if (check) {
@@ -1405,12 +1405,9 @@ ofree(struct dir_info *argpool, void *p,
}
}
 
-   if (argpool != pool) {
-   pool->active--;
+   if (*argpool != pool) {
pool->func = saved_function;
-   _MALLOC_UNLOCK(pool->mutex);
-   _MALLOC_LOCK(argpool->mutex);
-   argpool->active++;
+   *argpool = pool;
}
 }
 
@@ -1433,7 +1430,7 @@ free(void *ptr)
malloc_recurse(d);
return;
}
-   ofree(d, ptr, 0, 0, 0);
+   ofree(, ptr, 0, 0, 0);
d->active--;
_MALLOC_UNLOCK(d->mutex);
errno = saved_errno;
@@ -1471,7 +1468,7 @@ freezero(void *ptr, size_t sz)
malloc_recurse(d);
return;
}
-   ofree(d, ptr, 1, 1, sz);
+   ofree(, ptr, 1, 1, sz);
d->active--;
_MALLOC_UNLOCK(d->mutex);
errno = saved_errno;
@@ -1479,7 +1476,7 @@ freezero(void *ptr, size_t sz)
 DEF_WEAK(freezero);
 
 static void *
-orealloc(struct dir_info *argpool, void *p, size_t newsz, void *f)
+orealloc(struct dir_info **argpool, void *p, size_t newsz, void *f)
 {
struct region_info *r;
struct dir_info *pool;
@@ -1490,14 +1487,14 @@ orealloc(struct dir_info *argpool, void 
uint32_t chunknum;
 
if (p == NULL)
-   return omalloc(argpool, newsz, 0, f);
+   return omalloc(*argpool, newsz, 0, f);
 
if (newsz >= SIZE_MAX - mopts.malloc_guard - MALLOC_PAGESIZE) {
errno = ENOMEM;
return  NULL;
}
 
-   r = findpool(p, argpool, , _function);
+   r = findpool(p, *argpool, , _function);
 
REALSIZE(oldsz, r);
if (mopts.chunk_canaries && oldsz <= MALLOC_MAXCHUNK) {
@@ -1631,7 +1628,7 @@ gotit:
}
if (newsz != 0 && oldsz != 0)
memcpy(q, p, oldsz < newsz ? oldsz : newsz);
-   ofree(pool, p, 0, 0, 0);
+   ofree(, p, 0, 0, 0);
ret = q;
} else {
/* oldsz == newsz */
@@ -1641,12 +1638,9 @@ gotit:
ret = p;
}
 done:
-   if (argpool != pool) {
-   pool->active--;
+   if (*argpool != pool) {
pool->func = saved_function;
-   _MALLOC_UNLOCK(pool->mutex);
-   _MALLOC_LOCK(argpool->mutex);
-   argpool->active++;
+   *argpool = pool;
}
return ret;
 }
@@ -1669,7 +1663,7 @@ realloc(void *ptr, size_t size)
malloc_recurse(d);
return NULL;
}
-   r = orealloc(d, ptr, size, CALLER);
+   r = orealloc(, ptr, size, CALLER);
 
d->active--;
_MALLOC_UNLOCK(d->mutex);
@@ -1730,7 +1724,7 @@ calloc(size_t nmemb, size_t size)
 /*DEF_STRONG(calloc);*/
 
 static void *
-orecallocarray(struct dir_info *argpool, void *p, size_t oldsize,
+orecallocarray(struct dir_info **argpool, void *p, size_t oldsize,
 size_t newsize, void *f)
 {
struct region_info *r;
@@ -1740,12 +1734,12 @@ orecallocarray(struct dir_info *argpool,
size_t sz;
 
if (p == NULL)
-   return omalloc(argpool, newsize, 1, f);
+   return omalloc(*argpool, newsize, 1, f);
 
if (oldsize == newsize)
return p;
 
-   r = findpool(p, argpool, , _function);
+   r = findpool(p, *argpool, , _function);
 
REALSIZE(sz, r);
if (sz <= MALLOC_MAXCHUNK) {
@@ -1772,15 +1766,12 @@ orecallocarray(struct dir_info *argpool,
} else
memcpy(newptr, p, newsize);
 
-   ofree(pool, p, 1, 0, oldsize);
+   ofree(, p, 1, 0, oldsize);
 
 done:
-   if (argpool != pool) {
-   pool->active--;
+   if (*argpool != pool) {
pool->func = saved_function;
-   _MALLOC_UNLOCK(pool->mutex);
-   _MALLOC_LOCK(argpool->mutex);
-   argpool->active++;
+   

nsd 4.1.26

2018-12-06 Thread Florian Obser
tests, OKs?

diff --git Makefile.in Makefile.in
index 16d193f766d..fbfc44be33b 100644
--- Makefile.in
+++ Makefile.in
@@ -29,6 +29,8 @@ nsdconfigfile = @nsd_conf_file@
 zonesdir = @zonesdir@
 chrootdir= @chrootdir@
 user = @user@
+DNSTAP_SRC=@DNSTAP_SRC@
+DNSTAP_OBJ=@DNSTAP_OBJ@
 
 # override $U variable which is used by autotools for deansification (for
 # K C compilers), but causes problems if $U is defined in the env).
@@ -47,6 +49,7 @@ INSTALL_DATA  = $(INSTALL) -m 644
 
 YACC   = @YACC@
 LEX= @LEX@
+PROTOC_C   = @PROTOC_C@
 
 COMPILE= $(CC) $(CPPFLAGS) $(CFLAGS)
 LINK   = $(CC) $(CFLAGS) $(LDFLAGS)
@@ -72,7 +75,7 @@ TARGETS=nsd nsd-checkconf nsd-checkzone nsd-control 
nsd.conf.sample nsd-control-
 MANUALS=nsd.8 nsd-checkconf.8 nsd-checkzone.8 nsd-control.8 nsd.conf.5
 
 COMMON_OBJ=answer.o axfr.o buffer.o configlexer.o configparser.o dname.o dns.o 
edns.o iterated_hash.o lookup3.o namedb.o nsec3.o options.o packet.o query.o 
rbtree.o radtree.o rdata.o region-allocator.o rrl.o tsig.o tsig-openssl.o udb.o 
udbradtree.o udbzone.o util.o
-XFRD_OBJ=xfrd-disk.o xfrd-notify.o xfrd-tcp.o xfrd.o remote.o
+XFRD_OBJ=xfrd-disk.o xfrd-notify.o xfrd-tcp.o xfrd.o remote.o $(DNSTAP_OBJ)
 NSD_OBJ=$(COMMON_OBJ) $(XFRD_OBJ) difffile.o ipc.o mini_event.o netio.o nsd.o 
server.o dbaccess.o dbcreate.o zlexer.o zonec.o zparser.o
 ALL_OBJ=$(NSD_OBJ) nsd-checkconf.o nsd-checkzone.o nsd-control.o nsd-mem.o
 NSD_CHECKCONF_OBJ=$(COMMON_OBJ) nsd-checkconf.o
@@ -306,6 +309,22 @@ configlexer.c: $(srcdir)/configlexer.lex
 configparser.c configparser.h: $(srcdir)/configparser.y
$(YACC) -d -o configparser.c $(srcdir)/configparser.y
 
+# dnstap
+dnstap.o:  $(srcdir)/dnstap/dnstap.c config.h \
+   dnstap/dnstap.pb-c.c dnstap/dnstap.pb-c.h $(srcdir)/dnstap/dnstap.h \
+   $(srcdir)/util.h $(srcdir)/options.h $(srcdir)/rbtree.h \
+   $(srcdir)/region-allocator.h
+dnstap.pb-c.o: dnstap/dnstap.pb-c.c dnstap/dnstap.pb-c.h
+dnstap_collector.o:$(srcdir)/dnstap/dnstap_collector.c config.h \
+   $(srcdir)/dnstap/dnstap.h $(srcdir)/dnstap/dnstap_collector.h \
+   $(srcdir)/util.h $(srcdir)/nsd.h $(srcdir)/region-allocator.h \
+   $(srcdir)/buffer.h $(srcdir)/namedb.h $(srcdir)/dname.h \
+   $(srcdir)/dns.h $(srcdir)/radtree.h $(srcdir)/rbtree.h \
+   $(srcdir)/options.h
+dnstap/dnstap.pb-c.c dnstap/dnstap.pb-c.h: $(srcdir)/dnstap/dnstap.proto
+   @-if test ! -d dnstap; then $(INSTALL) -d dnstap; fi
+   $(PROTOC_C) --c_out=. --proto_path=$(srcdir) 
$(srcdir)/dnstap/dnstap.proto
+
 # autoconf rules
 config.h.in:   configure.ac
autoheader
diff --git config.h.in config.h.in
index 4d47f603062..67296ca99b7 100644
--- config.h.in
+++ config.h.in
@@ -22,6 +22,9 @@
 /* Pathname to the NSD database */
 #undef DBFILE
 
+/* default dnstap socket path */
+#undef DNSTAP_SOCKET_PATH
+
 /* Define to the default maximum message length with EDNS. */
 #undef EDNS_MAX_MESSAGE_LEN
 
@@ -510,6 +513,9 @@
 /* the user name to drop privileges to */
 #undef USER
 
+/* Define to 1 to enable dnstap support */
+#undef USE_DNSTAP
+
 /* Define if you want to use internal select based events */
 #undef USE_MINI_EVENT
 
diff --git configlexer.lex configlexer.lex
index 7fd4f17363f..ead1b96fa80 100644
--- configlexer.lex
+++ configlexer.lex
@@ -117,9 +117,8 @@ static void config_start_include_glob(const char* filename)
 #ifdef GLOB_ERR
 | GLOB_ERR
 #endif
-#ifdef GLOB_NOSORT
-| GLOB_NOSORT
-#endif
+/* do not set GLOB_NOSORT so the results are sorted
+   and in a predictable order. */
 #ifdef GLOB_BRACE
 | GLOB_BRACE
 #endif
@@ -270,6 +269,15 @@ rrl-whitelist-ratelimit{COLON} { LEXOUT(("v(%s) ", 
yytext)); return VAR_RRL_WHIT
 rrl-whitelist{COLON}   { LEXOUT(("v(%s) ", yytext)); return VAR_RRL_WHITELIST;}
 zonefiles-check{COLON} { LEXOUT(("v(%s) ", yytext)); return 
VAR_ZONEFILES_CHECK;}
 zonefiles-write{COLON} { LEXOUT(("v(%s) ", yytext)); return 
VAR_ZONEFILES_WRITE;}
+dnstap{COLON}  { LEXOUT(("v(%s) ", yytext)); return VAR_DNSTAP;}
+dnstap-enable{COLON}   { LEXOUT(("v(%s) ", yytext)); return VAR_DNSTAP_ENABLE;}
+dnstap-socket-path{COLON}  { LEXOUT(("v(%s) ", yytext)); return 
VAR_DNSTAP_SOCKET_PATH; }
+dnstap-send-identity{COLON}{ LEXOUT(("v(%s) ", yytext)); return 
VAR_DNSTAP_SEND_IDENTITY; }
+dnstap-send-version{COLON} { LEXOUT(("v(%s) ", yytext)); return 
VAR_DNSTAP_SEND_VERSION; }
+dnstap-identity{COLON} { LEXOUT(("v(%s) ", yytext)); return 
VAR_DNSTAP_IDENTITY; }
+dnstap-version{COLON}  { LEXOUT(("v(%s) ", yytext)); return 
VAR_DNSTAP_VERSION; }
+dnstap-log-auth-query-messages{COLON}  { LEXOUT(("v(%s) ", yytext)); return 
VAR_DNSTAP_LOG_AUTH_QUERY_MESSAGES; }
+dnstap-log-auth-response-messages{COLON}   { LEXOUT(("v(%s) ", yytext)); 
return VAR_DNSTAP_LOG_AUTH_RESPONSE_MESSAGES; }
 log-time-ascii{COLON}  { 

change reboot behaviour in vmd

2018-12-06 Thread Claudio Jeker
So doing autoinstall with -B net is great but one thing I was missing is
changing the reboot behaviour of vmd to exit at a guest reboot.
I came up with this minimal diff that does the trick for me. Now maybe it
would be better to have a proper flag for this instead of overloading 
vmc_bootdevice with it.

What is the preferred way of doing this?
-- 
:wq Claudio

Index: vmd.c
===
RCS file: /cvs/src/usr.sbin/vmd/vmd.c,v
retrieving revision 1.107
diff -u -p -r1.107 vmd.c
--- vmd.c   4 Dec 2018 08:15:09 -   1.107
+++ vmd.c   4 Dec 2018 09:11:51 -
@@ -452,7 +452,8 @@ vmd_dispatch_vmm(int fd, struct privsep_
__func__, vmr.vmr_id);
break;
}
-   if (vmr.vmr_result != EAGAIN) {
+   if (vmr.vmr_result != EAGAIN ||
+   vm->vm_params.vmc_bootdevice) {
if (vm->vm_from_config)
vm_stop(vm, 0, __func__);
else