Re: [patch(es)] fix a few typos in /src

2022-12-22 Thread Crystal Kolipe
I've only read through 50% of this so far, but there are a few issues:

On Thu, Dec 22, 2022 at 06:31:23PM -0500, Paul Tagliamonte wrote:

> Index: lib/libcurses/base/resizeterm.c
> ===
> RCS file: /cvs/src/lib/libcurses/base/resizeterm.c,v
> retrieving revision 1.4
> diff -u -p -r1.4 resizeterm.c
> --- lib/libcurses/base/resizeterm.c   10 Mar 2021 20:16:08 -  1.4
> +++ lib/libcurses/base/resizeterm.c   22 Dec 2022 21:14:13 -
> @@ -48,7 +48,7 @@ MODULE_ID("$Id: resizeterm.c,v 1.4 2021/
>  #define stolen_lines (screen_lines - SP->_lines_avail)
>  
>  /*
> - * If we're trying to be reentrant, do not want any local statics.
> + * If we're trying to be reentrant, do not want any local statistics.
>   */
>  #if USE_REENTRANT
>  #define EXTRA_ARGS , CurLines, CurCols

This is an incorrect change, and actually introduces a new error.

'Statics' here is entirely correct.

> Index: lib/libcrypto/objects/obj_dat.c
> ===
> RCS file: /cvs/src/lib/libcrypto/objects/obj_dat.c,v
> retrieving revision 1.50
> diff -u -p -r1.50 obj_dat.c
> --- lib/libcrypto/objects/obj_dat.c   26 Nov 2022 16:08:53 -  1.50
> +++ lib/libcrypto/objects/obj_dat.c   22 Dec 2022 21:14:12 -
> @@ -251,7 +251,7 @@ static IMPLEMENT_LHASH_DOALL_FN(cleanup2
>  static IMPLEMENT_LHASH_DOALL_FN(cleanup3, ADDED_OBJ)
>  
>  /* The purpose of obj_cleanup_defer is to avoid EVP_cleanup() attempting
> - * to use freed up OIDs. If neccessary the actual freeing up of OIDs is
> + * to use freed up OIDs. If necessary the actual freeing up of OIDs is
>   * delayed.
>   */
>  
> @@ -320,7 +320,7 @@ OBJ_add_object(const ASN1_OBJECT *obj)
>   ao[i]->type = i;
>   ao[i]->obj = o;
>   aop = lh_ADDED_OBJ_insert(added, ao[i]);
> - /* memory leak, buit should not normally matter */
> + /* memory leak, built should not normally matter */
>   free(aop);
>   }
>   }

This is wrong.  You are changing 'buit' to 'built', but the correct word
would be 'but'.

> Index: include/rpc/rpc_des.h
> ===
> RCS file: /cvs/src/include/rpc/rpc_des.h,v
> retrieving revision 1.4
> diff -u -p -r1.4 rpc_des.h
> --- include/rpc/rpc_des.h 1 Sep 2010 14:43:34 -   1.4
> +++ include/rpc/rpc_des.h 22 Dec 2022 21:14:06 -
> @@ -9,7 +9,7 @@
>   * The implementation was written so as to conform with Netscapes SSL.
>   * 
>   * This library is free for commercial and non-commercial use as long as
> - * the following conditions are aheared to.  The following conditions
> + * the following conditions are adhered to.  The following conditions
>   * apply to all code found in this distribution, be it the RC4, RSA,
>   * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
>   * included with this distribution is covered by the same copyright terms
> @@ -34,7 +34,7 @@
>   *must display the following acknowledgement:
>   *"This product includes cryptographic software written by
>   * Eric Young (e...@mincom.oz.au)"
> - *The word 'cryptographic' can be left out if the rouines from the 
> library
> + *The word 'cryptographic' can be left out if the routines from the 
> library
>   *being used are not cryptographic related :-).
>   * 4. If you include any Windows specific code (or a derivative thereof) 
> from 
>   *the apps directory (application code) you must include an 
> acknowledgement:
> @@ -52,7 +52,7 @@
>   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>   * SUCH DAMAGE.
>   * 
> - * The licence and distribution terms for any publically available version or
> + * The licence and distribution terms for any publicly available version or
>   * derivative of this code cannot be changed.  i.e. this code cannot simply 
> be
>   * copied and put under another distribution licence
>   * [including the GNU Public Licence.]

You shouldn't change license texts, even for spelling correction, as you
are changing the license itself.

> Index: lib/libcrypto/arch/aarch64/opensslconf.h
> ===
> RCS file: /cvs/src/lib/libcrypto/arch/aarch64/opensslconf.h,v
> retrieving revision 1.1
> diff -u -p -r1.1 opensslconf.h
> --- lib/libcrypto/arch/aarch64/opensslconf.h  11 Jan 2017 18:11:01 -  
> 1.1
> +++ lib/libcrypto/arch/aarch64/opensslconf.h  22 Dec 2022 21:14:10 -
> @@ -60,7 +60,7 @@
>  /* Only one for the following should be defined */
>  /* The prime number generation stuff may not work when
>   * EIGHT_BIT but I don't care since I've only used this mode
> - * for debuging the bignum libraries */
> + * for debugging the bignum libraries */
>  #define SIXTY_FOUR_BIT_LONG
>  #undef SIXTY_FOUR_BIT
>  #undef 

sparc64: pull retry logic out of tickcmpr_set(), sys_tickcmr_set()

2022-12-22 Thread Scott Cheloha
To keep the %TICK and %SYS_TICK code aligned with the Hummingbird
%STICK code, let's pull the retry logic out of tickcmpr_set() and
sys_tickcmpr_set() into tick_rearm() and sys_tick_rearm(),
respectively.

As far as I know, the retry logic in these assembly routines is not
defective, but keeping equivalent code similar is good and it doesn't
hurt to have less assembly code where it isn't strictly necessary.

With this complete, we can then rebase and retry the clockintr switch
patch for sparc64.

ok?

Index: clock.c
===
RCS file: /cvs/src/sys/arch/sparc64/sparc64/clock.c,v
retrieving revision 1.73
diff -u -p -r1.73 clock.c
--- clock.c 22 Dec 2022 19:51:11 -  1.73
+++ clock.c 22 Dec 2022 23:04:49 -
@@ -150,6 +150,8 @@ voidtick_start(void);
 void   sys_tick_start(void);
 void   stick_start(void);
 
+void   tick_rearm(uint64_t);
+void   sys_tick_rearm(uint64_t);
 void   stick_rearm(uint64_t);
 
 inttickintr(void *);
@@ -766,7 +768,7 @@ tickintr(void *cap)
 
/* Reset the interrupt. */
s = intr_disable();
-   tickcmpr_set(ci->ci_tick);
+   tick_rearm(ci->ci_tick);
intr_restore(s);
 
return (1);
@@ -789,7 +791,7 @@ sys_tickintr(void *cap)
 
/* Reset the interrupt. */
s = intr_disable();
-   sys_tickcmpr_set(ci->ci_tick);
+   sys_tick_rearm(ci->ci_tick);
intr_restore(s);
 
return (1);
@@ -875,18 +877,28 @@ tick_start(void)
 
tick_enable();
 
-   /*
-* Try to make the tick interrupts as synchronously as possible on
-* all CPUs to avoid inaccuracies for migrating processes.
-*/
-
s = intr_disable();
-   ci->ci_tick = roundup(tick(), tick_increment);
-   tickcmpr_set(ci->ci_tick);
+   ci->ci_tick = tick();
+   tick_rearm(ci->ci_tick);
intr_restore(s);
 }
 
 void
+tick_rearm(uint64_t cmp)
+{
+   uint64_t now, off = 8;
+
+   tickcmpr_set(cmp);
+   now = tick();
+   while (cmp <= now) {
+   cmp += off;
+   tickcmpr_set(cmp);
+   now = tick();
+   off *= 2;
+   }
+}
+
+void
 sys_tick_start(void)
 {
struct cpu_info *ci = curcpu();
@@ -897,29 +909,34 @@ sys_tick_start(void)
sys_tick_enable();
}
 
-   /*
-* Try to make the tick interrupts as synchronously as possible on
-* all CPUs to avoid inaccuracies for migrating processes.
-*/
-
s = intr_disable();
-   ci->ci_tick = roundup(sys_tick(), tick_increment);
-   sys_tickcmpr_set(ci->ci_tick);
+   ci->ci_tick = sys_tick();
+   sys_tick_rearm(ci->ci_tick);
intr_restore(s);
 }
 
 void
+sys_tick_rearm(uint64_t cmp)
+{
+   uint64_t now, off = 8;
+
+   sys_tickcmpr_set(cmp);
+   now = sys_tick();
+   while (cmp <= now) {
+   cmp += off;
+   sys_tickcmpr_set(cmp);
+   now = sys_tick();
+   off *= 2;
+   }
+}
+
+void
 stick_start(void)
 {
struct cpu_info *ci = curcpu();
u_int64_t s;
 
tick_enable();
-
-   /*
-* Try to make the tick interrupts as synchronously as possible on
-* all CPUs to avoid inaccuracies for migrating processes.
-*/
 
s = intr_disable();
ci->ci_tick = stick();
Index: locore.s
===
RCS file: /cvs/src/sys/arch/sparc64/sparc64/locore.s,v
retrieving revision 1.195
diff -u -p -r1.195 locore.s
--- locore.s22 Dec 2022 19:51:11 -  1.195
+++ locore.s22 Dec 2022 23:04:51 -
@@ -7477,22 +7477,9 @@ END(tick_enable)
  * sure those two instructions are in the same cache line.
  */
 ENTRY(tickcmpr_set)
-   ba  1f
-mov8, %o2  ! Initial step size
.align  64
-1: wr  %o0, 0, %tick_cmpr
+   wr  %o0, 0, %tick_cmpr
rd  %tick_cmpr, %g0
-
-   rd  %tick, %o1  ! Read current %tick
-   sllx%o1, 1, %o1
-   srlx%o1, 1, %o1
-
-   cmp %o0, %o1! Make sure the value we wrote to
-   bg,pt   %xcc, 2f!   %tick_cmpr was in the future.
-add%o0, %o2, %o0   ! If not, add the step size, double
-   ba,pt   %xcc, 1b!   the step size and try again.
-sllx   %o2, 1, %o2
-2:
retl
 nop
 END(tickcmpr_set)
@@ -7518,22 +7505,9 @@ ENTRY(sys_tick_enable)
 END(sys_tick_enable)
 
 ENTRY(sys_tickcmpr_set)
-   ba  1f
-mov8, %o2  ! Initial step size
.align  64
-1: wr  %o0, 0, %sys_tick_cmpr
+   wr  %o0, 0, %sys_tick_cmpr
rd  %sys_tick_cmpr, %g0
-
-   rd  %sys_tick, %o1  ! Read current %sys_tick
-   sllx%o1, 1, %o1
-   srlx%o1, 1, %o1
-
-   cmp %o0, %o1! Make sure the 

Re: [patch] add show.c style flag descriptions to route(8)

2022-12-22 Thread Philip Guenther
On Thu, Dec 22, 2022 at 12:04 PM Jason McIntyre  wrote:

> On Thu, Dec 22, 2022 at 11:49:09AM -0800, Philip Guenther wrote:
> > On Thu, Dec 22, 2022 at 11:33 AM Jason McIntyre 
> wrote:
> > ...
> >
> > > i have to say, i'm getting nowhere with this SYNOPSIS:
> > >
> > >  netstat -r [-AFu] [-f address_family] [-M core] [-N system]
> > >  [-p protocol] [-T rtable]
> > >
> > > i mean the combination of -r and -p. is it wholly redundant?
> > >
> >
> > Yeah, looking now I think -p is ignored when -r is supplied.  I guess I
> > missed that when we worked out rev 1.88 of netstat.1
> >
> > Philip
>
> so i'd rather deal with that separately. diff below to remove -p
> from the -r line.
>
> ok?
>
> jmc
>
> Index: main.c
> ===
> RCS file: /cvs/src/usr.bin/netstat/main.c,v
> retrieving revision 1.123
> diff -u -p -r1.123 main.c
> --- main.c  4 Dec 2022 23:50:48 -   1.123
> +++ main.c  22 Dec 2022 20:01:56 -
> @@ -485,8 +485,7 @@ usage(void)
> "   netstat -s [-gru] [-f address_family] [-p protocol]\n"
> "   netstat -g [-lnu] [-f address_family]\n"
> "   netstat -R\n"
> -   "   netstat -r [-AFu] [-f address_family] [-M core] [-N
> system] [-p protocol]\n"
> -   "   [-T rtable]\n"
> +   "   netstat -r [-AFu] [-f address_family] [-M core] [-N
> system] [-T rtable]\n"
> "   netstat -P pcbaddr [-v] [-M core] [-N system]\n");
> exit(1);
>  }
> Index: netstat.1
> ===
> RCS file: /cvs/src/usr.bin/netstat/netstat.1,v
> retrieving revision 1.96
> diff -u -p -r1.96 netstat.1
> --- netstat.1   22 Dec 2022 07:23:29 -  1.96
> +++ netstat.1   22 Dec 2022 20:01:56 -
> @@ -72,7 +72,6 @@
>  .Op Fl f Ar address_family
>  .Op Fl M Ar core
>  .Op Fl N Ar system
> -.Op Fl p Ar protocol
>  .Op Fl T Ar rtable
>  .Nm
>  .Fl P Ar pcbaddr
>

ok guenther@


Re: [patch] add show.c style flag descriptions to route(8)

2022-12-22 Thread Claudio Jeker
On Thu, Dec 22, 2022 at 08:02:54PM +, Jason McIntyre wrote:
> On Thu, Dec 22, 2022 at 11:49:09AM -0800, Philip Guenther wrote:
> > On Thu, Dec 22, 2022 at 11:33 AM Jason McIntyre  wrote:
> > ...
> > 
> > > i have to say, i'm getting nowhere with this SYNOPSIS:
> > >
> > >  netstat -r [-AFu] [-f address_family] [-M core] [-N system]
> > >  [-p protocol] [-T rtable]
> > >
> > > i mean the combination of -r and -p. is it wholly redundant?
> > >
> > 
> > Yeah, looking now I think -p is ignored when -r is supplied.  I guess I
> > missed that when we worked out rev 1.88 of netstat.1
> > 
> > Philip
> 
> so i'd rather deal with that separately. diff below to remove -p
> from the -r line.
> 
> ok?

OK claudio@
 
> jmc
> 
> Index: main.c
> ===
> RCS file: /cvs/src/usr.bin/netstat/main.c,v
> retrieving revision 1.123
> diff -u -p -r1.123 main.c
> --- main.c4 Dec 2022 23:50:48 -   1.123
> +++ main.c22 Dec 2022 20:01:56 -
> @@ -485,8 +485,7 @@ usage(void)
>   "   netstat -s [-gru] [-f address_family] [-p protocol]\n"
>   "   netstat -g [-lnu] [-f address_family]\n"
>   "   netstat -R\n"
> - "   netstat -r [-AFu] [-f address_family] [-M core] [-N system] 
> [-p protocol]\n"
> - "   [-T rtable]\n"
> + "   netstat -r [-AFu] [-f address_family] [-M core] [-N system] 
> [-T rtable]\n"
>   "   netstat -P pcbaddr [-v] [-M core] [-N system]\n");
>   exit(1);
>  }
> Index: netstat.1
> ===
> RCS file: /cvs/src/usr.bin/netstat/netstat.1,v
> retrieving revision 1.96
> diff -u -p -r1.96 netstat.1
> --- netstat.1 22 Dec 2022 07:23:29 -  1.96
> +++ netstat.1 22 Dec 2022 20:01:56 -
> @@ -72,7 +72,6 @@
>  .Op Fl f Ar address_family
>  .Op Fl M Ar core
>  .Op Fl N Ar system
> -.Op Fl p Ar protocol
>  .Op Fl T Ar rtable
>  .Nm
>  .Fl P Ar pcbaddr
> 

-- 
:wq Claudio



Re: [patch] add show.c style flag descriptions to route(8)

2022-12-22 Thread Claudio Jeker
On Thu, Dec 22, 2022 at 05:58:47PM +, Jason McIntyre wrote:
> On Thu, Dec 22, 2022 at 06:21:08PM +0100, Claudio Jeker wrote:
> > On Thu, Dec 22, 2022 at 05:08:15PM +, Jason McIntyre wrote:
> > > On Thu, Dec 22, 2022 at 07:32:18AM +, Jason McIntyre wrote:
> > > > 
> > > > next step is to examine Xr. will get round to that when i can.
> > > > 
> > > 
> > > so i looked at where we are using netstat. a lot of the references still
> > > make sense. diff below is for ones i think we can change. claudio kindly
> > > help me sift through some of the less clear ones (specifically where we
> > > have an Xr to netstat(1) in SEE ALSO but do not discuss it in any way
> > > within the manual).
> > > 
> > > here's the diff.
> > > 
> > 
> > A few comments below.
> > 
> > > Index: share/man/man4/ipcomp.4
> > > ===
> > > RCS file: /cvs/src/share/man/man4/ipcomp.4,v
> > > retrieving revision 1.16
> > > diff -u -p -r1.16 ipcomp.4
> > > --- share/man/man4/ipcomp.4   12 Jan 2018 04:36:44 -  1.16
> > > +++ share/man/man4/ipcomp.4   22 Dec 2022 17:04:39 -
> > > @@ -105,9 +105,9 @@ can be used to obtain some statistics ab
> > >  .Fl p
> > >  flag.
> > >  Just like for IPsec, using the
> > > -.Fl r
> > > -flag,
> > > -.Xr netstat 1
> > > +.Xr route 8
> > > +.Cm show
> > > +command
> > >  displays information about IPComp flows.
> > 
> > That's a lie. Neither netstat nor route show IPsec flows. This was moved
> > to ipsecctl(8). At least I was not able to display the flows with netstat
> > or route.
> > 
> 
> ah. so i tried ipcomp but thought it was maybe just not compiled in.
> 
> so what about the note above it:
> 
> DIAGNOSTICS
>netstat(1) can be used to obtain some statistics about
>IPComp usage, using the -p flag.
> 
> i can;t get netstat -p to do anything useful. should this whole text go,
> or just the -r text?

Oh, that is for netstat -sp ipcomp (or just netstat -s which dumps all the
various protocol counters). So maybe that DIAGNOSTICS bit could be
imporved to something like:
netstat(1) can be used to obtain some statistics about
IPComp usage, using the -s -p ipcomp arguments.

netstat -p without -s tries to print active connections so it does work
with tcp and udp but probably not much else.

-- 
:wq Claudio



Re: [patch] add show.c style flag descriptions to route(8)

2022-12-22 Thread Jason McIntyre
On Thu, Dec 22, 2022 at 07:31:26PM +, Jason McIntyre wrote:
> 
> anyway, how about this text for ipcomp/ipsec?
> jmc
> 

for completeness sake, here's the full diff.
jmc

Index: sbin/ifconfig/ifconfig.8
===
RCS file: /cvs/src/sbin/ifconfig/ifconfig.8,v
retrieving revision 1.387
diff -u -p -r1.387 ifconfig.8
--- sbin/ifconfig/ifconfig.826 Nov 2022 07:26:43 -  1.387
+++ sbin/ifconfig/ifconfig.822 Dec 2022 20:44:16 -
@@ -2329,11 +2329,11 @@ tried to alter an interface's configurat
 .Xr inet 4 ,
 .Xr intro 4 ,
 .Xr netintro 4 ,
-.Xr route 4 ,
 .Xr rtable 4 ,
 .Xr hostname.if 5 ,
 .Xr hosts 5 ,
 .Xr rc 8 ,
+.Xr route 8 ,
 .Xr slaacd 8 ,
 .Xr tcpdump 8
 .Sh HISTORY
Index: sbin/ping/ping.8
===
RCS file: /cvs/src/sbin/ping/ping.8,v
retrieving revision 1.65
diff -u -p -r1.65 ping.8
--- sbin/ping/ping.821 Feb 2021 17:18:01 -  1.65
+++ sbin/ping/ping.822 Dec 2022 20:44:16 -
@@ -418,8 +418,8 @@ Others may use completely wild values.
 exits 0 if at least one reply is received,
 and >0 if no reply is received or an error occurred.
 .Sh SEE ALSO
-.Xr netstat 1 ,
-.Xr ifconfig 8
+.Xr ifconfig 8 ,
+.Xr route 8
 .Sh HISTORY
 The
 .Nm
Index: share/man/man4/ipcomp.4
===
RCS file: /cvs/src/share/man/man4/ipcomp.4,v
retrieving revision 1.16
diff -u -p -r1.16 ipcomp.4
--- share/man/man4/ipcomp.4 12 Jan 2018 04:36:44 -  1.16
+++ share/man/man4/ipcomp.4 22 Dec 2022 20:44:16 -
@@ -101,14 +101,9 @@ compressed.
 .El
 .Sh DIAGNOSTICS
 .Xr netstat 1
-can be used to obtain some statistics about IPComp usage, using the
-.Fl p
-flag.
-Just like for IPsec, using the
-.Fl r
-flag,
-.Xr netstat 1
-displays information about IPComp flows.
+can be used to obtain some statistics about IPComp usage:
+.Pp
+.Dl $ netstat -s -p ipcomp
 .Sh SEE ALSO
 .Xr enc 4 ,
 .Xr inet 4 ,
Index: share/man/man4/ipsec.4
===
RCS file: /cvs/src/share/man/man4/ipsec.4,v
retrieving revision 1.88
diff -u -p -r1.88 ipsec.4
--- share/man/man4/ipsec.4  31 Mar 2022 17:27:21 -  1.88
+++ share/man/man4/ipsec.4  22 Dec 2022 20:44:16 -
@@ -356,14 +356,15 @@ was given.
 .El
 .Pp
 .Xr netstat 1
-can be used to obtain some statistics about AH and ESP usage, using the
-.Fl p
-flag.
-Using the
-.Fl r
-flag,
-.Xr netstat 1
-displays information about IPsec flows.
+can be used to obtain some statistics about AH or ESP usage:
+.Bd -literal -offset indent
+$ netstat -s -p ah
+$ netstat -s -p esp
+.Ed
+.Pp
+The
+.Xr ipsecctl 8
+command can be used to display information about IPsec flows.
 .Pp
 .Xr vmstat 8
 displays information about memory use by IPsec with the
Index: share/man/man8/afterboot.8
===
RCS file: /cvs/src/share/man/man8/afterboot.8,v
retrieving revision 1.171
diff -u -p -r1.171 afterboot.8
--- share/man/man8/afterboot.8  13 Apr 2022 18:00:34 -  1.171
+++ share/man/man8/afterboot.8  22 Dec 2022 20:44:16 -
@@ -183,9 +183,8 @@ See
 .Xr hostname.if 5
 for instructions on configuring interfaces with DHCP.
 .Pp
-Routing tables can be viewed by issuing a
-.Ic netstat -rn
-command.
+Routing tables can be viewed by issuing
+.Dq route -n show .
 The default gateway address is stored in the
 .Pa /etc/mygate
 file.
@@ -199,8 +198,10 @@ Or, you may prefer to manually configure
 .Ic route add
 and
 .Ic route delete
-commands (see
-.Xr route 8 ) .
+commands.
+See
+.Xr route 8
+for more information.
 .Pp
 If you wish to route packets between interfaces, add one or both
 of the following directives (depending on whether IPv4 or IPv6 routing
Index: usr.sbin/traceroute/traceroute.8
===
RCS file: /cvs/src/usr.sbin/traceroute/traceroute.8,v
retrieving revision 1.74
diff -u -p -r1.74 traceroute.8
--- usr.sbin/traceroute/traceroute.830 Jul 2022 07:19:31 -  1.74
+++ usr.sbin/traceroute/traceroute.822 Dec 2022 20:44:16 -
@@ -387,8 +387,8 @@ Because of the load it could impose on t
 .Nm
 during normal operations or from automated scripts.
 .Sh SEE ALSO
-.Xr netstat 1 ,
-.Xr ping 8
+.Xr ping 8 ,
+.Xr route 8
 .Sh HISTORY
 The very first
 .Nm



Re: [patch] add show.c style flag descriptions to route(8)

2022-12-22 Thread Jason McIntyre
On Thu, Dec 22, 2022 at 11:49:09AM -0800, Philip Guenther wrote:
> On Thu, Dec 22, 2022 at 11:33 AM Jason McIntyre  wrote:
> ...
> 
> > i have to say, i'm getting nowhere with this SYNOPSIS:
> >
> >  netstat -r [-AFu] [-f address_family] [-M core] [-N system]
> >  [-p protocol] [-T rtable]
> >
> > i mean the combination of -r and -p. is it wholly redundant?
> >
> 
> Yeah, looking now I think -p is ignored when -r is supplied.  I guess I
> missed that when we worked out rev 1.88 of netstat.1
> 
> Philip

so i'd rather deal with that separately. diff below to remove -p
from the -r line.

ok?

jmc

Index: main.c
===
RCS file: /cvs/src/usr.bin/netstat/main.c,v
retrieving revision 1.123
diff -u -p -r1.123 main.c
--- main.c  4 Dec 2022 23:50:48 -   1.123
+++ main.c  22 Dec 2022 20:01:56 -
@@ -485,8 +485,7 @@ usage(void)
"   netstat -s [-gru] [-f address_family] [-p protocol]\n"
"   netstat -g [-lnu] [-f address_family]\n"
"   netstat -R\n"
-   "   netstat -r [-AFu] [-f address_family] [-M core] [-N system] 
[-p protocol]\n"
-   "   [-T rtable]\n"
+   "   netstat -r [-AFu] [-f address_family] [-M core] [-N system] 
[-T rtable]\n"
"   netstat -P pcbaddr [-v] [-M core] [-N system]\n");
exit(1);
 }
Index: netstat.1
===
RCS file: /cvs/src/usr.bin/netstat/netstat.1,v
retrieving revision 1.96
diff -u -p -r1.96 netstat.1
--- netstat.1   22 Dec 2022 07:23:29 -  1.96
+++ netstat.1   22 Dec 2022 20:01:56 -
@@ -72,7 +72,6 @@
 .Op Fl f Ar address_family
 .Op Fl M Ar core
 .Op Fl N Ar system
-.Op Fl p Ar protocol
 .Op Fl T Ar rtable
 .Nm
 .Fl P Ar pcbaddr



Re: [patch] add show.c style flag descriptions to route(8)

2022-12-22 Thread Philip Guenther
On Thu, Dec 22, 2022 at 11:33 AM Jason McIntyre  wrote:
...

> i have to say, i'm getting nowhere with this SYNOPSIS:
>
>  netstat -r [-AFu] [-f address_family] [-M core] [-N system]
>  [-p protocol] [-T rtable]
>
> i mean the combination of -r and -p. is it wholly redundant?
>

Yeah, looking now I think -p is ignored when -r is supplied.  I guess I
missed that when we worked out rev 1.88 of netstat.1

Philip


Re: args vs arg ... in manuals

2022-12-22 Thread Klemens Nanni
12/21/22 11:58, Jason McIntyre пишет:
> On Wed, Dec 21, 2022 at 07:40:01AM +, Klemens Nanni wrote:
>> On Tue, Dec 20, 2022 at 08:24:29PM +, Jason McIntyre wrote:
>>> On Tue, Dec 20, 2022 at 06:24:45PM +, Klemens Nanni wrote:

 Feedback? OK?

>>>
>>> ok, in general i'm fine with this. i do have some concerns though:
>>
>> New diff with all points addressed, see inline for explanations.
>>
> 
> trimming this, but briefly: ok for your diff. i think this is fine. but
> still one nit:
> 
>> Index: usr.bin/csplit/csplit.1
>> ===
>> RCS file: /cvs/src/usr.bin/csplit/csplit.1,v
>> retrieving revision 1.12
>> diff -u -p -r1.12 csplit.1
>> --- usr.bin/csplit/csplit.1  24 Oct 2015 15:32:50 -  1.12
>> +++ usr.bin/csplit/csplit.1  21 Dec 2022 06:56:23 -
>> @@ -37,14 +37,15 @@
>>  .Op Fl ks
>>  .Op Fl f Ar prefix
>>  .Op Fl n Ar number
>> -.Ar file args ...
>> +.Ar file
>> +.Ar arg ...
>>  .Sh DESCRIPTION
>>  The
>>  .Nm
>>  utility splits
>>  .Ar file
>> -into pieces using the patterns
>> -.Ar args .
>> +into pieces using the pattern
>> +.Ar arg .
>>  If
>>  .Ar file
>>  is
>> @@ -92,7 +93,7 @@ created.
>>  .El
>>  .Pp
>>  The
>> -.Ar args
>> +.Ar arg
>>  operands may be a combination of the following patterns:
>>  .Bl -tag -width indent
>>  .It Xo
> 
> so, is "arg" an operand or operands? well, it depends how you are
> thinking of it. i would suggest we treat it as singular - it will read
> better, and i don;t think anyone will read this text and complain that
> it was misleading.

Right, I just went with the singular here, thanks.

> 
> jmc
> 



Re: [patch] add show.c style flag descriptions to route(8)

2022-12-22 Thread Jason McIntyre
On Thu, Dec 22, 2022 at 06:35:41PM +, Stuart Henderson wrote:
> On 2022/12/22 17:58, Jason McIntyre wrote:
> > > >  flag.
> > > >  Just like for IPsec, using the
> > > > -.Fl r
> > > > -flag,
> > > > -.Xr netstat 1
> > > > +.Xr route 8
> > > > +.Cm show
> > > > +command
> > > >  displays information about IPComp flows.
> > > 
> > > That's a lie. Neither netstat nor route show IPsec flows. This was moved
> > > to ipsecctl(8). At least I was not able to display the flows with netstat
> > > or route.
> > > 
> > 
> > ah. so i tried ipcomp but thought it was maybe just not compiled in.
> > 
> > so what about the note above it:
> > 
> > DIAGNOSTICS
> >  netstat(1) can be used to obtain some statistics about
> >  IPComp usage, using the -p flag.
> > 
> > i can;t get netstat -p to do anything useful. should this whole text go,
> > or just the -r text?
> 
> netstat -s -p ipcomp (or just netstat -s and look in the ipcomp section)
> displays statistics about ipcomp usage, but doesn't list ipcomp flows.
> unless you have actually configured ipcomp (probably most easily done
> via iked) you'll just see a bunch of zeroes though.
> 
> (similarly netstat -s shows some other stats for ipsec, though not flows)
> 

i have to say, i'm getting nowhere with this SYNOPSIS:

 netstat -r [-AFu] [-f address_family] [-M core] [-N system]
 [-p protocol] [-T rtable]

i mean the combination of -r and -p. is it wholly redundant?

anyway, how about this text for ipcomp/ipsec?
jmc

Index: ipcomp.4
===
RCS file: /cvs/src/share/man/man4/ipcomp.4,v
retrieving revision 1.16
diff -u -p -r1.16 ipcomp.4
--- ipcomp.412 Jan 2018 04:36:44 -  1.16
+++ ipcomp.422 Dec 2022 19:29:18 -
@@ -101,14 +101,9 @@ compressed.
 .El
 .Sh DIAGNOSTICS
 .Xr netstat 1
-can be used to obtain some statistics about IPComp usage, using the
-.Fl p
-flag.
-Just like for IPsec, using the
-.Fl r
-flag,
-.Xr netstat 1
-displays information about IPComp flows.
+can be used to obtain some statistics about IPComp usage:
+.Pp
+.Dl $ netstat -s -p ipcomp
 .Sh SEE ALSO
 .Xr enc 4 ,
 .Xr inet 4 ,
Index: ipsec.4
===
RCS file: /cvs/src/share/man/man4/ipsec.4,v
retrieving revision 1.88
diff -u -p -r1.88 ipsec.4
--- ipsec.4 31 Mar 2022 17:27:21 -  1.88
+++ ipsec.4 22 Dec 2022 19:29:19 -
@@ -356,14 +356,15 @@ was given.
 .El
 .Pp
 .Xr netstat 1
-can be used to obtain some statistics about AH and ESP usage, using the
-.Fl p
-flag.
-Using the
-.Fl r
-flag,
-.Xr netstat 1
-displays information about IPsec flows.
+can be used to obtain some statistics about AH or ESP usage:
+.Bd -literal -offset indent
+$ netstat -s -p ah
+$ netstat -s -p esp
+.Ed
+.Pp
+The
+.Xr ipsecctl 8
+command can be used to display information about IPsec flows.
 .Pp
 .Xr vmstat 8
 displays information about memory use by IPsec with the



Re: [patch] add show.c style flag descriptions to route(8)

2022-12-22 Thread Stuart Henderson
On 2022/12/22 17:58, Jason McIntyre wrote:
> > >  flag.
> > >  Just like for IPsec, using the
> > > -.Fl r
> > > -flag,
> > > -.Xr netstat 1
> > > +.Xr route 8
> > > +.Cm show
> > > +command
> > >  displays information about IPComp flows.
> > 
> > That's a lie. Neither netstat nor route show IPsec flows. This was moved
> > to ipsecctl(8). At least I was not able to display the flows with netstat
> > or route.
> > 
> 
> ah. so i tried ipcomp but thought it was maybe just not compiled in.
> 
> so what about the note above it:
> 
> DIAGNOSTICS
>netstat(1) can be used to obtain some statistics about
>IPComp usage, using the -p flag.
> 
> i can;t get netstat -p to do anything useful. should this whole text go,
> or just the -r text?

netstat -s -p ipcomp (or just netstat -s and look in the ipcomp section)
displays statistics about ipcomp usage, but doesn't list ipcomp flows.
unless you have actually configured ipcomp (probably most easily done
via iked) you'll just see a bunch of zeroes though.

(similarly netstat -s shows some other stats for ipsec, though not flows)



Re: [patch] add show.c style flag descriptions to route(8)

2022-12-22 Thread Jason McIntyre
On Thu, Dec 22, 2022 at 06:21:08PM +0100, Claudio Jeker wrote:
> On Thu, Dec 22, 2022 at 05:08:15PM +, Jason McIntyre wrote:
> > On Thu, Dec 22, 2022 at 07:32:18AM +, Jason McIntyre wrote:
> > > 
> > > next step is to examine Xr. will get round to that when i can.
> > > 
> > 
> > so i looked at where we are using netstat. a lot of the references still
> > make sense. diff below is for ones i think we can change. claudio kindly
> > help me sift through some of the less clear ones (specifically where we
> > have an Xr to netstat(1) in SEE ALSO but do not discuss it in any way
> > within the manual).
> > 
> > here's the diff.
> > 
> 
> A few comments below.
> 
> > Index: share/man/man4/ipcomp.4
> > ===
> > RCS file: /cvs/src/share/man/man4/ipcomp.4,v
> > retrieving revision 1.16
> > diff -u -p -r1.16 ipcomp.4
> > --- share/man/man4/ipcomp.4 12 Jan 2018 04:36:44 -  1.16
> > +++ share/man/man4/ipcomp.4 22 Dec 2022 17:04:39 -
> > @@ -105,9 +105,9 @@ can be used to obtain some statistics ab
> >  .Fl p
> >  flag.
> >  Just like for IPsec, using the
> > -.Fl r
> > -flag,
> > -.Xr netstat 1
> > +.Xr route 8
> > +.Cm show
> > +command
> >  displays information about IPComp flows.
> 
> That's a lie. Neither netstat nor route show IPsec flows. This was moved
> to ipsecctl(8). At least I was not able to display the flows with netstat
> or route.
> 

ah. so i tried ipcomp but thought it was maybe just not compiled in.

so what about the note above it:

DIAGNOSTICS
 netstat(1) can be used to obtain some statistics about
 IPComp usage, using the -p flag.

i can;t get netstat -p to do anything useful. should this whole text go,
or just the -r text?

> >  .Sh SEE ALSO
> >  .Xr enc 4 ,
> > Index: share/man/man4/ipsec.4
> > ===
> > RCS file: /cvs/src/share/man/man4/ipsec.4,v
> > retrieving revision 1.88
> > diff -u -p -r1.88 ipsec.4
> > --- share/man/man4/ipsec.4  31 Mar 2022 17:27:21 -  1.88
> > +++ share/man/man4/ipsec.4  22 Dec 2022 17:04:39 -
> > @@ -360,10 +360,9 @@ can be used to obtain some statistics ab
> >  .Fl p
> >  flag.
> >  Using the
> > -.Fl r
> > -flag,
> > -.Xr netstat 1
> > -displays information about IPsec flows.
> > +.Xr route 8
> > +.Cm show
> > +command displays information about IPsec flows.
> 
> See above.
> 

ditto

> >  .Pp
> >  .Xr vmstat 8
> >  displays information about memory use by IPsec with the
> > Index: share/man/man8/afterboot.8
> > ===
> > RCS file: /cvs/src/share/man/man8/afterboot.8,v
> > retrieving revision 1.171
> > diff -u -p -r1.171 afterboot.8
> > --- share/man/man8/afterboot.8  13 Apr 2022 18:00:34 -  1.171
> > +++ share/man/man8/afterboot.8  22 Dec 2022 17:04:39 -
> > @@ -184,7 +184,8 @@ See
> >  for instructions on configuring interfaces with DHCP.
> >  .Pp
> >  Routing tables can be viewed by issuing a
> > -.Ic netstat -rn
> > +.Xr route 8
> > +.Cm show
> 
> Should we add -n here as well so people don't end up waiting for DNS
> lookups? I would love if someone made -n the default and add a -N flag
> instead. Reverse DNS lookups are just not helpful in routing table output.
> 

yep, good spot. i'll adjust this.

jmc



Re: [patch] add show.c style flag descriptions to route(8)

2022-12-22 Thread Claudio Jeker
On Thu, Dec 22, 2022 at 05:08:15PM +, Jason McIntyre wrote:
> On Thu, Dec 22, 2022 at 07:32:18AM +, Jason McIntyre wrote:
> > 
> > next step is to examine Xr. will get round to that when i can.
> > 
> 
> so i looked at where we are using netstat. a lot of the references still
> make sense. diff below is for ones i think we can change. claudio kindly
> help me sift through some of the less clear ones (specifically where we
> have an Xr to netstat(1) in SEE ALSO but do not discuss it in any way
> within the manual).
> 
> here's the diff.
> 

A few comments below.

> Index: sbin/ifconfig/ifconfig.8
> ===
> RCS file: /cvs/src/sbin/ifconfig/ifconfig.8,v
> retrieving revision 1.387
> diff -u -p -r1.387 ifconfig.8
> --- sbin/ifconfig/ifconfig.8  26 Nov 2022 07:26:43 -  1.387
> +++ sbin/ifconfig/ifconfig.8  22 Dec 2022 17:04:39 -
> @@ -2329,11 +2329,11 @@ tried to alter an interface's configurat
>  .Xr inet 4 ,
>  .Xr intro 4 ,
>  .Xr netintro 4 ,
> -.Xr route 4 ,
>  .Xr rtable 4 ,
>  .Xr hostname.if 5 ,
>  .Xr hosts 5 ,
>  .Xr rc 8 ,
> +.Xr route 8 ,
>  .Xr slaacd 8 ,
>  .Xr tcpdump 8
>  .Sh HISTORY
> Index: sbin/ping/ping.8
> ===
> RCS file: /cvs/src/sbin/ping/ping.8,v
> retrieving revision 1.65
> diff -u -p -r1.65 ping.8
> --- sbin/ping/ping.8  21 Feb 2021 17:18:01 -  1.65
> +++ sbin/ping/ping.8  22 Dec 2022 17:04:39 -
> @@ -418,8 +418,8 @@ Others may use completely wild values.
>  exits 0 if at least one reply is received,
>  and >0 if no reply is received or an error occurred.
>  .Sh SEE ALSO
> -.Xr netstat 1 ,
> -.Xr ifconfig 8
> +.Xr ifconfig 8 ,
> +.Xr route 8
>  .Sh HISTORY
>  The
>  .Nm
> Index: share/man/man4/ipcomp.4
> ===
> RCS file: /cvs/src/share/man/man4/ipcomp.4,v
> retrieving revision 1.16
> diff -u -p -r1.16 ipcomp.4
> --- share/man/man4/ipcomp.4   12 Jan 2018 04:36:44 -  1.16
> +++ share/man/man4/ipcomp.4   22 Dec 2022 17:04:39 -
> @@ -105,9 +105,9 @@ can be used to obtain some statistics ab
>  .Fl p
>  flag.
>  Just like for IPsec, using the
> -.Fl r
> -flag,
> -.Xr netstat 1
> +.Xr route 8
> +.Cm show
> +command
>  displays information about IPComp flows.

That's a lie. Neither netstat nor route show IPsec flows. This was moved
to ipsecctl(8). At least I was not able to display the flows with netstat
or route.

>  .Sh SEE ALSO
>  .Xr enc 4 ,
> Index: share/man/man4/ipsec.4
> ===
> RCS file: /cvs/src/share/man/man4/ipsec.4,v
> retrieving revision 1.88
> diff -u -p -r1.88 ipsec.4
> --- share/man/man4/ipsec.431 Mar 2022 17:27:21 -  1.88
> +++ share/man/man4/ipsec.422 Dec 2022 17:04:39 -
> @@ -360,10 +360,9 @@ can be used to obtain some statistics ab
>  .Fl p
>  flag.
>  Using the
> -.Fl r
> -flag,
> -.Xr netstat 1
> -displays information about IPsec flows.
> +.Xr route 8
> +.Cm show
> +command displays information about IPsec flows.

See above.

>  .Pp
>  .Xr vmstat 8
>  displays information about memory use by IPsec with the
> Index: share/man/man8/afterboot.8
> ===
> RCS file: /cvs/src/share/man/man8/afterboot.8,v
> retrieving revision 1.171
> diff -u -p -r1.171 afterboot.8
> --- share/man/man8/afterboot.813 Apr 2022 18:00:34 -  1.171
> +++ share/man/man8/afterboot.822 Dec 2022 17:04:39 -
> @@ -184,7 +184,8 @@ See
>  for instructions on configuring interfaces with DHCP.
>  .Pp
>  Routing tables can be viewed by issuing a
> -.Ic netstat -rn
> +.Xr route 8
> +.Cm show

Should we add -n here as well so people don't end up waiting for DNS
lookups? I would love if someone made -n the default and add a -N flag
instead. Reverse DNS lookups are just not helpful in routing table output.

>  command.
>  The default gateway address is stored in the
>  .Pa /etc/mygate
> @@ -199,8 +200,7 @@ Or, you may prefer to manually configure
>  .Ic route add
>  and
>  .Ic route delete
> -commands (see
> -.Xr route 8 ) .
> +commands.
>  .Pp
>  If you wish to route packets between interfaces, add one or both
>  of the following directives (depending on whether IPv4 or IPv6 routing
> Index: usr.sbin/traceroute/traceroute.8
> ===
> RCS file: /cvs/src/usr.sbin/traceroute/traceroute.8,v
> retrieving revision 1.74
> diff -u -p -r1.74 traceroute.8
> --- usr.sbin/traceroute/traceroute.8  30 Jul 2022 07:19:31 -  1.74
> +++ usr.sbin/traceroute/traceroute.8  22 Dec 2022 17:04:39 -
> @@ -387,8 +387,8 @@ Because of the load it could impose on t
>  .Nm
>  during normal operations or from automated scripts.
>  .Sh SEE ALSO
> -.Xr netstat 1 ,
> -.Xr ping 8
> +.Xr ping 8 ,
> +.Xr route 8
>  .Sh HISTORY
>  The very first
>  .Nm
> 

I like this (apart from 

Re: [patch] add show.c style flag descriptions to route(8)

2022-12-22 Thread Jason McIntyre
On Thu, Dec 22, 2022 at 07:32:18AM +, Jason McIntyre wrote:
> 
> next step is to examine Xr. will get round to that when i can.
> 

so i looked at where we are using netstat. a lot of the references still
make sense. diff below is for ones i think we can change. claudio kindly
help me sift through some of the less clear ones (specifically where we
have an Xr to netstat(1) in SEE ALSO but do not discuss it in any way
within the manual).

here's the diff.

jmc

Index: sbin/ifconfig/ifconfig.8
===
RCS file: /cvs/src/sbin/ifconfig/ifconfig.8,v
retrieving revision 1.387
diff -u -p -r1.387 ifconfig.8
--- sbin/ifconfig/ifconfig.826 Nov 2022 07:26:43 -  1.387
+++ sbin/ifconfig/ifconfig.822 Dec 2022 17:04:39 -
@@ -2329,11 +2329,11 @@ tried to alter an interface's configurat
 .Xr inet 4 ,
 .Xr intro 4 ,
 .Xr netintro 4 ,
-.Xr route 4 ,
 .Xr rtable 4 ,
 .Xr hostname.if 5 ,
 .Xr hosts 5 ,
 .Xr rc 8 ,
+.Xr route 8 ,
 .Xr slaacd 8 ,
 .Xr tcpdump 8
 .Sh HISTORY
Index: sbin/ping/ping.8
===
RCS file: /cvs/src/sbin/ping/ping.8,v
retrieving revision 1.65
diff -u -p -r1.65 ping.8
--- sbin/ping/ping.821 Feb 2021 17:18:01 -  1.65
+++ sbin/ping/ping.822 Dec 2022 17:04:39 -
@@ -418,8 +418,8 @@ Others may use completely wild values.
 exits 0 if at least one reply is received,
 and >0 if no reply is received or an error occurred.
 .Sh SEE ALSO
-.Xr netstat 1 ,
-.Xr ifconfig 8
+.Xr ifconfig 8 ,
+.Xr route 8
 .Sh HISTORY
 The
 .Nm
Index: share/man/man4/ipcomp.4
===
RCS file: /cvs/src/share/man/man4/ipcomp.4,v
retrieving revision 1.16
diff -u -p -r1.16 ipcomp.4
--- share/man/man4/ipcomp.4 12 Jan 2018 04:36:44 -  1.16
+++ share/man/man4/ipcomp.4 22 Dec 2022 17:04:39 -
@@ -105,9 +105,9 @@ can be used to obtain some statistics ab
 .Fl p
 flag.
 Just like for IPsec, using the
-.Fl r
-flag,
-.Xr netstat 1
+.Xr route 8
+.Cm show
+command
 displays information about IPComp flows.
 .Sh SEE ALSO
 .Xr enc 4 ,
Index: share/man/man4/ipsec.4
===
RCS file: /cvs/src/share/man/man4/ipsec.4,v
retrieving revision 1.88
diff -u -p -r1.88 ipsec.4
--- share/man/man4/ipsec.4  31 Mar 2022 17:27:21 -  1.88
+++ share/man/man4/ipsec.4  22 Dec 2022 17:04:39 -
@@ -360,10 +360,9 @@ can be used to obtain some statistics ab
 .Fl p
 flag.
 Using the
-.Fl r
-flag,
-.Xr netstat 1
-displays information about IPsec flows.
+.Xr route 8
+.Cm show
+command displays information about IPsec flows.
 .Pp
 .Xr vmstat 8
 displays information about memory use by IPsec with the
Index: share/man/man8/afterboot.8
===
RCS file: /cvs/src/share/man/man8/afterboot.8,v
retrieving revision 1.171
diff -u -p -r1.171 afterboot.8
--- share/man/man8/afterboot.8  13 Apr 2022 18:00:34 -  1.171
+++ share/man/man8/afterboot.8  22 Dec 2022 17:04:39 -
@@ -184,7 +184,8 @@ See
 for instructions on configuring interfaces with DHCP.
 .Pp
 Routing tables can be viewed by issuing a
-.Ic netstat -rn
+.Xr route 8
+.Cm show
 command.
 The default gateway address is stored in the
 .Pa /etc/mygate
@@ -199,8 +200,7 @@ Or, you may prefer to manually configure
 .Ic route add
 and
 .Ic route delete
-commands (see
-.Xr route 8 ) .
+commands.
 .Pp
 If you wish to route packets between interfaces, add one or both
 of the following directives (depending on whether IPv4 or IPv6 routing
Index: usr.sbin/traceroute/traceroute.8
===
RCS file: /cvs/src/usr.sbin/traceroute/traceroute.8,v
retrieving revision 1.74
diff -u -p -r1.74 traceroute.8
--- usr.sbin/traceroute/traceroute.830 Jul 2022 07:19:31 -  1.74
+++ usr.sbin/traceroute/traceroute.822 Dec 2022 17:04:39 -
@@ -387,8 +387,8 @@ Because of the load it could impose on t
 .Nm
 during normal operations or from automated scripts.
 .Sh SEE ALSO
-.Xr netstat 1 ,
-.Xr ping 8
+.Xr ping 8 ,
+.Xr route 8
 .Sh HISTORY
 The very first
 .Nm



Re: LLVM 15: mismatched bound errors

2022-12-22 Thread Todd C . Miller
On Thu, 22 Dec 2022 02:08:42 +0100, Jeremie Courreges-Anglas wrote:

>   https://github.com/jcourreges/openbsd-src/commit/4862df383ccb8a8e03d5c11b4f
> b739b6a3a5a7c7
>
> Sadly making the size available in the declaration doesn't seem to be
> clang any smarter (yet?).  clang won't warn about passing the address of
> array[10] to a function which access array[15] or so.
>
> I don't care much about the direction we end up using, but specifying
> the size in the declaration isn't insane.  We seldom pass a pointers to
> a buffer without an accompanying buffer length.

My objection to adding sizes to the prototype and function declaration
is that it encourages things like:

int foo(char buf[2048])
{
...
snprintf(buf, sizeof(buf), "See spot run, run spot run...");
}

But of course, sizeof(buf) is really sizeof(char *).  The compiler
will warn when you do this so perhaps it is not such a big problem.
It still feels like a footgun to me.

 - todd



Size reduction experiments for LLVM-built sparc64 kernel

2022-12-22 Thread Koakuma
Hello tech@,
I had a discussion about this earlier with kn@ and he suggested me
to post this here, so here it is...

If I'm understanding it correctly, one of the things preventing
sparc64 from fully switching to clang/LLVM is that the generated
binaries (particularly, for the kernel) are much larger than GCC-built
ones, so I tried to tinker with it to reduce the size of LLVM-built
kernels, and here's what I did and the results so far:

1. Improve branches on 64-bit integers in LLVM.
   This mainly gets rid of accidental emission of useless ba/nop pairs.
   Those branches are common and so the savings end up pretty big.
   The patch is already accepted upstream at https://llvm.org/D130006,
   but it'll only be released with LLVM 16 so I'm giving a version
   adapted for OpenBSD's LLVM 13 below.

2. I noticed that LLVM's inliner is very aggressive (much more than
   GCC's) and will happily inline large functions, which,
   in some cases, increased the sizes of functions by > 2x.
   Currently I'm experimenting with adding
   COPTS="-fno-inline-functions -finline-hint-functions" to the make
   command when building the kernel with LLVM to turn off inlining
   except for functions explicitly declared inline, and so far
   the build seems to finish and boot normally.
   This should give some size reduction while keeping most of
   the benefits of performance optimizations
   (as opposed to going all the way with, say, -Os/-Oz).
   This could also be applicable to other binaries and/or arches, but
   on the other hand, I am not sure if globally limiting inlining in
   this way is a good idea...

With those two changes, I was able to get the kernel binary to be
about 87 KiB larger than the GCC-built one:

textdatabss dec hex
9534528 2294133 725888  12554549bf9135  bsd.clang
9085212 2294068 727320  12106600b8bb68  bsd.clang+patch
8089416 2295436 728216  3068a9926c  bsd.clang+patch+noinline
7862920 2429596 730968  11023484a8347c  bsd.gcc

Any comments?

This is the adapted LLVM patch:

diff --git a/gnu/llvm/llvm/lib/Target/Sparc/SparcISelLowering.cpp 
b/gnu/llvm/llvm/lib/Target/Sparc/SparcISelLowering.cpp
index 747f1b568a7..07ce6094ecd 100644
--- a/gnu/llvm/llvm/lib/Target/Sparc/SparcISelLowering.cpp
+++ b/gnu/llvm/llvm/lib/Target/Sparc/SparcISelLowering.cpp
@@ -1832,7 +1832,10 @@ const char 
*SparcTargetLowering::getTargetNodeName(unsigned Opcode) const {
   case SPISD::CMPICC:  return "SPISD::CMPICC";
   case SPISD::CMPFCC:  return "SPISD::CMPFCC";
   case SPISD::BRICC:   return "SPISD::BRICC";
-  case SPISD::BRXCC:   return "SPISD::BRXCC";
+  case SPISD::BPICC:
+return "SPISD::BPICC";
+  case SPISD::BPXCC:
+return "SPISD::BPXCC";
   case SPISD::BRFCC:   return "SPISD::BRFCC";
   case SPISD::SELECT_ICC:  return "SPISD::SELECT_ICC";
   case SPISD::SELECT_XCC:  return "SPISD::SELECT_XCC";
@@ -2434,8 +2437,8 @@ static SDValue LowerUINT_TO_FP(SDValue Op, SelectionDAG 
,
 }
 
 static SDValue LowerBR_CC(SDValue Op, SelectionDAG ,
-  const SparcTargetLowering ,
-  bool hasHardQuad) {
+  const SparcTargetLowering , bool hasHardQuad,
+  bool isV9) {
   SDValue Chain = Op.getOperand(0);
   ISD::CondCode CC = cast(Op.getOperand(1))->get();
   SDValue LHS = Op.getOperand(2);
@@ -2453,13 +2456,17 @@ static SDValue LowerBR_CC(SDValue Op, SelectionDAG ,
   if (LHS.getValueType().isInteger()) {
 CompareFlag = DAG.getNode(SPISD::CMPICC, dl, MVT::Glue, LHS, RHS);
 if (SPCC == ~0U) SPCC = IntCondCCodeToICC(CC);
-// 32-bit compares use the icc flags, 64-bit uses the xcc flags.
-Opc = LHS.getValueType() == MVT::i32 ? SPISD::BRICC : SPISD::BRXCC;
+if (isV9)
+  // 32-bit compares use the icc flags, 64-bit uses the xcc flags.
+  Opc = LHS.getValueType() == MVT::i32 ? SPISD::BPICC : SPISD::BPXCC;
+else
+  // Non-v9 targets don't have xcc.
+  Opc = SPISD::BRICC;
   } else {
 if (!hasHardQuad && LHS.getValueType() == MVT::f128) {
   if (SPCC == ~0U) SPCC = FPCondCCodeToFCC(CC);
   CompareFlag = TLI.LowerF128Compare(LHS, RHS, SPCC, dl, DAG);
-  Opc = SPISD::BRICC;
+  Opc = isV9 ? SPISD::BPICC : SPISD::BRICC;
 } else {
   CompareFlag = DAG.getNode(SPISD::CMPFCC, dl, MVT::Glue, LHS, RHS);
   if (SPCC == ~0U) SPCC = FPCondCCodeToFCC(CC);
@@ -3035,8 +3042,8 @@ LowerOperation(SDValue Op, SelectionDAG ) const {
hasHardQuad);
   case ISD::UINT_TO_FP: return LowerUINT_TO_FP(Op, DAG, *this,
hasHardQuad);
-  case ISD::BR_CC:  return LowerBR_CC(Op, DAG, *this,
-  hasHardQuad);
+  case ISD::BR_CC:
+return LowerBR_CC(Op, DAG, *this, hasHardQuad, isV9);
   case ISD::SELECT_CC:  return 

[patch] allow cp to ignore file flags whilst using -p

2022-12-22 Thread Crystal Kolipe
The attached patch adds a new -q option to cp that allows ignoring file flags
whilst copying with the existing -p, (preserve), option.  Without -p, the new
-q option does nothing.

Rationale:

File flags are not widely used, but we use them on copies of local data that
is not expected to change, (and is archived elsewhere as immutable).

When copying data from such locations, it is often preferable to preserve the
original file ownership and timestamp, but currently using the -p option also
causes the file flags to be set on the new copy.

This is inconvenient if done by a regular user, as the uchg flag has to be
manually removed afterwards.  If done by root, the schg flag can only be
removed by booting into single-user mode.

The following patch avoids this inconvenience by allowing the user invoking cp
to skip copying of flags altogether whilst preserving the other file
attributes.

--- cp.1.dist   Mon Sep  2 18:18:41 2019
+++ cp.1Thu Dec 22 08:56:17 2022
@@ -128,6 +128,10 @@
 and either the user ID or group ID cannot be preserved, neither
 the set-user-ID nor set-group-ID bits are preserved in the copy's
 permissions.
+.It Fl q
+Modify the behaviour of the
+.Fl p
+option such that file flags are not preserved.
 .It Fl R
 If
 .Ar source
--- cp.c.dist   Fri Jun 28 10:34:58 2019
+++ cp.cThu Dec 22 08:47:01 2022
@@ -71,7 +71,7 @@
 PATH_T to = { to.p_path, "" };
 
 uid_t myuid;
-int Rflag, fflag, iflag, pflag, rflag, vflag;
+int Rflag, fflag, iflag, pflag, qflag, rflag, vflag;
 mode_t myumask;
 
 enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
@@ -88,7 +88,7 @@
char *target;
 
Hflag = Lflag = Pflag = Rflag = 0;
-   while ((ch = getopt(argc, argv, "HLPRafiprv")) != -1)
+   while ((ch = getopt(argc, argv, "HLPRafipqrv")) != -1)
switch (ch) {
case 'H':
Hflag = 1;
@@ -121,6 +121,9 @@
break;
case 'p':
pflag = 1;
+   break;
+   case 'q':
+   qflag = 1;
break;
case 'r':
rflag = 1;
--- extern.h.dist   Sat Dec 26 15:11:43 2015
+++ extern.hThu Dec 22 08:47:22 2022
@@ -40,7 +40,7 @@
 
 extern PATH_T to;
 extern uid_t myuid;
-extern int fflag, iflag, pflag;
+extern int fflag, iflag, pflag, qflag;
 extern mode_t myumask;
 extern char *__progname;
 
--- utils.c.distSun Nov 28 16:28:41 2021
+++ utils.c Thu Dec 22 08:51:25 2022
@@ -314,12 +314,14 @@
 * if the server supports flags and we were trying to *remove* flags
 * on a file that we copied, i.e., that we didn't create.)
 */
-   errno = 0;
-   if (fd >= 0 ? fchflags(fd, fs->st_flags) :
-   chflagsat(AT_FDCWD, to.p_path, fs->st_flags, AT_SYMLINK_NOFOLLOW))
-   if (errno != EOPNOTSUPP || fs->st_flags != 0) {
-   warn("chflags: %s", to.p_path);
-   rval = 1;
+   if (qflag == 0) {
+   errno = 0;
+   if (fd >= 0 ? fchflags(fd, fs->st_flags) :
+   chflagsat(AT_FDCWD, to.p_path, fs->st_flags, 
AT_SYMLINK_NOFOLLOW))
+   if (errno != EOPNOTSUPP || fs->st_flags != 0) {
+   warn("chflags: %s", to.p_path);
+   rval = 1;
+   }
}
return (rval);
 }



rpki-client: small geofeed parsing bug

2022-12-22 Thread Theo Buehler
If the line contains no location info and a comma in a comment, what
follows the comma will be interpreted as location info. Actually ignore
what's in comments by adjusting the line length.

Index: geofeed.c
===
RCS file: /cvs/src/usr.sbin/rpki-client/geofeed.c,v
retrieving revision 1.8
diff -u -p -r1.8 geofeed.c
--- geofeed.c   14 Dec 2022 10:45:34 -  1.8
+++ geofeed.c   22 Dec 2022 10:18:45 -
@@ -198,8 +198,10 @@ geofeed_parse(X509 **x509, const char *f
 
/* zap comments */
delim = memchr(line, '#', linelen);
-   if (delim != NULL)
+   if (delim != NULL) {
*delim = '\0';
+   linelen = delim - line;
+   }
 
/* Split prefix and location info */
delim = memchr(line, ',', linelen);



Re: [patch] add show.c style flag descriptions to route(8)

2022-12-22 Thread Claudio Jeker
On Wed, Dec 21, 2022 at 10:21:16AM -0700, Theo de Raadt wrote:
> Claudio Jeker  wrote:
> 
> > In the old world only netstat could show the routing table. I think this
> > is still the case in FreeBSD for example. We added route show at some
> > point but the documentation was not shared between the manpages.
> > I agree that it is annoying to open up the netstat man page to find the
> > flags shown by route show. For this we added:
> > 
> >  Print out the routing table, in a fashion similar to
> >  "netstat -r".  The output is documented in more detail
> >  towards the end of the netstat(1) manual.
> > 
> > To the route manpage when describing route show. Not sure if that is
> > enough or if we should duplicate tables (whith the usual sync problem).
> 
> This is all true.
> 
> So netstat in those days was more of a "kvm reader" program, and as such
> racy.  Nowadays both route & netstat programs's subcommands are a mix of
> sysctl readers and route socket askers/listeners, and thus they have
> better atomicity or at least other types of truth.
> 
> The sub-command extensions in route are better designed, mostly because
> they are newer and were built in an era where kernels maintained more than
> a handful of routes.  I think we want to lean people towards using route,
> instead of netstat.
> 
> So I think route.8 is where we should try to have complete documentation,
> and once that is done we should change Xr's and other documentation to 
> point at route.8 instead of netstat.8

The show code of netstat and route should be in sync. I did that long time
ago. The kvm bits are only used in netstat and may be broken again. Did
not try lately.

Still I think 'route show' is more obvious and has a few extra arguments
over netstat -rn.

-- 
:wq Claudio