CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Aug 21 05:28:41 UTC 2020 Modified Files: src/usr.bin/make: lst.c Log Message: make(1): remove unnecessary type duplication in list implementation Having both the interface types Lst/LstNode and the implementation types List/ListNode does not make the code clearer, it is an unnecessary abstraction. Eliminating the implementation type means that some of the local variables can be merged, which will make the code simpler than before. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/lst.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/lst.c diff -u src/usr.bin/make/lst.c:1.12 src/usr.bin/make/lst.c:1.13 --- src/usr.bin/make/lst.c:1.12 Fri Aug 21 05:19:48 2020 +++ src/usr.bin/make/lst.c Fri Aug 21 05:28:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lst.c,v 1.12 2020/08/21 05:19:48 rillig Exp $ */ +/* $NetBSD: lst.c,v 1.13 2020/08/21 05:28:41 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -38,15 +38,15 @@ #include "make_malloc.h" #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: lst.c,v 1.12 2020/08/21 05:19:48 rillig Exp $"; +static char rcsid[] = "$NetBSD: lst.c,v 1.13 2020/08/21 05:28:41 rillig Exp $"; #else #include #ifndef lint -__RCSID("$NetBSD: lst.c,v 1.12 2020/08/21 05:19:48 rillig Exp $"); +__RCSID("$NetBSD: lst.c,v 1.13 2020/08/21 05:28:41 rillig Exp $"); #endif /* not lint */ #endif -typedef struct ListNode { +struct ListNode { struct ListNode *prevPtr; /* previous element in list */ struct ListNode *nextPtr; /* next in list */ uint8_t useCount; /* Count of functions using the node. @@ -54,25 +54,25 @@ typedef struct ListNode { * goes to 0 */ Boolean deleted; /* List node should be removed when done */ void *datum; /* datum associated with this element */ -} *ListNode; +}; typedef enum { Head, Middle, Tail, Unknown } Where; -typedef struct List { -ListNode firstPtr; /* first node in list */ -ListNode lastPtr; /* last node in list */ +struct List { +LstNode firstPtr; /* first node in list */ +LstNode lastPtr; /* last node in list */ /* * fields for sequential access */ Where atEnd; /* Where in the list the last access was */ Boolean isOpen; /* true if list has been Lst_Open'ed */ -ListNode curPtr; /* current node, if open. NULL if +LstNode curPtr; /* current node, if open. NULL if * *just* opened */ -ListNode prevPtr; /* Previous node, if open. Used by +LstNode prevPtr; /* Previous node, if open. Used by * Lst_Remove */ -} *List; +}; /* * LstValid -- @@ -97,7 +97,7 @@ LstNodeValid(LstNode ln) static LstNode LstNodeNew(void *datum) { -ListNode ln = bmake_malloc(sizeof *ln); +LstNode ln = bmake_malloc(sizeof *ln); /* prevPtr will be initialized by the calling code. */ /* nextPtr will be initialized by the calling code. */ ln->useCount = 0; @@ -120,9 +120,7 @@ LstIsEmpty(Lst l) Lst Lst_Init(void) { -List nList; - -nList = bmake_malloc(sizeof *nList); +Lst nList = bmake_malloc(sizeof *nList); nList->firstPtr = NULL; nList->lastPtr = NULL; @@ -153,8 +151,8 @@ Lst Lst_Duplicate(Lst l, DuplicateProc *copyProc) { Lst nl; -ListNode ln; -List list = l; +LstNode ln; +Lst list = l; if (!LstValid(l)) { return NULL; @@ -199,8 +197,8 @@ Lst_Duplicate(Lst l, DuplicateProc *copy void Lst_Destroy(Lst list, FreeProc *freeProc) { -ListNode ln; -ListNode tln = NULL; +LstNode ln; +LstNode tln = NULL; if (list == NULL) return; @@ -256,9 +254,9 @@ Lst_Destroy(Lst list, FreeProc *freeProc ReturnStatus Lst_InsertBefore(Lst l, LstNode ln, void *d) { -ListNode nLNode; /* new lnode for d */ -ListNode lNode = ln; -List list = l; +LstNode nLNode; /* new lnode for d */ +LstNode lNode = ln; +Lst list = l; /* @@ -318,9 +316,9 @@ Lst_InsertBefore(Lst l, LstNode ln, void ReturnStatus Lst_InsertAfter(Lst l, LstNode ln, void *d) { -List list; -ListNode lNode; -ListNode nLNode; +Lst list; +LstNode lNode; +LstNode nLNode; if (LstValid(l) && (ln == NULL && LstIsEmpty(l))) { goto ok; @@ -410,8 +408,8 @@ Lst_AtEnd(Lst l, void *d) void Lst_RemoveS(Lst l, LstNode ln) { -List list = l; -ListNode lNode = ln; +Lst list = l; +LstNode lNode = ln; assert(LstValid(l)); assert(LstNodeValid(ln)); @@ -629,7 +627,7 @@ LstNode Lst_FindFrom(Lst l, LstNode ln, const void *d, int (*cProc)(const void *, const void *)) { -ListNode tln; +LstNode tln; if (!LstValid(l) || LstIsEmpty(l) || !LstNodeValid(ln)) { return NULL; @@ -652,8 +650,8 @@ Lst_FindFrom(Lst l, LstNode ln, const vo LstNode Lst_Member(Lst l, void *d) { -List list = l; -ListNode lNode; +Lst
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Aug 21 05:19:48 UTC 2020 Modified Files: src/usr.bin/make: lst.c Log Message: make(1): extract creation of a list node into a separate function To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/lst.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/lst.c diff -u src/usr.bin/make/lst.c:1.11 src/usr.bin/make/lst.c:1.12 --- src/usr.bin/make/lst.c:1.11 Fri Aug 21 04:57:56 2020 +++ src/usr.bin/make/lst.c Fri Aug 21 05:19:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lst.c,v 1.11 2020/08/21 04:57:56 rillig Exp $ */ +/* $NetBSD: lst.c,v 1.12 2020/08/21 05:19:48 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -38,11 +38,11 @@ #include "make_malloc.h" #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: lst.c,v 1.11 2020/08/21 04:57:56 rillig Exp $"; +static char rcsid[] = "$NetBSD: lst.c,v 1.12 2020/08/21 05:19:48 rillig Exp $"; #else #include #ifndef lint -__RCSID("$NetBSD: lst.c,v 1.11 2020/08/21 04:57:56 rillig Exp $"); +__RCSID("$NetBSD: lst.c,v 1.12 2020/08/21 05:19:48 rillig Exp $"); #endif /* not lint */ #endif @@ -94,6 +94,18 @@ LstNodeValid(LstNode ln) return ln != NULL; } +static LstNode +LstNodeNew(void *datum) +{ +ListNode ln = bmake_malloc(sizeof *ln); +/* prevPtr will be initialized by the calling code. */ +/* nextPtr will be initialized by the calling code. */ +ln->useCount = 0; +ln->deleted = FALSE; +ln->datum = datum; +return ln; +} + /* * LstIsEmpty (l) -- * TRUE if the list l is empty. @@ -260,11 +272,7 @@ Lst_InsertBefore(Lst l, LstNode ln, void } ok: -nLNode = bmake_malloc(sizeof *nLNode); - -nLNode->datum = d; -nLNode->useCount = 0; -nLNode->deleted = FALSE; +nLNode = LstNodeNew(d); if (ln == NULL) { nLNode->prevPtr = nLNode->nextPtr = NULL; @@ -326,10 +334,7 @@ Lst_InsertAfter(Lst l, LstNode ln, void list = l; lNode = ln; -nLNode = bmake_malloc(sizeof *nLNode); -nLNode->datum = d; -nLNode->useCount = 0; -nLNode->deleted = FALSE; +nLNode = LstNodeNew(d); if (lNode == NULL) { nLNode->nextPtr = nLNode->prevPtr = NULL; @@ -836,16 +841,13 @@ Lst_Concat(Lst l1, Lst l2, int flags) ln != NULL; ln = ln->nextPtr) { - nln = bmake_malloc(sizeof *nln); - nln->datum = ln->datum; + nln = LstNodeNew(ln->datum); if (last != NULL) { last->nextPtr = nln; } else { list1->firstPtr = nln; } nln->prevPtr = last; - nln->useCount = 0; - nln->deleted = FALSE; last = nln; }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Aug 21 04:57:56 UTC 2020 Modified Files: src/usr.bin/make: lst.c Log Message: make(1): remove unnecessary macro PAlloc The ptype parameter was never used, which made it redundant. The remaining text is so simple that it's not worth having a macro for this purpose. This makes it easier to read the code since the previously implicit variable assignment is now clearly visible. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/lst.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/lst.c diff -u src/usr.bin/make/lst.c:1.10 src/usr.bin/make/lst.c:1.11 --- src/usr.bin/make/lst.c:1.10 Fri Aug 21 04:42:02 2020 +++ src/usr.bin/make/lst.c Fri Aug 21 04:57:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lst.c,v 1.10 2020/08/21 04:42:02 rillig Exp $ */ +/* $NetBSD: lst.c,v 1.11 2020/08/21 04:57:56 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -38,11 +38,11 @@ #include "make_malloc.h" #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: lst.c,v 1.10 2020/08/21 04:42:02 rillig Exp $"; +static char rcsid[] = "$NetBSD: lst.c,v 1.11 2020/08/21 04:57:56 rillig Exp $"; #else #include #ifndef lint -__RCSID("$NetBSD: lst.c,v 1.10 2020/08/21 04:42:02 rillig Exp $"); +__RCSID("$NetBSD: lst.c,v 1.11 2020/08/21 04:57:56 rillig Exp $"); #endif /* not lint */ #endif @@ -75,13 +75,6 @@ typedef struct List { } *List; /* - * PAlloc (var, ptype) -- - * Allocate a pointer-typedef structure 'ptype' into the variable 'var' - */ -#define PAlloc(var, ptype) \ -var = (ptype) bmake_malloc(sizeof *(var)) - -/* * LstValid -- * Return TRUE if the list is valid */ @@ -117,7 +110,7 @@ Lst_Init(void) { List nList; -PAlloc (nList, List); +nList = bmake_malloc(sizeof *nList); nList->firstPtr = NULL; nList->lastPtr = NULL; @@ -267,7 +260,7 @@ Lst_InsertBefore(Lst l, LstNode ln, void } ok: -PAlloc (nLNode, ListNode); +nLNode = bmake_malloc(sizeof *nLNode); nLNode->datum = d; nLNode->useCount = 0; @@ -333,7 +326,7 @@ Lst_InsertAfter(Lst l, LstNode ln, void list = l; lNode = ln; -PAlloc (nLNode, ListNode); +nLNode = bmake_malloc(sizeof *nLNode); nLNode->datum = d; nLNode->useCount = 0; nLNode->deleted = FALSE; @@ -843,7 +836,7 @@ Lst_Concat(Lst l1, Lst l2, int flags) ln != NULL; ln = ln->nextPtr) { - PAlloc (nln, ListNode); + nln = bmake_malloc(sizeof *nln); nln->datum = ln->datum; if (last != NULL) { last->nextPtr = nln;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Aug 21 04:42:03 UTC 2020 Modified Files: src/usr.bin/make: arch.c dir.c lst.c lst.h make.c suff.c targ.c Log Message: make(1): use stricter list API for sequential access In several places, it just doesn't make sense to have a null pointer when a list is expected. In the existing unit tests, the list passed to Lst_Open is always valid, but that's not a guarantee for real-world usage. Therefore, Lst_Open has been left for now, and Lst_OpenS is only the preferred alternative to it. To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/usr.bin/make/arch.c cvs rdiff -u -r1.95 -r1.96 src/usr.bin/make/dir.c cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/lst.c cvs rdiff -u -r1.25 -r1.26 src/usr.bin/make/lst.h cvs rdiff -u -r1.106 -r1.107 src/usr.bin/make/make.c cvs rdiff -u -r1.99 -r1.100 src/usr.bin/make/suff.c cvs rdiff -u -r1.66 -r1.67 src/usr.bin/make/targ.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/arch.c diff -u src/usr.bin/make/arch.c:1.85 src/usr.bin/make/arch.c:1.86 --- src/usr.bin/make/arch.c:1.85 Fri Aug 21 04:09:12 2020 +++ src/usr.bin/make/arch.c Fri Aug 21 04:42:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.85 2020/08/21 04:09:12 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.86 2020/08/21 04:42:02 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: arch.c,v 1.85 2020/08/21 04:09:12 rillig Exp $"; +static char rcsid[] = "$NetBSD: arch.c,v 1.86 2020/08/21 04:42:02 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: arch.c,v 1.85 2020/08/21 04:09:12 rillig Exp $"); +__RCSID("$NetBSD: arch.c,v 1.86 2020/08/21 04:42:02 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -1158,7 +1158,7 @@ Arch_MemMTime(GNode *gn) } } -Lst_Close(gn->parents); +Lst_CloseS(gn->parents); return gn->mtime; } Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.95 src/usr.bin/make/dir.c:1.96 --- src/usr.bin/make/dir.c:1.95 Fri Aug 21 04:09:12 2020 +++ src/usr.bin/make/dir.c Fri Aug 21 04:42:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.95 2020/08/21 04:09:12 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.96 2020/08/21 04:42:02 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: dir.c,v 1.95 2020/08/21 04:09:12 rillig Exp $"; +static char rcsid[] = "$NetBSD: dir.c,v 1.96 2020/08/21 04:42:02 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: dir.c,v 1.95 2020/08/21 04:09:12 rillig Exp $"); +__RCSID("$NetBSD: dir.c,v 1.96 2020/08/21 04:42:02 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -524,7 +524,7 @@ Dir_SetPATH(void) if (cur) Var_Append(".PATH", cur->name, VAR_GLOBAL); } - Lst_Close(dirSearchPath); + Lst_CloseS(dirSearchPath); } } @@ -817,7 +817,7 @@ DirExpandInt(const char *word, Lst path, p = (Path *)Lst_Datum(ln); DirMatchFiles(word, p, expansions); } - Lst_Close(path); + Lst_CloseS(path); } } @@ -1181,7 +1181,7 @@ Dir_FindFile(const char *name, Lst path) * specifies (fish.c) and what pmake finds (./fish.c). */ if (!hasLastDot && (file = DirFindDot(hasSlash, name, cp)) != NULL) { - Lst_Close(path); + Lst_CloseS(path); return file; } @@ -1190,17 +1190,17 @@ Dir_FindFile(const char *name, Lst path) if (p == dotLast) continue; if ((file = DirLookup(p, name, cp, hasSlash)) != NULL) { - Lst_Close(path); + Lst_CloseS(path); return file; } } if (hasLastDot && (file = DirFindDot(hasSlash, name, cp)) != NULL) { - Lst_Close(path); + Lst_CloseS(path); return file; } } -Lst_Close(path); +Lst_CloseS(path); /* * We didn't find the file on any directory in the search path. @@ -1242,7 +1242,7 @@ Dir_FindFile(const char *name, Lst path) return file; } - (void)Lst_Open(path); + Lst_OpenS(path); while ((ln = Lst_NextS(path)) != NULL) { p = (Path *)Lst_Datum(ln); if (p == dotLast) @@ -1253,11 +1253,11 @@ Dir_FindFile(const char *name, Lst path) checkedDot = TRUE; } if ((file = DirLookupSubdir(p, name)) != NULL) { - Lst_Close(path); + Lst_CloseS(path); return file; } } - Lst_Close(path); + Lst_CloseS(path); if (hasLastDot) { if (dot && !checkedDot) { @@ -1300,13 +1300,13 @@ Dir_FindFile(const char *name, Lst path) return file; } - (void)Lst_Open(path); + Lst_OpenS(path); while ((ln = Lst_NextS(path)) != NULL) { p = (Path *)Lst_Datum(ln); if (p == dotLast) continue; if ((file =
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Aug 21 04:09:12 UTC 2020 Modified Files: src/usr.bin/make: arch.c dir.c lst.c lst.h make.c suff.c targ.c Log Message: make(1): assert correct usage of the Lst_Open API All calls to Lst_Next are properly protected by Lst_Open, so there is no possible assertion failure here. To generate a diff of this commit: cvs rdiff -u -r1.84 -r1.85 src/usr.bin/make/arch.c cvs rdiff -u -r1.94 -r1.95 src/usr.bin/make/dir.c cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/lst.c cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/lst.h cvs rdiff -u -r1.105 -r1.106 src/usr.bin/make/make.c cvs rdiff -u -r1.98 -r1.99 src/usr.bin/make/suff.c cvs rdiff -u -r1.65 -r1.66 src/usr.bin/make/targ.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/arch.c diff -u src/usr.bin/make/arch.c:1.84 src/usr.bin/make/arch.c:1.85 --- src/usr.bin/make/arch.c:1.84 Fri Aug 21 02:20:47 2020 +++ src/usr.bin/make/arch.c Fri Aug 21 04:09:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.84 2020/08/21 02:20:47 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.85 2020/08/21 04:09:12 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: arch.c,v 1.84 2020/08/21 02:20:47 rillig Exp $"; +static char rcsid[] = "$NetBSD: arch.c,v 1.85 2020/08/21 04:09:12 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: arch.c,v 1.84 2020/08/21 02:20:47 rillig Exp $"); +__RCSID("$NetBSD: arch.c,v 1.85 2020/08/21 04:09:12 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -1130,7 +1130,7 @@ Arch_MemMTime(GNode *gn) gn->mtime = 0; return 0; } -while ((ln = Lst_Next(gn->parents)) != NULL) { +while ((ln = Lst_NextS(gn->parents)) != NULL) { pgn = (GNode *)Lst_Datum(ln); if (pgn->type & OP_ARCHV) { Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.94 src/usr.bin/make/dir.c:1.95 --- src/usr.bin/make/dir.c:1.94 Fri Aug 21 03:36:03 2020 +++ src/usr.bin/make/dir.c Fri Aug 21 04:09:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.94 2020/08/21 03:36:03 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.95 2020/08/21 04:09:12 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: dir.c,v 1.94 2020/08/21 03:36:03 rillig Exp $"; +static char rcsid[] = "$NetBSD: dir.c,v 1.95 2020/08/21 04:09:12 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: dir.c,v 1.94 2020/08/21 03:36:03 rillig Exp $"); +__RCSID("$NetBSD: dir.c,v 1.95 2020/08/21 04:09:12 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -509,7 +509,7 @@ Dir_SetPATH(void) Var_Append(".PATH", cur->name, VAR_GLOBAL); } - while ((ln = Lst_Next(dirSearchPath)) != NULL) { + while ((ln = Lst_NextS(dirSearchPath)) != NULL) { p = (Path *)Lst_Datum(ln); if (p == dotLast) continue; @@ -813,7 +813,7 @@ DirExpandInt(const char *word, Lst path, Path *p; /* Directory in the node */ if (Lst_Open(path) == SUCCESS) { - while ((ln = Lst_Next(path)) != NULL) { + while ((ln = Lst_NextS(path)) != NULL) { p = (Path *)Lst_Datum(ln); DirMatchFiles(word, p, expansions); } @@ -1185,7 +1185,7 @@ Dir_FindFile(const char *name, Lst path) return file; } - while ((ln = Lst_Next(path)) != NULL) { + while ((ln = Lst_NextS(path)) != NULL) { p = (Path *)Lst_Datum(ln); if (p == dotLast) continue; @@ -1243,7 +1243,7 @@ Dir_FindFile(const char *name, Lst path) } (void)Lst_Open(path); - while ((ln = Lst_Next(path)) != NULL) { + while ((ln = Lst_NextS(path)) != NULL) { p = (Path *)Lst_Datum(ln); if (p == dotLast) continue; @@ -1301,7 +1301,7 @@ Dir_FindFile(const char *name, Lst path) } (void)Lst_Open(path); - while ((ln = Lst_Next(path)) != NULL) { + while ((ln = Lst_NextS(path)) != NULL) { p = (Path *)Lst_Datum(ln); if (p == dotLast) continue; @@ -1679,7 +1679,7 @@ Dir_MakeFlags(const char *flag, Lst path Buf_Init(, 0); if (Lst_Open(path) == SUCCESS) { - while ((ln = Lst_Next(path)) != NULL) { + while ((ln = Lst_NextS(path)) != NULL) { Path *p = (Path *)Lst_Datum(ln); Buf_AddStr(, " "); Buf_AddStr(, flag); @@ -1803,7 +1803,7 @@ Dir_PrintDirectories(void) hits * 100 / (hits + bigmisses + nearmisses) : 0)); fprintf(debug_file, "# %-20s referenced\thits\n", "directory"); if (Lst_Open(openDirectories) == SUCCESS) { - while ((ln = Lst_Next(openDirectories)) != NULL) { + while ((ln = Lst_NextS(openDirectories)) != NULL) { p = (Path *)Lst_Datum(ln); fprintf(debug_file, "# %-20s %10d\t%4d\n", p->name, p->refCount, p->hits);
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: uwe Date: Fri Aug 21 03:44:58 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Mark up a few missed equal signs as literal. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.8 diff -u src/usr.sbin/wgconfig/wgconfig.8:1.8 src/usr.sbin/wgconfig/wgconfig.8:1.9 --- src/usr.sbin/wgconfig/wgconfig.8:1.8 Fri Aug 21 03:13:30 2020 +++ src/usr.sbin/wgconfig/wgconfig.8 Fri Aug 21 03:44:58 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: wgconfig.8,v 1.8 2020/08/21 03:13:30 uwe Exp $ +.\" $NetBSD: wgconfig.8,v 1.9 2020/08/21 03:44:58 uwe Exp $ .\" .\" Copyright (C) Ryota Ozaki .\" All rights reserved. @@ -60,8 +60,8 @@ .Nm .Li wg Ns Ar N\| .Cm "add peer" Ar name Ar pubkey -.Op Fl Fl preshared-key Ns = Ns Ar filename -.Op Fl Fl endpoint Ns = Ns Ar ip Ns Li \&: Ns Ar port +.Op Fl Fl preshared-key Ns Li \&= Ns Ar filename +.Oo Fl Fl endpoint Ns Li \&= Ns Ar ip Ns Li \&: Ns Ar port Oc .Oo .Fl Fl allowed-ips Ns Li \&= Ns Ar ip1 Ns Li \&/ Ns Ar cidr1 Ns .Op Li \&, Ns Ar ip2 Ns Li \&/ Ns Ar cidr2 Ns Li \&, Ns Ar ... @@ -138,7 +138,7 @@ is the peer's base64-encoded public key, .Pp The following options may be specified: .Bl -tag -width abcd -.It Fl Fl preshared-key-file Ns = Ns Ar filename +.It Fl Fl preshared-key-file Ns Li \&= Ns Ar filename Set a secret preshared key generated by .Nm wg-keygen .Fl Fl psk .
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Aug 21 03:36:03 UTC 2020 Modified Files: src/usr.bin/make: compat.c dir.c lst.c lst.h make.c meta.c suff.c Log Message: make(1): make list library code stricter Up to now, the list library didn't distinguish between programming mistakes (violations of invariants, illegal parameter values) and actually interesting situations like "element not found in list". The current code contains many branches for conditions that are neither exercised by the unit tests nor by real-world usage. There is no point in keeping this unnecessary code. The list functions will be migrated from their lenient variants to the stricter variants in small parts, each function getting the S suffix when it is made strict, to avoid any confusion about how strict a particular function is. When all functions have been migrated, they will be renamed back to their original names. While here, the comments of the functions are cleaned up since they mention irrelevant implementation details in the API comments, as well as "side effects" that are really main effects. To generate a diff of this commit: cvs rdiff -u -r1.118 -r1.119 src/usr.bin/make/compat.c cvs rdiff -u -r1.93 -r1.94 src/usr.bin/make/dir.c src/usr.bin/make/meta.c cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/lst.c cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/lst.h cvs rdiff -u -r1.104 -r1.105 src/usr.bin/make/make.c cvs rdiff -u -r1.97 -r1.98 src/usr.bin/make/suff.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/compat.c diff -u src/usr.bin/make/compat.c:1.118 src/usr.bin/make/compat.c:1.119 --- src/usr.bin/make/compat.c:1.118 Sat Aug 1 14:47:49 2020 +++ src/usr.bin/make/compat.c Fri Aug 21 03:36:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.118 2020/08/01 14:47:49 rillig Exp $ */ +/* $NetBSD: compat.c,v 1.119 2020/08/21 03:36:03 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: compat.c,v 1.118 2020/08/01 14:47:49 rillig Exp $"; +static char rcsid[] = "$NetBSD: compat.c,v 1.119 2020/08/21 03:36:03 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: compat.c,v 1.118 2020/08/01 14:47:49 rillig Exp $"); +__RCSID("$NetBSD: compat.c,v 1.119 2020/08/21 03:36:03 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -249,7 +249,7 @@ CompatRunCommand(void *cmdp, void *gnp) return 0; } cmd = cmdStart; -Lst_Replace(cmdNode, cmdStart); +Lst_ReplaceS(cmdNode, cmdStart); if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) { (void)Lst_AtEnd(ENDNode->commands, cmdStart); @@ -400,7 +400,7 @@ again: free(mav); free(bp); -Lst_Replace(cmdNode, NULL); +Lst_ReplaceS(cmdNode, NULL); #ifdef USE_META if (useMeta) { Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.93 src/usr.bin/make/dir.c:1.94 --- src/usr.bin/make/dir.c:1.93 Fri Aug 21 02:20:47 2020 +++ src/usr.bin/make/dir.c Fri Aug 21 03:36:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.93 2020/08/21 02:20:47 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.94 2020/08/21 03:36:03 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: dir.c,v 1.93 2020/08/21 02:20:47 rillig Exp $"; +static char rcsid[] = "$NetBSD: dir.c,v 1.94 2020/08/21 03:36:03 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: dir.c,v 1.93 2020/08/21 02:20:47 rillig Exp $"); +__RCSID("$NetBSD: dir.c,v 1.94 2020/08/21 03:36:03 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -429,7 +429,7 @@ Dir_InitDot(void) /* Remove old entry from openDirectories, but do not destroy. */ ln = Lst_Member(openDirectories, dot); - (void)Lst_Remove(openDirectories, ln); + Lst_RemoveS(openDirectories, ln); } dot = Dir_AddDir(NULL, "."); @@ -1719,7 +1719,7 @@ Dir_Destroy(void *pp) LstNode ln; ln = Lst_Member(openDirectories, p); - (void)Lst_Remove(openDirectories, ln); + Lst_RemoveS(openDirectories, ln); Hash_DeleteTable(>files); free(p->name); Index: src/usr.bin/make/meta.c diff -u src/usr.bin/make/meta.c:1.93 src/usr.bin/make/meta.c:1.94 --- src/usr.bin/make/meta.c:1.93 Fri Aug 21 02:20:47 2020 +++ src/usr.bin/make/meta.c Fri Aug 21 03:36:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.93 2020/08/21 02:20:47 rillig Exp $ */ +/* $NetBSD: meta.c,v 1.94 2020/08/21 03:36:03 rillig Exp $ */ /* * Implement 'meta' mode. @@ -1341,7 +1341,7 @@ meta_oodate(GNode *gn, Boolean oodate) nln = Lst_FindFrom(missingFiles, Lst_Succ(ln), p, path_match); tp =
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: uwe Date: Fri Aug 21 03:13:30 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Markup fixes. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.8 diff -u src/usr.sbin/wgconfig/wgconfig.8:1.7 src/usr.sbin/wgconfig/wgconfig.8:1.8 --- src/usr.sbin/wgconfig/wgconfig.8:1.7 Fri Aug 21 02:45:33 2020 +++ src/usr.sbin/wgconfig/wgconfig.8 Fri Aug 21 03:13:30 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: wgconfig.8,v 1.7 2020/08/21 02:45:33 uwe Exp $ +.\" $NetBSD: wgconfig.8,v 1.8 2020/08/21 03:13:30 uwe Exp $ .\" .\" Copyright (C) Ryota Ozaki .\" All rights reserved. @@ -37,30 +37,39 @@ .\" .Sh SYNOPSIS .Nm -.Ar wgN +.Li wg Ns Ar N\| .Op Cm "show all" .\" .Nm -.Ar wgN Cm "show peer" Ar name +.Li wg Ns Ar N\| +.Cm "show peer" Ar name .Op Fl Fl show-preshared-key .\" .Nm -.Ar wgN Cm "show private-key" +.Li wg Ns Ar N\| +.Cm "show private-key" .\" .Nm -.Ar wgN Cm "set private-key" Ar "filename" +.Li wg Ns Ar N\| +.Cm "set private-key" Ar "filename" .\" .Nm -.Ar wgN Cm "set listen-port" Ar port +.Li wg Ns Ar N\| +.Cm "set listen-port" Ar port .\" .Nm -.Ar wgN Cm "add peer" Ar name Ar pubkey +.Li wg Ns Ar N\| +.Cm "add peer" Ar name Ar pubkey .Op Fl Fl preshared-key Ns = Ns Ar filename -.Op Fl Fl endpoint Ns = Ns Ar ip : Ns Ar port -.Op Fl Fl allowed-ips Ns = Ns Ar ip1 Ns / Ns Ar cidr1 Ns Op , Ns Ar ip2 Ns / Ns Ar cidr2 Ns ,... +.Op Fl Fl endpoint Ns = Ns Ar ip Ns Li \&: Ns Ar port +.Oo +.Fl Fl allowed-ips Ns Li \&= Ns Ar ip1 Ns Li \&/ Ns Ar cidr1 Ns +.Op Li \&, Ns Ar ip2 Ns Li \&/ Ns Ar cidr2 Ns Li \&, Ns Ar ... +.Oc .\" .Nm -.Ar wgN Cm "delete peer" Ar name +.Li wg Ns Ar N\| +.Cm "delete peer" Ar name .\" .Sh DESCRIPTION The @@ -94,39 +103,45 @@ also display the secret preshared key th have with the .Fl Fl preshared-key option to -.Nm Ar wgN Cm "add peer" . +.Nm +.Li wg Ns Ar N Cm "add peer" . .It Cm "show private-key" Show the private key that was set with -.Nm Ar wgN Cm "set private-key" . +.Nm +.Li wg Ns Ar N Cm "set private-key" . .It Cm "set private-key" Ar filename Set the private key of -.Ar wgN +.Li wg Ns Ar N\| to the base64-encoded private key in the file at .Ar filename . .It Cm "set listen-port" Ar port Set the UDP port number that -.Ar wgN +.Li wg Ns Ar N\| listens for incoming WireGuard sessions on. This allows a peer to start a new session without having a specific endpoint IP address configured. -.It Cm "add peer" Ar name Ar pubkey Op Ar options... +.It Cm "add peer" Ar name Ar pubkey Op Ar options ... Add a peer. The argument .Ar name may be passed to -.Nm Ar wgN Cm "show peer" +.Nm +.Li wg Ns Ar N Cm "show peer" and -.Nm Ar wgN Cm "delete peer" . +.Nm +.Li wg Ns Ar N Cm "delete peer" . The argument .Ar pubkey is the peer's base64-encoded public key, as printed by -.Nm wg-keygen Fl Fl pub . +.Nm wg-keygen +.Fl Fl pub . .Pp The following options may be specified: .Bl -tag -width abcd .It Fl Fl preshared-key-file Ns = Ns Ar filename Set a secret preshared key generated by -.Nm wg-keygen Fl Fl psk . +.Nm wg-keygen +.Fl Fl psk . .Pp If the preshared key can be arranged in advance on a medium not subject to eavesdropping, then it defends against possible future quantum @@ -135,11 +150,12 @@ WireGuard still uses X25519 key agreemen session keys so that past session transcripts remain secret should one of the endpoints be compromised in the future; the preshared key is an additional measure on top. -.It Fl Fl endpoint Ns = Ns Ar ip : Ns Ar port +.It Fl Fl endpoint Ns Li \&= Ns Ar ip Ns Li \&: Ns Ar port Set the peer's endpoint address outside the tunnel. This is optional for a VPN server if the WireGuard interface is configured to listen on a port number. -.It Fl Fl allowed-ips Ns = Ns Ar ip1 Ns / Ns Ar cidr1 Ns Op , Ns Ar ip2 Ns / Ns Ar cidr2 Ns ,... +.It Fl Fl allowed-ips Ns Li \&= Ns Ar ip1 Ns Li \&/ Ns Ar cidr1 Ns \ +Op Li \&, Ns Ar ip2 Ns Li \&/ Ns Ar cidr2 Ns Li \&, Ns Ar ... Set the IP address ranges that the peer is allowed to select inside the tunnel. .El @@ -147,7 +163,8 @@ tunnel. Delete the peer .Ar name previously added with -.Nm Ar wgN Cm "add peer" Ar name . +.Nm +.Li wg Ns Ar N Cm "add peer" Ar name . .El .\" .Sh EXAMPLES
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Aug 21 03:03:45 UTC 2020 Modified Files: src/usr.bin/make: lst.c Log Message: make(1): don't use bitfields in list processing There is no need to squeeze unrelated fields of the struct into a single object. A bitset with a single flag is the same as a simple boolean variable. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/lst.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/lst.c diff -u src/usr.bin/make/lst.c:1.6 src/usr.bin/make/lst.c:1.7 --- src/usr.bin/make/lst.c:1.6 Fri Aug 21 02:56:25 2020 +++ src/usr.bin/make/lst.c Fri Aug 21 03:03:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lst.c,v 1.6 2020/08/21 02:56:25 rillig Exp $ */ +/* $NetBSD: lst.c,v 1.7 2020/08/21 03:03:45 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -36,27 +36,23 @@ #include "make_malloc.h" #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: lst.c,v 1.6 2020/08/21 02:56:25 rillig Exp $"; +static char rcsid[] = "$NetBSD: lst.c,v 1.7 2020/08/21 03:03:45 rillig Exp $"; #else #include #ifndef lint -__RCSID("$NetBSD: lst.c,v 1.6 2020/08/21 02:56:25 rillig Exp $"); +__RCSID("$NetBSD: lst.c,v 1.7 2020/08/21 03:03:45 rillig Exp $"); #endif /* not lint */ #endif typedef struct ListNode { struct ListNode *prevPtr; /* previous element in list */ struct ListNode *nextPtr; /* next in list */ -unsigned int useCount: 8, /* Count of functions using the node. +uint8_t useCount; /* Count of functions using the node. * node may not be deleted until count * goes to 0 */ - flags: 8; /* Node status flags */ +Boolean deleted; /* List node should be removed when done */ void *datum; /* datum associated with this element */ } *ListNode; -/* - * Flags required for synchronization - */ -#define LN_DELETED 0x0001 /* List node should be removed when done */ typedef enum { Head, Middle, Tail, Unknown @@ -272,7 +268,8 @@ Lst_InsertBefore(Lst l, LstNode ln, void PAlloc (nLNode, ListNode); nLNode->datum = d; -nLNode->useCount = nLNode->flags = 0; +nLNode->useCount = 0; +nLNode->deleted = FALSE; if (ln == NULL) { nLNode->prevPtr = nLNode->nextPtr = NULL; @@ -336,7 +333,8 @@ Lst_InsertAfter(Lst l, LstNode ln, void PAlloc (nLNode, ListNode); nLNode->datum = d; -nLNode->useCount = nLNode->flags = 0; +nLNode->useCount = 0; +nLNode->deleted = FALSE; if (lNode == NULL) { nLNode->nextPtr = nLNode->prevPtr = NULL; @@ -473,7 +471,7 @@ Lst_Remove(Lst l, LstNode ln) if (lNode->useCount == 0) { free(ln); } else { - lNode->flags |= LN_DELETED; + lNode->deleted = TRUE; } return SUCCESS; @@ -793,7 +791,7 @@ Lst_ForEachFrom(Lst l, LstNode ln, int ( done = 0; } - if (tln->flags & LN_DELETED) { + if (tln->deleted) { free((char *)tln); } tln = next; @@ -884,7 +882,8 @@ Lst_Concat(Lst l1, Lst l2, int flags) list1->firstPtr = nln; } nln->prevPtr = last; - nln->flags = nln->useCount = 0; + nln->useCount = 0; + nln->deleted = FALSE; last = nln; }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Aug 21 02:56:26 UTC 2020 Modified Files: src/usr.bin/make: lst.c lst.h Log Message: make(1): properly clean up the remaining code mentioning circular lists To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/lst.c cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/lst.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/lst.c diff -u src/usr.bin/make/lst.c:1.5 src/usr.bin/make/lst.c:1.6 --- src/usr.bin/make/lst.c:1.5 Fri Aug 21 02:20:47 2020 +++ src/usr.bin/make/lst.c Fri Aug 21 02:56:25 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lst.c,v 1.5 2020/08/21 02:20:47 rillig Exp $ */ +/* $NetBSD: lst.c,v 1.6 2020/08/21 02:56:25 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -36,11 +36,11 @@ #include "make_malloc.h" #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: lst.c,v 1.5 2020/08/21 02:20:47 rillig Exp $"; +static char rcsid[] = "$NetBSD: lst.c,v 1.6 2020/08/21 02:56:25 rillig Exp $"; #else #include #ifndef lint -__RCSID("$NetBSD: lst.c,v 1.5 2020/08/21 02:20:47 rillig Exp $"); +__RCSID("$NetBSD: lst.c,v 1.6 2020/08/21 02:56:25 rillig Exp $"); #endif /* not lint */ #endif @@ -467,15 +467,6 @@ Lst_Remove(Lst l, LstNode ln) } /* - * the only way firstPtr can still point to ln is if ln is the last - * node on the list (the list is circular, so lNode->nextptr == lNode in - * this case). The list is, therefore, empty and is marked as such - */ -if (list->firstPtr == lNode) { - list->firstPtr = NULL; -} - -/* * note that the datum is unmolested. The caller must free it as * necessary and as expected. */ @@ -563,21 +554,7 @@ Lst_Last(Lst l) } } -/*- - *--- - * Lst_Succ -- - * Return the successor to the given node on its list. - * - * Results: - * The successor of the node, if it exists (note that on a circular - * list, if the node is the only one in the list, it is its own - * successor). - * - * Side Effects: - * None. - * - *--- - */ +/* Return the successor to the given node on its list, or NULL. */ LstNode Lst_Succ(LstNode ln) { @@ -588,21 +565,7 @@ Lst_Succ(LstNode ln) } } -/*- - *--- - * Lst_Prev -- - * Return the predecessor to the given node on its list. - * - * Results: - * The predecessor of the node, if it exists (note that on a circular - * list, if the node is the only one in the list, it is its own - * predecessor). - * - * Side Effects: - * None. - * - *--- - */ +/* Return the predecessor to the given node on its list, or NULL. */ LstNode Lst_Prev(LstNode ln) { @@ -773,9 +736,6 @@ Lst_ForEach(Lst l, int (*proc)(void *, v * Apply the given function to each element of the given list, * starting from a given point. * - * If the list is circular, the application will wrap around to the - * beginning of the list again. - * * The function should return 0 if traversal should continue, and * non-zero if it should abort. * @@ -882,15 +842,6 @@ Lst_Concat(Lst l1, Lst l2, int flags) if (flags == LST_CONCLINK) { if (list2->firstPtr != NULL) { /* - * We set the nextPtr of the - * last element of list two to be NIL to make the loop easier and - * so we don't need an extra case should the first list turn - * out to be non-circular -- the final element will already point - * to NIL space and the first element will be untouched if it - * existed before and will also point to NIL space if it didn't. - */ - list2->lastPtr->nextPtr = NULL; - /* * So long as the second list isn't empty, we just link the * first element of the second list to the last element of the * first list. If the first list isn't empty, we then link the @@ -957,9 +908,6 @@ Lst_Concat(Lst l1, Lst l2, int flags) * The sequential functions access the list in a slightly different way. * CurPtr points to their idea of the current node in the list and they * access the list based on it. - * - * If the list is circular, Lst_Next and Lst_Prev will go around the list - * forever. Lst_IsAtEnd must be used to determine when to stop. */ /*- @@ -998,8 +946,7 @@ Lst_Open(Lst l) * * Results: * The next node or NULL if the list has yet to be opened. Also - * if the list is non-circular and the end has been reached, NULL - * is returned. + * if the end has been reached, NULL is returned. * * Side Effects: * the curPtr field is updated. Index: src/usr.bin/make/lst.h diff -u src/usr.bin/make/lst.h:1.22 src/usr.bin/make/lst.h:1.23 --- src/usr.bin/make/lst.h:1.22 Fri Aug 21 02:20:47 2020 +++
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: uwe Date: Fri Aug 21 02:45:34 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Fix synopsis. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.8 diff -u src/usr.sbin/wgconfig/wgconfig.8:1.6 src/usr.sbin/wgconfig/wgconfig.8:1.7 --- src/usr.sbin/wgconfig/wgconfig.8:1.6 Fri Aug 21 01:36:04 2020 +++ src/usr.sbin/wgconfig/wgconfig.8 Fri Aug 21 02:45:33 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: wgconfig.8,v 1.6 2020/08/21 01:36:04 riastradh Exp $ +.\" $NetBSD: wgconfig.8,v 1.7 2020/08/21 02:45:33 uwe Exp $ .\" .\" Copyright (C) Ryota Ozaki .\" All rights reserved. @@ -36,24 +36,31 @@ .Nd configure WireGuard interface parameters .\" .Sh SYNOPSIS -.Nm Ar wgN +.Nm +.Ar wgN .Op Cm "show all" .\" -.Nm Ar wgN Cm "show peer" Ar name +.Nm +.Ar wgN Cm "show peer" Ar name .Op Fl Fl show-preshared-key .\" -.Nm Ar wgN Cm "show private-key" +.Nm +.Ar wgN Cm "show private-key" .\" -.Nm Ar wgN Cm "set private-key" Ar "filename" +.Nm +.Ar wgN Cm "set private-key" Ar "filename" .\" -.Nm Ar wgN Cm "set listen-port" Ar port +.Nm +.Ar wgN Cm "set listen-port" Ar port .\" -.Nm Ar wgN Cm "add peer" Ar name Ar pubkey +.Nm +.Ar wgN Cm "add peer" Ar name Ar pubkey .Op Fl Fl preshared-key Ns = Ns Ar filename .Op Fl Fl endpoint Ns = Ns Ar ip : Ns Ar port .Op Fl Fl allowed-ips Ns = Ns Ar ip1 Ns / Ns Ar cidr1 Ns Op , Ns Ar ip2 Ns / Ns Ar cidr2 Ns ,... .\" -.Nm Ar wgN Cm "delete peer" Ar name +.Nm +.Ar wgN Cm "delete peer" Ar name .\" .Sh DESCRIPTION The
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Aug 21 02:20:48 UTC 2020 Modified Files: src/usr.bin/make: arch.c dir.c job.c lst.c lst.h main.c make.c meta.c parse.c suff.c targ.c Log Message: make(1): remove unused code for circular lists The list library had probably been imported from a general-purpose library that also supported circular lists. These are not used by make though. After replacing Lst_Init(FALSE) with Lst_Init(), only a single call to Lst_Init remained with a non-constant argument, and that was in Lst_Concat, which was to be expected. To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/usr.bin/make/arch.c cvs rdiff -u -r1.92 -r1.93 src/usr.bin/make/dir.c src/usr.bin/make/meta.c cvs rdiff -u -r1.206 -r1.207 src/usr.bin/make/job.c cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/lst.c cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/lst.h cvs rdiff -u -r1.304 -r1.305 src/usr.bin/make/main.c cvs rdiff -u -r1.103 -r1.104 src/usr.bin/make/make.c cvs rdiff -u -r1.251 -r1.252 src/usr.bin/make/parse.c cvs rdiff -u -r1.96 -r1.97 src/usr.bin/make/suff.c cvs rdiff -u -r1.64 -r1.65 src/usr.bin/make/targ.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/arch.c diff -u src/usr.bin/make/arch.c:1.83 src/usr.bin/make/arch.c:1.84 --- src/usr.bin/make/arch.c:1.83 Wed Aug 12 19:36:14 2020 +++ src/usr.bin/make/arch.c Fri Aug 21 02:20:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.83 2020/08/12 19:36:14 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.84 2020/08/21 02:20:47 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: arch.c,v 1.83 2020/08/12 19:36:14 rillig Exp $"; +static char rcsid[] = "$NetBSD: arch.c,v 1.84 2020/08/21 02:20:47 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: arch.c,v 1.83 2020/08/12 19:36:14 rillig Exp $"); +__RCSID("$NetBSD: arch.c,v 1.84 2020/08/21 02:20:47 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -392,7 +392,7 @@ Arch_ParseArchive(char **linePtr, Lst no */ free(buf); } else if (Dir_HasWildcards(memName)) { - Lst members = Lst_Init(FALSE); + Lst members = Lst_Init(); char *member; size_t sz = MAXPATHLEN, nsz; nameBuf = bmake_malloc(sz); @@ -1305,7 +1305,7 @@ Arch_LibOODate(GNode *gn) void Arch_Init(void) { -archives = Lst_Init(FALSE); +archives = Lst_Init(); } Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.92 src/usr.bin/make/dir.c:1.93 --- src/usr.bin/make/dir.c:1.92 Thu Aug 13 03:33:56 2020 +++ src/usr.bin/make/dir.c Fri Aug 21 02:20:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.92 2020/08/13 03:33:56 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.93 2020/08/21 02:20:47 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: dir.c,v 1.92 2020/08/13 03:33:56 rillig Exp $"; +static char rcsid[] = "$NetBSD: dir.c,v 1.93 2020/08/21 02:20:47 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: dir.c,v 1.92 2020/08/13 03:33:56 rillig Exp $"); +__RCSID("$NetBSD: dir.c,v 1.93 2020/08/21 02:20:47 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -367,8 +367,8 @@ void Dir_Init(const char *cdname) { if (!cdname) { - dirSearchPath = Lst_Init(FALSE); - openDirectories = Lst_Init(FALSE); + dirSearchPath = Lst_Init(); + openDirectories = Lst_Init(); Hash_InitTable(, 0); Hash_InitTable(, 0); return; @@ -909,7 +909,7 @@ Dir_Expand(const char *word, Lst path, L char *dp = [strlen(dirpath) - 1]; if (*dp == '/') *dp = '\0'; - path = Lst_Init(FALSE); + path = Lst_Init(); (void)Dir_AddDir(path, dirpath); DirExpandInt(cp + 1, path, expansions); Lst_Destroy(path, NULL); Index: src/usr.bin/make/meta.c diff -u src/usr.bin/make/meta.c:1.92 src/usr.bin/make/meta.c:1.93 --- src/usr.bin/make/meta.c:1.92 Mon Aug 3 20:26:09 2020 +++ src/usr.bin/make/meta.c Fri Aug 21 02:20:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.92 2020/08/03 20:26:09 rillig Exp $ */ +/* $NetBSD: meta.c,v 1.93 2020/08/21 02:20:47 rillig Exp $ */ /* * Implement 'meta' mode. @@ -625,7 +625,7 @@ meta_mode_init(const char *make_mode) /* * We consider ourselves master of all within ${.MAKE.META.BAILIWICK} */ -metaBailiwick = Lst_Init(FALSE); +metaBailiwick = Lst_Init(); metaBailiwickStr = Var_Subst("${.MAKE.META.BAILIWICK:O:u:tA}", VAR_GLOBAL, VARE_WANTRES); if (metaBailiwickStr) { @@ -634,7 +634,7 @@ meta_mode_init(const char *make_mode) /* * We ignore any paths that start with ${.MAKE.META.IGNORE_PATHS}
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Fri Aug 21 01:36:05 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Fix markup around optional command name. Avoids emboldened brackets. I remain fuzzy on how grouping in roff works, or doesn't work. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.8 diff -u src/usr.sbin/wgconfig/wgconfig.8:1.5 src/usr.sbin/wgconfig/wgconfig.8:1.6 --- src/usr.sbin/wgconfig/wgconfig.8:1.5 Thu Aug 20 23:03:08 2020 +++ src/usr.sbin/wgconfig/wgconfig.8 Fri Aug 21 01:36:04 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: wgconfig.8,v 1.5 2020/08/20 23:03:08 riastradh Exp $ +.\" $NetBSD: wgconfig.8,v 1.6 2020/08/21 01:36:04 riastradh Exp $ .\" .\" Copyright (C) Ryota Ozaki .\" All rights reserved. @@ -36,7 +36,8 @@ .Nd configure WireGuard interface parameters .\" .Sh SYNOPSIS -.Nm Ar wgN Op Cm "show all" +.Nm Ar wgN +.Op Cm "show all" .\" .Nm Ar wgN Cm "show peer" Ar name .Op Fl Fl show-preshared-key
CVS commit: src/sys/uvm/pmap
Module Name:src Committed By: mrg Date: Thu Aug 20 23:36:45 UTC 2020 Modified Files: src/sys/uvm/pmap: pmap_segtab.c Log Message: fix hpcmips and evbppc builds (wrong type in panic()). To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/uvm/pmap/pmap_segtab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/uvm/pmap/pmap_segtab.c diff -u src/sys/uvm/pmap/pmap_segtab.c:1.19 src/sys/uvm/pmap/pmap_segtab.c:1.20 --- src/sys/uvm/pmap/pmap_segtab.c:1.19 Thu Aug 20 05:54:32 2020 +++ src/sys/uvm/pmap/pmap_segtab.c Thu Aug 20 23:36:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_segtab.c,v 1.19 2020/08/20 05:54:32 mrg Exp $ */ +/* $NetBSD: pmap_segtab.c,v 1.20 2020/08/20 23:36:45 mrg Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: pmap_segtab.c,v 1.19 2020/08/20 05:54:32 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap_segtab.c,v 1.20 2020/08/20 23:36:45 mrg Exp $"); /* * Manages physical address maps. @@ -184,7 +184,7 @@ pmap_check_ptes(pt_entry_t *pte, const c "pte[%zu] = %#"PRIxPTE, j, pte_value(pte[j]), 0, 0); #endif - panic("%s: pte[%ju] entry at %pu not 0 (%#"PRIxPTE")", + panic("%s: pte[%zu] entry at %p not 0 (%#"PRIxPTE")", caller, i, [i], pte_value(pte[i])); } #endif
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Thu Aug 20 23:19:34 UTC 2020 Modified Files: src/bin/sh: sh.1 Log Message: Man page enhancements. Better describe the command search procedure. Document "trap -P" Describe what works as a function name. More accurate description of reserved word recognition. Be more accurate about when field splittng happens after expansions (and in particular note that tilde expansions are not subject to field splitting). Be clear that "$@" is not field split, it simply produces multiple fields as part of its expansion (hence IFS is irrelevant to this), but if used as $@ (unquoted) each field produced is potentially subject to field splitting. Other minor wording changes. To generate a diff of this commit: cvs rdiff -u -r1.224 -r1.225 src/bin/sh/sh.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/sh.1 diff -u src/bin/sh/sh.1:1.224 src/bin/sh/sh.1:1.225 --- src/bin/sh/sh.1:1.224 Thu Feb 20 18:24:20 2020 +++ src/bin/sh/sh.1 Thu Aug 20 23:19:34 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: sh.1,v 1.224 2020/02/20 18:24:20 pgoyette Exp $ +.\" $NetBSD: sh.1,v 1.225 2020/08/20 23:19:34 kre Exp $ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -31,7 +31,7 @@ .\" .\" @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" -.Dd February 20, 2020 +.Dd August 20, 2020 .Dt SH 1 .\" everything except c o and s (keep them ordered) .ds flags abCEeFfhIiLmnpquVvXx @@ -815,8 +815,11 @@ converted, it is treated as if it had be .Ss Reserved Words .\" Reserved words are words that have special meaning to the -shell and are recognized at the beginning of a line and -after a control operator. +shell and are recognized, +if completely unquoted, +at the beginning of a line, +after a control operator, +and where the syntax of a command specifically requires a reserved word. The following are reserved words: .Bl -column while while while while -offset indent .It Ic \&! Ta Ic \&{ Ta Ic \&} Ta Ic case @@ -1108,16 +,17 @@ number as a .\" .Ss Path Search .\" -When locating a command, the shell first looks to see if it has a shell -function by that name. -Then it looks for a built-in command by that name. -If a built-in command is not found, one of two things happen: -.Bl -enum -.It -Command names containing a slash are simply executed without performing -any searches. -.It -Otherwise, the shell searches each entry in +When locating a command, +command names containing a slash +.Pq Sq \&/ +are simply executed without performing any searches. +.Pp +If there is no slash in the name, +the shell first looks to see if it is a special built-in command, +if not it looks to see if there is a shell function by that name. +If that fails it looks for an ordinary built-in command. +If a none of these searches located the command +the shell searches each entry in .Ev PATH in turn for the command. The value of the @@ -1541,7 +1545,34 @@ The syntax of a function definition is .Dl Ar name Ns Ic \&() Ar command Op Ar redirect No ... .Pp A function definition is an executable statement; when executed it -installs a function named name and returns an exit status of zero. +installs a function named +.Ar name +and returns an exit status of zero. +To be portable, and standards compliant, the name must use the same +syntax as a variable name, (see +.Sx "Variables and Parameters" +below). +As an extension, this shell allows almost all characters in +.Ar name +.Po +the exception is slash +.Pq Sq \&/ +as there is no way to invoke a function with a name containing +a slash +.Pc . +Including quoting, whitespace, and operator characters requires +that the word be quoted. +The +.Ar name +is subject to quote removal, but no other expansions. +Because of implementation issues, +unquoted dollar signs +.Pq Sq \&$ +and backquotes +.Pq Sq \&` +are prohibited, +but can be included in a function name by use of quoting. +.Pp The command is normally a list enclosed between .Dq { and @@ -1748,12 +1779,15 @@ The order of word expansion is: .Bl -enum .It Tilde Expansion, Parameter Expansion, Command Substitution, -Arithmetic Expansion (these all occur at the same time). +Arithmetic Expansion (these all occur at the same time, and the +result of any of these expansions is not rescanned for further +instances of the expansion, or any of the others). .It -Field Splitting is performed on fields -generated by step (1) unless the +Unless the .Ev IFS -variable is null. +variable has an empty value, +Field Splitting is performed on fields +generated by step (1) except for Tilde Expansion. .It Pathname Expansion (unless set .Fl f @@ -1821,8 +1855,15 @@ If a parameter expansion occurs inside d pathname expansion is not performed on the results of the expansion; .It field splitting is not performed on the results of the -expansion, with the exception of the special
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Thu Aug 20 23:09:56 UTC 2020 Modified Files: src/bin/sh: eval.c trap.c Log Message: Be less conservative about when we do clear_traps() when we have traps_invalid (that is, when we actually nuke the parent shell's caught traps in a subshell). This allows more reasonable use of "trap -p" (and similar) in subshells than existed before (and in particular, that command can be in a function now - there can also be several related commands like traps=$(trap -p INT; trap -p QUIT; trap -p HUP) A side effect of all of this is that (eval "$(trap -p)"; ...) now allows copying caught traps into a subshell environment, if desired. Also att the ksh93 variant (the one not picked by POSIX as it isn't generally as useful) of "trap -p" (but call it "trap -P" which extracts just the trap action for named signals (giving more than one is usually undesirable). This allows eval "$(trap -P INT)" to run the action for SIGINT traps, without needing to attempt to parse the "trap -p" output. To generate a diff of this commit: cvs rdiff -u -r1.180 -r1.181 src/bin/sh/eval.c cvs rdiff -u -r1.54 -r1.55 src/bin/sh/trap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/eval.c diff -u src/bin/sh/eval.c:1.180 src/bin/sh/eval.c:1.181 --- src/bin/sh/eval.c:1.180 Thu May 14 08:34:17 2020 +++ src/bin/sh/eval.c Thu Aug 20 23:09:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: eval.c,v 1.180 2020/05/14 08:34:17 msaitoh Exp $ */ +/* $NetBSD: eval.c,v 1.181 2020/08/20 23:09:56 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95"; #else -__RCSID("$NetBSD: eval.c,v 1.180 2020/05/14 08:34:17 msaitoh Exp $"); +__RCSID("$NetBSD: eval.c,v 1.181 2020/08/20 23:09:56 kre Exp $"); #endif #endif /* not lint */ @@ -280,8 +280,10 @@ evaltree(union node *n, int flags) next = NULL; CTRACE(DBG_EVAL, ("pid %d, evaltree(%p: %s(%d), %#x) called\n", getpid(), n, NODETYPENAME(n->type), n->type, flags)); + /* if (n->type != NCMD && traps_invalid) free_traps(); + */ switch (n->type) { case NSEMI: evaltree(n->nbinary.ch1, sflags); @@ -302,6 +304,8 @@ evaltree(union node *n, int flags) next = n->nbinary.ch2; break; case NREDIR: + if (traps_invalid) +free_traps(); evalredir(n, flags); break; case NSUBSHELL: @@ -309,9 +313,13 @@ evaltree(union node *n, int flags) do_etest = !(flags & EV_TESTED); break; case NBACKGND: + if (traps_invalid) +free_traps(); evalsubshell(n, flags); break; case NIF: { + if (traps_invalid) +free_traps(); evaltree(n->nif.test, EV_TESTED); if (nflag || evalskip) goto out1; @@ -325,15 +333,23 @@ evaltree(union node *n, int flags) } case NWHILE: case NUNTIL: + if (traps_invalid) +free_traps(); evalloop(n, sflags); break; case NFOR: + if (traps_invalid) +free_traps(); evalfor(n, sflags); break; case NCASE: + if (traps_invalid) +free_traps(); evalcase(n, sflags); break; case NDEFUN: + if (traps_invalid) +free_traps(); CTRACE(DBG_EVAL, ("Defining fn %s @%d%s\n", n->narg.text, n->narg.lineno, fnline1 ? " LINENO=1" : "")); @@ -350,6 +366,8 @@ evaltree(union node *n, int flags) exitstatus = 1; break; case NPIPE: + if (traps_invalid) +free_traps(); evalpipe(n); do_etest = !(flags & EV_TESTED); break; @@ -1043,6 +1061,10 @@ evalcommand(union node *cmd, int flgs, s * command eval trap * eval command trap * without zapping the traps completely, in all other cases we do. + * Function calls also do not zap the traps (but commands they execute + * probably will) - this allows a function like + * trapstate() { trap -p; } + * called as save_traps=$(trapstate). * * The test here permits eval "anything" but when evalstring() comes * back here again, the "anything" will be validated. @@ -1055,6 +1077,7 @@ evalcommand(union node *cmd, int flgs, s * trapcmd() takes care of doing free_traps() if it is needed there. */ if (traps_invalid && + cmdentry.cmdtype != CMDFUNCTION && ((cmdentry.cmdtype!=CMDSPLBLTIN && cmdentry.cmdtype!=CMDBUILTIN) || (cmdentry.u.bltin != trapcmd && cmdentry.u.bltin != evalcmd))) free_traps(); Index: src/bin/sh/trap.c diff -u src/bin/sh/trap.c:1.54 src/bin/sh/trap.c:1.55 --- src/bin/sh/trap.c:1.54 Thu Aug 20 16:15:50 2020 +++ src/bin/sh/trap.c Thu Aug 20 23:09:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.54 2020/08/20 16:15:50 kre Exp $ */ +/* $NetBSD: trap.c,v 1.55 2020/08/20 23:09:56 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95"; #else -__RCSID("$NetBSD: trap.c,v 1.54 2020/08/20 16:15:50 kre Exp $"); +__RCSID("$NetBSD: trap.c,v 1.55
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Thu Aug 20 23:03:17 UTC 2020 Modified Files: src/bin/sh: jobs.c Log Message: Add lots of comments explaining what is happening in here. Also enhance some of the DEBUG mode trace output (nothing visible in a normal shell build). A couple of very minor code changes that no-one should ever notice (eg: one less wait() call in the case that there is nothing pending). To generate a diff of this commit: cvs rdiff -u -r1.107 -r1.108 src/bin/sh/jobs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/jobs.c diff -u src/bin/sh/jobs.c:1.107 src/bin/sh/jobs.c:1.108 --- src/bin/sh/jobs.c:1.107 Fri Feb 7 02:06:12 2020 +++ src/bin/sh/jobs.c Thu Aug 20 23:03:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: jobs.c,v 1.107 2020/02/07 02:06:12 kre Exp $ */ +/* $NetBSD: jobs.c,v 1.108 2020/08/20 23:03:17 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: jobs.c,v 1.107 2020/02/07 02:06:12 kre Exp $"); +__RCSID("$NetBSD: jobs.c,v 1.108 2020/08/20 23:03:17 kre Exp $"); #endif #endif /* not lint */ @@ -380,6 +380,18 @@ restartjob(struct job *jp) return; INTOFF; for (e = i = 0; i < jp->nprocs; i++) { + /* + * Don't touch a process we already waited for and collected + * exit status, that pid may have been reused for something + * else - even another of our jobs + */ + if (jp->ps[i].status != -1 && !WIFSTOPPED(jp->ps[i].status)) + continue; + + /* + * Otherwise tell it to continue, if it worked, we're done + * (we signal the whole process group) + */ if (killpg(jp->ps[i].pid, SIGCONT) != -1) break; if (e == 0 && errno != ESRCH) @@ -387,6 +399,11 @@ restartjob(struct job *jp) } if (i >= jp->nprocs) error("Cannot continue job (%s)", strerror(e ? e : ESRCH)); + + /* + * Now change state of all stopped processes in the job to running + * If there were any, the job is now running as well. + */ for (ps = jp->ps, i = jp->nprocs ; --i >= 0 ; ps++) { if (WIFSTOPPED(ps->status)) { VTRACE(DBG_JOBS, ( @@ -570,10 +587,10 @@ showjobs(struct output *out, int mode) CTRACE(DBG_JOBS, ("showjobs(%x) called\n", mode)); - /* If not even one one job changed, there is nothing to do */ - gotpid = dowait(WSILENT, NULL, NULL); - while (dowait(WSILENT, NULL, NULL) > 0) - continue; + /* Collect everything pending in the kernel */ + if ((gotpid = dowait(WSILENT, NULL, NULL)) > 0) + while (dowait(WSILENT, NULL, NULL) > 0) + continue; #ifdef JOBS /* * Check if we are not in our foreground group, and if not @@ -813,19 +830,25 @@ waitcmd(int argc, char **argv) /* * There is at least 1 job running, so we can - * safely wait() for something to exit. + * safely wait() (blocking) for something to exit. */ if (jp->state == JOBRUNNING) { job = NULL; if ((i = dowait(WBLOCK|WNOFREE, NULL, )) == -1) return 128 + lastsig(); - if (job == NULL) /* an interloper */ + /* + * This happens if an interloper has died + * (eg: a child of the executable that exec'd us) + * Simply go back and start all over again + * (this is rare). + */ + if (job == NULL) continue; /* - * one of the job's processes exited, - * but there are more + * one of the reported job's processes exited, + * but there are more still running, back for more */ if (job->state == JOBRUNNING) continue; @@ -1314,7 +1337,17 @@ waitforjob(struct job *jp) /* - * Wait for a process to terminate. + * Wait for a process (any process) to terminate. + * + * If "job" is given (not NULL), then its jobcontrol status (and mflag) + * are used to determine if we wait for stopping/continuing processes or + * only terminating ones, and the decision whether to report to stdout + * or not varies depending what happened, and whether the affected job + * is the one that was requested or not. + * + * If "changed" is not NULL, then the job which changed because a + * process terminated/stopped will be reported by setting *changed, + * if there is any such job, otherwise we set *changed = NULL. */ STATIC int @@ -1327,53 +1360,123 @@ dowait(int flags, struct job *job, struc struct job *thisjob; int done; int stopped; + int err; - VTRACE(DBG_JOBS|DBG_PROCS, ("dowait(%x) called\n", flags)); + VTRACE(DBG_JOBS|DBG_PROCS, ("dowait(%x) called for job %d%s\n", + flags, (job ? job-jobtab+1 : 0), changed ? " [report change]":"")); if (changed != NULL) *changed = NULL; + /* + * First deal with the kernel, collect info on any (one) of our + * children that has changed state since we last asked. + * (loop if we're interrupted by a signal that we aren't processing) + */ do { + err = 0; pid = waitproc(flags & WBLOCK, job, ); - VTRACE(DBG_JOBS|DBG_PROCS, ("wait returns pid %d,
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Thu Aug 20 23:03:08 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Add missing description for wgconfig `set private-key' command. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.8 diff -u src/usr.sbin/wgconfig/wgconfig.8:1.4 src/usr.sbin/wgconfig/wgconfig.8:1.5 --- src/usr.sbin/wgconfig/wgconfig.8:1.4 Thu Aug 20 23:01:20 2020 +++ src/usr.sbin/wgconfig/wgconfig.8 Thu Aug 20 23:03:08 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: wgconfig.8,v 1.4 2020/08/20 23:01:20 riastradh Exp $ +.\" $NetBSD: wgconfig.8,v 1.5 2020/08/20 23:03:08 riastradh Exp $ .\" .\" Copyright (C) Ryota Ozaki .\" All rights reserved. @@ -90,6 +90,11 @@ option to .It Cm "show private-key" Show the private key that was set with .Nm Ar wgN Cm "set private-key" . +.It Cm "set private-key" Ar filename +Set the private key of +.Ar wgN +to the base64-encoded private key in the file at +.Ar filename . .It Cm "set listen-port" Ar port Set the UDP port number that .Ar wgN
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Thu Aug 20 23:01:20 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Mark up argument as such and write out wgconfig command correctly. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.8 diff -u src/usr.sbin/wgconfig/wgconfig.8:1.3 src/usr.sbin/wgconfig/wgconfig.8:1.4 --- src/usr.sbin/wgconfig/wgconfig.8:1.3 Thu Aug 20 22:58:06 2020 +++ src/usr.sbin/wgconfig/wgconfig.8 Thu Aug 20 23:01:20 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: wgconfig.8,v 1.3 2020/08/20 22:58:06 riastradh Exp $ +.\" $NetBSD: wgconfig.8,v 1.4 2020/08/20 23:01:20 riastradh Exp $ .\" .\" Copyright (C) Ryota Ozaki .\" All rights reserved. @@ -96,7 +96,7 @@ Set the UDP port number that listens for incoming WireGuard sessions on. This allows a peer to start a new session without having a specific endpoint IP address configured. -.It Cm "add peer" Ar name Ar pubkey Op options... +.It Cm "add peer" Ar name Ar pubkey Op Ar options... Add a peer. The argument .Ar name @@ -134,7 +134,7 @@ tunnel. Delete the peer .Ar name previously added with -.Nm Cm "add peer" Ar name . +.Nm Ar wgN Cm "add peer" Ar name . .El .\" .Sh EXAMPLES
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Thu Aug 20 22:58:06 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Tweak markup so the square brackets don't become bold. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.8 diff -u src/usr.sbin/wgconfig/wgconfig.8:1.2 src/usr.sbin/wgconfig/wgconfig.8:1.3 --- src/usr.sbin/wgconfig/wgconfig.8:1.2 Thu Aug 20 21:36:00 2020 +++ src/usr.sbin/wgconfig/wgconfig.8 Thu Aug 20 22:58:06 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: wgconfig.8,v 1.2 2020/08/20 21:36:00 riastradh Exp $ +.\" $NetBSD: wgconfig.8,v 1.3 2020/08/20 22:58:06 riastradh Exp $ .\" .\" Copyright (C) Ryota Ozaki .\" All rights reserved. @@ -38,7 +38,8 @@ .Sh SYNOPSIS .Nm Ar wgN Op Cm "show all" .\" -.Nm Ar wgN Cm "show peer" Ar name Op Fl Fl show-preshared-key +.Nm Ar wgN Cm "show peer" Ar name +.Op Fl Fl show-preshared-key .\" .Nm Ar wgN Cm "show private-key" .\"
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kre Date: Thu Aug 20 22:56:56 UTC 2020 Modified Files: src/lib/libc/gen: signalname.3 signalnumber.c Log Message: When not compiling -DSMALL permit use of names RTMIN[+n] and RTMAX[-n] (where n is a decimal integer in the range [0 .. SIGRTMAX-SIGRTMIN]. As usual a leading "sig" is ignored and the strings are case independent. Some implementations do not name the real time signals, and using labels like RTMIN+3 can be the only way they can be manipulated, so allow that technique (we still return the RTnn names on the inverse translation though). Because this is used by both kill(1) and sh(1) the kill and trap commands both gain access to the new notation (when !SMALL). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/lib/libc/gen/signalname.3 \ src/lib/libc/gen/signalnumber.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/signalname.3 diff -u src/lib/libc/gen/signalname.3:1.2 src/lib/libc/gen/signalname.3:1.3 --- src/lib/libc/gen/signalname.3:1.2 Sun May 14 12:35:46 2017 +++ src/lib/libc/gen/signalname.3 Thu Aug 20 22:56:56 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: signalname.3,v 1.2 2017/05/14 12:35:46 wiz Exp $ +.\" $NetBSD: signalname.3,v 1.3 2020/08/20 22:56:56 kre Exp $ .\" .\" Available to all and sundry, without restriction on use, or other .\" limitations, and without fee. Also without any warranty of fitness @@ -76,6 +76,17 @@ prefix in .Fa name is ignored. .Pp +This implementation also accepts +.Dv rtmax Ns \&[\-n] +and +.Dv rtmin Ns \&[+n] +.Po +where the optional +.Ar n +is a decimal integer between 0 and SIGRTMAX\-SIGRTMIN +.Pc +to refer to the real time signals. +.Pp The .Fn signalnumber function returns the signal number, @@ -93,7 +104,8 @@ signal number. .Pp The .Fn signalnext -function returns minus one (\-1) on error, if the given signal +function returns minus one (\-1) on error, +that is, if the given signal .Fa sig is neither a valid signal number nor zero. It returns zero when the input signal number, Index: src/lib/libc/gen/signalnumber.c diff -u src/lib/libc/gen/signalnumber.c:1.2 src/lib/libc/gen/signalnumber.c:1.3 --- src/lib/libc/gen/signalnumber.c:1.2 Thu Jan 4 20:57:29 2018 +++ src/lib/libc/gen/signalnumber.c Thu Aug 20 22:56:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: signalnumber.c,v 1.2 2018/01/04 20:57:29 kamil Exp $ */ +/* $NetBSD: signalnumber.c,v 1.3 2020/08/20 22:56:56 kre Exp $ */ /* * Software available to all and sundry without limitations @@ -20,7 +20,9 @@ #include "namespace.h" #include +#include #include +#include /* * signalnumber() @@ -42,6 +44,10 @@ int signalnumber(const char *name) { int i; +#ifndef SMALL + long offs; + char *ep; +#endif if (strncasecmp(name, "sig", 3) == 0) name += 3; @@ -50,5 +56,36 @@ signalnumber(const char *name) if (sys_signame[i] != NULL && strcasecmp(name, sys_signame[i]) == 0) return i; + +#ifndef SMALL + if (strncasecmp(name, "rtm", 3) == 0) { + name += 3; + if (strncasecmp(name, "ax", 2) == 0) + i = SIGRTMAX; + else if (strncasecmp(name, "in", 2) == 0) + i = SIGRTMIN; + else + return 0; + name += 2; + if (name[0] == '\0') + return i; + if (i == SIGRTMAX && name[0] != '-') + return 0; + if (i == SIGRTMIN && name[0] != '+') + return 0; + if (!isdigit((unsigned char)name[1])) + return 0; + offs = strtol(name+1, , 10); + if (ep == name+1 || *ep != '\0' || + offs < 0 || offs > SIGRTMAX-SIGRTMIN) + return 0; + if (name[0] == '+') + i += (int)offs; + else + i -= (int)offs; + if (i >= SIGRTMIN && i <= SIGRTMAX) + return i; + } +#endif return 0; }
CVS commit: src/share/man/man4
Module Name:src Committed By: riastradh Date: Thu Aug 20 22:20:50 UTC 2020 Modified Files: src/share/man/man4: wg.4 Log Message: Slightly less indentation. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/share/man/man4/wg.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man4/wg.4 diff -u src/share/man/man4/wg.4:1.2 src/share/man/man4/wg.4:1.3 --- src/share/man/man4/wg.4:1.2 Thu Aug 20 22:19:56 2020 +++ src/share/man/man4/wg.4 Thu Aug 20 22:20:50 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: wg.4,v 1.2 2020/08/20 22:19:56 riastradh Exp $ +.\" $NetBSD: wg.4,v 1.3 2020/08/20 22:20:50 riastradh Exp $ .\" .\" Copyright (c) 2020 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -70,7 +70,7 @@ endpoint IP address outside the tunnel. .\" .Sh EXAMPLES Typical network topology: -.Bd -literal -offset abcdefgh +.Bd -literal -offset abcd wm0 = 1.2.3.4 bge0 = 4.3.2.1 Stationary server: Roaming client: @@ -90,7 +90,7 @@ Stationary server: .Ed .Pp Generate key pairs on A and B: -.Bd -literal -offset abcdefgh +.Bd -literal -offset abcd A# wg-keygen > /etc/wireguard/wg0 A# wg-keygen --pub < /etc/wireguard/wg0 > /etc/wireguard/wg0.pub A# cat /etc/wireguard/wg0.pub @@ -104,7 +104,7 @@ X7EGm3T3IfodBcyilkaC89j0SH3XD6+/pwvp7Dgp .Pp Configure A to listen on port 1234 and allow connections from B to appear in the 10.0.1.0/24 subnet: -.Bd -literal -offset abcdefgh +.Bd -literal -offset abcd A# ifconfig wg0 create 10.0.1.0/24 A# wgconfig wg0 set private-key /etc/wireguard/wg0 A# wgconfig wg0 set listen-port 1234 @@ -119,7 +119,7 @@ wg0: flags=0x51 .Pp Configure B to connect to A at 1.2.3.4 on port 1234 and the packets can begin to flow: -.Bd -literal -offset abcdefgh +.Bd -literal -offset abcd B# ifconfig wg0 create 10.0.1.1/24 B# wgconfig wg0 set private-key /etc/wireguard/wg0 B# wgconfig wg0 add peer A \e
CVS commit: src/share/man/man4
Module Name:src Committed By: riastradh Date: Thu Aug 20 22:19:57 UTC 2020 Modified Files: src/share/man/man4: wg.4 Log Message: Fix self-xref. Indent example displays. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/share/man/man4/wg.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man4/wg.4 diff -u src/share/man/man4/wg.4:1.1 src/share/man/man4/wg.4:1.2 --- src/share/man/man4/wg.4:1.1 Thu Aug 20 21:36:00 2020 +++ src/share/man/man4/wg.4 Thu Aug 20 22:19:56 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: wg.4,v 1.1 2020/08/20 21:36:00 riastradh Exp $ +.\" $NetBSD: wg.4,v 1.2 2020/08/20 22:19:56 riastradh Exp $ .\" .\" Copyright (c) 2020 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -51,7 +51,7 @@ with the peer, and the encapsulation is UDP. .Pp Every -.Xr wg 4 +.Nm interface can be configured with an IP address using .Xr ifconfig 8 , a private key generated with @@ -70,7 +70,7 @@ endpoint IP address outside the tunnel. .\" .Sh EXAMPLES Typical network topology: -.Bd -literal +.Bd -literal -offset abcdefgh wm0 = 1.2.3.4 bge0 = 4.3.2.1 Stationary server: Roaming client: @@ -90,7 +90,7 @@ Stationary server: .Ed .Pp Generate key pairs on A and B: -.Bd -literal +.Bd -literal -offset abcdefgh A# wg-keygen > /etc/wireguard/wg0 A# wg-keygen --pub < /etc/wireguard/wg0 > /etc/wireguard/wg0.pub A# cat /etc/wireguard/wg0.pub @@ -104,7 +104,7 @@ X7EGm3T3IfodBcyilkaC89j0SH3XD6+/pwvp7Dgp .Pp Configure A to listen on port 1234 and allow connections from B to appear in the 10.0.1.0/24 subnet: -.Bd -literal +.Bd -literal -offset abcdefgh A# ifconfig wg0 create 10.0.1.0/24 A# wgconfig wg0 set private-key /etc/wireguard/wg0 A# wgconfig wg0 set listen-port 1234 @@ -119,7 +119,7 @@ wg0: flags=0x51 .Pp Configure B to connect to A at 1.2.3.4 on port 1234 and the packets can begin to flow: -.Bd -literal +.Bd -literal -offset abcdefgh B# ifconfig wg0 create 10.0.1.1/24 B# wgconfig wg0 set private-key /etc/wireguard/wg0 B# wgconfig wg0 add peer A \e
CVS commit: src/usr.sbin/wg-userspace
Module Name:src Committed By: riastradh Date: Thu Aug 20 22:17:17 UTC 2020 Modified Files: src/usr.sbin/wg-userspace: wg-userspace.8 Log Message: Fix up wg-userspace(8) man page. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/wg-userspace/wg-userspace.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wg-userspace/wg-userspace.8 diff -u src/usr.sbin/wg-userspace/wg-userspace.8:1.1 src/usr.sbin/wg-userspace/wg-userspace.8:1.2 --- src/usr.sbin/wg-userspace/wg-userspace.8:1.1 Thu Aug 20 21:28:02 2020 +++ src/usr.sbin/wg-userspace/wg-userspace.8 Thu Aug 20 22:17:16 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: wg-userspace.8,v 1.1 2020/08/20 21:28:02 riastradh Exp $ +.\" $NetBSD: wg-userspace.8,v 1.2 2020/08/20 22:17:16 riastradh Exp $ .\" .\" Copyright (C) Ryota Ozaki .\" All rights reserved. @@ -27,28 +27,69 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd February 27, 2019 +.Dd August 20, 2020 .Dt WG-USERSPACE 8 .Os +.\" .Sh NAME .Nm wg-userspace .Nd manipulate WireGuard userspace instances +.\" .Sh SYNOPSIS -.Nm .Ar id +.Ar command .Op Ar arguments +.\" .Sh DESCRIPTION .Nm is used to create, destroy and configure WireGuard userspace instances. +.Pp +The following commands are supported: +.Bl -tag -width "destroy" +.It Cm create +Create a WireGuard interface. +The interface will appear as +.Li tun Ns Ar id +to the rest of the system, and will be served by a rump server in whose +context the interface appears as +.Li wg Ns Ar id . +.It Cm destroy +Destroy a WireGuard interface and stop the rump server behind it. +.It Cm ifconfig Ar wgN Ar args... +Run +.Xr ifconfig 8 +in the context of the WireGuard interface's rump server. +For example, +.Bd -literal -compact + # wg-userspace 0 ifconfig wg0 10.0.1.0/24 +.Ed +will set the WireGuard interface's IP address. +.It Cm wgconfig Ar wgN Ar args... +Run +.Xr wgconfig 8 +in the context of the WireGuard interface's rump server. +For example, +.Bd -literal -compact + # wg-userspace 0 wgconfig wg0 set listen-port 1234 +.Ed +will set the WireGuard interface's listening port. +.It Cm debug Ar command Op Ar args... +Run an arbitrary command in the context of the WireGuard interface's +rump server, using +.Xr rumphijack 3 . +.El +.\" .Sh SEE ALSO .Xr wg 4 , .Xr wg-keygen 8 , .Xr wgconfig 8 +.\" .Sh HISTORY The .Nm command first appeared in -.Nx 9.0 . +.Nx 10.0 . +.\" .Sh AUTHORS The .Nm
CVS commit: src/doc
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:59:55 UTC 2020 Modified Files: src/doc: 3RDPARTY Log Message: 3RDPARTY janitorial service To generate a diff of this commit: cvs rdiff -u -r1.1742 -r1.1743 src/doc/3RDPARTY Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/3RDPARTY diff -u src/doc/3RDPARTY:1.1742 src/doc/3RDPARTY:1.1743 --- src/doc/3RDPARTY:1.1742 Tue Aug 11 13:18:04 2020 +++ src/doc/3RDPARTY Thu Aug 20 21:59:54 2020 @@ -1,4 +1,4 @@ -# $NetBSD: 3RDPARTY,v 1.1742 2020/08/11 13:18:04 christos Exp $ +# $NetBSD: 3RDPARTY,v 1.1743 2020/08/20 21:59:54 riastradh Exp $ # # This file contains a list of the software that has been integrated into # NetBSD where we are not the primary maintainer. @@ -2204,45 +2204,58 @@ Date: 2019-11-27 Mailing List: bug-ncur...@gnu.org Responsible: License: none -Location: sys/external/bsd/ena-com +Location: share/terminfo Notes: Use the import script in /usr/src/share/terminfo Package: libcbor -Version: 20200302 -Current Vers: 20200302 +Version: 0.7.0 +Current Vers: 0.5.0-119-g3b41770 (3b41770ab0ca408d242041dddb3b75811345573f) Maintainer: Pavel Kalvoda -Archive Site: https://github.com/PJK/libcbor.git -Home Page: +Archive Site: https://github.com/PJK/libcbor +Home Page: Date: 2020-03-02 -Mailing List: christos -Responsible: +Mailing List: +Responsible: christos License: mit -Location: sys/external/mit/libcbor +Location: external/mit/libcbor Notes: Package: pam-u2f -Version: 1.0.8 +Version: 1.0.8-73-gd10f843 (d10f84314c55f10d244bc275794e783dc408e45c) Current Vers: 1.0.8 Maintainer: Yubico -Archive Site: https://github.com/Yubico/pam-u2f.git +Archive Site: https://github.com/Yubico/pam-u2f Home Page: https://developers.yubico.com/pam-u2f/ Date: 2020-06-13 -Mailing List: christos -Responsible: +Mailing List: +Responsible: christos License: bsd -Location: sys/external/bsd/pam-u2f +Location: external/bsd/pam-u2f Notes: Package: libfido2 -Version: 0.5.0 +Version: 1.3.0-155-gf6ab2ce (f6ab2ce65745f7f3b1bee7481623de5eaac28bb0) Current Vers: 1.4.0 Maintainer: Yubico -Archive Site: https://github.com/Yubico/libfido2.git -Home Page: https://developers.yubico.com/libfido2/Manuals/ +Archive Site: https://github.com/Yubico/libfido2 +Home Page: https://developers.yubico.com/libfido2/ Date: 2020-06-13 -Mailing List: christos -Responsible: +Mailing List: +Responsible: christos +License: bsd +Location: external/bsd/libfido2 +Notes: + +Package: libsodium +Version: 1.0.16 +Current Vers: 1.0.18 +Maintainer: Frank Denis +Archive Site: https://github.com/jedisct1/libsodium +Home Page: https://libsodium.org/ +Date: 2020-08-20 +Mailing List: sodium-subscr...@pureftpd.org +Responsible: riastradh License: bsd -Location: sys/external/bsd/libfido2 +Location: sys/external/bsd/libsodium Notes:
CVS commit: src/doc
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:45:46 UTC 2020 Modified Files: src/doc: CHANGES Log Message: Note WireGuard. (ozaki-r did the vast majority of the actual implementation in 2018; I just dusted it off and imported it.) To generate a diff of this commit: cvs rdiff -u -r1.2731 -r1.2732 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.2731 src/doc/CHANGES:1.2732 --- src/doc/CHANGES:1.2731 Mon Aug 17 04:16:24 2020 +++ src/doc/CHANGES Thu Aug 20 21:45:46 2020 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2731 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2732 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -273,3 +273,4 @@ Changes from NetBSD 9.0 to NetBSD 10.0: kernel: Add getrandom system call. [riastradh 20200813] kernel: Disable COMPAT_LINUX by default [jdolecek 20200816] mips: Port crash(8) to mips. [mrg 20200816] + wg(4): Add support for WireGuard. [ozaki-r 20200820]
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:35:33 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: Sprinkle const. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.16 src/sys/net/if_wg.c:1.17 --- src/sys/net/if_wg.c:1.16 Thu Aug 20 21:35:24 2020 +++ src/sys/net/if_wg.c Thu Aug 20 21:35:33 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.16 2020/08/20 21:35:24 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.17 2020/08/20 21:35:33 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.16 2020/08/20 21:35:24 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.17 2020/08/20 21:35:33 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1235,7 +1235,7 @@ wg_fill_msg_init(struct wg_softc *wg, st /* [W] 5.4.4 Cookie MACs */ wg_algo_mac_mac1(wgmi->wgmi_mac1, sizeof(wgmi->wgmi_mac1), wgp->wgp_pubkey, sizeof(wgp->wgp_pubkey), - (uint8_t *)wgmi, offsetof(struct wg_msg_init, wgmi_mac1)); + (const uint8_t *)wgmi, offsetof(struct wg_msg_init, wgmi_mac1)); /* Need mac1 to decrypt a cookie from a cookie message */ memcpy(wgp->wgp_last_sent_mac1, wgmi->wgmi_mac1, sizeof(wgp->wgp_last_sent_mac1)); @@ -1247,7 +1247,8 @@ wg_fill_msg_init(struct wg_softc *wg, st else { wg_algo_mac(wgmi->wgmi_mac2, sizeof(wgmi->wgmi_mac2), wgp->wgp_latest_cookie, WG_COOKIE_LEN, - (uint8_t *)wgmi, offsetof(struct wg_msg_init, wgmi_mac2), + (const uint8_t *)wgmi, + offsetof(struct wg_msg_init, wgmi_mac2), NULL, 0); } @@ -1646,7 +1647,7 @@ wg_fill_msg_resp(struct wg_softc *wg, st /* msg.mac1 := MAC(HASH(LABEL-MAC1 || Sm'^pub), msg_a) */ wg_algo_mac_mac1(wgmr->wgmr_mac1, sizeof(wgmi->wgmi_mac1), wgp->wgp_pubkey, sizeof(wgp->wgp_pubkey), - (uint8_t *)wgmr, offsetof(struct wg_msg_resp, wgmr_mac1)); + (const uint8_t *)wgmr, offsetof(struct wg_msg_resp, wgmr_mac1)); /* Need mac1 to decrypt a cookie from a cookie message */ memcpy(wgp->wgp_last_sent_mac1, wgmr->wgmr_mac1, sizeof(wgp->wgp_last_sent_mac1)); @@ -1660,7 +1661,8 @@ wg_fill_msg_resp(struct wg_softc *wg, st /* msg.mac2 := MAC(Lm, msg_b) */ wg_algo_mac(wgmr->wgmr_mac2, sizeof(wgmi->wgmi_mac2), wgp->wgp_latest_cookie, WG_COOKIE_LEN, - (uint8_t *)wgmr, offsetof(struct wg_msg_resp, wgmr_mac2), + (const uint8_t *)wgmr, + offsetof(struct wg_msg_resp, wgmr_mac2), NULL, 0); } @@ -1953,8 +1955,8 @@ wg_fill_msg_cookie(struct wg_softc *wg, } wg_algo_mac(cookie, sizeof(cookie), - (uint8_t *)>wgp_randval, sizeof(wgp->wgp_randval), - addr, addrlen, (uint8_t *)_sport, sizeof(uh_sport)); + (const uint8_t *)>wgp_randval, sizeof(wgp->wgp_randval), + addr, addrlen, (const uint8_t *)_sport, sizeof(uh_sport)); wg_algo_mac_cookie(key, sizeof(key), wg->wg_pubkey, sizeof(wg->wg_pubkey)); wg_algo_xaead_enc(wgmc->wgmc_cookie, sizeof(wgmc->wgmc_cookie), key, @@ -2133,15 +2135,15 @@ wg_change_endpoint(struct wg_peer *wgp, } static bool -wg_validate_inner_packet(char *packet, size_t decrypted_len, int *af) +wg_validate_inner_packet(const char *packet, size_t decrypted_len, int *af) { uint16_t packet_len; - struct ip *ip; + const struct ip *ip; if (__predict_false(decrypted_len < sizeof(struct ip))) return false; - ip = (struct ip *)packet; + ip = (const struct ip *)packet; if (ip->ip_v == 4) *af = AF_INET; else if (ip->ip_v == 6) @@ -2154,12 +2156,12 @@ wg_validate_inner_packet(char *packet, s if (*af == AF_INET) { packet_len = ntohs(ip->ip_len); } else { - struct ip6_hdr *ip6; + const struct ip6_hdr *ip6; if (__predict_false(decrypted_len < sizeof(struct ip6_hdr))) return false; - ip6 = (struct ip6_hdr *)packet; + ip6 = (const struct ip6_hdr *)packet; packet_len = sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen); } @@ -2188,13 +2190,13 @@ wg_validate_route(struct wg_softc *wg, s */ if (af == AF_INET) { - struct ip *ip = (struct ip *)packet; + const struct ip *ip = (const struct ip *)packet; struct sockaddr_in *sin = (struct sockaddr_in *) sockaddr_in_init(sin, >ip_src, 0); sa = sintosa(sin); #ifdef INET6 } else { - struct ip6_hdr *ip6 = (struct ip6_hdr *)packet; + const struct ip6_hdr *ip6 = (const struct ip6_hdr *)packet; struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sockaddr_in6_init(sin6, >ip6_src, 0, 0, 0); sa = sin6tosa(sin6); @@ -3757,9 +3759,9 @@ wg_handle_prop_peer(struct wg_softc *wg, case AF_INET: { struct sockaddr_in sin; sockaddr_copy(sintosa(), sizeof(sin), - (struct sockaddr *)); + (const struct sockaddr *)); sockaddr_copy(sintosa(>wgp_sin), - sizeof(wgp->wgp_sin),
CVS commit: src
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:36:00 UTC 2020 Modified Files: src/distrib/sets/lists/man: mi src/share/man/man4: Makefile src/usr.sbin/wg-keygen: wg-keygen.8 src/usr.sbin/wgconfig: wgconfig.8 Added Files: src/share/man/man4: wg.4 Log Message: Fill out WireGuard man pages. To generate a diff of this commit: cvs rdiff -u -r1.1698 -r1.1699 src/distrib/sets/lists/man/mi cvs rdiff -u -r1.706 -r1.707 src/share/man/man4/Makefile cvs rdiff -u -r0 -r1.1 src/share/man/man4/wg.4 cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/wg-keygen/wg-keygen.8 cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/man/mi diff -u src/distrib/sets/lists/man/mi:1.1698 src/distrib/sets/lists/man/mi:1.1699 --- src/distrib/sets/lists/man/mi:1.1698 Thu Aug 20 21:28:01 2020 +++ src/distrib/sets/lists/man/mi Thu Aug 20 21:35:59 2020 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1698 2020/08/20 21:28:01 riastradh Exp $ +# $NetBSD: mi,v 1.1699 2020/08/20 21:35:59 riastradh Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -2032,6 +2032,7 @@ ./usr/share/man/cat4/wds.0 man-sys-catman .cat ./usr/share/man/cat4/we.0 man-sys-catman .cat ./usr/share/man/cat4/wedge.0 man-sys-catman .cat +./usr/share/man/cat4/wg.0 man-sys-catman .cat ./usr/share/man/cat4/wi.0 man-sys-catman .cat ./usr/share/man/cat4/wm.0 man-sys-catman .cat ./usr/share/man/cat4/wmidell.0 man-sys-catman .cat @@ -5165,6 +5166,7 @@ ./usr/share/man/html4/wds.html man-sys-htmlman html ./usr/share/man/html4/we.html man-sys-htmlman html ./usr/share/man/html4/wedge.html man-sys-htmlman html +./usr/share/man/html4/wg.html man-sys-htmlman html ./usr/share/man/html4/wi.html man-sys-htmlman html ./usr/share/man/html4/wm.html man-sys-htmlman html ./usr/share/man/html4/wmidell.html man-sys-htmlman html @@ -8230,6 +8232,7 @@ ./usr/share/man/man4/wds.4 man-sys-man .man ./usr/share/man/man4/we.4 man-sys-man .man ./usr/share/man/man4/wedge.4 man-sys-man .man +./usr/share/man/man4/wg.4 man-sys-man .man ./usr/share/man/man4/wi.4 man-sys-man .man ./usr/share/man/man4/wm.4 man-sys-man .man ./usr/share/man/man4/wmidell.4 man-sys-man .man Index: src/share/man/man4/Makefile diff -u src/share/man/man4/Makefile:1.706 src/share/man/man4/Makefile:1.707 --- src/share/man/man4/Makefile:1.706 Sun Jul 26 15:13:09 2020 +++ src/share/man/man4/Makefile Thu Aug 20 21:36:00 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.706 2020/07/26 15:13:09 jdolecek Exp $ +# $NetBSD: Makefile,v 1.707 2020/08/20 21:36:00 riastradh Exp $ # @(#)Makefile 8.1 (Berkeley) 6/18/93 MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \ @@ -70,7 +70,7 @@ MAN= aac.4 ac97.4 acardide.4 aceride.4 a vald.4 valz.4 veriexec.4 vga.4 vge.4 viaide.4 video.4 \ vio9p.4 vioif.4 viomb.4 viornd.4 vioscsi.4 virt.4 virtio.4 \ vlan.4 vmmon.4 vmnet.4 vnd.4 voodoofb.4 vr.4 vte.4 \ - wapbl.4 wb.4 wbsio.4 wd.4 wdc.4 wi.4 wm.4 wpi.4 \ + wapbl.4 wb.4 wbsio.4 wd.4 wdc.4 wg.4 wi.4 wm.4 wpi.4 \ wsbell.4 wscons.4 wsdisplay.4 wsfont.4 wskbd.4 wsmouse.4 wsmux.4 \ xbox.4 xge.4 \ yds.4 ym.4 \ Index: src/usr.sbin/wg-keygen/wg-keygen.8 diff -u src/usr.sbin/wg-keygen/wg-keygen.8:1.1 src/usr.sbin/wg-keygen/wg-keygen.8:1.2 --- src/usr.sbin/wg-keygen/wg-keygen.8:1.1 Thu Aug 20 21:28:02 2020 +++ src/usr.sbin/wg-keygen/wg-keygen.8 Thu Aug 20 21:36:00 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: wg-keygen.8,v 1.1 2020/08/20 21:28:02 riastradh Exp $ +.\" $NetBSD: wg-keygen.8,v 1.2 2020/08/20 21:36:00 riastradh Exp $ .\" .\" Copyright (C) Ryota Ozaki .\" All rights reserved. @@ -27,29 +27,50 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd December 12, 2018 +.Dd August 20, 2020 .Dt WG-KEYGEN 8 .Os +.\" .Sh NAME .Nm wg-keygen -.Nd generates keys used by WireGuard interfaces. +.Nd generate keys for WireGuard interfaces +.\" .Sh SYNOPSIS .Nm +.Nm Fl Fl pub +.Nm Fl Fl psk +.\" .Sh DESCRIPTION .Nm -generates a private key and a preshared key used by a WireGuard interface. -It also generates a public key from a given private key. +generates keys for WireGuard. +.Bl -tag -width abcd +.It Nm +Generate a private key and print it to standard output. +.It Nm Fl Fl pub +Read a private key from standard input, and print the corresponding +public key to standard output. +.It Nm Fl Fl psk +Generate a preshared key and print it to standard output. +.El +.\" +.Sh EXAMPLES +See +.Xr wg 4
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:35:44 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: Avoid callout_halt under lock. - We could pass the lock in, except we hold another lock too. - We could halt before taking the other lock, but it's not safe to sleep after getting the session pointer before taking its lock. - We could halt before getting the session pointer, but then there's no point in doing it under the lock. So just halt a little earlier instead. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.17 src/sys/net/if_wg.c:1.18 --- src/sys/net/if_wg.c:1.17 Thu Aug 20 21:35:33 2020 +++ src/sys/net/if_wg.c Thu Aug 20 21:35:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.17 2020/08/20 21:35:33 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.18 2020/08/20 21:35:44 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.17 2020/08/20 21:35:33 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.18 2020/08/20 21:35:44 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1829,13 +1829,14 @@ wg_handle_msg_resp(struct wg_softc *wg, wg_clear_states(wgs); WG_TRACE("WGS_STATE_ESTABLISHED"); + wg_stop_handshake_timeout_timer(wgp); + mutex_enter(wgp->wgp_lock); wg_swap_sessions(wgp); wgs_prev = wgp->wgp_session_unstable; mutex_enter(wgs_prev->wgs_lock); getnanotime(>wgp_last_handshake_time); - wg_stop_handshake_timeout_timer(wgp); wgp->wgp_handshake_start_time = 0; wgp->wgp_last_sent_mac1_valid = false; wgp->wgp_last_sent_cookie_valid = false;
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:36:21 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: Mark KASSERT-only variable as __diagused. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.18 src/sys/net/if_wg.c:1.19 --- src/sys/net/if_wg.c:1.18 Thu Aug 20 21:35:44 2020 +++ src/sys/net/if_wg.c Thu Aug 20 21:36:21 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.18 2020/08/20 21:35:44 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.19 2020/08/20 21:36:21 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.18 2020/08/20 21:35:44 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.19 2020/08/20 21:36:21 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -907,7 +907,7 @@ wg_algo_dh(uint8_t out[WG_DH_OUTPUT_LEN] CTASSERT(WG_STATIC_KEY_LEN == crypto_scalarmult_curve25519_BYTES); - int ret = crypto_scalarmult(out, privkey, pubkey); + int ret __diagused = crypto_scalarmult(out, privkey, pubkey); KASSERT(ret == 0); }
CVS commit: src/sys/arch/amd64/conf
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:36:11 UTC 2020 Modified Files: src/sys/arch/amd64/conf: ALL Log Message: Add wg(4) to amd64/ALL. To generate a diff of this commit: cvs rdiff -u -r1.160 -r1.161 src/sys/arch/amd64/conf/ALL Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/conf/ALL diff -u src/sys/arch/amd64/conf/ALL:1.160 src/sys/arch/amd64/conf/ALL:1.161 --- src/sys/arch/amd64/conf/ALL:1.160 Sat Aug 1 12:28:19 2020 +++ src/sys/arch/amd64/conf/ALL Thu Aug 20 21:36:11 2020 @@ -1,4 +1,4 @@ -# $NetBSD: ALL,v 1.160 2020/08/01 12:28:19 jdolecek Exp $ +# $NetBSD: ALL,v 1.161 2020/08/20 21:36:11 riastradh Exp $ # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp # # ALL machine description file @@ -17,7 +17,7 @@ include "arch/amd64/conf/std.amd64" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "ALL-$Revision: 1.160 $" +#ident "ALL-$Revision: 1.161 $" maxusers 64 # estimated number of users @@ -1641,6 +1641,7 @@ pseudo-device npf # NPF packet filter pseudo-device kttcp # srt is EXPERIMENTAL pseudo-device srt # source-address-based routing +pseudo-device wg # WireGuard pseudo-device canloop # CAN loopback interface
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:34:32 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: Take advantage of prop_dictionary_util(3). To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.11 src/sys/net/if_wg.c:1.12 --- src/sys/net/if_wg.c:1.11 Thu Aug 20 21:34:23 2020 +++ src/sys/net/if_wg.c Thu Aug 20 21:34:32 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.11 2020/08/20 21:34:23 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.12 2020/08/20 21:34:32 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.11 2020/08/20 21:34:23 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.12 2020/08/20 21:34:32 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -3693,34 +3693,29 @@ wg_handle_prop_peer(struct wg_softc *wg, struct wg_peer **wgpp) { int error = 0; - prop_object_t prop_obj; - const char *pubkey; + const void *pubkey; size_t pubkey_len; + const void *psk; + size_t psk_len; const char *name = NULL; - prop_obj = prop_dictionary_get(peer, "name"); - if (prop_obj != NULL) { - name = prop_string_value(prop_obj); + if (prop_dictionary_get_string(peer, "name", )) { if (strlen(name) > WG_PEER_NAME_MAXLEN) { error = EINVAL; goto out; } } - prop_obj = prop_dictionary_get(peer, "public_key"); - if (prop_obj == NULL) { + if (!prop_dictionary_get_data(peer, "public_key", + , _len)) { error = EINVAL; goto out; } - pubkey = prop_data_value(prop_obj); - pubkey_len = prop_data_size(prop_obj); #ifdef WG_DEBUG_DUMP log(LOG_DEBUG, "pubkey=%p, pubkey_len=%lu\n", pubkey, pubkey_len); for (int _i = 0; _i < pubkey_len; _i++) - log(LOG_DEBUG, "%c", pubkey[_i]); + log(LOG_DEBUG, "%c", ((const char *)pubkey)[_i]); log(LOG_DEBUG, "\n"); -#else - (void)pubkey_len; /* XXX gcc */ #endif struct wg_peer *wgp = wg_alloc_peer(wg); @@ -3728,11 +3723,7 @@ wg_handle_prop_peer(struct wg_softc *wg, if (name != NULL) strncpy(wgp->wgp_name, name, sizeof(wgp->wgp_name)); - prop_obj = prop_dictionary_get(peer, "preshared_key"); - if (prop_obj != NULL) { - const char *psk = prop_data_value(prop_obj); - size_t psk_len = prop_data_size(prop_obj); - + if (prop_dictionary_get_data(peer, "preshared_key", , _len)) { if (psk_len != sizeof(wgp->wgp_psk)) { error = EINVAL; goto out; @@ -3741,15 +3732,11 @@ wg_handle_prop_peer(struct wg_softc *wg, } struct sockaddr_storage sockaddr; - const char *addr; + const void *addr; size_t addr_len; - prop_obj = prop_dictionary_get(peer, "endpoint"); - if (prop_obj == NULL) + if (!prop_dictionary_get_data(peer, "endpoint", , _len)) goto skip_endpoint; - - addr = prop_data_value(prop_obj); - addr_len = prop_data_size(prop_obj); memcpy(, addr, addr_len); switch (sockaddr.ss_family) { case AF_INET: { @@ -3793,21 +3780,15 @@ skip_endpoint: while ((prop_allowedip = prop_object_iterator_next(_it)) != NULL) { struct wg_allowedip *wga = >wgp_allowedips[j]; - prop_obj = prop_dictionary_get(prop_allowedip, "family"); - if (prop_obj == NULL) + if (!prop_dictionary_get_int(prop_allowedip, "family", + >wga_family)) continue; - wga->wga_family = prop_number_unsigned_value(prop_obj); - - prop_obj = prop_dictionary_get(prop_allowedip, "ip"); - if (prop_obj == NULL) + if (!prop_dictionary_get_data(prop_allowedip, "ip", + , _len)) continue; - addr = prop_data_value(prop_obj); - addr_len = prop_data_size(prop_obj); - - prop_obj = prop_dictionary_get(prop_allowedip, "cidr"); - if (prop_obj == NULL) + if (!prop_dictionary_get_uint8(prop_allowedip, "cidr", + >wga_cidr)) continue; - wga->wga_cidr = prop_number_unsigned_value(prop_obj); switch (wga->wga_family) { case AF_INET: { @@ -3909,9 +3890,8 @@ wg_ioctl_set_private_key(struct wg_softc { int error; prop_dictionary_t prop_dict; - prop_object_t prop_obj; char *buf = NULL; - const char *privkey; + const void *privkey; size_t privkey_len; error = wg_alloc_prop_buf(, ifd); @@ -3921,16 +3901,13 @@ wg_ioctl_set_private_key(struct wg_softc prop_dict = prop_dictionary_internalize(buf); if (prop_dict == NULL) goto out; - prop_obj = prop_dictionary_get(prop_dict, "private_key"); - if (prop_obj == NULL) + if (!prop_dictionary_get_data(prop_dict, "private_key", + , _len)) goto out; - - privkey = prop_data_value(prop_obj); - privkey_len = prop_data_size(prop_obj); #ifdef WG_DEBUG_DUMP log(LOG_DEBUG, "privkey=%p, privkey_len=%lu\n", privkey, privkey_len); for (int i = 0; i < privkey_len; i++) - log(LOG_DEBUG, "%c", privkey[i]); + log(LOG_DEBUG, "%c", ((const char *)privkey)[i]); log(LOG_DEBUG, "\n"); #endif if (privkey_len != WG_STATIC_KEY_LEN) @@ -3949,9
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:34:23 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: Split up wg_process_peer_tasks into bite-size functions. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.10 src/sys/net/if_wg.c:1.11 --- src/sys/net/if_wg.c:1.10 Thu Aug 20 21:34:13 2020 +++ src/sys/net/if_wg.c Thu Aug 20 21:34:23 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.10 2020/08/20 21:34:13 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.11 2020/08/20 21:34:23 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.10 2020/08/20 21:34:13 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.11 2020/08/20 21:34:23 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -2633,6 +2633,86 @@ wg_put_peer(struct wg_peer *wgp, struct } static void +wg_task_send_init_message(struct wg_softc *wg, struct wg_peer *wgp) +{ + struct psref psref; + struct wg_session *wgs; + + WG_TRACE("WGP_TASK_SEND_INIT_MESSAGE"); + + if (!wgp->wgp_endpoint_available) { + WGLOG(LOG_DEBUG, "No endpoint available\n"); + /* XXX should do something? */ + return; + } + + wgs = wg_get_stable_session(wgp, ); + if (wgs->wgs_state == WGS_STATE_UNKNOWN) { + wg_put_session(wgs, ); + wg_send_handshake_msg_init(wg, wgp); + } else { + wg_put_session(wgs, ); + /* rekey */ + wgs = wg_get_unstable_session(wgp, ); + if (wgs->wgs_state != WGS_STATE_INIT_ACTIVE) + wg_send_handshake_msg_init(wg, wgp); + wg_put_session(wgs, ); + } +} + +static void +wg_task_endpoint_changed(struct wg_softc *wg, struct wg_peer *wgp) +{ + + WG_TRACE("WGP_TASK_ENDPOINT_CHANGED"); + + mutex_enter(wgp->wgp_lock); + if (wgp->wgp_endpoint_changing) { + pserialize_perform(wgp->wgp_psz); + psref_target_destroy(>wgp_endpoint0->wgsa_psref, + wg_psref_class); + psref_target_init(>wgp_endpoint0->wgsa_psref, + wg_psref_class); + wgp->wgp_endpoint_changing = false; + } + mutex_exit(wgp->wgp_lock); +} + +static void +wg_task_send_keepalive_message(struct wg_softc *wg, struct wg_peer *wgp) +{ + struct psref psref; + struct wg_session *wgs; + + WG_TRACE("WGP_TASK_SEND_KEEPALIVE_MESSAGE"); + + wgs = wg_get_stable_session(wgp, ); + wg_send_keepalive_msg(wgp, wgs); + wg_put_session(wgs, ); +} + +static void +wg_task_destroy_prev_session(struct wg_softc *wg, struct wg_peer *wgp) +{ + struct wg_session *wgs; + + WG_TRACE("WGP_TASK_DESTROY_PREV_SESSION"); + + mutex_enter(wgp->wgp_lock); + wgs = wgp->wgp_session_unstable; + mutex_enter(wgs->wgs_lock); + if (wgs->wgs_state == WGS_STATE_DESTROYING) { + pserialize_perform(wgp->wgp_psz); + psref_target_destroy(>wgs_psref, wg_psref_class); + psref_target_init(>wgs_psref, wg_psref_class); + wg_clear_states(wgs); + wgs->wgs_state = WGS_STATE_UNKNOWN; + } + mutex_exit(wgs->wgs_lock); + mutex_exit(wgp->wgp_lock); +} + +static void wg_process_peer_tasks(struct wg_softc *wg) { struct wg_peer *wgp; @@ -2656,69 +2736,14 @@ wg_process_peer_tasks(struct wg_softc *w WG_DLOG("tasks=%x\n", tasks); - if (ISSET(tasks, WGP_TASK_SEND_INIT_MESSAGE)) { - struct psref _psref; - struct wg_session *wgs; - - WG_TRACE("WGP_TASK_SEND_INIT_MESSAGE"); - if (!wgp->wgp_endpoint_available) { -WGLOG(LOG_DEBUG, "No endpoint available\n"); -/* XXX should do something? */ -goto skip_init_message; - } - wgs = wg_get_stable_session(wgp, &_psref); - if (wgs->wgs_state == WGS_STATE_UNKNOWN) { -wg_put_session(wgs, &_psref); -wg_send_handshake_msg_init(wg, wgp); - } else { -wg_put_session(wgs, &_psref); -/* rekey */ -wgs = wg_get_unstable_session(wgp, &_psref); -if (wgs->wgs_state != WGS_STATE_INIT_ACTIVE) - wg_send_handshake_msg_init(wg, wgp); -wg_put_session(wgs, &_psref); - } - } - skip_init_message: - if (ISSET(tasks, WGP_TASK_ENDPOINT_CHANGED)) { - WG_TRACE("WGP_TASK_ENDPOINT_CHANGED"); - mutex_enter(wgp->wgp_lock); - if (wgp->wgp_endpoint_changing) { -pserialize_perform(wgp->wgp_psz); -psref_target_destroy(>wgp_endpoint0->wgsa_psref, -wg_psref_class); -psref_target_init(>wgp_endpoint0->wgsa_psref, -wg_psref_class); -wgp->wgp_endpoint_changing = false; - } - mutex_exit(wgp->wgp_lock); - } - if (ISSET(tasks, WGP_TASK_SEND_KEEPALIVE_MESSAGE)) { - struct psref _psref; - struct wg_session *wgs; - - WG_TRACE("WGP_TASK_SEND_KEEPALIVE_MESSAGE"); - wgs = wg_get_stable_session(wgp, &_psref); - wg_send_keepalive_msg(wgp, wgs); - wg_put_session(wgs, &_psref); - } - if (ISSET(tasks, WGP_TASK_DESTROY_PREV_SESSION)) { - struct wg_session *wgs; - - WG_TRACE("WGP_TASK_DESTROY_PREV_SESSION"); - mutex_enter(wgp->wgp_lock); - wgs = wgp->wgp_session_unstable; -
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:35:24 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: Use container_of rather than casts via void *. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.15 src/sys/net/if_wg.c:1.16 --- src/sys/net/if_wg.c:1.15 Thu Aug 20 21:35:13 2020 +++ src/sys/net/if_wg.c Thu Aug 20 21:35:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.15 2020/08/20 21:35:13 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.16 2020/08/20 21:35:24 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.15 2020/08/20 21:35:13 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.16 2020/08/20 21:35:24 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -3012,7 +3012,7 @@ wg_session_hit_limits(struct wg_session static void wg_peer_softint(void *arg) { - struct wg_peer *wgp = (struct wg_peer *)arg; + struct wg_peer *wgp = arg; struct wg_session *wgs; struct mbuf *m; struct psref psref; @@ -3355,7 +3355,7 @@ wg_clone_create(struct if_clone *ifc, in static int wg_clone_destroy(struct ifnet *ifp) { - struct wg_softc *wg = (void *) ifp; + struct wg_softc *wg = container_of(ifp, struct wg_softc, wg_if); mutex_enter(_softcs.lock); LIST_REMOVE(wg, wg_list); @@ -3413,7 +3413,7 @@ wg_pick_peer_by_sa(struct wg_softc *wg, WG_TRACE("success"); - wga = (struct wg_allowedip *)rn; + wga = container_of(rn, struct wg_allowedip, wga_nodes[0]); wgp = wga->wga_peer; wg_get_peer(wgp, psref);
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:34:03 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: Update for proplib API changes. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.8 src/sys/net/if_wg.c:1.9 --- src/sys/net/if_wg.c:1.8 Thu Aug 20 21:33:52 2020 +++ src/sys/net/if_wg.c Thu Aug 20 21:34:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.8 2020/08/20 21:33:52 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.9 2020/08/20 21:34:03 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.8 2020/08/20 21:33:52 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.9 2020/08/20 21:34:03 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -3669,13 +3669,13 @@ wg_handle_prop_peer(struct wg_softc *wg, { int error = 0; prop_object_t prop_obj; - char *pubkey; + const char *pubkey; size_t pubkey_len; const char *name = NULL; prop_obj = prop_dictionary_get(peer, "name"); if (prop_obj != NULL) { - name = prop_string_cstring_nocopy(prop_obj); + name = prop_string_value(prop_obj); if (strlen(name) > WG_PEER_NAME_MAXLEN) { error = EINVAL; goto out; @@ -3687,7 +3687,7 @@ wg_handle_prop_peer(struct wg_softc *wg, error = EINVAL; goto out; } - pubkey = prop_data_data(prop_obj); + pubkey = prop_data_value(prop_obj); pubkey_len = prop_data_size(prop_obj); #ifdef WG_DEBUG_DUMP log(LOG_DEBUG, "pubkey=%p, pubkey_len=%lu\n", pubkey, pubkey_len); @@ -3705,7 +3705,7 @@ wg_handle_prop_peer(struct wg_softc *wg, prop_obj = prop_dictionary_get(peer, "preshared_key"); if (prop_obj != NULL) { - char *psk = prop_data_data(prop_obj); + const char *psk = prop_data_value(prop_obj); size_t psk_len = prop_data_size(prop_obj); if (psk_len != sizeof(wgp->wgp_psk)) { @@ -3716,14 +3716,14 @@ wg_handle_prop_peer(struct wg_softc *wg, } struct sockaddr_storage sockaddr; - char *addr; + const char *addr; size_t addr_len; prop_obj = prop_dictionary_get(peer, "endpoint"); if (prop_obj == NULL) goto skip_endpoint; - addr = prop_data_data(prop_obj); + addr = prop_data_value(prop_obj); addr_len = prop_data_size(prop_obj); memcpy(, addr, addr_len); switch (sockaddr.ss_family) { @@ -3771,18 +3771,18 @@ skip_endpoint: prop_obj = prop_dictionary_get(prop_allowedip, "family"); if (prop_obj == NULL) continue; - wga->wga_family = prop_number_unsigned_integer_value(prop_obj); + wga->wga_family = prop_number_unsigned_value(prop_obj); prop_obj = prop_dictionary_get(prop_allowedip, "ip"); if (prop_obj == NULL) continue; - addr = prop_data_data(prop_obj); + addr = prop_data_value(prop_obj); addr_len = prop_data_size(prop_obj); prop_obj = prop_dictionary_get(prop_allowedip, "cidr"); if (prop_obj == NULL) continue; - wga->wga_cidr = prop_number_unsigned_integer_value(prop_obj); + wga->wga_cidr = prop_number_unsigned_value(prop_obj); switch (wga->wga_family) { case AF_INET: { @@ -3795,11 +3795,13 @@ skip_endpoint: return EINVAL; memcpy(>wga_addr4, addr, addr_len); - sockaddr_in_init(, (struct in_addr *)addr, 0); + sockaddr_in_init(, (const struct in_addr *)addr, + 0); sockaddr_copy(>wga_sa_addr, sizeof(sin), sintosa()); - sockaddr_format(sintosa(), addrstr, sizeof(addrstr)); + sockaddr_format(sintosa(), + addrstr, sizeof(addrstr)); WG_DLOG("addr=%s/%d\n", addrstr, wga->wga_cidr); in_len2mask(, wga->wga_cidr); @@ -3820,11 +3822,13 @@ skip_endpoint: return EINVAL; memcpy(>wga_addr6, addr, addr_len); - sockaddr_in6_init(, (struct in6_addr *)addr, 0, 0, 0); + sockaddr_in6_init(, (const struct in6_addr *)addr, + 0, 0, 0); sockaddr_copy(>wga_sa_addr, sizeof(sin6), sin6tosa()); - sockaddr_format(sin6tosa(), addrstr, sizeof(addrstr)); + sockaddr_format(sin6tosa(), + addrstr, sizeof(addrstr)); WG_DLOG("addr=%s/%d\n", addrstr, wga->wga_cidr); in6_prefixlen2mask(, wga->wga_cidr); @@ -3882,7 +3886,7 @@ wg_ioctl_set_private_key(struct wg_softc prop_dictionary_t prop_dict; prop_object_t prop_obj; char *buf = NULL; - char *privkey; + const char *privkey; size_t privkey_len; error = wg_alloc_prop_buf(, ifd); @@ -3896,7 +3900,7 @@ wg_ioctl_set_private_key(struct wg_softc if (prop_obj == NULL) goto out; - privkey = prop_data_data(prop_obj); + privkey = prop_data_value(prop_obj); privkey_len = prop_data_size(prop_obj); #ifdef WG_DEBUG_DUMP log(LOG_DEBUG, "privkey=%p, privkey_len=%lu\n", privkey, privkey_len); @@ -3935,7 +3939,7 @@ wg_ioctl_set_listen_port(struct wg_softc if (prop_obj == NULL) goto out; - port = prop_number_unsigned_integer_value(prop_obj);
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:35:13 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: Use be32enc, rather than possibly unaligned uint32_t cast and htonl. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.14 src/sys/net/if_wg.c:1.15 --- src/sys/net/if_wg.c:1.14 Thu Aug 20 21:35:01 2020 +++ src/sys/net/if_wg.c Thu Aug 20 21:35:13 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.14 2020/08/20 21:35:01 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.15 2020/08/20 21:35:13 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.14 2020/08/20 21:35:01 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.15 2020/08/20 21:35:13 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1073,19 +1073,18 @@ wg_algo_xaead_dec(uint8_t out[], const s } static void -wg_algo_tai64n(wg_timestamp_t _timestamp) +wg_algo_tai64n(wg_timestamp_t timestamp) { struct timespec ts; - uint32_t *timestamp = (uint32_t *)_timestamp; /* FIXME strict TAI64N (https://cr.yp.to/libtai/tai64.html) */ getnanotime(); /* TAI64 label in external TAI64 format */ - timestamp[0] = htonl(0x4000L + (ts.tv_sec >> 32)); + be32enc(timestamp, 0x4000UL + (ts.tv_sec >> 32)); /* second beginning from 1970 TAI */ - timestamp[1] = htonl((long)ts.tv_sec); + be32enc(timestamp + 4, ts.tv_sec & 0xU); /* nanosecond in big-endian format */ - timestamp[2] = htonl(ts.tv_nsec); + be32enc(timestamp + 8, ts.tv_nsec); } static struct wg_session *
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:33:53 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: Use SYSCTL_SETUP for net.wireguard subtree. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.7 src/sys/net/if_wg.c:1.8 --- src/sys/net/if_wg.c:1.7 Thu Aug 20 21:31:47 2020 +++ src/sys/net/if_wg.c Thu Aug 20 21:33:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.7 2020/08/20 21:31:47 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.8 2020/08/20 21:33:52 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.7 2020/08/20 21:31:47 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.8 2020/08/20 21:33:52 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -676,8 +676,6 @@ static void wg_stop(struct ifnet *, int) static int wg_clone_create(struct if_clone *, int); static int wg_clone_destroy(struct ifnet *); -static void wg_setup_sysctl(void); - struct wg_ops { int (*send_hs_msg)(struct wg_peer *, struct mbuf *); int (*send_data_msg)(struct wg_peer *, struct mbuf *); @@ -771,8 +769,6 @@ static void wginit(void) { - wg_setup_sysctl(); - wg_psref_class = psref_class_create("wg", IPL_SOFTNET); mutex_init(_softcs.lock, MUTEX_DEFAULT, IPL_NONE); @@ -4366,60 +4362,49 @@ wg_stop(struct ifnet *ifp, int disable) /* Need to do something? */ } -static struct sysctllog *wg_sysctllog; -static void -wg_setup_sysctl(void) -{ #ifdef WG_DEBUG_PARAMS +SYSCTL_SETUP(sysctl_net_wireguard_setup, "sysctl net.wireguard setup") +{ const struct sysctlnode *node = NULL; - sysctl_createv(_sysctllog, 0, NULL, , - CTLFLAG_PERMANENT, CTLTYPE_NODE, "wireguard", - SYSCTL_DESCR("WireGuard"), - NULL, 0, NULL, 0, CTL_NET, CTL_CREATE, CTL_EOL); - if (node != NULL) { - sysctl_createv(_sysctllog, 0, NULL, NULL, - CTLFLAG_PERMANENT|CTLFLAG_READWRITE, - CTLTYPE_LONG, "rekey_after_messages", - SYSCTL_DESCR("session liftime by messages"), - NULL, 0, _rekey_after_messages, 0, - CTL_NET, node->sysctl_num, CTL_CREATE, CTL_EOL); - sysctl_createv(_sysctllog, 0, NULL, NULL, - CTLFLAG_PERMANENT|CTLFLAG_READWRITE, - CTLTYPE_LONG, "rekey_after_time", - SYSCTL_DESCR("session liftime"), - NULL, 0, _rekey_after_time, 0, - CTL_NET, node->sysctl_num, CTL_CREATE, CTL_EOL); - sysctl_createv(_sysctllog, 0, NULL, NULL, - CTLFLAG_PERMANENT|CTLFLAG_READWRITE, - CTLTYPE_LONG, "rekey_timeout", - SYSCTL_DESCR("session handshake retry time"), - NULL, 0, _rekey_timeout, 0, - CTL_NET, node->sysctl_num, CTL_CREATE, CTL_EOL); - sysctl_createv(_sysctllog, 0, NULL, NULL, - CTLFLAG_PERMANENT|CTLFLAG_READWRITE, - CTLTYPE_LONG, "rekey_attempt_time", - SYSCTL_DESCR("session handshake timeout"), - NULL, 0, _rekey_attempt_time, 0, - CTL_NET, node->sysctl_num, CTL_CREATE, CTL_EOL); - sysctl_createv(_sysctllog, 0, NULL, NULL, - CTLFLAG_PERMANENT|CTLFLAG_READWRITE, - CTLTYPE_LONG, "keepalive_timeout", - SYSCTL_DESCR("keepalive timeout"), - NULL, 0, _keepalive_timeout, 0, - CTL_NET, node->sysctl_num, CTL_CREATE, CTL_EOL); - - sysctl_createv(_sysctllog, 0, NULL, NULL, - CTLFLAG_PERMANENT|CTLFLAG_READWRITE, - CTLTYPE_BOOL, "force_underload", - SYSCTL_DESCR("force to detemine under load"), - NULL, 0, _force_underload, 0, - CTL_NET, node->sysctl_num, CTL_CREATE, CTL_EOL); - } -#else - (void)wg_sysctllog; -#endif + sysctl_createv(clog, 0, NULL, , + CTLFLAG_PERMANENT, + CTLTYPE_NODE, "wireguard", + SYSCTL_DESCR("WireGuard"), + NULL, 0, NULL, 0, + CTL_NET, CTL_CREATE, CTL_EOL); + sysctl_createv(clog, 0, , NULL, + CTLFLAG_PERMANENT|CTLFLAG_READWRITE, + CTLTYPE_LONG, "rekey_after_messages", + SYSCTL_DESCR("session liftime by messages"), + NULL, 0, _rekey_after_messages, 0, CTL_CREATE, CTL_EOL); + sysctl_createv(clog, 0, , NULL, + CTLFLAG_PERMANENT|CTLFLAG_READWRITE, + CTLTYPE_LONG, "rekey_after_time", + SYSCTL_DESCR("session liftime"), + NULL, 0, _rekey_after_time, 0, CTL_CREATE, CTL_EOL); + sysctl_createv(clog, 0, , NULL, + CTLFLAG_PERMANENT|CTLFLAG_READWRITE, + CTLTYPE_LONG, "rekey_timeout", + SYSCTL_DESCR("session handshake retry time"), + NULL, 0, _rekey_timeout, 0, CTL_CREATE, CTL_EOL); + sysctl_createv(clog, 0, , NULL, + CTLFLAG_PERMANENT|CTLFLAG_READWRITE, + CTLTYPE_LONG, "rekey_attempt_time", + SYSCTL_DESCR("session handshake timeout"), + NULL, 0, _rekey_attempt_time, 0, CTL_CREATE, CTL_EOL); + sysctl_createv(clog, 0, , NULL, + CTLFLAG_PERMANENT|CTLFLAG_READWRITE, + CTLTYPE_LONG, "keepalive_timeout", + SYSCTL_DESCR("keepalive timeout"), + NULL, 0, _keepalive_timeout, 0, CTL_CREATE, CTL_EOL); + sysctl_createv(clog, 0, , NULL, +
CVS commit: src/sys/rump/kern/lib/libcrypto
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:33:43 UTC 2020 Modified Files: src/sys/rump/kern/lib/libcrypto: Makefile Log Message: Missed a spot -- add sys/crypto/blake2 to .PATH here. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/rump/kern/lib/libcrypto/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/kern/lib/libcrypto/Makefile diff -u src/sys/rump/kern/lib/libcrypto/Makefile:1.15 src/sys/rump/kern/lib/libcrypto/Makefile:1.16 --- src/sys/rump/kern/lib/libcrypto/Makefile:1.15 Thu Aug 20 21:30:32 2020 +++ src/sys/rump/kern/lib/libcrypto/Makefile Thu Aug 20 21:33:43 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.15 2020/08/20 21:30:32 riastradh Exp $ +# $NetBSD: Makefile,v 1.16 2020/08/20 21:33:43 riastradh Exp $ # SODIUM_IMPORTDIR=${.CURDIR}/../../../../external/isc/libsodium @@ -6,6 +6,7 @@ SODIUM_DIR=${.CURDIR}/../../../../extern .PATH: ${.CURDIR}/../../../../crypto/adiantum\ ${.CURDIR}/../../../../crypto/aes\ + ${.CURDIR}/../../../../crypto/blake2\ ${.CURDIR}/../../../../crypto/blowfish\ ${.CURDIR}/../../../../crypto/camellia\ ${.CURDIR}/../../../../crypto/cast128\
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:31:47 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: Fix in-kernel debug build. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.6 src/sys/net/if_wg.c:1.7 --- src/sys/net/if_wg.c:1.6 Thu Aug 20 21:31:36 2020 +++ src/sys/net/if_wg.c Thu Aug 20 21:31:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.6 2020/08/20 21:31:36 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.7 2020/08/20 21:31:47 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.6 2020/08/20 21:31:36 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.7 2020/08/20 21:31:47 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -209,6 +209,8 @@ static bool wg_force_underload = false; #endif #ifdef WG_DEBUG_DUMP + +#ifdef WG_RUMPKERNEL static void wg_dump_buf(const char *func, const char *buf, const size_t size) { @@ -218,6 +220,7 @@ wg_dump_buf(const char *func, const char log(LOG_DEBUG, "%02x ", (int)(0xff & buf[i])); log(LOG_DEBUG, "\n"); } +#endif static void wg_dump_hash(const uint8_t *func, const uint8_t *name, const uint8_t *hash,
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:34:13 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: Fix race in wg_worker kthread destruction. Also allow the thread to migrate between CPUs -- just not while we're in the middle of processing and holding onto things with psrefs. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.9 src/sys/net/if_wg.c:1.10 --- src/sys/net/if_wg.c:1.9 Thu Aug 20 21:34:03 2020 +++ src/sys/net/if_wg.c Thu Aug 20 21:34:13 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.9 2020/08/20 21:34:03 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.10 2020/08/20 21:34:13 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.9 2020/08/20 21:34:03 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.10 2020/08/20 21:34:13 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -2736,32 +2736,32 @@ wg_worker(void *arg) { struct wg_softc *wg = arg; struct wg_worker *wgw = wg->wg_worker; - int bound = curlwp_bind(); + bool todie = false; KASSERT(wg != NULL); KASSERT(wgw != NULL); - while (!wgw->wgw_todie) { + while (!todie) { int reasons; + int bound; mutex_enter(>wgw_lock); /* New tasks may come during task handling */ - if (wgw->wgw_wakeup_reasons == 0) + while ((reasons = wgw->wgw_wakeup_reasons) == 0 && + !(todie = wgw->wgw_todie)) cv_wait(>wgw_cv, >wgw_lock); - reasons = wgw->wgw_wakeup_reasons; wgw->wgw_wakeup_reasons = 0; mutex_exit(>wgw_lock); + bound = curlwp_bind(); if (ISSET(reasons, WG_WAKEUP_REASON_RECEIVE_PACKETS_IPV4)) wg_receive_packets(wg, AF_INET); if (ISSET(reasons, WG_WAKEUP_REASON_RECEIVE_PACKETS_IPV6)) wg_receive_packets(wg, AF_INET6); - if (!ISSET(reasons, WG_WAKEUP_REASON_PEER)) - continue; - - wg_process_peer_tasks(wg); + if (ISSET(reasons, WG_WAKEUP_REASON_PEER)) + wg_process_peer_tasks(wg); + curlwp_bindx(bound); } - curlwp_bindx(bound); kthread_exit(0); }
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:35:01 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: KNF To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.13 src/sys/net/if_wg.c:1.14 --- src/sys/net/if_wg.c:1.13 Thu Aug 20 21:34:42 2020 +++ src/sys/net/if_wg.c Thu Aug 20 21:35:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.13 2020/08/20 21:34:42 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.14 2020/08/20 21:35:01 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.13 2020/08/20 21:34:42 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.14 2020/08/20 21:35:01 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -143,27 +143,30 @@ __KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1. * - Data messages are always sent via a stable session * * Locking notes: - * - wg interfaces (struct wg_softc, wg) is listed in wg_softcs.list and protected - * by wg_softcs.lock + * - wg interfaces (struct wg_softc, wg) is listed in wg_softcs.list and + * protected by wg_softcs.lock * - Each wg has a mutex(9) and a rwlock(9) * - The mutex (wg_lock) protects its peer list (wg_peers) - * - A peer on the list of a wg is also protected by pserialize(9) or psref(9) + * - A peer on the list is also protected by pserialize(9) or psref(9) * - The rwlock (wg_rwlock) protects the routing tables (wg_rtable_ipv[46]) * - Each peer (struct wg_peer, wgp) has a mutex * - The mutex (wgp_lock) protects wgp_session_unstable and wgp_state * - Each session (struct wg_session, wgs) has a mutex * - The mutex (wgs_lock) protects its state (wgs_state) and its handshake * states - * - wgs_state of a unstable session can be changed while it never be changed - * on a stable session, so once get a session instace via wgp_session_stable - * we can safely access wgs_state without holding wgs_lock + * - wgs_state of a unstable session can be changed while it never be + * changed on a stable session, so once get a session instace via + * wgp_session_stable we can safely access wgs_state without + * holding wgs_lock * - A session is protected by pserialize or psref like wgp - * - On a session swap, we must wait for all readers to release a reference - * to a stable session before changing wgs_state and session states + * - On a session swap, we must wait for all readers to release a + * reference to a stable session before changing wgs_state and + * session states */ -#define WGLOG(level, fmt, args...) log(level, "%s: " fmt, __func__, ##args) +#define WGLOG(level, fmt, args...) \ + log(level, "%s: " fmt, __func__, ##args) /* Debug options */ #ifdef WG_DEBUG @@ -186,7 +189,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1. #endif #ifdef WG_DEBUG_TRACE -#define WG_TRACE(msg) log(LOG_DEBUG, "%s:%d: %s\n", __func__, __LINE__, (msg)) +#define WG_TRACE(msg) \ + log(LOG_DEBUG, "%s:%d: %s\n", __func__, __LINE__, (msg)) #else #define WG_TRACE(msg) __nothing #endif @@ -292,7 +296,7 @@ wg_dump_hash(const uint8_t *func, const /* * The protocol messages */ -struct wg_msg{ +struct wg_msg { uint32_t wgm_type; } __packed; @@ -550,7 +554,7 @@ struct wg_peer { time_t wgp_handshake_start_time; - int wgp_n_allowedips;; + int wgp_n_allowedips; struct wg_allowedip wgp_allowedips[WG_ALLOWEDIPS]; time_t wgp_latest_cookie_time; @@ -952,8 +956,8 @@ wg_algo_kdf(uint8_t out1[WG_KDF_OUTPUT_L uint8_t one[1]; /* - * [N] 4.3: "an input_key_material byte sequence with length either zero - * bytes, 32 bytes, or DHLEN bytes." + * [N] 4.3: "an input_key_material byte sequence with length + * either zero bytes, 32 bytes, or DHLEN bytes." */ KASSERT(inputlen == 0 || inputlen == 32 || inputlen == NOISE_DHLEN); @@ -1045,8 +1049,8 @@ wg_algo_xaead_enc(uint8_t out[], const s int error __diagused; CTASSERT(WG_SALT_LEN == crypto_aead_xchacha20poly1305_ietf_NPUBBYTES); - error = crypto_aead_xchacha20poly1305_ietf_encrypt(out, , plain, - plainsize, auth, authlen, NULL, nonce, key); + error = crypto_aead_xchacha20poly1305_ietf_encrypt(out, , + plain, plainsize, auth, authlen, NULL, nonce, key); KASSERT(error == 0); KASSERT(outsize == expected_outsize); } @@ -1414,9 +1418,9 @@ wg_handle_msg_init(struct wg_softc *wg, wg_algo_hash(hash, wgmi->wgmi_timestamp, sizeof(wgmi->wgmi_timestamp)); /* - * [W] 5.1 "The responder keeps track of the greatest timestamp received per - * peer and discards packets containing timestamps less than or - * equal to it." + * [W] 5.1 "The responder keeps track of the greatest timestamp + * received per
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:34:51 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.c Log Message: Update wgconfig(8) for proplib API changes. Also check type tags before conversion. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/wgconfig/wgconfig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.c diff -u src/usr.sbin/wgconfig/wgconfig.c:1.2 src/usr.sbin/wgconfig/wgconfig.c:1.3 --- src/usr.sbin/wgconfig/wgconfig.c:1.2 Thu Aug 20 21:31:26 2020 +++ src/usr.sbin/wgconfig/wgconfig.c Thu Aug 20 21:34:51 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: wgconfig.c,v 1.2 2020/08/20 21:31:26 riastradh Exp $ */ +/* $NetBSD: wgconfig.c,v 1.3 2020/08/20 21:34:51 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: wgconfig.c,v 1.2 2020/08/20 21:31:26 riastradh Exp $"); +__RCSID("$NetBSD: wgconfig.c,v 1.3 2020/08/20 21:34:51 riastradh Exp $"); #include @@ -80,15 +80,16 @@ static const char * format_key(prop_object_t key_prop) { int error; - unsigned char *key; + const void *key; size_t key_len; static char key_b64[KEY_BASE64_LEN + 1]; - static const char *none = "(none)"; if (key_prop == NULL) - return none; + return "(none)"; + if (prop_object_type(key_prop) != PROP_TYPE_DATA) + errx(EXIT_FAILURE, "invalid key"); - key = prop_data_data(key_prop); + key = prop_data_value(key_prop); key_len = prop_data_size(key_prop); if (key_len != KEY_LEN) errx(EXIT_FAILURE, "invalid key len: %lu", key_len); @@ -106,10 +107,13 @@ format_endpoint(prop_object_t endpoint_p int error; static char buf[INET6_ADDRSTRLEN]; struct sockaddr_storage sockaddr; - char *addr; + const void *addr; size_t addr_len; - addr = prop_data_data(endpoint_prop); + if (prop_object_type(endpoint_prop) != PROP_TYPE_DATA) + errx(EXIT_FAILURE, "invalid endpoint"); + + addr = prop_data_value(endpoint_prop); addr_len = prop_data_size(endpoint_prop); memcpy(, addr, addr_len); @@ -124,48 +128,68 @@ format_endpoint(prop_object_t endpoint_p static void handle_allowed_ips(prop_dictionary_t peer, const char *prefix) { + prop_object_t prop_obj; prop_array_t allowedips; prop_object_iterator_t it; prop_dictionary_t allowedip; bool first = true; - allowedips = prop_dictionary_get(peer, "allowedips"); - if (allowedips == NULL) + prop_obj = prop_dictionary_get(peer, "allowedips"); + if (prop_obj == NULL) return; + if (prop_object_type(prop_obj) != PROP_TYPE_ARRAY) + errx(EXIT_FAILURE, "invalid allowedips"); + allowedips = prop_obj; printf("%sallowed-ips: ", prefix); it = prop_array_iterator(allowedips); - while ((allowedip = prop_object_iterator_next(it)) != NULL) { - prop_object_t prop_obj; + while ((prop_obj = prop_object_iterator_next(it)) != NULL) { uint8_t family; uint8_t cidr; - char *addr; + const void *addr; + size_t addrlen, famaddrlen; char ntopbuf[INET6_ADDRSTRLEN]; const char *ntopret; - prop_obj = prop_dictionary_get(allowedip, "family"); - if (prop_obj == NULL) { - warnx("allowed-ip without family"); + if (prop_object_type(prop_obj) != PROP_TYPE_DICTIONARY) { + warnx("invalid allowedip"); continue; } + allowedip = prop_obj; - family = (uint8_t)prop_number_unsigned_integer_value(prop_obj); + if (!prop_dictionary_get_uint8(allowedip, "family", )) { + warnx("allowed-ip without family"); + continue; + } - prop_obj = prop_dictionary_get(allowedip, "cidr"); - if (prop_obj == NULL) { + if (!prop_dictionary_get_uint8(allowedip, "cidr", )) { warnx("allowed-ip without cidr"); continue; } - cidr = (uint8_t)prop_number_unsigned_integer_value(prop_obj); - prop_obj = prop_dictionary_get(allowedip, "ip"); - if (prop_obj == NULL) { + if (!prop_dictionary_get_data(allowedip, "ip", + , )) { warnx("allowed-ip without ip"); continue; } - addr = prop_data_data(prop_obj); + switch (family) { + case AF_INET: + famaddrlen = sizeof(struct in_addr); + break; + case AF_INET6: + famaddrlen = sizeof(struct in6_addr); + break; + default: + warnx("unknown family %d", family); + continue; + } + if (addrlen != famaddrlen) { + warnx("allowed-ip bad ip length"); + continue; + } + ntopret = inet_ntop(family, addr, ntopbuf, sizeof(ntopbuf)); if (ntopret == NULL) errx(EXIT_FAILURE, "inet_ntop failed"); @@ -217,6 +241,7 @@ static void show_peer(prop_dictionary_t peer, const char *prefix, bool show_psk) { prop_object_t prop_obj; + uint64_t sec; prop_obj = prop_dictionary_get(peer, "public_key"); if (prop_obj == NULL) { @@ -240,15 +265,10 @@ show_peer(prop_dictionary_t peer, const handle_allowed_ips(peer, prefix); - prop_obj = prop_dictionary_get(peer, "last_handshake_time_sec"); - if (prop_obj != NULL) { - uint64_t sec =
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:34:42 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: Use consttime_memequal, not memcmp, to compare secrets for equality. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.12 src/sys/net/if_wg.c:1.13 --- src/sys/net/if_wg.c:1.12 Thu Aug 20 21:34:32 2020 +++ src/sys/net/if_wg.c Thu Aug 20 21:34:42 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.12 2020/08/20 21:34:32 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.13 2020/08/20 21:34:42 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.12 2020/08/20 21:34:32 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.13 2020/08/20 21:34:42 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1357,7 +1357,7 @@ wg_handle_msg_init(struct wg_softc *wg, * "the responder, ..., must always reject messages with an invalid * msg.mac1" */ - if (memcmp(mac1, wgmi->wgmi_mac1, sizeof(mac1)) != 0) { + if (!consttime_memequal(mac1, wgmi->wgmi_mac1, sizeof(mac1))) { WG_DLOG("mac1 is invalid\n"); goto out; } @@ -1373,7 +1373,7 @@ wg_handle_msg_init(struct wg_softc *wg, * message" */ uint8_t zero[WG_MAC_LEN] = {0}; - if (memcmp(wgmi->wgmi_mac2, zero, sizeof(zero)) == 0) { + if (consttime_memequal(wgmi->wgmi_mac2, zero, sizeof(zero))) { WG_TRACE("sending a cookie message: no cookie included"); (void)wg_send_cookie_msg(wg, wgp, wgmi->wgmi_sender, wgmi->wgmi_mac1, src); @@ -1389,7 +1389,7 @@ wg_handle_msg_init(struct wg_softc *wg, wg_algo_mac(mac2, sizeof(mac2), wgp->wgp_last_sent_cookie, WG_COOKIE_LEN, (const uint8_t *)wgmi, offsetof(struct wg_msg_init, wgmi_mac2), NULL, 0); - if (memcmp(mac2, wgmi->wgmi_mac2, sizeof(mac2)) != 0) { + if (!consttime_memequal(mac2, wgmi->wgmi_mac2, sizeof(mac2))) { WG_DLOG("mac2 is invalid\n"); goto out; } @@ -1715,7 +1715,7 @@ wg_handle_msg_resp(struct wg_softc *wg, * "the responder, ..., must always reject messages with an invalid * msg.mac1" */ - if (memcmp(mac1, wgmr->wgmr_mac1, sizeof(mac1)) != 0) { + if (!consttime_memequal(mac1, wgmr->wgmr_mac1, sizeof(mac1))) { WG_DLOG("mac1 is invalid\n"); goto out; } @@ -1731,7 +1731,7 @@ wg_handle_msg_resp(struct wg_softc *wg, * message" */ uint8_t zero[WG_MAC_LEN] = {0}; - if (memcmp(wgmr->wgmr_mac2, zero, sizeof(zero)) == 0) { + if (consttime_memequal(wgmr->wgmr_mac2, zero, sizeof(zero))) { WG_TRACE("sending a cookie message: no cookie included"); (void)wg_send_cookie_msg(wg, wgp, wgmr->wgmr_sender, wgmr->wgmr_mac1, src); @@ -1747,7 +1747,7 @@ wg_handle_msg_resp(struct wg_softc *wg, wg_algo_mac(mac2, sizeof(mac2), wgp->wgp_last_sent_cookie, WG_COOKIE_LEN, (const uint8_t *)wgmr, offsetof(struct wg_msg_resp, wgmr_mac2), NULL, 0); - if (memcmp(mac2, wgmr->wgmr_mac2, sizeof(mac2)) != 0) { + if (!consttime_memequal(mac2, wgmr->wgmr_mac2, sizeof(mac2))) { WG_DLOG("mac2 is invalid\n"); goto out; } @@ -1892,7 +1892,8 @@ wg_lookup_peer_by_pubkey(struct wg_softc int s = pserialize_read_enter(); /* XXX O(n) */ WG_PEER_READER_FOREACH(wgp, wg) { - if (memcmp(wgp->wgp_pubkey, pubkey, sizeof(wgp->wgp_pubkey)) == 0) + if (consttime_memequal(wgp->wgp_pubkey, pubkey, + sizeof(wgp->wgp_pubkey))) break; } if (wgp != NULL) @@ -4058,7 +4059,8 @@ wg_ioctl_get(struct wg_softc *wg, struct goto next; uint8_t psk_zero[WG_PRESHARED_KEY_LEN] = {0}; - if (memcmp(wgp->wgp_psk, psk_zero, sizeof(wgp->wgp_psk) != 0)) { + if (!consttime_memequal(wgp->wgp_psk, psk_zero, + sizeof(wgp->wgp_psk))) { if (!prop_dictionary_set_data(prop_peer, "preshared_key", wgp->wgp_psk, sizeof(wgp->wgp_psk)))
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:31:37 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: Implement sliding window for wireguard replay detection. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.5 src/sys/net/if_wg.c:1.6 --- src/sys/net/if_wg.c:1.5 Thu Aug 20 21:31:16 2020 +++ src/sys/net/if_wg.c Thu Aug 20 21:31:36 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.5 2020/08/20 21:31:16 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.6 2020/08/20 21:31:36 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.5 2020/08/20 21:31:16 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.6 2020/08/20 21:31:36 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -337,6 +337,82 @@ struct wg_msg_cookie { #define WG_MSG_TYPE_DATA 4 #define WG_MSG_TYPE_MAX WG_MSG_TYPE_DATA +/* Sliding windows */ + +#define SLIWIN_BITS 2048u +#define SLIWIN_TYPE uint32_t +#define SLIWIN_BPW NBBY*sizeof(SLIWIN_TYPE) +#define SLIWIN_WORDS howmany(SLIWIN_BITS, SLIWIN_BPW) +#define SLIWIN_NPKT (SLIWIN_BITS - NBBY*sizeof(SLIWIN_TYPE)) + +struct sliwin { + SLIWIN_TYPE B[SLIWIN_WORDS]; + uint64_t T; +}; + +static void +sliwin_reset(struct sliwin *W) +{ + + memset(W, 0, sizeof(*W)); +} + +static int +sliwin_check_fast(const volatile struct sliwin *W, uint64_t S) +{ + + /* + * If it's more than one window older than the highest sequence + * number we've seen, reject. + */ + if (S + SLIWIN_NPKT < atomic_load_relaxed(>T)) + return EAUTH; + + /* + * Otherwise, we need to take the lock to decide, so don't + * reject just yet. Caller must serialize a call to + * sliwin_update in this case. + */ + return 0; +} + +static int +sliwin_update(struct sliwin *W, uint64_t S) +{ + unsigned word, bit; + + /* + * If it's more than one window older than the highest sequence + * number we've seen, reject. + */ + if (S + SLIWIN_NPKT < W->T) + return EAUTH; + + /* + * If it's higher than the highest sequence number we've seen, + * advance the window. + */ + if (S > W->T) { + uint64_t i = W->T / SLIWIN_BPW; + uint64_t j = S / SLIWIN_BPW; + unsigned k; + + for (k = 0; k < MIN(j - i, SLIWIN_WORDS); k++) + W->B[(i + k + 1) % SLIWIN_WORDS] = 0; + atomic_store_relaxed(>T, S); + } + + /* Test and set the bit -- if already set, reject. */ + word = (S / SLIWIN_BPW) % SLIWIN_WORDS; + bit = S % SLIWIN_BPW; + if (W->B[word] & (1UL << bit)) + return EAUTH; + W->B[word] |= 1UL << bit; + + /* Accept! */ + return 0; +} + struct wg_worker { kmutex_t wgw_lock; kcondvar_t wgw_cv; @@ -370,8 +446,11 @@ struct wg_session { uint32_t wgs_receiver_index; volatile uint64_t wgs_send_counter; - volatile uint64_t - wgs_recv_counter; + + struct { + kmutex_t lock; + struct sliwin window; + } *wgs_recvwin; uint8_t wgs_handshake_hash[WG_HASH_LEN]; uint8_t wgs_chaining_key[WG_CHAINING_KEY_LEN]; @@ -1942,7 +2021,7 @@ wg_clear_states(struct wg_session *wgs) { wgs->wgs_send_counter = 0; - wgs->wgs_recv_counter = 0; + sliwin_reset(>wgs_recvwin->window); #define wgs_clear(v) explicit_memset(wgs->wgs_##v, 0, sizeof(wgs->wgs_##v)) wgs_clear(handshake_hash); @@ -2231,6 +2310,15 @@ wg_handle_msg_data(struct wg_softc *wg, } wgp = wgs->wgs_peer; + error = sliwin_check_fast(>wgs_recvwin->window, + wgmd->wgmd_counter); + if (error) { + WG_LOG_RATECHECK(>wgp_ppsratecheck, LOG_DEBUG, + "out-of-window packet: %"PRIu64"\n", + wgmd->wgmd_counter); + goto out; + } + mlen = m_length(m); encrypted_len = mlen - sizeof(*wgmd); @@ -2281,17 +2369,17 @@ wg_handle_msg_data(struct wg_softc *wg, } WG_DLOG("outsize=%u\n", (u_int)decrypted_len); - /* TODO deal with reordering with a sliding window */ - if (wgs->wgs_recv_counter != 0 && - wgmd->wgmd_counter <= wgs->wgs_recv_counter) { + mutex_enter(>wgs_recvwin->lock); + error = sliwin_update(>wgs_recvwin->window, + wgmd->wgmd_counter); + mutex_exit(>wgs_recvwin->lock); + if (error) { WG_LOG_RATECHECK(>wgp_ppsratecheck, LOG_DEBUG, - "wgmd_counter is equal to or smaller than wgs_recv_counter:" - " %"PRIu64" <= %"PRIu64"\n", wgmd->wgmd_counter, - wgs->wgs_recv_counter); + "replay or out-of-window packet: %"PRIu64"\n", + wgmd->wgmd_counter); m_freem(n); goto out; } - wgs->wgs_recv_counter = wgmd->wgmd_counter; m_freem(m); m = NULL; @@ -3020,11 +3108,16 @@ wg_alloc_peer(struct wg_softc *wg) wgs->wgs_state = WGS_STATE_UNKNOWN; psref_target_init(>wgs_psref, wg_psref_class); wgs->wgs_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE); + wgs->wgs_recvwin = kmem_zalloc(sizeof(*wgs->wgs_recvwin), KM_SLEEP); + mutex_init(>wgs_recvwin->lock, MUTEX_DEFAULT, IPL_NONE);
CVS commit: src/sys/rump/kern/lib/libcrypto
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:30:32 UTC 2020 Modified Files: src/sys/rump/kern/lib/libcrypto: Makefile Log Message: Fix vestiges of libb2. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/rump/kern/lib/libcrypto/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/kern/lib/libcrypto/Makefile diff -u src/sys/rump/kern/lib/libcrypto/Makefile:1.14 src/sys/rump/kern/lib/libcrypto/Makefile:1.15 --- src/sys/rump/kern/lib/libcrypto/Makefile:1.14 Thu Aug 20 21:21:32 2020 +++ src/sys/rump/kern/lib/libcrypto/Makefile Thu Aug 20 21:30:32 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.14 2020/08/20 21:21:32 riastradh Exp $ +# $NetBSD: Makefile,v 1.15 2020/08/20 21:30:32 riastradh Exp $ # SODIUM_IMPORTDIR=${.CURDIR}/../../../../external/isc/libsodium @@ -11,7 +11,6 @@ SODIUM_DIR=${.CURDIR}/../../../../extern ${.CURDIR}/../../../../crypto/cast128\ ${.CURDIR}/../../../../crypto/des\ ${.CURDIR}/../../../../crypto/skipjack\ - ${.CURDIR}/../../../../external/cc0/libb2/dist/src \ ${SODIUM_DIR}/crypto_scalarmult/curve25519/ref10 \ ${SODIUM_DIR}/crypto_scalarmult/curve25519 \ ${SODIUM_DIR}/crypto_scalarmult \ @@ -58,9 +57,7 @@ SRCS+= des_ecb.c des_setkey.c des_enc.c SRCS+= skipjack.c # BLAKE2 -SRCS+= blake2s-ref.c -CPPFLAGS.blake2s-ref.c+= -I${.CURDIR}/../../../../external/cc0/libb2/include \ --Wno-cast-qual -DSUFFIX= +SRCS+= blake2s.c # Various cryptography functions SODIUM_CPPFLAGS=
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:31:16 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: Don't falsely assert cpu_softintr_p(). Will fail in the following stack trace: wg_worker (kthread) wg_receive_packets wg_handle_packet wg_handle_msg_data KASSERT(cpu_softintr_p()) Instead, use kpreempt_disable/enable around softint_schedule. XXX Not clear that softint is the right place to do this! To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.4 src/sys/net/if_wg.c:1.5 --- src/sys/net/if_wg.c:1.4 Thu Aug 20 21:31:06 2020 +++ src/sys/net/if_wg.c Thu Aug 20 21:31:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.4 2020/08/20 21:31:06 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.5 2020/08/20 21:31:16 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.4 2020/08/20 21:31:06 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.5 2020/08/20 21:31:16 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -2351,8 +2351,9 @@ wg_handle_msg_data(struct wg_softc *wg, mutex_exit(wgs_prev->wgs_lock); /* Anyway run a softint to flush pending packets */ - KASSERT(cpu_softintr_p()); + kpreempt_disable(); softint_schedule(wgp->wgp_si); + kpreempt_enable(); } else { if (__predict_false(wg_need_to_send_init_message(wgs))) { wg_schedule_peer_task(wgp, WGP_TASK_SEND_INIT_MESSAGE);
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:31:26 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.c Log Message: Make `wgconfig --help' and variations work. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/wgconfig/wgconfig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.c diff -u src/usr.sbin/wgconfig/wgconfig.c:1.1 src/usr.sbin/wgconfig/wgconfig.c:1.2 --- src/usr.sbin/wgconfig/wgconfig.c:1.1 Thu Aug 20 21:28:02 2020 +++ src/usr.sbin/wgconfig/wgconfig.c Thu Aug 20 21:31:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: wgconfig.c,v 1.1 2020/08/20 21:28:02 riastradh Exp $ */ +/* $NetBSD: wgconfig.c,v 1.2 2020/08/20 21:31:26 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: wgconfig.c,v 1.1 2020/08/20 21:28:02 riastradh Exp $"); +__RCSID("$NetBSD: wgconfig.c,v 1.2 2020/08/20 21:31:26 riastradh Exp $"); #include @@ -729,7 +729,10 @@ main(int argc, char *argv[]) const char *command; const char *target; - if (argc < 2) { + if (argc < 2 || + strcmp(argv[1], "-h") == 0 || + strcmp(argv[1], "-?") == 0 || + strcmp(argv[1], "--help") == 0) { usage(); }
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:29:44 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: [ozaki-r] Fix bugs found by maxv's audits To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.1 src/sys/net/if_wg.c:1.2 --- src/sys/net/if_wg.c:1.1 Thu Aug 20 21:28:01 2020 +++ src/sys/net/if_wg.c Thu Aug 20 21:29:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.1 2020/08/20 21:28:01 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.2 2020/08/20 21:29:44 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.1 2020/08/20 21:28:01 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.2 2020/08/20 21:29:44 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -2047,35 +2047,40 @@ wg_change_endpoint(struct wg_peer *wgp, wg_schedule_peer_task(wgp, WGP_TASK_ENDPOINT_CHANGED); } -static int -wg_determine_af(char *packet) +static bool +wg_validate_inner_packet(char *packet, size_t decrypted_len, int *af) { + uint16_t packet_len; struct ip *ip; - int af; + + if (__predict_false(decrypted_len < sizeof(struct ip))) + return false; ip = (struct ip *)packet; - af = ip->ip_v == 4 ? AF_INET : AF_INET6; - WG_DLOG("af=%d\n", af); + if (ip->ip_v == 4) + *af = AF_INET; + else if (ip->ip_v == 6) + *af = AF_INET6; + else + return false; - return af; -} + WG_DLOG("af=%d\n", *af); -static bool -wg_validate_inner_length(int af, char *packet, size_t expected_len) -{ - uint16_t actual_len; - - if (af == AF_INET) { - struct ip *ip = (struct ip *)packet; - actual_len = ntohs(ip->ip_len); + if (*af == AF_INET) { + packet_len = ntohs(ip->ip_len); } else { - struct ip6_hdr *ip6 = (struct ip6_hdr *)packet; - actual_len = sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen); + struct ip6_hdr *ip6; + + if (__predict_false(decrypted_len < sizeof(struct ip6_hdr))) + return false; + + ip6 = (struct ip6_hdr *)packet; + packet_len = sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen); } - WG_DLOG("actual_len=%u\n", actual_len); - if (actual_len > expected_len) { + + WG_DLOG("packet_len=%u\n", packet_len); + if (packet_len > decrypted_len) return false; - } return true; } @@ -2197,7 +2202,7 @@ static void wg_handle_msg_data(struct wg_softc *wg, struct mbuf *m, const struct sockaddr *src) { - struct wg_msg_data *wgmd = mtod(m, struct wg_msg_data *); + struct wg_msg_data *wgmd; char *encrypted_buf = NULL, *decrypted_buf; size_t encrypted_len, decrypted_len; struct wg_session *wgs; @@ -2208,6 +2213,13 @@ wg_handle_msg_data(struct wg_softc *wg, bool success, free_encrypted_buf = false, ok; struct mbuf *n; + if (m->m_len < sizeof(struct wg_msg_data)) { + m = m_pullup(m, sizeof(struct wg_msg_data)); + if (m == NULL) + return; + } + wgmd = mtod(m, struct wg_msg_data *); + KASSERT(wgmd->wgmd_type == WG_MSG_TYPE_DATA); WG_TRACE("data"); @@ -,6 +2234,11 @@ wg_handle_msg_data(struct wg_softc *wg, mlen = m_length(m); encrypted_len = mlen - sizeof(*wgmd); + if (encrypted_len < WG_AUTHTAG_LEN) { + WG_DLOG("Short encrypted_len: %lu\n", encrypted_len); + goto out; + } + success = m_ensure_contig(, sizeof(*wgmd) + encrypted_len); if (success) { encrypted_buf = mtod(m, char *) + sizeof(*wgmd); @@ -2231,15 +2248,20 @@ wg_handle_msg_data(struct wg_softc *wg, WG_DLOG("failed to allocate encrypted_buf\n"); goto out; } - m_copydata(m, sizeof(*wgmd), mlen - sizeof(*wgmd), - encrypted_buf); + m_copydata(m, sizeof(*wgmd), encrypted_len, encrypted_buf); free_encrypted_buf = true; } /* m_ensure_contig may change m regardless of its result */ wgmd = mtod(m, struct wg_msg_data *); - decrypted_len = encrypted_len; /* To avoid zero length */ - n = wg_get_mbuf(0, decrypted_len); + decrypted_len = encrypted_len - WG_AUTHTAG_LEN; + if (decrypted_len > MCLBYTES) { + /* FIXME handle larger data than MCLBYTES */ + WG_DLOG("couldn't handle larger data than MCLBYTES\n"); + goto out; + } + + n = wg_get_mbuf(0, decrypted_len + WG_AUTHTAG_LEN); /* To avoid zero length */ if (n == NULL) { WG_DLOG("wg_get_mbuf failed\n"); goto out; @@ -2275,8 +2297,7 @@ wg_handle_msg_data(struct wg_softc *wg, m = NULL; wgmd = NULL; - af = wg_determine_af(decrypted_buf); - ok = wg_validate_inner_length(af, decrypted_buf, decrypted_len); + ok = wg_validate_inner_packet(decrypted_buf, decrypted_len, ); if (!ok) { /* something wrong... */ m_freem(n); @@ -2359,7 +2380,7 @@ wg_handle_msg_data(struct wg_softc *wg, out: wg_put_session(wgs, ); if (m != NULL) - m_free(m); + m_freem(m); if (free_encrypted_buf) kmem_intr_free(encrypted_buf, encrypted_len); } @@ -2410,10 +2431,55 @@ out: wg_put_session(wgs, ); }
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:31:06 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: Convert wg(4) to if_stat. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.3 src/sys/net/if_wg.c:1.4 --- src/sys/net/if_wg.c:1.3 Thu Aug 20 21:30:56 2020 +++ src/sys/net/if_wg.c Thu Aug 20 21:31:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.3 2020/08/20 21:30:56 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.4 2020/08/20 21:31:06 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.3 2020/08/20 21:30:56 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.4 2020/08/20 21:31:06 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -3469,8 +3469,8 @@ wg_send_data_msg(struct wg_peer *wgp, st error = wg->wg_ops->send_data_msg(wgp, n); if (error == 0) { struct ifnet *ifp = >wg_if; - ifp->if_obytes += mlen; - ifp->if_opackets++; + if_statadd(ifp, if_obytes, mlen); + if_statinc(ifp, if_opackets); if (wgs->wgs_is_initiator && wgs->wgs_time_last_data_sent == 0) { /* * [W] 6.2 Transport Message Limits @@ -3531,8 +3531,8 @@ wg_input(struct ifnet *ifp, struct mbuf const u_int h = curcpu()->ci_index; if (__predict_true(pktq_enqueue(pktq, m, h))) { - ifp->if_ibytes += pktlen; - ifp->if_ipackets++; + if_statadd(ifp, if_ibytes, pktlen); + if_statinc(ifp, if_ipackets); } else { m_freem(m); }
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:30:56 UTC 2020 Modified Files: src/sys/external/isc/libsodium/include: randombytes.h src/sys/net: if_wg.c Log Message: Use cprng_strong, not cprng_fast, for ephemeral key. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/external/isc/libsodium/include/randombytes.h cvs rdiff -u -r1.2 -r1.3 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/isc/libsodium/include/randombytes.h diff -u src/sys/external/isc/libsodium/include/randombytes.h:1.1 src/sys/external/isc/libsodium/include/randombytes.h:1.2 --- src/sys/external/isc/libsodium/include/randombytes.h:1.1 Thu Aug 20 21:20:16 2020 +++ src/sys/external/isc/libsodium/include/randombytes.h Thu Aug 20 21:30:56 2020 @@ -1,11 +1,12 @@ /* This overwrites dist/src/libsodium/include/sodium/randombytes.h */ +#include + static inline void randombytes_buf(void * const buf, const size_t size) { - extern size_t cprng_fast(void *, size_t); - cprng_fast(buf, size); + cprng_strong(kern_cprng, buf, size, 0); } static inline void Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.2 src/sys/net/if_wg.c:1.3 --- src/sys/net/if_wg.c:1.2 Thu Aug 20 21:29:44 2020 +++ src/sys/net/if_wg.c Thu Aug 20 21:30:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.2 2020/08/20 21:29:44 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.3 2020/08/20 21:30:56 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.2 2020/08/20 21:29:44 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.3 2020/08/20 21:30:56 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -813,7 +813,7 @@ wg_algo_generate_keypair(uint8_t pubkey[ CTASSERT(WG_EPHEMERAL_KEY_LEN == crypto_scalarmult_curve25519_BYTES); - cprng_fast(privkey, WG_EPHEMERAL_KEY_LEN); + cprng_strong(kern_cprng, privkey, WG_EPHEMERAL_KEY_LEN, 0); crypto_scalarmult_base(pubkey, privkey); }
CVS commit: src/usr.sbin
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:30:46 UTC 2020 Modified Files: src/usr.sbin: Makefile Log Message: Descend into wg-userspace. To generate a diff of this commit: cvs rdiff -u -r1.284 -r1.285 src/usr.sbin/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/Makefile diff -u src/usr.sbin/Makefile:1.284 src/usr.sbin/Makefile:1.285 --- src/usr.sbin/Makefile:1.284 Thu Aug 20 21:21:32 2020 +++ src/usr.sbin/Makefile Thu Aug 20 21:30:46 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.284 2020/08/20 21:21:32 riastradh Exp $ +# $NetBSD: Makefile,v 1.285 2020/08/20 21:30:46 riastradh Exp $ # from: @(#)Makefile 5.20 (Berkeley) 6/12/93 .include @@ -30,8 +30,9 @@ SUBDIR= ac accton acpitools altq apm apm tadpolectl tcpdchk tcpdmatch tcpdrop timed tpctl tprof traceroute trpt \ unlink usbdevs user \ videomode vipw veriexecgen vnconfig \ - wakeonlan wg-keygen wgconfig wiconfig wlanctl wsconscfg wsfontload wsmoused \ - wsmuxctl zdump zic + wakeonlan wg-keygen wg-userspace wgconfig wiconfig wlanctl \ + wsconscfg wsfontload wsmoused wsmuxctl \ + zdump zic .if ${MKMAKEMANDB} != "no" SUBDIR+= makemandb
CVS commit: src
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:21:33 UTC 2020 Modified Files: src/sys/conf: files src/sys/net: Makefile files.net if_types.h src/sys/netinet: in.c in.h in_pcb.c in_pcb.h in_pcb_hdr.h ip_encap.c udp_usrreq.c udp_var.h src/sys/netinet6: in6_pcb.h udp6_usrreq.c src/sys/rump/kern/lib/libcrypto: Makefile src/sys/rump/net: Makefile.rumpnetcomp src/tests/net: Makefile src/usr.sbin: Makefile Log Message: [ozaki-r] Changes to the kernel core for wireguard To generate a diff of this commit: cvs rdiff -u -r1.1274 -r1.1275 src/sys/conf/files cvs rdiff -u -r1.42 -r1.43 src/sys/net/Makefile cvs rdiff -u -r1.25 -r1.26 src/sys/net/files.net cvs rdiff -u -r1.29 -r1.30 src/sys/net/if_types.h cvs rdiff -u -r1.236 -r1.237 src/sys/netinet/in.c cvs rdiff -u -r1.109 -r1.110 src/sys/netinet/in.h cvs rdiff -u -r1.183 -r1.184 src/sys/netinet/in_pcb.c cvs rdiff -u -r1.66 -r1.67 src/sys/netinet/in_pcb.h cvs rdiff -u -r1.13 -r1.14 src/sys/netinet/in_pcb_hdr.h cvs rdiff -u -r1.72 -r1.73 src/sys/netinet/ip_encap.c cvs rdiff -u -r1.258 -r1.259 src/sys/netinet/udp_usrreq.c cvs rdiff -u -r1.45 -r1.46 src/sys/netinet/udp_var.h cvs rdiff -u -r1.50 -r1.51 src/sys/netinet6/in6_pcb.h cvs rdiff -u -r1.147 -r1.148 src/sys/netinet6/udp6_usrreq.c cvs rdiff -u -r1.13 -r1.14 src/sys/rump/kern/lib/libcrypto/Makefile cvs rdiff -u -r1.20 -r1.21 src/sys/rump/net/Makefile.rumpnetcomp cvs rdiff -u -r1.34 -r1.35 src/tests/net/Makefile cvs rdiff -u -r1.283 -r1.284 src/usr.sbin/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/conf/files diff -u src/sys/conf/files:1.1274 src/sys/conf/files:1.1275 --- src/sys/conf/files:1.1274 Sat Aug 1 08:20:52 2020 +++ src/sys/conf/files Thu Aug 20 21:21:31 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files,v 1.1274 2020/08/01 08:20:52 maxv Exp $ +# $NetBSD: files,v 1.1275 2020/08/20 21:21:31 riastradh Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 version 20171118 @@ -217,6 +217,12 @@ include "crypto/nist_hash_drbg/files.nis # ChaCha-based fast PRNG include "crypto/cprng_fast/files.cprng_fast" +# BLAKE2s, a cryptographic hash function optimized for 8- to 32-bit +include "crypto/blake2/files.blake2s" + +# Various cryptography functions +include "crypto/sodium/files.sodium" + # # Kernel history/tracing. Old UVMHIST depends upon this. # @@ -1427,6 +1433,7 @@ defpseudo carp: ifnet, ether, arp defpseudodev l2tp: ifnet, ether, arp defpseudo canloop: ifnet defpseudo ipsecif: ifnet # avoid to confuse ipsec itself option +defpseudo wg: ifnet, blake2s, libsodium defpseudo sequencer defpseudo clockctl Index: src/sys/net/Makefile diff -u src/sys/net/Makefile:1.42 src/sys/net/Makefile:1.43 --- src/sys/net/Makefile:1.42 Wed Jan 29 03:16:28 2020 +++ src/sys/net/Makefile Thu Aug 20 21:21:32 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.42 2020/01/29 03:16:28 thorpej Exp $ +# $NetBSD: Makefile,v 1.43 2020/08/20 21:21:32 riastradh Exp $ INCSDIR= /usr/include/net @@ -6,7 +6,7 @@ INCS= bpf.h bpfjit.h bpfdesc.h dlt.h eth if_bridgevar.h if_dl.h if_ether.h if_gif.h \ if_gre.h if_ieee1394.h if_ipsec.h if_llc.h if_media.h if_mpls.h \ if_pflog.h if_ppp.h if_pppoe.h if_l2tp.h if_sppp.h if_srt.h if_stats.h \ - if_stf.h if_tap.h if_tun.h if_types.h if_vlanvar.h net_stats.h \ + if_stf.h if_tap.h if_tun.h if_types.h if_vlanvar.h if_wg.h net_stats.h \ netisr.h pfil.h pfkeyv2.h pfvar.h ppp-comp.h ppp_defs.h radix.h \ raw_cb.h route.h slcompress.h slip.h zlib.h Index: src/sys/net/files.net diff -u src/sys/net/files.net:1.25 src/sys/net/files.net:1.26 --- src/sys/net/files.net:1.25 Wed Jan 29 03:16:28 2020 +++ src/sys/net/files.net Thu Aug 20 21:21:32 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.net,v 1.25 2020/01/29 03:16:28 thorpej Exp $ +# $NetBSD: files.net,v 1.26 2020/08/20 21:21:32 riastradh Exp $ # XXX CLEANUP define net @@ -33,6 +33,7 @@ file net/if_tap.c tap file net/if_tun.c tun file net/if_vlan.c vlan needs-flag file net/if_pppoe.c pppoe needs-flag +file net/if_wg.c wg needs-flag file net/pfil.c net file net/ppp-deflate.c ppp & ppp_deflate file net/ppp_tty.c ppp Index: src/sys/net/if_types.h diff -u src/sys/net/if_types.h:1.29 src/sys/net/if_types.h:1.30 --- src/sys/net/if_types.h:1.29 Tue Jul 31 16:44:30 2018 +++ src/sys/net/if_types.h Thu Aug 20 21:21:32 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_types.h,v 1.29 2018/07/31 16:44:30 khorben Exp $ */ +/* $NetBSD: if_types.h,v 1.30 2020/08/20 21:21:32 riastradh Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -267,5 +267,6 @@ #define IFT_CARP 0xf8 /* Common Address Redundancy Protocol */ #define IFT_IPSEC 0xf9 /* IPsec I/F */ #define IFT_MBIM 0xfa /* Mobile Broadband Interface Model */ +#define IFT_WIREGUARD 0xfb /* WireGuard */ #endif /* !_NET_IF_TYPES_H_ */ Index: src/sys/netinet/in.c diff -u
CVS commit: src/sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:20:47 UTC 2020 Modified Files: src/sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10: ed25519_ref10.c Log Message: Split ge25519_scalarmult up in order to reduce stack usage. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 \ src/sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c diff -u src/sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c:1.2 src/sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c:1.3 --- src/sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c:1.2 Thu Aug 20 21:20:37 2020 +++ src/sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c Thu Aug 20 21:20:47 2020 @@ -748,18 +748,11 @@ ge25519_double_scalarmult_vartime(ge2551 p is public */ -void -ge25519_scalarmult(ge25519_p3 *h, const unsigned char *a, const ge25519_p3 *p) +static void __noinline +ge25519_scalarmult_cache(ge25519_cached pi[static 8], const ge25519_p3 *p) { -signed char e[64]; -signed char carry; -ge25519_p1p1r; -ge25519_p2 s; ge25519_p1p1t1; ge25519_p3 p2, p3, p4, pt; -ge25519_cached pi[8]; -ge25519_cached t; -int i; ge25519_p3_to_cached([1 - 1], p); /* p */ @@ -790,6 +783,18 @@ ge25519_scalarmult(ge25519_p3 *h, const ge25519_p3_dbl(, ); ge25519_p1p1_to_p3(, ); ge25519_p3_to_cached([8 - 1], ); /* 8p = 2*4p */ +} + +static void __noinline +ge25519_scalarmult_cached(ge25519_p3 *h, const unsigned char *a, +const ge25519_p3 *p, const ge25519_cached pi[static 8]) +{ +signed char e[64]; +signed char carry; +ge25519_p1p1r; +ge25519_p2 s; +ge25519_cached t; +int i; for (i = 0; i < 32; ++i) { e[2 * i + 0] = (a[i] >> 0) & 15; @@ -831,6 +836,15 @@ ge25519_scalarmult(ge25519_p3 *h, const ge25519_p1p1_to_p3(h, ); } +void +ge25519_scalarmult(ge25519_p3 *h, const unsigned char *a, const ge25519_p3 *p) +{ +ge25519_cached pi[8]; + +ge25519_scalarmult_cache(pi, p); +ge25519_scalarmult_cached(h, a, p, pi); +} + /* h = a * B (with precomputation) where a = a[0]+256*a[1]+...+256^31 a[31]
CVS commit: src/sys/crypto/blake2
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:21:05 UTC 2020 Added Files: src/sys/crypto/blake2: blake2s.c blake2s.h files.blake2s Log Message: Import small BLAKE2s implementation. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/crypto/blake2/blake2s.c \ src/sys/crypto/blake2/blake2s.h src/sys/crypto/blake2/files.blake2s Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/crypto/blake2/blake2s.c diff -u /dev/null src/sys/crypto/blake2/blake2s.c:1.1 --- /dev/null Thu Aug 20 21:21:05 2020 +++ src/sys/crypto/blake2/blake2s.c Thu Aug 20 21:21:05 2020 @@ -0,0 +1,350 @@ +/* $NetBSD: blake2s.c,v 1.1 2020/08/20 21:21:05 riastradh Exp $ */ + +/*- + * Copyright (c) 2015 Taylor R. Campbell + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef _KERNEL + +#include +__KERNEL_RCSID(0, "$NetBSD: blake2s.c,v 1.1 2020/08/20 21:21:05 riastradh Exp $"); + +#include +#include + +#include + +#else + +#define _POSIX_C_SOURCE 200809L + +#include +#include +#include + +#endif + +#include "blake2s.h" + +#include + +static inline uint32_t +rotr32(uint32_t x, unsigned c) +{ + + return ((x >> c) | (x << (32 - c))); +} + +#define BLAKE2S_G(VA, VB, VC, VD, X, Y) do \ +{ \ + (VA) = (VA) + (VB) + (X); \ + (VD) = rotr32((VD) ^ (VA), 16); \ + (VC) = (VC) + (VD); \ + (VB) = rotr32((VB) ^ (VC), 12); \ + (VA) = (VA) + (VB) + (Y); \ + (VD) = rotr32((VD) ^ (VA), 8); \ + (VC) = (VC) + (VD); \ + (VB) = rotr32((VB) ^ (VC), 7); \ +} while (0) + +static const uint32_t blake2s_iv[8] = { + 0x6a09e667U, 0xbb67ae85U, 0x3c6ef372U, 0xa54ff53aU, + 0x510e527fU, 0x9b05688cU, 0x1f83d9abU, 0x5be0cd19U, +}; + +static const uint8_t blake2s_sigma[10][16] = { + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, + { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }, + { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 }, + { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 }, + { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 }, + { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 }, + { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 }, + { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 }, + { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 }, + { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 }, +}; + +static void +blake2s_compress(uint32_t h[8], uint64_t c, uint32_t last, +const uint8_t in[64]) +{ + uint32_t v0,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15; + uint32_t m[16]; + unsigned i; + + /* Load the variables: first 8 from state, next 8 from IV. */ + v0 = h[0]; + v1 = h[1]; + v2 = h[2]; + v3 = h[3]; + v4 = h[4]; + v5 = h[5]; + v6 = h[6]; + v7 = h[7]; + v8 = blake2s_iv[0]; + v9 = blake2s_iv[1]; + v10 = blake2s_iv[2]; + v11 = blake2s_iv[3]; + v12 = blake2s_iv[4]; + v13 = blake2s_iv[5]; + v14 = blake2s_iv[6]; + v15 = blake2s_iv[7]; + + /* Incorporate the block counter and whether this is last. */ + v12 ^= c & 0xU; + v13 ^= c >> 32; + v14 ^= last; + + /* Load the message block. */ + for (i = 0; i < 16; i++) + m[i] = le32dec(in + 4*i); + + /* Transform the variables. */ + for (i = 0; i < 10; i++) { + const uint8_t *sigma = blake2s_sigma[i]; + + BLAKE2S_G(v0, v4, v8, v12, m[sigma[ 0]], m[sigma[ 1]]); + BLAKE2S_G(v1, v5, v9, v13, m[sigma[ 2]], m[sigma[ 3]]); + BLAKE2S_G(v2, v6, v10, v14, m[sigma[ 4]], m[sigma[ 5]]); + BLAKE2S_G(v3, v7, v11, v15, m[sigma[
CVS commit: src/sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:20:37 UTC 2020 Modified Files: src/sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10: ed25519_ref10.c Log Message: Reuse temporaries in ge25519_scalarmult to reduce stack usage. To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 \ src/sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c diff -u src/sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c:1.1.1.1 src/sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c:1.2 --- src/sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c:1.1.1.1 Thu Aug 20 21:17:06 2020 +++ src/sys/external/isc/libsodium/dist/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c Thu Aug 20 21:20:37 2020 @@ -755,41 +755,41 @@ ge25519_scalarmult(ge25519_p3 *h, const signed char carry; ge25519_p1p1r; ge25519_p2 s; -ge25519_p1p1t2, t3, t4, t5, t6, t7, t8; -ge25519_p3 p2, p3, p4, p5, p6, p7, p8; +ge25519_p1p1t1; +ge25519_p3 p2, p3, p4, pt; ge25519_cached pi[8]; ge25519_cached t; int i; ge25519_p3_to_cached([1 - 1], p); /* p */ -ge25519_p3_dbl(, p); -ge25519_p1p1_to_p3(, ); +ge25519_p3_dbl(, p); +ge25519_p1p1_to_p3(, ); ge25519_p3_to_cached([2 - 1], ); /* 2p = 2*p */ -ge25519_add(, p, [2 - 1]); -ge25519_p1p1_to_p3(, ); +ge25519_add(, p, [2 - 1]); +ge25519_p1p1_to_p3(, ); ge25519_p3_to_cached([3 - 1], ); /* 3p = 2p+p */ -ge25519_p3_dbl(, ); -ge25519_p1p1_to_p3(, ); +ge25519_p3_dbl(, ); +ge25519_p1p1_to_p3(, ); ge25519_p3_to_cached([4 - 1], ); /* 4p = 2*2p */ -ge25519_add(, p, [4 - 1]); -ge25519_p1p1_to_p3(, ); -ge25519_p3_to_cached([5 - 1], ); /* 5p = 4p+p */ - -ge25519_p3_dbl(, ); -ge25519_p1p1_to_p3(, ); -ge25519_p3_to_cached([6 - 1], ); /* 6p = 2*3p */ - -ge25519_add(, p, [6 - 1]); -ge25519_p1p1_to_p3(, ); -ge25519_p3_to_cached([7 - 1], ); /* 7p = 6p+p */ - -ge25519_p3_dbl(, ); -ge25519_p1p1_to_p3(, ); -ge25519_p3_to_cached([8 - 1], ); /* 8p = 2*4p */ +ge25519_add(, p, [4 - 1]); +ge25519_p1p1_to_p3(, ); +ge25519_p3_to_cached([5 - 1], ); /* 5p = 4p+p */ + +ge25519_p3_dbl(, ); +ge25519_p1p1_to_p3(, ); +ge25519_p3_to_cached([6 - 1], ); /* 6p = 2*3p */ + +ge25519_add(, p, [6 - 1]); +ge25519_p1p1_to_p3(, ); +ge25519_p3_to_cached([7 - 1], ); /* 7p = 6p+p */ + +ge25519_p3_dbl(, ); +ge25519_p1p1_to_p3(, ); +ge25519_p3_to_cached([8 - 1], ); /* 8p = 2*4p */ for (i = 0; i < 32; ++i) { e[2 * i + 0] = (a[i] >> 0) & 15;
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:20:17 UTC 2020 Added Files: src/sys/crypto/sodium: crypto_aead_chacha20poly1305.h crypto_aead_xchacha20poly1305.h crypto_kx.h crypto_scalarmult.h crypto_scalarmult_curve25519.h export.h files.sodium src/sys/external/isc/libsodium/conf: files.libsodium src/sys/external/isc/libsodium/include: assert.h core.h crypto_verify_16.h errno.h limits.h randombytes.h stddef.h stdint.h stdio.h stdlib.h string.h utils.h src/sys/external/isc/libsodium/src: glue.c Log Message: [ozaki-r] libsodium glue To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/crypto/sodium/crypto_aead_chacha20poly1305.h \ src/sys/crypto/sodium/crypto_aead_xchacha20poly1305.h \ src/sys/crypto/sodium/crypto_kx.h \ src/sys/crypto/sodium/crypto_scalarmult.h \ src/sys/crypto/sodium/crypto_scalarmult_curve25519.h \ src/sys/crypto/sodium/export.h src/sys/crypto/sodium/files.sodium cvs rdiff -u -r0 -r1.1 src/sys/external/isc/libsodium/conf/files.libsodium cvs rdiff -u -r0 -r1.1 src/sys/external/isc/libsodium/include/assert.h \ src/sys/external/isc/libsodium/include/core.h \ src/sys/external/isc/libsodium/include/crypto_verify_16.h \ src/sys/external/isc/libsodium/include/errno.h \ src/sys/external/isc/libsodium/include/limits.h \ src/sys/external/isc/libsodium/include/randombytes.h \ src/sys/external/isc/libsodium/include/stddef.h \ src/sys/external/isc/libsodium/include/stdint.h \ src/sys/external/isc/libsodium/include/stdio.h \ src/sys/external/isc/libsodium/include/stdlib.h \ src/sys/external/isc/libsodium/include/string.h \ src/sys/external/isc/libsodium/include/utils.h cvs rdiff -u -r0 -r1.1 src/sys/external/isc/libsodium/src/glue.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/crypto/sodium/crypto_aead_chacha20poly1305.h diff -u /dev/null src/sys/crypto/sodium/crypto_aead_chacha20poly1305.h:1.1 --- /dev/null Thu Aug 20 21:20:17 2020 +++ src/sys/crypto/sodium/crypto_aead_chacha20poly1305.h Thu Aug 20 21:20:16 2020 @@ -0,0 +1,704 @@ +#ifndef crypto_aead_chacha20poly1305_H +#define crypto_aead_chacha20poly1305_H + +#if 0 +#include +#endif +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +/* -- IETF ChaCha20-Poly1305 construction with a 96-bit nonce and a 32-bit internal counter -- */ + +#define crypto_aead_chacha20poly1305_ietf_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_aead_chacha20poly1305_ietf_keybytes(void); + +#define crypto_aead_chacha20poly1305_ietf_NSECBYTES 0U +SODIUM_EXPORT +size_t crypto_aead_chacha20poly1305_ietf_nsecbytes(void); + +#define crypto_aead_chacha20poly1305_ietf_NPUBBYTES 12U + +SODIUM_EXPORT +size_t crypto_aead_chacha20poly1305_ietf_npubbytes(void); + +#define crypto_aead_chacha20poly1305_ietf_ABYTES 16U +SODIUM_EXPORT +size_t crypto_aead_chacha20poly1305_ietf_abytes(void); + +#define crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX \ +SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_chacha20poly1305_ietf_ABYTES, \ + (64ULL * (1ULL << 32) - 64ULL) - crypto_aead_chacha20poly1305_ietf_ABYTES) +SODIUM_EXPORT +size_t crypto_aead_chacha20poly1305_ietf_messagebytes_max(void); + +SODIUM_EXPORT +int crypto_aead_chacha20poly1305_ietf_encrypt(unsigned char *c, + unsigned long long *clen_p, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *nsec, + const unsigned char *npub, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_aead_chacha20poly1305_ietf_decrypt(unsigned char *m, + unsigned long long *mlen_p, + unsigned char *nsec, + const unsigned char *c, + unsigned long long clen, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *npub, + const unsigned char *k) +__attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_aead_chacha20poly1305_ietf_encrypt_detached(unsigned char *c, + unsigned char *mac, +
CVS import: src/sys/external/isc/libsodium/dist
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:17:06 UTC 2020 Update of /cvsroot/src/sys/external/isc/libsodium/dist In directory ivanova.netbsd.org:/tmp/cvs-serv9899 Log Message: libsodium 1.0.16 Status: Vendor Tag: LIBSODIUM Release Tags: libsodium-1-0-16 N src/sys/external/isc/libsodium/dist/libsodium.sln N src/sys/external/isc/libsodium/dist/install-sh N src/sys/external/isc/libsodium/dist/libsodium.vcxproj N src/sys/external/isc/libsodium/dist/configure.ac N src/sys/external/isc/libsodium/dist/ltmain.sh N src/sys/external/isc/libsodium/dist/LICENSE N src/sys/external/isc/libsodium/dist/configure N src/sys/external/isc/libsodium/dist/libsodium.pc.in N src/sys/external/isc/libsodium/dist/ChangeLog N src/sys/external/isc/libsodium/dist/AUTHORS N src/sys/external/isc/libsodium/dist/libsodium-uninstalled.pc.in N src/sys/external/isc/libsodium/dist/config.guess N src/sys/external/isc/libsodium/dist/depcomp N src/sys/external/isc/libsodium/dist/missing N src/sys/external/isc/libsodium/dist/Makefile.am N src/sys/external/isc/libsodium/dist/config.sub N src/sys/external/isc/libsodium/dist/README.markdown N src/sys/external/isc/libsodium/dist/compile N src/sys/external/isc/libsodium/dist/THANKS N src/sys/external/isc/libsodium/dist/libsodium.vcxproj.filters N src/sys/external/isc/libsodium/dist/Makefile.in N src/sys/external/isc/libsodium/dist/aclocal.m4 N src/sys/external/isc/libsodium/dist/autogen.sh N src/sys/external/isc/libsodium/dist/build-aux/install-sh N src/sys/external/isc/libsodium/dist/build-aux/ltmain.sh N src/sys/external/isc/libsodium/dist/build-aux/config.guess N src/sys/external/isc/libsodium/dist/build-aux/depcomp N src/sys/external/isc/libsodium/dist/build-aux/missing N src/sys/external/isc/libsodium/dist/build-aux/config.sub N src/sys/external/isc/libsodium/dist/build-aux/compile N src/sys/external/isc/libsodium/dist/build-aux/test-driver N src/sys/external/isc/libsodium/dist/test/Makefile.am N src/sys/external/isc/libsodium/dist/test/Makefile.in N src/sys/external/isc/libsodium/dist/test/quirks/quirks.h N src/sys/external/isc/libsodium/dist/test/default/scalarmult7.exp N src/sys/external/isc/libsodium/dist/test/default/codecs.c N src/sys/external/isc/libsodium/dist/test/default/pwhash_argon2id.exp N src/sys/external/isc/libsodium/dist/test/default/sodium_utils2.c N src/sys/external/isc/libsodium/dist/test/default/core4.exp N src/sys/external/isc/libsodium/dist/test/default/verify1.c N src/sys/external/isc/libsodium/dist/test/default/core5.exp N src/sys/external/isc/libsodium/dist/test/default/box_easy.exp N src/sys/external/isc/libsodium/dist/test/default/box_seal.c N src/sys/external/isc/libsodium/dist/test/default/scalarmult6.exp N src/sys/external/isc/libsodium/dist/test/default/hash3.exp N src/sys/external/isc/libsodium/dist/test/default/core6.exp N src/sys/external/isc/libsodium/dist/test/default/keygen.c N src/sys/external/isc/libsodium/dist/test/default/kx.c N src/sys/external/isc/libsodium/dist/test/default/keygen.exp N src/sys/external/isc/libsodium/dist/test/default/hash2.exp N src/sys/external/isc/libsodium/dist/test/default/metamorphic.exp N src/sys/external/isc/libsodium/dist/test/default/scalarmult5.exp N src/sys/external/isc/libsodium/dist/test/default/kx.exp N src/sys/external/isc/libsodium/dist/test/default/sodium_core.c N src/sys/external/isc/libsodium/dist/test/default/auth.c N src/sys/external/isc/libsodium/dist/test/default/core2.exp N src/sys/external/isc/libsodium/dist/test/default/box_seed.exp N src/sys/external/isc/libsodium/dist/test/default/core3.c N src/sys/external/isc/libsodium/dist/test/default/scalarmult.exp N src/sys/external/isc/libsodium/dist/test/default/ed25519_convert.c N src/sys/external/isc/libsodium/dist/test/default/core3.exp N src/sys/external/isc/libsodium/dist/test/default/scalarmult2.exp N src/sys/external/isc/libsodium/dist/test/default/secretbox_easy.exp N src/sys/external/isc/libsodium/dist/test/default/chacha20.c N src/sys/external/isc/libsodium/dist/test/default/pwhash_scrypt.exp N src/sys/external/isc/libsodium/dist/test/default/stream3.c N src/sys/external/isc/libsodium/dist/test/default/core1.exp N src/sys/external/isc/libsodium/dist/test/default/auth7.exp N src/sys/external/isc/libsodium/dist/test/default/pwhash_scrypt_ll.c N src/sys/external/isc/libsodium/dist/test/default/auth3.c N src/sys/external/isc/libsodium/dist/test/default/generichash3.c N src/sys/external/isc/libsodium/dist/test/default/box7.c N src/sys/external/isc/libsodium/dist/test/default/scalarmult7.c N src/sys/external/isc/libsodium/dist/test/default/box.exp N src/sys/external/isc/libsodium/dist/test/default/secretbox7.c N src/sys/external/isc/libsodium/dist/test/default/core_ed25519.c N src/sys/external/isc/libsodium/dist/test/default/box8.exp N src/sys/external/isc/libsodium/dist/test/default/onetimeauth.exp N src/sys/external/isc/libsodium/dist/test/default/auth6.exp N
CVS commit: src/sys/ufs
Module Name:src Committed By: christos Date: Thu Aug 20 20:28:13 UTC 2020 Modified Files: src/sys/ufs/ffs: ffs_vfsops.c src/sys/ufs/ufs: inode.h ufs_vnops.c Log Message: Don't cache id's for vnodes that have ACLs. ok chs@ To generate a diff of this commit: cvs rdiff -u -r1.371 -r1.372 src/sys/ufs/ffs/ffs_vfsops.c cvs rdiff -u -r1.77 -r1.78 src/sys/ufs/ufs/inode.h cvs rdiff -u -r1.255 -r1.256 src/sys/ufs/ufs/ufs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_vfsops.c diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.371 src/sys/ufs/ffs/ffs_vfsops.c:1.372 --- src/sys/ufs/ffs/ffs_vfsops.c:1.371 Sun Jul 5 16:37:40 2020 +++ src/sys/ufs/ffs/ffs_vfsops.c Thu Aug 20 16:28:13 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_vfsops.c,v 1.371 2020/07/05 20:37:40 christos Exp $ */ +/* $NetBSD: ffs_vfsops.c,v 1.372 2020/08/20 20:28:13 christos Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.371 2020/07/05 20:37:40 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.372 2020/08/20 20:28:13 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -2139,7 +2139,7 @@ ffs_loadvnode(struct mount *mp, struct v ip->i_gid = ip->i_ffs1_ogid; /* XXX */ } /* XXX */ uvm_vnp_setsize(vp, ip->i_size); - cache_enter_id(vp, ip->i_mode, ip->i_uid, ip->i_gid, true); + cache_enter_id(vp, ip->i_mode, ip->i_uid, ip->i_gid, !HAS_ACLS(ip)); *new_key = >i_number; return 0; } @@ -2261,7 +2261,7 @@ ffs_newvnode(struct mount *mp, struct vn } uvm_vnp_setsize(vp, ip->i_size); - cache_enter_id(vp, ip->i_mode, ip->i_uid, ip->i_gid, true); + cache_enter_id(vp, ip->i_mode, ip->i_uid, ip->i_gid, !HAS_ACLS(ip)); *new_key = >i_number; return 0; } Index: src/sys/ufs/ufs/inode.h diff -u src/sys/ufs/ufs/inode.h:1.77 src/sys/ufs/ufs/inode.h:1.78 --- src/sys/ufs/ufs/inode.h:1.77 Sat Apr 18 15:18:34 2020 +++ src/sys/ufs/ufs/inode.h Thu Aug 20 16:28:13 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: inode.h,v 1.77 2020/04/18 19:18:34 christos Exp $ */ +/* $NetBSD: inode.h,v 1.78 2020/08/20 20:28:13 christos Exp $ */ /* * Copyright (c) 1982, 1989, 1993 @@ -238,6 +238,14 @@ struct inode { #if defined(_KERNEL) /* + * This macro does not differentiate between having extattrs and having + * extattrs containing ACLS, but that's ok since it is only used to + * determine if we are eligible for namei cache and we can be pessimistic + */ +#define HAS_ACLS(ip) \ +((ip)->i_ump->um_fstype == UFS2 && (ip)->i_ffs2_extsize > 0) + +/* * The DIP macro is used to access fields in the dinode that are * not cached in the inode itself. */ Index: src/sys/ufs/ufs/ufs_vnops.c diff -u src/sys/ufs/ufs/ufs_vnops.c:1.255 src/sys/ufs/ufs/ufs_vnops.c:1.256 --- src/sys/ufs/ufs/ufs_vnops.c:1.255 Mon May 18 04:28:44 2020 +++ src/sys/ufs/ufs/ufs_vnops.c Thu Aug 20 16:28:13 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vnops.c,v 1.255 2020/05/18 08:28:44 hannken Exp $ */ +/* $NetBSD: ufs_vnops.c,v 1.256 2020/08/20 20:28:13 christos Exp $ */ /*- * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.255 2020/05/18 08:28:44 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.256 2020/08/20 20:28:13 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -669,7 +669,7 @@ ufs_setattr(void *v) } VN_KNOTE(vp, NOTE_ATTRIB); out: - cache_enter_id(vp, ip->i_mode, ip->i_uid, ip->i_gid, true); + cache_enter_id(vp, ip->i_mode, ip->i_uid, ip->i_gid, !HAS_ACLS(ip)); return (error); } @@ -740,7 +740,7 @@ ufs_chmod(struct vnode *vp, int mode, ka ip->i_flag |= IN_CHANGE; DIP_ASSIGN(ip, mode, ip->i_mode); UFS_WAPBL_UPDATE(vp, NULL, NULL, 0); - cache_enter_id(vp, ip->i_mode, ip->i_uid, ip->i_gid, true); + cache_enter_id(vp, ip->i_mode, ip->i_uid, ip->i_gid, !HAS_ACLS(ip)); return (0); } @@ -810,7 +810,7 @@ ufs_chown(struct vnode *vp, uid_t uid, g #endif /* QUOTA || QUOTA2 */ ip->i_flag |= IN_CHANGE; UFS_WAPBL_UPDATE(vp, NULL, NULL, 0); - cache_enter_id(vp, ip->i_mode, ip->i_uid, ip->i_gid, true); + cache_enter_id(vp, ip->i_mode, ip->i_uid, ip->i_gid, !HAS_ACLS(ip)); return (0); }
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Thu Aug 20 19:43:42 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: cond-token-var.exp cond-token-var.mk Log Message: make(1): add test for variable expressions in conditions To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cond-token-var.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-token-var.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/cond-token-var.exp diff -u src/usr.bin/make/unit-tests/cond-token-var.exp:1.1 src/usr.bin/make/unit-tests/cond-token-var.exp:1.2 --- src/usr.bin/make/unit-tests/cond-token-var.exp:1.1 Sun Aug 16 12:07:51 2020 +++ src/usr.bin/make/unit-tests/cond-token-var.exp Thu Aug 20 19:43:42 2020 @@ -1 +1,7 @@ -exit status 0 +make: "cond-token-var.mk" line 9: ok +make: "cond-token-var.mk" line 15: Malformed conditional (${UNDEF} == ${DEF}) +make: "cond-token-var.mk" line 20: Malformed conditional (${DEF} == ${UNDEF}) +make: "cond-token-var.mk" line 29: Malformed conditional (${UNDEF}) +make: Fatal errors encountered -- cannot continue +make: stopped in unit-tests +exit status 1 Index: src/usr.bin/make/unit-tests/cond-token-var.mk diff -u src/usr.bin/make/unit-tests/cond-token-var.mk:1.2 src/usr.bin/make/unit-tests/cond-token-var.mk:1.3 --- src/usr.bin/make/unit-tests/cond-token-var.mk:1.2 Sun Aug 16 14:25:16 2020 +++ src/usr.bin/make/unit-tests/cond-token-var.mk Thu Aug 20 19:43:42 2020 @@ -1,8 +1,34 @@ -# $NetBSD: cond-token-var.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $ +# $NetBSD: cond-token-var.mk,v 1.3 2020/08/20 19:43:42 rillig Exp $ # # Tests for variables in .if conditions. -# TODO: Implementation +DEF= defined -all: - @:; +# A defined variable may appear on either side of the comparison. +.if ${DEF} == ${DEF} +.info ok +.else +.error +.endif + +# A variable that appears on the left-hand side must be defined. +.if ${UNDEF} == ${DEF} +.error +.endif + +# A variable that appears on the right-hand side must be defined. +.if ${DEF} == ${UNDEF} +.error +.endif + +# A defined variable may appear as an expression of its own. +.if ${DEF} +.endif + +# An undefined variable generates a warning. +.if ${UNDEF} +.endif + +# The :U modifier turns an undefined variable into an ordinary expression. +.if ${UNDEF:U} +.endif
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Aug 20 18:47:57 UTC 2020 Modified Files: src/usr.bin/make: cond.c Log Message: make(1): move complicated boolean expression out of the function call It's easier to inspect in a debugger this way. To generate a diff of this commit: cvs rdiff -u -r1.97 -r1.98 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.97 src/usr.bin/make/cond.c:1.98 --- src/usr.bin/make/cond.c:1.97 Thu Aug 20 17:11:47 2020 +++ src/usr.bin/make/cond.c Thu Aug 20 18:47:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.97 2020/08/20 17:11:47 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.98 2020/08/20 18:47:57 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: cond.c,v 1.97 2020/08/20 17:11:47 rillig Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.98 2020/08/20 18:47:57 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: cond.c,v 1.97 2020/08/20 17:11:47 rillig Exp $"); +__RCSID("$NetBSD: cond.c,v 1.98 2020/08/20 18:47:57 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -392,6 +392,7 @@ CondGetString(Boolean doEval, Boolean *q int len; Boolean qt; const char *start; +VarEvalFlags eflags; Buf_Init(, 0); str = NULL; @@ -428,9 +429,9 @@ CondGetString(Boolean doEval, Boolean *q break; case '$': /* if we are in quotes, then an undefined variable is ok */ - str = Var_Parse(condExpr, VAR_CMD, - ((!qt && doEval) ? VARE_UNDEFERR : 0) | - (doEval ? VARE_WANTRES : 0), , freeIt); + eflags = ((!qt && doEval) ? VARE_UNDEFERR : 0) | + (doEval ? VARE_WANTRES : 0); + str = Var_Parse(condExpr, VAR_CMD, eflags, , freeIt); if (str == var_Error) { if (*freeIt) { free(*freeIt);
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Thu Aug 20 18:43:19 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: cond-cmp-string.exp cond-cmp-string.mk Log Message: make(1): add test for string literals in comparisons To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cond-cmp-string.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-cmp-string.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/cond-cmp-string.exp diff -u src/usr.bin/make/unit-tests/cond-cmp-string.exp:1.1 src/usr.bin/make/unit-tests/cond-cmp-string.exp:1.2 --- src/usr.bin/make/unit-tests/cond-cmp-string.exp:1.1 Sun Aug 16 12:07:51 2020 +++ src/usr.bin/make/unit-tests/cond-cmp-string.exp Thu Aug 20 18:43:19 2020 @@ -1 +1,5 @@ -exit status 0 +make: "cond-cmp-string.mk" line 18: Malformed conditional (str != str) +make: "cond-cmp-string.mk" line 37: Malformed conditional ("string" != "str""ing") +make: Fatal errors encountered -- cannot continue +make: stopped in unit-tests +exit status 1 Index: src/usr.bin/make/unit-tests/cond-cmp-string.mk diff -u src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.2 src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.3 --- src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.2 Sun Aug 16 14:25:16 2020 +++ src/usr.bin/make/unit-tests/cond-cmp-string.mk Thu Aug 20 18:43:19 2020 @@ -1,8 +1,39 @@ -# $NetBSD: cond-cmp-string.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $ +# $NetBSD: cond-cmp-string.mk,v 1.3 2020/08/20 18:43:19 rillig Exp $ # # Tests for string comparisons in .if conditions. -# TODO: Implementation +# This is a simple comparison of string literals. +# Nothing surprising here. +.if "str" != "str" +.error +.endif -all: - @:; +# The right-hand side of the comparison may be written without quotes. +.if "str" != str +.error +.endif + +# The left-hand side of the comparison must be enclosed in quotes. +# This one is not enclosed in quotes and thus generates an error message. +.if str != str +.error +.endif + +# The left-hand side of the comparison requires a defined variable. +# The variable named "" is not defined, but applying the :U modifier to it +# makes it "kind of defined" (see VAR_KEEP). Therefore it is ok here. +.if ${:Ustr} != "str" +.error +.endif + +# Any character in a string literal may be escaped using a backslash. +# This means that "\n" does not mean a newline but a simple "n". +.if "string" != "\s\t\r\i\n\g" +.error +.endif + +# It is not possible to concatenate two string literals to form a single +# string. +.if "string" != "str""ing" +.error +.endif
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Thu Aug 20 18:05:57 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: Makefile Log Message: make(1): enable debug logging for archive test This test succeeds locally on NetBSD 8.0 but not in the official test runs on https://releng.netbsd.org/test-results.html. To see the difference, run the test with full debug information. This test is commented out in usr.bin/make/unit-tests/Makefile, but that doesn't stop tests/usr.bin/make/t_make.sh from running it nevertheless, since over there, all *.mk files are considered tests, be they commented out or not. To generate a diff of this commit: cvs rdiff -u -r1.103 -r1.104 src/usr.bin/make/unit-tests/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.103 src/usr.bin/make/unit-tests/Makefile:1.104 --- src/usr.bin/make/unit-tests/Makefile:1.103 Thu Aug 20 17:45:47 2020 +++ src/usr.bin/make/unit-tests/Makefile Thu Aug 20 18:05:57 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.103 2020/08/20 17:45:47 rillig Exp $ +# $NetBSD: Makefile,v 1.104 2020/08/20 18:05:57 rillig Exp $ # # Unit tests for make(1) # @@ -306,6 +306,7 @@ ENV.varmisc+= FROM_ENV_BEFORE=env ENV.varmisc+= FROM_ENV_AFTER=env # Override make flags for some of the tests; default is -k. +FLAGS.archive= -dA FLAGS.counter= -dv FLAGS.doterror= # none FLAGS.envfirst= -e
CVS commit: src
Module Name:src Committed By: rillig Date: Thu Aug 20 17:45:47 UTC 2020 Modified Files: src/distrib/sets/lists/tests: mi src/usr.bin/make/unit-tests: Makefile cond-func-defined.exp Added Files: src/usr.bin/make/unit-tests: cond-func.exp cond-func.mk Log Message: make(1): add test for parsing functions in .if conditions To generate a diff of this commit: cvs rdiff -u -r1.894 -r1.895 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.102 -r1.103 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-func-defined.exp cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/cond-func.exp \ src/usr.bin/make/unit-tests/cond-func.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.894 src/distrib/sets/lists/tests/mi:1.895 --- src/distrib/sets/lists/tests/mi:1.894 Tue Aug 18 07:13:59 2020 +++ src/distrib/sets/lists/tests/mi Thu Aug 20 17:45:46 2020 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.894 2020/08/18 07:13:59 nakayama Exp $ +# $NetBSD: mi,v 1.895 2020/08/20 17:45:46 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -4546,6 +4546,8 @@ ./usr/tests/usr.bin/make/unit-tests/cond-func-make.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/cond-func-target.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/cond-func-target.mk tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/cond-func.exp tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/cond-func.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/cond-late.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/cond-late.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/cond-op-and.exp tests-usr.bin-tests compattestfile,atf Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.102 src/usr.bin/make/unit-tests/Makefile:1.103 --- src/usr.bin/make/unit-tests/Makefile:1.102 Wed Aug 19 05:25:26 2020 +++ src/usr.bin/make/unit-tests/Makefile Thu Aug 20 17:45:47 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.102 2020/08/19 05:25:26 rillig Exp $ +# $NetBSD: Makefile,v 1.103 2020/08/20 17:45:47 rillig Exp $ # # Unit tests for make(1) # @@ -40,6 +40,7 @@ TESTS+= cmdline TESTS+= comment TESTS+= cond-cmp-numeric TESTS+= cond-cmp-string +TESTS+= cond-func TESTS+= cond-func-commands TESTS+= cond-func-defined TESTS+= cond-func-empty Index: src/usr.bin/make/unit-tests/cond-func-defined.exp diff -u src/usr.bin/make/unit-tests/cond-func-defined.exp:1.2 src/usr.bin/make/unit-tests/cond-func-defined.exp:1.3 --- src/usr.bin/make/unit-tests/cond-func-defined.exp:1.2 Thu Aug 20 17:23:43 2020 +++ src/usr.bin/make/unit-tests/cond-func-defined.exp Thu Aug 20 17:45:47 2020 @@ -1,5 +1,5 @@ -make: "cond-func-defined.mk" line 25: warning: Missing closing parenthesis for defined() -make: "cond-func-defined.mk" line 25: Malformed conditional (!defined(A B)) +make: "cond-func-defined.mk" line 23: warning: Missing closing parenthesis for defined() +make: "cond-func-defined.mk" line 23: Malformed conditional (!defined(A B)) make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Added files: Index: src/usr.bin/make/unit-tests/cond-func.exp diff -u /dev/null src/usr.bin/make/unit-tests/cond-func.exp:1.1 --- /dev/null Thu Aug 20 17:45:47 2020 +++ src/usr.bin/make/unit-tests/cond-func.exp Thu Aug 20 17:45:47 2020 @@ -0,0 +1,9 @@ +make: "cond-func.mk" line 29: warning: Missing closing parenthesis for defined() +make: "cond-func.mk" line 29: Malformed conditional (!defined(A B)) +make: "cond-func.mk" line 44: warning: Missing closing parenthesis for defined() +make: "cond-func.mk" line 44: Malformed conditional (!defined(A)) +make: "cond-func.mk" line 47: warning: Missing closing parenthesis for defined() +make: "cond-func.mk" line 47: Malformed conditional (!defined(A|B)) +make: Fatal errors encountered -- cannot continue +make: stopped in unit-tests +exit status 1 Index: src/usr.bin/make/unit-tests/cond-func.mk diff -u /dev/null src/usr.bin/make/unit-tests/cond-func.mk:1.1 --- /dev/null Thu Aug 20 17:45:47 2020 +++ src/usr.bin/make/unit-tests/cond-func.mk Thu Aug 20 17:45:47 2020 @@ -0,0 +1,63 @@ +# $NetBSD: cond-func.mk,v 1.1 2020/08/20 17:45:47 rillig Exp $ +# +# Tests for those parts of the functions in .if conditions that are common +# among several functions. +# +# The below test uses the function defined(...) since it has no side-effects, +# the other functions (except empty(...)) would work equally well. + +DEF= defined +${:UA B}= variable name with spaces +${:UVAR(value)}= variable name with parentheses +${:UVAR{value}}= variable name
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Thu Aug 20 17:23:44 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: cond-func-defined.exp cond-func-defined.mk Log Message: make(1): add test for the function defined(...) To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cond-func-defined.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-func-defined.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/cond-func-defined.exp diff -u src/usr.bin/make/unit-tests/cond-func-defined.exp:1.1 src/usr.bin/make/unit-tests/cond-func-defined.exp:1.2 --- src/usr.bin/make/unit-tests/cond-func-defined.exp:1.1 Sun Aug 16 12:07:51 2020 +++ src/usr.bin/make/unit-tests/cond-func-defined.exp Thu Aug 20 17:23:43 2020 @@ -1 +1,5 @@ -exit status 0 +make: "cond-func-defined.mk" line 25: warning: Missing closing parenthesis for defined() +make: "cond-func-defined.mk" line 25: Malformed conditional (!defined(A B)) +make: Fatal errors encountered -- cannot continue +make: stopped in unit-tests +exit status 1 Index: src/usr.bin/make/unit-tests/cond-func-defined.mk diff -u src/usr.bin/make/unit-tests/cond-func-defined.mk:1.2 src/usr.bin/make/unit-tests/cond-func-defined.mk:1.3 --- src/usr.bin/make/unit-tests/cond-func-defined.mk:1.2 Sun Aug 16 14:25:16 2020 +++ src/usr.bin/make/unit-tests/cond-func-defined.mk Thu Aug 20 17:23:43 2020 @@ -1,8 +1,33 @@ -# $NetBSD: cond-func-defined.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $ +# $NetBSD: cond-func-defined.mk,v 1.3 2020/08/20 17:23:43 rillig Exp $ # # Tests for the defined() function in .if conditions. -# TODO: Implementation +DEF= defined +${:UA B}= variable name with spaces + +.if !defined(DEF) +.error +.endif + +# Horizontal whitespace after the opening parenthesis is ignored. +.if !defined( DEF) +.error +.endif + +# Horizontal whitespace before the closing parenthesis is ignored. +.if !defined(DEF ) +.error +.endif + +# The argument of a function must not directly contain whitespace. +.if !defined(A B) +.error +.endif + +# If necessary, the whitespace can be generated by a variable expression. +.if !defined(${:UA B}) +.error +.endif all: @:;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Aug 20 17:13:06 UTC 2020 Modified Files: src/usr.bin/make: make.h Log Message: make(1): remove unused function declarations To generate a diff of this commit: cvs rdiff -u -r1.117 -r1.118 src/usr.bin/make/make.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.117 src/usr.bin/make/make.h:1.118 --- src/usr.bin/make/make.h:1.117 Thu Aug 20 17:06:26 2020 +++ src/usr.bin/make/make.h Thu Aug 20 17:13:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.117 2020/08/20 17:06:26 rillig Exp $ */ +/* $NetBSD: make.h,v 1.118 2020/08/20 17:13:05 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -480,8 +480,6 @@ void Make_HandleUse(GNode *, GNode *); void Make_Update(GNode *); void Make_DoAllVar(GNode *); Boolean Make_Run(Lst); -char * Check_Cwd_Cmd(const char *); -void Check_Cwd(const char **); int dieQuietly(GNode *, int); void PrintOnError(GNode *, const char *); void Main_ExportMAKEFLAGS(Boolean);
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Aug 20 17:11:47 UTC 2020 Modified Files: src/usr.bin/make: cond.c Log Message: make(1): fix type of string length variables To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.96 src/usr.bin/make/cond.c:1.97 --- src/usr.bin/make/cond.c:1.96 Thu Aug 20 17:06:26 2020 +++ src/usr.bin/make/cond.c Thu Aug 20 17:11:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.96 2020/08/20 17:06:26 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.97 2020/08/20 17:11:47 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: cond.c,v 1.96 2020/08/20 17:06:26 rillig Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.97 2020/08/20 17:11:47 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: cond.c,v 1.96 2020/08/20 17:06:26 rillig Exp $"); +__RCSID("$NetBSD: cond.c,v 1.97 2020/08/20 17:11:47 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -494,7 +494,7 @@ cleanup: /* The different forms of #if's. */ static const struct If { const char *form; /* Form of if */ -int formlen; /* Length of form */ +size_t formlen; /* Length of form */ Boolean doNot; /* TRUE if default function should be negated */ Boolean (*defProc)(int, const char *); /* Default function to apply */ } ifs[] = { @@ -731,7 +731,7 @@ compare_function(Boolean doEval) { static const struct fn_def { const char *fn_name; - int fn_name_len; + size_t fn_name_len; int (*fn_getarg)(Boolean, const char **, char **, const char *); Boolean (*fn_proc)(int, const char *); } fn_defs[] = {
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Aug 20 17:06:26 UTC 2020 Modified Files: src/usr.bin/make: cond.c make.h Log Message: make(1): fix wrong or outdated comments To generate a diff of this commit: cvs rdiff -u -r1.95 -r1.96 src/usr.bin/make/cond.c cvs rdiff -u -r1.116 -r1.117 src/usr.bin/make/make.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.95 src/usr.bin/make/cond.c:1.96 --- src/usr.bin/make/cond.c:1.95 Thu Aug 13 20:13:46 2020 +++ src/usr.bin/make/cond.c Thu Aug 20 17:06:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.95 2020/08/13 20:13:46 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.96 2020/08/20 17:06:26 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: cond.c,v 1.95 2020/08/13 20:13:46 rillig Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.96 2020/08/20 17:06:26 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: cond.c,v 1.95 2020/08/13 20:13:46 rillig Exp $"); +__RCSID("$NetBSD: cond.c,v 1.96 2020/08/20 17:06:26 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -121,8 +121,7 @@ __RCSID("$NetBSD: cond.c,v 1.95 2020/08/ * T -> ! T * op -> == | != | > | < | >= | <= * - * 'symbol' is some other symbol to which the default function (condDefProc) - * is applied. + * 'symbol' is some other symbol to which the default function is applied. * * Tokens are scanned from the 'condExpr' string. The scanner (CondToken) * will return TOK_AND for '&' and '&&', TOK_OR for '|' and '||', @@ -141,10 +140,6 @@ typedef enum { TOK_LPAREN, TOK_RPAREN, TOK_EOF, TOK_NONE, TOK_ERROR } Token; -/*- - * Structures to handle elegantly the different forms of #if's. The - * last two fields are stored in condInvert and condDefProc, respectively. - */ static Token CondE(Boolean); static CondEvalResult do_Cond_EvalExpression(Boolean *); @@ -496,6 +491,7 @@ cleanup: return str; } +/* The different forms of #if's. */ static const struct If { const char *form; /* Form of if */ int formlen; /* Length of form */ Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.116 src/usr.bin/make/make.h:1.117 --- src/usr.bin/make/make.h:1.116 Thu Aug 13 03:54:57 2020 +++ src/usr.bin/make/make.h Thu Aug 20 17:06:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.116 2020/08/13 03:54:57 rillig Exp $ */ +/* $NetBSD: make.h,v 1.117 2020/08/20 17:06:26 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -440,7 +440,7 @@ extern pid_t myPid; * There is one bit per module. It is up to the module what debug * information to print. */ -extern FILE *debug_file; /* Output written here - default stdout */ +extern FILE *debug_file; /* Output is written here - default stderr */ extern int debug; #define DEBUG_ARCH 0x1 #define DEBUG_COND 0x2
CVS commit: [netbsd-9] src/doc
Module Name:src Committed By: martin Date: Thu Aug 20 16:16:33 UTC 2020 Modified Files: src/doc [netbsd-9]: CHANGES-9.1 Log Message: Ticket #1059 To generate a diff of this commit: cvs rdiff -u -r1.1.2.99 -r1.1.2.100 src/doc/CHANGES-9.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES-9.1 diff -u src/doc/CHANGES-9.1:1.1.2.99 src/doc/CHANGES-9.1:1.1.2.100 --- src/doc/CHANGES-9.1:1.1.2.99 Wed Aug 19 18:38:02 2020 +++ src/doc/CHANGES-9.1 Thu Aug 20 16:16:33 2020 @@ -1,4 +1,4 @@ -# $NetBSD: CHANGES-9.1,v 1.1.2.99 2020/08/19 18:38:02 martin Exp $ +# $NetBSD: CHANGES-9.1,v 1.1.2.100 2020/08/20 16:16:33 martin Exp $ A complete list of changes from the NetBSD 9.0 release to the NetBSD 9.1 release: @@ -4779,3 +4779,10 @@ sys/uvm/uvm_amap.c1.123 (patch) to allocate the ppref memory. [chs, ticket #1057] +external/mit/xorg/server/xorg-server/doc/Makefile 1.6 +external/mit/xorg/server/xorg-server/hw/xfree86/doc/Makefile 1.8 +share/mk/bsd.x11.mk1.133,1.136 + + Fix unexpanded @foo@ tags in X11 manual pages. + [kim, ticket #1059] +
CVS commit: [netbsd-9] src
Module Name:src Committed By: martin Date: Thu Aug 20 16:15:44 UTC 2020 Modified Files: src/external/mit/xorg/server/xorg-server/doc [netbsd-9]: Makefile src/external/mit/xorg/server/xorg-server/hw/xfree86/doc [netbsd-9]: Makefile src/share/mk [netbsd-9]: bsd.x11.mk Log Message: Pull up following revision(s) (requested by kim in ticket #1059): share/mk/bsd.x11.mk: revision 1.133 share/mk/bsd.x11.mk: revision 1.136 external/mit/xorg/server/xorg-server/hw/xfree86/doc/Makefile: revision 1.8 external/mit/xorg/server/xorg-server/doc/Makefile: revision 1.6 Allow overriding the default man substitutions with X11EXTRAMANTRANSFORMS fix various missing transforms for man page, ala PR#55422. add method to transform both the "__foo__" and "@foo@" version of various transforms, while upstream are converting from the former to the latter it seems. convert all the common transforms to this method. expand the grep for .pc files to look for missing @foo@ fixes to the man page genration, and ignore a few things (thanks uwe@ - .IN lines, and stuff between tab(@) and .TE.) xorg-server __default_font_path__ -> @default_font_path@, and xfree86 transform xconfigdir, xkbdir, and modulepath using new both method. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.5.16.1 \ src/external/mit/xorg/server/xorg-server/doc/Makefile cvs rdiff -u -r1.7 -r1.7.16.1 \ src/external/mit/xorg/server/xorg-server/hw/xfree86/doc/Makefile cvs rdiff -u -r1.132.2.1 -r1.132.2.2 src/share/mk/bsd.x11.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/mit/xorg/server/xorg-server/doc/Makefile diff -u src/external/mit/xorg/server/xorg-server/doc/Makefile:1.5 src/external/mit/xorg/server/xorg-server/doc/Makefile:1.5.16.1 --- src/external/mit/xorg/server/xorg-server/doc/Makefile:1.5 Sun Aug 14 00:03:58 2016 +++ src/external/mit/xorg/server/xorg-server/doc/Makefile Thu Aug 20 16:15:44 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.5 2016/08/14 00:03:58 mrg Exp $ +# $NetBSD: Makefile,v 1.5.16.1 2020/08/20 16:15:44 martin Exp $ .include @@ -7,7 +7,7 @@ .PATH: ${X11SRCDIR.xorg-server}/doc .PATH: ${X11SRCDIR.xorg-server}/man MAN= Xserver.1 -X11EXTRAMANDEFS+= -e 's%__default_font_path__%${X11DEFAULTFONTPATH:ts,:S/,/, /g}%g' +X11EXTRAMANDEFS+= -e 's%@default_font_path@%${X11DEFAULTFONTPATH:ts,:S/,/, /g}%g' .include .include Index: src/external/mit/xorg/server/xorg-server/hw/xfree86/doc/Makefile diff -u src/external/mit/xorg/server/xorg-server/hw/xfree86/doc/Makefile:1.7 src/external/mit/xorg/server/xorg-server/hw/xfree86/doc/Makefile:1.7.16.1 --- src/external/mit/xorg/server/xorg-server/hw/xfree86/doc/Makefile:1.7 Sun Aug 14 03:43:04 2016 +++ src/external/mit/xorg/server/xorg-server/hw/xfree86/doc/Makefile Thu Aug 20 16:15:43 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.7 2016/08/14 03:43:04 mrg Exp $ +# $NetBSD: Makefile,v 1.7.16.1 2020/08/20 16:15:43 martin Exp $ .include @@ -12,5 +12,10 @@ FILESDIR= ${X11USRLIBDIR}/X11/doc MAN= Xorg.1 xorg.conf.5 # xorg.conf.d.5? +X11EXTRAMANTRANSFORMS_BOTH+= \ + xconfigdir xorg.conf.d \ + xkbdir ${X11LIBDIR}/xkb \ + modulepath ${X11ROOTDIR}/modules + .include .include Index: src/share/mk/bsd.x11.mk diff -u src/share/mk/bsd.x11.mk:1.132.2.1 src/share/mk/bsd.x11.mk:1.132.2.2 --- src/share/mk/bsd.x11.mk:1.132.2.1 Sun Jul 26 10:59:47 2020 +++ src/share/mk/bsd.x11.mk Thu Aug 20 16:15:43 2020 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.x11.mk,v 1.132.2.1 2020/07/26 10:59:47 martin Exp $ +# $NetBSD: bsd.x11.mk,v 1.132.2.2 2020/08/20 16:15:43 martin Exp $ .include @@ -136,7 +136,7 @@ XORG_SERVER_TEENY= 6 XORG_SERVER_MINOR= 20 XORG_SERVER_TEENY= 5 .endif - + XVENDORNAMESHORT= '"X.Org"' XVENDORNAME= '"The X.Org Foundation"' XORG_RELEASE= '"Release ${XORG_SERVER_MAJOR}.${XORG_SERVER_MINOR}.${XORG_SERVER_TEENY}"' @@ -194,6 +194,15 @@ realall: ${CPPSCRIPTS} CLEANFILES+= ${CPPSCRIPTS} .endif# } +# Used by pkg-config and manual handling to ensure we picked up all +# the necessary changes. +# +# Skip any line that starts with .IN (old X11 indexing method), +# or between a tab(@) and .TE. +_X11SKIP_FALSE_POSITIVE_GREP_CMD= \ + ${TOOL_SED} -e '/tab(@)/,/^\.TE/d' -e '/^\.IN /d' ${.TARGET}.tmp | \ + ${TOOL_GREP} -E '@([^ ]+)@' + # # X.Org pkgconfig files handling # @@ -356,14 +365,13 @@ ${_pkg}.pc: ${PKGDIST.${_pkg}}/configure s,@FREETYPE_CFLAGS@,-I${X11ROOTDIR}/include/freetype2 -I${X11ROOTDIR}/include,;" \ -e '/^Libs:/ s%-L\([^ ]*\)%-Wl,-rpath,\1 &%g' \ < ${.IMPSRC} > ${.TARGET}.tmp - if ${TOOL_GREP} '@.*@' ${.TARGET}.tmp; then \ - echo "${.TARGET} matches @.*@, probably missing updates" 1>&2; \ + if ${_X11SKIP_FALSE_POSITIVE_GREP_CMD}; then \ + echo "pkg-config ${.TARGET} matches @.*@, probably missing updates" 1>&2; \ false; \ else \ ${MV} ${.TARGET}.tmp
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Thu Aug 20 16:15:50 UTC 2020 Modified Files: src/bin/sh: trap.c Log Message: Whitespace. NFCI. To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/bin/sh/trap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/trap.c diff -u src/bin/sh/trap.c:1.53 src/bin/sh/trap.c:1.54 --- src/bin/sh/trap.c:1.53 Mon Dec 9 00:14:30 2019 +++ src/bin/sh/trap.c Thu Aug 20 16:15:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.53 2019/12/09 00:14:30 kre Exp $ */ +/* $NetBSD: trap.c,v 1.54 2020/08/20 16:15:50 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95"; #else -__RCSID("$NetBSD: trap.c,v 1.53 2019/12/09 00:14:30 kre Exp $"); +__RCSID("$NetBSD: trap.c,v 1.54 2020/08/20 16:15:50 kre Exp $"); #endif #endif /* not lint */ @@ -115,7 +115,7 @@ signame_to_signum(const char *p) if (strcasecmp(p, "exit") == 0 ) return 0; - + i = signalnumber(p); if (i == 0) i = -1; @@ -153,7 +153,7 @@ printsignals(struct output *out, int len outc(' ', out); for (n = 1; n < NSIG; n++) { outfmt(out, "%s", trap_signame(n)); - if ((n == NSIG/2) || n == (NSIG - 1)) + if ((n == NSIG/2) || n == (NSIG - 1)) outstr("\n", out); else outc(' ', out); @@ -580,7 +580,7 @@ setsignal(int signo, int vforked) switch (action) { case S_DFL: sigact = SIG_DFL; break; - case S_CATCH: sigact = onsig; break; + case S_CATCH: sigact = onsig; break; case S_IGN: sigact = SIG_IGN; break; } @@ -694,7 +694,7 @@ onsig(int signo) if (signo == SIGINT && (traps_invalid || trap[SIGINT] == NULL)) { VTRACE(DBG_SIG, ("onsig(SIGINT), doing it now\n")); - if (suppressint && !in_dotrap) + if (suppressint && !in_dotrap) intpending = 1; else onint(); @@ -841,7 +841,7 @@ exitshell_savedstatus(void) sigset_t sigs; CTRACE(DBG_ERRS|DBG_PROCS|DBG_CMDS|DBG_TRAP, - ("pid %d: exitshell_savedstatus()%s $?=%d xs=%d dt=%d ts=%d\n", + ("pid %d: exitshell_savedstatus()%s $?=%d xs=%d dt=%d ts=%d\n", getpid(), exiting ? " exiting" : "", exitstatus, exiting_status, in_dotrap, last_trapsig));
CVS commit: src
Module Name:src Committed By: riastradh Date: Thu Aug 20 15:54:12 UTC 2020 Modified Files: src/external/bsd/ppp/usr.sbin/pppd: tdb.c src/external/bsd/tre/dist/src: agrep.c src/external/cddl/osnet/dist/cmd/ztest: ztest.c src/external/cddl/osnet/dist/common/ctf: ctf_open.c src/external/cddl/osnet/dist/lib/libctf/common: ctf_lib.c src/lib/libc/tls: tls.c src/sbin/newfs: mkfs.c src/sys/arch/amiga/stand/bootblock/elf2bb: elf2bb.c src/usr.sbin/acpitools/acpidump: acpi_user.c src/usr.sbin/acpitools/amldb: amldb.c Log Message: mmap MAP_FAILED audit. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/external/bsd/ppp/usr.sbin/pppd/tdb.c cvs rdiff -u -r1.3 -r1.4 src/external/bsd/tre/dist/src/agrep.c cvs rdiff -u -r1.8 -r1.9 src/external/cddl/osnet/dist/cmd/ztest/ztest.c cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/dist/common/ctf/ctf_open.c cvs rdiff -u -r1.7 -r1.8 \ src/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c cvs rdiff -u -r1.13 -r1.14 src/lib/libc/tls/tls.c cvs rdiff -u -r1.129 -r1.130 src/sbin/newfs/mkfs.c cvs rdiff -u -r1.16 -r1.17 src/sys/arch/amiga/stand/bootblock/elf2bb/elf2bb.c cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/acpitools/acpidump/acpi_user.c cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/acpitools/amldb/amldb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/ppp/usr.sbin/pppd/tdb.c diff -u src/external/bsd/ppp/usr.sbin/pppd/tdb.c:1.1 src/external/bsd/ppp/usr.sbin/pppd/tdb.c:1.2 --- src/external/bsd/ppp/usr.sbin/pppd/tdb.c:1.1 Thu Nov 28 22:33:43 2013 +++ src/external/bsd/ppp/usr.sbin/pppd/tdb.c Thu Aug 20 15:54:11 2020 @@ -222,6 +222,8 @@ static int tdb_oob(TDB_CONTEXT *tdb, tdb tdb->map_ptr = (void *)mmap(NULL, tdb->map_size, tdb->read_only?PROT_READ:PROT_READ|PROT_WRITE, MAP_SHARED | MAP_FILE, tdb->fd, 0); + if (tdb->map_ptr == MAP_FAILED) + tdb->map_ptr = NULL; #endif return 0; } @@ -389,6 +391,8 @@ static int tdb_expand(TDB_CONTEXT *tdb, tdb->map_ptr = (void *)mmap(NULL, tdb->map_size, PROT_READ|PROT_WRITE, MAP_SHARED | MAP_FILE, tdb->fd, 0); + if (tdb->map_ptr == MAP_FAILED) + tdb->map_ptr = NULL; } #endif @@ -1194,6 +1198,8 @@ TDB_CONTEXT *tdb_open(char *name, int ha tdb.map_ptr = (void *)mmap(NULL, st.st_size, tdb.read_only? PROT_READ : PROT_READ|PROT_WRITE, MAP_SHARED | MAP_FILE, tdb.fd, 0); + if (tdb->map_ptr == MAP_FAILED) + tdb->map_ptr = NULL; } #endif Index: src/external/bsd/tre/dist/src/agrep.c diff -u src/external/bsd/tre/dist/src/agrep.c:1.3 src/external/bsd/tre/dist/src/agrep.c:1.4 --- src/external/bsd/tre/dist/src/agrep.c:1.3 Fri Jun 10 05:11:18 2016 +++ src/external/bsd/tre/dist/src/agrep.c Thu Aug 20 15:54:11 2020 @@ -336,6 +336,10 @@ isbinaryfile(const char *filename) } else { size = (size_t)st.st_size; mapped = mmap(NULL, size, PROT_READ, MAP_SHARED, fileno(fp), 0); + if (mapped == MAP_FAILED) { + fclose(fp); + return 1; + } for (i = 0 ; !isbin && i < size ; i++) { if (mapped[i] == 0x0) { isbin = 1; Index: src/external/cddl/osnet/dist/cmd/ztest/ztest.c diff -u src/external/cddl/osnet/dist/cmd/ztest/ztest.c:1.8 src/external/cddl/osnet/dist/cmd/ztest/ztest.c:1.9 --- src/external/cddl/osnet/dist/cmd/ztest/ztest.c:1.8 Mon May 28 21:05:04 2018 +++ src/external/cddl/osnet/dist/cmd/ztest/ztest.c Thu Aug 20 15:54:11 2020 @@ -6034,7 +6034,7 @@ setup_hdr(void) hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()), PROT_READ | PROT_WRITE, MAP_SHARED, ztest_fd_data, 0); - ASSERT(hdr != MAP_FAILED); + VERIFY(hdr != MAP_FAILED); VERIFY3U(0, ==, ftruncate(ztest_fd_data, sizeof (ztest_shared_hdr_t))); @@ -6061,14 +6061,14 @@ setup_data(void) hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()), PROT_READ, MAP_SHARED, ztest_fd_data, 0); - ASSERT(hdr != MAP_FAILED); + VERIFY(hdr != MAP_FAILED); size = shared_data_size(hdr); (void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize())); hdr = ztest_shared_hdr = (void *)mmap(0, P2ROUNDUP(size, getpagesize()), PROT_READ | PROT_WRITE, MAP_SHARED, ztest_fd_data, 0); - ASSERT(hdr != MAP_FAILED); + VERIFY(hdr != MAP_FAILED); buf = (uint8_t *)hdr; offset = hdr->zh_hdr_size; Index: src/external/cddl/osnet/dist/common/ctf/ctf_open.c diff -u src/external/cddl/osnet/dist/common/ctf/ctf_open.c:1.5 src/external/cddl/osnet/dist/common/ctf/ctf_open.c:1.6 --- src/external/cddl/osnet/dist/common/ctf/ctf_open.c:1.5 Sun Dec 27 21:39:01 2015 +++ src/external/cddl/osnet/dist/common/ctf/ctf_open.c Thu Aug 20 15:54:11 2020 @@ -814,7 +814,7 @@ ctf_dup(ctf_file_t *ofp) */ bcopy(>ctf_data,
CVS commit: src/tests/fs/nfs
Module Name:src Committed By: riastradh Date: Thu Aug 20 13:58:30 UTC 2020 Modified Files: src/tests/fs/nfs: t_rquotad.sh Log Message: Nix trailing whitespace. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/fs/nfs/t_rquotad.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/fs/nfs/t_rquotad.sh diff -u src/tests/fs/nfs/t_rquotad.sh:1.8 src/tests/fs/nfs/t_rquotad.sh:1.9 --- src/tests/fs/nfs/t_rquotad.sh:1.8 Thu Aug 20 07:32:40 2020 +++ src/tests/fs/nfs/t_rquotad.sh Thu Aug 20 13:58:30 2020 @@ -1,8 +1,8 @@ -# $NetBSD: t_rquotad.sh,v 1.8 2020/08/20 07:32:40 gson Exp $ +# $NetBSD: t_rquotad.sh,v 1.9 2020/08/20 13:58:30 riastradh Exp $ # # Copyright (c) 2011 Manuel Bouyer # All rights reserved. -# +# # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: @@ -11,7 +11,7 @@ # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# +# # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -33,7 +33,7 @@ test_case_rquotad() local name="${1}"; shift local check_function="${1}"; shift local descr="${1}"; shift - + atf_test_case "${name}" cleanup eval "${name}_head() { \
CVS commit: src/tests/dev/cgd
Module Name:src Committed By: riastradh Date: Thu Aug 20 13:33:54 UTC 2020 Modified Files: src/tests/dev/cgd: t_cgd_adiantum.c Log Message: clang can't handle __aligned on anonymous structure initializers. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/dev/cgd/t_cgd_adiantum.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/dev/cgd/t_cgd_adiantum.c diff -u src/tests/dev/cgd/t_cgd_adiantum.c:1.4 src/tests/dev/cgd/t_cgd_adiantum.c:1.5 --- src/tests/dev/cgd/t_cgd_adiantum.c:1.4 Sat Aug 15 10:03:10 2020 +++ src/tests/dev/cgd/t_cgd_adiantum.c Thu Aug 20 13:33:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: t_cgd_adiantum.c,v 1.4 2020/08/15 10:03:10 mlelstv Exp $ */ +/* $NetBSD: t_cgd_adiantum.c,v 1.5 2020/08/20 13:33:54 riastradh Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -47,6 +47,9 @@ #define MAXSECSIZE 512 /* for now; should be cgd parameter */ #define IMGSIZE 0x101*512 +/* Used as buffer for cgd device I/O, must be at least 32-bit aligned. */ +static const uint8_t zerosector[512] __aligned(4); + static const struct { uint8_t key[32]; uint64_t blkno; @@ -58,7 +61,7 @@ static const struct { .key = {0}, .blkno = 0, .secsize = 512, - .ptxt = (const __aligned(4) uint8_t[512]) {0}, + .ptxt = zerosector, .ctxt = (const uint8_t[512]) { 0x51,0x6d,0xe2,0x81, 0x26,0xd5,0xc8,0xd7, 0xff,0xc6,0xc2,0xff, 0x39,0xbf,0x15,0x15, @@ -130,7 +133,7 @@ static const struct { .key = {0}, .blkno = 1, .secsize = 512, - .ptxt = (const __aligned(4) uint8_t[512]) {0}, + .ptxt = zerosector, .ctxt = (const uint8_t[512]) { 0xf2,0x23,0x68,0x5a, 0x15,0x11,0x56,0xa1, 0x71,0x57,0x5c,0x5e, 0x32,0xd4,0xdd,0xbb, @@ -202,7 +205,7 @@ static const struct { .key = {0}, .blkno = 0x100, .secsize = 512, - .ptxt = (const __aligned(4) uint8_t[512]) {0}, + .ptxt = zerosector, .ctxt = (const uint8_t[512]) { 0x32,0x26,0xaf,0x56, 0xbc,0x43,0xac,0x37, 0xb2,0x8d,0xa4,0xfb, 0x32,0xdc,0x09,0x03,
CVS commit: src/sys/dev/nvmm/x86
Module Name:src Committed By: maxv Date: Thu Aug 20 11:09:56 UTC 2020 Modified Files: src/sys/dev/nvmm/x86: nvmm_x86.c nvmm_x86.h nvmm_x86_svm.c nvmm_x86_vmx.c Log Message: nvmm-x86: improve the CPUID emulation - x86-svm: explicitly handle 0x8007 and 0x8008. The latter contains extended features we must filter out. Apply the same in x86-vmx for symmetry. - x86-svm: explicitly handle extended leaves until 0x801F, and truncate to it. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/dev/nvmm/x86/nvmm_x86.c cvs rdiff -u -r1.18 -r1.19 src/sys/dev/nvmm/x86/nvmm_x86.h cvs rdiff -u -r1.69 -r1.70 src/sys/dev/nvmm/x86/nvmm_x86_svm.c cvs rdiff -u -r1.70 -r1.71 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/nvmm/x86/nvmm_x86.c diff -u src/sys/dev/nvmm/x86/nvmm_x86.c:1.13 src/sys/dev/nvmm/x86/nvmm_x86.c:1.14 --- src/sys/dev/nvmm/x86/nvmm_x86.c:1.13 Thu Aug 20 11:07:43 2020 +++ src/sys/dev/nvmm/x86/nvmm_x86.c Thu Aug 20 11:09:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86.c,v 1.13 2020/08/20 11:07:43 maxv Exp $ */ +/* $NetBSD: nvmm_x86.c,v 1.14 2020/08/20 11:09:56 maxv Exp $ */ /* * Copyright (c) 2018-2020 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvmm_x86.c,v 1.13 2020/08/20 11:07:43 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm_x86.c,v 1.14 2020/08/20 11:09:56 maxv Exp $"); #include #include @@ -421,6 +421,26 @@ const struct nvmm_x86_cpuid_mask nvmm_cp CPUID_3DNOW }; +const struct nvmm_x86_cpuid_mask nvmm_cpuid_8007 = { + .eax = 0, + .ebx = 0, + .ecx = 0, + .edx = CPUID_APM_ITSC +}; + +const struct nvmm_x86_cpuid_mask nvmm_cpuid_8008 = { + .eax = ~0, + .ebx = + CPUID_CAPEX_CLZERO | + /* CPUID_CAPEX_IRPERF excluded */ + CPUID_CAPEX_XSAVEERPTR | + /* CPUID_CAPEX_RDPRU excluded */ + /* CPUID_CAPEX_MCOMMIT excluded */ + CPUID_CAPEX_WBNOINVD, + .ecx = ~0, /* TODO? */ + .edx = 0 +}; + bool nvmm_x86_pat_validate(uint64_t val) { Index: src/sys/dev/nvmm/x86/nvmm_x86.h diff -u src/sys/dev/nvmm/x86/nvmm_x86.h:1.18 src/sys/dev/nvmm/x86/nvmm_x86.h:1.19 --- src/sys/dev/nvmm/x86/nvmm_x86.h:1.18 Mon Oct 28 08:30:49 2019 +++ src/sys/dev/nvmm/x86/nvmm_x86.h Thu Aug 20 11:09:56 2020 @@ -1,7 +1,7 @@ -/* $NetBSD: nvmm_x86.h,v 1.18 2019/10/28 08:30:49 maxv Exp $ */ +/* $NetBSD: nvmm_x86.h,v 1.19 2020/08/20 11:09:56 maxv Exp $ */ /* - * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. + * Copyright (c) 2018-2020 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -320,6 +320,8 @@ extern const struct nvmm_x64_state nvmm_ extern const struct nvmm_x86_cpuid_mask nvmm_cpuid_0001; extern const struct nvmm_x86_cpuid_mask nvmm_cpuid_0007; extern const struct nvmm_x86_cpuid_mask nvmm_cpuid_8001; +extern const struct nvmm_x86_cpuid_mask nvmm_cpuid_8007; +extern const struct nvmm_x86_cpuid_mask nvmm_cpuid_8008; bool nvmm_x86_pat_validate(uint64_t); #endif Index: src/sys/dev/nvmm/x86/nvmm_x86_svm.c diff -u src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.69 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.70 --- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.69 Tue Aug 18 17:08:05 2020 +++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c Thu Aug 20 11:09:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86_svm.c,v 1.69 2020/08/18 17:08:05 maxv Exp $ */ +/* $NetBSD: nvmm_x86_svm.c,v 1.70 2020/08/20 11:09:56 maxv Exp $ */ /* * Copyright (c) 2018-2020 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.69 2020/08/18 17:08:05 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.70 2020/08/20 11:09:56 maxv Exp $"); #include #include @@ -795,7 +795,9 @@ svm_inkernel_advance(struct vmcb *vmcb) #define SVM_CPUID_MAX_BASIC 0xD #define SVM_CPUID_MAX_HYPERVISOR 0x4000 +#define SVM_CPUID_MAX_EXTENDED 0x801F static uint32_t svm_cpuid_max_basic __read_mostly; +static uint32_t svm_cpuid_max_extended __read_mostly; static void svm_inkernel_exec_cpuid(struct svm_cpudata *cpudata, uint64_t eax, uint64_t ecx) @@ -825,6 +827,11 @@ svm_inkernel_handle_cpuid(struct nvmm_cp eax = svm_cpuid_max_basic; svm_inkernel_exec_cpuid(cpudata, eax, ecx); } + } else { + if (__predict_false(eax > svm_cpuid_max_extended)) { + eax = svm_cpuid_max_basic; + svm_inkernel_exec_cpuid(cpudata, eax, ecx); + } } switch (eax) { @@ -928,12 +935,74 @@ svm_inkernel_handle_cpuid(struct nvmm_cp memcpy(>gprs[NVMM_X64_GPR_RDX], " ___", 4); break; + case 0x8000: + cpudata->vmcb->state.rax = svm_cpuid_max_extended; + break; case 0x8001: cpudata->vmcb->state.rax &= nvmm_cpuid_8001.eax; cpudata->gprs[NVMM_X64_GPR_RBX] &= nvmm_cpuid_8001.ebx;
CVS commit: src/sys/dev/nvmm/x86
Module Name:src Committed By: maxv Date: Thu Aug 20 11:07:43 UTC 2020 Modified Files: src/sys/dev/nvmm/x86: nvmm_x86.c Log Message: nvmm-x86: advertise the SERIALIZE instruction, available on future CPUs To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/dev/nvmm/x86/nvmm_x86.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/nvmm/x86/nvmm_x86.c diff -u src/sys/dev/nvmm/x86/nvmm_x86.c:1.12 src/sys/dev/nvmm/x86/nvmm_x86.c:1.13 --- src/sys/dev/nvmm/x86/nvmm_x86.c:1.12 Tue Aug 11 15:23:10 2020 +++ src/sys/dev/nvmm/x86/nvmm_x86.c Thu Aug 20 11:07:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86.c,v 1.12 2020/08/11 15:23:10 maxv Exp $ */ +/* $NetBSD: nvmm_x86.c,v 1.13 2020/08/20 11:07:43 maxv Exp $ */ /* * Copyright (c) 2018-2020 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvmm_x86.c,v 1.12 2020/08/11 15:23:10 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm_x86.c,v 1.13 2020/08/20 11:07:43 maxv Exp $"); #include #include @@ -363,7 +363,7 @@ const struct nvmm_x86_cpuid_mask nvmm_cp /* CPUID_SEF_SRBDS_CTRL excluded */ CPUID_SEF_MD_CLEAR | /* CPUID_SEF_TSX_FORCE_ABORT excluded */ - /* CPUID_SEF_SERIALIZE excluded */ + CPUID_SEF_SERIALIZE | /* CPUID_SEF_HYBRID excluded */ /* CPUID_SEF_TSXLDTRK excluded */ /* CPUID_SEF_CET_IBT excluded */
CVS commit: src/sys/netinet6
Module Name:src Committed By: roy Date: Thu Aug 20 11:01:02 UTC 2020 Modified Files: src/sys/netinet6: nd6.h nd6_nbr.c Log Message: Sprinkle some const To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/sys/netinet6/nd6.h cvs rdiff -u -r1.179 -r1.180 src/sys/netinet6/nd6_nbr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/netinet6/nd6.h diff -u src/sys/netinet6/nd6.h:1.89 src/sys/netinet6/nd6.h:1.90 --- src/sys/netinet6/nd6.h:1.89 Fri Jun 12 11:04:45 2020 +++ src/sys/netinet6/nd6.h Thu Aug 20 11:01:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nd6.h,v 1.89 2020/06/12 11:04:45 roy Exp $ */ +/* $NetBSD: nd6.h,v 1.90 2020/08/20 11:01:02 roy Exp $ */ /* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */ /* @@ -200,7 +200,7 @@ void nd6_na_output(struct ifnet *, const const struct in6_addr *, u_long, int, const struct sockaddr *); void nd6_ns_input(struct mbuf *, int, int); void nd6_ns_output(struct ifnet *, const struct in6_addr *, - const struct in6_addr *, struct in6_addr *, uint8_t *); + const struct in6_addr *, const struct in6_addr *, const uint8_t *); const void *nd6_ifptomac(const struct ifnet *); void nd6_dad_start(struct ifaddr *, int); void nd6_dad_stop(struct ifaddr *); Index: src/sys/netinet6/nd6_nbr.c diff -u src/sys/netinet6/nd6_nbr.c:1.179 src/sys/netinet6/nd6_nbr.c:1.180 --- src/sys/netinet6/nd6_nbr.c:1.179 Fri Jun 12 11:04:45 2020 +++ src/sys/netinet6/nd6_nbr.c Thu Aug 20 11:01:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nd6_nbr.c,v 1.179 2020/06/12 11:04:45 roy Exp $ */ +/* $NetBSD: nd6_nbr.c,v 1.180 2020/08/20 11:01:02 roy Exp $ */ /* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */ /* @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.179 2020/06/12 11:04:45 roy Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.180 2020/08/20 11:01:02 roy Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -389,13 +389,14 @@ nd6_ns_input(struct mbuf *m, int off, in void nd6_ns_output(struct ifnet *ifp, const struct in6_addr *daddr6, const struct in6_addr *taddr6, -struct in6_addr *hsrc, -uint8_t *nonce /* duplicate address detection */) +const struct in6_addr *hsrc, +const uint8_t *nonce /* duplicate address detection */) { struct mbuf *m; struct ip6_hdr *ip6; struct nd_neighbor_solicit *nd_ns; - struct in6_addr *src, src_in; + const struct in6_addr *src; + struct in6_addr src_in; struct ip6_moptions im6o; int icmp6len; int maxlen;
CVS commit: src/libexec/httpd
Module Name:src Committed By: mrg Date: Thu Aug 20 07:56:27 UTC 2020 Modified Files: src/libexec/httpd: bozohttpd.c Log Message: compare mmap return again MAP_FAILED not -1 or 0. To generate a diff of this commit: cvs rdiff -u -r1.118 -r1.119 src/libexec/httpd/bozohttpd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/httpd/bozohttpd.c diff -u src/libexec/httpd/bozohttpd.c:1.118 src/libexec/httpd/bozohttpd.c:1.119 --- src/libexec/httpd/bozohttpd.c:1.118 Thu Aug 20 05:46:31 2020 +++ src/libexec/httpd/bozohttpd.c Thu Aug 20 07:56:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: bozohttpd.c,v 1.118 2020/08/20 05:46:31 spz Exp $ */ +/* $NetBSD: bozohttpd.c,v 1.119 2020/08/20 07:56:26 mrg Exp $ */ /* $eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $ */ @@ -914,7 +914,7 @@ mmap_and_write_part(bozohttpd_t *httpd, wroffset = (size_t)(first_byte_pos - mappedoffset); addr = mmap(0, mappedsz, PROT_READ, MAP_SHARED, fd, mappedoffset); - if (addr == (char *)-1) { + if (addr == MAP_FAILED) { bozowarn(httpd, "mmap failed: %s", strerror(errno)); return -1; } @@ -1201,7 +1201,7 @@ check_remap(bozo_httpreq_t *request) } fmap = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, mapfile, 0); - if (fmap == NULL) { + if (fmap == MAP_FAILED) { bozowarn(httpd, "could not mmap " REMAP_FILE ", error %d", errno); goto out;
CVS commit: src/libexec/httpd
Module Name:src Committed By: mrg Date: Thu Aug 20 07:57:01 UTC 2020 Modified Files: src/libexec/httpd: bozohttpd.c Log Message: call this bozohttpd/20200820 To generate a diff of this commit: cvs rdiff -u -r1.119 -r1.120 src/libexec/httpd/bozohttpd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/httpd/bozohttpd.c diff -u src/libexec/httpd/bozohttpd.c:1.119 src/libexec/httpd/bozohttpd.c:1.120 --- src/libexec/httpd/bozohttpd.c:1.119 Thu Aug 20 07:56:26 2020 +++ src/libexec/httpd/bozohttpd.c Thu Aug 20 07:57:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: bozohttpd.c,v 1.119 2020/08/20 07:56:26 mrg Exp $ */ +/* $NetBSD: bozohttpd.c,v 1.120 2020/08/20 07:57:01 mrg Exp $ */ /* $eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $ */ @@ -109,7 +109,7 @@ #define INDEX_HTML "index.html" #endif #ifndef SERVER_SOFTWARE -#define SERVER_SOFTWARE "bozohttpd/20190228" +#define SERVER_SOFTWARE "bozohttpd/20200820" #endif #ifndef PUBLIC_HTML #define PUBLIC_HTML "public_html"
CVS commit: src/libexec/httpd
Module Name:src Committed By: mrg Date: Thu Aug 20 07:55:10 UTC 2020 Modified Files: src/libexec/httpd: CHANGES bozohttpd.8 Log Message: update for recent changes. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/libexec/httpd/CHANGES cvs rdiff -u -r1.83 -r1.84 src/libexec/httpd/bozohttpd.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/httpd/CHANGES diff -u src/libexec/httpd/CHANGES:1.40 src/libexec/httpd/CHANGES:1.41 --- src/libexec/httpd/CHANGES:1.40 Thu Feb 28 09:16:42 2019 +++ src/libexec/httpd/CHANGES Thu Aug 20 07:55:10 2020 @@ -1,4 +1,10 @@ -$NetBSD: CHANGES,v 1.40 2019/02/28 09:16:42 mrg Exp $ +$NetBSD: CHANGES,v 1.41 2020/08/20 07:55:10 mrg Exp $ + +changes in bozohttpd 20200820: + o make this work on sun2 by reducing mmap window there. + o fix SSL shutdown sequence. from s...@netbsd.org. + o add readme support to directory indexing. from jmcne...@netbsd.org + o add blocklist(8) support. from jru...@netbsd.org. changes in bozohttpd 20190228: o extend timeout facility to ssl and stop servers hanging forever Index: src/libexec/httpd/bozohttpd.8 diff -u src/libexec/httpd/bozohttpd.8:1.83 src/libexec/httpd/bozohttpd.8:1.84 --- src/libexec/httpd/bozohttpd.8:1.83 Mon Jul 13 09:41:18 2020 +++ src/libexec/httpd/bozohttpd.8 Thu Aug 20 07:55:10 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: bozohttpd.8,v 1.83 2020/07/13 09:41:18 wiz Exp $ +.\" $NetBSD: bozohttpd.8,v 1.84 2020/08/20 07:55:10 mrg Exp $ .\" .\" $eterna: bozohttpd.8,v 1.101 2011/11/18 01:25:11 mrg Exp $ .\" @@ -701,8 +701,8 @@ provided initial IPv6 support .It .An Martin Husemann .Aq Mt mar...@netbsd.org -provided .bzabsredirect and .bzredir support, and fixed various -redirection issues +provided .bzabsredirect and .bzredir support, fixed various +redirection issues and more .It .An Arto Huusko .Aq Mt arto.huu...@pp2.inet.fi @@ -804,6 +804,19 @@ provided http authorization fixes .Aq Mt x...@kittenz.org provided chroot and change-to-user support, and other various fixes .It +.An Jukka Ruohonen +.Aq Mt jru...@netbsd.org +provided support for +.Xr blocklist 8 +.It +.An Jared McNeill +.Aq Mt jmcne...@netbsd.org +added support for readme in directory indexing +.It +.An S.P.Zeidler +.Aq Mt s...@netbsd.org +fixed several SSL shutdown issues +.It Coyote Point provided various CGI fixes .El .Pp
CVS commit: src/tests/fs/nfs
Module Name:src Committed By: gson Date: Thu Aug 20 07:32:40 UTC 2020 Modified Files: src/tests/fs/nfs: t_rquotad.sh Log Message: Add cleanup of possible leftover rump processes, replacing the non-working cleanup code just removed from ffs_common.sh. Fixes PR bin/48892 with respect to the t_rquotad test. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/fs/nfs/t_rquotad.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/fs/nfs/t_rquotad.sh diff -u src/tests/fs/nfs/t_rquotad.sh:1.7 src/tests/fs/nfs/t_rquotad.sh:1.8 --- src/tests/fs/nfs/t_rquotad.sh:1.7 Mon May 13 17:55:07 2019 +++ src/tests/fs/nfs/t_rquotad.sh Thu Aug 20 07:32:40 2020 @@ -1,4 +1,4 @@ -# $NetBSD: t_rquotad.sh,v 1.7 2019/05/13 17:55:07 bad Exp $ +# $NetBSD: t_rquotad.sh,v 1.8 2020/08/20 07:32:40 gson Exp $ # # Copyright (c) 2011 Manuel Bouyer # All rights reserved. @@ -24,10 +24,42 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # + +# Like test_case_root() in ../ffs/ffs_common.sh, plus cleanup of both +# rump servers. + +test_case_rquotad() +{ + local name="${1}"; shift + local check_function="${1}"; shift + local descr="${1}"; shift + + atf_test_case "${name}" cleanup + + eval "${name}_head() { \ + atf_set "descr" "${descr}" + atf_set "require.user" "root" + atf_set "timeout" "360" + }" + eval "${name}_body() { \ + RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \ + export RUMP_SERVER=unix://\${RUMP_SOCKET}; \ + ${check_function} " "${@}" "; \ + }" + # Can't use RUMP_SOCKETS_LIST here because it is not set in +# the cleanup shell. + eval "${name}_cleanup() { \ + for s in \${RUMP_SOCKET} clientsock; do \ + RUMP_SERVER=unix://\${s} rump.halt 2>/dev/null || true; \ + done; \ + }" + tests="${tests} ${name}" +} + for e in le be; do for v in 1; do for q in "user" "group" "both"; do - test_case_root get_nfs_${e}_${v}_${q} get_nfs_quota \ + test_case_rquotad get_nfs_${e}_${v}_${q} get_nfs_quota \ "get NFS quota with ${q} enabled" ${e} ${v} ${q} done done
CVS commit: src/tests/fs/ffs
Module Name:src Committed By: gson Date: Thu Aug 20 07:23:20 UTC 2020 Modified Files: src/tests/fs/ffs: ffs_common.sh Log Message: Remove non-functional cleanup code from test_case() and test_case_root(). It had no effect because RUMP_SOCKETS_LIST is not set in the shell running the cleanup phase. Even if RUMP_SOCKETS_LIST had been set, the code would still not have worked correctly because it ran rump.halt via "atf_check -s exit:1", which would cause the first successful halting of a rump processes to be treated as a failure and abort the cleanup without halting any other rump processes still running. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/fs/ffs/ffs_common.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/fs/ffs/ffs_common.sh diff -u src/tests/fs/ffs/ffs_common.sh:1.4 src/tests/fs/ffs/ffs_common.sh:1.5 --- src/tests/fs/ffs/ffs_common.sh:1.4 Mon Aug 17 06:18:39 2020 +++ src/tests/fs/ffs/ffs_common.sh Thu Aug 20 07:23:20 2020 @@ -1,4 +1,4 @@ -# $NetBSD: ffs_common.sh,v 1.4 2020/08/17 06:18:39 gson Exp $ +# $NetBSD: ffs_common.sh,v 1.5 2020/08/20 07:23:20 gson Exp $ create_ffs() { @@ -30,7 +30,7 @@ test_case() local check_function="${1}"; shift local descr="${1}"; shift - atf_test_case "${name}" cleanup + atf_test_case "${name}" eval "${name}_head() { \ atf_set "descr" "${descr}" @@ -41,12 +41,6 @@ test_case() export RUMP_SERVER=unix://\${RUMP_SOCKET}; \ ${check_function} " "${@}" "; \ }" - eval "${name}_cleanup() { \ - for s in \${RUMP_SOCKETS_LIST}; do \ - export RUMP_SERVER=unix://\${s}; \ - atf_check -s exit:1 -o ignore -e ignore rump.halt; \ - done; \ - }" tests="${tests} ${name}" } @@ -56,7 +50,7 @@ test_case_root() local check_function="${1}"; shift local descr="${1}"; shift - atf_test_case "${name}" cleanup + atf_test_case "${name}" eval "${name}_head() { \ atf_set "descr" "${descr}" @@ -68,12 +62,6 @@ test_case_root() export RUMP_SERVER=unix://\${RUMP_SOCKET}; \ ${check_function} " "${@}" "; \ }" - eval "${name}_cleanup() { \ - for s in \${RUMP_SOCKETS_LIST}; do \ - export RUMP_SERVER=unix://\${s}; \ - atf_check -s exit:1 -o ignore -e ignore rump.halt; \ - done; \ - }" tests="${tests} ${name}" }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Aug 20 07:15:52 UTC 2020 Modified Files: src/usr.bin/make: var.c Log Message: make(1): make a few comments more precise To generate a diff of this commit: cvs rdiff -u -r1.453 -r1.454 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.453 src/usr.bin/make/var.c:1.454 --- src/usr.bin/make/var.c:1.453 Thu Aug 20 07:09:06 2020 +++ src/usr.bin/make/var.c Thu Aug 20 07:15:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.453 2020/08/20 07:09:06 rillig Exp $ */ +/* $NetBSD: var.c,v 1.454 2020/08/20 07:15:52 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.453 2020/08/20 07:09:06 rillig Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.454 2020/08/20 07:15:52 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: var.c,v 1.453 2020/08/20 07:09:06 rillig Exp $"); +__RCSID("$NetBSD: var.c,v 1.454 2020/08/20 07:15:52 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -1921,19 +1921,18 @@ typedef struct { GNode * const ctxt; const VarEvalFlags eflags; -char *val; /* The value of the expression before the - * modifier is applied */ -char *newVal; /* The new value after applying the modifier - * to the expression */ +char *val; /* The old value of the expression, + * before applying the modifier */ +char *newVal; /* The new value of the expression, + * after applying the modifier */ char missing_delim; /* For error reporting */ char sep; /* Word separator in expansions * (see the :ts modifier) */ -Boolean oneBigWord; /* TRUE if the variable value is treated as a - * single big word, even if it contains - * embedded spaces (as opposed to the - * usual behaviour of treating it as - * several space-separated words). */ +Boolean oneBigWord; /* TRUE if some modifiers that otherwise split + * the variable value into words, like :S and + * :C, treat the variable value as a single big + * word, possibly containing spaces. */ } ApplyModifiersState; typedef enum {
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Aug 20 07:09:06 UTC 2020 Modified Files: src/usr.bin/make: var.c Log Message: make(1): use more descriptive variable name in ModifyWords To generate a diff of this commit: cvs rdiff -u -r1.452 -r1.453 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.452 src/usr.bin/make/var.c:1.453 --- src/usr.bin/make/var.c:1.452 Thu Aug 20 07:01:39 2020 +++ src/usr.bin/make/var.c Thu Aug 20 07:09:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.452 2020/08/20 07:01:39 rillig Exp $ */ +/* $NetBSD: var.c,v 1.453 2020/08/20 07:09:06 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.452 2020/08/20 07:01:39 rillig Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.453 2020/08/20 07:09:06 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: var.c,v 1.452 2020/08/20 07:01:39 rillig Exp $"); +__RCSID("$NetBSD: var.c,v 1.453 2020/08/20 07:09:06 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -1031,7 +1031,7 @@ Var_Value(const char *name, GNode *ctxt, typedef struct { Buffer buf; Boolean needSep; -char sep; +char sep; /* usually ' ', but see the :ts modifier */ } SepBuf; static void @@ -1554,15 +1554,15 @@ ModifyWord_Realpath(const char *word, Se * Input: * str String whose words should be modified * modifyWord Function that modifies a single word - * data Custom data for modifyWord + * modifyWord_args Custom arguments for modifyWord * * Results: * A string of all the words modified appropriately. *--- */ static char * -ModifyWords(GNode *ctx, char sep, Boolean oneBigWord, - const char *str, ModifyWordsCallback modifyWord, void *data) +ModifyWords(GNode *ctx, char sep, Boolean oneBigWord, const char *str, + ModifyWordsCallback modifyWord, void *modifyWord_args) { SepBuf result; char **av; /* word list */ @@ -1572,7 +1572,7 @@ ModifyWords(GNode *ctx, char sep, Boolea if (oneBigWord) { SepBuf_Init(, sep); - modifyWord(str, , data); + modifyWord(str, , modifyWord_args); return SepBuf_Destroy(, FALSE); } @@ -1583,7 +1583,7 @@ ModifyWords(GNode *ctx, char sep, Boolea VAR_DEBUG("ModifyWords: split \"%s\" into %d words\n", str, ac); for (i = 0; i < ac; i++) { - modifyWord(av[i], , data); + modifyWord(av[i], , modifyWord_args); if (result.buf.count > 0) SepBuf_Sep(); }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Aug 20 07:01:39 UTC 2020 Modified Files: src/usr.bin/make: var.c Log Message: make(1): remove VARP_SUB_MATCHED This flag didn't really belong to the other flags. The other flags are set during parsing and are then left as-is by ModifyWord_Subst and ModifyWord_SubstRegex. It's clearer to use a separate variable for storing whether there was a match already. To generate a diff of this commit: cvs rdiff -u -r1.451 -r1.452 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.451 src/usr.bin/make/var.c:1.452 --- src/usr.bin/make/var.c:1.451 Thu Aug 20 06:48:18 2020 +++ src/usr.bin/make/var.c Thu Aug 20 07:01:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.451 2020/08/20 06:48:18 rillig Exp $ */ +/* $NetBSD: var.c,v 1.452 2020/08/20 07:01:39 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.451 2020/08/20 06:48:18 rillig Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.452 2020/08/20 07:01:39 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: var.c,v 1.451 2020/08/20 06:48:18 rillig Exp $"); +__RCSID("$NetBSD: var.c,v 1.452 2020/08/20 07:01:39 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -277,9 +277,8 @@ typedef enum { typedef enum { VARP_SUB_GLOBAL = 0x01, /* Apply substitution globally */ VARP_SUB_ONE = 0x02, /* Apply substitution to one word */ -VARP_SUB_MATCHED = 0x04, /* There was a match */ -VARP_ANCHOR_START = 0x08, /* Match at start of word */ -VARP_ANCHOR_END = 0x10 /* Match at end of word */ +VARP_ANCHOR_START = 0x04, /* Match at start of word */ +VARP_ANCHOR_END = 0x08 /* Match at end of word */ } VarPatternFlags; typedef enum { @@ -1269,6 +1268,7 @@ typedef struct { const char *rhs; size_t rhsLen; VarPatternFlags pflags; +Boolean matched; } ModifyWord_SubstArgs; /* Callback for ModifyWords to implement the :S,from,to, modifier. @@ -1280,7 +1280,7 @@ ModifyWord_Subst(const char *word, SepBu ModifyWord_SubstArgs *args = data; const char *match; -if ((args->pflags & VARP_SUB_ONE) && (args->pflags & VARP_SUB_MATCHED)) +if ((args->pflags & VARP_SUB_ONE) && args->matched) goto nosub; if (args->pflags & VARP_ANCHOR_START) { @@ -1293,11 +1293,11 @@ ModifyWord_Subst(const char *word, SepBu goto nosub; SepBuf_AddBytes(buf, args->rhs, args->rhsLen); - args->pflags |= VARP_SUB_MATCHED; + args->matched = TRUE; } else { SepBuf_AddBytes(buf, args->rhs, args->rhsLen); SepBuf_AddBytes(buf, word + args->lhsLen, wordLen - args->lhsLen); - args->pflags |= VARP_SUB_MATCHED; + args->matched = TRUE; } return; } @@ -1314,7 +1314,7 @@ ModifyWord_Subst(const char *word, SepBu SepBuf_AddBytesBetween(buf, word, start); SepBuf_AddBytes(buf, args->rhs, args->rhsLen); - args->pflags |= VARP_SUB_MATCHED; + args->matched = TRUE; return; } @@ -1322,7 +1322,7 @@ ModifyWord_Subst(const char *word, SepBu while ((match = Str_FindSubstring(word, args->lhs)) != NULL) { SepBuf_AddBytesBetween(buf, word, match); SepBuf_AddBytes(buf, args->rhs, args->rhsLen); - args->pflags |= VARP_SUB_MATCHED; + args->matched = TRUE; wordLen -= (size_t)(match - word) + args->lhsLen; word += (size_t)(match - word) + args->lhsLen; if (wordLen == 0 || !(args->pflags & VARP_SUB_GLOBAL)) @@ -1349,6 +1349,7 @@ typedef struct { size_t nsub; char *replace; VarPatternFlags pflags; +Boolean matched; } ModifyWord_SubstRegexArgs; /* Callback for ModifyWords to implement the :C/from/to/ modifier. @@ -1363,7 +1364,7 @@ ModifyWord_SubstRegex(const char *word, int flags = 0; regmatch_t m[10]; -if ((args->pflags & VARP_SUB_ONE) && (args->pflags & VARP_SUB_MATCHED)) +if ((args->pflags & VARP_SUB_ONE) && args->matched) goto nosub; tryagain: @@ -1371,7 +1372,7 @@ tryagain: switch (xrv) { case 0: - args->pflags |= VARP_SUB_MATCHED; + args->matched = TRUE; SepBuf_AddBytes(buf, wp, (size_t)m[0].rm_so); for (rp = args->replace; *rp; rp++) { @@ -2316,6 +2317,7 @@ ApplyModifier_Subst(const char **pp, App *pp += 2; args.pflags = 0; +args.matched = FALSE; /* * If pattern begins with '^', it is anchored to the @@ -2401,6 +2403,7 @@ ApplyModifier_Regex(const char **pp, App } args.pflags = 0; +args.matched = FALSE; oneBigWord = st->oneBigWord; for (;; (*pp)++) { switch (**pp) {
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Aug 20 06:48:18 UTC 2020 Modified Files: src/usr.bin/make: var.c Log Message: make(1): consistently access args->pflags in ModifyWord_Subst It was confusing that some accesses were via pflags and some via args->pflags. To generate a diff of this commit: cvs rdiff -u -r1.450 -r1.451 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.450 src/usr.bin/make/var.c:1.451 --- src/usr.bin/make/var.c:1.450 Thu Aug 20 06:35:14 2020 +++ src/usr.bin/make/var.c Thu Aug 20 06:48:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.450 2020/08/20 06:35:14 rillig Exp $ */ +/* $NetBSD: var.c,v 1.451 2020/08/20 06:48:18 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.450 2020/08/20 06:35:14 rillig Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.451 2020/08/20 06:48:18 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: var.c,v 1.450 2020/08/20 06:35:14 rillig Exp $"); +__RCSID("$NetBSD: var.c,v 1.451 2020/08/20 06:48:18 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -1278,10 +1278,9 @@ ModifyWord_Subst(const char *word, SepBu { size_t wordLen = strlen(word); ModifyWord_SubstArgs *args = data; -const VarPatternFlags pflags = args->pflags; const char *match; -if ((pflags & VARP_SUB_ONE) && (pflags & VARP_SUB_MATCHED)) +if ((args->pflags & VARP_SUB_ONE) && (args->pflags & VARP_SUB_MATCHED)) goto nosub; if (args->pflags & VARP_ANCHOR_START) {
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Aug 20 06:35:14 UTC 2020 Modified Files: src/usr.bin/make: make_malloc.c make_malloc.h var.c Log Message: make(1): remove unreached code from bmake_strndup The "at most" branch was never taken since all call sites in var.c only ever need a substring, and the target buffer is not limited. Therefore rename the function and make it simpler. It's ok that bmake_strldup is defined as estrndup in case of USE_EMALLOC since that function's implementation is compatible to the "copy exactly", it just contains some extra null checks that will never match since the variable values cannot (well, or should not) contain null bytes. Theoretically they can, but the behavior then depends on the exact implementation and is unreliable, therefore nobody does this. After all, Makefiles are used for text processing, not for binary data. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/make_malloc.c cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/make_malloc.h cvs rdiff -u -r1.449 -r1.450 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/make_malloc.c diff -u src/usr.bin/make/make_malloc.c:1.14 src/usr.bin/make/make_malloc.c:1.15 --- src/usr.bin/make/make_malloc.c:1.14 Wed Aug 12 18:47:21 2020 +++ src/usr.bin/make/make_malloc.c Thu Aug 20 06:35:14 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: make_malloc.c,v 1.14 2020/08/12 18:47:21 rillig Exp $ */ +/* $NetBSD: make_malloc.c,v 1.15 2020/08/20 06:35:14 rillig Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ #ifdef MAKE_NATIVE #include -__RCSID("$NetBSD: make_malloc.c,v 1.14 2020/08/12 18:47:21 rillig Exp $"); +__RCSID("$NetBSD: make_malloc.c,v 1.15 2020/08/20 06:35:14 rillig Exp $"); #endif #include @@ -82,23 +82,13 @@ bmake_strdup(const char *str) return memcpy(p, str, len); } -/* - * bmake_strndup -- - * strndup, but die on error. - */ +/* Allocate a string starting from str with exactly len characters. */ char * -bmake_strndup(const char *str, size_t max_len) +bmake_strldup(const char *str, size_t len) { - size_t len; - char *p; - - for (len = 0; len < max_len; len++) - if (str[len] == '\0') - break; - p = bmake_malloc(len + 1); + char *p = bmake_malloc(len + 1); memcpy(p, str, len); p[len] = '\0'; - return p; } Index: src/usr.bin/make/make_malloc.h diff -u src/usr.bin/make/make_malloc.h:1.6 src/usr.bin/make/make_malloc.h:1.7 --- src/usr.bin/make/make_malloc.h:1.6 Sat Aug 1 14:47:49 2020 +++ src/usr.bin/make/make_malloc.h Thu Aug 20 06:35:14 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: make_malloc.h,v 1.6 2020/08/01 14:47:49 rillig Exp $ */ +/* $NetBSD: make_malloc.h,v 1.7 2020/08/20 06:35:14 rillig Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -30,13 +30,13 @@ void *bmake_malloc(size_t); void *bmake_realloc(void *, size_t); char *bmake_strdup(const char *); -char *bmake_strndup(const char *, size_t); +char *bmake_strldup(const char *, size_t); #else #include #define bmake_malloc(x) emalloc(x) #define bmake_realloc(x,y) erealloc(x,y) #define bmake_strdup(x) estrdup(x) -#define bmake_strndup(x,y) estrndup(x,y) +#define bmake_strldup(x,y) estrndup(x,y) #endif /* Thin wrapper around free(3) to avoid the extra function call in case Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.449 src/usr.bin/make/var.c:1.450 --- src/usr.bin/make/var.c:1.449 Thu Aug 13 04:12:13 2020 +++ src/usr.bin/make/var.c Thu Aug 20 06:35:14 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.449 2020/08/13 04:12:13 rillig Exp $ */ +/* $NetBSD: var.c,v 1.450 2020/08/20 06:35:14 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.449 2020/08/13 04:12:13 rillig Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.450 2020/08/20 06:35:14 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: var.c,v 1.449 2020/08/13 04:12:13 rillig Exp $"); +__RCSID("$NetBSD: var.c,v 1.450 2020/08/20 06:35:14 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -2280,7 +2280,7 @@ ApplyModifier_Match(const char **pp, App * Either Var_Subst or ModifyWords will need a * nul-terminated string soon, so construct one now. */ - pattern = bmake_strndup(mod + 1, (size_t)(endpat - (mod + 1))); + pattern = bmake_strldup(mod + 1, (size_t)(endpat - (mod + 1))); } if (needSubst) { @@ -2894,7 +2894,7 @@ ApplyModifier_Remember(const char **pp, if (mod[1] == '=') { size_t n = strcspn(mod + 2, ":)}"); - char *name = bmake_strndup(mod + 2, n); + char *name = bmake_strldup(mod + 2, n); Var_Set(name, st->val, st->ctxt); free(name); *pp = mod + 2 + n; @@ -3510,7 +3510,7 @@