CVS commit: src/sys
Module Name:src Committed By: isaki Date: Sat Sep 12 05:19:16 UTC 2020 Modified Files: src/sys/arch/sparc/conf: files.sparc src/sys/arch/sparc/dev: audioamd.c src/sys/arch/sparc/sparc: genassym.cf src/sys/arch/vax/vsa: vsaudio.c src/sys/dev/ic: am7930.c am7930var.h src/sys/dev/tc: bba.c Removed Files: src/sys/arch/sparc/dev: audioamdvar.h src/sys/arch/sparc/include: am7930_machdep.h src/sys/arch/sparc/sparc: amd7930intr.s Log Message: Improve am7930 family drivers to share more code. audioamd(4) on sparc, vsaudio(4) on vax, and bba(4) are. - Remove complex and useless callbacks: onopen, onclose, and indirect_{read,write}. This makes audioamd and vsaudio almost the same. - Remove (already disabled) assembly fast interrupt path from audioamd(4). cf. http://mail-index.netbsd.org/source-changes/2009/12/19/msg004585.html - Use trigger_* method rather than start_* method. It's more suitable. vsaudio(4) was tested by naru@, bba(4) was tested by tsutsui@. To generate a diff of this commit: cvs rdiff -u -r1.159 -r1.160 src/sys/arch/sparc/conf/files.sparc cvs rdiff -u -r1.29 -r1.30 src/sys/arch/sparc/dev/audioamd.c cvs rdiff -u -r1.4 -r0 src/sys/arch/sparc/dev/audioamdvar.h cvs rdiff -u -r1.1 -r0 src/sys/arch/sparc/include/am7930_machdep.h cvs rdiff -u -r1.23 -r0 src/sys/arch/sparc/sparc/amd7930intr.s cvs rdiff -u -r1.70 -r1.71 src/sys/arch/sparc/sparc/genassym.cf cvs rdiff -u -r1.6 -r1.7 src/sys/arch/vax/vsa/vsaudio.c cvs rdiff -u -r1.59 -r1.60 src/sys/dev/ic/am7930.c cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ic/am7930var.h cvs rdiff -u -r1.45 -r1.46 src/sys/dev/tc/bba.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/arch/sparc/conf/files.sparc diff -u src/sys/arch/sparc/conf/files.sparc:1.159 src/sys/arch/sparc/conf/files.sparc:1.160 --- src/sys/arch/sparc/conf/files.sparc:1.159 Fri Mar 1 02:28:27 2019 +++ src/sys/arch/sparc/conf/files.sparc Sat Sep 12 05:19:15 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.sparc,v 1.159 2019/03/01 02:28:27 macallan Exp $ +# $NetBSD: files.sparc,v 1.160 2020/09/12 05:19:15 isaki Exp $ # @(#)files.sparc 8.1 (Berkeley) 7/19/93 # sparc-specific configuration info @@ -233,7 +233,6 @@ attach audioamd at mainbus with audioamd attach audioamd at obio with audioamd_obio attach audioamd at sbus with audioamd_sbus file arch/sparc/dev/audioamd.c audioamd -file arch/sparc/sparc/amd7930intr.s audioamd device apc attach apc at sbus Index: src/sys/arch/sparc/dev/audioamd.c diff -u src/sys/arch/sparc/dev/audioamd.c:1.29 src/sys/arch/sparc/dev/audioamd.c:1.30 --- src/sys/arch/sparc/dev/audioamd.c:1.29 Wed May 8 13:40:16 2019 +++ src/sys/arch/sparc/dev/audioamd.c Sat Sep 12 05:19:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: audioamd.c,v 1.29 2019/05/08 13:40:16 isaki Exp $ */ +/* $NetBSD: audioamd.c,v 1.30 2020/09/12 05:19:16 isaki Exp $ */ /* NetBSD: am7930_sparc.c,v 1.44 1999/03/14 22:29:00 jonathan Exp */ /* @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: audioamd.c,v 1.29 2019/05/08 13:40:16 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: audioamd.c,v 1.30 2020/09/12 05:19:16 isaki Exp $"); #include "audio.h" #if NAUDIO > 0 @@ -52,52 +52,14 @@ __KERNEL_RCSID(0, "$NetBSD: audioamd.c,v #include #include -#include #define AUDIO_ROM_NAME "audio" -#ifdef AUDIO_DEBUG -#define DPRINTF(x) if (am7930debug) printf x -#define DPRINTFN(n,x) if (am7930debug>(n)) printf x -#else -#define DPRINTF(x) -#define DPRINTFN(n,x) -#endif /* AUDIO_DEBUG */ - - -/* interrupt interfaces */ -int am7930hwintr(void *); -struct auio *auiop; -void am7930swintr(void *); - -/* from amd7930intr.s: */ -void amd7930_trap(void); - -/* - * interrupt-handler status - */ -struct am7930_intrhand { - int (*ih_fun)(void *); - void *ih_arg; -}; - struct audioamd_softc { struct am7930_softc sc_am7930; /* glue to MI code */ bus_space_tag_t sc_bt; /* bus cookie */ bus_space_handle_t sc_bh; /* device registers */ - - struct am7930_intrhand sc_ih; /* interrupt vector (hw or sw) */ - void (*sc_rintr)(void*); /* input completion intr handler */ - void *sc_rarg; /* arg for sc_rintr() */ - void (*sc_pintr)(void*); /* output completion intr handler */ - void *sc_parg; /* arg for sc_pintr() */ - - /* sc_au is special in that the hardware interrupt handler uses it */ - struct auio sc_au; /* recv and xmit buffers, etc */ -#define sc_intrcnt sc_au.au_intrcnt /* statistics */ - void *sc_sicookie; /* softintr(9) cookie */ - kmutex_t sc_lock; }; int audioamd_mainbus_match(device_t, cfdata_t, void *); @@ -121,40 +83,25 @@ CFATTACH_DECL_NEW(audioamd_sbus, sizeof( * Define our interface into the am7930 MI driver. */ -uint8_t audioamd_codec_iread(struct am7930_softc *, int); -uint16_t audioamd_codec_iread16(struct am7930_softc *, int); -uint8_t audioamd_codec_dread(struct audioamd_softc *, int); -void
CVS commit: src/sys
Module Name:src Committed By: isaki Date: Sat Sep 12 05:19:16 UTC 2020 Modified Files: src/sys/arch/sparc/conf: files.sparc src/sys/arch/sparc/dev: audioamd.c src/sys/arch/sparc/sparc: genassym.cf src/sys/arch/vax/vsa: vsaudio.c src/sys/dev/ic: am7930.c am7930var.h src/sys/dev/tc: bba.c Removed Files: src/sys/arch/sparc/dev: audioamdvar.h src/sys/arch/sparc/include: am7930_machdep.h src/sys/arch/sparc/sparc: amd7930intr.s Log Message: Improve am7930 family drivers to share more code. audioamd(4) on sparc, vsaudio(4) on vax, and bba(4) are. - Remove complex and useless callbacks: onopen, onclose, and indirect_{read,write}. This makes audioamd and vsaudio almost the same. - Remove (already disabled) assembly fast interrupt path from audioamd(4). cf. http://mail-index.netbsd.org/source-changes/2009/12/19/msg004585.html - Use trigger_* method rather than start_* method. It's more suitable. vsaudio(4) was tested by naru@, bba(4) was tested by tsutsui@. To generate a diff of this commit: cvs rdiff -u -r1.159 -r1.160 src/sys/arch/sparc/conf/files.sparc cvs rdiff -u -r1.29 -r1.30 src/sys/arch/sparc/dev/audioamd.c cvs rdiff -u -r1.4 -r0 src/sys/arch/sparc/dev/audioamdvar.h cvs rdiff -u -r1.1 -r0 src/sys/arch/sparc/include/am7930_machdep.h cvs rdiff -u -r1.23 -r0 src/sys/arch/sparc/sparc/amd7930intr.s cvs rdiff -u -r1.70 -r1.71 src/sys/arch/sparc/sparc/genassym.cf cvs rdiff -u -r1.6 -r1.7 src/sys/arch/vax/vsa/vsaudio.c cvs rdiff -u -r1.59 -r1.60 src/sys/dev/ic/am7930.c cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ic/am7930var.h cvs rdiff -u -r1.45 -r1.46 src/sys/dev/tc/bba.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys
On 11.09.2020 17:16, Roy Marples wrote: > Module Name: src > Committed By: roy > Date: Fri Sep 11 15:16:00 UTC 2020 > > Modified Files: > src/sys/net: if_llatbl.c > src/sys/netinet: if_arp.c if_inarp.h tcp_input.c > > Log Message: > ARP: Use ND rather than our own. > > This brings the benefit of Neighbour Unreachability Detection which is > something ARP sorely lacks. > > The new timings mirror those of IPv6 and are adjustable via sysctl(8). > Unlike IPv6 ND, these are global and not per interface. > > This change broke rump: /public/netbsd-9/tooldir.NetBSD-9.99.72-amd64/lib/gcc/x86_64--netbsd/9.3.0/../../../../x86_64--netbsd/bin/ld: /public/netbsd-9/destdir.amd64/usr/lib/librumpnet_net.so: undefined reference to `rumpns_nd_set_timer' /public/netbsd-9/tooldir.NetBSD-9.99.72-amd64/lib/gcc/x86_64--netbsd/9.3.0/../../../../x86_64--netbsd/bin/ld: /public/netbsd-9/destdir.amd64/usr/lib/librumpnet_net.so: undefined reference to `rumpns_nd_resolve' /public/netbsd-9/tooldir.NetBSD-9.99.72-amd64/lib/gcc/x86_64--netbsd/9.3.0/../../../../x86_64--netbsd/bin/ld: /public/netbsd-9/destdir.amd64/usr/lib/librumpnet_net.so: undefined reference to `rumpns_nd_nud_hint' /public/netbsd-9/tooldir.NetBSD-9.99.72-amd64/lib/gcc/x86_64--netbsd/9.3.0/../../../../x86_64--netbsd/bin/ld: /public/netbsd-9/destdir.amd64/usr/lib/librumpnet_net.so: undefined reference to `rumpns_nd_attach_domain' collect2: error: ld returned 1 exit status signature.asc Description: OpenPGP digital signature
CVS commit: src/usr.bin/kdump
Module Name:src Committed By: roy Date: Sat Sep 12 01:36:26 UTC 2020 Modified Files: src/usr.bin/kdump: mkioctls Log Message: kdump: include netinet/in_var.h to access in_nbrinfo To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/usr.bin/kdump/mkioctls 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/kdump/mkioctls diff -u src/usr.bin/kdump/mkioctls:1.56 src/usr.bin/kdump/mkioctls:1.57 --- src/usr.bin/kdump/mkioctls:1.56 Thu Apr 2 21:36:03 2020 +++ src/usr.bin/kdump/mkioctls Sat Sep 12 01:36:26 2020 @@ -1,5 +1,5 @@ #!/bin/sh -# $NetBSD: mkioctls,v 1.56 2020/04/02 21:36:03 christos Exp $ +# $NetBSD: mkioctls,v 1.57 2020/09/12 01:36:26 roy Exp $ # # Copyright (c) 1994 # The Regents of the University of California. All rights reserved. @@ -67,6 +67,7 @@ echo "#include " echo "#include " echo "#include " echo "#include " +echo "#include " echo "#include " echo "#include " echo "#include "
CVS commit: src/usr.bin/kdump
Module Name:src Committed By: roy Date: Sat Sep 12 01:36:26 UTC 2020 Modified Files: src/usr.bin/kdump: mkioctls Log Message: kdump: include netinet/in_var.h to access in_nbrinfo To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/usr.bin/kdump/mkioctls Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/external/gpl3/gcc
On 11.09.2020 23:38, Joerg Sonnenberger wrote: > On Fri, Sep 11, 2020 at 04:07:24PM +0200, Kamil Rytarowski wrote: >> The current code is confusing, as it attempts to use unimplemented >> _PTHREAD_GETTCB_EXT() and in one place uses _lwp_getprivate_fast() in >> other _lwp_getprivate(). This caused my confusion... as I assumed that >> _lwp_getprivate_fast() is internal and _lwp_getprivate() for public >> consumption. > > _PTHREAD_GETTCB_EXT is a rump hack. There is no _lwp_getprivate_fast. > There is __lwp_getprivate_fast, which originally wasn't implemented on > architectures without a fast path (like VAX). Nowadays, all functional > ports provide either __lwp_getprivate_fast (potentially with a fall-back > to the system call) or __lwp_gettcb_fast. The difference is whether the > TLS register is biased or not. > Do you agree with this patch: http://netbsd.org/~kamil/patch-00278-_rtld_tls_self.txt And then, using _rtld_tls_self() in sanitizers (and wherever someone finds it useful)? As an alternative we will use __lwp_gettcb_fast() or __lwp_getprivate_fast() manually in 3rd party code, which seems fragile. > Joerg > signature.asc Description: OpenPGP digital signature
Re: CVS commit: src/external/gpl3/gcc
On Fri, Sep 11, 2020 at 04:07:24PM +0200, Kamil Rytarowski wrote: > The current code is confusing, as it attempts to use unimplemented > _PTHREAD_GETTCB_EXT() and in one place uses _lwp_getprivate_fast() in > other _lwp_getprivate(). This caused my confusion... as I assumed that > _lwp_getprivate_fast() is internal and _lwp_getprivate() for public > consumption. _PTHREAD_GETTCB_EXT is a rump hack. There is no _lwp_getprivate_fast. There is __lwp_getprivate_fast, which originally wasn't implemented on architectures without a fast path (like VAX). Nowadays, all functional ports provide either __lwp_getprivate_fast (potentially with a fall-back to the system call) or __lwp_gettcb_fast. The difference is whether the TLS register is biased or not. Joerg
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Sep 11 17:32:36 UTC 2020 Modified Files: src/usr.bin/make: arch.c compat.c cond.c for.c job.c main.c make.h metachar.h parse.c var.c Log Message: make(1): add wrappers around ctype.h functions This avoids casting the argument to unsigned char, and to cast the result of toupper/tolower back to char. To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 src/usr.bin/make/arch.c cvs rdiff -u -r1.139 -r1.140 src/usr.bin/make/compat.c cvs rdiff -u -r1.133 -r1.134 src/usr.bin/make/cond.c cvs rdiff -u -r1.78 -r1.79 src/usr.bin/make/for.c cvs rdiff -u -r1.229 -r1.230 src/usr.bin/make/job.c cvs rdiff -u -r1.331 -r1.332 src/usr.bin/make/main.c cvs rdiff -u -r1.138 -r1.139 src/usr.bin/make/make.h cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/metachar.h cvs rdiff -u -r1.289 -r1.290 src/usr.bin/make/parse.c cvs rdiff -u -r1.492 -r1.493 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/arch.c diff -u src/usr.bin/make/arch.c:1.110 src/usr.bin/make/arch.c:1.111 --- src/usr.bin/make/arch.c:1.110 Mon Sep 7 06:51:05 2020 +++ src/usr.bin/make/arch.c Fri Sep 11 17:32:36 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.110 2020/09/07 06:51:05 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.111 2020/09/11 17:32:36 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: arch.c,v 1.110 2020/09/07 06:51:05 rillig Exp $"; +static char rcsid[] = "$NetBSD: arch.c,v 1.111 2020/09/11 17:32:36 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.110 2020/09/07 06:51:05 rillig Exp $"); +__RCSID("$NetBSD: arch.c,v 1.111 2020/09/11 17:32:36 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -265,11 +265,11 @@ Arch_ParseArchive(char **linePtr, Lst no */ Boolean doSubst = FALSE; /* TRUE if need to substitute in memName */ - while (*cp != '\0' && *cp != ')' && isspace ((unsigned char)*cp)) { + while (*cp != '\0' && *cp != ')' && ch_isspace(*cp)) { cp++; } memName = cp; - while (*cp != '\0' && *cp != ')' && !isspace ((unsigned char)*cp)) { + while (*cp != '\0' && *cp != ')' && !ch_isspace(*cp)) { if (*cp == '$') { /* * Variable spec, so call the Var module to parse the puppy @@ -448,7 +448,7 @@ Arch_ParseArchive(char **linePtr, Lst no */ do { cp++; -} while (*cp != '\0' && isspace ((unsigned char)*cp)); +} while (*cp != '\0' && ch_isspace(*cp)); *linePtr = cp; return TRUE; @@ -631,7 +631,7 @@ ArchStatMember(const char *archive, cons * first bytes of the file */ if (strncmp(memName, AR_EFMT1, sizeof(AR_EFMT1) - 1) == 0 && - isdigit((unsigned char)memName[sizeof(AR_EFMT1) - 1])) { + ch_isdigit(memName[sizeof(AR_EFMT1) - 1])) { int elen = atoi([sizeof(AR_EFMT1)-1]); @@ -879,7 +879,7 @@ ArchFindMember(const char *archive, cons */ if (strncmp(arhPtr->ar_name, AR_EFMT1, sizeof(AR_EFMT1) - 1) == 0 && - isdigit((unsigned char)arhPtr->ar_name[sizeof(AR_EFMT1) - 1])) { + ch_isdigit(arhPtr->ar_name[sizeof(AR_EFMT1) - 1])) { int elen = atoi(>ar_name[sizeof(AR_EFMT1)-1]); char ename[MAXPATHLEN + 1]; Index: src/usr.bin/make/compat.c diff -u src/usr.bin/make/compat.c:1.139 src/usr.bin/make/compat.c:1.140 --- src/usr.bin/make/compat.c:1.139 Sun Aug 30 20:08:47 2020 +++ src/usr.bin/make/compat.c Fri Sep 11 17:32:36 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.139 2020/08/30 20:08:47 rillig Exp $ */ +/* $NetBSD: compat.c,v 1.140 2020/09/11 17:32:36 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.139 2020/08/30 20:08:47 rillig Exp $"; +static char rcsid[] = "$NetBSD: compat.c,v 1.140 2020/09/11 17:32:36 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.139 2020/08/30 20:08:47 rillig Exp $"); +__RCSID("$NetBSD: compat.c,v 1.140 2020/09/11 17:32:36 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -264,7 +264,7 @@ CompatRunCommand(void *cmdp, void *gnp) cmd++; } -while (isspace((unsigned char)*cmd)) +while (ch_isspace(*cmd)) cmd++; /* @@ -416,9 +416,9 @@ CompatRunCommand(void *cmdp, void *gnp) fprintf(debug_file, "\n*** Failed target: %s\n*** Failed command: ", gn->name); for (cp = cmd; *cp; ) { - if (isspace((unsigned char)*cp)) { + if (ch_isspace(*cp)) { fprintf(debug_file, " "); -while (isspace((unsigned char)*cp)) +while (ch_isspace(*cp)) cp++; } else { fprintf(debug_file, "%c", *cp); Index:
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Sep 11 17:32:36 UTC 2020 Modified Files: src/usr.bin/make: arch.c compat.c cond.c for.c job.c main.c make.h metachar.h parse.c var.c Log Message: make(1): add wrappers around ctype.h functions This avoids casting the argument to unsigned char, and to cast the result of toupper/tolower back to char. To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 src/usr.bin/make/arch.c cvs rdiff -u -r1.139 -r1.140 src/usr.bin/make/compat.c cvs rdiff -u -r1.133 -r1.134 src/usr.bin/make/cond.c cvs rdiff -u -r1.78 -r1.79 src/usr.bin/make/for.c cvs rdiff -u -r1.229 -r1.230 src/usr.bin/make/job.c cvs rdiff -u -r1.331 -r1.332 src/usr.bin/make/main.c cvs rdiff -u -r1.138 -r1.139 src/usr.bin/make/make.h cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/metachar.h cvs rdiff -u -r1.289 -r1.290 src/usr.bin/make/parse.c cvs rdiff -u -r1.492 -r1.493 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.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Sep 11 16:37:48 UTC 2020 Modified Files: src/usr.bin/make: cond.c Log Message: make(1): split EvalComparison into smaller functions To generate a diff of this commit: cvs rdiff -u -r1.132 -r1.133 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.132 src/usr.bin/make/cond.c:1.133 --- src/usr.bin/make/cond.c:1.132 Fri Sep 11 16:23:47 2020 +++ src/usr.bin/make/cond.c Fri Sep 11 16:37:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.132 2020/09/11 16:23:47 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.133 2020/09/11 16:37:48 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.132 2020/09/11 16:23:47 rillig Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.133 2020/09/11 16:37:48 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.132 2020/09/11 16:23:47 rillig Exp $"); +__RCSID("$NetBSD: cond.c,v 1.133 2020/09/11 16:37:48 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -546,61 +546,64 @@ EvalNotEmpty(CondParser *par, const char return par->if_info->defProc(strlen(lhs), lhs) != par->if_info->doNot; } -/* Evaluate a comparison, such as "${VAR} == 12345". */ +/* Evaluate a numerical comparison, such as in ".if ${VAR} >= 9". */ static Token -EvalComparison(const char *lhs, Boolean lhsQuoted, const char *op, - const char *rhs, Boolean rhsQuoted) +EvalCompareNum(double lhs, const char *op, double rhs) { -double left, right; - -if (rhsQuoted || lhsQuoted) { - do_string_compare: - if ((*op != '!' && *op != '=') || op[1] != '=') { - Parse_Error(PARSE_WARNING, - "String comparison operator should be either == or !="); - return TOK_ERROR; - } - - if (DEBUG(COND)) { - fprintf(debug_file, "lhs = \"%s\", rhs = \"%s\", op = %.2s\n", - lhs, rhs, op); - } - return (*op == '=') == (strcmp(lhs, rhs) == 0); -} - -/* - * rhs is either a float or an integer. Convert both the - * lhs and the rhs to a double and compare the two. - */ - -if (!TryParseNumber(lhs, ) || !TryParseNumber(rhs, )) - goto do_string_compare; +if (DEBUG(COND)) + fprintf(debug_file, "lhs = %f, right = %f, op = %.2s\n", lhs, rhs, op); -if (DEBUG(COND)) { - fprintf(debug_file, "left = %f, right = %f, op = %.2s\n", left, - right, op); -} switch (op[0]) { case '!': if (op[1] != '=') { Parse_Error(PARSE_WARNING, "Unknown operator"); return TOK_ERROR; } - return left != right; + return lhs != rhs; case '=': if (op[1] != '=') { Parse_Error(PARSE_WARNING, "Unknown operator"); return TOK_ERROR; } - return left == right; + return lhs == rhs; case '<': - return op[1] == '=' ? left <= right : left < right; + return op[1] == '=' ? lhs <= rhs : lhs < rhs; case '>': - return op[1] == '=' ? left >= right : left > right; + return op[1] == '=' ? lhs >= rhs : lhs > rhs; } return TOK_ERROR; } +static Token +EvalCompareStr(const char *lhs, const char *op, const char *rhs) +{ +if ((*op != '!' && *op != '=') || op[1] != '=') { + Parse_Error(PARSE_WARNING, + "String comparison operator should be either == or !="); + return TOK_ERROR; +} + +if (DEBUG(COND)) { + fprintf(debug_file, "lhs = \"%s\", rhs = \"%s\", op = %.2s\n", + lhs, rhs, op); +} +return (*op == '=') == (strcmp(lhs, rhs) == 0); +} + +/* Evaluate a comparison, such as "${VAR} == 12345". */ +static Token +EvalCompare(const char *lhs, Boolean lhsQuoted, const char *op, + const char *rhs, Boolean rhsQuoted) +{ +double left, right; + +if (!rhsQuoted && !lhsQuoted) + if (TryParseNumber(lhs, ) && TryParseNumber(rhs, )) + return EvalCompareNum(left, op, right); + +return EvalCompareStr(lhs, op, rhs); +} + /* Parse a comparison condition such as: * * 0 @@ -668,7 +671,7 @@ CondParser_Comparison(CondParser *par, B goto done; } -t = EvalComparison(lhs, lhsQuoted, op, rhs, rhsQuoted); +t = EvalCompare(lhs, lhsQuoted, op, rhs, rhsQuoted); done: free(lhsFree);
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Sep 11 16:37:48 UTC 2020 Modified Files: src/usr.bin/make: cond.c Log Message: make(1): split EvalComparison into smaller functions To generate a diff of this commit: cvs rdiff -u -r1.132 -r1.133 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.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Sep 11 16:23:47 UTC 2020 Modified Files: src/usr.bin/make: cond.c Log Message: make(1): clean up code for evaluating conditions To generate a diff of this commit: cvs rdiff -u -r1.131 -r1.132 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.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Sep 11 16:23:47 UTC 2020 Modified Files: src/usr.bin/make: cond.c Log Message: make(1): clean up code for evaluating conditions To generate a diff of this commit: cvs rdiff -u -r1.131 -r1.132 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.131 src/usr.bin/make/cond.c:1.132 --- src/usr.bin/make/cond.c:1.131 Fri Sep 11 16:22:15 2020 +++ src/usr.bin/make/cond.c Fri Sep 11 16:23:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.131 2020/09/11 16:22:15 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.132 2020/09/11 16:23: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.131 2020/09/11 16:22:15 rillig Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.132 2020/09/11 16:23: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.131 2020/09/11 16:22:15 rillig Exp $"); +__RCSID("$NetBSD: cond.c,v 1.132 2020/09/11 16:23:47 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -555,7 +555,7 @@ EvalComparison(const char *lhs, Boolean if (rhsQuoted || lhsQuoted) { do_string_compare: - if (((*op != '!') && (*op != '=')) || (op[1] != '=')) { + if ((*op != '!' && *op != '=') || op[1] != '=') { Parse_Error(PARSE_WARNING, "String comparison operator should be either == or !="); return TOK_ERROR; @@ -583,30 +583,20 @@ EvalComparison(const char *lhs, Boolean switch (op[0]) { case '!': if (op[1] != '=') { - Parse_Error(PARSE_WARNING, - "Unknown operator"); + Parse_Error(PARSE_WARNING, "Unknown operator"); return TOK_ERROR; } return left != right; case '=': if (op[1] != '=') { - Parse_Error(PARSE_WARNING, - "Unknown operator"); + Parse_Error(PARSE_WARNING, "Unknown operator"); return TOK_ERROR; } return left == right; case '<': - if (op[1] == '=') { - return left <= right; - } else { - return left < right; - } + return op[1] == '=' ? left <= right : left < right; case '>': - if (op[1] == '=') { - return left >= right; - } else { - return left > right; - } + return op[1] == '=' ? left >= right : left > right; } return TOK_ERROR; } @@ -621,16 +611,11 @@ EvalComparison(const char *lhs, Boolean static Token CondParser_Comparison(CondParser *par, Boolean doEval) { -Token t; -const char *lhs; -const char *rhs; -const char *op; -void *lhsFree; -void *rhsFree; -Boolean lhsQuoted; -Boolean rhsQuoted; +Token t = TOK_ERROR; +const char *lhs, *op, *rhs; +void *lhsFree, *rhsFree; +Boolean lhsQuoted, rhsQuoted; -t = TOK_ERROR; rhs = NULL; lhsFree = rhsFree = NULL; lhsQuoted = rhsQuoted = FALSE; @@ -670,13 +655,12 @@ CondParser_Comparison(CondParser *par, B CondParser_SkipWhitespace(par); if (par->p[0] == '\0') { - Parse_Error(PARSE_WARNING, - "Missing right-hand-side of operator"); + Parse_Error(PARSE_WARNING, "Missing right-hand-side of operator"); goto done; } rhs = CondParser_String(par, doEval, FALSE, , ); -if (!rhs) +if (rhs == NULL) goto done; if (!doEval) {
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Sep 11 16:22:15 UTC 2020 Modified Files: src/usr.bin/make: cond.c Log Message: make(1): extract EvalNotEmpty from CondParser_Comparison To generate a diff of this commit: cvs rdiff -u -r1.130 -r1.131 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.130 src/usr.bin/make/cond.c:1.131 --- src/usr.bin/make/cond.c:1.130 Fri Sep 11 13:58:45 2020 +++ src/usr.bin/make/cond.c Fri Sep 11 16:22:15 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.130 2020/09/11 13:58:45 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.131 2020/09/11 16:22:15 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.130 2020/09/11 13:58:45 rillig Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.131 2020/09/11 16:22:15 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.130 2020/09/11 13:58:45 rillig Exp $"); +__RCSID("$NetBSD: cond.c,v 1.131 2020/09/11 16:22:15 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -523,6 +523,30 @@ static const struct If { { NULL,0, FALSE, NULL } }; +/* Evaluate a "comparison without operator", such as in ".if ${VAR}" or + * ".if 0". */ +static Token +EvalNotEmpty(CondParser *par, const char *lhs, Boolean lhsQuoted) +{ +double left; + +/* For .ifxxx "..." check for non-empty string. */ +if (lhsQuoted) + return lhs[0] != '\0'; + +/* For .ifxxx compare against zero */ +if (TryParseNumber(lhs, )) + return left != 0.0; + +/* For .if ${...} check for non-empty string (defProc is ifdef). */ +if (par->if_info->form[0] == '\0') + return lhs[0] != 0; + +/* Otherwise action default test ... */ +return par->if_info->defProc(strlen(lhs), lhs) != par->if_info->doNot; +} + +/* Evaluate a comparison, such as "${VAR} == 12345". */ static Token EvalComparison(const char *lhs, Boolean lhsQuoted, const char *op, const char *rhs, Boolean rhsQuoted) @@ -639,30 +663,7 @@ CondParser_Comparison(CondParser *par, B } break; default: - if (!doEval) { - t = TOK_FALSE; - goto done; - } - /* For .ifxxx "..." check for non-empty string. */ - if (lhsQuoted) { - t = lhs[0] != '\0'; - goto done; - } - /* For .ifxxx compare against zero */ - { - double left; - if (TryParseNumber(lhs, )) { - t = left != 0.0; - goto done; - } - } - /* For .if ${...} check for non-empty string (defProc is ifdef). */ - if (par->if_info->form[0] == '\0') { - t = lhs[0] != 0; - goto done; - } - /* Otherwise action default test ... */ - t = par->if_info->defProc(strlen(lhs), lhs) != par->if_info->doNot; +t = doEval ? EvalNotEmpty(par, lhs, lhsQuoted) : TOK_FALSE; goto done; }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Sep 11 16:22:15 UTC 2020 Modified Files: src/usr.bin/make: cond.c Log Message: make(1): extract EvalNotEmpty from CondParser_Comparison To generate a diff of this commit: cvs rdiff -u -r1.130 -r1.131 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.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Fri Sep 11 15:33:28 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: cond-cmp-numeric-eq.exp cond-cmp-numeric-eq.mk cond-cmp-string.exp cond-cmp-string.mk Log Message: make(1): fix tests about nonexistent = and === operators To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk \ src/usr.bin/make/unit-tests/cond-cmp-string.exp cvs rdiff -u -r1.4 -r1.5 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.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Fri Sep 11 15:33:28 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: cond-cmp-numeric-eq.exp cond-cmp-numeric-eq.mk cond-cmp-string.exp cond-cmp-string.mk Log Message: make(1): fix tests about nonexistent = and === operators To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk \ src/usr.bin/make/unit-tests/cond-cmp-string.exp cvs rdiff -u -r1.4 -r1.5 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-numeric-eq.exp diff -u src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.exp:1.1 src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.exp:1.2 --- src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.exp:1.1 Sun Aug 23 13:50:17 2020 +++ src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.exp Fri Sep 11 15:33:28 2020 @@ -1 +1,6 @@ -exit status 0 +make: "cond-cmp-numeric-eq.mk" line 54: warning: Unknown operator +make: "cond-cmp-numeric-eq.mk" line 54: Malformed conditional (!(12345 = 12345)) +make: "cond-cmp-numeric-eq.mk" line 61: Malformed conditional (!(12345 === 12345)) +make: Fatal errors encountered -- cannot continue +make: stopped in unit-tests +exit status 1 Index: src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk diff -u src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk:1.2 src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk:1.3 --- src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk:1.2 Fri Sep 11 15:19:04 2020 +++ src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk Fri Sep 11 15:33:28 2020 @@ -1,4 +1,4 @@ -# $NetBSD: cond-cmp-numeric-eq.mk,v 1.2 2020/09/11 15:19:04 rillig Exp $ +# $NetBSD: cond-cmp-numeric-eq.mk,v 1.3 2020/09/11 15:33:28 rillig Exp $ # # Tests for numeric comparisons with the == operator in .if conditions. @@ -50,8 +50,7 @@ .endif -# There is no = operator for numbers. Well, not quite, there is one, but -# it generates a warning. Therefore it is not used in practice. +# There is no = operator for numbers. .if !(12345 = 12345) . error .else Index: src/usr.bin/make/unit-tests/cond-cmp-string.exp diff -u src/usr.bin/make/unit-tests/cond-cmp-string.exp:1.2 src/usr.bin/make/unit-tests/cond-cmp-string.exp:1.3 --- src/usr.bin/make/unit-tests/cond-cmp-string.exp:1.2 Thu Aug 20 18:43:19 2020 +++ src/usr.bin/make/unit-tests/cond-cmp-string.exp Fri Sep 11 15:33:28 2020 @@ -1,5 +1,8 @@ make: "cond-cmp-string.mk" line 18: Malformed conditional (str != str) make: "cond-cmp-string.mk" line 37: Malformed conditional ("string" != "str""ing") +make: "cond-cmp-string.mk" line 42: warning: String comparison operator should be either == or != +make: "cond-cmp-string.mk" line 42: Malformed conditional (!("value" = "value")) +make: "cond-cmp-string.mk" line 49: Malformed conditional (!("value" === "value")) 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.4 src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.5 --- src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.4 Fri Sep 11 15:19:04 2020 +++ src/usr.bin/make/unit-tests/cond-cmp-string.mk Fri Sep 11 15:33:28 2020 @@ -1,4 +1,4 @@ -# $NetBSD: cond-cmp-string.mk,v 1.4 2020/09/11 15:19:04 rillig Exp $ +# $NetBSD: cond-cmp-string.mk,v 1.5 2020/09/11 15:33:28 rillig Exp $ # # Tests for string comparisons in .if conditions. @@ -38,8 +38,7 @@ .error .endif -# There is no = operator for strings. Well, not quite, there is one, but -# it generates a warning. Therefore it is not used in practice. +# There is no = operator for strings. .if !("value" = "value") . error .else
CVS commit: src/usr.sbin/arp
Module Name:src Committed By: roy Date: Fri Sep 11 15:28:29 UTC 2020 Modified Files: src/usr.sbin/arp: arp.8 arp.c arp_hostops.c arp_rumpops.c prog_ops.h Log Message: arp: Use SIOCGNBRINFO to display neighbor state information To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/usr.sbin/arp/arp.8 cvs rdiff -u -r1.65 -r1.66 src/usr.sbin/arp/arp.c cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/arp/arp_hostops.c \ src/usr.sbin/arp/arp_rumpops.c src/usr.sbin/arp/prog_ops.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/arp
Module Name:src Committed By: roy Date: Fri Sep 11 15:28:29 UTC 2020 Modified Files: src/usr.sbin/arp: arp.8 arp.c arp_hostops.c arp_rumpops.c prog_ops.h Log Message: arp: Use SIOCGNBRINFO to display neighbor state information To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/usr.sbin/arp/arp.8 cvs rdiff -u -r1.65 -r1.66 src/usr.sbin/arp/arp.c cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/arp/arp_hostops.c \ src/usr.sbin/arp/arp_rumpops.c src/usr.sbin/arp/prog_ops.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.sbin/arp/arp.8 diff -u src/usr.sbin/arp/arp.8:1.24 src/usr.sbin/arp/arp.8:1.25 --- src/usr.sbin/arp/arp.8:1.24 Fri Jul 6 00:50:05 2018 +++ src/usr.sbin/arp/arp.8 Fri Sep 11 15:28:29 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: arp.8,v 1.24 2018/07/06 00:50:05 christos Exp $ +.\" $NetBSD: arp.8,v 1.25 2020/09/11 15:28:29 roy Exp $ .\" .\" Copyright (c) 1985, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" from: @(#)arp.8 8.2 (Berkeley) 4/27/95 .\" -.Dd July 5, 2018 +.Dd September 11, 2020 .Dt ARP 8 .Os .Sh NAME @@ -69,6 +69,27 @@ entry for The host may be specified by name or by number, using Internet dot notation. .Pp +The state of the arp entry is shown as a single letter preceeded by the +time the state is applicable for: +.Bl -tag -width indent -compact +.It D +Delay +.It I +Incomplete +.It N +Nostate +.It P +Probe +.It R +Reachable +.It S +Stale +.It W +Waitdelete +.It ? +Unknown state (should never happen). +.El +.Pp Available options: .Bl -tag -width Ds .It Fl a Index: src/usr.sbin/arp/arp.c diff -u src/usr.sbin/arp/arp.c:1.65 src/usr.sbin/arp/arp.c:1.66 --- src/usr.sbin/arp/arp.c:1.65 Thu Feb 28 01:20:25 2019 +++ src/usr.sbin/arp/arp.c Fri Sep 11 15:28:29 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: arp.c,v 1.65 2019/02/28 01:20:25 nonaka Exp $ */ +/* $NetBSD: arp.c,v 1.66 2020/09/11 15:28:29 roy Exp $ */ /* * Copyright (c) 1984, 1993 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1984, 19 #if 0 static char sccsid[] = "@(#)arp.c 8.3 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: arp.c,v 1.65 2019/02/28 01:20:25 nonaka Exp $"); +__RCSID("$NetBSD: arp.c,v 1.66 2020/09/11 15:28:29 roy Exp $"); #endif #endif /* not lint */ @@ -60,8 +60,10 @@ __RCSID("$NetBSD: arp.c,v 1.65 2019/02/2 #include #include #include +#include #include #include +#include #include #include @@ -92,6 +94,8 @@ static int getsocket(void); static int getetheraddr(struct in_addr, struct sockaddr_dl *); static struct rt_msghdr * rtmsg(const int, const int, struct rt_msghdr *, const struct sockaddr_inarp *, const struct sockaddr_dl *); +static struct in_nbrinfo * getnbrinfo(const char *, struct in_addr *); +static const char * sec2str(time_t); static int set(int, char **); static void usage(void) __dead; @@ -439,6 +443,8 @@ dump(uint32_t addr) struct sockaddr_inarp *sina; struct sockaddr_dl *sdl; struct hostent *hp; + struct timeval tim; + struct in_nbrinfo *nbi; mib[0] = CTL_NET; mib[1] = PF_ROUTE; @@ -497,6 +503,49 @@ dump(uint32_t addr) if (sina->sin_len != 8) (void)printf("(weird)"); } + + if (sdl->sdl_index == 0) + goto done; + (void)gettimeofday(, 0); + nbi = getnbrinfo(ifname, >sin_addr); + if (nbi != NULL) { + if (nbi->expire > tim.tv_sec) { +(void)printf(" %s", +sec2str(nbi->expire - tim.tv_sec)); + } else if (nbi->expire == 0) +(void)printf(" %s", "permanent"); + else +(void)printf(" %s", "expired"); + + switch (nbi->state) { + case ND_LLINFO_NOSTATE: +(void)printf(" N"); +break; + case ND_LLINFO_WAITDELETE: +(void)printf(" W"); +break; + case ND_LLINFO_INCOMPLETE: +(void)printf(" I"); +break; + case ND_LLINFO_REACHABLE: +(void)printf(" R"); +break; + case ND_LLINFO_STALE: +(void)printf(" S"); +break; + case ND_LLINFO_DELAY: +(void)printf(" D"); +break; + case ND_LLINFO_PROBE: +(void)printf(" P"); +break; + default: +(void)printf(" ?"); +break; + } + } + +done: (void)printf("\n"); } free(buf); @@ -800,3 +849,66 @@ getetheraddr(struct in_addr ipaddr, stru freeifaddrs(ifaddrs); return -1; } + +static struct in_nbrinfo * +getnbrinfo(const char *ifname, struct in_addr *addr) +{ + static struct in_nbrinfo nbi, *nbip; + int s; + + if ((s = prog_socket(AF_INET, SOCK_DGRAM, 0)) == -1) + err(1, "socket"); + + (void)memset(, 0, sizeof(nbi)); + (void)strlcpy(nbi.ifname, ifname, sizeof(nbi.ifname)); + nbi.addr = *addr; + if (prog_ioctl(s, SIOCGNBRINFO, ) == -1) { + warn("ioctl(SIOCGNBRINFO)"); + nbip = NULL; + } else + nbip = + (void)prog_close(s); + + return nbip; +} + +static const char * +sec2str(time_t total) +{ + static char result[256]; + int days, hours, mins, secs; + int first = 1; + char *p = result; + char *ep = [sizeof(result)]; + int
CVS commit: src/sys
Module Name:src Committed By: roy Date: Fri Sep 11 15:22:13 UTC 2020 Modified Files: src/sys/netinet: in.c in_var.h src/sys/sys: sockio.h Log Message: inet: Add SIOCGNBRINFO to retrieve neighbor state about an address To generate a diff of this commit: cvs rdiff -u -r1.239 -r1.240 src/sys/netinet/in.c cvs rdiff -u -r1.97 -r1.98 src/sys/netinet/in_var.h cvs rdiff -u -r1.38 -r1.39 src/sys/sys/sockio.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: roy Date: Fri Sep 11 15:22:13 UTC 2020 Modified Files: src/sys/netinet: in.c in_var.h src/sys/sys: sockio.h Log Message: inet: Add SIOCGNBRINFO to retrieve neighbor state about an address To generate a diff of this commit: cvs rdiff -u -r1.239 -r1.240 src/sys/netinet/in.c cvs rdiff -u -r1.97 -r1.98 src/sys/netinet/in_var.h cvs rdiff -u -r1.38 -r1.39 src/sys/sys/sockio.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/netinet/in.c diff -u src/sys/netinet/in.c:1.239 src/sys/netinet/in.c:1.240 --- src/sys/netinet/in.c:1.239 Fri Sep 11 15:19:31 2020 +++ src/sys/netinet/in.c Fri Sep 11 15:22:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: in.c,v 1.239 2020/09/11 15:19:31 roy Exp $ */ +/* $NetBSD: in.c,v 1.240 2020/09/11 15:22:12 roy Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.239 2020/09/11 15:19:31 roy Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.240 2020/09/11 15:22:12 roy Exp $"); #include "arp.h" @@ -424,6 +424,24 @@ in_control0(struct socket *so, u_long cm if (ifp == NULL) return EINVAL; return ifaddrpref_ioctl(so, cmd, data, ifp); +#if NARP > 0 + case SIOCGNBRINFO: + { + struct in_nbrinfo *nbi = (struct in_nbrinfo *)data; + struct llentry *ln; + struct in_addr nb_addr = nbi->addr; /* make local for safety */ + + ln = arplookup(ifp, _addr, NULL, 0); + if (ln == NULL) + return EINVAL; + nbi->state = ln->ln_state; + nbi->asked = ln->ln_asked; + nbi->expire = ln->ln_expire ? + time_mono_to_wall(ln->ln_expire) : 0; + LLE_RUNLOCK(ln); + return 0; + } +#endif } bound = curlwp_bind(); Index: src/sys/netinet/in_var.h diff -u src/sys/netinet/in_var.h:1.97 src/sys/netinet/in_var.h:1.98 --- src/sys/netinet/in_var.h:1.97 Thu Nov 29 09:51:20 2018 +++ src/sys/netinet/in_var.h Fri Sep 11 15:22:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: in_var.h,v 1.97 2018/11/29 09:51:20 ozaki-r Exp $ */ +/* $NetBSD: in_var.h,v 1.98 2020/09/11 15:22:12 roy Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -115,6 +115,14 @@ struct in_ifaddr { #endif }; +struct in_nbrinfo { + char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */ + struct in_addr addr; /* IPv4 address of the neighbor */ + long asked; /* number of queries already sent for this addr */ + int state; /* reachability state */ + int expire; /* lifetime for NDP state transition */ +}; + #ifdef _KERNEL static __inline void ia4_acquire(struct in_ifaddr *ia, struct psref *psref) Index: src/sys/sys/sockio.h diff -u src/sys/sys/sockio.h:1.38 src/sys/sys/sockio.h:1.39 --- src/sys/sys/sockio.h:1.38 Thu Jul 4 02:44:25 2019 +++ src/sys/sys/sockio.h Fri Sep 11 15:22:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sockio.h,v 1.38 2019/07/04 02:44:25 ozaki-r Exp $ */ +/* $NetBSD: sockio.h,v 1.39 2020/09/11 15:22:12 roy Exp $ */ /*- * Copyright (c) 1982, 1986, 1990, 1993, 1994 @@ -153,4 +153,6 @@ #define SIOCSETPFSYNC _IOW('i', 247, struct ifreq) #define SIOCGETPFSYNC _IOWR('i', 248, struct ifreq) +#define SIOCGNBRINFO _IOWR('i', 249, struct in_nbrinfo) /* get IA ND info */ + #endif /* !_SYS_SOCKIO_H_ */
CVS commit: src/distrib/sets/lists/base
Module Name:src Committed By: jakllsch Date: Fri Sep 11 15:21:49 UTC 2020 Modified Files: src/distrib/sets/lists/base: ad.arm Log Message: Limit bootarm.efi expectation further. Should fix iyonix, and zaurus builds. Also probably fixes all oarm AKA 'arm' builds too. To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/distrib/sets/lists/base/ad.arm Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/distrib/sets/lists/base
Module Name:src Committed By: jakllsch Date: Fri Sep 11 15:21:49 UTC 2020 Modified Files: src/distrib/sets/lists/base: ad.arm Log Message: Limit bootarm.efi expectation further. Should fix iyonix, and zaurus builds. Also probably fixes all oarm AKA 'arm' builds too. To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/distrib/sets/lists/base/ad.arm 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/base/ad.arm diff -u src/distrib/sets/lists/base/ad.arm:1.83 src/distrib/sets/lists/base/ad.arm:1.84 --- src/distrib/sets/lists/base/ad.arm:1.83 Thu Sep 10 15:17:23 2020 +++ src/distrib/sets/lists/base/ad.arm Fri Sep 11 15:21:48 2020 @@ -1,4 +1,4 @@ -# $NetBSD: ad.arm,v 1.83 2020/09/10 15:17:23 jakllsch Exp $ +# $NetBSD: ad.arm,v 1.84 2020/09/11 15:21:48 jakllsch Exp $ ./libexec/ld.elf_so-oabi base-sysutil-bin compat,pic ./sbin/ldconfig base-sysutil-root pic,endian=1234 ./usr/bin/fdformatbase-util-bin @@ -17,7 +17,7 @@ ./usr/mdec/boot26,ffabase-obsolete obsolete ./usr/mdec/boot32base-sysutil-bin endian=1234 ./usr/mdec/boot32,ffabase-sysutil-bin endian=1234 -./usr/mdec/bootarm.efibase-sysutil-bin !machine_arch=earmv4,!machine_arch=earmv4eb,!machine_arch=earmv5,!machine_arch=earmv5eb,!machine_arch=earmv5hf,!machine_arch=earmv5hfeb,!machine_arch=earmv6,!machine_arch=earmv6eb,!machine_arch=earmv6hf,!machine_arch=earmv6hfeb,!machine_arch=earmv7,!machine_arch=earmv7eb +./usr/mdec/bootarm.efibase-sysutil-bin machine=evbarm,!machine_arch=arm,!machine_arch=earm,!machine_arch=earmeb,!machine_arch=earmv4,!machine_arch=earmv4eb,!machine_arch=earmv5,!machine_arch=earmv5eb,!machine_arch=earmv5hf,!machine_arch=earmv5hfeb,!machine_arch=earmv6,!machine_arch=earmv6eb,!machine_arch=earmv6hf,!machine_arch=earmv6hfeb,!machine_arch=earmv7,!machine_arch=earmv7eb ./usr/mdec/bootimx23base-sysutil-bin endian=1234 ./usr/mdec/bootmini2440base-sysutil-bin ./usr/mdec/gzboot_ADI_BRH_0x0014.bin base-sysutil-bin
CVS commit: src/sys/netinet
Module Name:src Committed By: roy Date: Fri Sep 11 15:19:31 UTC 2020 Modified Files: src/sys/netinet: in.c Log Message: in: No need to set expire here anymore To generate a diff of this commit: cvs rdiff -u -r1.238 -r1.239 src/sys/netinet/in.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/netinet/in.c diff -u src/sys/netinet/in.c:1.238 src/sys/netinet/in.c:1.239 --- src/sys/netinet/in.c:1.238 Sat Aug 29 17:41:14 2020 +++ src/sys/netinet/in.c Fri Sep 11 15:19:31 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: in.c,v 1.238 2020/08/29 17:41:14 christos Exp $ */ +/* $NetBSD: in.c,v 1.239 2020/09/11 15:19:31 roy Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.238 2020/08/29 17:41:14 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.239 2020/09/11 15:19:31 roy Exp $"); #include "arp.h" @@ -1959,11 +1959,6 @@ in_lltable_new(struct in_addr addr4, u_i if (lle == NULL) /* NB: caller generates msg */ return NULL; - /* - * For IPv4 this will trigger "arpresolve" to generate - * an ARP request. - */ - lle->la_expire = time_uptime; /* mark expired */ lle->r_l3addr.addr4 = addr4; lle->lle_refcnt = 1; lle->lle_free = in_lltable_destroy_lle;
CVS commit: src/sys/netinet
Module Name:src Committed By: roy Date: Fri Sep 11 15:19:31 UTC 2020 Modified Files: src/sys/netinet: in.c Log Message: in: No need to set expire here anymore To generate a diff of this commit: cvs rdiff -u -r1.238 -r1.239 src/sys/netinet/in.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Fri Sep 11 15:19:04 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: cond-cmp-numeric-eq.mk cond-cmp-string.mk Log Message: make(1): add tests for the unknown = and === operators To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk cvs rdiff -u -r1.3 -r1.4 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.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Fri Sep 11 15:19:04 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: cond-cmp-numeric-eq.mk cond-cmp-string.mk Log Message: make(1): add tests for the unknown = and === operators To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk cvs rdiff -u -r1.3 -r1.4 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-numeric-eq.mk diff -u src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk:1.1 src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk:1.2 --- src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk:1.1 Sun Aug 23 13:50:17 2020 +++ src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk Fri Sep 11 15:19:04 2020 @@ -1,4 +1,4 @@ -# $NetBSD: cond-cmp-numeric-eq.mk,v 1.1 2020/08/23 13:50:17 rillig Exp $ +# $NetBSD: cond-cmp-numeric-eq.mk,v 1.2 2020/09/11 15:19:04 rillig Exp $ # # Tests for numeric comparisons with the == operator in .if conditions. @@ -49,5 +49,21 @@ .error .endif + +# There is no = operator for numbers. Well, not quite, there is one, but +# it generates a warning. Therefore it is not used in practice. +.if !(12345 = 12345) +. error +.else +. error +.endif + +# There is no === operator for numbers either. +.if !(12345 === 12345) +. error +.else +. error +.endif + all: @:; Index: src/usr.bin/make/unit-tests/cond-cmp-string.mk diff -u src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.3 src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.4 --- src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.3 Thu Aug 20 18:43:19 2020 +++ src/usr.bin/make/unit-tests/cond-cmp-string.mk Fri Sep 11 15:19:04 2020 @@ -1,4 +1,4 @@ -# $NetBSD: cond-cmp-string.mk,v 1.3 2020/08/20 18:43:19 rillig Exp $ +# $NetBSD: cond-cmp-string.mk,v 1.4 2020/09/11 15:19:04 rillig Exp $ # # Tests for string comparisons in .if conditions. @@ -37,3 +37,19 @@ .if "string" != "str""ing" .error .endif + +# There is no = operator for strings. Well, not quite, there is one, but +# it generates a warning. Therefore it is not used in practice. +.if !("value" = "value") +. error +.else +. error +.endif + +# There is no === operator for strings either. +.if !("value" === "value") +. error +.else +. error +.endif +
CVS commit: src/share/man/man7
Module Name:src Committed By: roy Date: Fri Sep 11 15:16:49 UTC 2020 Modified Files: src/share/man/man7: sysctl.7 Log Message: sysctl: Adjust man page for new ARP sysctl ND settings To generate a diff of this commit: cvs rdiff -u -r1.148 -r1.149 src/share/man/man7/sysctl.7 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/share/man/man7
Module Name:src Committed By: roy Date: Fri Sep 11 15:16:49 UTC 2020 Modified Files: src/share/man/man7: sysctl.7 Log Message: sysctl: Adjust man page for new ARP sysctl ND settings To generate a diff of this commit: cvs rdiff -u -r1.148 -r1.149 src/share/man/man7/sysctl.7 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/man7/sysctl.7 diff -u src/share/man/man7/sysctl.7:1.148 src/share/man/man7/sysctl.7:1.149 --- src/share/man/man7/sysctl.7:1.148 Mon Jul 13 15:05:05 2020 +++ src/share/man/man7/sysctl.7 Fri Sep 11 15:16:48 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: sysctl.7,v 1.148 2020/07/13 15:05:05 jruoho Exp $ +.\" $NetBSD: sysctl.7,v 1.149 2020/09/11 15:16:48 roy Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95 .\" -.Dd July 13, 2020 +.Dd August 20, 2020 .Dt SYSCTL 7 .Os .Sh NAME @@ -1419,8 +1419,13 @@ The fourth level name is the variable na The currently defined protocols and names are: .Bl -column "Protocol" "anonportalgo.available" "integer" "Changeable" -offset indent .It Sy Protocol Variable Ta Sy Type Ta Sy Changeable -.It arp down integer yes -.It arp keep integer yes +.It arp nd_delay integer yes +.It arp nd_bmaxtries integer yes +.It arp nd_umaxtries integer yes +.It arp nd_basereachable integer yes +.It arp nd_retrans integer yes +.It arp nd_nud integer yes +.It arp nd_maxnudhint integer yes .It arp log_movements integer yes .It arp log_permanent_modify integer yes .It arp log_unknown_network integer yes @@ -1502,10 +1507,31 @@ The currently defined protocols and name .Pp The variables are as follows: .Bl -tag -width "123456" -.It Li arp.down -Failed ARP entry lifetime. -.It Li arp.keep -Valid ARP entry lifetime. +.It Li arp.nd_delay +The delay in seconds before sending the first probe, +after it has been decided that the entry is stale. +.It Li arp.nd_bmaxtries +The maximum number of broadcasts send to discover the hardware address +claiming an IP address. +.It Li arp.nd_umaxtries +The maximum number of unicasts send to the hardware address to ensure +it still claims an IP address. +.It Li arp.nd_basereachable +The number of milliseconds the ARP entry is considered reachable before +probing reachability. +.It Li arp.nd_retrans +The number of milliseconds between ARP probes. +.It Li arp.nd_nud +If set to non-zero, perform Neighor Unreachability Detection. +.It Li arp.nd_maxnudhint +Neighbor discovery permits upper layer protocols to supply reachability +hints, to avoid unnecessary neighbor discovery exchanges. +The variable defines the number of consecutive hints the neighbor discovery +layer will take. +For example, by setting the variable to 3, neighbor discovery layer +will take 3 consecutive hints in maximum. +After receiving 3 hints, neighbor discovery layer will perform +normal neighbor discovery process. .It Li carp.allow If set to 0, incoming .Xr carp 4 @@ -2024,7 +2050,7 @@ timing constant in IPv6 neighbor discove .Pq RFC 2461 , in seconds. .It Li icmp6.nd6_maxnudhint -IPv6 neighbor discovery permits upper layer protocols to supply reachability +Neighbor discovery permits upper layer protocols to supply reachability hints, to avoid unnecessary neighbor discovery exchanges. The variable defines the number of consecutive hints the neighbor discovery layer will take.
CVS commit: src/sys
Module Name:src Committed By: roy Date: Fri Sep 11 15:16:00 UTC 2020 Modified Files: src/sys/net: if_llatbl.c src/sys/netinet: if_arp.c if_inarp.h tcp_input.c Log Message: ARP: Use ND rather than our own. This brings the benefit of Neighbour Unreachability Detection which is something ARP sorely lacks. The new timings mirror those of IPv6 and are adjustable via sysctl(8). Unlike IPv6 ND, these are global and not per interface. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/net/if_llatbl.c cvs rdiff -u -r1.294 -r1.295 src/sys/netinet/if_arp.c cvs rdiff -u -r1.51 -r1.52 src/sys/netinet/if_inarp.h cvs rdiff -u -r1.421 -r1.422 src/sys/netinet/tcp_input.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_llatbl.c diff -u src/sys/net/if_llatbl.c:1.32 src/sys/net/if_llatbl.c:1.33 --- src/sys/net/if_llatbl.c:1.32 Fri Sep 11 15:01:26 2020 +++ src/sys/net/if_llatbl.c Fri Sep 11 15:16:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_llatbl.c,v 1.32 2020/09/11 15:01:26 roy Exp $ */ +/* $NetBSD: if_llatbl.c,v 1.33 2020/09/11 15:16:00 roy Exp $ */ /* * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved. * Copyright (c) 2004-2008 Qing Li. All rights reserved. @@ -717,6 +717,11 @@ lla_rt_output(const u_char rtm_type, con lle->la_flags |= LLE_PUB; lle->la_flags |= LLE_VALID; switch (dst->sa_family) { +#ifdef INET + case AF_INET: + lle->ln_state = ND_LLINFO_REACHABLE; + break; +#endif #ifdef INET6 case AF_INET6: lle->ln_state = ND_LLINFO_REACHABLE; Index: src/sys/netinet/if_arp.c diff -u src/sys/netinet/if_arp.c:1.294 src/sys/netinet/if_arp.c:1.295 --- src/sys/netinet/if_arp.c:1.294 Mon Mar 9 21:20:55 2020 +++ src/sys/netinet/if_arp.c Fri Sep 11 15:16:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_arp.c,v 1.294 2020/03/09 21:20:55 roy Exp $ */ +/* $NetBSD: if_arp.c,v 1.295 2020/09/11 15:16:00 roy Exp $ */ /* * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.294 2020/03/09 21:20:55 roy Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.295 2020/09/11 15:16:00 roy Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -108,6 +108,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1 #include #include #include +#include #include #include @@ -132,12 +133,36 @@ __KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1 */ #define ETHERTYPE_IPTRAILERS ETHERTYPE_TRAIL -/* timer values */ -static int arpt_keep = (20*60); /* once resolved, good for 20 more minutes */ -static int arpt_down = 20; /* once declared down, don't send for 20 secs */ -static int arp_maxhold = 1; /* number of packets to hold per ARP entry */ -#define rt_expire rt_rmx.rmx_expire -#define rt_pksent rt_rmx.rmx_pksent +/* timers */ +static int arp_reachable = REACHABLE_TIME; +static int arp_retrans = RETRANS_TIMER; +static int arp_perform_nud = 1; + +static bool arp_nud_enabled(struct ifnet *); +static unsigned int arp_llinfo_reachable(struct ifnet *); +static unsigned int arp_llinfo_retrans(struct ifnet *); +static union nd_addr *arp_llinfo_holdsrc(struct llentry *, union nd_addr *); +static void arp_llinfo_output(struct ifnet *, const union nd_addr *, +const union nd_addr *, const uint8_t *, const union nd_addr *); +static void arp_llinfo_missed(struct ifnet *, const union nd_addr *, +struct mbuf *); +static void arp_free(struct llentry *, int); + +static struct nd_domain arp_nd_domain = { + .nd_family = AF_INET, + .nd_delay = 5, /* delay first probe time 5 second */ + .nd_mmaxtries = 3, /* maximum broadcast query */ + .nd_umaxtries = 3, /* maximum unicast query */ + .nd_maxnudhint = 0, /* max # of subsequent upper layer hints */ + .nd_maxqueuelen = 1, /* max # of packets in unresolved ND entries */ + .nd_nud_enabled = arp_nud_enabled, + .nd_reachable = arp_llinfo_reachable, + .nd_retrans = arp_llinfo_retrans, + .nd_holdsrc = arp_llinfo_holdsrc, + .nd_output = arp_llinfo_output, + .nd_missed = arp_llinfo_missed, + .nd_free = arp_free, +}; int ip_dad_count = PROBE_NUM; #ifdef ARP_DEBUG @@ -151,14 +176,10 @@ static void arp_dad_init(void); static void arprequest(struct ifnet *, const struct in_addr *, const struct in_addr *, -const uint8_t *); +const uint8_t *, const uint8_t *); static void arpannounce1(struct ifaddr *); static struct sockaddr *arp_setgate(struct rtentry *, struct sockaddr *, const struct sockaddr *); -static void arptimer(void *); -static void arp_settimer(struct llentry *, int); -static struct llentry *arplookup(struct ifnet *, -const struct in_addr *, const struct sockaddr *, int); static struct llentry *arpcreate(struct ifnet *, const struct in_addr *, const struct sockaddr *, int); static void in_arpinput(struct mbuf *); @@ -173,8 +194,6 @@ static void arp_dad_start(struct ifaddr static void arp_dad_stop(struct
CVS commit: src/sys
Module Name:src Committed By: roy Date: Fri Sep 11 15:16:00 UTC 2020 Modified Files: src/sys/net: if_llatbl.c src/sys/netinet: if_arp.c if_inarp.h tcp_input.c Log Message: ARP: Use ND rather than our own. This brings the benefit of Neighbour Unreachability Detection which is something ARP sorely lacks. The new timings mirror those of IPv6 and are adjustable via sysctl(8). Unlike IPv6 ND, these are global and not per interface. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/net/if_llatbl.c cvs rdiff -u -r1.294 -r1.295 src/sys/netinet/if_arp.c cvs rdiff -u -r1.51 -r1.52 src/sys/netinet/if_inarp.h cvs rdiff -u -r1.421 -r1.422 src/sys/netinet/tcp_input.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/netinet
Module Name:src Committed By: roy Date: Fri Sep 11 15:08:25 UTC 2020 Modified Files: src/sys/netinet: tcp_input.c Log Message: tcp_input: Adjust for ND changes To generate a diff of this commit: cvs rdiff -u -r1.420 -r1.421 src/sys/netinet/tcp_input.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/netinet/tcp_input.c diff -u src/sys/netinet/tcp_input.c:1.420 src/sys/netinet/tcp_input.c:1.421 --- src/sys/netinet/tcp_input.c:1.420 Fri Sep 11 09:08:47 2020 +++ src/sys/netinet/tcp_input.c Fri Sep 11 15:08:25 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_input.c,v 1.420 2020/09/11 09:08:47 kardel Exp $ */ +/* $NetBSD: tcp_input.c,v 1.421 2020/09/11 15:08:25 roy Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -148,7 +148,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.420 2020/09/11 09:08:47 kardel Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.421 2020/09/11 15:08:25 roy Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -253,24 +253,46 @@ static void syn_cache_timer(void *); /* * Neighbor Discovery, Neighbor Unreachability Detection Upper layer hint. */ -#ifdef INET6 -static inline void -nd6_hint(struct tcpcb *tp) +static void +nd_hint(struct tcpcb *tp) { - struct rtentry *rt = NULL; + struct route *ro = NULL; + struct rtentry *rt; + + if (tp == NULL) + return; + + switch (tp->t_family) { +#ifdef INET6 + case AF_INET6: + if (tp->t_in6pcb != NULL) + ro = >t_in6pcb->in6p_route; + break; +#endif + } + + if (ro == NULL) + return; - if (tp != NULL && tp->t_in6pcb != NULL && tp->t_family == AF_INET6 && - (rt = rtcache_validate(>t_in6pcb->in6p_route)) != NULL) { + rt = rtcache_validate(ro); + if (rt == NULL) + return; + + switch (tp->t_family) { +#ifdef INET + case AF_INET: + arp_nud_hint(rt); + break; +#endif +#ifdef INET6 + case AF_INET6: nd6_nud_hint(rt); - rtcache_unref(rt, >t_in6pcb->in6p_route); + break; +#endif } + + rtcache_unref(rt, ro); } -#else -static inline void -nd6_hint(struct tcpcb *tp) -{ -} -#endif /* * Compute ACK transmission behavior. Delay the ACK unless @@ -769,7 +791,7 @@ present: tp->rcv_nxt += q->ipqe_len; pkt_flags = q->ipqe_flags & TH_FIN; - nd6_hint(tp); + nd_hint(tp); TAILQ_REMOVE(>segq, q, ipqe_q); TAILQ_REMOVE(>timeq, q, ipqe_timeq); @@ -1884,7 +1906,7 @@ after_listen: tcps[TCP_STAT_RCVACKPACK]++; tcps[TCP_STAT_RCVACKBYTE] += acked; TCP_STAT_PUTREF(); -nd6_hint(tp); +nd_hint(tp); if (acked > (tp->t_lastoff - tp->t_inoff)) tp->t_lastm = NULL; @@ -1967,7 +1989,7 @@ after_listen: tcps[TCP_STAT_RCVPACK]++; tcps[TCP_STAT_RCVBYTE] += tlen; TCP_STAT_PUTREF(); - nd6_hint(tp); + nd_hint(tp); /* * Automatic sizing enables the performance of large buffers * and most of the efficiency of small ones by only allocating @@ -2595,7 +2617,7 @@ after_listen: */ tp->t_congctl->newack(tp, th); - nd6_hint(tp); + nd_hint(tp); if (acked > so->so_snd.sb_cc) { tp->snd_wnd -= so->so_snd.sb_cc; sbdrop(>so_snd, (int)so->so_snd.sb_cc); @@ -2801,7 +2823,7 @@ dodata: tcps[TCP_STAT_RCVPACK]++; tcps[TCP_STAT_RCVBYTE] += tlen; TCP_STAT_PUTREF(); - nd6_hint(tp); + nd_hint(tp); if (so->so_state & SS_CANTRCVMORE) { m_freem(m); } else {
CVS commit: src/sys/netinet
Module Name:src Committed By: roy Date: Fri Sep 11 15:08:25 UTC 2020 Modified Files: src/sys/netinet: tcp_input.c Log Message: tcp_input: Adjust for ND changes To generate a diff of this commit: cvs rdiff -u -r1.420 -r1.421 src/sys/netinet/tcp_input.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/netinet6
Module Name:src Committed By: roy Date: Fri Sep 11 15:03:33 UTC 2020 Modified Files: src/sys/netinet6: icmp6.c nd6.c nd6.h nd6_nbr.c Log Message: inet6: Use generic Neighor Detection rather than IPv6 specific No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.246 -r1.247 src/sys/netinet6/icmp6.c cvs rdiff -u -r1.271 -r1.272 src/sys/netinet6/nd6.c cvs rdiff -u -r1.90 -r1.91 src/sys/netinet6/nd6.h cvs rdiff -u -r1.180 -r1.181 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/icmp6.c diff -u src/sys/netinet6/icmp6.c:1.246 src/sys/netinet6/icmp6.c:1.247 --- src/sys/netinet6/icmp6.c:1.246 Mon Jul 27 14:52:55 2020 +++ src/sys/netinet6/icmp6.c Fri Sep 11 15:03:33 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: icmp6.c,v 1.246 2020/07/27 14:52:55 roy Exp $ */ +/* $NetBSD: icmp6.c,v 1.247 2020/09/11 15:03:33 roy Exp $ */ /* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */ /* @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.246 2020/07/27 14:52:55 roy Exp $"); +__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.247 2020/09/11 15:03:33 roy Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -87,6 +87,7 @@ __KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1. #include #include #include +#include #include #include @@ -98,9 +99,9 @@ __KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1. #include #include #include -#include #include #include +#include #include #ifdef IPSEC @@ -2953,7 +2954,6 @@ out: static void sysctl_net_inet6_icmp6_setup(struct sysctllog **clog) { - extern int nd6_maxqueuelen; /* defined in nd6.c */ sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT, @@ -3008,23 +3008,37 @@ sysctl_net_inet6_icmp6_setup(struct sysc CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, "nd6_delay", SYSCTL_DESCR("First probe delay time"), - NULL, 0, _delay, 0, + NULL, 0, _nd_domain.nd_delay, 0, CTL_NET, PF_INET6, IPPROTO_ICMPV6, ICMPV6CTL_ND6_DELAY, CTL_EOL); sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, + CTLTYPE_INT, "nd6_mmaxtries", + SYSCTL_DESCR("Number of multicast discovery attempts"), + NULL, 0, _nd_domain.nd_mmaxtries, 0, + CTL_NET, PF_INET6, IPPROTO_ICMPV6, + ICMPV6CTL_ND6_MMAXTRIES, CTL_EOL); + sysctl_createv(clog, 0, NULL, NULL, + CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, "nd6_umaxtries", SYSCTL_DESCR("Number of unicast discovery attempts"), - NULL, 0, _umaxtries, 0, + NULL, 0, _nd_domain.nd_umaxtries, 0, CTL_NET, PF_INET6, IPPROTO_ICMPV6, ICMPV6CTL_ND6_UMAXTRIES, CTL_EOL); sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, - CTLTYPE_INT, "nd6_mmaxtries", - SYSCTL_DESCR("Number of multicast discovery attempts"), - NULL, 0, _mmaxtries, 0, + CTLTYPE_INT, "nd6_maxnudhint", + SYSCTL_DESCR("Maximum neighbor unreachable hint count"), + NULL, 0, _nd_domain.nd_maxnudhint, 0, CTL_NET, PF_INET6, IPPROTO_ICMPV6, - ICMPV6CTL_ND6_MMAXTRIES, CTL_EOL); + ICMPV6CTL_ND6_MAXNUDHINT, CTL_EOL); + sysctl_createv(clog, 0, NULL, NULL, + CTLFLAG_PERMANENT|CTLFLAG_READWRITE, + CTLTYPE_INT, "maxqueuelen", + SYSCTL_DESCR("max packet queue len for a unresolved ND"), + NULL, 1, _nd_domain.nd_maxqueuelen, 0, + CTL_NET, PF_INET6, IPPROTO_ICMPV6, + ICMPV6CTL_ND6_MAXQLEN, CTL_EOL); sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, "nd6_useloopback", @@ -3056,13 +3070,6 @@ sysctl_net_inet6_icmp6_setup(struct sysc ICMPV6CTL_ERRPPSLIMIT, CTL_EOL); sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, - CTLTYPE_INT, "nd6_maxnudhint", - SYSCTL_DESCR("Maximum neighbor unreachable hint count"), - NULL, 0, _maxnudhint, 0, - CTL_NET, PF_INET6, IPPROTO_ICMPV6, - ICMPV6CTL_ND6_MAXNUDHINT, CTL_EOL); - sysctl_createv(clog, 0, NULL, NULL, - CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, "mtudisc_hiwat", SYSCTL_DESCR("Low mark on MTU Discovery route timers"), NULL, 0, _mtudisc_hiwat, 0, @@ -3098,13 +3105,6 @@ sysctl_net_inet6_icmp6_setup(struct sysc CTL_NET, PF_INET6, IPPROTO_ICMPV6, OICMPV6CTL_ND6_PRLIST, CTL_EOL); #endif - sysctl_createv(clog, 0, NULL, NULL, - CTLFLAG_PERMANENT|CTLFLAG_READWRITE, - CTLTYPE_INT, "maxqueuelen", - SYSCTL_DESCR("max packet queue len for a unresolved ND"), - NULL, 1, _maxqueuelen, 0, - CTL_NET, PF_INET6, IPPROTO_ICMPV6, - ICMPV6CTL_ND6_MAXQLEN, CTL_EOL); } void Index:
CVS commit: src/sys/netinet6
Module Name:src Committed By: roy Date: Fri Sep 11 15:03:33 UTC 2020 Modified Files: src/sys/netinet6: icmp6.c nd6.c nd6.h nd6_nbr.c Log Message: inet6: Use generic Neighor Detection rather than IPv6 specific No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.246 -r1.247 src/sys/netinet6/icmp6.c cvs rdiff -u -r1.271 -r1.272 src/sys/netinet6/nd6.c cvs rdiff -u -r1.90 -r1.91 src/sys/netinet6/nd6.h cvs rdiff -u -r1.180 -r1.181 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.
CVS commit: src/sys/net
Module Name:src Committed By: roy Date: Fri Sep 11 15:01:27 UTC 2020 Modified Files: src/sys/net: if_llatbl.c Log Message: if_llatbl.c: adjust for nd changes To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/net/if_llatbl.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_llatbl.c diff -u src/sys/net/if_llatbl.c:1.31 src/sys/net/if_llatbl.c:1.32 --- src/sys/net/if_llatbl.c:1.31 Wed Sep 25 09:53:37 2019 +++ src/sys/net/if_llatbl.c Fri Sep 11 15:01:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_llatbl.c,v 1.31 2019/09/25 09:53:37 ozaki-r Exp $ */ +/* $NetBSD: if_llatbl.c,v 1.32 2020/09/11 15:01:26 roy Exp $ */ /* * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved. * Copyright (c) 2004-2008 Qing Li. All rights reserved. @@ -59,11 +59,11 @@ #include #include #include +#include #include #include #include #include -#include static SLIST_HEAD(, lltable) lltables; krwlock_t lltable_rwlock; @@ -716,13 +716,14 @@ lla_rt_output(const u_char rtm_type, con if ((rtm_flags & RTF_ANNOUNCE)) lle->la_flags |= LLE_PUB; lle->la_flags |= LLE_VALID; + switch (dst->sa_family) { #ifdef INET6 - /* - * ND6 - */ - if (dst->sa_family == AF_INET6) - lle->ln_state = ND6_LLINFO_REACHABLE; + case AF_INET6: + lle->ln_state = ND_LLINFO_REACHABLE; + break; #endif + } + /* * NB: arp and ndp always set (RTF_STATIC | RTF_HOST) */
CVS commit: src/sys/net
Module Name:src Committed By: roy Date: Fri Sep 11 15:01:27 UTC 2020 Modified Files: src/sys/net: if_llatbl.c Log Message: if_llatbl.c: adjust for nd changes To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/net/if_llatbl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: roy Date: Fri Sep 11 14:59:22 UTC 2020 Modified Files: src/sys/net: Makefile files.net Added Files: src/sys/net: nd.c nd.h Log Message: Implement address agnostic Neighbor Detection. This is heavily based on IPv6 Neighbor Detection and allows per protocol timers which also facilitate Neighor Unreachability Detection. To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/net/Makefile cvs rdiff -u -r1.26 -r1.27 src/sys/net/files.net cvs rdiff -u -r0 -r1.1 src/sys/net/nd.c src/sys/net/nd.h 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/Makefile diff -u src/sys/net/Makefile:1.43 src/sys/net/Makefile:1.44 --- src/sys/net/Makefile:1.43 Thu Aug 20 21:21:32 2020 +++ src/sys/net/Makefile Fri Sep 11 14:59:22 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.43 2020/08/20 21:21:32 riastradh Exp $ +# $NetBSD: Makefile,v 1.44 2020/09/11 14:59:22 roy Exp $ INCSDIR= /usr/include/net @@ -6,8 +6,9 @@ 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 if_wg.h net_stats.h \ - netisr.h pfil.h pfkeyv2.h pfvar.h ppp-comp.h ppp_defs.h radix.h \ + if_stf.h if_tap.h if_tun.h if_types.h if_vlanvar.h if_wg.h \ + nd.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 SUBDIR= agr npf Index: src/sys/net/files.net diff -u src/sys/net/files.net:1.26 src/sys/net/files.net:1.27 --- src/sys/net/files.net:1.26 Thu Aug 20 21:21:32 2020 +++ src/sys/net/files.net Fri Sep 11 14:59:22 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.net,v 1.26 2020/08/20 21:21:32 riastradh Exp $ +# $NetBSD: files.net,v 1.27 2020/09/11 14:59:22 roy Exp $ # XXX CLEANUP define net @@ -34,6 +34,7 @@ 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/nd.c inet | inet6 file net/pfil.c net file net/ppp-deflate.c ppp & ppp_deflate file net/ppp_tty.c ppp Added files: Index: src/sys/net/nd.c diff -u /dev/null src/sys/net/nd.c:1.1 --- /dev/null Fri Sep 11 14:59:22 2020 +++ src/sys/net/nd.c Fri Sep 11 14:59:22 2020 @@ -0,0 +1,420 @@ +/* $NetBSD: */ + +/* + * Copyright (c) 2020 The NetBSD Foundation, Inc. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Roy Marples. + * + * 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 ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: nd.c,v 1.1 2020/09/11 14:59:22 roy Exp $"); + +#include +#include +#include /* for softnet_lock */ + +#include +#include +#include + +#include +#include + +static struct nd_domain *nd_domains[AF_MAX]; + +static int nd_gctimer = (60 * 60 * 24); /* 1 day: garbage collection timer */ + +static void nd_set_timertick(struct llentry *, time_t); +static struct nd_domain *nd_find_domain(int); + +static void +nd_timer(void *arg) +{ + struct llentry *ln = arg; + struct nd_domain *nd; + struct ifnet *ifp = NULL; + struct psref psref; + struct mbuf *m = NULL; + bool send_ns = false, missed = false; + union nd_addr taddr, *daddrp = NULL; + + SOFTNET_KERNEL_LOCK_UNLESS_NET_MPSAFE(); + LLE_WLOCK(ln); + + if (!(ln->la_flags & LLE_LINKED)) + goto out; + if (ln->ln_ntick > 0) { + nd_set_timer(ln, ND_TIMER_TICK); + goto out; + } + + nd = nd_find_domain(ln->lle_tbl->llt_af); + ifp = ln->lle_tbl->llt_ifp; + KASSERT(ifp != NULL); + if_acquire(ifp, ); + + memcpy(, >r_l3addr, sizeof(taddr)); + +
CVS commit: src/sys/net
Module Name:src Committed By: roy Date: Fri Sep 11 14:59:22 UTC 2020 Modified Files: src/sys/net: Makefile files.net Added Files: src/sys/net: nd.c nd.h Log Message: Implement address agnostic Neighbor Detection. This is heavily based on IPv6 Neighbor Detection and allows per protocol timers which also facilitate Neighor Unreachability Detection. To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/net/Makefile cvs rdiff -u -r1.26 -r1.27 src/sys/net/files.net cvs rdiff -u -r0 -r1.1 src/sys/net/nd.c src/sys/net/nd.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Fri Sep 11 14:29:00 UTC 2020 Modified Files: src/sys/net: pktqueue.c Log Message: pktqueue(9): Use percpu_create to allow early initialization. Otherwise pktqueues can't be created before all CPUs are detected -- they will have a queue only for the primary CPU, not for others. This will also be necessary if we want to add CPU hotplug (still need some way to block hotplug during pktq_set_maxlen but it's a start). To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/net/pktqueue.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Fri Sep 11 14:29:00 UTC 2020 Modified Files: src/sys/net: pktqueue.c Log Message: pktqueue(9): Use percpu_create to allow early initialization. Otherwise pktqueues can't be created before all CPUs are detected -- they will have a queue only for the primary CPU, not for others. This will also be necessary if we want to add CPU hotplug (still need some way to block hotplug during pktq_set_maxlen but it's a start). To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/net/pktqueue.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/pktqueue.c diff -u src/sys/net/pktqueue.c:1.11 src/sys/net/pktqueue.c:1.12 --- src/sys/net/pktqueue.c:1.11 Fri Feb 7 12:35:33 2020 +++ src/sys/net/pktqueue.c Fri Sep 11 14:29:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pktqueue.c,v 1.11 2020/02/07 12:35:33 thorpej Exp $ */ +/* $NetBSD: pktqueue.c,v 1.12 2020/09/11 14:29:00 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pktqueue.c,v 1.11 2020/02/07 12:35:33 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pktqueue.c,v 1.12 2020/09/11 14:29:00 riastradh Exp $"); #include #include @@ -74,7 +74,7 @@ struct pktqueue { void * pq_sih; /* Finally, per-CPU queues. */ - pcq_t * pq_queue[]; + struct percpu * pq_pcq; /* struct pcq * */ }; /* The counters of the packet queue. */ @@ -90,17 +90,46 @@ typedef struct { /* Special marker value used by pktq_barrier() mechanism. */ #define PKTQ_MARKER ((void *)(~0ULL)) -/* - * The total size of pktqueue_t which depends on the number of CPUs. - */ -#define PKTQUEUE_STRUCT_LEN(ncpu) \ -roundup2(offsetof(pktqueue_t, pq_queue[ncpu]), coherency_unit) +static void +pktq_init_cpu(void *vqp, void *vpq, struct cpu_info *ci) +{ + struct pcq **qp = vqp; + struct pktqueue *pq = vpq; + + *qp = pcq_create(pq->pq_maxlen, KM_SLEEP); +} + +static void +pktq_fini_cpu(void *vqp, void *vpq, struct cpu_info *ci) +{ + struct pcq **qp = vqp, *q = *qp; + + KASSERT(pcq_peek(q) == NULL); + pcq_destroy(q); + *qp = NULL; /* paranoia */ +} + +static struct pcq * +pktq_pcq(struct pktqueue *pq, struct cpu_info *ci) +{ + struct pcq **qp, *q; + + /* + * As long as preemption is disabled, the xcall to swap percpu + * buffers can't complete, so it is safe to read the pointer. + */ + KASSERT(kpreempt_disabled()); + + qp = percpu_getptr_remote(pq->pq_pcq, ci); + q = *qp; + + return q; +} pktqueue_t * pktq_create(size_t maxlen, void (*intrh)(void *), void *sc) { const u_int sflags = SOFTINT_NET | SOFTINT_MPSAFE | SOFTINT_RCPU; - const size_t len = PKTQUEUE_STRUCT_LEN(ncpu); pktqueue_t *pq; percpu_t *pc; void *sih; @@ -111,14 +140,13 @@ pktq_create(size_t maxlen, void (*intrh) return NULL; } - pq = kmem_zalloc(len, KM_SLEEP); - for (u_int i = 0; i < ncpu; i++) { - pq->pq_queue[i] = pcq_create(maxlen, KM_SLEEP); - } + pq = kmem_zalloc(sizeof(*pq), KM_SLEEP); mutex_init(>pq_lock, MUTEX_DEFAULT, IPL_NONE); pq->pq_maxlen = maxlen; pq->pq_counters = pc; pq->pq_sih = sih; + pq->pq_pcq = percpu_create(sizeof(struct pcq *), + pktq_init_cpu, pktq_fini_cpu, pq); return pq; } @@ -126,17 +154,12 @@ pktq_create(size_t maxlen, void (*intrh) void pktq_destroy(pktqueue_t *pq) { - const size_t len = PKTQUEUE_STRUCT_LEN(ncpu); - for (u_int i = 0; i < ncpu; i++) { - pcq_t *q = pq->pq_queue[i]; - KASSERT(pcq_peek(q) == NULL); - pcq_destroy(q); - } + percpu_free(pq->pq_pcq, sizeof(struct pcq *)); percpu_free(pq->pq_counters, sizeof(pktq_counters_t)); softint_disestablish(pq->pq_sih); mutex_destroy(>pq_lock); - kmem_free(pq, len); + kmem_free(pq, sizeof(*pq)); } /* @@ -213,18 +236,18 @@ bool pktq_enqueue(pktqueue_t *pq, struct mbuf *m, const u_int hash __unused) { #if defined(_RUMPKERNEL) || defined(_RUMP_NATIVE_ABI) - const unsigned cpuid = curcpu()->ci_index; + struct cpu_info *ci = curcpu(); #else - const unsigned cpuid = hash % ncpu; + struct cpu_info *ci = cpu_lookup(hash % ncpu); #endif KASSERT(kpreempt_disabled()); - if (__predict_false(!pcq_put(pq->pq_queue[cpuid], m))) { + if (__predict_false(!pcq_put(pktq_pcq(pq, ci), m))) { pktq_inc_count(pq, PQCNT_DROP); return false; } - softint_schedule_cpu(pq->pq_sih, cpu_lookup(cpuid)); + softint_schedule_cpu(pq->pq_sih, ci); pktq_inc_count(pq, PQCNT_ENQUEUE); return true; } @@ -238,11 +261,12 @@ pktq_enqueue(pktqueue_t *pq, struct mbuf struct mbuf * pktq_dequeue(pktqueue_t *pq) { - const struct cpu_info *ci = curcpu(); - const unsigned cpuid = cpu_index(ci); + struct cpu_info *ci = curcpu(); struct mbuf *m; - m = pcq_get(pq->pq_queue[cpuid]); + KASSERT(kpreempt_disabled()); + + m = pcq_get(pktq_pcq(pq, ci)); if (__predict_false(m == PKTQ_MARKER)) { /* Note the marker entry. */ atomic_inc_uint(>pq_barrier); @@
Re: CVS commit: src/external/gpl3/gcc
On 11.09.2020 07:13, Rin Okuyama wrote: > Hi again, > > On 2020/09/10 21:53, Kamil Rytarowski wrote: >> Module Name: src >> Committed By: kamil >> Date: Thu Sep 10 12:53:06 UTC 2020 >> >> Modified Files: >> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common: >> sanitizer_linux_libcdep.cc >> src/external/gpl3/gcc/lib: Makefile.sanitizer >> >> Log Message: >> Avoid using internal RTLD/libpthread/libc symbol in sanitizers >> > ... >> Index: >> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc >> >> diff -u >> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc:1.15 >> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc:1.16 >> >> --- >> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc:1.15 >> >> Mon Sep 7 07:10:43 2020 >> +++ >> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc >> >> Thu Sep 10 12:53:05 2020 >> @@ -47,6 +47,7 @@ >> #if SANITIZER_NETBSD >> #include >> #include >> +#include >> #endif >> #if SANITIZER_SOLARIS >> @@ -417,13 +418,7 @@ uptr ThreadSelf() { >> #if SANITIZER_NETBSD >> static struct tls_tcb * ThreadSelfTlsTcb() { >> - struct tls_tcb * tcb = NULL; >> -# ifdef __HAVE___LWP_GETTCB_FAST >> - tcb = (struct tls_tcb *)__lwp_gettcb_fast(); >> -# elif defined(__HAVE___LWP_GETPRIVATE_FAST) >> - tcb = (struct tls_tcb *)__lwp_getprivate_fast(); >> -# endif >> - return tcb; >> + return (struct tls_tcb *)_lwp_getprivate(); >> } >> uptr ThreadSelf() { >> > > This change breaks at least mips and powerpc, in which the return value of > __lwp_getprivate(2), i.e., curlwp->l_private is not tcb address itself, but > biased one. On the other hand, the return value of __lwp_gettcb_fast() is > unbiased address; see sys/arch/{mips,powerpc}/include/mcontext.h. > > For powerpc, I recently attempted to change l_private to store tcb address > itself: > > http://www.nerv.org/netbsd/?q=id:20200621T004000Z.95c1a18070b53713ce2c763df7f40743bf74172c > > > But I reverted it soon as requested by joerg: > > http://www.nerv.org/netbsd/?q=id:20200622T053457Z.05db3be87b5ad499f5d1adba755bc573fd241c87 > > > His reasoning was that kernel must not know the ABI details in userland. > I fully agree with this. See above links for more details. > > Thanks, > rin Thank you for noting it! This is strange as I assumed that _lwp_getprivate() returns always the correct private pointer and it is abstraction over fast ABI specific calls . Also the usage of _lwp_getprivate() was suggested by Joerg back then in sanitizers. So we want exported to userland functionality to get the tls_tcb pointer, something without using the internal RTLS/LIBPTHREAD/LIBC namespaces. The current code is confusing, as it attempts to use unimplemented _PTHREAD_GETTCB_EXT() and in one place uses _lwp_getprivate_fast() in other _lwp_getprivate(). This caused my confusion... as I assumed that _lwp_getprivate_fast() is internal and _lwp_getprivate() for public consumption. https://nxr.netbsd.org/xref/src/lib/libpthread/pthread_int.h#266 263 static inline pthread_t __constfunc 264 pthread__self(void) 265 { 266 #if defined(_PTHREAD_GETTCB_EXT) 267 struct tls_tcb * const tcb = _PTHREAD_GETTCB_EXT(); 268 #elif defined(__HAVE___LWP_GETTCB_FAST) 269 struct tls_tcb * const tcb = __lwp_gettcb_fast(); 270 #else 271 struct tls_tcb * const tcb = __lwp_getprivate_fast(); 272 #endif 273 return (pthread_t)tcb->tcb_pthread; 274 } https://nxr.netbsd.org/xref/src/lib/libpthread/pthread.c#1268 1268 #if defined(_PTHREAD_GETTCB_EXT) 1269 pthread__main->pt_tls = _PTHREAD_GETTCB_EXT(); 1270 #elif defined(__HAVE___LWP_GETTCB_FAST) 1271 pthread__main->pt_tls = __lwp_gettcb_fast(); 1272 #else 1273 pthread__main->pt_tls = _lwp_getprivate(); 1274 #endif 1275 pthread__main->pt_tls->tcb_pthread = pthread__main; https://nxr.netbsd.org/xref/src/libexec/ld.elf_so/tls.c#294 293 #ifdef __HAVE___LWP_GETTCB_FAST 294 struct tls_tcb * const tcb = __lwp_gettcb_fast(); 295 #else 296 struct tls_tcb * const tcb = __lwp_getprivate_fast(); 297 #endif 1. Could we please synchronize above three code chunks, avoiding the situation of having each of them implemented differently? 2. Could we please export _rtld_tls_self() or something similar and register in ? Does this patch look good? https://www.netbsd.org/~kamil/patch-00278-_rtld_tls_self.txt In the worst case I will need to reexpose internal APIs in sanitizers and pick one of the above tls_tcb retrieval implementations and use in LLVM/GCC sanitizers. PS. There is an ongoing GCC and Linux kernel discussion on a related topic in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96200 "Implement __builtin_thread_pointer() and
CVS commit: src
Module Name:src Committed By: jmcneill Date: Fri Sep 11 14:06:00 UTC 2020 Modified Files: src/distrib/sets/lists/base: ad.aarch64 src/external/bsd/acpica/bin/iasl: Makefile src/usr.sbin/acpitools/acpidump: Makefile src/usr.sbin/acpitools/amldb: Makefile Log Message: Build acpi tools and iasl on aarch64eb, and fix set lists for MKDEBUG. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/distrib/sets/lists/base/ad.aarch64 cvs rdiff -u -r1.25 -r1.26 src/external/bsd/acpica/bin/iasl/Makefile cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/acpitools/acpidump/Makefile cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/acpitools/amldb/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: jmcneill Date: Fri Sep 11 14:06:00 UTC 2020 Modified Files: src/distrib/sets/lists/base: ad.aarch64 src/external/bsd/acpica/bin/iasl: Makefile src/usr.sbin/acpitools/acpidump: Makefile src/usr.sbin/acpitools/amldb: Makefile Log Message: Build acpi tools and iasl on aarch64eb, and fix set lists for MKDEBUG. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/distrib/sets/lists/base/ad.aarch64 cvs rdiff -u -r1.25 -r1.26 src/external/bsd/acpica/bin/iasl/Makefile cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/acpitools/acpidump/Makefile cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/acpitools/amldb/Makefile 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/base/ad.aarch64 diff -u src/distrib/sets/lists/base/ad.aarch64:1.33 src/distrib/sets/lists/base/ad.aarch64:1.34 --- src/distrib/sets/lists/base/ad.aarch64:1.33 Tue Sep 8 16:39:36 2020 +++ src/distrib/sets/lists/base/ad.aarch64 Fri Sep 11 14:06:00 2020 @@ -1,4 +1,4 @@ -# $NetBSD: ad.aarch64,v 1.33 2020/09/08 16:39:36 jmcneill Exp $ +# $NetBSD: ad.aarch64,v 1.34 2020/09/11 14:06:00 jmcneill Exp $ ./lib/eabi base-compat-lib compat,llvm ./lib/eabi/npf base-compat-lib compat,llvm ./lib/eabihf base-compat-lib compat,llvm @@ -8,7 +8,7 @@ ./libexec/ld.elf_so-eabi base-compat-shlib compat,pic,llvm ./libexec/ld.elf_so-eabihf base-compat-shlib compat,pic,llvm ./libexec/ld.elf_so-oabi base-sysutil-bin compat,pic,llvm -./usr/bin/iasl base-util-bin endian=1234 +./usr/bin/iasl base-util-bin ./usr/lib/eabi base-compat-lib compat,llvm ./usr/lib/eabi/i18nbase-compat-lib compat,llvm ./usr/lib/eabi/libarm.so.0 base-compat-shlib compat,pic,llvm @@ -38,7 +38,7 @@ ./usr/libexec/ld.elf_so-eabihf base-compat-shlib compat,pic,llvm ./usr/libexec/ld.elf_so-oabi base-sysutil-bin compat,pic,llvm ./usr/mdec/bootaa64.efibase-sysutil-bin -./usr/sbin/acpidumpbase-sysutil-bin endian=1234 -./usr/sbin/amldbbase-sysutil-bin endian=1234 +./usr/sbin/acpidumpbase-sysutil-bin +./usr/sbin/amldbbase-sysutil-bin ./usr/sbin/ofctlbase-sysutil-bin ./usr/sbin/tpctlbase-sysutil-bin Index: src/external/bsd/acpica/bin/iasl/Makefile diff -u src/external/bsd/acpica/bin/iasl/Makefile:1.25 src/external/bsd/acpica/bin/iasl/Makefile:1.26 --- src/external/bsd/acpica/bin/iasl/Makefile:1.25 Tue Oct 15 16:14:49 2019 +++ src/external/bsd/acpica/bin/iasl/Makefile Fri Sep 11 14:06:00 2020 @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.25 2019/10/15 16:14:49 christos Exp $ +# $NetBSD: Makefile,v 1.26 2020/09/11 14:06:00 jmcneill Exp $ -.if (${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "aarch64") +.if (${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" || !empty(MACHINE_ARCH:Maarch64*)) PROG= iasl .endif BINDIR= /usr/bin Index: src/usr.sbin/acpitools/acpidump/Makefile diff -u src/usr.sbin/acpitools/acpidump/Makefile:1.7 src/usr.sbin/acpitools/acpidump/Makefile:1.8 --- src/usr.sbin/acpitools/acpidump/Makefile:1.7 Sun Oct 14 13:36:32 2018 +++ src/usr.sbin/acpitools/acpidump/Makefile Fri Sep 11 14:06:00 2020 @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.7 2018/10/14 13:36:32 jmcneill Exp $ +# $NetBSD: Makefile,v 1.8 2020/09/11 14:06:00 jmcneill Exp $ # $FreeBSD: src/usr.sbin/acpi/acpidump/Makefile,v 1.7 2003/08/28 03:33:07 njl Exp $ -.if (${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "aarch64") +.if (${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" || !empty(MACHINE_ARCH:Maarch64*)) CPPFLAGS+=-I${.CURDIR}/../../../sys -D_KERNTYPES CPPFLAGS+=-I${.CURDIR}/.. PROG= acpidump Index: src/usr.sbin/acpitools/amldb/Makefile diff -u src/usr.sbin/acpitools/amldb/Makefile:1.6 src/usr.sbin/acpitools/amldb/Makefile:1.7 --- src/usr.sbin/acpitools/amldb/Makefile:1.6 Sun Oct 13 07:28:17 2019 +++ src/usr.sbin/acpitools/amldb/Makefile Fri Sep 11 14:06:00 2020 @@ -1,8 +1,8 @@ -# $NetBSD: Makefile,v 1.6 2019/10/13 07:28:17 mrg Exp $ +# $NetBSD: Makefile,v 1.7 2020/09/11 14:06:00 jmcneill Exp $ # Id: Makefile,v 1.5 2000/07/14 18:16:30 iwasaki Exp # $FreeBSD: src/usr.sbin/acpi/amldb/Makefile,v 1.7 2001/10/22 17:25:32 iwasaki Exp $ -.if (${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "aarch64") +.if (${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" || !empty(MACHINE_ARCH:Maarch64*)) PROG= amldb SRCS= amldb.c debug.c region.c SRCS+= aml_parse.c aml_name.c aml_amlmem.c aml_memman.c aml_store.c \
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Sep 11 13:58:46 UTC 2020 Modified Files: src/usr.bin/make: cond.c Log Message: make(1): split CondParser_Comparison into 2 parts To generate a diff of this commit: cvs rdiff -u -r1.129 -r1.130 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.129 src/usr.bin/make/cond.c:1.130 --- src/usr.bin/make/cond.c:1.129 Fri Sep 11 07:09:40 2020 +++ src/usr.bin/make/cond.c Fri Sep 11 13:58:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.129 2020/09/11 07:09:40 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.130 2020/09/11 13:58:45 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.129 2020/09/11 07:09:40 rillig Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.130 2020/09/11 13:58:45 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.129 2020/09/11 07:09:40 rillig Exp $"); +__RCSID("$NetBSD: cond.c,v 1.130 2020/09/11 13:58:45 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -523,6 +523,70 @@ static const struct If { { NULL,0, FALSE, NULL } }; +static Token +EvalComparison(const char *lhs, Boolean lhsQuoted, const char *op, + const char *rhs, Boolean rhsQuoted) +{ +double left, right; + +if (rhsQuoted || lhsQuoted) { + do_string_compare: + if (((*op != '!') && (*op != '=')) || (op[1] != '=')) { + Parse_Error(PARSE_WARNING, + "String comparison operator should be either == or !="); + return TOK_ERROR; + } + + if (DEBUG(COND)) { + fprintf(debug_file, "lhs = \"%s\", rhs = \"%s\", op = %.2s\n", + lhs, rhs, op); + } + return (*op == '=') == (strcmp(lhs, rhs) == 0); +} + +/* + * rhs is either a float or an integer. Convert both the + * lhs and the rhs to a double and compare the two. + */ + +if (!TryParseNumber(lhs, ) || !TryParseNumber(rhs, )) + goto do_string_compare; + +if (DEBUG(COND)) { + fprintf(debug_file, "left = %f, right = %f, op = %.2s\n", left, + right, op); +} +switch (op[0]) { +case '!': + if (op[1] != '=') { + Parse_Error(PARSE_WARNING, + "Unknown operator"); + return TOK_ERROR; + } + return left != right; +case '=': + if (op[1] != '=') { + Parse_Error(PARSE_WARNING, + "Unknown operator"); + return TOK_ERROR; + } + return left == right; +case '<': + if (op[1] == '=') { + return left <= right; + } else { + return left < right; + } +case '>': + if (op[1] == '=') { + return left >= right; + } else { + return left > right; + } +} +return TOK_ERROR; +} + /* Parse a comparison condition such as: * * 0 @@ -541,7 +605,6 @@ CondParser_Comparison(CondParser *par, B void *rhsFree; Boolean lhsQuoted; Boolean rhsQuoted; -double left, right; t = TOK_ERROR; rhs = NULL; @@ -586,9 +649,12 @@ CondParser_Comparison(CondParser *par, B goto done; } /* For .ifxxx compare against zero */ - if (TryParseNumber(lhs, )) { - t = left != 0.0; - goto done; + { + double left; + if (TryParseNumber(lhs, )) { + t = left != 0.0; + goto done; + } } /* For .if ${...} check for non-empty string (defProc is ifdef). */ if (par->if_info->form[0] == '\0') { @@ -617,73 +683,7 @@ CondParser_Comparison(CondParser *par, B goto done; } -if (rhsQuoted || lhsQuoted) { -do_string_compare: - if (((*op != '!') && (*op != '=')) || (op[1] != '=')) { - Parse_Error(PARSE_WARNING, - "String comparison operator should be either == or !="); - goto done; - } - - if (DEBUG(COND)) { - fprintf(debug_file, "lhs = \"%s\", rhs = \"%s\", op = %.2s\n", - lhs, rhs, op); - } - /* - * Null-terminate rhs and perform the comparison. - * t is set to the result. - */ - if (*op == '=') { - t = strcmp(lhs, rhs) == 0; - } else { - t = strcmp(lhs, rhs) != 0; - } -} else { - /* - * rhs is either a float or an integer. Convert both the - * lhs and the rhs to a double and compare the two. - */ - - if (!TryParseNumber(lhs, ) || !TryParseNumber(rhs, )) - goto do_string_compare; - - if (DEBUG(COND)) { - fprintf(debug_file, "left = %f, right = %f, op = %.2s\n", left, - right, op); - } - switch (op[0]) { - case '!': - if (op[1] != '=') { - Parse_Error(PARSE_WARNING, - "Unknown operator"); - goto done; - } - t = (left != right); - break; - case '=': - if (op[1] != '=') { - Parse_Error(PARSE_WARNING, - "Unknown operator"); - goto done; - } - t = (left == right); - break; - case '<': - if (op[1] == '=') { - t = (left <= right); - } else { - t = (left < right); - } - break;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Sep 11 13:58:46 UTC 2020 Modified Files: src/usr.bin/make: cond.c Log Message: make(1): split CondParser_Comparison into 2 parts To generate a diff of this commit: cvs rdiff -u -r1.129 -r1.130 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.
CVS commit: src/etc/rc.d
Module Name:src Committed By: kim Date: Fri Sep 11 12:50:14 UTC 2020 Modified Files: src/etc/rc.d: motd Log Message: Make a ": " suffix a fixed part of the release info tag This results in correct updates to /etc/motd even when the value of motd_release_tag is changed (a likely event). Add safe quoting to outputting the read kernel version. Thanks to kre@ for the feedback. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/etc/rc.d/motd Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/etc/rc.d
Module Name:src Committed By: kim Date: Fri Sep 11 12:50:14 UTC 2020 Modified Files: src/etc/rc.d: motd Log Message: Make a ": " suffix a fixed part of the release info tag This results in correct updates to /etc/motd even when the value of motd_release_tag is changed (a likely event). Add safe quoting to outputting the read kernel version. Thanks to kre@ for the feedback. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/etc/rc.d/motd Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/etc/rc.d/motd diff -u src/etc/rc.d/motd:1.10 src/etc/rc.d/motd:1.11 --- src/etc/rc.d/motd:1.10 Fri Sep 11 09:59:35 2020 +++ src/etc/rc.d/motd Fri Sep 11 12:50:14 2020 @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: motd,v 1.10 2020/09/11 09:59:35 kim Exp $ +# $NetBSD: motd,v 1.11 2020/09/11 12:50:14 kim Exp $ # # PROVIDE: motd @@ -26,13 +26,13 @@ motd_start() fi ( umask 022 T=/etc/_motd - sysctl -n kern.version | while read i; do echo $i; break; done > $T + sysctl -n kern.version | while read i; do echo "$i"; break; done > $T if checkyesno update_motd_release; then - local t="${motd_release_tag}" - sed -En '1{/^NetBSD/{s/^/'"$t"'/;h;d;};q;} + local t=$(echo "${motd_release_tag%%:*}" | tr -d /) + sed -En '1{/^NetBSD/{'"${t:+s/^/${t}: /;}"'h;d;};q;} /^ *Build ID */{s//(/;s/$/)/;H;g;y/\n/ /;p;q;} ${g;p;}' < /etc/release >> $T - sed -E '1,2{/^'"${t+(${t})?}"'NetBSD/{d;};};' \ + sed -E '1,2{/^([^:]*: )?NetBSD/{d;};};' \ < /etc/motd >> $T else sed '1{/^NetBSD.*/{d;};};' < /etc/motd >> $T
CVS commit: src/share/man/man5
Module Name:src Committed By: wiz Date: Fri Sep 11 12:20:01 UTC 2020 Modified Files: src/share/man/man5: rc.conf.5 Log Message: New sentence, new line. To generate a diff of this commit: cvs rdiff -u -r1.186 -r1.187 src/share/man/man5/rc.conf.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/share/man/man5
Module Name:src Committed By: wiz Date: Fri Sep 11 12:20:01 UTC 2020 Modified Files: src/share/man/man5: rc.conf.5 Log Message: New sentence, new line. To generate a diff of this commit: cvs rdiff -u -r1.186 -r1.187 src/share/man/man5/rc.conf.5 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/man5/rc.conf.5 diff -u src/share/man/man5/rc.conf.5:1.186 src/share/man/man5/rc.conf.5:1.187 --- src/share/man/man5/rc.conf.5:1.186 Fri Sep 11 12:01:59 2020 +++ src/share/man/man5/rc.conf.5 Fri Sep 11 12:20:01 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: rc.conf.5,v 1.186 2020/09/11 12:01:59 kim Exp $ +.\" $NetBSD: rc.conf.5,v 1.187 2020/09/11 12:20:01 wiz Exp $ .\" .\" Copyright (c) 1996 Matthew R. Green .\" All rights reserved. @@ -616,8 +616,8 @@ updates a second version string in the .Pa /etc/motd file to reflect the version, architecture, and Build ID of -the installed userland. An optional prefix can be provided -for this version string in +the installed userland. +An optional prefix can be provided for this version string in .Sy motd_release_tag . .It Sy virecover Boolean value.
CVS commit: src/share/man/man5
Module Name:src Committed By: kim Date: Fri Sep 11 12:01:59 UTC 2020 Modified Files: src/share/man/man5: rc.conf.5 Log Message: Document update_motd_release and motd_release_tag To generate a diff of this commit: cvs rdiff -u -r1.185 -r1.186 src/share/man/man5/rc.conf.5 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/man5/rc.conf.5 diff -u src/share/man/man5/rc.conf.5:1.185 src/share/man/man5/rc.conf.5:1.186 --- src/share/man/man5/rc.conf.5:1.185 Wed Jul 15 17:55:34 2020 +++ src/share/man/man5/rc.conf.5 Fri Sep 11 12:01:59 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: rc.conf.5,v 1.185 2020/07/15 17:55:34 leot Exp $ +.\" $NetBSD: rc.conf.5,v 1.186 2020/09/11 12:01:59 kim Exp $ .\" .\" Copyright (c) 1996 Matthew R. Green .\" All rights reserved. @@ -55,7 +55,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd July 15, 2020 +.Dd September 11, 2020 .Dt RC.CONF 5 .Os .Sh NAME @@ -607,6 +607,18 @@ version string in the file to reflect the version of the running kernel. See .Xr motd 5 . +.It Sy update_motd_release +Boolean value. +If enabled in addition to +.Sy update_motd , +updates a second +.Nx +version string in the +.Pa /etc/motd +file to reflect the version, architecture, and Build ID of +the installed userland. An optional prefix can be provided +for this version string in +.Sy motd_release_tag . .It Sy virecover Boolean value. Send notification mail to users if any recoverable files exist in
CVS commit: src/share/man/man5
Module Name:src Committed By: kim Date: Fri Sep 11 12:01:59 UTC 2020 Modified Files: src/share/man/man5: rc.conf.5 Log Message: Document update_motd_release and motd_release_tag To generate a diff of this commit: cvs rdiff -u -r1.185 -r1.186 src/share/man/man5/rc.conf.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/etc
Module Name:src Committed By: kim Date: Fri Sep 11 09:59:36 UTC 2020 Modified Files: src/etc/defaults: rc.conf src/etc/rc.d: motd Log Message: Add optional release info in /etc/motd My personal preferencese for /etc/rc.conf: update_motd_release=YES motd_release_tag='Binaries: ' This provides an explanation to users about the second version in motd. To generate a diff of this commit: cvs rdiff -u -r1.158 -r1.159 src/etc/defaults/rc.conf cvs rdiff -u -r1.9 -r1.10 src/etc/rc.d/motd Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/etc
Module Name:src Committed By: kim Date: Fri Sep 11 09:59:36 UTC 2020 Modified Files: src/etc/defaults: rc.conf src/etc/rc.d: motd Log Message: Add optional release info in /etc/motd My personal preferencese for /etc/rc.conf: update_motd_release=YES motd_release_tag='Binaries: ' This provides an explanation to users about the second version in motd. To generate a diff of this commit: cvs rdiff -u -r1.158 -r1.159 src/etc/defaults/rc.conf cvs rdiff -u -r1.9 -r1.10 src/etc/rc.d/motd Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/etc/defaults/rc.conf diff -u src/etc/defaults/rc.conf:1.158 src/etc/defaults/rc.conf:1.159 --- src/etc/defaults/rc.conf:1.158 Mon Jun 15 01:57:30 2020 +++ src/etc/defaults/rc.conf Fri Sep 11 09:59:35 2020 @@ -1,4 +1,4 @@ -# $NetBSD: rc.conf,v 1.158 2020/06/15 01:57:30 christos Exp $ +# $NetBSD: rc.conf,v 1.159 2020/09/11 09:59:35 kim Exp $ # # /etc/defaults/rc.conf -- # default configuration of /etc/rc.conf @@ -133,6 +133,7 @@ per_user_tmp=NO # per-user /tmp dire per_user_tmp_dir="/private/tmp" # real storage for /tmp clear_tmp=YES # clear /tmp after reboot update_motd=YES # updates /etc/motd +update_motd_release=NO motd_release_tag="" # release info in /etc/motd dmesg=YES dmesg_flags="-t" # write /var/run/dmesg.boot accounting=NO # uses /var/account/acct newsyslog=NO newsyslog_flags="" # trim log files Index: src/etc/rc.d/motd diff -u src/etc/rc.d/motd:1.9 src/etc/rc.d/motd:1.10 --- src/etc/rc.d/motd:1.9 Fri Aug 13 18:08:03 2004 +++ src/etc/rc.d/motd Fri Sep 11 09:59:35 2020 @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: motd,v 1.9 2004/08/13 18:08:03 mycroft Exp $ +# $NetBSD: motd,v 1.10 2020/09/11 09:59:35 kim Exp $ # # PROVIDE: motd @@ -16,7 +16,7 @@ stop_cmd=":" motd_start() { - # Update kernel info in /etc/motd + # Update kernel and release info in /etc/motd # Must be done *before* interactive logins are possible # to prevent possible race conditions. # @@ -27,7 +27,16 @@ motd_start() ( umask 022 T=/etc/_motd sysctl -n kern.version | while read i; do echo $i; break; done > $T - sed '1{/^NetBSD.*/{d;};};' < /etc/motd >> $T + if checkyesno update_motd_release; then + local t="${motd_release_tag}" + sed -En '1{/^NetBSD/{s/^/'"$t"'/;h;d;};q;} + /^ *Build ID */{s//(/;s/$/)/;H;g;y/\n/ /;p;q;} + ${g;p;}' < /etc/release >> $T + sed -E '1,2{/^'"${t+(${t})?}"'NetBSD/{d;};};' \ + < /etc/motd >> $T + else + sed '1{/^NetBSD.*/{d;};};' < /etc/motd >> $T + fi cmp -s $T /etc/motd || cp $T /etc/motd rm -f $T )
CVS commit: src/sys/netinet
Module Name:src Committed By: kardel Date: Fri Sep 11 09:08:47 UTC 2020 Modified Files: src/sys/netinet: tcp_input.c Log Message: PR/kern 55567 fix the data-only fast path. RCV.UP and SND.WL1 could be left behind on long sequences of data only packets. pull them along to avoid relative sequence wraps. consistent with FreeBSD addresses second failure mode of PR/kern 55567. pullup to netbsd-8 pullup to netbsd-9 To generate a diff of this commit: cvs rdiff -u -r1.419 -r1.420 src/sys/netinet/tcp_input.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/netinet/tcp_input.c diff -u src/sys/netinet/tcp_input.c:1.419 src/sys/netinet/tcp_input.c:1.420 --- src/sys/netinet/tcp_input.c:1.419 Wed Sep 2 15:08:46 2020 +++ src/sys/netinet/tcp_input.c Fri Sep 11 09:08:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_input.c,v 1.419 2020/09/02 15:08:46 kardel Exp $ */ +/* $NetBSD: tcp_input.c,v 1.420 2020/09/11 09:08:47 kardel Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -148,7 +148,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.419 2020/09/02 15:08:46 kardel Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.420 2020/09/11 09:08:47 kardel Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1949,13 +1949,25 @@ after_listen: * we have enough buffer space to take it. */ tp->rcv_nxt += tlen; + + /* + * Pull rcv_up up to prevent seq wrap relative to + * rcv_nxt. + */ + tp->rcv_up = tp->rcv_nxt; + + /* + * Pull snd_wl1 up to prevent seq wrap relative to + * th_seq. + */ + tp->snd_wl1 = th->th_seq; + tcps = TCP_STAT_GETREF(); tcps[TCP_STAT_PREDDAT]++; tcps[TCP_STAT_RCVPACK]++; tcps[TCP_STAT_RCVBYTE] += tlen; TCP_STAT_PUTREF(); nd6_hint(tp); - /* * Automatic sizing enables the performance of large buffers * and most of the efficiency of small ones by only allocating
CVS commit: src/sys/netinet
Module Name:src Committed By: kardel Date: Fri Sep 11 09:08:47 UTC 2020 Modified Files: src/sys/netinet: tcp_input.c Log Message: PR/kern 55567 fix the data-only fast path. RCV.UP and SND.WL1 could be left behind on long sequences of data only packets. pull them along to avoid relative sequence wraps. consistent with FreeBSD addresses second failure mode of PR/kern 55567. pullup to netbsd-8 pullup to netbsd-9 To generate a diff of this commit: cvs rdiff -u -r1.419 -r1.420 src/sys/netinet/tcp_input.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/gpl3/gcc/dist/libsanitizer/lsan
Module Name:src Committed By: mrg Date: Fri Sep 11 09:01:41 UTC 2020 Modified Files: src/external/gpl3/gcc/dist/libsanitizer/lsan: lsan_common.cc Log Message: __mips64 does not mean 64 bit address space. also check _LP64. To generate a diff of this commit: cvs rdiff -u -r1.1.1.7 -r1.2 \ src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_common.cc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_common.cc diff -u src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_common.cc:1.1.1.7 src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_common.cc:1.2 --- src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_common.cc:1.1.1.7 Sat Sep 5 07:52:57 2020 +++ src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_common.cc Fri Sep 11 09:01:41 2020 @@ -135,7 +135,7 @@ static inline bool CanBeAHeapPointer(upt #if defined(__x86_64__) // Accept only canonical form user-space addresses. return ((p >> 47) == 0); -#elif defined(__mips64) +#elif defined(__mips64) && defined(_LP64) return ((p >> 40) == 0); #elif defined(__aarch64__) unsigned runtimeVMA =
CVS commit: src/external/gpl3/gcc/dist/libsanitizer/lsan
Module Name:src Committed By: mrg Date: Fri Sep 11 09:01:41 UTC 2020 Modified Files: src/external/gpl3/gcc/dist/libsanitizer/lsan: lsan_common.cc Log Message: __mips64 does not mean 64 bit address space. also check _LP64. To generate a diff of this commit: cvs rdiff -u -r1.1.1.7 -r1.2 \ src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_common.cc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Sep 11 07:09:40 UTC 2020 Modified Files: src/usr.bin/make: cond.c Log Message: make(1): document CondParser_Comparison To generate a diff of this commit: cvs rdiff -u -r1.128 -r1.129 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.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Sep 11 07:09:40 UTC 2020 Modified Files: src/usr.bin/make: cond.c Log Message: make(1): document CondParser_Comparison To generate a diff of this commit: cvs rdiff -u -r1.128 -r1.129 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.128 src/usr.bin/make/cond.c:1.129 --- src/usr.bin/make/cond.c:1.128 Fri Sep 11 06:47:42 2020 +++ src/usr.bin/make/cond.c Fri Sep 11 07:09:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.128 2020/09/11 06:47:42 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.129 2020/09/11 07:09:40 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.128 2020/09/11 06:47:42 rillig Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.129 2020/09/11 07:09:40 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.128 2020/09/11 06:47:42 rillig Exp $"); +__RCSID("$NetBSD: cond.c,v 1.129 2020/09/11 07:09:40 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -523,6 +523,13 @@ static const struct If { { NULL,0, FALSE, NULL } }; +/* Parse a comparison condition such as: + * + * 0 + * ${VAR:Mpattern} + * ${VAR} == value + * ${VAR:U0} < 12345 + */ static Token CondParser_Comparison(CondParser *par, Boolean doEval) {
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Fri Sep 11 06:51:39 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: cond-op-or.mk Log Message: make(1): fix comment in test for the || operator in conditions Thanks to wiz for discovering this. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond-op-or.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Fri Sep 11 06:51:39 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: cond-op-or.mk Log Message: make(1): fix comment in test for the || operator in conditions Thanks to wiz for discovering this. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond-op-or.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-op-or.mk diff -u src/usr.bin/make/unit-tests/cond-op-or.mk:1.4 src/usr.bin/make/unit-tests/cond-op-or.mk:1.5 --- src/usr.bin/make/unit-tests/cond-op-or.mk:1.4 Thu Sep 10 22:44:08 2020 +++ src/usr.bin/make/unit-tests/cond-op-or.mk Fri Sep 11 06:51:38 2020 @@ -1,4 +1,4 @@ -# $NetBSD: cond-op-or.mk,v 1.4 2020/09/10 22:44:08 rillig Exp $ +# $NetBSD: cond-op-or.mk,v 1.5 2020/09/11 06:51:38 rillig Exp $ # # Tests for the || operator in .if conditions. @@ -23,7 +23,7 @@ .if 1 || ${UNDEF} .endif -# The && operator may be abbreviated as &. This is not widely known though +# The || operator may be abbreviated as |. This is not widely known though # and is also not documented in the manual page. .if 0 | 0
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Sep 11 06:47:42 UTC 2020 Modified Files: src/usr.bin/make: cond.c src/usr.bin/make/unit-tests: cond-token-plain.exp cond-token-plain.mk Log Message: make(1): add tests for really strange edge cases in conditions To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/usr.bin/make/cond.c cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cond-token-plain.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-token-plain.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/cond.c diff -u src/usr.bin/make/cond.c:1.127 src/usr.bin/make/cond.c:1.128 --- src/usr.bin/make/cond.c:1.127 Fri Sep 11 06:08:10 2020 +++ src/usr.bin/make/cond.c Fri Sep 11 06:47:42 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.127 2020/09/11 06:08:10 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.128 2020/09/11 06:47:42 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.127 2020/09/11 06:08:10 rillig Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.128 2020/09/11 06:47:42 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.127 2020/09/11 06:08:10 rillig Exp $"); +__RCSID("$NetBSD: cond.c,v 1.128 2020/09/11 06:47:42 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -985,7 +985,12 @@ CondParser_Expr(CondParser *par, Boolean static CondEvalResult CondParser_Eval(CondParser *par, Boolean *value) { -Token res = CondParser_Expr(par, TRUE); +Token res; + +if (DEBUG(COND)) + fprintf(debug_file, "CondParser_Eval: %s\n", par->p); + +res = CondParser_Expr(par, TRUE); if (res != TOK_FALSE && res != TOK_TRUE) return COND_INVALID; @@ -996,9 +1001,9 @@ CondParser_Eval(CondParser *par, Boolean return COND_PARSE; } -/* Evaluate the condition in the passed line, including any side effects from - * the variable expressions in the condition. The condition consists of &&, - * ||, !, function(arg), comparisons and parenthetical groupings thereof. +/* Evaluate the condition, including any side effects from the variable + * expressions in the condition. The condition consists of &&, ||, !, + * function(arg), comparisons and parenthetical groupings thereof. * * Results: * COND_PARSE if the condition was valid grammatically @@ -1007,7 +1012,7 @@ CondParser_Eval(CondParser *par, Boolean * (*value) is set to the boolean value of the condition */ CondEvalResult -Cond_EvalExpression(const struct If *info, const char *line, Boolean *value, +Cond_EvalExpression(const struct If *info, const char *cond, Boolean *value, int eprint, Boolean strictLHS) { static const struct If *dflt_info; @@ -1016,8 +1021,8 @@ Cond_EvalExpression(const struct If *inf lhsStrict = strictLHS; -while (*line == ' ' || *line == '\t') - line++; +while (*cond == ' ' || *cond == '\t') + cond++; if (info == NULL && (info = dflt_info) == NULL) { /* Scan for the entry for .if - it can't be first */ @@ -1029,13 +1034,13 @@ Cond_EvalExpression(const struct If *inf assert(info != NULL); par.if_info = info; -par.p = line; +par.p = cond; par.curr = TOK_NONE; rval = CondParser_Eval(, value); if (rval == COND_INVALID && eprint) - Parse_Error(PARSE_FATAL, "Malformed conditional (%s)", line); + Parse_Error(PARSE_FATAL, "Malformed conditional (%s)", cond); return rval; } Index: src/usr.bin/make/unit-tests/cond-token-plain.exp diff -u src/usr.bin/make/unit-tests/cond-token-plain.exp:1.1 src/usr.bin/make/unit-tests/cond-token-plain.exp:1.2 --- src/usr.bin/make/unit-tests/cond-token-plain.exp:1.1 Sun Aug 16 12:07:51 2020 +++ src/usr.bin/make/unit-tests/cond-token-plain.exp Fri Sep 11 06:47:42 2020 @@ -1 +1,18 @@ +CondParser_Eval: ${:Uvalue} != value +lhs = "value", rhs = "value", op = != +CondParser_Eval: ${:U} != " +lhs = "", rhs = "", op = != +CondParser_Eval: ${:U#hash} != "#hash" +lhs = "#hash", rhs = "#hash", op = != +CondParser_Eval: ${:U\\} != "\\ +lhs = "\", rhs = "\", op = != +CondParser_Eval: ${:U#hash} != #hash +lhs = "#hash", rhs = "#hash", op = != +CondParser_Eval: 0 # This is treated as a comment, but why? +CondParser_Eval: ${0 # comment :?yes:no} != no +CondParser_Eval: 0 # comment +lhs = "no", rhs = "no", op = != +CondParser_Eval: ${1 # comment :?yes:no} != yes +CondParser_Eval: 1 # comment +lhs = "yes", rhs = "yes", op = != exit status 0 Index: src/usr.bin/make/unit-tests/cond-token-plain.mk diff -u src/usr.bin/make/unit-tests/cond-token-plain.mk:1.2 src/usr.bin/make/unit-tests/cond-token-plain.mk:1.3 --- src/usr.bin/make/unit-tests/cond-token-plain.mk:1.2 Sun Aug 16 14:25:16 2020 +++
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Sep 11 06:47:42 UTC 2020 Modified Files: src/usr.bin/make: cond.c src/usr.bin/make/unit-tests: cond-token-plain.exp cond-token-plain.mk Log Message: make(1): add tests for really strange edge cases in conditions To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/usr.bin/make/cond.c cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cond-token-plain.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-token-plain.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/arm32
Module Name:src Committed By: skrll Date: Fri Sep 11 06:40:26 UTC 2020 Modified Files: src/sys/arch/arm/arm32: arm32_boot.c Log Message: Wrap a long comment To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/arch/arm/arm32/arm32_boot.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/arch/arm/arm32/arm32_boot.c diff -u src/sys/arch/arm/arm32/arm32_boot.c:1.39 src/sys/arch/arm/arm32/arm32_boot.c:1.40 --- src/sys/arch/arm/arm32/arm32_boot.c:1.39 Fri Jul 10 12:25:09 2020 +++ src/sys/arch/arm/arm32/arm32_boot.c Fri Sep 11 06:40:25 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: arm32_boot.c,v 1.39 2020/07/10 12:25:09 skrll Exp $ */ +/* $NetBSD: arm32_boot.c,v 1.40 2020/09/11 06:40:25 skrll Exp $ */ /* * Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved. @@ -122,7 +122,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: arm32_boot.c,v 1.39 2020/07/10 12:25:09 skrll Exp $"); +__KERNEL_RCSID(1, "$NetBSD: arm32_boot.c,v 1.40 2020/09/11 06:40:25 skrll Exp $"); #include "opt_arm_debug.h" #include "opt_cputypes.h" @@ -293,7 +293,10 @@ initarm_common(vaddr_t kvm_base, vsize_t } } - /* Boot strap pmap telling it where the managed kernel virtual memory is */ + /* + * Bootstrap pmap telling it where the managed kernel virtual memory + * is. + */ VPRINTF("pmap "); pmap_bootstrap(kvm_base, kvm_base + kvm_size);
CVS commit: src/sys/arch/arm/arm32
Module Name:src Committed By: skrll Date: Fri Sep 11 06:40:26 UTC 2020 Modified Files: src/sys/arch/arm/arm32: arm32_boot.c Log Message: Wrap a long comment To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/arch/arm/arm32/arm32_boot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Sep 11 06:08:10 UTC 2020 Modified Files: src/usr.bin/make: cond.c Log Message: make(1): reorder parameters of condition parsing functions First the subject, then the options, then the output parameters. To generate a diff of this commit: cvs rdiff -u -r1.126 -r1.127 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.126 src/usr.bin/make/cond.c:1.127 --- src/usr.bin/make/cond.c:1.126 Fri Sep 11 05:03:20 2020 +++ src/usr.bin/make/cond.c Fri Sep 11 06:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.126 2020/09/11 05:03:20 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.127 2020/09/11 06:08:10 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.126 2020/09/11 05:03:20 rillig Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.127 2020/09/11 06:08:10 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.126 2020/09/11 05:03:20 rillig Exp $"); +__RCSID("$NetBSD: cond.c,v 1.127 2020/09/11 06:08:10 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -198,8 +198,8 @@ CondParser_SkipWhitespace(CondParser *pa /* Parse the argument of a built-in function. * * Arguments: - * *linePtr initially points to the '(', upon successful return points - * beyond the ')'. + * *linePtr initially points at the '(', upon successful return points + * right after the ')'. * * *out_arg receives the argument as string. * @@ -208,8 +208,8 @@ CondParser_SkipWhitespace(CondParser *pa * * Return the length of the argument. */ static int -ParseFuncArg(Boolean doEval, const char **linePtr, char **out_arg, - const char *func) { +ParseFuncArg(const char **linePtr, Boolean doEval, const char *func, + char **out_arg) { const char *cp; Buffer buf; int paren_depth; @@ -685,8 +685,8 @@ done: } static int -ParseEmptyArg(Boolean doEval, const char **linePtr, char **argPtr, - const char *func MAKE_ATTR_UNUSED) +ParseEmptyArg(const char **linePtr, Boolean doEval, + const char *func MAKE_ATTR_UNUSED, char **argPtr) { void *val_freeIt; const char *val; @@ -730,8 +730,8 @@ CondParser_Func(CondParser *par, Boolean static const struct fn_def { const char *fn_name; size_t fn_name_len; - int (*fn_getarg)(Boolean, const char **, char **, const char *); - Boolean (*fn_proc)(int, const char *); + int (*fn_parse)(const char **, Boolean, const char *, char **); + Boolean (*fn_eval)(int, const char *); } fn_defs[] = { { "defined", 7, ParseFuncArg, FuncDefined }, { "make", 4, ParseFuncArg, FuncMake }, @@ -758,13 +758,13 @@ CondParser_Func(CondParser *par, Boolean if (*cp != '(') break; - arglen = fn_def->fn_getarg(doEval, , , fn_def->fn_name); + arglen = fn_def->fn_parse(, doEval, fn_def->fn_name, ); if (arglen <= 0) { par->p = cp; return arglen < 0 ? TOK_ERROR : TOK_FALSE; } /* Evaluate the argument using the required function. */ - t = !doEval || fn_def->fn_proc(arglen, arg); + t = !doEval || fn_def->fn_eval(arglen, arg); free(arg); par->p = cp; return t; @@ -783,7 +783,7 @@ CondParser_Func(CondParser *par, Boolean * would be invalid if we did "defined(a)" - so instead treat as an * expression. */ -arglen = ParseFuncArg(doEval, , , NULL); +arglen = ParseFuncArg(, doEval, NULL, ); for (cp1 = cp; isspace((unsigned char)*cp1); cp1++) continue; if (*cp1 == '=' || *cp1 == '!')
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Sep 11 06:08:10 UTC 2020 Modified Files: src/usr.bin/make: cond.c Log Message: make(1): reorder parameters of condition parsing functions First the subject, then the options, then the output parameters. To generate a diff of this commit: cvs rdiff -u -r1.126 -r1.127 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.