svn commit: r359818 - head/sys/kern
Author: kib Date: Sun Apr 12 05:10:48 2020 New Revision: 359818 URL: https://svnweb.freebsd.org/changeset/base/359818 Log: sendfile_iodone: correct calculation of the page index for relookup. This is yet another bug in r359473. Reported and tested by: delphij Sponsored by: The FreeBSD Foundation MFC after:2 weeks Modified: head/sys/kern/kern_sendfile.c Modified: head/sys/kern/kern_sendfile.c == --- head/sys/kern/kern_sendfile.c Sun Apr 12 03:10:29 2020 (r359817) +++ head/sys/kern/kern_sendfile.c Sun Apr 12 05:10:48 2020 (r359818) @@ -298,7 +298,7 @@ sendfile_iodone(void *arg, vm_page_t *pa, int count, i for (i = 0; i < count; i++) { if (pa[i] == bogus_page) { pa[i] = vm_page_relookup(sfio->obj, - sfio->pindex0 + i + (sfio->pa - pa)); + sfio->pindex0 + i + (pa - sfio->pa)); KASSERT(pa[i] != NULL, ("%s: page %p[%d] disappeared", __func__, pa, i)); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359815 - head/usr.sbin/config
Author: jah Date: Sun Apr 12 02:42:42 2020 New Revision: 359815 URL: https://svnweb.freebsd.org/changeset/base/359815 Log: config(8): use sbuf to manage line buffers PR: 245476 Reported by: kevans Reviewed by: imp, kevans MFC after:1 week Differential Revision:https://reviews.freebsd.org/D24373 Modified: head/usr.sbin/config/main.c Modified: head/usr.sbin/config/main.c == --- head/usr.sbin/config/main.c Sun Apr 12 01:03:13 2020(r359814) +++ head/usr.sbin/config/main.c Sun Apr 12 02:42:42 2020(r359815) @@ -113,6 +113,8 @@ struct hdr_list { struct hdr_list *h_next; } *htab; +static struct sbuf *line_buf = NULL; + /* * Config builds a set of files for building a UNIX * system given a description of the desired system. @@ -313,6 +315,29 @@ usage(void) exit(EX_USAGE); } +static void +init_line_buf(void) +{ + if (line_buf == NULL) { + line_buf = sbuf_new(NULL, NULL, 80, SBUF_AUTOEXTEND); + if (line_buf == NULL) { + errx(EXIT_FAILURE, "failed to allocate line buffer"); + } + } else { + sbuf_clear(line_buf); + } +} + +static char * +get_line_buf(void) +{ + if (sbuf_finish(line_buf) != 0) { + errx(EXIT_FAILURE, "failed to generate line buffer, " + "partial line = %s", sbuf_data(line_buf)); + } + return sbuf_data(line_buf); +} + /* * get_word * returns EOF on end of file @@ -322,11 +347,10 @@ usage(void) char * get_word(FILE *fp) { - static char line[160]; int ch; - char *cp; int escaped_nl = 0; + init_line_buf(); begin: while ((ch = getc(fp)) != EOF) if (ch != ' ' && ch != '\t') @@ -345,29 +369,20 @@ begin: else return (NULL); } - cp = line; - *cp++ = ch; + sbuf_putc(line_buf, ch); /* Negation operator is a word by itself. */ if (ch == '!') { - *cp = 0; - return (line); + return get_line_buf(); } - while ((ch = getc(fp)) != EOF && cp < line + sizeof(line)) { + while ((ch = getc(fp)) != EOF) { if (isspace(ch)) break; - *cp++ = ch; + sbuf_putc(line_buf, ch); } - if (cp >= line + sizeof(line)) { - line[sizeof(line) - 1] = '\0'; - fprintf(stderr, "config: attempted overflow, partial line: `%s'", - line); - exit(2); - } - *cp = 0; if (ch == EOF) return ((char *)EOF); (void) ungetc(ch, fp); - return (line); + return (get_line_buf()); } /* @@ -378,11 +393,10 @@ begin: char * get_quoted_word(FILE *fp) { - static char line[512]; int ch; - char *cp; int escaped_nl = 0; + init_line_buf(); begin: while ((ch = getc(fp)) != EOF) if (ch != ' ' && ch != '\t') @@ -401,7 +415,6 @@ begin: else return (NULL); } - cp = line; if (ch == '"' || ch == '\'') { int quote = ch; @@ -410,9 +423,8 @@ begin: if (ch == quote && !escaped_nl) break; if (ch == '\n' && !escaped_nl) { - *cp = 0; printf("config: missing quote reading `%s'\n", - line); + get_line_buf()); exit(2); } if (ch == '\\' && !escaped_nl) { @@ -420,38 +432,23 @@ begin: continue; } if (ch != quote && escaped_nl) - *cp++ = '\\'; - if (cp >= line + sizeof(line)) { - line[sizeof(line) - 1] = '\0'; - printf( - "config: line buffer overflow reading partial line `%s'\n", - line); - exit(2); - } - *cp++ = ch; + sbuf_putc(line_buf, '\\'); + sbuf_putc(line_buf, ch); escaped_nl = 0; } } else { - *cp++ = ch; - while ((ch = getc(fp)) != EOF && cp < line + sizeof(line)) { + sbuf_putc(line_buf, ch); + while ((ch = getc(fp)) != EOF) { if (isspace(ch)) break; - *cp++ = ch; +
svn commit: r359811 - in head/sys/fs: nfs nfsclient
Author: rmacklem Date: Sat Apr 11 23:37:58 2020 New Revision: 359811 URL: https://svnweb.freebsd.org/changeset/base/359811 Log: Replace mbuf macros with the code they would generate in the NFS code. When the code was ported to Mac OS/X, mbuf handling functions were converted to using the Mac OS/X accessor functions. For FreeBSD, they are a simple set of macros in sys/fs/nfs/nfskpiport.h. Since porting to Mac OS/X is no longer a consideration, replacement of these macros with the code generated by them makes the code more readable. When support for external page mbufs is added as needed by the KERN_TLS, the patch becomes simpler if done without the macros. This patch should not result in any semantic change. This is the final patch of this series and the macros should now be able to be deleted from the .h files in a future commit. Modified: head/sys/fs/nfs/nfs_commonkrpc.c head/sys/fs/nfsclient/nfs_clrpcops.c Modified: head/sys/fs/nfs/nfs_commonkrpc.c == --- head/sys/fs/nfs/nfs_commonkrpc.cSat Apr 11 20:57:15 2020 (r359810) +++ head/sys/fs/nfs/nfs_commonkrpc.cSat Apr 11 23:37:58 2020 (r359811) @@ -893,7 +893,7 @@ tryagain: */ newnfs_realign(>nd_mrep, M_WAITOK); nd->nd_md = nd->nd_mrep; - nd->nd_dpos = NFSMTOD(nd->nd_md, caddr_t); + nd->nd_dpos = mtod(nd->nd_md, caddr_t); nd->nd_repstat = 0; if (nd->nd_procnum != NFSPROC_NULL && nd->nd_procnum != NFSV4PROC_CBNULL) { Modified: head/sys/fs/nfsclient/nfs_clrpcops.c == --- head/sys/fs/nfsclient/nfs_clrpcops.cSat Apr 11 20:57:15 2020 (r359810) +++ head/sys/fs/nfsclient/nfs_clrpcops.cSat Apr 11 23:37:58 2020 (r359811) @@ -238,7 +238,7 @@ nfsrpc_null(vnode_t vp, struct ucred *cred, NFSPROC_T error = nfscl_request(nd, vp, p, cred, NULL); if (nd->nd_repstat && !error) error = nd->nd_repstat; - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); return (error); } @@ -344,7 +344,7 @@ nfsrpc_accessrpc(vnode_t vp, u_int32_t mode, struct uc } else error = nd->nd_repstat; nfsmout: - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); return (error); } @@ -679,7 +679,7 @@ nfsmout: *dpp = ndp; else if (ndp != NULL) free(ndp, M_NFSCLDELEG); - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); return (error); } @@ -722,7 +722,7 @@ nfsrpc_opendowngrade(vnode_t vp, u_int32_t mode, struc if (error == NFSERR_STALESTATEID) nfscl_initiate_recovery(op->nfso_own->nfsow_clp); nfsmout: - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); return (error); } @@ -880,7 +880,7 @@ nfsrpc_closerpc(struct nfsrv_descript *nd, struct nfsm if (error == NFSERR_STALESTATEID) nfscl_initiate_recovery(op->nfso_own->nfsow_clp); nfsmout: - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); return (error); } @@ -922,7 +922,7 @@ nfsrpc_openconfirm(vnode_t vp, u_int8_t *nfhp, int fhl if (error == NFSERR_STALESTATEID) nfscl_initiate_recovery(op->nfso_own->nfsow_clp); nfsmout: - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); return (error); } @@ -1077,7 +1077,7 @@ nfsrpc_setclient(struct nfsmount *nmp, struct nfsclcli tsep->nfsess_clientid.lval[1] = *tl++; confirm.lval[0] = *tl++; confirm.lval[1] = *tl; - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); nd->nd_mrep = NULL; /* @@ -1095,7 +1095,7 @@ nfsrpc_setclient(struct nfsmount *nmp, struct nfsclcli cred, NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL); if (error) return (error); - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); nd->nd_mrep = NULL; if (nd->nd_repstat == 0) { nfscl_reqstart(nd, NFSPROC_GETATTR, nmp, nmp->nm_fh, @@ -1123,7 +1123,7 @@ nfsrpc_setclient(struct nfsmount *nmp, struct nfsclcli } error = nd->nd_repstat; nfsmout: - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); return (error); } @@ -1150,7 +1150,7 @@ nfsrpc_getattr(vnode_t vp, struct ucred *cred, NFSPROC error = nfsm_loadattr(nd, nap); else error = nd->nd_repstat; - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); return (error); } @@ -1190,7 +1190,7 @@ nfsrpc_getattrnovp(struct nfsmount *nmp, u_int8_t *fhp error = nfsm_loadattr(nd, nap); } else error = nd->nd_repstat; - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); return
Re: svn commit: r359797 - in head/sys: net netinet netinet6
11.04.2020, 21:58, "Ian Lepore" : > On Sat, 2020-04-11 at 13:02 -0700, Conrad Meyer wrote: >> Hi Alexander, >> >> On Sat, Apr 11, 2020 at 12:37 AM Alexander V. Chernikov >> wrote: >> > >> > Author: melifaro >> > Date: Sat Apr 11 07:37:08 2020 >> > New Revision: 359797 >> > URL: https://svnweb.freebsd.org/changeset/base/359797 >> > >> > Log: >> > Remove per-AF radix_mpath initializtion functions. >> > >> > Split their functionality by moving random seed allocation >> > to SYSINIT and calling (new) generic multipath function from >> > standard IPv4/IPv5 RIB init handlers. >> > ... >> > --- head/sys/net/radix_mpath.c Sat Apr 11 07:31:16 >> > 2020 (r359796) >> > +++ head/sys/net/radix_mpath.c Sat Apr 11 07:37:08 >> > 2020 (r359797) >> > @@ -290,38 +290,18 @@ rtalloc_mpath_fib(struct route *ro, uint32_t >> > hash, u_i >> > ... >> > +static void >> > +mpath_init(void) >> > { >> > - struct rib_head *rnh; >> > >> > hashjitter = arc4random(); >> > - if (in6_inithead(head, off, fibnum) == 1) { >> > - rnh = (struct rib_head *)*head; >> > - rnh->rnh_multipath = 1; >> > - return 1; >> > - } else >> > - return 0; >> > } >> > +SYSINIT(mpath_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY, mpath_init, >> > NULL); >> >> This is pretty early in boot to be asking for random numbers. We >> don't have interrupts yet, for example. If the system doesn't have a >> saved /boot/entropy loaded (PPC, or installer, or some other embedded >> system perhaps), we will either deadlock boot or get not especially >> random numbers here (depending on availability behavior of arc4random >> — currently we err on the side of low quality random numbers). >> >> If this number is predictable to an attacker, is it easier to DoS the >> system? Do we need the random number before userspace starts? (I >> would imagine networking does not really start chatting with remote >> hosts prior to userspace boot, but this is just a guess.) >> >> Best, >> Conrad > > I believe the earliest use of networking during boot is for mounting > the rootfs using nfs. So SI_SUB_ROOT_CONF-1 might be good. Yep, that's a good one. Generally you're right. In this particular case, this random value is only used when we have multiple paths to a particular destination. Such configuraition implies having either routing daemon up, or static route(8) configuration applied, which will happen at least after SI_SUB_KTHREAD_INIT. With all this in mind I'm thinking of moving it to the SI_SUB_LAST to increase the chance of getting good entropy. Does this sound good to you? > > -- Ian ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r359797 - in head/sys: net netinet netinet6
11.04.2020, 22:28, "Conrad Meyer" : > On Sat, Apr 11, 2020 at 1:45 PM Alexander V. Chernikov > wrote: >> This number only affects selection of the outbound path in presence of >> multiple paths available for the same prefix. It means to mitigate hash >> polarization in the network ( >> https://www.cisco.com/c/en/us/support/docs/ip/express-forwarding-cef/116376-technote-cef-00.html >> contains somewhat relevant description). >> I don't think it that knowing the number make DoSing of the particular >> system easier. > > Thanks! Does it need to be stable over time, or would it be > acceptable to be updated at some point? If "at some point" means "after N hours/days" than the short answer is no. In the multi-layer CLOS-like networks people usually try to reduce the amount of churn, even in presence of some failures. Changing that number results in increased randomness around the traffic flow, which doesn't bring any obvious benefit. I could potentially imagine user being able to override the number, but typically vendors don't do that. > >> However, better quality randomness is always good. >> Speaking of "when" it is needed - you're right, it is needed pretty late in >> the boot process, after the userland starts. >> Will moving the order to SI_SUB_LAST help or I need to trigger number >> generation by different means? > > SI_SUB_LAST is better, sure. If you want to ensure you eventually get > a random number, and changing the number at runtime is acceptable, you > could have userspace induce seeding. But maybe that is unnecessarily Yep, that's a tradeoff between the ideal solution and implementation complexity. I was thinking of an approach when first rtsock connection triggers this generation, but that looks a bit ugly. If we have a good change to get somewhat decent entropy at SI_SUB_LAST, then I guess that's "good enough". > complex. Typical x86 systems using loader will have good entropy > available already at this point, outside of the installer or if there > is /boot corruption. > > (It sounds like this application would be fine with not really random > numbers, at least early in boot. We don't have a great API for that > need today, unfortunately.) Yep, for this value to be used, one need to install multipath route towards particular destination and it has to be actually used by the outbound traffic. Even if it is, nothing exceptionally bad will happen event with 0 value. > > Cheers, > Conrad ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r359809 - head/sys/netinet
Hi Michael, On Sat, Apr 11, 2020 at 1:37 PM Michael Tuexen wrote: > > Author: tuexen > Date: Sat Apr 11 20:36:54 2020 > New Revision: 359809 > URL: https://svnweb.freebsd.org/changeset/base/359809 > > Log: > Zero out pointers for consistency. > > This was found by running syzkaller on an INVARIANTS kernel. For consistency? If syzkaller found something due to INVARIANTS sys/queue.h debugging trashing the pointer values, masking them by writing zeroes doesn't help. Generally, defeating the kernel's INVARIANTS system is not wise or useful. In this use, consider using 'TAILQ_CONCAT(>asoc.strmout[i].outqueue, [i].outqueue, next)' instead of the loop construct. Conrad ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r359797 - in head/sys: net netinet netinet6
On Sat, Apr 11, 2020 at 1:45 PM Alexander V. Chernikov wrote: > This number only affects selection of the outbound path in presence of > multiple paths available for the same prefix. It means to mitigate hash > polarization in the network ( > https://www.cisco.com/c/en/us/support/docs/ip/express-forwarding-cef/116376-technote-cef-00.html > contains somewhat relevant description). > I don't think it that knowing the number make DoSing of the particular system > easier. Thanks! Does it need to be stable over time, or would it be acceptable to be updated at some point? > However, better quality randomness is always good. > Speaking of "when" it is needed - you're right, it is needed pretty late in > the boot process, after the userland starts. > Will moving the order to SI_SUB_LAST help or I need to trigger number > generation by different means? SI_SUB_LAST is better, sure. If you want to ensure you eventually get a random number, and changing the number at runtime is acceptable, you could have userspace induce seeding. But maybe that is unnecessarily complex. Typical x86 systems using loader will have good entropy available already at this point, outside of the installer or if there is /boot corruption. (It sounds like this application would be fine with not really random numbers, at least early in boot. We don't have a great API for that need today, unfortunately.) Cheers, Conrad ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r359797 - in head/sys: net netinet netinet6
On Sat, 2020-04-11 at 13:02 -0700, Conrad Meyer wrote: > Hi Alexander, > > On Sat, Apr 11, 2020 at 12:37 AM Alexander V. Chernikov > wrote: > > > > Author: melifaro > > Date: Sat Apr 11 07:37:08 2020 > > New Revision: 359797 > > URL: https://svnweb.freebsd.org/changeset/base/359797 > > > > Log: > > Remove per-AF radix_mpath initializtion functions. > > > > Split their functionality by moving random seed allocation > >to SYSINIT and calling (new) generic multipath function from > >standard IPv4/IPv5 RIB init handlers. > > ... > > --- head/sys/net/radix_mpath.c Sat Apr 11 07:31:16 > > 2020(r359796) > > +++ head/sys/net/radix_mpath.c Sat Apr 11 07:37:08 > > 2020(r359797) > > @@ -290,38 +290,18 @@ rtalloc_mpath_fib(struct route *ro, uint32_t > > hash, u_i > > ... > > +static void > > +mpath_init(void) > > { > > - struct rib_head *rnh; > > > > hashjitter = arc4random(); > > - if (in6_inithead(head, off, fibnum) == 1) { > > - rnh = (struct rib_head *)*head; > > - rnh->rnh_multipath = 1; > > - return 1; > > - } else > > - return 0; > > } > > +SYSINIT(mpath_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY, mpath_init, > > NULL); > > This is pretty early in boot to be asking for random numbers. We > don't have interrupts yet, for example. If the system doesn't have a > saved /boot/entropy loaded (PPC, or installer, or some other embedded > system perhaps), we will either deadlock boot or get not especially > random numbers here (depending on availability behavior of arc4random > — currently we err on the side of low quality random numbers). > > If this number is predictable to an attacker, is it easier to DoS the > system? Do we need the random number before userspace starts? (I > would imagine networking does not really start chatting with remote > hosts prior to userspace boot, but this is just a guess.) > > Best, > Conrad > I believe the earliest use of networking during boot is for mounting the rootfs using nfs. So SI_SUB_ROOT_CONF-1 might be good. -- Ian ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359810 - in head/sys/fs: nfs nfsserver
Author: rmacklem Date: Sat Apr 11 20:57:15 2020 New Revision: 359810 URL: https://svnweb.freebsd.org/changeset/base/359810 Log: Replace mbuf macros with the code they would generate in the NFS code. When the code was ported to Mac OS/X, mbuf handling functions were converted to using the Mac OS/X accessor functions. For FreeBSD, they are a simple set of macros in sys/fs/nfs/nfskpiport.h. Since porting to Mac OS/X is no longer a consideration, replacement of these macros with the code generated by them makes the code more readable. When support for external page mbufs is added as needed by the KERN_TLS, the patch becomes simpler if done without the macros. This patch should not result in any semantic change. Modified: head/sys/fs/nfs/nfs_commonkrpc.c head/sys/fs/nfs/nfsm_subs.h head/sys/fs/nfsserver/nfs_nfsdcache.c head/sys/fs/nfsserver/nfs_nfsdport.c head/sys/fs/nfsserver/nfs_nfsdserv.c head/sys/fs/nfsserver/nfs_nfsdstate.c Modified: head/sys/fs/nfs/nfs_commonkrpc.c == --- head/sys/fs/nfs/nfs_commonkrpc.cSat Apr 11 20:36:54 2020 (r359809) +++ head/sys/fs/nfs/nfs_commonkrpc.cSat Apr 11 20:57:15 2020 (r359810) @@ -1188,8 +1188,8 @@ tryagain: newnfs_restore_sigmask(td, ); return (0); nfsmout: - mbuf_freem(nd->nd_mrep); - mbuf_freem(nd->nd_mreq); + m_freem(nd->nd_mrep); + m_freem(nd->nd_mreq); if (usegssname == 0) AUTH_DESTROY(auth); if (rep != NULL) Modified: head/sys/fs/nfs/nfsm_subs.h == --- head/sys/fs/nfs/nfsm_subs.h Sat Apr 11 20:36:54 2020(r359809) +++ head/sys/fs/nfs/nfsm_subs.h Sat Apr 11 20:57:15 2020(r359810) @@ -68,8 +68,8 @@ nfsm_build(struct nfsrv_descript *nd, int siz) NFSMCLGET(mb2, M_NOWAIT); if (siz > MLEN) panic("build > MLEN"); - mbuf_setlen(mb2, 0); - nd->nd_bpos = NFSMTOD(mb2, caddr_t); + mb2->m_len = 0; + nd->nd_bpos = mtod(mb2, caddr_t); nd->nd_mb->m_next = mb2; nd->nd_mb = mb2; } @@ -87,7 +87,7 @@ nfsm_dissect(struct nfsrv_descript *nd, int siz) int tt1; void *retp; - tt1 = NFSMTOD(nd->nd_md, caddr_t) + nd->nd_md->m_len - nd->nd_dpos; + tt1 = mtod(nd->nd_md, caddr_t) + nd->nd_md->m_len - nd->nd_dpos; if (tt1 >= siz) { retp = (void *)nd->nd_dpos; nd->nd_dpos += siz; @@ -103,7 +103,7 @@ nfsm_dissect_nonblock(struct nfsrv_descript *nd, int s int tt1; void *retp; - tt1 = NFSMTOD(nd->nd_md, caddr_t) + nd->nd_md->m_len - nd->nd_dpos; + tt1 = mtod(nd->nd_md, caddr_t) + nd->nd_md->m_len - nd->nd_dpos; if (tt1 >= siz) { retp = (void *)nd->nd_dpos; nd->nd_dpos += siz; Modified: head/sys/fs/nfsserver/nfs_nfsdcache.c == --- head/sys/fs/nfsserver/nfs_nfsdcache.c Sat Apr 11 20:36:54 2020 (r359809) +++ head/sys/fs/nfsserver/nfs_nfsdcache.c Sat Apr 11 20:57:15 2020 (r359810) @@ -486,7 +486,7 @@ nfsrvd_updatecache(struct nfsrv_descript *nd) mtx_unlock(mutex); nd->nd_repstat = 0; if (nd->nd_mreq) - mbuf_freem(nd->nd_mreq); + m_freem(nd->nd_mreq); if (!(rp->rc_flag & RC_REPMBUF)) panic("reply from cache"); nd->nd_mreq = m_copym(rp->rc_reply, 0, @@ -798,7 +798,7 @@ nfsrc_freecache(struct nfsrvcache *rp) } nfsrc_wanted(rp); if (rp->rc_flag & RC_REPMBUF) { - mbuf_freem(rp->rc_reply); + m_freem(rp->rc_reply); if (!(rp->rc_flag & RC_UDP)) atomic_add_int(_tcpsavedreplies, -1); } @@ -1020,8 +1020,8 @@ nfsrc_getlenandcksum(mbuf_t m1, u_int16_t *cksum) m = m1; while (m) { - len += mbuf_len(m); - m = mbuf_next(m); + len += m->m_len; + m = m->m_next; } cklen = (len > NFSRVCACHE_CHECKLEN) ? NFSRVCACHE_CHECKLEN : len; *cksum = in_cksum(m1, cklen); Modified: head/sys/fs/nfsserver/nfs_nfsdport.c == --- head/sys/fs/nfsserver/nfs_nfsdport.cSat Apr 11 20:36:54 2020 (r359809) +++ head/sys/fs/nfsserver/nfs_nfsdport.cSat Apr 11 20:57:15 2020 (r359810) @@ -903,18 +903,18 @@ nfsrv_createiovecw(int retlen, struct mbuf *m, char *c cnt = 0; len = retlen; mp = m; - i = mtod(mp, caddr_t) + mbuf_len(mp) - cp; + i = mtod(mp, caddr_t) +
Re: svn commit: r359797 - in head/sys: net netinet netinet6
11.04.2020, 21:02, "Conrad Meyer" : > Hi Alexander, Hi Conrad, > > On Sat, Apr 11, 2020 at 12:37 AM Alexander V. Chernikov > wrote: >> Author: melifaro >> Date: Sat Apr 11 07:37:08 2020 >> New Revision: 359797 >> URL: https://svnweb.freebsd.org/changeset/base/359797 >> >> Log: >> Remove per-AF radix_mpath initializtion functions. >> >> Split their functionality by moving random seed allocation >> to SYSINIT and calling (new) generic multipath function from >> standard IPv4/IPv5 RIB init handlers. >> ... >> --- head/sys/net/radix_mpath.c Sat Apr 11 07:31:16 2020 (r359796) >> +++ head/sys/net/radix_mpath.c Sat Apr 11 07:37:08 2020 (r359797) >> @@ -290,38 +290,18 @@ rtalloc_mpath_fib(struct route *ro, uint32_t hash, u_i >> ... >> +static void >> +mpath_init(void) >> { >> - struct rib_head *rnh; >> >> hashjitter = arc4random(); >> - if (in6_inithead(head, off, fibnum) == 1) { >> - rnh = (struct rib_head *)*head; >> - rnh->rnh_multipath = 1; >> - return 1; >> - } else >> - return 0; >> } >> +SYSINIT(mpath_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY, mpath_init, NULL); > > This is pretty early in boot to be asking for random numbers. We > don't have interrupts yet, for example. If the system doesn't have a > saved /boot/entropy loaded (PPC, or installer, or some other embedded > system perhaps), we will either deadlock boot or get not especially > random numbers here (depending on availability behavior of arc4random > — currently we err on the side of low quality random numbers). Got it, that's a good datapoint! > > If this number is predictable to an attacker, is it easier to DoS the > system? Do we need the random number before userspace starts? (I > would imagine networking does not really start chatting with remote > hosts prior to userspace boot, but this is just a guess.) This number only affects selection of the outbound path in presence of multiple paths available for the same prefix. It means to mitigate hash polarization in the network ( https://www.cisco.com/c/en/us/support/docs/ip/express-forwarding-cef/116376-technote-cef-00.html contains somewhat relevant description). I don't think it that knowing the number make DoSing of the particular system easier. However, better quality randomness is always good. Speaking of "when" it is needed - you're right, it is needed pretty late in the boot process, after the userland starts. Will moving the order to SI_SUB_LAST help or I need to trigger number generation by different means? > > Best, > Conrad ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359809 - head/sys/netinet
Author: tuexen Date: Sat Apr 11 20:36:54 2020 New Revision: 359809 URL: https://svnweb.freebsd.org/changeset/base/359809 Log: Zero out pointers for consistency. This was found by running syzkaller on an INVARIANTS kernel. MFC after:3 days Modified: head/sys/netinet/sctp_output.c Modified: head/sys/netinet/sctp_output.c == --- head/sys/netinet/sctp_output.c Sat Apr 11 17:54:35 2020 (r359808) +++ head/sys/netinet/sctp_output.c Sat Apr 11 20:36:54 2020 (r359809) @@ -12275,6 +12275,8 @@ sctp_send_str_reset_req(struct sctp_tcb *stcb, /* now anything on those queues? */ TAILQ_FOREACH_SAFE(sp, [i].outqueue, next, nsp) { TAILQ_REMOVE([i].outqueue, sp, next); + sp->ss_next.tqe_next = NULL; + sp->ss_next.tqe_prev = NULL; TAILQ_INSERT_TAIL(>asoc.strmout[i].outqueue, sp, next); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r359797 - in head/sys: net netinet netinet6
Hi Alexander, On Sat, Apr 11, 2020 at 12:37 AM Alexander V. Chernikov wrote: > > Author: melifaro > Date: Sat Apr 11 07:37:08 2020 > New Revision: 359797 > URL: https://svnweb.freebsd.org/changeset/base/359797 > > Log: > Remove per-AF radix_mpath initializtion functions. > > Split their functionality by moving random seed allocation >to SYSINIT and calling (new) generic multipath function from >standard IPv4/IPv5 RIB init handlers. > ... > --- head/sys/net/radix_mpath.c Sat Apr 11 07:31:16 2020(r359796) > +++ head/sys/net/radix_mpath.c Sat Apr 11 07:37:08 2020(r359797) > @@ -290,38 +290,18 @@ rtalloc_mpath_fib(struct route *ro, uint32_t hash, u_i > ... > +static void > +mpath_init(void) > { > - struct rib_head *rnh; > > hashjitter = arc4random(); > - if (in6_inithead(head, off, fibnum) == 1) { > - rnh = (struct rib_head *)*head; > - rnh->rnh_multipath = 1; > - return 1; > - } else > - return 0; > } > +SYSINIT(mpath_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY, mpath_init, NULL); This is pretty early in boot to be asking for random numbers. We don't have interrupts yet, for example. If the system doesn't have a saved /boot/entropy loaded (PPC, or installer, or some other embedded system perhaps), we will either deadlock boot or get not especially random numbers here (depending on availability behavior of arc4random — currently we err on the side of low quality random numbers). If this number is predictable to an attacker, is it easier to DoS the system? Do we need the random number before userspace starts? (I would imagine networking does not really start chatting with remote hosts prior to userspace boot, but this is just a guess.) Best, Conrad ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359808 - in head/cddl/contrib/opensolaris: cmd/zfs lib/libzfs/common
Author: oshogbo Date: Sat Apr 11 17:54:35 2020 New Revision: 359808 URL: https://svnweb.freebsd.org/changeset/base/359808 Log: zfs: Add option for forcible unmounting dataset while receiving snapshot. Currently when the dataset is in use we can't receive snapshots. zfs send test/1@asd | zfs recv -FM test/2 cannot unmount '/test/2': Device busy This commits add option 'M' which attempts to forcibly unmount the dataset. Thanks to this we can enforce receiving snapshots in a single step. Note that this functionality is not supported on Linux because the VFS will prevent active mounted filesystems from being unmounted, even with the force option. This is the intended VFS behavior. Discussed-with: Pawel Jakub Dawidek Reviewed-by: Ryan Moeller Reviewed-by: Brian Behlendorf Reviewed-by: Allan Jude Differential Revision:https://reviews.freebsd.org/D22306 openzfs/zfs@a57d3d45d6efdff935421e2ef3f97e3dc089d93d Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs.8 head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs.8 == --- head/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Sat Apr 11 17:30:33 2020 (r359807) +++ head/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Sat Apr 11 17:54:35 2020 (r359808) @@ -32,7 +32,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 16, 2019 +.Dd February 16, 2020 .Dt ZFS 8 .Os .Sh NAME @@ -201,12 +201,12 @@ .Fl t Ar receive_resume_token .Nm .Cm receive Ns | Ns Cm recv -.Op Fl vnsFu +.Op Fl vnsFMu .Op Fl o Sy origin Ns = Ns Ar snapshot .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot .Nm .Cm receive Ns | Ns Cm recv -.Op Fl vnsFu +.Op Fl vnsFMu .Op Fl d | e .Op Fl o Sy origin Ns = Ns Ar snapshot .Ar filesystem @@ -2909,14 +2909,14 @@ for more details. .It Xo .Nm .Cm receive Ns | Ns Cm recv -.Op Fl vnsFu +.Op Fl vnsFMu .Op Fl o Sy origin Ns = Ns Ar snapshot .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot .Xc .It Xo .Nm .Cm receive Ns | Ns Cm recv -.Op Fl vnsFu +.Op Fl vnsFMu .Op Fl d | e .Op Fl o Sy origin Ns = Ns Ar snapshot .Ar filesystem @@ -3016,6 +3016,9 @@ performing the receive operation. If receiving an incr stream (for example, one generated by .Qq Nm Cm send Fl R Bro Fl i | Fl I Brc ) , destroy snapshots and file systems that do not exist on the sending side. +.It Fl M +Force an unmount of the file system while receiving a snapshot. +This option is not supported on Linux. .It Fl s If the receive is interrupted, save the partially received state, rather than deleting it. Interruption may be due to premature termination of Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c == --- head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.cSat Apr 11 17:30:33 2020(r359807) +++ head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.cSat Apr 11 17:54:35 2020(r359808) @@ -274,9 +274,9 @@ get_usage(zfs_help_t idx) case HELP_PROMOTE: return (gettext("\tpromote \n")); case HELP_RECEIVE: - return (gettext("\treceive|recv [-vnsFu] \n" - "\treceive|recv [-vnsFu] [-o origin=] [-d | -e] " + "\treceive|recv [-vnsFMu] [-o origin=] [-d | -e] " "\n" "\treceive|recv -A \n")); case HELP_RENAME: @@ -4078,7 +4078,7 @@ zfs_do_receive(int argc, char **argv) nomem(); /* check options */ - while ((c = getopt(argc, argv, ":o:denuvFsA")) != -1) { + while ((c = getopt(argc, argv, ":o:denuvMFsA")) != -1) { switch (c) { case 'o': if (parseprop(props, optarg) != 0) @@ -4105,6 +4105,9 @@ zfs_do_receive(int argc, char **argv) break; case 'F': flags.force = B_TRUE; + break; + case 'M': + flags.forceunmount = B_TRUE; break; case 'A': abort_resumable = B_TRUE; Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h == --- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.hSat Apr 11 17:30:33 2020(r359807) +++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.hSat Apr 11 17:54:35 2020(r359808) @@ -737,6 +737,9 @@ typedef struct recvflags { /* do not mount file systems as they are extracted (private) */ boolean_t nomount; + + /* force unmount while recv snapshot (private) */ + boolean_t forceunmount; } recvflags_t; extern
svn commit: r359807 - head/sbin/decryptcore
Author: oshogbo Date: Sat Apr 11 17:30:33 2020 New Revision: 359807 URL: https://svnweb.freebsd.org/changeset/base/359807 Log: decryptcore: load the nls data Load the nls data before the openssl will try to do it in the capability mode. On my machine the sa_ossl_private_decrypt is trying to do that. MFC after:2 weeks Modified: head/sbin/decryptcore/decryptcore.c Modified: head/sbin/decryptcore/decryptcore.c == --- head/sbin/decryptcore/decryptcore.c Sat Apr 11 15:52:07 2020 (r359806) +++ head/sbin/decryptcore/decryptcore.c Sat Apr 11 17:30:33 2020 (r359807) @@ -170,6 +170,7 @@ decrypt(int ofd, const char *privkeyfile, const char * goto failed; } + caph_cache_catpages(); if (caph_enter() < 0) { pjdlog_errno(LOG_ERR, "Unable to enter capability mode"); goto failed; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359806 - head/sys/arm/ti/am335x
Author: manu Date: Sat Apr 11 15:52:07 2020 New Revision: 359806 URL: https://svnweb.freebsd.org/changeset/base/359806 Log: arm: am335x: Honor pmic option ti,pmic-shutdown-controller Honor ti,pmic-shutdown-controller option in DTS Tested on stable r359316 @ Sleep mode on custom hw, Power off on BBB and PB OFF bit [1] in status register control the pmic behaviour when PWR_EN pin is pulled low. On most AM335x hardware [beaglebone *] the desired behaviour are in fact power off due to some hardware designs - read more in the comments around pmic in sys/gnu/dts/arm/am335x-bone-common.dtsi This patch let the device-tree decide with ti,pmic-shutdown-controller[2] the state of off bit in status register. [1] 8.6.12 table 12 http://www.ti.com/lit/ds/symlink/tps65217.pdf [2] Documentation/devicetree/bindings/regulator/tps65217.txt PR: 245159 Submitted by: Oskar Holmlund MFC after:2 weeks Modified: head/sys/arm/ti/am335x/am335x_pmic.c Modified: head/sys/arm/ti/am335x/am335x_pmic.c == --- head/sys/arm/ti/am335x/am335x_pmic.cSat Apr 11 15:25:40 2020 (r359805) +++ head/sys/arm/ti/am335x/am335x_pmic.cSat Apr 11 15:52:07 2020 (r359806) @@ -208,6 +208,7 @@ am335x_pmic_start(struct am335x_pmic_softc *sc) char name[20]; char pwr[4][11] = {"Battery", "USB", "AC", "USB and AC"}; int rv; + phandle_t node; dev = sc->sc_dev; am335x_pmic_read(dev, TPS65217_CHIPID_REG, (uint8_t *)_reg, 1); @@ -232,6 +233,16 @@ am335x_pmic_start(struct am335x_pmic_softc *sc) device_printf(dev, "%s powered by %s\n", name, pwr[status_reg.usbpwr | (status_reg.acpwr << 1)]); + /* Check devicetree for ti,pmic-shutdown-controller +* if present; PMIC will go to shutdown state on PWR_EN toggle +* if not present; PMIC will enter sleep state on PWR_EN toggle (default on reset) +*/ + node = ofw_bus_get_node(dev); + if (OF_hasprop(node, "ti,pmic-shutdown-controller")) { + status_reg.off = 1; + am335x_pmic_write(dev, TPS65217_STATUS_REG, (uint8_t *)_reg, 1); + } + if (am335x_pmic_vo[0] != '\0') { for (vo = 0; vo < 4; vo++) { if (strcmp(tps65217_voreg_c[vo], am335x_pmic_vo) == 0) @@ -291,16 +302,9 @@ am335x_pmic_attach(device_t dev) static void am335x_pmic_shutdown(void *xdev, int howto) { - device_t dev; - struct tps65217_status_reg reg; - if (!(howto & RB_POWEROFF)) return; - dev = (device_t)xdev; - am335x_pmic_read(dev, TPS65217_STATUS_REG, (uint8_t *), 1); - /* Set the OFF bit on status register to start the shutdown sequence. */ - reg.off = 1; - am335x_pmic_write(dev, TPS65217_STATUS_REG, (uint8_t *), 1); + /* Toggle pmic_pwr_enable to shutdown the PMIC. */ am335x_rtc_pmic_pwr_toggle(); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359805 - head/usr.sbin/gpioctl
Author: manu Date: Sat Apr 11 15:25:40 2020 New Revision: 359805 URL: https://svnweb.freebsd.org/changeset/base/359805 Log: gpioctl: Print interrupts capabilities GPIO drivers who supports interrupts report them in the caps (obtain via the getcaps method) but gpioctl doesn't know how to interpret this and print "UNKNOWN" for each one of them. Even if we don't have userland gpio interrupts support for now let gpioctl print the supported caps. MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D24133 Modified: head/usr.sbin/gpioctl/gpioctl.c Modified: head/usr.sbin/gpioctl/gpioctl.c == --- head/usr.sbin/gpioctl/gpioctl.c Sat Apr 11 09:38:45 2020 (r359804) +++ head/usr.sbin/gpioctl/gpioctl.c Sat Apr 11 15:25:40 2020 (r359805) @@ -62,6 +62,11 @@ static struct flag_desc gpio_flags[] = { { "II", GPIO_PIN_INVIN }, { "IO", GPIO_PIN_INVOUT }, { "PULSE", GPIO_PIN_PULSATE }, + { "INTRLL", GPIO_INTR_LEVEL_LOW}, + { "INTRLH", GPIO_INTR_LEVEL_HIGH}, + { "INTRER", GPIO_INTR_EDGE_RISING}, + { "INTREF", GPIO_INTR_EDGE_FALLING}, + { "INTREB", GPIO_INTR_EDGE_BOTH}, { NULL, 0 }, }; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359804 - head/sys/net
Author: melifaro Date: Sat Apr 11 09:38:45 2020 New Revision: 359804 URL: https://svnweb.freebsd.org/changeset/base/359804 Log: Fix build by adding forgotten header to radix_mpath.c after r359797. Modified: head/sys/net/radix_mpath.c Modified: head/sys/net/radix_mpath.c == --- head/sys/net/radix_mpath.c Sat Apr 11 09:36:41 2020(r359803) +++ head/sys/net/radix_mpath.c Sat Apr 11 09:38:45 2020(r359804) @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359803 - stable/11/sys/netinet6
Author: ae Date: Sat Apr 11 09:36:41 2020 New Revision: 359803 URL: https://svnweb.freebsd.org/changeset/base/359803 Log: MFC r359498: Ignore ND6 neighbor advertisement received for static link-layer entries. Previously such NA could override manually created LLE. Reported by:Martin Beran Modified: stable/11/sys/netinet6/nd6_nbr.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet6/nd6_nbr.c == --- stable/11/sys/netinet6/nd6_nbr.cSat Apr 11 09:35:48 2020 (r359802) +++ stable/11/sys/netinet6/nd6_nbr.cSat Apr 11 09:36:41 2020 (r359803) @@ -745,6 +745,12 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len) goto freeit; } + /* +* Do not try to override static entry. +*/ + if (ln->la_flags & LLE_STATIC) + goto freeit; + if (ln->ln_state == ND6_LLINFO_INCOMPLETE) { /* * If the link-layer has address, and no lladdr option came, ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359802 - stable/12/sys/netinet6
Author: ae Date: Sat Apr 11 09:35:48 2020 New Revision: 359802 URL: https://svnweb.freebsd.org/changeset/base/359802 Log: MFC r359498: Ignore ND6 neighbor advertisement received for static link-layer entries. Previously such NA could override manually created LLE. Reported by:Martin Beran Modified: stable/12/sys/netinet6/nd6_nbr.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/netinet6/nd6_nbr.c == --- stable/12/sys/netinet6/nd6_nbr.cSat Apr 11 08:16:35 2020 (r359801) +++ stable/12/sys/netinet6/nd6_nbr.cSat Apr 11 09:35:48 2020 (r359802) @@ -753,6 +753,12 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len) goto freeit; } + /* +* Do not try to override static entry. +*/ + if (ln->la_flags & LLE_STATIC) + goto freeit; + if (ln->ln_state == ND6_LLINFO_INCOMPLETE) { /* * If the link-layer has address, and no lladdr option came, ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359801 - head/usr.bin/wc
Author: eugen Date: Sat Apr 11 08:16:35 2020 New Revision: 359801 URL: https://svnweb.freebsd.org/changeset/base/359801 Log: wc(1): document SIGINFO handling in the manual page. MFC after:3 days Modified: head/usr.bin/wc/wc.1 Modified: head/usr.bin/wc/wc.1 == --- head/usr.bin/wc/wc.1Sat Apr 11 07:56:11 2020(r359800) +++ head/usr.bin/wc/wc.1Sat Apr 11 08:16:35 2020(r359801) @@ -31,7 +31,7 @@ .\" @(#)wc.1 8.2 (Berkeley) 4/19/94 .\" $FreeBSD$ .\" -.Dd August 2, 2018 +.Dd April 11, 2020 .Dt WC 1 .Os .Sh NAME @@ -126,6 +126,18 @@ file name is displayed. The prompt will accept input until receiving EOF, or .Bq ^D in most environments. +.Pp +If +.Nm +receives a +.Dv SIGINFO +(see the +.Cm status +argument for +.Xr stty 1 ) +signal, the interim data will be written +to the standard error output in the same format +as the standard completion message. .Sh ENVIRONMENT The .Ev LANG , LC_ALL ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359800 - head/sys/netinet6
Author: melifaro Date: Sat Apr 11 07:56:11 2020 New Revision: 359800 URL: https://svnweb.freebsd.org/changeset/base/359800 Log: Remove RADIX_MPATH headers, they were unused since r293159. MFC after:2 weeks Modified: head/sys/netinet6/nd6_nbr.c Modified: head/sys/netinet6/nd6_nbr.c == --- head/sys/netinet6/nd6_nbr.c Sat Apr 11 07:46:38 2020(r359799) +++ head/sys/netinet6/nd6_nbr.c Sat Apr 11 07:56:11 2020(r359800) @@ -37,7 +37,6 @@ __FBSDID("$FreeBSD$"); #include "opt_inet.h" #include "opt_inet6.h" #include "opt_ipsec.h" -#include "opt_mpath.h" #include #include @@ -63,9 +62,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef RADIX_MPATH -#include -#endif #include #include ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359799 - stable/11/usr.bin/ruptime
Author: nyan Date: Sat Apr 11 07:46:38 2020 New Revision: 359799 URL: https://svnweb.freebsd.org/changeset/base/359799 Log: MFC: r342965 > Fix indentation in ruptime command output for hosts in the "down" state. MFC: r359631 > Remove extra spaces for the load average of machines that are down. PR: 234239, 245296 Modified: stable/11/usr.bin/ruptime/ruptime.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/ruptime/ruptime.c == --- stable/11/usr.bin/ruptime/ruptime.c Sat Apr 11 07:37:10 2020 (r359798) +++ stable/11/usr.bin/ruptime/ruptime.c Sat Apr 11 07:46:38 2020 (r359799) @@ -232,18 +232,21 @@ ruptime(const char *host, int aflg, int (*cmp)(const v if (hostnamewidth < (int)strlen(wd->wd_hostname)) hostnamewidth = (int)strlen(wd->wd_hostname); - for (i = 0; i < 3; i++) { - w = iwidth(wd->wd_loadav[i] / 100) + 3; - if (loadavwidth[i] < w) - loadavwidth[i] = w; + + if (!ISDOWN(hsp)) { + for (i = 0; i < 3; i++) { + w = iwidth(wd->wd_loadav[i] / 100) + 3; + if (loadavwidth[i] < w) + loadavwidth[i] = w; + } + for (hsp->hs_nusers = 0, we = >wd_we[0]; +(char *)(we + 1) <= (char *)wd + cc; we++) + if (aflg || we->we_idle < 3600) + ++hsp->hs_nusers; + if (userswidth < iwidth(hsp->hs_nusers)) + userswidth = iwidth(hsp->hs_nusers); } - for (hsp->hs_nusers = 0, we = >wd_we[0]; - (char *)(we + 1) <= (char *)wd + cc; we++) - if (aflg || we->we_idle < 3600) - ++hsp->hs_nusers; - if (userswidth < iwidth(hsp->hs_nusers)) - userswidth = iwidth(hsp->hs_nusers); ++hsp; ++nhosts; } @@ -262,7 +265,7 @@ ruptime(const char *host, int aflg, int (*cmp)(const v hsp = [i]; wd = >hs_wd; if (ISDOWN(hsp)) { - (void)printf("%-*.*s%s\n", + (void)printf("%-*.*s %s\n", hostnamewidth, hostnamewidth, wd->wd_hostname, interval(now - hsp->hs_wd.wd_recvtime, "down")); continue; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359798 - stable/11/usr.bin/ruptime
Author: nyan Date: Sat Apr 11 07:37:10 2020 New Revision: 359798 URL: https://svnweb.freebsd.org/changeset/base/359798 Log: MFC: r314640 (by bde) > Fix formatting. ruptime output on FreeBSD cluster machines annoyed me > by usually being double-spaced due to auto-wrap at column 80. > > r212771 increased width of the hostname field from 12 to 25. This was > supposed to allow for 80-column output with all 3 load averages taking > 5 characters each, but it actually gave width exactly 80 and thus worse > than useless auto-wrap in that case. 3 wide load average fields are > unusual, but later expansion of another field gave the auto-wrap with > just 2 wide load average fields. > > Change to dynamic field widths for all fields except the uptime. This > also fixes the formatting of high (above ) user counts and not > very high (above 9.99) load averages. The formatting for numbers now > breaks at 9.99, but scientific notation should be used starting > well below that. > > The field width for the uptime remains hard-coded to work consistently > for uptimes less than 1 days, but this gives too much space for > small uptimes. Punctuation between fields could be improved in many > ways, for example by removing it. Modified: stable/11/usr.bin/ruptime/ruptime.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/ruptime/ruptime.c == --- stable/11/usr.bin/ruptime/ruptime.c Sat Apr 11 07:37:08 2020 (r359797) +++ stable/11/usr.bin/ruptime/ruptime.c Sat Apr 11 07:37:10 2020 (r359798) @@ -69,6 +69,7 @@ static DIR *dirp; static int hscmp(const void *, const void *); static char*interval(time_t, const char *); +static int iwidth(int); static int lcmp(const void *, const void *); static void ruptime(const char *, int, int (*)(const void *, const void *)); static int tcmp(const void *, const void *); @@ -143,6 +144,21 @@ interval(time_t tval, const char *updown) return (resbuf); } +/* Width to print a small nonnegative integer. */ +static int +iwidth(int w) +{ + if (w < 10) + return (1); + if (w < 100) + return (2); + if (w < 1000) + return (3); + if (w < 1) + return (4); + return (5); +} + #defineHS(a) ((const struct hs *)(a)) /* Alphabetical comparison. */ @@ -176,14 +192,17 @@ ruptime(const char *host, int aflg, int (*cmp)(const v struct whod *wd; struct whoent *we; struct dirent *dp; - const char *hostname; - int fd, i, maxloadav; + int fd, hostnamewidth, i, loadavwidth[3], userswidth, w; size_t hspace; ssize_t cc; rewinddir(dirp); hsp = NULL; - maxloadav = -1; + hostnamewidth = 0; + loadavwidth[0] = 4; + loadavwidth[1] = 4; + loadavwidth[2] = 4; + userswidth = 1; (void)time(); for (nhosts = hspace = 0; (dp = readdir(dirp)) != NULL;) { if (dp->d_ino == 0 || strncmp(dp->d_name, "whod.", 5) != 0) @@ -206,22 +225,25 @@ ruptime(const char *host, int aflg, int (*cmp)(const v if (cc < (ssize_t)WHDRSIZE) continue; - if (host != NULL) { - hostname = wd->wd_hostname; - if (strcasecmp(hostname, host) != 0) - continue; - } + if (host != NULL && strcasecmp(wd->wd_hostname, host) != 0) + continue; if (LEFTEARTH(wd->wd_recvtime)) continue; - for (i = 0; i < 2; i++) - if (wd->wd_loadav[i] > maxloadav) - maxloadav = wd->wd_loadav[i]; + if (hostnamewidth < (int)strlen(wd->wd_hostname)) + hostnamewidth = (int)strlen(wd->wd_hostname); + for (i = 0; i < 3; i++) { + w = iwidth(wd->wd_loadav[i] / 100) + 3; + if (loadavwidth[i] < w) + loadavwidth[i] = w; + } for (hsp->hs_nusers = 0, we = >wd_we[0]; (char *)(we + 1) <= (char *)wd + cc; we++) if (aflg || we->we_idle < 3600) ++hsp->hs_nusers; + if (userswidth < iwidth(hsp->hs_nusers)) + userswidth = iwidth(hsp->hs_nusers); ++hsp; ++nhosts; } @@ -233,27 +255,28 @@ ruptime(const char *host, int aflg, int (*cmp)(const v } qsort(hs, nhosts, sizeof(hs[0]), cmp); + w = userswidth + loadavwidth[0] + loadavwidth[1] + loadavwidth[2]; + if (hostnamewidth + w > 41) + hostnamewidth = 41 - w; /* limit to 79
svn commit: r359797 - in head/sys: net netinet netinet6
Author: melifaro Date: Sat Apr 11 07:37:08 2020 New Revision: 359797 URL: https://svnweb.freebsd.org/changeset/base/359797 Log: Remove per-AF radix_mpath initializtion functions. Split their functionality by moving random seed allocation to SYSINIT and calling (new) generic multipath function from standard IPv4/IPv5 RIB init handlers. Differential Revision:https://reviews.freebsd.org/D24356 Modified: head/sys/net/radix_mpath.c head/sys/net/route_var.h head/sys/netinet/in_proto.c head/sys/netinet/in_rmx.c head/sys/netinet6/in6_proto.c head/sys/netinet6/in6_rmx.c Modified: head/sys/net/radix_mpath.c == --- head/sys/net/radix_mpath.c Sat Apr 11 07:31:16 2020(r359796) +++ head/sys/net/radix_mpath.c Sat Apr 11 07:37:08 2020(r359797) @@ -290,38 +290,18 @@ rtalloc_mpath_fib(struct route *ro, uint32_t hash, u_i RT_UNLOCK(ro->ro_rt); } -extern int in6_inithead(void **head, int off, u_int fibnum); -extern int in_inithead(void **head, int off, u_int fibnum); - -#ifdef INET -int -rn4_mpath_inithead(void **head, int off, u_int fibnum) +void +rt_mpath_init_rnh(struct rib_head *rnh) { - struct rib_head *rnh; - hashjitter = arc4random(); - if (in_inithead(head, off, fibnum) == 1) { - rnh = (struct rib_head *)*head; - rnh->rnh_multipath = 1; - return 1; - } else - return 0; + rnh->rnh_multipath = 1; } -#endif -#ifdef INET6 -int -rn6_mpath_inithead(void **head, int off, u_int fibnum) +static void +mpath_init(void) { - struct rib_head *rnh; hashjitter = arc4random(); - if (in6_inithead(head, off, fibnum) == 1) { - rnh = (struct rib_head *)*head; - rnh->rnh_multipath = 1; - return 1; - } else - return 0; } +SYSINIT(mpath_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY, mpath_init, NULL); -#endif Modified: head/sys/net/route_var.h == --- head/sys/net/route_var.hSat Apr 11 07:31:16 2020(r359796) +++ head/sys/net/route_var.hSat Apr 11 07:37:08 2020(r359797) @@ -88,6 +88,7 @@ _Static_assert(__offsetof(struct route, ro_dst) == __o "ro_dst and " #_dst_new " are at different offset") struct rib_head *rt_tables_get_rnh(int fib, int family); +void rt_mpath_init_rnh(struct rib_head *rnh); /* rte<>nhop translation */ static inline uint16_t Modified: head/sys/netinet/in_proto.c == --- head/sys/netinet/in_proto.c Sat Apr 11 07:31:16 2020(r359796) +++ head/sys/netinet/in_proto.c Sat Apr 11 07:37:08 2020(r359797) @@ -62,9 +62,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef RADIX_MPATH -#include -#endif #include #endif /* INET */ @@ -305,11 +302,7 @@ struct domain inetdomain = { .dom_name = "internet", .dom_protosw = inetsw, .dom_protoswNPROTOSW = [nitems(inetsw)], -#ifdef RADIX_MPATH - .dom_rtattach = rn4_mpath_inithead, -#else .dom_rtattach = in_inithead, -#endif #ifdef VIMAGE .dom_rtdetach = in_detachhead, #endif Modified: head/sys/netinet/in_rmx.c == --- head/sys/netinet/in_rmx.c Sat Apr 11 07:31:16 2020(r359796) +++ head/sys/netinet/in_rmx.c Sat Apr 11 07:37:08 2020(r359797) @@ -30,6 +30,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_mpath.h" + #include #include #include @@ -125,6 +127,9 @@ in_inithead(void **head, int off, u_int fibnum) return (0); rh->rnh_addaddr = in_addroute; +#ifdef RADIX_MPATH + rt_mpath_init_rnh(rh); +#endif *head = (void *)rh; if (_in_rt_was_here == 0 ) { Modified: head/sys/netinet6/in6_proto.c == --- head/sys/netinet6/in6_proto.c Sat Apr 11 07:31:16 2020 (r359796) +++ head/sys/netinet6/in6_proto.c Sat Apr 11 07:37:08 2020 (r359797) @@ -90,9 +90,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef RADIX_MPATH -#include -#endif #include #include @@ -346,11 +343,7 @@ struct domain inet6domain = { .dom_name = "internet6", .dom_protosw = (struct protosw *)inet6sw, .dom_protoswNPROTOSW = (struct protosw *)[nitems(inet6sw)], -#ifdef RADIX_MPATH - .dom_rtattach = rn6_mpath_inithead, -#else .dom_rtattach = in6_inithead, -#endif #ifdef VIMAGE .dom_rtdetach = in6_detachhead, #endif Modified: head/sys/netinet6/in6_rmx.c
svn commit: r359796 - stable/12/usr.bin/ruptime
Author: nyan Date: Sat Apr 11 07:31:16 2020 New Revision: 359796 URL: https://svnweb.freebsd.org/changeset/base/359796 Log: MFC: r359631 Remove extra spaces for the load average of machines that are down. PR: 245296 Submitted by: martin _at_ lispworks.com Modified: stable/12/usr.bin/ruptime/ruptime.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.bin/ruptime/ruptime.c == --- stable/12/usr.bin/ruptime/ruptime.c Sat Apr 11 07:24:57 2020 (r359795) +++ stable/12/usr.bin/ruptime/ruptime.c Sat Apr 11 07:31:16 2020 (r359796) @@ -234,18 +234,21 @@ ruptime(const char *host, int aflg, int (*cmp)(const v if (hostnamewidth < (int)strlen(wd->wd_hostname)) hostnamewidth = (int)strlen(wd->wd_hostname); - for (i = 0; i < 3; i++) { - w = iwidth(wd->wd_loadav[i] / 100) + 3; - if (loadavwidth[i] < w) - loadavwidth[i] = w; + + if (!ISDOWN(hsp)) { + for (i = 0; i < 3; i++) { + w = iwidth(wd->wd_loadav[i] / 100) + 3; + if (loadavwidth[i] < w) + loadavwidth[i] = w; + } + for (hsp->hs_nusers = 0, we = >wd_we[0]; +(char *)(we + 1) <= (char *)wd + cc; we++) + if (aflg || we->we_idle < 3600) + ++hsp->hs_nusers; + if (userswidth < iwidth(hsp->hs_nusers)) + userswidth = iwidth(hsp->hs_nusers); } - for (hsp->hs_nusers = 0, we = >wd_we[0]; - (char *)(we + 1) <= (char *)wd + cc; we++) - if (aflg || we->we_idle < 3600) - ++hsp->hs_nusers; - if (userswidth < iwidth(hsp->hs_nusers)) - userswidth = iwidth(hsp->hs_nusers); ++hsp; ++nhosts; } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359795 - head/sys/dev/acpi_support
Author: delphij Date: Sat Apr 11 07:24:57 2020 New Revision: 359795 URL: https://svnweb.freebsd.org/changeset/base/359795 Log: Avoid using a variable solely for sizes that are never meant to be modified runtime. No functional change. MFC after:2 weeks Modified: head/sys/dev/acpi_support/acpi_hp.c Modified: head/sys/dev/acpi_support/acpi_hp.c == --- head/sys/dev/acpi_support/acpi_hp.c Sat Apr 11 05:12:38 2020 (r359794) +++ head/sys/dev/acpi_support/acpi_hp.c Sat Apr 11 07:24:57 2020 (r359795) @@ -962,10 +962,9 @@ acpi_hp_get_cmi_block(device_t wmi_dev, const char* gu ACPI_BUFFER out = { ACPI_ALLOCATE_BUFFER, NULL }; int i; int outlen; - int size = 255; int has_enums = 0; int valuebase = 0; - charstring_buffer[size]; + charstring_buffer[255]; int enumbase; outlen = 0; @@ -1019,18 +1018,21 @@ acpi_hp_get_cmi_block(device_t wmi_dev, const char* gu if (detail & ACPI_HP_CMI_DETAIL_PATHS) { strlcat(outbuf, acpi_hp_get_string_from_object( - >Package.Elements[2], string_buffer, size), outsize); + >Package.Elements[2], + string_buffer, sizeof(string_buffer)), outsize); outlen += 48; while (strlen(outbuf) < outlen) strlcat(outbuf, " ", outsize); } strlcat(outbuf, acpi_hp_get_string_from_object( - >Package.Elements[0], string_buffer, size), outsize); + >Package.Elements[0], + string_buffer, sizeof(string_buffer)), outsize); outlen += 43; while (strlen(outbuf) < outlen) strlcat(outbuf, " ", outsize); strlcat(outbuf, acpi_hp_get_string_from_object( - >Package.Elements[valuebase], string_buffer, size), outsize); + >Package.Elements[valuebase], + string_buffer, sizeof(string_buffer)), outsize); outlen += 21; while (strlen(outbuf) < outlen) strlcat(outbuf, " ", outsize); @@ -1041,7 +1043,8 @@ acpi_hp_get_cmi_block(device_t wmi_dev, const char* gu for (i = enumbase + 1; i < enumbase + 1 + obj->Package.Elements[enumbase].Integer.Value; ++i) { acpi_hp_get_string_from_object( - >Package.Elements[i], string_buffer, size); + >Package.Elements[i], + string_buffer, sizeof(string_buffer)); if (strlen(string_buffer) > 1 || (strlen(string_buffer) == 1 && string_buffer[0] != ' ')) { @@ -1211,8 +1214,7 @@ acpi_hp_hpcmi_read(struct cdev *dev, struct uio *buf, UINT8 instance; UINT8 maxInstance; UINT32 sequence; - int linesize = 1025; - charline[linesize]; + charline[1025]; if (dev == NULL || dev->si_drv1 == NULL) return (EBADF); @@ -1237,7 +1239,7 @@ acpi_hp_hpcmi_read(struct cdev *dev, struct uio *buf, ++instance) { if (acpi_hp_get_cmi_block(sc->wmi_dev, ACPI_HP_WMI_CMI_GUID, instance, - line, linesize, , + line, sizeof(line), , sc->cmi_detail)) { instance = maxInstance; } @@ -1270,7 +1272,7 @@ acpi_hp_hpcmi_read(struct cdev *dev, struct uio *buf, for (i=0; icmi_order_size; ++i) { if (!acpi_hp_get_cmi_block(sc->wmi_dev, ACPI_HP_WMI_CMI_GUID, - sc->cmi_order[i].instance, line, linesize, + sc->cmi_order[i].instance, line, sizeof(line), , sc->cmi_detail)) { sbuf_printf(>hpcmi_sbuf, "%s\n", line); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"