Re: powerpc ld.lld fix

2020-11-01 Thread Mark Kettenis
> From: Philip Guenther 
> Date: Sun, 1 Nov 2020 05:06:13 -0900
> 
> Makes sense.  This code is just the space reservation, the relocation
> generation or whatever fills them in is suppressed already, yes?  Assuming
> so, r+

Yes.  The slots are reserved such that ld.so can fill them in.

> On Sat, Oct 31, 2020 at 2:46 PM Mark Kettenis 
> wrote:
> 
>  > Date: Sat, 10 Oct 2020 23:19:19 +0200 (CEST)
>  > From: Mark Kettenis 
>  > 
>  > On powerpc with the secure-plt ABI we need a .got section, even if the
>  > _GLOBAL_OFFSET_TABLE_ symbol isn't referenced.  This is needed because
>  > the first three entries of the GOT are used by the dynamic linker.
>  > 
>  > With this fix I can build executables of all flavours (including
>  > -static/-nopie).
> 
>  Turns out that adding these GOT entries when using "ld -r" is a bad
>  idea.  Dif below fixes that.
> 
>  ok?
> 
>  Index: gnu/llvm/lld/ELF/SyntheticSections.cpp
>  ===
>  RCS file: /cvs/src/gnu/llvm/lld/ELF/SyntheticSections.cpp,v
>  retrieving revision 1.2
>  diff -u -p -r1.2 SyntheticSections.cpp
>  --- gnu/llvm/lld/ELF/SyntheticSections.cpp  11 Oct 2020 13:10:13
>  -  1.2
>  +++ gnu/llvm/lld/ELF/SyntheticSections.cpp  31 Oct 2020 23:37:11
>  -
>  @@ -604,7 +604,7 @@ GotSection::GotSection()
> // ElfSym::globalOffsetTable.
> if (ElfSym::globalOffsetTable && !target->gotBaseSymInGotPlt)
>   numEntries += target->gotHeaderEntriesNum;
>  -  else if (config->emachine == EM_PPC)
>  +  else if (config->emachine == EM_PPC && !config->relocatable)
>   numEntries += target->gotHeaderEntriesNum;
>   }



Re: powerpc ld.lld fix

2020-11-01 Thread Philip Guenther
Makes sense.  This code is just the space reservation, the relocation
generation or whatever fills them in is suppressed already, yes?  Assuming
so, r+

On Sat, Oct 31, 2020 at 2:46 PM Mark Kettenis 
wrote:

> > Date: Sat, 10 Oct 2020 23:19:19 +0200 (CEST)
> > From: Mark Kettenis 
> >
> > On powerpc with the secure-plt ABI we need a .got section, even if the
> > _GLOBAL_OFFSET_TABLE_ symbol isn't referenced.  This is needed because
> > the first three entries of the GOT are used by the dynamic linker.
> >
> > With this fix I can build executables of all flavours (including
> > -static/-nopie).
>
> Turns out that adding these GOT entries when using "ld -r" is a bad
> idea.  Dif below fixes that.
>
> ok?
>
>
> Index: gnu/llvm/lld/ELF/SyntheticSections.cpp
> ===
> RCS file: /cvs/src/gnu/llvm/lld/ELF/SyntheticSections.cpp,v
> retrieving revision 1.2
> diff -u -p -r1.2 SyntheticSections.cpp
> --- gnu/llvm/lld/ELF/SyntheticSections.cpp  11 Oct 2020 13:10:13
> -  1.2
> +++ gnu/llvm/lld/ELF/SyntheticSections.cpp  31 Oct 2020 23:37:11 -
> @@ -604,7 +604,7 @@ GotSection::GotSection()
>// ElfSym::globalOffsetTable.
>if (ElfSym::globalOffsetTable && !target->gotBaseSymInGotPlt)
>  numEntries += target->gotHeaderEntriesNum;
> -  else if (config->emachine == EM_PPC)
> +  else if (config->emachine == EM_PPC && !config->relocatable)
>  numEntries += target->gotHeaderEntriesNum;
>  }
>
>
>


Re: Diff: Introductory Clause Comma Crap

2020-11-01 Thread Jason McIntyre
On Sun, Nov 01, 2020 at 04:14:19PM -0500, VARIK VALEFOR wrote:
> Mr. MCINTYRE:
> 
> > Mr. MACINTYRE... you must mean my dad!
> :^)
> 
> > commas are really subjective, so a massive comma diff is always likely
> > to be problematic. sentence clauses do not always need commas. sometimes
> > commas just make the text harder to read.
> However, the comma rules which are specified at the Web site whose URL
> was attached to VARIK's previous message _do_ exist for a reason; the
> correct application of these rules tends to increase clarity.  But there
> do exist unjustifiable "stylistic" choices.
> 

well, there are not so much comma rules as comma suggestions.

> > in a if/then sentence structure, "then" indicates the second
> > clause. the comma is redundant. "then" performs the role of a comma
> However, omitting the comma which is placed after an introductory
> clause but before "then" can lead to confusion.
> 
> = BEGIN PROOF =
> Let there exist a sentence $s =$ "If $x > y$ then $z$.".
> 
> For all sentences, the meaning of a sentence is ambiguous iff
> $\#\left\{\textrm{FEASIBLE MEANING OF SENTENCE}\left\} > 1$.
> 
> Sentence $s$ can be interpreted as "if $x > y$ then, $z$",
> which is approximately semantically equivalent to "if $x > y$ at
> the previously-mentioned point in time, then $z$".  Although such
> an interpretation is not terribly often correct, bad habits, e.g.,
> overlooking such potential sources of confusion, are formed quickly.
> 
> However, sentence $s$ can also be interpreted as "if $x > y$, then
> $z$", which is not semantically equivalent to "if $x > y$ at the
> previously-mentioned point in time, then $z$".
> 
> Therefore, the meaning of sentence $s$ is ambiguous as a result of
> omitting the comma which would have been placed after the
> introductory clause but before "then".
> 
> Therefore, omitting the comma which is placed after the
> introductory clause but before "then" can lead to ambiguity.
> = END PROOF =
> 

yes, the point being that there are not so much rules as suggestions.

> > i think you should follow philip's advice to supply a small diff, check
> > whether such changes made wholesale would be welcome, then proceed.
> WILCO.
> 

roger that!

> > i;d be happy to look over a diff where the clauses are not marked with
> > "then", such as here:
> See the attached diffs.
> 
> > in this case it is really hard to tell where one clause ends and another
> > starts - the comma improves readability. in addition, "an nosuchinstance" 
> > should
> > be "a nosuchinstance".
> Fixing incorrect article usage was not the goal of the previous diff 
> assortment;
> the solution to this type of problem shall receive a dedicated
> twenty-thousand-line message.  :^)
> 

if our manual pages require a twenty thousand line article fix diff i am
hanging up my boots.

i committed your diff - with thanks - but changed audio.4 to work
without commas.

thanks,
jmc

> KUTGW,
> Varik "NOT A COMPUTER PROGRAMMER!!!" Valefor
> 
> = BEGIN SLIGHTLY-LESS-LONG-ASS DIFFS =
> diff --git a/share/man/man4/audio.4 b/share/man/man4/audio.4
> index 94a1c227c2f..00d099e392d 100644
> --- a/share/man/man4/audio.4
> +++ b/share/man/man4/audio.4
> @@ -166,11 +166,13 @@ Bytes per sample; if specified, it must be large enough 
> to hold all bits.
>  By default it's set to the smallest power of two large enough to hold
>  .Va bits .
>  .It Va sig
> -If set (i.e. non-zero) then the samples are signed,
> -otherwise they are unsigned.
> +If set (i.e., non-zero), then the samples are signed;
> +otherwise, they are unsigned.
> +\"This sentence was a run-on.
>  .It Va le
>  If set, then the byte order is little endian;
> -if not it is big endian;
> +if not, it is big endian;
> +\""[I]f not" is an introductory phrase, and introductory phrases are 
> followed by commas.
> -it's meaningful only if
> +It's meaningful only if
> +\"The capitalisation of this sentence was fixed.
>  .Va bps
>  > 1.
> 
> 
> 
> diff --git a/usr.bin/openssl/openssl.1 b/usr.bin/openssl/openssl.1
> index e364586f5ad..7c0af459fae 100644
> --- a/usr.bin/openssl/openssl.1
> +++ b/usr.bin/openssl/openssl.1
> @@ -1121,7 +1121,7 @@ commands.
>  .It Fl binary
>  Normally the input message is converted to "canonical" format which is
>  effectively using CR/LF as end of line, as required by the S/MIME 
> specification.
> -When this option is present no translation occurs.
> +When this option is present, no translation occurs.
>  This is useful when handling binary data which may not be in MIME format.
>  .It Fl CAfile Ar file
>  A file containing trusted CA certificates, used with
> @@ -1971,7 +1971,8 @@ Encrypt the private key with DES, triple DES, or
>  any other cipher supported by
>  .Nm openssl .
>  A pass phrase is prompted for.
> -If none of these options is specified the key is written in plain text.
> +If none of these options are specified, the key is written in plain text.
> +\""[I]s" was changed to "are" to maintain consistency 

Re: Diff: Introductory Clause Comma Crap

2020-11-01 Thread VARIK VALEFOR
Mr. MCINTYRE:

> Mr. MACINTYRE... you must mean my dad!
:^)

> commas are really subjective, so a massive comma diff is always likely
> to be problematic. sentence clauses do not always need commas. sometimes
> commas just make the text harder to read.
However, the comma rules which are specified at the Web site whose URL
was attached to VARIK's previous message _do_ exist for a reason; the
correct application of these rules tends to increase clarity.  But there
do exist unjustifiable "stylistic" choices.

> in a if/then sentence structure, "then" indicates the second
> clause. the comma is redundant. "then" performs the role of a comma
However, omitting the comma which is placed after an introductory
clause but before "then" can lead to confusion.

= BEGIN PROOF =
Let there exist a sentence $s =$ "If $x > y$ then $z$.".

For all sentences, the meaning of a sentence is ambiguous iff
$\#\left\{\textrm{FEASIBLE MEANING OF SENTENCE}\left\} > 1$.

Sentence $s$ can be interpreted as "if $x > y$ then, $z$",
which is approximately semantically equivalent to "if $x > y$ at
the previously-mentioned point in time, then $z$".  Although such
an interpretation is not terribly often correct, bad habits, e.g.,
overlooking such potential sources of confusion, are formed quickly.

However, sentence $s$ can also be interpreted as "if $x > y$, then
$z$", which is not semantically equivalent to "if $x > y$ at the
previously-mentioned point in time, then $z$".

Therefore, the meaning of sentence $s$ is ambiguous as a result of
omitting the comma which would have been placed after the
introductory clause but before "then".

Therefore, omitting the comma which is placed after the
introductory clause but before "then" can lead to ambiguity.
= END PROOF =

> i think you should follow philip's advice to supply a small diff, check
> whether such changes made wholesale would be welcome, then proceed.
WILCO.

> i;d be happy to look over a diff where the clauses are not marked with
> "then", such as here:
See the attached diffs.

> in this case it is really hard to tell where one clause ends and another
> starts - the comma improves readability. in addition, "an nosuchinstance" 
> should
> be "a nosuchinstance".
Fixing incorrect article usage was not the goal of the previous diff assortment;
the solution to this type of problem shall receive a dedicated
twenty-thousand-line message.  :^)

KUTGW,
Varik "NOT A COMPUTER PROGRAMMER!!!" Valefor

= BEGIN SLIGHTLY-LESS-LONG-ASS DIFFS =
diff --git a/share/man/man4/audio.4 b/share/man/man4/audio.4
index 94a1c227c2f..00d099e392d 100644
--- a/share/man/man4/audio.4
+++ b/share/man/man4/audio.4
@@ -166,11 +166,13 @@ Bytes per sample; if specified, it must be large enough 
to hold all bits.
 By default it's set to the smallest power of two large enough to hold
 .Va bits .
 .It Va sig
-If set (i.e. non-zero) then the samples are signed,
-otherwise they are unsigned.
+If set (i.e., non-zero), then the samples are signed;
+otherwise, they are unsigned.
+\"This sentence was a run-on.
 .It Va le
 If set, then the byte order is little endian;
-if not it is big endian;
+if not, it is big endian;
+\""[I]f not" is an introductory phrase, and introductory phrases are followed 
by commas.
-it's meaningful only if
+It's meaningful only if
+\"The capitalisation of this sentence was fixed.
 .Va bps
 > 1.



diff --git a/usr.bin/openssl/openssl.1 b/usr.bin/openssl/openssl.1
index e364586f5ad..7c0af459fae 100644
--- a/usr.bin/openssl/openssl.1
+++ b/usr.bin/openssl/openssl.1
@@ -1121,7 +1121,7 @@ commands.
 .It Fl binary
 Normally the input message is converted to "canonical" format which is
 effectively using CR/LF as end of line, as required by the S/MIME 
specification.
-When this option is present no translation occurs.
+When this option is present, no translation occurs.
 This is useful when handling binary data which may not be in MIME format.
 .It Fl CAfile Ar file
 A file containing trusted CA certificates, used with
@@ -1971,7 +1971,8 @@ Encrypt the private key with DES, triple DES, or
 any other cipher supported by
 .Nm openssl .
 A pass phrase is prompted for.
-If none of these options is specified the key is written in plain text.
+If none of these options are specified, the key is written in plain text.
+\""[I]s" was changed to "are" to maintain consistency with the rest of this 
manual page.
 This means that using the
 .Nm ec
 utility to read in an encrypted key with no
@@ -1982,7 +1983,7 @@ These options can only be used with PEM format output 
files.
 .It Fl in Ar file
 The input file to read a key from,
 or standard input if not specified.
-If the key is encrypted a pass phrase will be prompted for.
+If the key is encrypted, a pass phrase will be prompted for.
 .It Fl inform Cm der | pem
 The input format.
 .It Fl noout
@@ -3356,7 +3358,7 @@ is acceptable, such as
 .It Fl in Ar file
 The input file to read from,
 or standard input if not specified.
-If the key is encrypted 

Move TCPCTL_ALWAYS_KEEPALIVE into tcpctl_vars

2020-11-01 Thread Greg Steuck
This one was an omission from the earlier conversion, should be an easy
OK?

>From 1ea2565b9414fddc1227781348101e5d9c37a913 Mon Sep 17 00:00:00 2001
From: Greg Steuck 
Date: Sun, 1 Nov 2020 19:05:14 -0800
Subject: [PATCH 1/3] Move TCPCTL_ALWAYS_KEEPALIVE into tcpctl_vars

---
 sys/netinet/tcp_usrreq.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git sys/netinet/tcp_usrreq.c sys/netinet/tcp_usrreq.c
index 7b0aaac7bac..0da0827f407 100644
--- sys/netinet/tcp_usrreq.c
+++ sys/netinet/tcp_usrreq.c
@@ -125,6 +125,7 @@ const struct sysctl_bounded_args tcpctl_vars[] = {
{ TCPCTL_SYN_CACHE_LIMIT, _syn_cache_limit, 1, 1000 * 1000 },
{ TCPCTL_SYN_BUCKET_LIMIT, _syn_bucket_limit, 1, INT_MAX },
{ TCPCTL_RFC3390, _do_rfc3390, 0, 2 },
+   { TCPCTL_ALWAYS_KEEPALIVE, _always_keepalive, 0, 1 },
 };
 
 struct inpcbtable tcbtable;
@@ -1027,13 +1028,6 @@ tcp_sysctl(int *name, u_int namelen, void *oldp, size_t 
*oldlenp, void *newp,
NET_UNLOCK();
return (error);
 
-   case TCPCTL_ALWAYS_KEEPALIVE:
-   NET_LOCK();
-   error = sysctl_int(oldp, oldlenp, newp, newlen,
-   _always_keepalive);
-   NET_UNLOCK();
-   return (error);
-
case TCPCTL_REASS_LIMIT:
NET_LOCK();
nval = tcp_reass_limit;
-- 
2.29.1



Convert ffs_sysctl to sysctl_bounded_args

2020-11-01 Thread Greg Steuck
How does the encoding of sysctl_rdint as [1,0] sound?

OK?

>From 27fda35ce0990df113dab99f2e4018e63b5390d7 Mon Sep 17 00:00:00 2001
From: Greg Steuck 
Date: Sun, 1 Nov 2020 19:14:12 -0800
Subject: [PATCH] Convert ffs_sysctl to sysctl_bounded_args

Requires sysctl_bounded_arr branch to support sysctl_rdint.
The read-only variables are marked by an empty range of [1, 0].
---
 sys/kern/kern_sysctl.c   | 10 -
 sys/sys/sysctl.h |  2 +-
 sys/ufs/ffs/ffs_vfsops.c | 88 ++--
 3 files changed, 39 insertions(+), 61 deletions(-)

diff --git sys/kern/kern_sysctl.c sys/kern/kern_sysctl.c
index ccf0e5ffa05..87419cf2d17 100644
--- sys/kern/kern_sysctl.c
+++ sys/kern/kern_sysctl.c
@@ -938,8 +938,14 @@ sysctl_bounded_arr(const struct sysctl_bounded_args 
*valpp, u_int valplen,
return (ENOTDIR);
for (i = 0; i < valplen; ++i) {
if (valpp[i].mib == name[0]) {
-   return (sysctl_int_bounded(oldp, oldlenp, newp, newlen,
-   valpp[i].var, valpp[i].minimum, valpp[i].maximum));
+   if (valpp[i].minimum <= valpp[i].maximum) {
+   return (sysctl_int_bounded(oldp, oldlenp, newp,
+   newlen, valpp[i].var, valpp[i].minimum,
+   valpp[i].maximum));
+   } else {
+   return (sysctl_rdint(oldp, oldlenp, newp,
+   *valpp[i].var));
+   }
}
}
return (EOPNOTSUPP);
diff --git sys/sys/sysctl.h sys/sys/sysctl.h
index 5e5115d4f4e..f8f36cfb55b 100644
--- sys/sys/sysctl.h
+++ sys/sys/sysctl.h
@@ -984,7 +984,7 @@ struct sysctl_bounded_args {
int mib; /* identifier shared with userspace as a CTL_ #define */
int *var;/* never NULL */
int minimum; /* checking is disabled if minimum == maximum  */
-   int maximum;
+   int maximum; /* read-only variable if minimum > maximum */
 };
 
 /*
diff --git sys/ufs/ffs/ffs_vfsops.c sys/ufs/ffs/ffs_vfsops.c
index 5bfec8dc339..70ded4d905d 100644
--- sys/ufs/ffs/ffs_vfsops.c
+++ sys/ufs/ffs/ffs_vfsops.c
@@ -1568,69 +1568,41 @@ ffs_init(struct vfsconf *vfsp)
return (ufs_init(vfsp));
 }
 
-/*
- * fast filesystem related variables.
- */
-int
-ffs_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
-size_t newlen, struct proc *p)
-{
 #ifdef FFS_SOFTUPDATES
-   extern int max_softdeps, tickdelay, stat_worklist_push;
-   extern int stat_blk_limit_push, stat_ino_limit_push, stat_blk_limit_hit;
-   extern int stat_ino_limit_hit, stat_sync_limit_hit, stat_indir_blk_ptrs;
-   extern int stat_inode_bitmap, stat_direct_blk_ptrs, stat_dir_entry;
+extern int max_softdeps, tickdelay, stat_worklist_push;
+extern int stat_blk_limit_push, stat_ino_limit_push, stat_blk_limit_hit;
+extern int stat_ino_limit_hit, stat_sync_limit_hit, stat_indir_blk_ptrs;
+extern int stat_inode_bitmap, stat_direct_blk_ptrs, stat_dir_entry;
 #endif
-
-   /* all sysctl names at this level are terminal */
-   if (namelen != 1)
-   return (ENOTDIR);   /* overloaded */
-
-   switch (name[0]) {
-   case FFS_CLUSTERREAD:
-   case FFS_CLUSTERWRITE:
-   case FFS_REALLOCBLKS:
-   case FFS_ASYNCFREE:
-   return (EOPNOTSUPP);
+const struct sysctl_bounded_args ffs_vars[] = {
 #ifdef FFS_SOFTUPDATES
-   case FFS_MAX_SOFTDEPS:
-   return (sysctl_int(oldp, oldlenp, newp, newlen, _softdeps));
-   case FFS_SD_TICKDELAY:
-   return (sysctl_int(oldp, oldlenp, newp, newlen, ));
-   case FFS_SD_WORKLIST_PUSH:
-   return (sysctl_rdint(oldp, oldlenp, newp, stat_worklist_push));
-   case FFS_SD_BLK_LIMIT_PUSH:
-   return (sysctl_rdint(oldp, oldlenp, newp, stat_blk_limit_push));
-   case FFS_SD_INO_LIMIT_PUSH:
-   return (sysctl_rdint(oldp, oldlenp, newp, stat_ino_limit_push));
-   case FFS_SD_BLK_LIMIT_HIT:
-   return (sysctl_rdint(oldp, oldlenp, newp, stat_blk_limit_hit));
-   case FFS_SD_INO_LIMIT_HIT:
-   return (sysctl_rdint(oldp, oldlenp, newp, stat_ino_limit_hit));
-   case FFS_SD_SYNC_LIMIT_HIT:
-   return (sysctl_rdint(oldp, oldlenp, newp, stat_sync_limit_hit));
-   case FFS_SD_INDIR_BLK_PTRS:
-   return (sysctl_rdint(oldp, oldlenp, newp, stat_indir_blk_ptrs));
-   case FFS_SD_INODE_BITMAP:
-   return (sysctl_rdint(oldp, oldlenp, newp, stat_inode_bitmap));
-   case FFS_SD_DIRECT_BLK_PTRS:
-   return (sysctl_rdint(oldp, oldlenp, newp, 
stat_direct_blk_ptrs));
-   case FFS_SD_DIR_ENTRY:
-   return (sysctl_rdint(oldp, oldlenp, newp, stat_dir_entry));
+   { FFS_MAX_SOFTDEPS, _softdeps, 0, INT_MAX },
+   { FFS_SD_TICKDELAY, , 2, INT_MAX },
+   { 

sndio support for Rust (cpal crate) - review requested

2020-11-01 Thread Aaron Miller
Hello all,

I have added support for a host for the sndio(7) system to the
cpal Rust audio library[1]. I am seeking reviewers who are
familiar with the sndio API and with Rust. My PR is here:
https://github.com/RustAudio/cpal/pull/493
Although it's not the most straightforward code it's only about
1k SLOC so I don't expect it'll take a long time to review.

The cpal crate is a big deal in the Rust audio ecosystem --
it'll enable OpenBSD audio support for the two major game
engines (ggez and amethyst), and some various audio tools as
well.[2]

If anyone would be willing to test it on their machine and
report back, that would be appreciated as well:
1. Install the rust package (if not already installed)
2. git clone https://github.com/conwayste/cpal \
 -b aaron/openbsd_sndio_host
3. cd cpal
4. cargo run --example beep
(there are some other examples under examples/)

Thanks in advance :)

Aaron Miller

[1] https://crates.io/crates/cpal
[2] https://rust.audio/



bpf_sysctl for sysctl_int_bounded

2020-11-01 Thread Greg Steuck
Mildly different in flavor due to the special check. OK?

Tested:
% sysctl | grep bpf
net.bpf.bufsize=32768
net.bpf.maxbufsize=2097152
% doas sysctl -w net.bpf.bufsize=32768
net.bpf.bufsize: 32768 -> 32768
% doas sysctl -w net.bpf.bufsize=32767
net.bpf.bufsize: 32768 -> 32767
% doas sysctl -w net.bpf.bufsize=32
net.bpf.bufsize: 32767 -> 32
% doas sysctl -w net.bpf.bufsize=31
sysctl: net.bpf.bufsize: Invalid argument
% doas sysctl -w net.bpf.bufsize=2097152
net.bpf.bufsize: 32 -> 2097152
% doas sysctl -w net.bpf.bufsize=2097153
sysctl: net.bpf.bufsize: Invalid argument
% doas sysctl -w net.bpf.bufsize=32768
net.bpf.bufsize: 2097152 -> 32768
% doas sysctl -w net.bpf.maxbufsize=100
net.bpf.maxbufsize: 2097152 -> 100
% doas sysctl -w net.bpf.bufsize=90
net.bpf.bufsize: 32768 -> 90
% doas sysctl -w net.bpf.bufsize=101
sysctl: net.bpf.bufsize: Invalid argument
% sysctl | grep bpf
net.bpf.bufsize=90
net.bpf.maxbufsize=100
% doas sysctl -w net.bpf.maxbufsize=2097152
net.bpf.maxbufsize: 100 -> 2097152
% doas sysctl -w net.bpf.bufsize=32768
net.bpf.bufsize: 90 -> 32768

>From 8e7e3c4b19cc527bfe4a643c816fe971a284 Mon Sep 17 00:00:00 2001
From: Greg Steuck 
Date: Sun, 1 Nov 2020 19:06:46 -0800
Subject: [PATCH 2/3] Use bpf_sysctl for sysctl_int_bounded

Unlike the other cases of sysctl_bounded_arr this one uses a dynamic limit.
---
 sys/net/bpf.c | 24 
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git sys/net/bpf.c sys/net/bpf.c
index 0d900b38e3c..efb1d4b2a17 100644
--- sys/net/bpf.c
+++ sys/net/bpf.c
@@ -1720,32 +1720,16 @@ int
 bpf_sysctl_locked(int *name, u_int namelen, void *oldp, size_t *oldlenp,
 void *newp, size_t newlen)
 {
-   int newval;
-   int error;
-
switch (name[0]) {
case NET_BPF_BUFSIZE:
-   newval = bpf_bufsize;
-   error = sysctl_int(oldp, oldlenp, newp, newlen, );
-   if (error)
-   return (error);
-   if (newval < BPF_MINBUFSIZE || newval > bpf_maxbufsize)
-   return (EINVAL);
-   bpf_bufsize = newval;
-   break;
+   return sysctl_int_bounded(oldp, oldlenp, newp, newlen,
+   _bufsize, BPF_MINBUFSIZE, bpf_maxbufsize);
case NET_BPF_MAXBUFSIZE:
-   newval = bpf_maxbufsize;
-   error = sysctl_int(oldp, oldlenp, newp, newlen, );
-   if (error)
-   return (error);
-   if (newval < BPF_MINBUFSIZE)
-   return (EINVAL);
-   bpf_maxbufsize = newval;
-   break;
+   return sysctl_int_bounded(oldp, oldlenp, newp, newlen,
+   _maxbufsize, BPF_MINBUFSIZE, INT_MAX);
default:
return (EOPNOTSUPP);
}
-   return (0);
 }
 
 int
-- 
2.29.1