From a161269b2451140a45de2d0cae0dad84f9e7b439 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Thu, 11 Jul 2024 14:55:11 -0400 Subject: [PATCH 1/6] buf_ring: Make buf_ring.h amenable to userspace compilation This will be useful for adding test cases. Reviewed by: andrew MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D45869 --- sys/sys/buf_ring.h | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/sys/sys/buf_ring.h b/sys/sys/buf_ring.h index 32c9f5b15f22..cb18175c3a75 100644 --- a/sys/sys/buf_ring.h +++ b/sys/sys/buf_ring.h @@ -30,11 +30,18 @@ #ifndef _SYS_BUF_RING_H_ #define _SYS_BUF_RING_H_ +#include +#include +#include #include #ifdef DEBUG_BUFRING +#ifdef _KERNEL #include #include +#else +#error "DEBUG_BUFRING is only supported in kernel" +#endif #endif struct buf_ring { @@ -361,8 +368,36 @@ buf_ring_count(struct buf_ring *br) & br->br_prod_mask); } +#ifdef _KERNEL struct buf_ring *buf_ring_alloc(int count, struct malloc_type *type, int flags, struct mtx *); void buf_ring_free(struct buf_ring *br, struct malloc_type *type); +#else -#endif +#include + +static inline struct buf_ring * +buf_ring_alloc(int count) +{ + struct buf_ring *br; + + KASSERT(powerof2(count), ("buf ring must be size power of 2")); + + br = calloc(1, sizeof(struct buf_ring) + count * sizeof(void *)); + if (br == NULL) + return (NULL); + br->br_prod_size = br->br_cons_size = count; + br->br_prod_mask = br->br_cons_mask = count - 1; + br->br_prod_head = br->br_cons_head = 0; + br->br_prod_tail = br->br_cons_tail = 0; + return (br); +} + +static inline void +buf_ring_free(struct buf_ring *br) +{ + free(br); +} + +#endif /* !_KERNEL */ +#endif /* _SYS_BUF_RING_H_ */ From d68d124817780db5f98f65ae02a7ce286cd426eb Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Thu, 11 Jul 2024 15:19:42 -0400 Subject: [PATCH 2/6] arm: Add evdev to the TEGRA124 config This is required for the kernel to link after commit 13d00a43cba4. Fixes: 13d00a43cba4 ("conf: Add usbhid and hidbus to GENERIC* kernel configs") --- sys/arm/conf/TEGRA124 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/arm/conf/TEGRA124 b/sys/arm/conf/TEGRA124 index 6a39abf6cee4..058a85955a04 100644 --- a/sys/arm/conf/TEGRA124 +++ b/sys/arm/conf/TEGRA124 @@ -128,6 +128,11 @@ device drm2 #device sound #device snd_hda +# evdev interface +options EVDEV_SUPPORT # evdev support in legacy drivers +device evdev # input event device support +device uinput # install /dev/uinput cdev + # HID support device hid # Generic HID support device hidbus # Generic HID Bus From 7c2901b08b4e68c3fb0587003cf7e46335e24baa Mon Sep 17 00:00:00 2001 From: Joyu Liao Date: Thu, 11 Jul 2024 12:38:04 -0700 Subject: [PATCH 3/6] mountd: Add options to disable daemon mode and setting localhost In our products, we need those options to support our features. Add daemon mode option for mountd, nfsd. Add skip local host binding option for rpcd. Add skip local host binding option for mountd. Reviewed by: rmacklem Differential Revision: https://reviews.freebsd.org/D45118 --- usr.sbin/mountd/mountd.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c index 14693a922186..00293909614e 100644 --- a/usr.sbin/mountd/mountd.c +++ b/usr.sbin/mountd/mountd.c @@ -287,6 +287,8 @@ static int *sock_fd; static int sock_fdcnt; static int sock_fdpos; static int suspend_nfsd = 0; +static int nofork = 0; +static int skiplocalhost = 0; static int opt_flags; static int have_v6 = 1; @@ -436,7 +438,7 @@ main(int argc, char **argv) else close(s); - while ((c = getopt(argc, argv, "2Adeh:lnp:RrS")) != -1) + while ((c = getopt(argc, argv, "2Adeh:lNnp:RrSs")) != -1) switch (c) { case '2': force_v2 = 1; @@ -495,6 +497,12 @@ main(int argc, char **argv) case 'S': suspend_nfsd = 1; break; + case 'N': + nofork = 1; + break; + case 's': + skiplocalhost = 1; + break; default: usage(); } @@ -514,6 +522,9 @@ main(int argc, char **argv) } } + if (nhosts == 0 && skiplocalhost != 0) + warnx("-s without -h, ignored"); + if (modfind("nfsd") < 0) { /* Not present in kernel, try loading it */ if (kldload("nfsd") < 0 || modfind("nfsd") < 0) @@ -535,7 +546,7 @@ main(int argc, char **argv) get_mountlist(); if (debug) warnx("here we go"); - if (debug == 0) { + if (debug == 0 && nofork == 0) { daemon(0, 0); signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); @@ -571,7 +582,7 @@ main(int argc, char **argv) out_of_mem(); hosts[0] = "*"; nhosts = 1; - } else { + } else if (skiplocalhost == 0) { hosts_bak = hosts; if (have_v6) { hosts_bak = realloc(hosts, (nhosts + 2) * @@ -1111,8 +1122,8 @@ static void usage(void) { fprintf(stderr, - "usage: mountd [-2] [-d] [-e] [-l] [-n] [-p ] [-r] " - "[-S] [-h ] [export_file ...]\n"); + "usage: mountd [-2] [-d] [-e] [-l] [-N] [-n] [-p ] [-r] [-S] " + "[-s] [-h ] [export_file ...]\n"); exit(1); } From 8cd71a0e01d60cc4eb0cdef3c62556a516976b77 Mon Sep 17 00:00:00 2001 From: Ka Ho Ng Date: Thu, 11 Jul 2024 15:48:28 -0400 Subject: [PATCH 4/6] libfetch: parse IPv4address in IPv6address properly This fix parsing problems of IPv6 addresses which contains IPv4 addresses. One example is ::192.168.0.1. Documents are in below: https://datatracker.ietf.org/doc/html/rfc2373#page-22 Sponsored by: Juniper Networks, Inc. MFC after: 1 week Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D45896 --- lib/libfetch/fetch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c index df97bf486f9b..12cbd0fb746f 100644 --- a/lib/libfetch/fetch.c +++ b/lib/libfetch/fetch.c @@ -399,7 +399,7 @@ fetchParseURL(const char *URL) /* hostname */ if (*p == '[') { - q = p + 1 + strspn(p + 1, ":0123456789ABCDEFabcdef"); + q = p + 1 + strspn(p + 1, ":0123456789ABCDEFabcdef."); if (*q++ != ']') goto ouch; } else { From 2e5c9eaf5728dd96ce456f6fab18c50c0dfb5f5c Mon Sep 17 00:00:00 2001 From: Joyu Liao Date: Thu, 11 Jul 2024 12:48:31 -0700 Subject: [PATCH 5/6] mountd.8: Update the man page for -N and -s Commit 7c2901b08b4e added new command line options "-N" and "-s". This patch updates the man page for this. This is a content change. Reviewed by: Alexander Ziaee (manpages) Differential Revision: https://reviews.freebsd.org/D45118 --- usr.sbin/mountd/mountd.8 | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/usr.sbin/mountd/mountd.8 b/usr.sbin/mountd/mountd.8 index 6528aa3c94a1..5c5717063f15 100644 --- a/usr.sbin/mountd/mountd.8 +++ b/usr.sbin/mountd/mountd.8 @@ -25,7 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd April 8, 2024 +.Dd July 5, 2024 .Dt MOUNTD 8 .Os .Sh NAME @@ -35,7 +35,7 @@ mount requests .Sh SYNOPSIS .Nm -.Op Fl 2AdelnRrS +.Op Fl 2AdelNnRrSs .Op Fl h Ar bindip .Op Fl p Ar port .Op Ar exportsfile ... @@ -98,6 +98,10 @@ to the list. Cause all succeeded .Nm requests to be logged. +.It Fl N +Cause +.Nm +to execute in the foreground instead of in daemon mode. .It Fl n Allow non-root mount requests to be served. This should only be specified if there are clients such as PC's, @@ -158,6 +162,13 @@ crashes while an exports load is in progress, .Nm must be restarted to get the nfsd threads running again, if this option is used. +.It Fl s +Cause +.Nm +to skip automatic binding to localhost for IPv4 and IPv6. +This option is meaningless unless +.Fl h +has also been used. .El .Pp When From bae19029ad2a187f6daca727ba5343f319048917 Mon Sep 17 00:00:00 2001 From: Rick Macklem Date: Thu, 11 Jul 2024 13:03:42 -0700 Subject: [PATCH 6/6] rpcbind.8: Fix missing option entry in commit df3f247e4696 Commit df3f247e4696 added descriptions for the new command line option "-I". However, it failed to update the .Op line. This is a content change. Reviewed by: Alexander Ziaee (manpages) Differential Revision: https://reviews.freebsd.org/D45118 --- usr.sbin/rpcbind/rpcbind.8 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/rpcbind/rpcbind.8 b/usr.sbin/rpcbind/rpcbind.8 index 1dd145f945f4..36c7a8da9984 100644 --- a/usr.sbin/rpcbind/rpcbind.8 +++ b/usr.sbin/rpcbind/rpcbind.8 @@ -1,6 +1,6 @@ .\" Copyright 1989 AT&T .\" Copyright 1991 Sun Microsystems, Inc. -.Dd July 5, 2024 +.Dd July 11, 2024 .Dt RPCBIND 8 .Os .Sh NAME @@ -8,7 +8,7 @@ .Nd universal addresses to RPC program number mapper .Sh SYNOPSIS .Nm -.Op Fl 6adiLlNswW +.Op Fl 6adIiLlNswW .Op Fl h Ar bindip .Sh DESCRIPTION The