FreeBSD/src c817e3clib/libc/resolv res_init.c

libc/resolv: Refactor the configuration parser

This was previously all a single loop in res_init(), apart from option
parsing which we cleaned up in a previous commit.  Break it out into
separate functions for reading the configuration line by line, setting
the default domain, setting the search list, and adding a nameserver
to the nameserver list.  Sprinkle bounds checks and code comments all
around.

The sortlist code, which has been disabled for the past 20 years, will
be dealt with in a separate commit.

MFC after:      1 week
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D57924

(cherry picked from commit ffeb56905ed6a7ac759367096d6dc0596e82e03f)
DeltaFile
+381-268lib/libc/resolv/res_init.c
+381-2681 files

FreeBSD/src fc00e7alib/libc/resolv res_init.c Makefile.inc, share/man/man5 resolver.5

libc/resolv: Reimplement the sortlist parser

When we switched from the BIND4 resolver to the BIND9 resolver, the
sortlist parser was inadvertently disabled due to a missing #define, and
nobody seemed to notice.  The sorting code remained enabled in the
resolver, but there was no way to set a sort order.

Reimplement the sortlist parser, but correctly, and update the manual
accordingly.  The new parser accepts IPv4 and IPv6 addresses with or
without a mask or prefix length, just like the old one, except IPv6
support was a bit wonky in the original code.

Fixes:          5342d17f09a8 ("Update the resolver in libc to BIND9's one.")
Relnotes:       yes
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D57925

(cherry picked from commit fbe0257b5613f457af42f82efb2e3bc9395d0557)
DeltaFile
+136-110lib/libc/resolv/res_init.c
+23-13share/man/man5/resolver.5
+1-0lib/libc/resolv/Makefile.inc
+160-1233 files

FreeBSD/src 19d044blib/libc/resolv res_init.c

libc/resolv: Dead code and style cleanup

Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D57928

(cherry picked from commit 4805b88edb009e53c4fee159138d2cbe0c848da7)
DeltaFile
+17-42lib/libc/resolv/res_init.c
+17-421 files

FreeBSD/src c6030cainclude resolv.h

resolv.h: Remove unused parts

Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D57927

(cherry picked from commit 3f15998d25da08677d2c40bc2240de293aec4205)
DeltaFile
+0-49include/resolv.h
+0-491 files

FreeBSD/src 345d104lib/libc/resolv res_init.c, share/man/man5 resolver.5

libc/resolv: Add no-debug and no-rotate options

These are simply the reverse of the debug and rotate options.

Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D57926

(cherry picked from commit 60827d7885016861dc02caa45f3ce873ad2a020e)
DeltaFile
+12-0share/man/man5/resolver.5
+4-0lib/libc/resolv/res_init.c
+16-02 files

FreeBSD/src 2bab563share/man/man5 resolver.5

resolver(5): Overhaul

* Modernize the markup

* Describe the comment syntax

* Drop obsolete advice

* Capitalize sentences

* Improve the language

* Replace no_tld_query with no-tld-query; both are supported, but all the
  other multi-word options use hyphens rather than underscores.

* Add missing ENVIRONMENT section

* Redo the example


    [5 lines not shown]
DeltaFile
+116-111share/man/man5/resolver.5
+116-1111 files

FreeBSD/src b796284lib/libc/net gethostbydns.c, lib/libc/resolv res_send.c res_init.c

libc: Disable debugging code in the resolver.

Reviewed by:    kevans
Differential Revision:  https://reviews.freebsd.org/D37319

(cherry picked from commit cd0756cef21079104967969e275c18b84dc45053)
DeltaFile
+10-8lib/libc/resolv/res_send.c
+0-6lib/libc/resolv/res_init.c
+6-0lib/libc/net/gethostbydns.c
+0-5lib/libc/resolv/res_mkquery.c
+0-5lib/libc/resolv/res_query.c
+0-4lib/libc/resolv/res_mkupdate.c
+16-282 files not shown
+19-318 files

FreeBSD/src 3052e15share/man/man5 resolver.5

resolver.5: document six previously undocumented options

Document the edns0, inet6, insecure1, insecure2, no-check-names,
and rotate options which are parsed by res_init(3) but were not
described in the resolver(5) man page.

MFC after:      1 week
Signed-off-by:  Christos Longros <chris.longros at gmail.com>
Reviewed by:    des
Differential Revision:  https://reviews.freebsd.org/D55864

(cherry picked from commit 462a1f6197fa3de63e0eca2835b1d5b0bc6a3bbb)
DeltaFile
+39-1share/man/man5/resolver.5
+39-11 files

FreeBSD/src b52d95blib/libc/resolv res_init.c

libc/resolv: Refactor the option parser

Start the loop by finding the end of the option name, the name-value
separator (if any), and the end of the option.  Use those pointers to
simplify matching the option name and parsing the option value, and
validate option names and values more strictly.  This means that:

* We no longer accept trailing garbage in an option name or value.  For
  instance, we would previously interpret “edns0123” as “edns0” and
  “timeout:3xyz” as “timeout:3”.  This was actually quite lucky because
  we also failed to recognize the newline at the end of the option line
  as a whitespace character.

* For options that take a numerical argument, we would previously accept
  negative values and treat non-numerical arguments as 0, while large
  numerical arguments would be capped to the option's maximum permitted
  value.  Now, any failure to parse the argument, including overflow,
  results in the option being left unchanged.


    [6 lines not shown]
DeltaFile
+106-90lib/libc/resolv/res_init.c
+106-901 files

FreeBSD/src 899cf59lib/libc/nameser ns_parse.c, lib/libc/resolv res_init.c res_comp.c

libc/resolv: Drop Solaris 2 compatibility

MFC after:      1 week
Reviewed by:    kevans, markj
Differential Revision:  https://reviews.freebsd.org/D57922

(cherry picked from commit aba9fffebf97d631f85e904813ff35ed031a3bac)
DeltaFile
+0-42lib/libc/resolv/res_init.c
+0-11lib/libc/resolv/res_comp.c
+0-5lib/libc/nameser/ns_parse.c
+0-583 files

FreeBSD/src f4b82c7lib/libc/resolv res_init.c

libc/resolv: Dead code and style cleanup

Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D57928

(cherry picked from commit 4805b88edb009e53c4fee159138d2cbe0c848da7)
DeltaFile
+17-42lib/libc/resolv/res_init.c
+17-421 files

FreeBSD/src 506c2delib/libc/resolv res_init.c, share/man/man5 resolver.5

libc/resolv: Add no-debug and no-rotate options

These are simply the reverse of the debug and rotate options.

Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D57926

(cherry picked from commit 60827d7885016861dc02caa45f3ce873ad2a020e)
DeltaFile
+12-0share/man/man5/resolver.5
+4-0lib/libc/resolv/res_init.c
+16-02 files

FreeBSD/src 55f219blib/libc/resolv res_init.c Makefile.inc, share/man/man5 resolver.5

libc/resolv: Reimplement the sortlist parser

When we switched from the BIND4 resolver to the BIND9 resolver, the
sortlist parser was inadvertently disabled due to a missing #define, and
nobody seemed to notice.  The sorting code remained enabled in the
resolver, but there was no way to set a sort order.

Reimplement the sortlist parser, but correctly, and update the manual
accordingly.  The new parser accepts IPv4 and IPv6 addresses with or
without a mask or prefix length, just like the old one, except IPv6
support was a bit wonky in the original code.

Fixes:          5342d17f09a8 ("Update the resolver in libc to BIND9's one.")
Relnotes:       yes
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D57925

(cherry picked from commit fbe0257b5613f457af42f82efb2e3bc9395d0557)
DeltaFile
+136-110lib/libc/resolv/res_init.c
+23-13share/man/man5/resolver.5
+1-0lib/libc/resolv/Makefile.inc
+160-1233 files

FreeBSD/src 3e44888lib/libc/resolv res_init.c

libc/resolv: Refactor the configuration parser

This was previously all a single loop in res_init(), apart from option
parsing which we cleaned up in a previous commit.  Break it out into
separate functions for reading the configuration line by line, setting
the default domain, setting the search list, and adding a nameserver
to the nameserver list.  Sprinkle bounds checks and code comments all
around.

The sortlist code, which has been disabled for the past 20 years, will
be dealt with in a separate commit.

MFC after:      1 week
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D57924

(cherry picked from commit ffeb56905ed6a7ac759367096d6dc0596e82e03f)
DeltaFile
+381-268lib/libc/resolv/res_init.c
+381-2681 files

FreeBSD/src 491337clib/libc/resolv res_init.c

libc/resolv: Refactor the option parser

Start the loop by finding the end of the option name, the name-value
separator (if any), and the end of the option.  Use those pointers to
simplify matching the option name and parsing the option value, and
validate option names and values more strictly.  This means that:

* We no longer accept trailing garbage in an option name or value.  For
  instance, we would previously interpret “edns0123” as “edns0” and
  “timeout:3xyz” as “timeout:3”.  This was actually quite lucky because
  we also failed to recognize the newline at the end of the option line
  as a whitespace character.

* For options that take a numerical argument, we would previously accept
  negative values and treat non-numerical arguments as 0, while large
  numerical arguments would be capped to the option's maximum permitted
  value.  Now, any failure to parse the argument, including overflow,
  results in the option being left unchanged.


    [6 lines not shown]
DeltaFile
+106-90lib/libc/resolv/res_init.c
+106-901 files

FreeBSD/src 22ee851include resolv.h

resolv.h: Remove unused parts

Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D57927

(cherry picked from commit 3f15998d25da08677d2c40bc2240de293aec4205)
DeltaFile
+0-49include/resolv.h
+0-491 files

FreeBSD/src 6d73486lib/libc/nameser ns_parse.c, lib/libc/resolv res_init.c res_comp.c

libc/resolv: Drop Solaris 2 compatibility

MFC after:      1 week
Reviewed by:    kevans, markj
Differential Revision:  https://reviews.freebsd.org/D57922

(cherry picked from commit aba9fffebf97d631f85e904813ff35ed031a3bac)
DeltaFile
+0-42lib/libc/resolv/res_init.c
+0-11lib/libc/resolv/res_comp.c
+0-5lib/libc/nameser/ns_parse.c
+0-583 files

FreeBSD/src 5bdba2eshare/man/man5 resolver.5

resolver(5): Overhaul

* Modernize the markup

* Describe the comment syntax

* Drop obsolete advice

* Capitalize sentences

* Improve the language

* Replace no_tld_query with no-tld-query; both are supported, but all the
  other multi-word options use hyphens rather than underscores.

* Add missing ENVIRONMENT section

* Redo the example


    [5 lines not shown]
DeltaFile
+116-111share/man/man5/resolver.5
+116-1111 files

FreeBSD/src c93f3b5lib/libutil getlocalbase.3 getlocalbase.c, lib/libutil/tests getlocalbase_test.c Makefile

libutil: Reimplement getlocalbase()

* Get rid of the pointless LOCALBASE_CTL_LEN mechanism

* Apply minimal normalization to the paths obtained from the environment
  or sysctl variable

* Turn the manual page into a manual page

* Add tests

MFC after:      1 week
Reviewed by:    se
Differential Revision:  https://reviews.freebsd.org/D58362
DeltaFile
+52-59lib/libutil/getlocalbase.3
+61-39lib/libutil/getlocalbase.c
+92-0lib/libutil/tests/getlocalbase_test.c
+1-0lib/libutil/tests/Makefile
+206-984 files

FreeBSD/src 134ddd3usr.bin/xinstall xinstall.c

install: Code cleanup

This is mainy focused on using bool for booleans but also renames some
variables for clarity, adds some explicit comparisons, adds some braces,
with miscellanous style fixes thrown in.

MFC after:      1 week
Reviewed by:    imp
Differential Revision:  https://reviews.freebsd.org/D58355
DeltaFile
+106-104usr.bin/xinstall/xinstall.c
+106-1041 files

FreeBSD/src d348707usr.bin/xinstall xinstall.c install.1, usr.bin/xinstall/tests install_test.sh

install: Allow installing stdin

If from_name is "/dev/stdin" or "-" and the target is not a directory,
skip the comparison and copy data from standard input to the target.

MFC after:      1 week
Reviewed by:    imp
Differential Revision:  https://reviews.freebsd.org/D58348
DeltaFile
+35-17usr.bin/xinstall/xinstall.c
+32-0usr.bin/xinstall/tests/install_test.sh
+6-1usr.bin/xinstall/install.1
+73-183 files

FreeBSD/src bd30d1asys/dev/nvme nvme_ns.c

nvme: Explicitly cast caddr_t values

Sponsored by:   Klara, Inc.
Sponsored by:   NetApp, Inc.
MFC after:      1 week
Fixes:          6d0001d44490 ("nvme: add support for DIOCGIDENT")
Reviewed by:    bnovkov, imp
Differential Revision:  https://reviews.freebsd.org/D58357
DeltaFile
+1-1sys/dev/nvme/nvme_ns.c
+1-11 files

FreeBSD/src 67518c9usr.sbin/wpa Makefile.inc, usr.sbin/wpa/src/utils Makefile

wpa: Define CONFIG_DEBUG_FILE globally

We defined CONFIG_DEBUG_FILE only in libwpautils, not in wpa_supplicant,
so all it did was enable code that never got called.  Enable it at the
top level so it also applies to wpa_supplicant(8), and the -f option
mentioned in the manual page now actually works.

PR:             281617
MFC after:      1 week
Reviewed by:    cy
Differential Revision:  https://reviews.freebsd.org/D57723
DeltaFile
+0-2usr.sbin/wpa/src/utils/Makefile
+1-0usr.sbin/wpa/Makefile.inc
+1-22 files

FreeBSD/src ff6574dtools/test/stress2/misc nullfs35.sh

stress2: Added a regression test
DeltaFile
+65-0tools/test/stress2/misc/nullfs35.sh
+65-01 files

FreeBSD/src 4dc01fetools/test/stress2/misc rename18.sh

stress2: Added a comment
DeltaFile
+1-0tools/test/stress2/misc/rename18.sh
+1-01 files

FreeBSD/src b11a605tools/test/stress2/misc all.exclude

stress2: Updated the exclude file
DeltaFile
+2-2tools/test/stress2/misc/all.exclude
+2-21 files

FreeBSD/src a048601usr.sbin/bhyve pci_nvme.c

bhyve: check upper bounds for value from qsz

The max_qentries in pci_nvme_softc is uint16_t and
too large int may get truncated to invalid value.
While there, use local declarations for val.

Suggested by: Bill Sommerfeld
Reviewed by:    chuck
Differential Revision:  https://reviews.freebsd.org/D58293
DeltaFile
+1-1usr.sbin/bhyve/pci_nvme.c
+1-11 files

FreeBSD/src 3811003sys/dev/ena ena.c

ena: Put taskqueues into correct domain if !RSS

When compiled without 'options RSS', the ena driver created taskqueues
using taskqueue_start_threads_cpuset passing a mask value of NULL,
both in the ena_setup_tx_resources path (for enqueues) and in the
ena_create_io_queues path (for the completion-processing).

In the default configuration, on most EC2 instances, this results in
taskqueues running in the right NUMA domain, but only by accident; in
non-default configurations (e.g. with with multiple EBS volumes
attached and associated NVMe taskqueues) the taskqueues may land in
the wrong NUMA domain even on instance types where the one-EBS-one-ENA
case produces the desired results.

Set (struct ena_que)->domain and use that to inform the choice of CPU
sets.  On a c8gn.48xlarge EC2 instance this doubles throughput on a
32-TCP-stream benchmark.

Reviewed by:    akiyano

    [5 lines not shown]
DeltaFile
+11-1sys/dev/ena/ena.c
+11-11 files

FreeBSD/src acee62fsys/dev/ena ena.c

ena: Put taskqueues into correct domain if !RSS

When compiled without 'options RSS', the ena driver created taskqueues
using taskqueue_start_threads_cpuset passing a mask value of NULL,
both in the ena_setup_tx_resources path (for enqueues) and in the
ena_create_io_queues path (for the completion-processing).

In the default configuration, on most EC2 instances, this results in
taskqueues running in the right NUMA domain, but only by accident; in
non-default configurations (e.g. with with multiple EBS volumes
attached and associated NVMe taskqueues) the taskqueues may land in
the wrong NUMA domain even on instance types where the one-EBS-one-ENA
case produces the desired results.

Set (struct ena_que)->domain and use that to inform the choice of CPU
sets.  On a c8gn.48xlarge EC2 instance this doubles throughput on a
32-TCP-stream benchmark.

Reviewed by:    akiyano

    [5 lines not shown]
DeltaFile
+11-1sys/dev/ena/ena.c
+11-11 files

FreeBSD/src eca7b25sys/kern sys_process.c

kern/sys_ptrace: do not skip P2_PTRACEREQ wait for PT_CLEARSTEP/PT_GET_CHILDREN

Reported and reviewed by:       markj
Fixes:  d3b7bbee9275 ("ptrace(2): add PT_GET_CHILDREN")
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D58364
DeltaFile
+16-17sys/kern/sys_process.c
+16-171 files