From owner-svn-src-projects@freebsd.org Sun Mar 31 03:19:12 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4170D156FDFB for ; Sun, 31 Mar 2019 03:19:12 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D636E8CA2D; Sun, 31 Mar 2019 03:19:11 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AF0F520B96; Sun, 31 Mar 2019 03:19:11 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2V3JBaY038632; Sun, 31 Mar 2019 03:19:11 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2V3JAGH038626; Sun, 31 Mar 2019 03:19:10 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201903310319.x2V3JAGH038626@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Sun, 31 Mar 2019 03:19:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345742 - projects/fuse2/sys/fs/fuse X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: projects/fuse2/sys/fs/fuse X-SVN-Commit-Revision: 345742 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D636E8CA2D X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.978,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 03:19:12 -0000 Author: asomers Date: Sun Mar 31 03:19:10 2019 New Revision: 345742 URL: https://svnweb.freebsd.org/changeset/base/345742 Log: fusefs: replace the fufh table with a linked list The FUSE protocol allows each open file descriptor to have a unique file handle. On FreeBSD, these file handles must all be stored in the vnode. The old method (also used by OSX and OpenBSD) is to store them all in a small array. But that limits the total number that can be stored. This commit replaces the array with a linked list (a technique also used by Illumos). There is not yet any change in functionality, but this is the first step to fixing several bugs. PR: 236329, 236340, 236381, 236560, 236844 Discussed with: cem Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/sys/fs/fuse/fuse_file.c projects/fuse2/sys/fs/fuse/fuse_file.h projects/fuse2/sys/fs/fuse/fuse_internal.c projects/fuse2/sys/fs/fuse/fuse_node.c projects/fuse2/sys/fs/fuse/fuse_node.h projects/fuse2/sys/fs/fuse/fuse_vnops.c Modified: projects/fuse2/sys/fs/fuse/fuse_file.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_file.c Sat Mar 30 23:43:58 2019 (r345741) +++ projects/fuse2/sys/fs/fuse/fuse_file.c Sun Mar 31 03:19:10 2019 (r345742) @@ -82,6 +82,8 @@ __FBSDID("$FreeBSD$"); #include "fuse_ipc.h" #include "fuse_node.h" +MALLOC_DEFINE(M_FUSE_FILEHANDLE, "fuse_filefilehandle", "FUSE file handle"); + SDT_PROVIDER_DECLARE(fuse); /* * Fuse trace probe: @@ -157,16 +159,14 @@ fuse_filehandle_close(struct vnode *vp, fufh_type_t fu { struct fuse_dispatcher fdi; struct fuse_release_in *fri; - struct fuse_vnode_data *fvdat = VTOFUD(vp); struct fuse_filehandle *fufh = NULL; int err = 0; int op = FUSE_RELEASE; - fufh = &(fvdat->fufh[fufh_type]); - if (!FUFH_IS_VALID(fufh)) { - panic("FUSE: filehandle_put called on invalid fufh (type=%d)", - fufh_type); + if (fuse_filehandle_get(vp, fufh_type, &fufh)) { + panic("FUSE: fuse_filehandle_close called on invalid fufh " + "(type=%d)", fufh_type); /* NOTREACHED */ } if (fuse_isdeadfs(vp)) { @@ -185,8 +185,8 @@ fuse_filehandle_close(struct vnode *vp, fufh_type_t fu out: atomic_subtract_acq_int(&fuse_fh_count, 1); - fufh->fh_id = (uint64_t)-1; - fufh->fh_type = FUFH_INVALID; + LIST_REMOVE(fufh, next); + free(fufh, M_FUSE_FILEHANDLE); return err; } @@ -194,31 +194,22 @@ out: int fuse_filehandle_valid(struct vnode *vp, fufh_type_t fufh_type) { - struct fuse_vnode_data *fvdat = VTOFUD(vp); - struct fuse_filehandle *fufh; - - fufh = &(fvdat->fufh[fufh_type]); - return FUFH_IS_VALID(fufh); + return (0 == fuse_filehandle_get(vp, fufh_type, NULL)); } /* * Check for a valid file handle, first the type requested, but if that * isn't valid, try for FUFH_RDWR. * Return the FUFH type that is valid or FUFH_INVALID if there are none. - * This is a variant of fuse_filehandle_vaild() analogous to + * This is a variant of fuse_filehandle_valid() analogous to * fuse_filehandle_getrw(). */ fufh_type_t fuse_filehandle_validrw(struct vnode *vp, fufh_type_t fufh_type) { - struct fuse_vnode_data *fvdat = VTOFUD(vp); - struct fuse_filehandle *fufh; - - fufh = &fvdat->fufh[fufh_type]; - if (FUFH_IS_VALID(fufh) != 0) + if (fuse_filehandle_get(vp, fufh_type, NULL) == 0) return (fufh_type); - fufh = &fvdat->fufh[FUFH_RDWR]; - if (FUFH_IS_VALID(fufh) != 0) + if (fuse_filehandle_get(vp, FUFH_RDWR, NULL) == 0) return (FUFH_RDWR); return (FUFH_INVALID); } @@ -230,8 +221,14 @@ fuse_filehandle_get(struct vnode *vp, fufh_type_t fufh struct fuse_vnode_data *fvdat = VTOFUD(vp); struct fuse_filehandle *fufh; - fufh = &(fvdat->fufh[fufh_type]); - if (!FUFH_IS_VALID(fufh)) + /* TODO: Find a list entry with the same mode, pid, gid, and uid */ + /* Fallback: find a list entry with the right mode */ + LIST_FOREACH(fufh, &fvdat->handles, next) { + if (fufh->mode == fufh_type) + break; + } + + if (fufh == NULL) return EBADF; if (fufhp != NULL) *fufhp = fufh; @@ -242,14 +239,12 @@ int fuse_filehandle_getrw(struct vnode *vp, fufh_type_t fufh_type, struct fuse_filehandle **fufhp) { - struct fuse_vnode_data *fvdat = VTOFUD(vp); - struct fuse_filehandle *fufh; + int err; - fufh = &(fvdat->fufh[fufh_type]); - if (!FUFH_IS_VALID(fufh)) { - fufh_type = FUFH_RDWR; - } - return fuse_filehandle_get(vp, fufh_type, fufhp); + err = fuse_filehandle_get(vp, fufh_type, fufhp); + if (err) + err = fuse_filehandle_get(vp, FUFH_RDWR, fufhp); + return err; } void @@ -259,13 +254,16 @@ fuse_filehandle_init(struct vnode *vp, fufh_type_t fuf struct fuse_vnode_data *fvdat = VTOFUD(vp); struct fuse_filehandle *fufh; - fufh = &(fvdat->fufh[fufh_type]); - MPASS(!FUFH_IS_VALID(fufh)); + fufh = malloc(sizeof(struct fuse_filehandle), M_FUSE_FILEHANDLE, + M_WAITOK); + MPASS(fufh != NULL); fufh->fh_id = fh_id; - fufh->fh_type = fufh_type; + fufh->mode = fufh_type; + /* TODO: initialize fufh credentials and open flags */ if (!FUFH_IS_VALID(fufh)) { panic("FUSE: init: invalid filehandle id (type=%d)", fufh_type); } + LIST_INSERT_HEAD(&fvdat->handles, fufh, next); if (fufhp != NULL) *fufhp = fufh; Modified: projects/fuse2/sys/fs/fuse/fuse_file.h ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_file.h Sat Mar 30 23:43:58 2019 (r345741) +++ projects/fuse2/sys/fs/fuse/fuse_file.h Sun Mar 31 03:19:10 2019 (r345742) @@ -78,11 +78,24 @@ _Static_assert(FUFH_WRONLY == O_WRONLY, "WRONLY"); _Static_assert(FUFH_RDWR == O_RDWR, "RDWR"); struct fuse_filehandle { + LIST_ENTRY(fuse_filehandle) next; + + /* The filehandle returned by FUSE_OPEN */ uint64_t fh_id; - fufh_type_t fh_type; + + /* flags returned by FUSE_OPEN */ + uint32_t fuse_open_flags; + + /* The mode used to open(2) the file (using O_RDONLY, not FREAD) */ + uint32_t mode; + + /* Credentials used to open the file */ + gid_t gid; + pid_t pid; + uid_t uid; }; -#define FUFH_IS_VALID(f) ((f)->fh_type != FUFH_INVALID) +#define FUFH_IS_VALID(f) ((f)->mode != FUFH_INVALID) static inline fufh_type_t fuse_filehandle_xlate_from_fflags(int fflags) Modified: projects/fuse2/sys/fs/fuse/fuse_internal.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_internal.c Sat Mar 30 23:43:58 2019 (r345741) +++ projects/fuse2/sys/fs/fuse/fuse_internal.c Sun Mar 31 03:19:10 2019 (r345742) @@ -285,7 +285,6 @@ fuse_internal_fsync(struct vnode *vp, struct fuse_fsync_in *ffsi; struct fuse_dispatcher fdi; struct fuse_filehandle *fufh; - struct fuse_vnode_data *fvdat = VTOFUD(vp); int op = FUSE_FSYNC; int type = 0; int err = 0; @@ -295,8 +294,7 @@ fuse_internal_fsync(struct vnode *vp, return 0; } for (type = 0; type < FUFH_MAXTYPE; type++) { - fufh = &(fvdat->fufh[type]); - if (FUFH_IS_VALID(fufh)) { + if (fuse_filehandle_get(vp, type, &fufh) == 0) { if (vnode_isdir(vp)) { op = FUSE_FSYNCDIR; } @@ -454,11 +452,7 @@ fuse_internal_remove(struct vnode *dvp, enum fuse_opcode op) { struct fuse_dispatcher fdi; - struct fuse_vnode_data *fvdat; - int err; - - err = 0; - fvdat = VTOFUD(vp); + int err = 0; fdisp_init(&fdi, cnp->cn_namelen + 1); fdisp_make_vp(&fdi, op, dvp, cnp->cn_thread, cnp->cn_cred); Modified: projects/fuse2/sys/fs/fuse/fuse_node.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_node.c Sat Mar 30 23:43:58 2019 (r345741) +++ projects/fuse2/sys/fs/fuse/fuse_node.c Sun Mar 31 03:19:10 2019 (r345742) @@ -174,9 +174,8 @@ static void fuse_vnode_init(struct vnode *vp, struct fuse_vnode_data *fvdat, uint64_t nodeid, enum vtype vtyp) { - int i; - fvdat->nid = nodeid; + LIST_INIT(&fvdat->handles); vattr_null(&fvdat->cached_attrs); if (nodeid == FUSE_ROOT_ID) { vp->v_vflag |= VV_ROOT; @@ -184,9 +183,6 @@ fuse_vnode_init(struct vnode *vp, struct fuse_vnode_da vp->v_type = vtyp; vp->v_data = fvdat; - for (i = 0; i < FUFH_MAXTYPE; i++) - fvdat->fufh[i].fh_type = FUFH_INVALID; - atomic_add_acq_int(&fuse_node_count, 1); } @@ -196,6 +192,8 @@ fuse_vnode_destroy(struct vnode *vp) struct fuse_vnode_data *fvdat = vp->v_data; vp->v_data = NULL; + KASSERT(LIST_EMPTY(&fvdat->handles), + ("Destroying fuse vnode with open files!")); free(fvdat, M_FUSEVN); atomic_subtract_acq_int(&fuse_node_count, 1); @@ -314,7 +312,7 @@ void fuse_vnode_open(struct vnode *vp, int32_t fuse_open_flags, struct thread *td) { /* - * Funcation is called for every vnode open. + * Function is called for every vnode open. * Merge fuse_open_flags it may be 0 */ /* Modified: projects/fuse2/sys/fs/fuse/fuse_node.h ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_node.h Sat Mar 30 23:43:58 2019 (r345741) +++ projects/fuse2/sys/fs/fuse/fuse_node.h Sun Mar 31 03:19:10 2019 (r345742) @@ -80,7 +80,8 @@ struct fuse_vnode_data { uint64_t parent_nid; /** I/O **/ - struct fuse_filehandle fufh[FUFH_MAXTYPE]; + /* List of file data for each of the vnode's open file descriptors */ + LIST_HEAD(, fuse_filehandle) handles; /** flags **/ uint32_t flag; Modified: projects/fuse2/sys/fs/fuse/fuse_vnops.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_vnops.c Sat Mar 30 23:43:58 2019 (r345741) +++ projects/fuse2/sys/fs/fuse/fuse_vnops.c Sun Mar 31 03:19:10 2019 (r345742) @@ -606,8 +606,7 @@ fuse_vnop_inactive(struct vop_inactive_args *ap) int type, need_flush = 1; for (type = 0; type < FUFH_MAXTYPE; type++) { - fufh = &(fvdat->fufh[type]); - if (FUFH_IS_VALID(fufh)) { + if (!fuse_filehandle_get(vp, type, &fufh)) { if (need_flush && vp->v_type == VREG) { if ((VTOFUD(vp)->flag & FN_SIZECHANGE) != 0) { fuse_vnode_savesize(vp, NULL); @@ -1396,7 +1395,6 @@ fuse_vnop_reclaim(struct vop_reclaim_args *ap) struct thread *td = ap->a_td; struct fuse_vnode_data *fvdat = VTOFUD(vp); - struct fuse_filehandle *fufh = NULL; int type; @@ -1404,8 +1402,7 @@ fuse_vnop_reclaim(struct vop_reclaim_args *ap) panic("FUSE: no vnode data during recycling"); } for (type = 0; type < FUFH_MAXTYPE; type++) { - fufh = &(fvdat->fufh[type]); - if (FUFH_IS_VALID(fufh)) { + if (fuse_filehandle_get(vp, type, NULL) == 0) { printf("FUSE: vnode being reclaimed but fufh (type=%d) is valid", type); fuse_filehandle_close(vp, type, td, NULL); From owner-svn-src-projects@freebsd.org Sun Mar 31 05:16:29 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BC3C9154D383 for ; Sun, 31 Mar 2019 05:16:29 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6110169B72; Sun, 31 Mar 2019 05:16:29 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 36A912212A; Sun, 31 Mar 2019 05:16:29 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2V5GTNC001858; Sun, 31 Mar 2019 05:16:29 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2V5GRIW001851; Sun, 31 Mar 2019 05:16:27 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201903310516.x2V5GRIW001851@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Sun, 31 Mar 2019 05:16:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345746 - in projects/capsicum-test: libexec/rc/rc.d libexec/save-entropy sys/compat/freebsd32 sys/net sys/netinet6 X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: in projects/capsicum-test: libexec/rc/rc.d libexec/save-entropy sys/compat/freebsd32 sys/net sys/netinet6 X-SVN-Commit-Revision: 345746 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 6110169B72 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.951,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 05:16:30 -0000 Author: ngie Date: Sun Mar 31 05:16:27 2019 New Revision: 345746 URL: https://svnweb.freebsd.org/changeset/base/345746 Log: MFhead@r345745 Modified: projects/capsicum-test/libexec/rc/rc.d/random projects/capsicum-test/libexec/save-entropy/save-entropy.sh projects/capsicum-test/sys/compat/freebsd32/freebsd32_misc.c projects/capsicum-test/sys/net/if_stf.c projects/capsicum-test/sys/netinet6/in6.c projects/capsicum-test/sys/netinet6/in6_ifattach.c projects/capsicum-test/sys/netinet6/nd6.c Directory Properties: projects/capsicum-test/ (props changed) Modified: projects/capsicum-test/libexec/rc/rc.d/random ============================================================================== --- projects/capsicum-test/libexec/rc/rc.d/random Sun Mar 31 05:15:32 2019 (r345745) +++ projects/capsicum-test/libexec/rc/rc.d/random Sun Mar 31 05:16:27 2019 (r345746) @@ -25,7 +25,8 @@ save_dev_random() for f ; do debug "saving entropy to $f" dd if=/dev/random of="$f" bs=4096 count=1 status=none && - chmod 600 "$f" + chmod 600 "$f" && + fsync "$f" "$(dirname "$f")" done umask ${oumask} } @@ -120,6 +121,9 @@ random_stop() dd if=/dev/random of=${entropy_file_confirmed} \ bs=4096 count=1 2> /dev/null || warn 'write failed (unwriteable file or full fs?)' + fsync "${entropy_file_confirmed}" \ + "$(dirname "${entropy_file_confirmed}")" \ + 2> /dev/null echo '.' ;; esac @@ -145,6 +149,9 @@ random_stop() dd if=/dev/random of=${entropy_boot_file_confirmed} \ bs=4096 count=1 2> /dev/null || warn 'write failed (unwriteable file or full fs?)' + fsync "${entropy_boot_file_confirmed}" \ + "$(dirname "${entropy_boot_file_confirmed}")" \ + 2> /dev/null echo '.' ;; esac Modified: projects/capsicum-test/libexec/save-entropy/save-entropy.sh ============================================================================== --- projects/capsicum-test/libexec/save-entropy/save-entropy.sh Sun Mar 31 05:15:32 2019 (r345745) +++ projects/capsicum-test/libexec/save-entropy/save-entropy.sh Sun Mar 31 05:16:27 2019 (r345746) @@ -90,5 +90,6 @@ while [ ${n} -ge 1 ]; do done dd if=/dev/random of=saved-entropy.1 bs=${entropy_save_sz} count=1 2>/dev/null +fsync saved-entropy.1 "." exit 0 Modified: projects/capsicum-test/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- projects/capsicum-test/sys/compat/freebsd32/freebsd32_misc.c Sun Mar 31 05:15:32 2019 (r345745) +++ projects/capsicum-test/sys/compat/freebsd32/freebsd32_misc.c Sun Mar 31 05:16:27 2019 (r345746) @@ -1160,8 +1160,8 @@ freebsd32_copy_msg_out(struct msghdr *msg, struct mbuf cm = NULL; } - msg->msg_controllen += FREEBSD32_ALIGN(sizeof(*cm)) + - datalen_out; + msg->msg_controllen += + FREEBSD32_CMSG_SPACE(datalen_out); } } if (len == 0 && m != NULL) { Modified: projects/capsicum-test/sys/net/if_stf.c ============================================================================== --- projects/capsicum-test/sys/net/if_stf.c Sun Mar 31 05:15:32 2019 (r345745) +++ projects/capsicum-test/sys/net/if_stf.c Sun Mar 31 05:16:27 2019 (r345746) @@ -724,6 +724,7 @@ stf_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } ifp->if_flags |= IFF_UP; + ifp->if_drv_flags |= IFF_DRV_RUNNING; break; case SIOCADDMULTI: Modified: projects/capsicum-test/sys/netinet6/in6.c ============================================================================== --- projects/capsicum-test/sys/netinet6/in6.c Sun Mar 31 05:15:32 2019 (r345745) +++ projects/capsicum-test/sys/netinet6/in6.c Sun Mar 31 05:16:27 2019 (r345746) @@ -1951,26 +1951,14 @@ in6_if_up(struct ifnet *ifp) int in6if_do_dad(struct ifnet *ifp) { + if ((ifp->if_flags & IFF_LOOPBACK) != 0) return (0); - - if ((ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) || - (ND_IFINFO(ifp)->flags & ND6_IFF_NO_DAD)) + if ((ifp->if_flags & IFF_MULTICAST) == 0) return (0); - - /* - * Our DAD routine requires the interface up and running. - * However, some interfaces can be up before the RUNNING - * status. Additionally, users may try to assign addresses - * before the interface becomes up (or running). - * This function returns EAGAIN in that case. - * The caller should mark "tentative" on the address instead of - * performing DAD immediately. - */ - if (!((ifp->if_flags & IFF_UP) && - (ifp->if_drv_flags & IFF_DRV_RUNNING))) - return (EAGAIN); - + if ((ND_IFINFO(ifp)->flags & + (ND6_IFF_IFDISABLED | ND6_IFF_NO_DAD)) != 0) + return (0); return (1); } Modified: projects/capsicum-test/sys/netinet6/in6_ifattach.c ============================================================================== --- projects/capsicum-test/sys/netinet6/in6_ifattach.c Sun Mar 31 05:15:32 2019 (r345745) +++ projects/capsicum-test/sys/netinet6/in6_ifattach.c Sun Mar 31 05:16:27 2019 (r345746) @@ -692,6 +692,7 @@ in6_ifattach(struct ifnet *ifp, struct ifnet *altifp) * it is rather harmful to have one. */ ND_IFINFO(ifp)->flags &= ~ND6_IFF_AUTO_LINKLOCAL; + ND_IFINFO(ifp)->flags |= ND6_IFF_NO_DAD; break; default: break; Modified: projects/capsicum-test/sys/netinet6/nd6.c ============================================================================== --- projects/capsicum-test/sys/netinet6/nd6.c Sun Mar 31 05:15:32 2019 (r345745) +++ projects/capsicum-test/sys/netinet6/nd6.c Sun Mar 31 05:16:27 2019 (r345746) @@ -900,6 +900,7 @@ nd6_timer(void *arg) struct nd_prhead prl; struct nd_defrouter *dr, *ndr; struct nd_prefix *pr, *npr; + struct ifnet *ifp; struct in6_ifaddr *ia6, *nia6; uint64_t genid; @@ -996,14 +997,15 @@ nd6_timer(void *arg) * Check status of the interface. If it is down, * mark the address as tentative for future DAD. */ - if ((ia6->ia_ifp->if_flags & IFF_UP) == 0 || - (ia6->ia_ifp->if_drv_flags & IFF_DRV_RUNNING) - == 0 || - (ND_IFINFO(ia6->ia_ifp)->flags & - ND6_IFF_IFDISABLED) != 0) { + ifp = ia6->ia_ifp; + if ((ND_IFINFO(ifp)->flags & ND6_IFF_NO_DAD) == 0 && + ((ifp->if_flags & IFF_UP) == 0 || + (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || + (ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) != 0)){ ia6->ia6_flags &= ~IN6_IFF_DUPLICATED; ia6->ia6_flags |= IN6_IFF_TENTATIVE; } + /* * A new RA might have made a deprecated address * preferred. From owner-svn-src-projects@freebsd.org Sun Mar 31 06:20:01 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B2827154F08F for ; Sun, 31 Mar 2019 06:20:01 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49DAE6B932; Sun, 31 Mar 2019 06:20:01 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1EA9622B89; Sun, 31 Mar 2019 06:20:01 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2V6K07W033416; Sun, 31 Mar 2019 06:20:00 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2V6K0ih033415; Sun, 31 Mar 2019 06:20:00 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201903310620.x2V6K0ih033415@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Sun, 31 Mar 2019 06:20:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345749 - projects/kyua-use-googletest-test-interface/share/mk X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/kyua-use-googletest-test-interface/share/mk X-SVN-Commit-Revision: 345749 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 49DAE6B932 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.977,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 06:20:01 -0000 Author: ngie Date: Sun Mar 31 06:20:00 2019 New Revision: 345749 URL: https://svnweb.freebsd.org/changeset/base/345749 Log: Improve googletest integration with kyua This change modifies googletest.test.mk to use experimental googletest support in kyua, available as part of the `add-googletest-support` feature branch in https://github.com/ngie-eign/kyua. The experimental support provides test suite and test case level execution and result reporting, instead of requiring googletests to be run as the plain tests. As such, make the default GTESTS test engine interface googletest, providing a backwards compatibility knob, GTESTS_USE_PLAIN_TEST_INTERFACE, so end-users with older versions of kyua can run the googletest tests. While here, provide a per-PROG test interface hook for GTESTS. In short, not all of the googlemock and googletest provided tests conform to the format described in the googletest docs. Thus, they are better run as plain tests. Modified: projects/kyua-use-googletest-test-interface/share/mk/googletest.test.mk Modified: projects/kyua-use-googletest-test-interface/share/mk/googletest.test.mk ============================================================================== --- projects/kyua-use-googletest-test-interface/share/mk/googletest.test.mk Sun Mar 31 06:16:07 2019 (r345748) +++ projects/kyua-use-googletest-test-interface/share/mk/googletest.test.mk Sun Mar 31 06:20:00 2019 (r345749) @@ -26,6 +26,16 @@ # manpage. GTESTS?= +# Default test interface for googletest +# +# This knob should be used if the version of kyua in use doesn't support the +# `googletest` test interface. +.ifdef GTESTS_USE_PLAIN_TEST_INTERFACE +GTESTS_DEFAULT_TEST_INTERFACE= plain +.else +GTESTS_DEFAULT_TEST_INTERFACE= googletest +.endif + .if !empty(GTESTS) .include @@ -36,6 +46,6 @@ BINDIR.${_T}= ${TESTSDIR} CXXFLAGS.${_T}+= ${GTESTS_CXXFLAGS} MAN.${_T}?= # empty SRCS.${_T}?= ${_T}.cc -TEST_INTERFACE.${_T}= plain +TEST_INTERFACE.${_T}?= ${GTESTS_DEFAULT_TEST_INTERFACE} .endfor .endif From owner-svn-src-projects@freebsd.org Sun Mar 31 05:33:11 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6D1C0154DCB6 for ; Sun, 31 Mar 2019 05:33:11 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0D9E06A616; Sun, 31 Mar 2019 05:33:11 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DB472224D2; Sun, 31 Mar 2019 05:33:10 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2V5XAjc012201; Sun, 31 Mar 2019 05:33:10 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2V5XAwW012200; Sun, 31 Mar 2019 05:33:10 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201903310533.x2V5XAwW012200@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Sun, 31 Mar 2019 05:33:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345747 - projects/kyua-use-googletest-test-interface X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/kyua-use-googletest-test-interface X-SVN-Commit-Revision: 345747 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 0D9E06A616 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.951,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 05:33:11 -0000 Author: ngie Date: Sun Mar 31 05:33:10 2019 New Revision: 345747 URL: https://svnweb.freebsd.org/changeset/base/345747 Log: Improve googletest TEST_INTERFACE support Switch googletest.test.mk from the plain test interface to the googletest interface. This requires experimental features, currently only available in my GitHub kyua fork: https://github.com/ngie-eign/kyua/tree/add-googletest-support . I am close enough to completing the project that it's time to move my work from git to svn for developer visibility. Added: - copied from r345746, head/ Directory Properties: projects/kyua-use-googletest-test-interface/ (props changed) From owner-svn-src-projects@freebsd.org Sun Mar 31 06:16:08 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BD494154EFFE for ; Sun, 31 Mar 2019 06:16:08 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 449486B844; Sun, 31 Mar 2019 06:16:08 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ED06222B85; Sun, 31 Mar 2019 06:16:07 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2V6G7J6033183; Sun, 31 Mar 2019 06:16:07 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2V6G70f033182; Sun, 31 Mar 2019 06:16:07 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201903310616.x2V6G70f033182@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Sun, 31 Mar 2019 06:16:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345748 - projects/import-googletest-1.8.1 X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/import-googletest-1.8.1 X-SVN-Commit-Revision: 345748 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 449486B844 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.976,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 06:16:08 -0000 Author: ngie Date: Sun Mar 31 06:16:07 2019 New Revision: 345748 URL: https://svnweb.freebsd.org/changeset/base/345748 Log: Prune branch merged into ^/head as r345203 Deleted: projects/import-googletest-1.8.1/ From owner-svn-src-projects@freebsd.org Sun Mar 31 05:15:33 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2B93A154D270 for ; Sun, 31 Mar 2019 05:15:33 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C19B169A13; Sun, 31 Mar 2019 05:15:32 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9AFAD22129; Sun, 31 Mar 2019 05:15:32 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2V5FWqa001746; Sun, 31 Mar 2019 05:15:32 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2V5FWDK001745; Sun, 31 Mar 2019 05:15:32 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201903310515.x2V5FWDK001745@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Sun, 31 Mar 2019 05:15:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345745 - projects/capsicum-test/contrib/capsicum-test X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/capsicum-test/contrib/capsicum-test X-SVN-Commit-Revision: 345745 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C19B169A13 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.951,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 05:15:33 -0000 Author: ngie Date: Sun Mar 31 05:15:32 2019 New Revision: 345745 URL: https://svnweb.freebsd.org/changeset/base/345745 Log: Refine r345743 Add backwards compatibility shim for versions of googletest without `GTEST_SKIP()` and https://github.com/google/googletest/pull/2203, e.g., the version of googletest in ports and the embedded version in the capsicum-test project, mapping to `GTEST_FAIL()`. The goal in this case was to make `capsicum-test` do a hard stop and not execute if the kernel didn't have capsicum support or `kern.trap_enotcap` was enabled. The only way to achieve this prior to https://github.com/google/googletest/pull/2203, was to trigger a fatal failure, e.g., call `GTEST_FAIL()`. Output the skip diagnostic message via std::cerr, instead of using the `GTEST_{FAIL,SKIP}()` macros. For some reason I don't yet understand, the diagnostic messages aren't being output when both macros are triggered, so there's a bug potentially with googletest version 1.8.1 (but not master) where it's not properly outputting the messages. Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc ============================================================================== --- projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Sun Mar 31 04:57:50 2019 (r345744) +++ projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Sun Mar 31 05:15:32 2019 (r345745) @@ -33,6 +33,12 @@ class SetupEnvironment : public ::testing::Environment std::cerr << tmpdir << std::endl; } void CheckCapsicumSupport() { + // For versions of googletest that lack GTEST_SKIP. +#ifndef GTEST_SKIP +#define GTEST_SKIP GTEST_FAIL +#define GTEST_SKIP_defined +#endif + #ifdef __FreeBSD__ size_t trap_enotcap_enabled_len; int rc; @@ -41,9 +47,13 @@ class SetupEnvironment : public ::testing::Environment trap_enotcap_enabled_len = sizeof(trap_enotcap_enabled); if (feature_present("security_capabilities") == 0) { - GTEST_SKIP() << "Tests require a CAPABILITIES enabled kernel"; + // XXX (ngie): using std::cerr because 1.8.1 (with GTEST_SKIP support) + // isn't properly outputting skip diagnostic message here. + std::cerr << "Tests require a CAPABILITIES enabled kernel" << std::endl; + GTEST_SKIP(); } else { - std::cerr << "Running on a CAPABILITIES enabled kernel" << std::endl; + std::cerr << "Running on a CAPABILITIES enabled kernel - OK!" + << std::endl; } const char *oid = "kern.trap_enotcap"; rc = sysctlbyname(oid, &trap_enotcap_enabled, &trap_enotcap_enabled_len, @@ -52,11 +62,19 @@ class SetupEnvironment : public ::testing::Environment GTEST_FAIL() << "sysctlbyname failed: " << strerror(errno); } if (trap_enotcap_enabled) { - GTEST_SKIP() << "Sysctl " << oid << " enabled. " - << "Skipping tests to avoid non-determinism with results"; + // XXX (ngie): using std::cerr because 1.8.1 (with GTEST_SKIP support) + // isn't properly outputting skip diagnostic message here. + std::cerr << "Sysctl " << oid << " enabled. " + << "Skipping tests to avoid non-determinism with results" + << std::endl; + GTEST_SKIP(); } else { - std::cerr << "Sysctl " << oid << " not enabled." << std::endl; + std::cerr << "Sysctl " << oid << " not enabled - OK!" << std::endl; } +#endif /* FreeBSD */ + +#ifdef GTEST_SKIP_defined +#undef GTEST_SKIP #endif } void CreateTemporaryRoot() { From owner-svn-src-projects@freebsd.org Sun Mar 31 04:24:53 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 09BB51571F80 for ; Sun, 31 Mar 2019 04:24:53 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9C6898EF86; Sun, 31 Mar 2019 04:24:52 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 737A321862; Sun, 31 Mar 2019 04:24:52 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2V4Oqkc075761; Sun, 31 Mar 2019 04:24:52 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2V4OqMS075760; Sun, 31 Mar 2019 04:24:52 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201903310424.x2V4OqMS075760@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Sun, 31 Mar 2019 04:24:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345743 - projects/capsicum-test/contrib/capsicum-test X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/capsicum-test/contrib/capsicum-test X-SVN-Commit-Revision: 345743 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9C6898EF86 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.951,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 04:24:53 -0000 Author: ngie Date: Sun Mar 31 04:24:51 2019 New Revision: 345743 URL: https://svnweb.freebsd.org/changeset/base/345743 Log: Add FreeBSD-specific capsicum feature sanity checks to Environment::SetUp * Not all consumers build with CAPABILITIES enabled kernels, thus, we must check for the `security_capabilities` feature via feature_present(3) before running the tests. Otherwise, the test results are invalid. * Check the `kern.trap_enotcap` sysctl to make sure it's disabled. If it's not disabled, skip the tests. Reason being is that it can trigger failures, as noted in https://github.com/google/capsicum-test/issues/23 by markj@. This fixes the first TODO item in D19758. Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc ============================================================================== --- projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Sun Mar 31 03:19:10 2019 (r345742) +++ projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Sun Mar 31 04:24:51 2019 (r345743) @@ -2,6 +2,8 @@ #ifdef __linux__ #include #include +#elif defined(__FreeBSD__) +#include #endif #include #include @@ -21,6 +23,7 @@ class SetupEnvironment : public ::testing::Environment public: SetupEnvironment() : teardown_tmpdir_(false) {} void SetUp() override { + CheckCapsicumSupport(); if (tmpdir.empty()) { std::cerr << "Generating temporary directory root: "; CreateTemporaryRoot(); @@ -28,6 +31,33 @@ class SetupEnvironment : public ::testing::Environment std::cerr << "User provided temporary directory root: "; } std::cerr << tmpdir << std::endl; + } + void CheckCapsicumSupport() { +#ifdef __FreeBSD__ + size_t trap_enotcap_enabled_len; + int rc; + bool trap_enotcap_enabled; + + trap_enotcap_enabled_len = sizeof(trap_enotcap_enabled); + + if (feature_present("security_capabilities") == 0) { + GTEST_SKIP() << "Tests require a CAPABILITIES enabled kernel"; + } else { + std::cerr << "Running on a CAPABILITIES enabled kernel" << std::endl; + } + const char *oid = "kern.trap_enotcap"; + rc = sysctlbyname(oid, &trap_enotcap_enabled, &trap_enotcap_enabled_len, + nullptr, 0); + if (rc != 0) { + GTEST_FAIL() << "sysctlbyname failed: " << strerror(errno); + } + if (trap_enotcap_enabled) { + GTEST_SKIP() << "Sysctl " << oid << " enabled. " + << "Skipping tests to avoid non-determinism with results"; + } else { + std::cerr << "Sysctl " << oid << " not enabled." << std::endl; + } +#endif } void CreateTemporaryRoot() { char *tmpdir_name = tempnam(nullptr, "cptst"); From owner-svn-src-projects@freebsd.org Sun Mar 31 06:21:33 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 82307154F2BB for ; Sun, 31 Mar 2019 06:21:33 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2A8776BC04; Sun, 31 Mar 2019 06:21:33 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0469E22BD6; Sun, 31 Mar 2019 06:21:33 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2V6LWlp035877; Sun, 31 Mar 2019 06:21:32 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2V6LWC0035875; Sun, 31 Mar 2019 06:21:32 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201903310621.x2V6LWC0035875@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Sun, 31 Mar 2019 06:21:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345750 - in projects/kyua-use-googletest-test-interface/lib/googletest: gmock/tests gtest/tests gtest_main/tests X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: in projects/kyua-use-googletest-test-interface/lib/googletest: gmock/tests gtest/tests gtest_main/tests X-SVN-Commit-Revision: 345750 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 2A8776BC04 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.977,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 06:21:33 -0000 Author: ngie Date: Sun Mar 31 06:21:32 2019 New Revision: 345750 URL: https://svnweb.freebsd.org/changeset/base/345750 Log: Use the test engine interface plain for some googlemock/googletest provided tests The issues are as follows: i. Some tests don't execute `RUN_ALL_TESTS()`. ii. Some tests incorrectly analyze the results when `--gtest_list_tests` is specified on the command line. iii. Some tests assume all tests are run (in order to analyze the results at the end of the test program as part of Environment::TearDown()). The above items cause Kyua googletest engine to bail, since there is spurious output on the command line (in the case of i. and ii.), or failures/asserts are needlessly triggered (in the case of iii.). Add comments noting why the testcases cannot use the googletest interface, along with their respective googletest issues. Case ii: https://github.com/google/googletest/issues/2204 Case iii: https://github.com/google/googletest/issues/2205 Modified: projects/kyua-use-googletest-test-interface/lib/googletest/gmock/tests/Makefile projects/kyua-use-googletest-test-interface/lib/googletest/gtest/tests/Makefile projects/kyua-use-googletest-test-interface/lib/googletest/gtest_main/tests/Makefile Modified: projects/kyua-use-googletest-test-interface/lib/googletest/gmock/tests/Makefile ============================================================================== --- projects/kyua-use-googletest-test-interface/lib/googletest/gmock/tests/Makefile Sun Mar 31 06:20:00 2019 (r345749) +++ projects/kyua-use-googletest-test-interface/lib/googletest/gmock/tests/Makefile Sun Mar 31 06:21:32 2019 (r345750) @@ -8,6 +8,11 @@ GTESTS+= gmock_stress_test LIBADD+= pthread gtest gmock +# This test cannot selectively run a single test, as it verifies results when +# `--gtest_list_tests` is run: +# https://github.com/google/googletest/issues/2204 +TEST_INTERFACE.gmock_stress_test= plain + # The next release will resolve a number of build warnings issues. NO_WERROR= Modified: projects/kyua-use-googletest-test-interface/lib/googletest/gtest/tests/Makefile ============================================================================== --- projects/kyua-use-googletest-test-interface/lib/googletest/gtest/tests/Makefile Sun Mar 31 06:20:00 2019 (r345749) +++ projects/kyua-use-googletest-test-interface/lib/googletest/gtest/tests/Makefile Sun Mar 31 06:21:32 2019 (r345750) @@ -36,6 +36,17 @@ SRCS.googletest-param-test-test= \ LIBADD+= gtest +# These tests confuse the kyua googletest engine, as they don't conform to the +# googletest spec; they're functional unit tests for the library. +TEST_INTERFACE.gtest_environment_test= plain +TEST_INTERFACE.gtest_no_test_unittest= plain +TEST_INTERFACE.gtest_repeat_test= plain +TEST_INTERFACE.gtest_stress_test= plain +TEST_INTERFACE.gtest_throw_on_failure_ex_test= plain +# This test program cannot selectively run test suites/testcases: +# https://github.com/google/googletest/issues/2205 +TEST_INTERFACE.gtest-unittest-api_test= plain + # XXX: explicitly listing -lpthread is incorrect. src.libnames.mk should be # handling this. LIBADD.gtest_stress_test+= pthread Modified: projects/kyua-use-googletest-test-interface/lib/googletest/gtest_main/tests/Makefile ============================================================================== --- projects/kyua-use-googletest-test-interface/lib/googletest/gtest_main/tests/Makefile Sun Mar 31 06:20:00 2019 (r345749) +++ projects/kyua-use-googletest-test-interface/lib/googletest/gtest_main/tests/Makefile Sun Mar 31 06:21:32 2019 (r345750) @@ -21,6 +21,11 @@ GTESTS+= gtest-typed-test_test GTESTS+= gtest_skip_test GTESTS+= gtest_unittest +# This test cannot selectively run a single test, as it verifies results when +# `--gtest_list_tests` is run: +# https://github.com/google/googletest/issues/2204 +TEST_INTERFACE.googletest-listener-test= plain + CXXFLAGS+= -I${GOOGLETEST_SRCROOT}/include CXXFLAGS+= -I${GOOGLETEST_SRCROOT} From owner-svn-src-projects@freebsd.org Sun Mar 31 04:55:24 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9E8641572CA1 for ; Sun, 31 Mar 2019 04:55:24 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 860B48FE48; Sun, 31 Mar 2019 04:55:23 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-io1-f53.google.com with SMTP id u12so4960984iop.11; Sat, 30 Mar 2019 21:55:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc:content-transfer-encoding; bh=bVrcy8H/ypmHJAYNgyxMJTZbiRFEWJbcmXScmo8G4R4=; b=DuKzG6kWloSujVvEztHMudwclymTS9QjCIofXSrRi7QCC9Lxds14rVTz1/ABRFMfeh 9xqkqYUWUeCAUlUoABvLU7IcCJgZAJ/JwndZYCrZyhmBoGOxbspPWsP4xyKmmSZZhkns 1Dd0fhoSF0R8XUEbGYGjK6dsD47N/DbWF3ARtZtA47KpzxFygw4bG7WWOgjfYQlQb6Tj lMqPQJMt9hQFofKBksEZXLC78tXb3BYeOp5/l9EDg7EUzY/KfmciKBJfd2jb0lgOwM// 6CWmhCqLceVJPt5JQllWS7SlzMZVYF5wUooIRytww4BLVTJCYHv9rPSkxUD53Hsntwmh zSOA== X-Gm-Message-State: APjAAAU9i+446ZDrwWVmw1snSwxyBiXrrXT6IRblYBf2/dGpjmLngiQ9 3rl4xcLbeWuOt2oc5J0mBohldHh+ X-Google-Smtp-Source: APXvYqwOyIr9TRquQEv9j5wr5paPy8jNvj1FSUPidbLWpL/BCbdA5oMa2rEBIs6Pl+8gJw3069DDaw== X-Received: by 2002:a6b:e418:: with SMTP id u24mr39276390iog.128.1554008117164; Sat, 30 Mar 2019 21:55:17 -0700 (PDT) Received: from mail-io1-f53.google.com (mail-io1-f53.google.com. [209.85.166.53]) by smtp.gmail.com with ESMTPSA id q22sm2880867ion.15.2019.03.30.21.55.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Mar 2019 21:55:17 -0700 (PDT) Received: by mail-io1-f53.google.com with SMTP id n11so5015863ioh.1; Sat, 30 Mar 2019 21:55:17 -0700 (PDT) X-Received: by 2002:a5e:a710:: with SMTP id b16mr37337357iod.233.1554008116940; Sat, 30 Mar 2019 21:55:16 -0700 (PDT) MIME-Version: 1.0 References: <201903310319.x2V3JAGH038626@repo.freebsd.org> In-Reply-To: <201903310319.x2V3JAGH038626@repo.freebsd.org> Reply-To: cem@freebsd.org From: Conrad Meyer Date: Sat, 30 Mar 2019 21:55:06 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r345742 - projects/fuse2/sys/fs/fuse To: Alan Somers Cc: src-committers , svn-src-projects@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 860B48FE48 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of csecem@gmail.com designates 209.85.166.53 as permitted sender) smtp.mailfrom=csecem@gmail.com X-Spamd-Result: default: False [-4.18 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_REPLYTO(0.00)[cem@freebsd.org]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; REPLYTO_ADDR_EQ_FROM(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; MX_GOOD(-0.01)[cached: alt3.gmail-smtp-in.l.google.com]; FORGED_SENDER(0.30)[cem@freebsd.org,csecem@gmail.com]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; TAGGED_FROM(0.00)[]; FROM_NEQ_ENVFROM(0.00)[cem@freebsd.org,csecem@gmail.com]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[freebsd.org]; NEURAL_SPAM_SHORT(0.17)[0.166,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; IP_SCORE(-2.34)[ip: (-5.61), ipnet: 209.85.128.0/17(-3.87), asn: 15169(-2.15), country: US(-0.07)]; RCVD_IN_DNSWL_NONE(0.00)[53.166.85.209.list.dnswl.org : 127.0.5.0]; RWL_MAILSPIKE_POSSIBLE(0.00)[53.166.85.209.rep.mailspike.net : 127.0.0.17] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 04:55:24 -0000 Hi Alan, On Sat, Mar 30, 2019 at 8:19 PM Alan Somers wrote: > ... > Discussed with: cem I don't object to the change, but I'm not sure the "discussed with" tag is appropriate here =E2=80=94 to me it implies at least some level of consensus reached. Best, Conrad From owner-svn-src-projects@freebsd.org Sun Mar 31 16:56:38 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D440615652E4 for ; Sun, 31 Mar 2019 16:56:37 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 734F889409; Sun, 31 Mar 2019 16:56:37 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0C84619BD; Sun, 31 Mar 2019 16:56:37 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2VGuaaf071355; Sun, 31 Mar 2019 16:56:36 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2VGuaf0071354; Sun, 31 Mar 2019 16:56:36 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201903311656.x2VGuaf0071354@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Sun, 31 Mar 2019 16:56:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345755 - projects/capsicum-test/contrib/capsicum-test X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/capsicum-test/contrib/capsicum-test X-SVN-Commit-Revision: 345755 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 734F889409 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.957,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 16:56:38 -0000 Author: ngie Date: Sun Mar 31 16:56:36 2019 New Revision: 345755 URL: https://svnweb.freebsd.org/changeset/base/345755 Log: Remove comment and fold std::cerr call into GTEST_SKIP() There's a missing set of commits that is preventing D19765 from working on this branch (it works on googletest master). Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc ============================================================================== --- projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Sun Mar 31 14:18:02 2019 (r345754) +++ projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Sun Mar 31 16:56:36 2019 (r345755) @@ -47,10 +47,7 @@ class SetupEnvironment : public ::testing::Environment trap_enotcap_enabled_len = sizeof(trap_enotcap_enabled); if (feature_present("security_capabilities") == 0) { - // XXX (ngie): using std::cerr because 1.8.1 (with GTEST_SKIP support) - // isn't properly outputting skip diagnostic message here. - std::cerr << "Tests require a CAPABILITIES enabled kernel" << std::endl; - GTEST_SKIP(); + GTEST_SKIP() << "Tests require a CAPABILITIES enabled kernel"; } else { std::cerr << "Running on a CAPABILITIES enabled kernel - OK!" << std::endl; @@ -62,12 +59,8 @@ class SetupEnvironment : public ::testing::Environment GTEST_FAIL() << "sysctlbyname failed: " << strerror(errno); } if (trap_enotcap_enabled) { - // XXX (ngie): using std::cerr because 1.8.1 (with GTEST_SKIP support) - // isn't properly outputting skip diagnostic message here. - std::cerr << "Sysctl " << oid << " enabled. " - << "Skipping tests to avoid non-determinism with results" - << std::endl; - GTEST_SKIP(); + GTEST_SKIP() << "Sysctl " << oid << " enabled. " + << "Skipping tests to avoid non-determinism with results"; } else { std::cerr << "Sysctl " << oid << " not enabled - OK!" << std::endl; } From owner-svn-src-projects@freebsd.org Sun Mar 31 17:27:30 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0FC35156627F for ; Sun, 31 Mar 2019 17:27:30 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A37CD8A65A; Sun, 31 Mar 2019 17:27:29 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 71F201F26; Sun, 31 Mar 2019 17:27:29 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2VHRTRh087610; Sun, 31 Mar 2019 17:27:29 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2VHRTum087609; Sun, 31 Mar 2019 17:27:29 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201903311727.x2VHRTum087609@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Sun, 31 Mar 2019 17:27:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345756 - projects/capsicum-test/contrib/googletest/googletest/src X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/capsicum-test/contrib/googletest/googletest/src X-SVN-Commit-Revision: 345756 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: A37CD8A65A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.957,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 17:27:30 -0000 Author: ngie Date: Sun Mar 31 17:27:28 2019 New Revision: 345756 URL: https://svnweb.freebsd.org/changeset/base/345756 Log: Import the missing hunk from r345740 This makes the proof-of-concept actually work. Modified: projects/capsicum-test/contrib/googletest/googletest/src/gtest.cc Modified: projects/capsicum-test/contrib/googletest/googletest/src/gtest.cc ============================================================================== --- projects/capsicum-test/contrib/googletest/googletest/src/gtest.cc Sun Mar 31 16:56:36 2019 (r345755) +++ projects/capsicum-test/contrib/googletest/googletest/src/gtest.cc Sun Mar 31 17:27:28 2019 (r345756) @@ -5243,9 +5243,23 @@ bool UnitTestImpl::RunAllTests() { ForEach(environments_, SetUpEnvironment); repeater->OnEnvironmentsSetUpEnd(*parent_); - // Runs the tests only if there was no fatal failure during global - // set-up. - if (!Test::HasFatalFailure()) { + // Runs the tests only if there was no fatal failure or skip triggered + // during global set-up. + if (Test::IsSkipped()) { + // Emit diagnostics when global set-up calls skip, as it will not be + // emitted by default. + TestResult& test_result = + *internal::GetUnitTestImpl()->current_test_result(); + for (int j = 0; j < test_result.total_part_count(); ++j) { + const TestPartResult& test_part_result = + test_result.GetTestPartResult(j); + if (test_part_result.type() == TestPartResult::kSkip) { + const std::string& result = test_part_result.message(); + printf("%s\n", result.c_str()); + } + } + fflush(stdout); + } else if (!Test::HasFatalFailure()) { for (int test_index = 0; test_index < total_test_case_count(); test_index++) { GetMutableTestCase(test_index)->Run(); From owner-svn-src-projects@freebsd.org Sun Mar 31 23:18:13 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0892F1570376 for ; Sun, 31 Mar 2019 23:18:13 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9BD8E954A7; Sun, 31 Mar 2019 23:18:12 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7163B5D66; Sun, 31 Mar 2019 23:18:12 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2VNIC1w070402; Sun, 31 Mar 2019 23:18:12 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2VNICvp070401; Sun, 31 Mar 2019 23:18:12 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201903312318.x2VNICvp070401@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Sun, 31 Mar 2019 23:18:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345759 - projects/capsicum-test/contrib/capsicum-test X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/capsicum-test/contrib/capsicum-test X-SVN-Commit-Revision: 345759 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9BD8E954A7 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.975,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2019 23:18:13 -0000 Author: ngie Date: Sun Mar 31 23:18:12 2019 New Revision: 345759 URL: https://svnweb.freebsd.org/changeset/base/345759 Log: Apply suggestions * Sort preprocessor define blocks. * Reword messages when skipping due to missing prereqs. Requested by: emaste (https://github.com/google/capsicum-test/pull/42) * Remove diagnostic `std::cerr`'s, since the root-cause for the checks not working before was found and addressed in D19765. Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc ============================================================================== --- projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Sun Mar 31 21:34:58 2019 (r345758) +++ projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Sun Mar 31 23:18:12 2019 (r345759) @@ -1,9 +1,9 @@ #include -#ifdef __linux__ +#if defined(__FreeBSD__) +#include +#elif defined(__linux__) #include #include -#elif defined(__FreeBSD__) -#include #endif #include #include @@ -47,10 +47,8 @@ class SetupEnvironment : public ::testing::Environment trap_enotcap_enabled_len = sizeof(trap_enotcap_enabled); if (feature_present("security_capabilities") == 0) { - GTEST_SKIP() << "Tests require a CAPABILITIES enabled kernel"; - } else { - std::cerr << "Running on a CAPABILITIES enabled kernel - OK!" - << std::endl; + GTEST_SKIP() << "Skipping tests because capsicum support is not " + << "enabled in the kernel."; } const char *oid = "kern.trap_enotcap"; rc = sysctlbyname(oid, &trap_enotcap_enabled, &trap_enotcap_enabled_len, @@ -61,8 +59,6 @@ class SetupEnvironment : public ::testing::Environment if (trap_enotcap_enabled) { GTEST_SKIP() << "Sysctl " << oid << " enabled. " << "Skipping tests to avoid non-determinism with results"; - } else { - std::cerr << "Sysctl " << oid << " not enabled - OK!" << std::endl; } #endif /* FreeBSD */ From owner-svn-src-projects@freebsd.org Mon Apr 1 05:53:29 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8D89C1582851 for ; Mon, 1 Apr 2019 05:53:29 +0000 (UTC) (envelope-from SRS0=8Ful=SD=vega.codepro.be=kp@codepro.be) Received: from venus.codepro.be (venus.codepro.be [IPv6:2a01:4f8:162:1127::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.codepro.be", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8906F7700B; Mon, 1 Apr 2019 05:53:28 +0000 (UTC) (envelope-from SRS0=8Ful=SD=vega.codepro.be=kp@codepro.be) Received: from vega.codepro.be (unknown [172.16.1.3]) by venus.codepro.be (Postfix) with ESMTP id 0005A2E0C2; Mon, 1 Apr 2019 07:53:18 +0200 (CEST) Received: by vega.codepro.be (Postfix, from userid 1001) id F10BD260A0; Mon, 1 Apr 2019 07:53:18 +0200 (CEST) Date: Mon, 1 Apr 2019 07:53:18 +0200 From: Kristof Provost To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345760 - in head: contrib/pf sys/netpfil/pf sbin/pfctl Message-ID: <20190401055318.GI7163@vega.codepro.be> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: in head: contrib/pf sys/netpfil/pf sbin/pfctl X-SVN-Commit-Revision: 345760 X-SVN-Commit-Repository: base Precedence: bulk X-Loop: FreeBSD.org User-Agent: Mutt/1.11.2 (2019-01-07) X-Rspamd-Queue-Id: 8906F7700B X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of SRS0=8Ful=SD=vega.codepro.be=kp@codepro.be designates 2a01:4f8:162:1127::2 as permitted sender) smtp.mailfrom=SRS0=8Ful=SD=vega.codepro.be=kp@codepro.be X-Spamd-Result: default: False [-6.00 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2a01:4f8:162:1127::2]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; PRECEDENCE_BULK(0.00)[]; DMARC_NA(0.00)[freebsd.org]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCVD_COUNT_THREE(0.00)[3]; RCVD_TLS_LAST(0.00)[]; RCVD_IN_DNSWL_MED(-0.20)[2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.7.2.1.1.2.6.1.0.8.f.4.0.1.0.a.2.list.dnswl.org : 127.0.9.2]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-0.96)[-0.962,0]; MX_GOOD(-0.01)[mx2.codepro.be,mx1.codepro.be]; MAILLIST(-0.10)[generic]; IP_SCORE(-2.43)[ip: (-8.03), ipnet: 2a01:4f8::/29(-2.17), asn: 24940(-1.94), country: DE(-0.01)]; FORGED_SENDER(0.00)[kp@freebsd.org,SRS0=8Ful=SD=vega.codepro.be=kp@codepro.be]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:2a01:4f8::/29, country:DE]; FROM_NEQ_ENVFROM(0.00)[kp@freebsd.org,SRS0=8Ful=SD=vega.codepro.be=kp@codepro.be]; FORGED_SENDER_MAILLIST(0.00)[] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 05:53:30 -0000 Author: kp Date: Mon Apr 1 06:51:32 2019 New Revision: 345760 URL: https://svnweb.freebsd.org/changeset/base/345625 Log: pf: Remove obsolete pf pf in FreeBSD lags years behind OpenBSD's pf. Remove it. Users are advised to migrate to ipf. Deleted: head/contrib/pf/authpf/authpf.8 head/contrib/pf/authpf/authpf.c head/contrib/pf/authpf/pathnames.h head/contrib/pf/ftp-proxy/filter.c head/contrib/pf/ftp-proxy/filter.h head/contrib/pf/ftp-proxy/ftp-proxy.8 head/contrib/pf/ftp-proxy/ftp-proxy.c head/contrib/pf/libevent/buffer.c head/contrib/pf/libevent/evbuffer.c head/contrib/pf/libevent/event-internal.h head/contrib/pf/libevent/event.c head/contrib/pf/libevent/event.h head/contrib/pf/libevent/evsignal.h head/contrib/pf/libevent/kqueue.c head/contrib/pf/libevent/log.c head/contrib/pf/libevent/log.h head/contrib/pf/libevent/poll.c head/contrib/pf/libevent/select.c head/contrib/pf/libevent/signal.c head/contrib/pf/pflogd/pflogd.8 head/contrib/pf/pflogd/pflogd.c head/contrib/pf/pflogd/pflogd.h head/contrib/pf/pflogd/pidfile.c head/contrib/pf/pflogd/pidfile.h head/contrib/pf/pflogd/privsep.c head/contrib/pf/pflogd/privsep_fdpass.c head/contrib/pf/tftp-proxy/filter.c head/contrib/pf/tftp-proxy/filter.h head/contrib/pf/tftp-proxy/tftp-proxy.8 head/contrib/pf/tftp-proxy/tftp-proxy.c head/contrib/tcpdump/print-pflog.c head/contrib/tcpdump/print-pfsync.c head/sbin/pfctl/Makefile head/sbin/pfctl/parse.y head/sbin/pfctl/pf.os head/sbin/pfctl/pf_print_state.c head/sbin/pfctl/pfctl.8 head/sbin/pfctl/pfctl.c head/sbin/pfctl/pfctl.h head/sbin/pfctl/pfctl_altq.c head/sbin/pfctl/pfctl_optimize.c head/sbin/pfctl/pfctl_osfp.c head/sbin/pfctl/pfctl_parser.c head/sbin/pfctl/pfctl_parser.h head/sbin/pfctl/pfctl_qstats.c head/sbin/pfctl/pfctl_radix.c head/sbin/pfctl/pfctl_table.c head/sys/modules/pf/Makefile head/sys/modules/pflog/Makefile head/sys/modules/pfsync/Makefile head/sys/netpfil/pf/if_pflog.c head/sys/netpfil/pf/if_pfsync.c head/sys/netpfil/pf/in4_cksum.c head/sys/netpfil/pf/pf.c head/sys/netpfil/pf/pf.h head/sys/netpfil/pf/pf_altq.h head/sys/netpfil/pf/pf_if.c head/sys/netpfil/pf/pf_ioctl.c head/sys/netpfil/pf/pf_lb.c head/sys/netpfil/pf/pf_mtag.h head/sys/netpfil/pf/pf_norm.c head/sys/netpfil/pf/pf_osfp.c head/sys/netpfil/pf/pf_ruleset.c head/sys/netpfil/pf/pf_table.c Index: contrib/pf/authpf/authpf.8 =================================================================== --- contrib/pf/authpf/authpf.8 (revision 345223) +++ contrib/pf/authpf/authpf.8 (working copy) @@ -1,584 +0,0 @@ -.\" $FreeBSD$ -.\" $OpenBSD: authpf.8,v 1.47 2009/01/06 03:11:50 mcbride Exp $ -.\" -.\" Copyright (c) 1998-2007 Bob Beck (beck@openbsd.org>. All rights reserved. -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.\" -.Dd January 29 2014 -.Dt AUTHPF 8 -.Os -.Sh NAME -.Nm authpf , -.Nm authpf-noip -.Nd authenticating gateway user shell -.Sh SYNOPSIS -.Nm authpf -.Nm authpf-noip -.Sh DESCRIPTION -.Nm -is a user shell for authenticating gateways. -It is used to change -.Xr pf 4 -rules when a user authenticates and starts a session with -.Xr sshd 8 -and to undo these changes when the user's session exits. -Typical use would be for a gateway that authenticates users before -allowing them Internet use, or a gateway that allows different users into -different places. -Combined with properly set up filter rules and secure switches, -.Nm -can be used to ensure users are held accountable for their network traffic. -It is meant to be used with users who can connect via -.Xr ssh 1 -only, and requires the -.Xr pf 4 -subsystem and an -.Xr fdescfs 5 -file system mounted at -.Pa /dev/fd -to be enabled. -.Pp -.Nm authpf-noip -is a user shell -which allows multiple connections to take -place from the same IP address. -It is useful primarily in cases where connections are tunneled via -the gateway system, and can be directly associated with the user name. -It cannot ensure accountability when -classifying connections by IP address; -in this case the client's IP address -is not provided to the packet filter via the -.Ar client_ip -macro or the -.Ar authpf_users -table. -Additionally, states associated with the client IP address -are not purged when the session is ended. -.Pp -To use either -.Nm -or -.Nm authpf-noip , -the user's shell needs to be set to -.Pa /usr/sbin/authpf -or -.Pa /usr/sbin/authpf-noip . -.Pp -.Nm -uses the -.Xr pf.conf 5 -syntax to change filter and translation rules for an individual -user or client IP address as long as a user maintains an active -.Xr ssh 1 -session, and logs the successful start and end of a session to -.Xr syslogd 8 . -.Nm -retrieves the client's connecting IP address via the -.Ev SSH_CLIENT -environment variable and, after performing additional access checks, -reads a template file to determine what filter and translation rules -(if any) to add, and -maintains the list of IP addresses of connected users in the -.Ar authpf_users -table. -On session exit the same rules and table entries that were added at startup -are removed, and all states associated with the client's IP address are purged. -.Pp -Each -.Nm -process stores its rules in a separate ruleset inside a -.Xr pf 4 -.Pa anchor -shared by all -.Nm -processes. -By default, the -.Pa anchor -name "authpf" is used, and the ruleset names equal the username and PID of the -.Nm -processes as "username(pid)". -The following rules need to be added to the main ruleset -.Pa /etc/pf.conf -in order to cause evaluation of any -.Nm -rules: -.Bd -literal -offset indent -nat-anchor "authpf/*" -rdr-anchor "authpf/*" -binat-anchor "authpf/*" -anchor "authpf/*" -.Ed -.Pp -The "/*" at the end of the anchor name is required for -.Xr pf 4 -to process the rulesets attached to the anchor by -.Nm authpf . -.Sh FILTER AND TRANSLATION RULES -Filter and translation rules for -.Nm -use the same format described in -.Xr pf.conf 5 . -The only difference is that these rules may (and probably should) use -the macro -.Em user_ip , -which is assigned the connecting IP address whenever -.Nm -is run. -Additionally, the macro -.Em user_id -is assigned the user name. -.Pp -Filter and translation rules are stored in a file called -.Pa authpf.rules . -This file will first be searched for in -.Pa /etc/authpf/users/$USER/ -and then in -.Pa /etc/authpf/ . -Only one of these files will be used if both are present. -.Pp -Per-user rules from the -.Pa /etc/authpf/users/$USER/ -directory are intended to be used when non-default rules -are needed on an individual user basis. -It is important to ensure that a user can not write or change -these configuration files. -.Pp -The -.Pa authpf.rules -file must exist in one of the above locations for -.Nm -to run. -.Sh CONFIGURATION -Options are controlled by the -.Pa /etc/authpf/authpf.conf -file. -If the file is empty, defaults are used for all -configuration options. -The file consists of pairs of the form -.Li name=value , -one per line. -Currently, the allowed values are as follows: -.Bl -tag -width Ds -.It anchor=name -Use the specified -.Pa anchor -name instead of "authpf". -.It table=name -Use the specified -.Pa table -name instead of "authpf_users". -.El -.Sh USER MESSAGES -On successful invocation, -.Nm -displays a message telling the user he or she has been authenticated. -It will additionally display the contents of the file -.Pa /etc/authpf/authpf.message -if the file exists and is readable. -.Pp -There exist two methods for providing additional granularity to the control -offered by -.Nm -- it is possible to set the gateway to explicitly allow users who have -authenticated to -.Xr ssh 1 -and deny access to only a few troublesome individuals. -This is done by creating a file with the banned user's login name as the -filename in -.Pa /etc/authpf/banned/ . -The contents of this file will be displayed to a banned user, thus providing -a method for informing the user that they have been banned, and where they can -go and how to get there if they want to have their service restored. -This is the default behaviour. -.Pp -It is also possible to configure -.Nm -to only allow specific users access. -This is done by listing their login names, one per line, in -.Pa /etc/authpf/authpf.allow . -A group of users can also be indicated by prepending "%" to the group name, -and all members of a login class can be indicated by prepending "@" to the -login class name. -If "*" is found on a line, then all usernames match. -If -.Nm -is unable to verify the user's permission to use the gateway, it will -print a brief message and die. -It should be noted that a ban takes precedence over an allow. -.Pp -On failure, messages will be logged to -.Xr syslogd 8 -for the system administrator. -The user does not see these, but will be told the system is unavailable due to -technical difficulties. -The contents of the file -.Pa /etc/authpf/authpf.problem -will also be displayed if the file exists and is readable. -.Sh CONFIGURATION ISSUES -.Nm -maintains the changed filter rules as long as the user maintains an -active session. -It is important to remember however, that the existence -of this session means the user is authenticated. -Because of this, it is important to configure -.Xr sshd 8 -to ensure the security of the session, and to ensure that the network -through which users connect is secure. -.Xr sshd 8 -should be configured to use the -.Ar ClientAliveInterval -and -.Ar ClientAliveCountMax -parameters to ensure that a ssh session is terminated quickly if -it becomes unresponsive, or if arp or address spoofing is used to -hijack the session. -Note that TCP keepalives are not sufficient for -this, since they are not secure. -Also note that the various SSH tunnelling mechanisms, -such as -.Ar AllowTcpForwarding -and -.Ar PermitTunnel , -should be disabled for -.Nm -users to prevent them from circumventing restrictions imposed by the -packet filter ruleset. -.Pp -.Nm -will remove state table entries that were created during a user's -session. -This ensures that there will be no unauthenticated traffic -allowed to pass after the controlling -.Xr ssh 1 -session has been closed. -.Pp -.Nm -is designed for gateway machines which typically do not have regular -(non-administrative) users using the machine. -An administrator must remember that -.Nm -can be used to modify the filter rules through the environment in -which it is run, and as such could be used to modify the filter rules -(based on the contents of the configuration files) by regular -users. -In the case where a machine has regular users using it, as well -as users with -.Nm -as their shell, the regular users should be prevented from running -.Nm -by using the -.Pa /etc/authpf/authpf.allow -or -.Pa /etc/authpf/banned/ -facilities. -.Pp -.Nm -modifies the packet filter and address translation rules, and because -of this it needs to be configured carefully. -.Nm -will not run and will exit silently if the -.Pa /etc/authpf/authpf.conf -file does not exist. -After considering the effect -.Nm -may have on the main packet filter rules, the system administrator may -enable -.Nm -by creating an appropriate -.Pa /etc/authpf/authpf.conf -file. -.Sh EXAMPLES -.Sy Control Files -\- To illustrate the user-specific access control -mechanisms, let us consider a typical user named bob. -Normally, as long as bob can authenticate himself, the -.Nm -program will load the appropriate rules. -Enter the -.Pa /etc/authpf/banned/ -directory. -If bob has somehow fallen from grace in the eyes of the -powers-that-be, they can prohibit him from using the gateway by creating -the file -.Pa /etc/authpf/banned/bob -containing a message about why he has been banned from using the network. -Once bob has done suitable penance, his access may be restored by moving or -removing the file -.Pa /etc/authpf/banned/bob . -.Pp -Now consider a workgroup containing alice, bob, carol and dave. -They have a -wireless network which they would like to protect from unauthorized use. -To accomplish this, they create the file -.Pa /etc/authpf/authpf.allow -which lists their login ids, group prepended with "%", or login class -prepended with "@", one per line. -At this point, even if eve could authenticate to -.Xr sshd 8 , -she would not be allowed to use the gateway. -Adding and removing users from -the work group is a simple matter of maintaining a list of allowed userids. -If bob once again manages to annoy the powers-that-be, they can ban him from -using the gateway by creating the familiar -.Pa /etc/authpf/banned/bob -file. -Though bob is listed in the allow file, he is prevented from using -this gateway due to the existence of a ban file. -.Pp -.Sy Distributed Authentication -\- It is often desirable to interface with a -distributed password system rather than forcing the sysadmins to keep a large -number of local password files in sync. -The -.Xr login.conf 5 -mechanism in -.Ox -can be used to fork the right shell. -To make that happen, -.Xr login.conf 5 -should have entries that look something like this: -.Bd -literal -offset indent -shell-default:shell=/bin/csh - -default:\e - ... - :shell=/usr/sbin/authpf - -daemon:\e - ... - :shell=/bin/csh:\e - :tc=default: - -staff:\e - ... - :shell=/bin/csh:\e - :tc=default: -.Ed -.Pp -Using a default password file, all users will get -.Nm -as their shell except for root who will get -.Pa /bin/csh . -.Pp -.Sy SSH Configuration -\- As stated earlier, -.Xr sshd 8 -must be properly configured to detect and defeat network attacks. -To that end, the following options should be added to -.Xr sshd_config 5 : -.Bd -literal -offset indent -Protocol 2 -ClientAliveInterval 15 -ClientAliveCountMax 3 -.Ed -.Pp -This ensures that unresponsive or spoofed sessions are terminated within a -minute, since a hijacker should not be able to spoof ssh keepalive messages. -.Pp -.Sy Banners -\- Once authenticated, the user is shown the contents of -.Pa /etc/authpf/authpf.message . -This message may be a screen-full of the appropriate use policy, the contents -of -.Pa /etc/motd -or something as simple as the following: -.Bd -literal -offset indent -This means you will be held accountable by the powers that be -for traffic originating from your machine, so please play nice. -.Ed -.Pp -To tell the user where to go when the system is broken, -.Pa /etc/authpf/authpf.problem -could contain something like this: -.Bd -literal -offset indent -Sorry, there appears to be some system problem. To report this -problem so we can fix it, please phone 1-900-314-1597 or send -an email to remove@bulkmailerz.net. -.Ed -.Pp -.Sy Packet Filter Rules -\- In areas where this gateway is used to protect a -wireless network (a hub with several hundred ports), the default rule set as -well as the per-user rules should probably allow very few things beyond -encrypted protocols like -.Xr ssh 1 , -.Xr ssl 8 , -or -.Xr ipsec 4 . -On a securely switched network, with plug-in jacks for visitors who are -given authentication accounts, you might want to allow out everything. -In this context, a secure switch is one that tries to prevent address table -overflow attacks. -.Pp -Example -.Pa /etc/pf.conf : -.Bd -literal -# by default we allow internal clients to talk to us using -# ssh and use us as a dns server. -internal_if="fxp1" -gateway_addr="10.0.1.1" -nat-anchor "authpf/*" -rdr-anchor "authpf/*" -binat-anchor "authpf/*" -block in on $internal_if from any to any -pass in quick on $internal_if proto tcp from any to $gateway_addr \e - port = ssh -pass in quick on $internal_if proto udp from any to $gateway_addr \e - port = domain -anchor "authpf/*" -.Ed -.Pp -.Sy For a switched, wired net -\- This example -.Pa /etc/authpf/authpf.rules -makes no real restrictions; it turns the IP address on and off, logging -TCP connections. -.Bd -literal -external_if = "xl0" -internal_if = "fxp0" - -pass in log quick on $internal_if proto tcp from $user_ip to any -pass in quick on $internal_if from $user_ip to any -.Ed -.Pp -.Sy For a wireless or shared net -\- This example -.Pa /etc/authpf/authpf.rules -could be used for an insecure network (such as a public wireless network) where -we might need to be a bit more restrictive. -.Bd -literal -internal_if="fxp1" -ipsec_gw="10.2.3.4" - -# rdr ftp for proxying by ftp-proxy(8) -rdr on $internal_if proto tcp from $user_ip to any port 21 \e - -> 127.0.0.1 port 8021 - -# allow out ftp, ssh, www and https only, and allow user to negotiate -# ipsec with the ipsec server. -pass in log quick on $internal_if proto tcp from $user_ip to any \e - port { 21, 22, 80, 443 } -pass in quick on $internal_if proto tcp from $user_ip to any \e - port { 21, 22, 80, 443 } -pass in quick proto udp from $user_ip to $ipsec_gw port = isakmp -pass in quick proto esp from $user_ip to $ipsec_gw -.Ed -.Pp -.Sy Dealing with NAT -\- The following -.Pa /etc/authpf/authpf.rules -shows how to deal with NAT, using tags: -.Bd -literal -ext_if = "fxp1" -ext_addr = 129.128.11.10 -int_if = "fxp0" -# nat and tag connections... -nat on $ext_if from $user_ip to any tag $user_ip -> $ext_addr -pass in quick on $int_if from $user_ip to any -pass out log quick on $ext_if tagged $user_ip -.Ed -.Pp -With the above rules added by -.Nm , -outbound connections corresponding to each users NAT'ed connections -will be logged as in the example below, where the user may be identified -from the ruleset name. -.Bd -literal -# tcpdump -n -e -ttt -i pflog0 -Oct 31 19:42:30.296553 rule 0.bbeck(20267).1/0(match): pass out on fxp1: \e -129.128.11.10.60539 > 198.137.240.92.22: S 2131494121:2131494121(0) win \e -16384 (DF) -.Ed -.Pp -.Sy Using the authpf_users table -\- Simple -.Nm -settings can be implemented without an anchor by just using the "authpf_users" -.Pa table . -For example, the following -.Xr pf.conf 5 -lines will give SMTP and IMAP access to logged in users: -.Bd -literal -table persist -pass in on $ext_if proto tcp from \e - to port { smtp imap } -.Ed -.Pp -It is also possible to use the "authpf_users" -.Pa table -in combination with anchors. -For example, -.Xr pf 4 -processing can be sped up by looking up the anchor -only for packets coming from logged in users: -.Bd -literal -table persist -anchor "authpf/*" from -rdr-anchor "authpf/*" from -.Ed -.Pp -.Sy Tunneled users -\- normally -.Nm -allows only one session per client IP address. -However in some cases, such as when connections are tunneled via -.Xr ssh 1 -or -.Xr ipsec 4 , -the connections can be authorized based on the userid of the user instead of -the client IP address. -In this case it is appropriate to use -.Nm authpf-noip -to allow multiple users behind a NAT gateway to connect. -In the -.Pa /etc/authpf/authpf.rules -example below, the remote user could tunnel a remote desktop session to their -workstation: -.Bd -literal -internal_if="bge0" -workstation_ip="10.2.3.4" - -pass out on $internal_if from (self) to $workstation_ip port 3389 \e - user $user_id -.Ed -.Sh FILES -.Bl -tag -width "/etc/authpf/authpf.conf" -compact -.It Pa /etc/authpf/authpf.conf -.It Pa /etc/authpf/authpf.allow -.It Pa /etc/authpf/authpf.rules -.It Pa /etc/authpf/authpf.message -.It Pa /etc/authpf/authpf.problem -.El -.Sh SEE ALSO -.Xr pf 4 , -.Xr fdescfs 5 , -.Xr pf.conf 5 , -.Xr securelevel 7 , -.Xr ftp-proxy 8 -.Sh HISTORY -The -.Nm -program first appeared in -.Ox 3.1 . -.Sh BUGS -Configuration issues are tricky. -The authenticating -.Xr ssh 1 -connection may be secured, but if the network is not secured the user may -expose insecure protocols to attackers on the same network, or enable other -attackers on the network to pretend to be the user by spoofing their IP -address. -.Pp -.Nm -is not designed to prevent users from denying service to other users. Index: contrib/pf/authpf/pathnames.h =================================================================== --- contrib/pf/authpf/pathnames.h (revision 345223) +++ contrib/pf/authpf/pathnames.h (working copy) @@ -1,39 +0,0 @@ -/* $OpenBSD: pathnames.h,v 1.8 2008/02/14 01:49:17 mcbride Exp $ */ - -/* - * Copyright (C) 2002 Chris Kuethe (ckuethe@ualberta.ca) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#define PATH_CONFFILE "/etc/authpf/authpf.conf" -#define PATH_ALLOWFILE "/etc/authpf/authpf.allow" -#define PATH_PFRULES "/etc/authpf/authpf.rules" -#define PATH_PROBLEM "/etc/authpf/authpf.problem" -#define PATH_MESSAGE "/etc/authpf/authpf.message" -#define PATH_USER_DIR "/etc/authpf/users" -#define PATH_BAN_DIR "/etc/authpf/banned" -#define PATH_DEVFILE "/dev/pf" -#define PATH_PIDFILE "/var/authpf" -#define PATH_AUTHPF_SHELL "/usr/sbin/authpf" -#define PATH_AUTHPF_SHELL_NOIP "/usr/sbin/authpf-noip" -#define PATH_PFCTL "/sbin/pfctl" Index: contrib/pf/ftp-proxy/filter.c =================================================================== --- contrib/pf/ftp-proxy/filter.c (revision 345223) +++ contrib/pf/ftp-proxy/filter.c (working copy) @@ -1,393 +0,0 @@ -/* $OpenBSD: filter.c,v 1.8 2008/06/13 07:25:26 claudio Exp $ */ - -/* - * Copyright (c) 2004, 2005 Camiel Dobbelaar, - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "filter.h" - -/* From netinet/in.h, but only _KERNEL_ gets them. */ -#define satosin(sa) ((struct sockaddr_in *)(sa)) -#define satosin6(sa) ((struct sockaddr_in6 *)(sa)) - -enum { TRANS_FILTER = 0, TRANS_NAT, TRANS_RDR, TRANS_SIZE }; - -int prepare_rule(u_int32_t, int, struct sockaddr *, struct sockaddr *, - u_int16_t); -int server_lookup4(struct sockaddr_in *, struct sockaddr_in *, - struct sockaddr_in *); -int server_lookup6(struct sockaddr_in6 *, struct sockaddr_in6 *, - struct sockaddr_in6 *); - -static struct pfioc_pooladdr pfp; -static struct pfioc_rule pfr; -static struct pfioc_trans pft; -static struct pfioc_trans_e pfte[TRANS_SIZE]; -static int dev, rule_log; -static const char *qname, *tagname; - -int -add_filter(u_int32_t id, u_int8_t dir, struct sockaddr *src, - struct sockaddr *dst, u_int16_t d_port) -{ - if (!src || !dst || !d_port) { - errno = EINVAL; - return (-1); - } - - if (prepare_rule(id, PF_RULESET_FILTER, src, dst, d_port) == -1) - return (-1); - - pfr.rule.direction = dir; - if (ioctl(dev, DIOCADDRULE, &pfr) == -1) - return (-1); - - return (0); -} - -int -add_nat(u_int32_t id, struct sockaddr *src, struct sockaddr *dst, - u_int16_t d_port, struct sockaddr *nat, u_int16_t nat_range_low, - u_int16_t nat_range_high) -{ - if (!src || !dst || !d_port || !nat || !nat_range_low || - (src->sa_family != nat->sa_family)) { - errno = EINVAL; - return (-1); - } - - if (prepare_rule(id, PF_RULESET_NAT, src, dst, d_port) == -1) - return (-1); - - if (nat->sa_family == AF_INET) { - memcpy(&pfp.addr.addr.v.a.addr.v4, - &satosin(nat)->sin_addr.s_addr, 4); - memset(&pfp.addr.addr.v.a.mask.addr8, 255, 4); - } else { - memcpy(&pfp.addr.addr.v.a.addr.v6, - &satosin6(nat)->sin6_addr.s6_addr, 16); - memset(&pfp.addr.addr.v.a.mask.addr8, 255, 16); - } - if (ioctl(dev, DIOCADDADDR, &pfp) == -1) - return (-1); - - pfr.rule.rpool.proxy_port[0] = nat_range_low; - pfr.rule.rpool.proxy_port[1] = nat_range_high; - if (ioctl(dev, DIOCADDRULE, &pfr) == -1) - return (-1); - - return (0); -} - -int -add_rdr(u_int32_t id, struct sockaddr *src, struct sockaddr *dst, - u_int16_t d_port, struct sockaddr *rdr, u_int16_t rdr_port) -{ - if (!src || !dst || !d_port || !rdr || !rdr_port || - (src->sa_family != rdr->sa_family)) { - errno = EINVAL; - return (-1); - } - - if (prepare_rule(id, PF_RULESET_RDR, src, dst, d_port) == -1) - return (-1); - - if (rdr->sa_family == AF_INET) { - memcpy(&pfp.addr.addr.v.a.addr.v4, - &satosin(rdr)->sin_addr.s_addr, 4); - memset(&pfp.addr.addr.v.a.mask.addr8, 255, 4); - } else { - memcpy(&pfp.addr.addr.v.a.addr.v6, - &satosin6(rdr)->sin6_addr.s6_addr, 16); - memset(&pfp.addr.addr.v.a.mask.addr8, 255, 16); - } - if (ioctl(dev, DIOCADDADDR, &pfp) == -1) - return (-1); - - pfr.rule.rpool.proxy_port[0] = rdr_port; - if (ioctl(dev, DIOCADDRULE, &pfr) == -1) - return (-1); - - return (0); -} - -int -do_commit(void) -{ - if (ioctl(dev, DIOCXCOMMIT, &pft) == -1) - return (-1); - - return (0); -} - -int -do_rollback(void) -{ - if (ioctl(dev, DIOCXROLLBACK, &pft) == -1) - return (-1); - - return (0); -} - -void -init_filter(const char *opt_qname, const char *opt_tagname, int opt_verbose) -{ - struct pf_status status; - - qname = opt_qname; - tagname = opt_tagname; - - if (opt_verbose == 1) - rule_log = PF_LOG; - else if (opt_verbose == 2) - rule_log = PF_LOG_ALL; - - dev = open("/dev/pf", O_RDWR); - if (dev == -1) - err(1, "open /dev/pf"); - if (ioctl(dev, DIOCGETSTATUS, &status) == -1) - err(1, "DIOCGETSTATUS"); - if (!status.running) - errx(1, "pf is disabled"); -} - -int -prepare_commit(u_int32_t id) -{ - char an[PF_ANCHOR_NAME_SIZE]; - int i; - - memset(&pft, 0, sizeof pft); - pft.size = TRANS_SIZE; - pft.esize = sizeof pfte[0]; - pft.array = pfte; - - snprintf(an, PF_ANCHOR_NAME_SIZE, "%s/%d.%d", FTP_PROXY_ANCHOR, - getpid(), id); - for (i = 0; i < TRANS_SIZE; i++) { - memset(&pfte[i], 0, sizeof pfte[0]); - strlcpy(pfte[i].anchor, an, PF_ANCHOR_NAME_SIZE); - switch (i) { - case TRANS_FILTER: - pfte[i].rs_num = PF_RULESET_FILTER; - break; - case TRANS_NAT: - pfte[i].rs_num = PF_RULESET_NAT; - break; - case TRANS_RDR: - pfte[i].rs_num = PF_RULESET_RDR; - break; - default: - errno = EINVAL; - return (-1); - } - } - - if (ioctl(dev, DIOCXBEGIN, &pft) == -1) - return (-1); - - return (0); -} - -int -prepare_rule(u_int32_t id, int rs_num, struct sockaddr *src, - struct sockaddr *dst, u_int16_t d_port) -{ - char an[PF_ANCHOR_NAME_SIZE]; - - if ((src->sa_family != AF_INET && src->sa_family != AF_INET6) || - (src->sa_family != dst->sa_family)) { - errno = EPROTONOSUPPORT; - return (-1); - } - - memset(&pfp, 0, sizeof pfp); - memset(&pfr, 0, sizeof pfr); - snprintf(an, PF_ANCHOR_NAME_SIZE, "%s/%d.%d", FTP_PROXY_ANCHOR, - getpid(), id); - strlcpy(pfp.anchor, an, PF_ANCHOR_NAME_SIZE); - strlcpy(pfr.anchor, an, PF_ANCHOR_NAME_SIZE); - - switch (rs_num) { - case PF_RULESET_FILTER: - pfr.ticket = pfte[TRANS_FILTER].ticket; - break; - case PF_RULESET_NAT: - pfr.ticket = pfte[TRANS_NAT].ticket; - break; - case PF_RULESET_RDR: - pfr.ticket = pfte[TRANS_RDR].ticket; - break; - default: - errno = EINVAL; - return (-1); - } - if (ioctl(dev, DIOCBEGINADDRS, &pfp) == -1) - return (-1); - pfr.pool_ticket = pfp.ticket; - - /* Generic for all rule types. */ - pfr.rule.af = src->sa_family; - pfr.rule.proto = IPPROTO_TCP; - pfr.rule.src.addr.type = PF_ADDR_ADDRMASK; - pfr.rule.dst.addr.type = PF_ADDR_ADDRMASK; - if (src->sa_family == AF_INET) { - memcpy(&pfr.rule.src.addr.v.a.addr.v4, - &satosin(src)->sin_addr.s_addr, 4); - memset(&pfr.rule.src.addr.v.a.mask.addr8, 255, 4); - memcpy(&pfr.rule.dst.addr.v.a.addr.v4, - &satosin(dst)->sin_addr.s_addr, 4); - memset(&pfr.rule.dst.addr.v.a.mask.addr8, 255, 4); - } else { - memcpy(&pfr.rule.src.addr.v.a.addr.v6, - &satosin6(src)->sin6_addr.s6_addr, 16); - memset(&pfr.rule.src.addr.v.a.mask.addr8, 255, 16); - memcpy(&pfr.rule.dst.addr.v.a.addr.v6, - &satosin6(dst)->sin6_addr.s6_addr, 16); - memset(&pfr.rule.dst.addr.v.a.mask.addr8, 255, 16); - } - pfr.rule.dst.port_op = PF_OP_EQ; - pfr.rule.dst.port[0] = htons(d_port); - - switch (rs_num) { - case PF_RULESET_FILTER: - /* - * pass [quick] [log] inet[6] proto tcp \ - * from $src to $dst port = $d_port flags S/SA keep state - * (max 1) [queue qname] [tag tagname] - */ - pfr.rule.action = PF_PASS; - pfr.rule.quick = 1; - pfr.rule.log = rule_log; - pfr.rule.keep_state = 1; - pfr.rule.flags = TH_SYN; - pfr.rule.flagset = (TH_SYN|TH_ACK); - pfr.rule.max_states = 1; - if (qname != NULL) - strlcpy(pfr.rule.qname, qname, sizeof pfr.rule.qname); - if (tagname != NULL) { - pfr.rule.quick = 0; - strlcpy(pfr.rule.tagname, tagname, - sizeof pfr.rule.tagname); - } - break; - case PF_RULESET_NAT: - /* - * nat inet[6] proto tcp from $src to $dst port $d_port -> $nat - */ - pfr.rule.action = PF_NAT; - break; - case PF_RULESET_RDR: - /* - * rdr inet[6] proto tcp from $src to $dst port $d_port -> $rdr - */ - pfr.rule.action = PF_RDR; - break; - default: - errno = EINVAL; - return (-1); - } - - return (0); -} - -int -server_lookup(struct sockaddr *client, struct sockaddr *proxy, - struct sockaddr *server) -{ - if (client->sa_family == AF_INET) - return (server_lookup4(satosin(client), satosin(proxy), - satosin(server))); - - if (client->sa_family == AF_INET6) - return (server_lookup6(satosin6(client), satosin6(proxy), - satosin6(server))); - - errno = EPROTONOSUPPORT; - return (-1); -} - -int -server_lookup4(struct sockaddr_in *client, struct sockaddr_in *proxy, - struct sockaddr_in *server) -{ - struct pfioc_natlook pnl; - - memset(&pnl, 0, sizeof pnl); - pnl.direction = PF_OUT; - pnl.af = AF_INET; - pnl.proto = IPPROTO_TCP; - memcpy(&pnl.saddr.v4, &client->sin_addr.s_addr, sizeof pnl.saddr.v4); - memcpy(&pnl.daddr.v4, &proxy->sin_addr.s_addr, sizeof pnl.daddr.v4); - pnl.sport = client->sin_port; - pnl.dport = proxy->sin_port; - - if (ioctl(dev, DIOCNATLOOK, &pnl) == -1) - return (-1); - - memset(server, 0, sizeof(struct sockaddr_in)); - server->sin_len = sizeof(struct sockaddr_in); - server->sin_family = AF_INET; - memcpy(&server->sin_addr.s_addr, &pnl.rdaddr.v4, - sizeof server->sin_addr.s_addr); - server->sin_port = pnl.rdport; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-projects@freebsd.org Mon Apr 1 06:40:17 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 88D7C15855A1 for ; Mon, 1 Apr 2019 06:40:17 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 31C30855D2 for ; Mon, 1 Apr 2019 06:40:15 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: by mail-ed1-x531.google.com with SMTP id v21so7141720edq.4 for ; Sun, 31 Mar 2019 23:40:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuxi-nl.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+8o7Yn+YF/Dzb7NS5vvKbRtRIKBqgspedlvxl4j8jWY=; b=ZR7/o3c8BMovrR4CNYB0DiUvwxPYLCVFlBmT5hQxFQjTC5wyfuFx/JiXPzN8Bmhb4E iAefhMwlFrXZoRBNHPor9w2+OczfffPmSOKu7WKCNLJ/AUhtXkm5zCIlDPoxVy/7Vv1R 67N/amZ7LZc72s9Y2Ftwlw+UzHN1cx7RREC+KQittTZ7XZ0cDH6mMElmvE6K8F8pCBvy +UYPSadba/dV/+q6jHf2nGki5tP2aHHrX/1SRcXaz9QVEia2SeINpjhFPUQ5xWA0J/Qj yp3vOp/DWJB6kaOS/NZuVVDspk1GilxGBo2+ZDtnEOQtnUBy1yISzSkVQN0wGGAHpDdW 0QAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+8o7Yn+YF/Dzb7NS5vvKbRtRIKBqgspedlvxl4j8jWY=; b=pa0Q4njLkppElQqfSt0QuoUwQSfKdQ4L//wDW+EPsNi21tEgde7BNDjPFaiUYThO/6 TfJoUXd7mYlFQCZVj90IOCF1eGPwnx+4b0E8BuUQ0dXGKfIq6oiVU30mihamgmZGK3sr JwW+yJHN2FGPEgPIjIpkz0ZJr57WNFdovukFaoax5Dai8aF1+wj0SlPZnAD1mvN+RqBP AlZ7kvlqm1yniID9dQHzH1icIj5/wLq/KL5t/n/l7JeyHLiidUL2Udkpi5T7/ExvkiZ3 350Idx6vsloQrKE2J/AFOaxLk42Ee0Aw1VLWI9KhQKBdQHoBixSxxLTwepIMFN1ealvU hiyw== X-Gm-Message-State: APjAAAUAqn/7rrQEI+SKOLtOw/iZao9NYcC4Qnm+zDWAclhDXg6RNrw0 ki5UAF/bdF0hNdJHTCF704pIpNL56x7bLy39Yp4jz1q0 X-Google-Smtp-Source: APXvYqwGeP+ZanULROwqS5qAMAaP7fZY3n5vm/CJjCsLQpO55E5PfH+DmR5kpJBBviYWKTN66ZMU/CcQ20GzF8MFJlQ= X-Received: by 2002:a50:bd85:: with SMTP id y5mr29058246edh.112.1554100814503; Sun, 31 Mar 2019 23:40:14 -0700 (PDT) MIME-Version: 1.0 References: <20190401055318.GI7163@vega.codepro.be> In-Reply-To: <20190401055318.GI7163@vega.codepro.be> From: Ed Schouten Date: Mon, 1 Apr 2019 08:39:48 +0200 Message-ID: Subject: Re: svn commit: r345760 - in head: contrib/pf sys/netpfil/pf sbin/pfctl To: Kristof Provost Cc: src-committers , svn-src-projects@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 31C30855D2 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=nuxi-nl.20150623.gappssmtp.com header.s=20150623 header.b=ZR7/o3c8 X-Spamd-Result: default: False [-4.11 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; R_DKIM_ALLOW(-0.20)[nuxi-nl.20150623.gappssmtp.com:s=20150623]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[svn-src-projects@freebsd.org]; DMARC_NA(0.00)[nuxi.nl]; NEURAL_SPAM_SHORT(0.93)[0.928,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[nuxi-nl.20150623.gappssmtp.com:+]; MX_GOOD(-0.01)[ASPMX.L.GOOGLE.COM,ALT2.ASPMX.L.GOOGLE.COM,ASPMX5.GOOGLEMAIL.COM,ALT1.ASPMX.L.GOOGLE.COM,ASPMX4.GOOGLEMAIL.COM,ASPMX3.GOOGLEMAIL.COM,ASPMX2.GOOGLEMAIL.COM]; RCVD_IN_DNSWL_NONE(0.00)[1.3.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.5.4.1.0.0.a.2.list.dnswl.org : 127.0.5.0]; R_SPF_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; IP_SCORE(-2.73)[ip: (-9.10), ipnet: 2a00:1450::/32(-2.36), asn: 15169(-2.15), country: US(-0.06)] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 06:40:17 -0000 Op ma 1 apr. 2019 om 07:53 schreef Kristof Provost : > Users are advised to migrate to ipf. Has anyone considered importing netfilter/iptables? -- Ed Schouten From owner-svn-src-projects@freebsd.org Mon Apr 1 06:47:23 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EA7E215868F7 for ; Mon, 1 Apr 2019 06:47:22 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 84425864FA; Mon, 1 Apr 2019 06:47:22 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from venus.codepro.be (venus.codepro.be [5.9.86.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.codepro.be", Issuer "Let's Encrypt Authority X3" (verified OK)) (Authenticated sender: kp) by smtp.freebsd.org (Postfix) with ESMTPSA id 4910919E9A; Mon, 1 Apr 2019 06:47:22 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from [100.115.136.111] (unknown [188.189.172.36]) (Authenticated sender: kp) by venus.codepro.be (Postfix) with ESMTPSA id 81EAD2E161; Mon, 1 Apr 2019 08:47:20 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (1.0) Subject: Re: svn commit: r345760 - in head: contrib/pf sys/netpfil/pf sbin/pfctl From: Kristof Provost X-Mailer: iPhone Mail (16E227) In-Reply-To: Date: Mon, 1 Apr 2019 08:47:16 +0200 Cc: src-committers , svn-src-projects@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20190401055318.GI7163@vega.codepro.be> To: Ed Schouten X-Rspamd-Queue-Id: 84425864FA X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.75 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.75)[-0.746,0]; ASN(0.00)[asn:11403, ipnet:96.47.64.0/20, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 06:47:23 -0000 > On 1 Apr 2019, at 08:39, Ed Schouten wrote: >=20 > Op ma 1 apr. 2019 om 07:53 schreef Kristof Provost : >> Users are advised to migrate to ipf. >=20 > Has anyone considered importing netfilter/iptables? >=20 Nftables, surely? We wouldn=E2=80=99t want to import their outdated firewall.=20 Kristof= From owner-svn-src-projects@freebsd.org Mon Apr 1 07:28:40 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B3E15158EC91 for ; Mon, 1 Apr 2019 07:28:40 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 551EE89284; Mon, 1 Apr 2019 07:28:39 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.67.125.17]) by shaw.ca with ESMTPA id ArMwh9ox3ldkPArMxhFZho; Mon, 01 Apr 2019 01:28:36 -0600 X-Authority-Analysis: v=2.3 cv=Ko4zJleN c=1 sm=1 tr=0 a=VFtTW3WuZNDh6VkGe7fA3g==:117 a=VFtTW3WuZNDh6VkGe7fA3g==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=8nJEP1OIZ-IA:10 a=oexKYjalfGEA:10 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=9kjIXSS1uQBkUWT0IQoA:9 a=wPNLvfGTeEIA:10 a=-FsMTTDYTgkA:10 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id AE4A728E; Mon, 1 Apr 2019 00:28:33 -0700 (PDT) Received: from slippy.cwsent.com (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id x317SWvK076166; Mon, 1 Apr 2019 00:28:33 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Received: from slippy (cy@localhost) by slippy.cwsent.com (8.15.2/8.15.2/Submit) with ESMTP id x317SWXD076162; Mon, 1 Apr 2019 00:28:32 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201904010728.x317SWXD076162@slippy.cwsent.com> X-Authentication-Warning: slippy.cwsent.com: cy owned process doing -bs X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Kristof Provost cc: Ed Schouten , src-committers , svn-src-projects@freebsd.org Subject: Re: svn commit: r345760 - in head: contrib/pf sys/netpfil/pf sbin/pfctl In-Reply-To: Message from Kristof Provost of "Mon, 01 Apr 2019 08:47:16 +0200." Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Date: Mon, 01 Apr 2019 00:28:32 -0700 X-CMAE-Envelope: MS4wfGSqeA/PmpmBvnSL5CGPtTWw1TIb5dXcMnH94VDPRJyoWiv0MePw8zT50b9XVsmUbDcCxbqgrXlXpO5sq/Bn/PhdBVuwE0SXY47ACFJD7hHts6S83fvX GQ0JCiKmstmef6RYbO6h7N6hhLFY+3FENA8izVfvW5vBVaiYNgqxfDnWZcIYXPtuOAjd28MdIfDrGW3DbrlJ+o2kN8YF/zxgP1XSiJm6hYoQfWF9ABCWNt1D sgK13vFy862eV4NrynV+6NE5DHtdWDLPnS47cBynSfo= X-Rspamd-Queue-Id: 551EE89284 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-4.61 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_FIVE(0.00)[5]; HAS_REPLYTO(0.00)[Cy.Schubert@cschubert.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; MV_CASE(0.50)[]; IP_SCORE(-2.38)[ip: (-6.43), ipnet: 64.59.128.0/20(-3.04), asn: 6327(-2.35), country: CA(-0.09)]; MIME_GOOD(-0.10)[text/plain]; HAS_XAW(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; TO_DN_SOME(0.00)[]; REPLYTO_EQ_FROM(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MX_GOOD(-0.01)[cached: spqr.komquats.com]; NEURAL_HAM_SHORT(-0.52)[-0.517,0]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_SPF_NA(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[17.125.67.70.zen.spamhaus.org : 127.0.0.11]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:6327, ipnet:64.59.128.0/20, country:CA]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[12.134.59.64.list.dnswl.org : 127.0.5.1] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 07:28:41 -0000 In message , Kristof Provost writes: > > > > On 1 Apr 2019, at 08:39, Ed Schouten wrote: > > > > Op ma 1 apr. 2019 om 07:53 schreef Kristof Provost : > >> Users are advised to migrate to ipf. > > > > Has anyone considered importing netfilter/iptables? > > > Nftables, surely? > We wouldn’t want to import their outdated firewall. Does it support RFC 1149 and RFC 2549? None of our firewalls do. Then again, neither does our stack. How difficult would it be to support this? -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few. From owner-svn-src-projects@freebsd.org Mon Apr 1 07:31:09 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2D2B1158EFAD for ; Mon, 1 Apr 2019 07:31:09 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 930BE89414; Mon, 1 Apr 2019 07:31:08 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from venus.codepro.be (venus.codepro.be [5.9.86.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.codepro.be", Issuer "Let's Encrypt Authority X3" (verified OK)) (Authenticated sender: kp) by smtp.freebsd.org (Postfix) with ESMTPSA id 6ED761A307; Mon, 1 Apr 2019 07:31:08 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from [10.69.87.58] (unknown [149.11.171.2]) (Authenticated sender: kp) by venus.codepro.be (Postfix) with ESMTPSA id 1D6AC2E23E; Mon, 1 Apr 2019 09:31:07 +0200 (CEST) From: "Kristof Provost" To: "Cy Schubert" Cc: "Ed Schouten" , src-committers , svn-src-projects@freebsd.org Subject: Re: svn commit: r345760 - in head: contrib/pf sys/netpfil/pf sbin/pfctl Date: Mon, 01 Apr 2019 09:31:06 +0200 X-Mailer: MailMate (2.0BETAr6135) Message-ID: <9E67836D-5E66-4E82-AB3F-F854AE008759@FreeBSD.org> In-Reply-To: <201904010728.x317SWXD076162@slippy.cwsent.com> References: <201904010728.x317SWXD076162@slippy.cwsent.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 930BE89414 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 07:31:09 -0000 On 1 Apr 2019, at 9:28, Cy Schubert wrote: > In message , Kristof > Provost > writes: >> >> >>> On 1 Apr 2019, at 08:39, Ed Schouten wrote: >>> >>> Op ma 1 apr. 2019 om 07:53 schreef Kristof Provost : >>>> Users are advised to migrate to ipf. >>> >>> Has anyone considered importing netfilter/iptables? >>> >> Nftables, surely? >> We wouldn’t want to import their outdated firewall. > > Does it support RFC 1149 and RFC 2549? None of our firewalls do. Then > again, neither does our stack. How difficult would it be to support > this? > I’ve done some investigating, and the current research indicates that while it is possible to filter RFC 1149 and RFC 2549 it’s very hard to train the falcons, and it does make a bit of a mess when you drop packets. Regards, Kristof From owner-svn-src-projects@freebsd.org Mon Apr 1 13:04:57 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 85B0A1562B79 for ; Mon, 1 Apr 2019 13:04:57 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8074E6E442; Mon, 1 Apr 2019 13:04:56 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id x31D4s1v015087; Mon, 1 Apr 2019 06:04:54 -0700 (PDT) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id x31D4sCH015086; Mon, 1 Apr 2019 06:04:54 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201904011304.x31D4sCH015086@gndrsh.dnsmgr.net> Subject: Re: svn commit: r345760 - in head: contrib/pf sys/netpfil/pf sbin/pfctl In-Reply-To: <20190401055318.GI7163@vega.codepro.be> To: Kristof Provost Date: Mon, 1 Apr 2019 06:04:53 -0700 (PDT) CC: src-committers@freebsd.org, svn-src-projects@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 8074E6E442 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.96 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.96)[-0.957,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 13:04:57 -0000 > Author: kp > Date: Mon Apr 1 06:51:32 2019 > New Revision: 345760 > URL: https://svnweb.freebsd.org/changeset/base/345625 > > Log: > pf: Remove obsolete pf > > pf in FreeBSD lags years behind OpenBSD's pf. > Remove it. > > Users are advised to migrate to ipf. WOW! Where was any discussion on arch@ or any other place had about this action. I have just come back from ietf/104 with very specific requests about the state of this code.... This is totally outside of the normal deprecation model, you have not even committed a warning that this is gone_in_14, which would be more proper model following. > Deleted: > head/contrib/pf/authpf/authpf.8 > head/contrib/pf/authpf/authpf.c > head/contrib/pf/authpf/pathnames.h > head/contrib/pf/ftp-proxy/filter.c > head/contrib/pf/ftp-proxy/filter.h > head/contrib/pf/ftp-proxy/ftp-proxy.8 > head/contrib/pf/ftp-proxy/ftp-proxy.c > head/contrib/pf/libevent/buffer.c > head/contrib/pf/libevent/evbuffer.c > head/contrib/pf/libevent/event-internal.h > head/contrib/pf/libevent/event.c > head/contrib/pf/libevent/event.h > head/contrib/pf/libevent/evsignal.h > head/contrib/pf/libevent/kqueue.c > head/contrib/pf/libevent/log.c > head/contrib/pf/libevent/log.h > head/contrib/pf/libevent/poll.c > head/contrib/pf/libevent/select.c > head/contrib/pf/libevent/signal.c > head/contrib/pf/pflogd/pflogd.8 > head/contrib/pf/pflogd/pflogd.c > head/contrib/pf/pflogd/pflogd.h > head/contrib/pf/pflogd/pidfile.c > head/contrib/pf/pflogd/pidfile.h > head/contrib/pf/pflogd/privsep.c > head/contrib/pf/pflogd/privsep_fdpass.c > head/contrib/pf/tftp-proxy/filter.c > head/contrib/pf/tftp-proxy/filter.h > head/contrib/pf/tftp-proxy/tftp-proxy.8 > head/contrib/pf/tftp-proxy/tftp-proxy.c > head/contrib/tcpdump/print-pflog.c > head/contrib/tcpdump/print-pfsync.c > head/sbin/pfctl/Makefile > head/sbin/pfctl/parse.y > head/sbin/pfctl/pf.os > head/sbin/pfctl/pf_print_state.c > head/sbin/pfctl/pfctl.8 > head/sbin/pfctl/pfctl.c > head/sbin/pfctl/pfctl.h > head/sbin/pfctl/pfctl_altq.c > head/sbin/pfctl/pfctl_optimize.c > head/sbin/pfctl/pfctl_osfp.c > head/sbin/pfctl/pfctl_parser.c > head/sbin/pfctl/pfctl_parser.h > head/sbin/pfctl/pfctl_qstats.c > head/sbin/pfctl/pfctl_radix.c > head/sbin/pfctl/pfctl_table.c > head/sys/modules/pf/Makefile > head/sys/modules/pflog/Makefile > head/sys/modules/pfsync/Makefile > head/sys/netpfil/pf/if_pflog.c > head/sys/netpfil/pf/if_pfsync.c > head/sys/netpfil/pf/in4_cksum.c > head/sys/netpfil/pf/pf.c > head/sys/netpfil/pf/pf.h > head/sys/netpfil/pf/pf_altq.h > head/sys/netpfil/pf/pf_if.c > head/sys/netpfil/pf/pf_ioctl.c > head/sys/netpfil/pf/pf_lb.c > head/sys/netpfil/pf/pf_mtag.h > head/sys/netpfil/pf/pf_norm.c > head/sys/netpfil/pf/pf_osfp.c > head/sys/netpfil/pf/pf_ruleset.c > head/sys/netpfil/pf/pf_table.c > > Index: contrib/pf/authpf/authpf.8 > =================================================================== > --- contrib/pf/authpf/authpf.8 (revision 345223) > +++ contrib/pf/authpf/authpf.8 (working copy) > @@ -1,584 +0,0 @@ > -.\" $FreeBSD$ > -.\" $OpenBSD: authpf.8,v 1.47 2009/01/06 03:11:50 mcbride Exp $ > -.\" > -.\" Copyright (c) 1998-2007 Bob Beck (beck@openbsd.org>. All rights reserved. > -.\" > -.\" Permission to use, copy, modify, and distribute this software for any > -.\" purpose with or without fee is hereby granted, provided that the above > -.\" copyright notice and this permission notice appear in all copies. > -.\" > -.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES > -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF > -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR > -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES > -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN > -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF > -.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. > -.\" > -.Dd January 29 2014 > -.Dt AUTHPF 8 > -.Os > -.Sh NAME > -.Nm authpf , > -.Nm authpf-noip > -.Nd authenticating gateway user shell > -.Sh SYNOPSIS > -.Nm authpf > -.Nm authpf-noip > -.Sh DESCRIPTION > -.Nm > -is a user shell for authenticating gateways. > -It is used to change > -.Xr pf 4 > -rules when a user authenticates and starts a session with > -.Xr sshd 8 > -and to undo these changes when the user's session exits. > -Typical use would be for a gateway that authenticates users before > -allowing them Internet use, or a gateway that allows different users into > -different places. > -Combined with properly set up filter rules and secure switches, > -.Nm > -can be used to ensure users are held accountable for their network traffic. > -It is meant to be used with users who can connect via > -.Xr ssh 1 > -only, and requires the > -.Xr pf 4 > -subsystem and an > -.Xr fdescfs 5 > -file system mounted at > -.Pa /dev/fd > -to be enabled. > -.Pp > -.Nm authpf-noip > -is a user shell > -which allows multiple connections to take > -place from the same IP address. > -It is useful primarily in cases where connections are tunneled via > -the gateway system, and can be directly associated with the user name. > -It cannot ensure accountability when > -classifying connections by IP address; > -in this case the client's IP address > -is not provided to the packet filter via the > -.Ar client_ip > -macro or the > -.Ar authpf_users > -table. > -Additionally, states associated with the client IP address > -are not purged when the session is ended. > -.Pp > -To use either > -.Nm > -or > -.Nm authpf-noip , > -the user's shell needs to be set to > -.Pa /usr/sbin/authpf > -or > -.Pa /usr/sbin/authpf-noip . > -.Pp > -.Nm > -uses the > -.Xr pf.conf 5 > -syntax to change filter and translation rules for an individual > -user or client IP address as long as a user maintains an active > -.Xr ssh 1 > -session, and logs the successful start and end of a session to > -.Xr syslogd 8 . > -.Nm > -retrieves the client's connecting IP address via the > -.Ev SSH_CLIENT > -environment variable and, after performing additional access checks, > -reads a template file to determine what filter and translation rules > -(if any) to add, and > -maintains the list of IP addresses of connected users in the > -.Ar authpf_users > -table. > -On session exit the same rules and table entries that were added at startup > -are removed, and all states associated with the client's IP address are purged. > -.Pp > -Each > -.Nm > -process stores its rules in a separate ruleset inside a > -.Xr pf 4 > -.Pa anchor > -shared by all > -.Nm > -processes. > -By default, the > -.Pa anchor > -name "authpf" is used, and the ruleset names equal the username and PID of the > -.Nm > -processes as "username(pid)". > -The following rules need to be added to the main ruleset > -.Pa /etc/pf.conf > -in order to cause evaluation of any > -.Nm > -rules: > -.Bd -literal -offset indent > -nat-anchor "authpf/*" > -rdr-anchor "authpf/*" > -binat-anchor "authpf/*" > -anchor "authpf/*" > -.Ed > -.Pp > -The "/*" at the end of the anchor name is required for > -.Xr pf 4 > -to process the rulesets attached to the anchor by > -.Nm authpf . > -.Sh FILTER AND TRANSLATION RULES > -Filter and translation rules for > -.Nm > -use the same format described in > -.Xr pf.conf 5 . > -The only difference is that these rules may (and probably should) use > -the macro > -.Em user_ip , > -which is assigned the connecting IP address whenever > -.Nm > -is run. > -Additionally, the macro > -.Em user_id > -is assigned the user name. > -.Pp > -Filter and translation rules are stored in a file called > -.Pa authpf.rules . > -This file will first be searched for in > -.Pa /etc/authpf/users/$USER/ > -and then in > -.Pa /etc/authpf/ . > -Only one of these files will be used if both are present. > -.Pp > -Per-user rules from the > -.Pa /etc/authpf/users/$USER/ > -directory are intended to be used when non-default rules > -are needed on an individual user basis. > -It is important to ensure that a user can not write or change > -these configuration files. > -.Pp > -The > -.Pa authpf.rules > -file must exist in one of the above locations for > -.Nm > -to run. > -.Sh CONFIGURATION > -Options are controlled by the > -.Pa /etc/authpf/authpf.conf > -file. > -If the file is empty, defaults are used for all > -configuration options. > -The file consists of pairs of the form > -.Li name=value , > -one per line. > -Currently, the allowed values are as follows: > -.Bl -tag -width Ds > -.It anchor=name > -Use the specified > -.Pa anchor > -name instead of "authpf". > -.It table=name > -Use the specified > -.Pa table > -name instead of "authpf_users". > -.El > -.Sh USER MESSAGES > -On successful invocation, > -.Nm > -displays a message telling the user he or she has been authenticated. > -It will additionally display the contents of the file > -.Pa /etc/authpf/authpf.message > -if the file exists and is readable. > -.Pp > -There exist two methods for providing additional granularity to the control > -offered by > -.Nm > -- it is possible to set the gateway to explicitly allow users who have > -authenticated to > -.Xr ssh 1 > -and deny access to only a few troublesome individuals. > -This is done by creating a file with the banned user's login name as the > -filename in > -.Pa /etc/authpf/banned/ . > -The contents of this file will be displayed to a banned user, thus providing > -a method for informing the user that they have been banned, and where they can > -go and how to get there if they want to have their service restored. > -This is the default behaviour. > -.Pp > -It is also possible to configure > -.Nm > -to only allow specific users access. > -This is done by listing their login names, one per line, in > -.Pa /etc/authpf/authpf.allow . > -A group of users can also be indicated by prepending "%" to the group name, > -and all members of a login class can be indicated by prepending "@" to the > -login class name. > -If "*" is found on a line, then all usernames match. > -If > -.Nm > -is unable to verify the user's permission to use the gateway, it will > -print a brief message and die. > -It should be noted that a ban takes precedence over an allow. > -.Pp > -On failure, messages will be logged to > -.Xr syslogd 8 > -for the system administrator. > -The user does not see these, but will be told the system is unavailable due to > -technical difficulties. > -The contents of the file > -.Pa /etc/authpf/authpf.problem > -will also be displayed if the file exists and is readable. > -.Sh CONFIGURATION ISSUES > -.Nm > -maintains the changed filter rules as long as the user maintains an > -active session. > -It is important to remember however, that the existence > -of this session means the user is authenticated. > -Because of this, it is important to configure > -.Xr sshd 8 > -to ensure the security of the session, and to ensure that the network > -through which users connect is secure. > -.Xr sshd 8 > -should be configured to use the > -.Ar ClientAliveInterval > -and > -.Ar ClientAliveCountMax > -parameters to ensure that a ssh session is terminated quickly if > -it becomes unresponsive, or if arp or address spoofing is used to > -hijack the session. > -Note that TCP keepalives are not sufficient for > -this, since they are not secure. > -Also note that the various SSH tunnelling mechanisms, > -such as > -.Ar AllowTcpForwarding > -and > -.Ar PermitTunnel , > -should be disabled for > -.Nm > -users to prevent them from circumventing restrictions imposed by the > -packet filter ruleset. > -.Pp > -.Nm > -will remove state table entries that were created during a user's > -session. > -This ensures that there will be no unauthenticated traffic > -allowed to pass after the controlling > -.Xr ssh 1 > -session has been closed. > -.Pp > -.Nm > -is designed for gateway machines which typically do not have regular > -(non-administrative) users using the machine. > -An administrator must remember that > -.Nm > -can be used to modify the filter rules through the environment in > -which it is run, and as such could be used to modify the filter rules > -(based on the contents of the configuration files) by regular > -users. > -In the case where a machine has regular users using it, as well > -as users with > -.Nm > -as their shell, the regular users should be prevented from running > -.Nm > -by using the > -.Pa /etc/authpf/authpf.allow > -or > -.Pa /etc/authpf/banned/ > -facilities. > -.Pp > -.Nm > -modifies the packet filter and address translation rules, and because > -of this it needs to be configured carefully. > -.Nm > -will not run and will exit silently if the > -.Pa /etc/authpf/authpf.conf > -file does not exist. > -After considering the effect > -.Nm > -may have on the main packet filter rules, the system administrator may > -enable > -.Nm > -by creating an appropriate > -.Pa /etc/authpf/authpf.conf > -file. > -.Sh EXAMPLES > -.Sy Control Files > -\- To illustrate the user-specific access control > -mechanisms, let us consider a typical user named bob. > -Normally, as long as bob can authenticate himself, the > -.Nm > -program will load the appropriate rules. > -Enter the > -.Pa /etc/authpf/banned/ > -directory. > -If bob has somehow fallen from grace in the eyes of the > -powers-that-be, they can prohibit him from using the gateway by creating > -the file > -.Pa /etc/authpf/banned/bob > -containing a message about why he has been banned from using the network. > -Once bob has done suitable penance, his access may be restored by moving or > -removing the file > -.Pa /etc/authpf/banned/bob . > -.Pp > -Now consider a workgroup containing alice, bob, carol and dave. > -They have a > -wireless network which they would like to protect from unauthorized use. > -To accomplish this, they create the file > -.Pa /etc/authpf/authpf.allow > -which lists their login ids, group prepended with "%", or login class > -prepended with "@", one per line. > -At this point, even if eve could authenticate to > -.Xr sshd 8 , > -she would not be allowed to use the gateway. > -Adding and removing users from > -the work group is a simple matter of maintaining a list of allowed userids. > -If bob once again manages to annoy the powers-that-be, they can ban him from > -using the gateway by creating the familiar > -.Pa /etc/authpf/banned/bob > -file. > -Though bob is listed in the allow file, he is prevented from using > -this gateway due to the existence of a ban file. > -.Pp > -.Sy Distributed Authentication > -\- It is often desirable to interface with a > -distributed password system rather than forcing the sysadmins to keep a large > -number of local password files in sync. > -The > -.Xr login.conf 5 > -mechanism in > -.Ox > -can be used to fork the right shell. > -To make that happen, > -.Xr login.conf 5 > -should have entries that look something like this: > -.Bd -literal -offset indent > -shell-default:shell=/bin/csh > - > -default:\e > - ... > - :shell=/usr/sbin/authpf > - > -daemon:\e > - ... > - :shell=/bin/csh:\e > - :tc=default: > - > -staff:\e > - ... > - :shell=/bin/csh:\e > - :tc=default: > -.Ed > -.Pp > -Using a default password file, all users will get > -.Nm > -as their shell except for root who will get > -.Pa /bin/csh . > -.Pp > -.Sy SSH Configuration > -\- As stated earlier, > -.Xr sshd 8 > -must be properly configured to detect and defeat network attacks. > -To that end, the following options should be added to > -.Xr sshd_config 5 : > -.Bd -literal -offset indent > -Protocol 2 > -ClientAliveInterval 15 > -ClientAliveCountMax 3 > -.Ed > -.Pp > -This ensures that unresponsive or spoofed sessions are terminated within a > -minute, since a hijacker should not be able to spoof ssh keepalive messages. > -.Pp > -.Sy Banners > -\- Once authenticated, the user is shown the contents of > -.Pa /etc/authpf/authpf.message . > -This message may be a screen-full of the appropriate use policy, the contents > -of > -.Pa /etc/motd > -or something as simple as the following: > -.Bd -literal -offset indent > -This means you will be held accountable by the powers that be > -for traffic originating from your machine, so please play nice. > -.Ed > -.Pp > -To tell the user where to go when the system is broken, > -.Pa /etc/authpf/authpf.problem > -could contain something like this: > -.Bd -literal -offset indent > -Sorry, there appears to be some system problem. To report this > -problem so we can fix it, please phone 1-900-314-1597 or send > -an email to remove@bulkmailerz.net. > -.Ed > -.Pp > -.Sy Packet Filter Rules > -\- In areas where this gateway is used to protect a > -wireless network (a hub with several hundred ports), the default rule set as > -well as the per-user rules should probably allow very few things beyond > -encrypted protocols like > -.Xr ssh 1 , > -.Xr ssl 8 , > -or > -.Xr ipsec 4 . > -On a securely switched network, with plug-in jacks for visitors who are > -given authentication accounts, you might want to allow out everything. > -In this context, a secure switch is one that tries to prevent address table > -overflow attacks. > -.Pp > -Example > -.Pa /etc/pf.conf : > -.Bd -literal > -# by default we allow internal clients to talk to us using > -# ssh and use us as a dns server. > -internal_if="fxp1" > -gateway_addr="10.0.1.1" > -nat-anchor "authpf/*" > -rdr-anchor "authpf/*" > -binat-anchor "authpf/*" > -block in on $internal_if from any to any > -pass in quick on $internal_if proto tcp from any to $gateway_addr \e > - port = ssh > -pass in quick on $internal_if proto udp from any to $gateway_addr \e > - port = domain > -anchor "authpf/*" > -.Ed > -.Pp > -.Sy For a switched, wired net > -\- This example > -.Pa /etc/authpf/authpf.rules > -makes no real restrictions; it turns the IP address on and off, logging > -TCP connections. > -.Bd -literal > -external_if = "xl0" > -internal_if = "fxp0" > - > -pass in log quick on $internal_if proto tcp from $user_ip to any > -pass in quick on $internal_if from $user_ip to any > -.Ed > -.Pp > -.Sy For a wireless or shared net > -\- This example > -.Pa /etc/authpf/authpf.rules > -could be used for an insecure network (such as a public wireless network) where > -we might need to be a bit more restrictive. > -.Bd -literal > -internal_if="fxp1" > -ipsec_gw="10.2.3.4" > - > -# rdr ftp for proxying by ftp-proxy(8) > -rdr on $internal_if proto tcp from $user_ip to any port 21 \e > - -> 127.0.0.1 port 8021 > - > -# allow out ftp, ssh, www and https only, and allow user to negotiate > -# ipsec with the ipsec server. > -pass in log quick on $internal_if proto tcp from $user_ip to any \e > - port { 21, 22, 80, 443 } > -pass in quick on $internal_if proto tcp from $user_ip to any \e > - port { 21, 22, 80, 443 } > -pass in quick proto udp from $user_ip to $ipsec_gw port = isakmp > -pass in quick proto esp from $user_ip to $ipsec_gw > -.Ed > -.Pp > -.Sy Dealing with NAT > -\- The following > -.Pa /etc/authpf/authpf.rules > -shows how to deal with NAT, using tags: > -.Bd -literal > -ext_if = "fxp1" > -ext_addr = 129.128.11.10 > -int_if = "fxp0" > -# nat and tag connections... > -nat on $ext_if from $user_ip to any tag $user_ip -> $ext_addr > -pass in quick on $int_if from $user_ip to any > -pass out log quick on $ext_if tagged $user_ip > -.Ed > -.Pp > -With the above rules added by > -.Nm , > -outbound connections corresponding to each users NAT'ed connections > -will be logged as in the example below, where the user may be identified > -from the ruleset name. > -.Bd -literal > -# tcpdump -n -e -ttt -i pflog0 > -Oct 31 19:42:30.296553 rule 0.bbeck(20267).1/0(match): pass out on fxp1: \e > -129.128.11.10.60539 > 198.137.240.92.22: S 2131494121:2131494121(0) win \e > -16384 (DF) > -.Ed > -.Pp > -.Sy Using the authpf_users table > -\- Simple > -.Nm > -settings can be implemented without an anchor by just using the "authpf_users" > -.Pa table . > -For example, the following > -.Xr pf.conf 5 > -lines will give SMTP and IMAP access to logged in users: > -.Bd -literal > -table persist > -pass in on $ext_if proto tcp from \e > - to port { smtp imap } > -.Ed > -.Pp > -It is also possible to use the "authpf_users" > -.Pa table > -in combination with anchors. > -For example, > -.Xr pf 4 > -processing can be sped up by looking up the anchor > -only for packets coming from logged in users: > -.Bd -literal > -table persist > -anchor "authpf/*" from > -rdr-anchor "authpf/*" from > -.Ed > -.Pp > -.Sy Tunneled users > -\- normally > -.Nm > -allows only one session per client IP address. > -However in some cases, such as when connections are tunneled via > -.Xr ssh 1 > -or > -.Xr ipsec 4 , > -the connections can be authorized based on the userid of the user instead of > -the client IP address. > -In this case it is appropriate to use > -.Nm authpf-noip > -to allow multiple users behind a NAT gateway to connect. > -In the > -.Pa /etc/authpf/authpf.rules > -example below, the remote user could tunnel a remote desktop session to their > -workstation: > -.Bd -literal > -internal_if="bge0" > -workstation_ip="10.2.3.4" > - > -pass out on $internal_if from (self) to $workstation_ip port 3389 \e > - user $user_id > -.Ed > -.Sh FILES > -.Bl -tag -width "/etc/authpf/authpf.conf" -compact > -.It Pa /etc/authpf/authpf.conf > -.It Pa /etc/authpf/authpf.allow > -.It Pa /etc/authpf/authpf.rules > -.It Pa /etc/authpf/authpf.message > -.It Pa /etc/authpf/authpf.problem > -.El > -.Sh SEE ALSO > -.Xr pf 4 , > -.Xr fdescfs 5 , > -.Xr pf.conf 5 , > -.Xr securelevel 7 , > -.Xr ftp-proxy 8 > -.Sh HISTORY > -The > -.Nm > -program first appeared in > -.Ox 3.1 . > -.Sh BUGS > -Configuration issues are tricky. > -The authenticating > -.Xr ssh 1 > -connection may be secured, but if the network is not secured the user may > -expose insecure protocols to attackers on the same network, or enable other > -attackers on the network to pretend to be the user by spoofing their IP > -address. > -.Pp > -.Nm > -is not designed to prevent users from denying service to other users. > Index: contrib/pf/authpf/pathnames.h > =================================================================== > --- contrib/pf/authpf/pathnames.h (revision 345223) > +++ contrib/pf/authpf/pathnames.h (working copy) > @@ -1,39 +0,0 @@ > -/* $OpenBSD: pathnames.h,v 1.8 2008/02/14 01:49:17 mcbride Exp $ */ > - > -/* > - * Copyright (C) 2002 Chris Kuethe (ckuethe@ualberta.ca) > - * > - * Redistribution and use in source and binary forms, with or without > - * modification, are permitted provided that the following conditions > - * are met: > - * 1. Redistributions of source code must retain the above copyright > - * notice, this list of conditions and the following disclaimer. > - * 2. Redistributions in binary form must reproduce the above copyright > - * notice, this list of conditions and the following disclaimer in the > - * documentation and/or other materials provided with the distribution. > - * > - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > - * SUCH DAMAGE. > - */ > - > -#define PATH_CONFFILE "/etc/authpf/authpf.conf" > -#define PATH_ALLOWFILE "/etc/authpf/authpf.allow" > -#define PATH_PFRULES "/etc/authpf/authpf.rules" > -#define PATH_PROBLEM "/etc/authpf/authpf.problem" > -#define PATH_MESSAGE "/etc/authpf/authpf.message" > -#define PATH_USER_DIR "/etc/authpf/users" > -#define PATH_BAN_DIR "/etc/authpf/banned" > -#define PATH_DEVFILE "/dev/pf" > -#define PATH_PIDFILE "/var/authpf" > -#define PATH_AUTHPF_SHELL "/usr/sbin/authpf" > -#define PATH_AUTHPF_SHELL_NOIP "/usr/sbin/authpf-noip" > -#define PATH_PFCTL "/sbin/pfctl" > Index: contrib/pf/ftp-proxy/filter.c > =================================================================== > --- contrib/pf/ftp-proxy/filter.c (revision 345223) > +++ contrib/pf/ftp-proxy/filter.c (working copy) > @@ -1,393 +0,0 @@ > -/* $OpenBSD: filter.c,v 1.8 2008/06/13 07:25:26 claudio Exp $ */ > - > -/* > - * Copyright (c) 2004, 2005 Camiel Dobbelaar, > - * > - * Permission to use, copy, modify, and distribute this software for any > - * purpose with or without fee is hereby granted, provided that the above > - * copyright notice and this permission notice appear in all copies. > - * > - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES > - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF > - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR > - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES > - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN > - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF > - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. > - */ > - > -#include > -#include > -#include > - > -#include > -#include > -#include > -#include > -#include > - > -#include > -#include > -#include > -#include > -#include > -#include > - > -#include "filter.h" > - > -/* From netinet/in.h, but only _KERNEL_ gets them. */ > -#define satosin(sa) ((struct sockaddr_in *)(sa)) > -#define satosin6(sa) ((struct sockaddr_in6 *)(sa)) > - > -enum { TRANS_FILTER = 0, TRANS_NAT, TRANS_RDR, TRANS_SIZE }; > - > -int prepare_rule(u_int32_t, int, struct sockaddr *, struct sockaddr *, > - u_int16_t); > -int server_lookup4(struct sockaddr_in *, struct sockaddr_in *, > - struct sockaddr_in *); > -int server_lookup6(struct sockaddr_in6 *, struct sockaddr_in6 *, > - struct sockaddr_in6 *); > - > -static struct pfioc_pooladdr pfp; > -static struct pfioc_rule pfr; > -static struct pfioc_trans pft; > -static struct pfioc_trans_e pfte[TRANS_SIZE]; > -static int dev, rule_log; > -static const char *qname, *tagname; > - > -int > -add_filter(u_int32_t id, u_int8_t dir, struct sockaddr *src, > - struct sockaddr *dst, u_int16_t d_port) > -{ > - if (!src || !dst || !d_port) { > - errno = EINVAL; > - return (-1); > - } > - > - if (prepare_rule(id, PF_RULESET_FILTER, src, dst, d_port) == -1) > - return (-1); > - > - pfr.rule.direction = dir; > - if (ioctl(dev, DIOCADDRULE, &pfr) == -1) > - return (-1); > - > - return (0); > -} > - > -int > -add_nat(u_int32_t id, struct sockaddr *src, struct sockaddr *dst, > - u_int16_t d_port, struct sockaddr *nat, u_int16_t nat_range_low, > - u_int16_t nat_range_high) > -{ > - if (!src || !dst || !d_port || !nat || !nat_range_low || > - (src->sa_family != nat->sa_family)) { > - errno = EINVAL; > - return (-1); > - } > - > - if (prepare_rule(id, PF_RULESET_NAT, src, dst, d_port) == -1) > - return (-1); > - > - if (nat->sa_family == AF_INET) { > - memcpy(&pfp.addr.addr.v.a.addr.v4, > - &satosin(nat)->sin_addr.s_addr, 4); > - memset(&pfp.addr.addr.v.a.mask.addr8, 255, 4); > - } else { > - memcpy(&pfp.addr.addr.v.a.addr.v6, > - &satosin6(nat)->sin6_addr.s6_addr, 16); > - memset(&pfp.addr.addr.v.a.mask.addr8, 255, 16); > - } > - if (ioctl(dev, DIOCADDADDR, &pfp) == -1) > - return (-1); > - > - pfr.rule.rpool.proxy_port[0] = nat_range_low; > - pfr.rule.rpool.proxy_port[1] = nat_range_high; > - if (ioctl(dev, DIOCADDRULE, &pfr) == -1) > - return (-1); > - > - return (0); > -} > - > -int > -add_rdr(u_int32_t id, struct sockaddr *src, struct sockaddr *dst, > - u_int16_t d_port, struct sockaddr *rdr, u_int16_t rdr_port) > -{ > - if (!src || !dst || !d_port || !rdr || !rdr_port || > - (src->sa_family != rdr->sa_family)) { > - errno = EINVAL; > - return (-1); > - } > - > - if (prepare_rule(id, PF_RULESET_RDR, src, dst, d_port) == -1) > - return (-1); > - > - if (rdr->sa_family == AF_INET) { > - memcpy(&pfp.addr.addr.v.a.addr.v4, > - &satosin(rdr)->sin_addr.s_addr, 4); > - memset(&pfp.addr.addr.v.a.mask.addr8, 255, 4); > - } else { > - memcpy(&pfp.addr.addr.v.a.addr.v6, > - &satosin6(rdr)->sin6_addr.s6_addr, 16); > - memset(&pfp.addr.addr.v.a.mask.addr8, 255, 16); > - } > - if (ioctl(dev, DIOCADDADDR, &pfp) == -1) > - return (-1); > - > - pfr.rule.rpool.proxy_port[0] = rdr_port; > - if (ioctl(dev, DIOCADDRULE, &pfr) == -1) > - return (-1); > - > - return (0); > -} > - > -int > -do_commit(void) > -{ > - if (ioctl(dev, DIOCXCOMMIT, &pft) == -1) > - return (-1); > - > - return (0); > -} > - > -int > -do_rollback(void) > -{ > - if (ioctl(dev, DIOCXROLLBACK, &pft) == -1) > - return (-1); > - > - return (0); > -} > - > -void > -init_filter(const char *opt_qname, const char *opt_tagname, int opt_verbose) > -{ > - struct pf_status status; > - > - qname = opt_qname; > - tagname = opt_tagname; > - > - if (opt_verbose == 1) > - rule_log = PF_LOG; > - else if (opt_verbose == 2) > - rule_log = PF_LOG_ALL; > - > - dev = open("/dev/pf", O_RDWR); > - if (dev == -1) > - err(1, "open /dev/pf"); > - if (ioctl(dev, DIOCGETSTATUS, &status) == -1) > - err(1, "DIOCGETSTATUS"); > - if (!status.running) > - errx(1, "pf is disabled"); > -} > - > -int > -prepare_commit(u_int32_t id) > -{ > - char an[PF_ANCHOR_NAME_SIZE]; > - int i; > - > - memset(&pft, 0, sizeof pft); > - pft.size = TRANS_SIZE; > - pft.esize = sizeof pfte[0]; > - pft.array = pfte; > - > - snprintf(an, PF_ANCHOR_NAME_SIZE, "%s/%d.%d", FTP_PROXY_ANCHOR, > - getpid(), id); > - for (i = 0; i < TRANS_SIZE; i++) { > - memset(&pfte[i], 0, sizeof pfte[0]); > - strlcpy(pfte[i].anchor, an, PF_ANCHOR_NAME_SIZE); > - switch (i) { > - case TRANS_FILTER: > - pfte[i].rs_num = PF_RULESET_FILTER; > - break; > - case TRANS_NAT: > - pfte[i].rs_num = PF_RULESET_NAT; > - break; > - case TRANS_RDR: > - pfte[i].rs_num = PF_RULESET_RDR; > - break; > - default: > - errno = EINVAL; > - return (-1); > - } > - } > - > - if (ioctl(dev, DIOCXBEGIN, &pft) == -1) > - return (-1); > - > - return (0); > -} > - > -int > -prepare_rule(u_int32_t id, int rs_num, struct sockaddr *src, > - struct sockaddr *dst, u_int16_t d_port) > -{ > - char an[PF_ANCHOR_NAME_SIZE]; > - > - if ((src->sa_family != AF_INET && src->sa_family != AF_INET6) || > - (src->sa_family != dst->sa_family)) { > - errno = EPROTONOSUPPORT; > - return (-1); > - } > - > - memset(&pfp, 0, sizeof pfp); > - memset(&pfr, 0, sizeof pfr); > - snprintf(an, PF_ANCHOR_NAME_SIZE, "%s/%d.%d", FTP_PROXY_ANCHOR, > - getpid(), id); > - strlcpy(pfp.anchor, an, PF_ANCHOR_NAME_SIZE); > - strlcpy(pfr.anchor, an, PF_ANCHOR_NAME_SIZE); > - > - switch (rs_num) { > - case PF_RULESET_FILTER: > - pfr.ticket = pfte[TRANS_FILTER].ticket; > - break; > - case PF_RULESET_NAT: > - pfr.ticket = pfte[TRANS_NAT].ticket; > - break; > - case PF_RULESET_RDR: > - pfr.ticket = pfte[TRANS_RDR].ticket; > - break; > - default: > - errno = EINVAL; > - return (-1); > - } > - if (ioctl(dev, DIOCBEGINADDRS, &pfp) == -1) > - return (-1); > - pfr.pool_ticket = pfp.ticket; > - > - /* Generic for all rule types. */ > - pfr.rule.af = src->sa_family; > - pfr.rule.proto = IPPROTO_TCP; > - pfr.rule.src.addr.type = PF_ADDR_ADDRMASK; > - pfr.rule.dst.addr.type = PF_ADDR_ADDRMASK; > - if (src->sa_family == AF_INET) { > - memcpy(&pfr.rule.src.addr.v.a.addr.v4, > - &satosin(src)->sin_addr.s_addr, 4); > - memset(&pfr.rule.src.addr.v.a.mask.addr8, 255, 4); > - memcpy(&pfr.rule.dst.addr.v.a.addr.v4, > - &satosin(dst)->sin_addr.s_addr, 4); > - memset(&pfr.rule.dst.addr.v.a.mask.addr8, 255, 4); > - } else { > - memcpy(&pfr.rule.src.addr.v.a.addr.v6, > - &satosin6(src)->sin6_addr.s6_addr, 16); > - memset(&pfr.rule.src.addr.v.a.mask.addr8, 255, 16); > - memcpy(&pfr.rule.dst.addr.v.a.addr.v6, > - &satosin6(dst)->sin6_addr.s6_addr, 16); > - memset(&pfr.rule.dst.addr.v.a.mask.addr8, 255, 16); > - } > - pfr.rule.dst.port_op = PF_OP_EQ; > - pfr.rule.dst.port[0] = htons(d_port); > - > - switch (rs_num) { > - case PF_RULESET_FILTER: > - /* > - * pass [quick] [log] inet[6] proto tcp \ > - * from $src to $dst port = $d_port flags S/SA keep state > - * (max 1) [queue qname] [tag tagname] > - */ > - pfr.rule.action = PF_PASS; > - pfr.rule.quick = 1; > - pfr.rule.log = rule_log; > - pfr.rule.keep_state = 1; > - pfr.rule.flags = TH_SYN; > - pfr.rule.flagset = (TH_SYN|TH_ACK); > - pfr.rule.max_states = 1; > - if (qname != NULL) > - strlcpy(pfr.rule.qname, qname, sizeof pfr.rule.qname); > - if (tagname != NULL) { > - pfr.rule.quick = 0; > - strlcpy(pfr.rule.tagname, tagname, > - sizeof pfr.rule.tagname); > - } > - break; > - case PF_RULESET_NAT: > - /* > - * nat inet[6] proto tcp from $src to $dst port $d_port -> $nat > - */ > - pfr.rule.action = PF_NAT; > - break; > - case PF_RULESET_RDR: > - /* > - * rdr inet[6] proto tcp from $src to $dst port $d_port -> $rdr > - */ > - pfr.rule.action = PF_RDR; > - break; > - default: > - errno = EINVAL; > - return (-1); > - } > - > - return (0); > -} > - > -int > -server_lookup(struct sockaddr *client, struct sockaddr *proxy, > - struct sockaddr *server) > -{ > - if (client->sa_family == AF_INET) > - return (server_lookup4(satosin(client), satosin(proxy), > - satosin(server))); > - > - if (client->sa_family == AF_INET6) > - return (server_lookup6(satosin6(client), satosin6(proxy), > - satosin6(server))); > - > - errno = EPROTONOSUPPORT; > - return (-1); > -} > - > -int > -server_lookup4(struct sockaddr_in *client, struct sockaddr_in *proxy, > - struct sockaddr_in *server) > -{ > - struct pfioc_natlook pnl; > - > - memset(&pnl, 0, sizeof pnl); > - pnl.direction = PF_OUT; > - pnl.af = AF_INET; > - pnl.proto = IPPROTO_TCP; > - memcpy(&pnl.saddr.v4, &client->sin_addr.s_addr, sizeof pnl.saddr.v4); > - memcpy(&pnl.daddr.v4, &proxy->sin_addr.s_addr, sizeof pnl.daddr.v4); > - pnl.sport = client->sin_port; > - pnl.dport = proxy->sin_port; > - > - if (ioctl(dev, DIOCNATLOOK, &pnl) == -1) > - return (-1); > - > - memset(server, 0, sizeof(struct sockaddr_in)); > - server->sin_len = sizeof(struct sockaddr_in); > - server->sin_family = AF_INET; > - memcpy(&server->sin_addr.s_addr, &pnl.rdaddr.v4, > - sizeof server->sin_addr.s_addr); > - server->sin_port = pnl.rdport; > > *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** > > -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-projects@freebsd.org Mon Apr 1 13:13:36 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 131451562E83 for ; Mon, 1 Apr 2019 13:13:36 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AA6AF6E944; Mon, 1 Apr 2019 13:13:35 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-qt1-x842.google.com with SMTP id z17so10377293qts.13; Mon, 01 Apr 2019 06:13:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Ip0hfQYu6nrV9xQvjwNFL/NU84NOuYarK0Ij+Gt4XYA=; b=APOXTHdsbdkVU6aKbdGpMVhjnS1xlDT0J/syTwu0E0wS4nx+BHBOeq2yQq8aQthbQy 1/wvtk/vZga8Qqd2Reo8+vpft1zh8tSXH9myO7zaBwpQZ6x0TCm4GUeNpgCw6NDQUPmP lY9AyW9NEoybB65SmDaTVfrlJgTdyvUroCiwCfCVWKfOBcfBBk+OV8AJVuayENaIkuPK Z07jzBwE5cY2my5qoJSxVIRaD6JnqeKcDm3baxdHwPRmBmvWNdfGQK8p/h6tLhYD2zPO VSQZ20G4EYT/N3P5kYQ0QVZaOnbDtVD69tEyxoJO2WGyjTzOx4HQ6kRvWnGMYH6Lk0Tc IsXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Ip0hfQYu6nrV9xQvjwNFL/NU84NOuYarK0Ij+Gt4XYA=; b=KM+XUdmpcdCobOInJKIWlU9JUnYMIODYmRfJHZMtk2VX9QG4tvz518zZn57Y8jpGOt Bm/bWswW45/Zyxd4/m0ChiHQsYIDApJf8Y798aYBsOLeYFqIsgKZQIzCEw1hR5hjzM2o CSHoAk6rM9QIkoZFbYb1HaLCScI76lGICYTzRANWCtjmkDY2lVO3EVo7Tcg6EBUHkIg/ Mp4NFC1bThuKp6w3YgXcg74iFZOr4EMwtt96E8fLWPIouc3c7h7Fy3yVIftAdhMREZs1 w0H2G2ZDp2PBLxvENpQk8+YU3h8+oma6T/NEfBr4jpUGDYvxsoKYWktDXEi7E+Q9qElS Hm0w== X-Gm-Message-State: APjAAAWD+lDHr6S2yE6Hf32NBCeoTTTpW3BYRlLDknI5ykxlN96AdApO umyn3/PK0dvnEQ/UzROuiIXQJILPSTt1Cu540jyNfw== X-Google-Smtp-Source: APXvYqwpCuVyM1muGzVwe1nEO2o2RgtPWW9CFtI5sb8v3qWFAn2wcLmaYBxOrYfURK+z2EHfxDTVe/dzrffnwC/4vaA= X-Received: by 2002:a0c:c173:: with SMTP id i48mr33789442qvh.233.1554124414741; Mon, 01 Apr 2019 06:13:34 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac8:3353:0:0:0:0:0 with HTTP; Mon, 1 Apr 2019 06:13:32 -0700 (PDT) In-Reply-To: <20190401055318.GI7163@vega.codepro.be> References: <20190401055318.GI7163@vega.codepro.be> From: Mateusz Guzik Date: Mon, 1 Apr 2019 15:13:32 +0200 Message-ID: Subject: Re: svn commit: r345760 - in head: contrib/pf sys/netpfil/pf sbin/pfctl To: Kristof Provost Cc: src-committers@freebsd.org, svn-src-projects@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: AA6AF6E944 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.94 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.94)[-0.943,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 13:13:36 -0000 On 4/1/19, Kristof Provost wrote: > Author: kp > Date: Mon Apr 1 06:51:32 2019 > New Revision: 345760 > URL: https://svnweb.freebsd.org/changeset/base/345625 > > Log: > pf: Remove obsolete pf > > pf in FreeBSD lags years behind OpenBSD's pf. > Remove it. > > Users are advised to migrate to ipf. > I think you jumped the gun here. I understand maintaing pf in isolation is a burden and it prompted the removal, but there are other projects which also have the port. I think a reasonable course of action would be to maintain a portable pf port as a join effort with NetBSD. To that end you can start with replacing FreeBSD network stack with theirs to increase compatibility. After that it's all smooth sailing. -- Mateusz Guzik From owner-svn-src-projects@freebsd.org Mon Apr 1 13:26:28 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7346A1563250 for ; Mon, 1 Apr 2019 13:26:28 +0000 (UTC) (envelope-from mrvmurray@icloud.com) Received: from st43p00im-zteg10073401.me.com (st43p00im-zteg10073401.me.com [17.58.63.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1B7D56EE93 for ; Mon, 1 Apr 2019 13:26:28 +0000 (UTC) (envelope-from mrvmurray@icloud.com) Received: from gronkulator.grondar.org (grouter.grondar.org [88.96.155.38]) by st43p00im-zteg10073401.me.com (Postfix) with ESMTPSA id 5875A5E0140; Mon, 1 Apr 2019 13:26:20 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Subject: Re: svn commit: r345760 - in head: contrib/pf sys/netpfil/pf sbin/pfctl From: Mark Murray In-Reply-To: <20190401055318.GI7163@vega.codepro.be> Date: Mon, 1 Apr 2019 14:26:18 +0100 Cc: src-committers , svn-src-projects@freebsd.org Content-Transfer-Encoding: 7bit Message-Id: References: <20190401055318.GI7163@vega.codepro.be> To: Kristof Provost X-Mailer: Apple Mail (2.3445.104.8) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-04-01_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 mlxscore=0 mlxlogscore=331 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1812120000 definitions=main-1904010092 X-Rspamd-Queue-Id: 1B7D56EE93 X-Spamd-Bar: ------ X-Spamd-Result: default: False [-6.98 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.977,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 13:26:28 -0000 > On 1 Apr 2019, at 06:53, Kristof Provost wrote: > > pf in FreeBSD lags years behind OpenBSD's pf. > Remove it. > > Users are advised to migrate to ipf. Wouldn't AFD be a better choice? M -- From owner-svn-src-projects@freebsd.org Mon Apr 1 13:30:15 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0AE0C156335B for ; Mon, 1 Apr 2019 13:30:15 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8749F6F0CC; Mon, 1 Apr 2019 13:30:14 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id x31DUC00015186; Mon, 1 Apr 2019 06:30:12 -0700 (PDT) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id x31DUCYY015185; Mon, 1 Apr 2019 06:30:12 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201904011330.x31DUCYY015185@gndrsh.dnsmgr.net> Subject: Re: svn commit: r345760 - in head: contrib/pf sys/netpfil/pf sbin/pfctl In-Reply-To: To: Mateusz Guzik Date: Mon, 1 Apr 2019 06:30:12 -0700 (PDT) CC: Kristof Provost , src-committers@freebsd.org, svn-src-projects@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 8749F6F0CC X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.95 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.95)[-0.951,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 13:30:15 -0000 > On 4/1/19, Kristof Provost wrote: > > Author: kp > > Date: Mon Apr 1 06:51:32 2019 > > New Revision: 345760 > > URL: https://svnweb.freebsd.org/changeset/base/345625 > > > > Log: > > pf: Remove obsolete pf > > > > pf in FreeBSD lags years behind OpenBSD's pf. > > Remove it. > > > > Users are advised to migrate to ipf. > > > > I think you jumped the gun here. I understand maintaing pf in isolation > is a burden and it prompted the removal, but there are other projects > which also have the port. > > I think a reasonable course of action would be to maintain a portable pf > port as a join effort with NetBSD. To that end you can start with > replacing FreeBSD network stack with theirs to increase compatibility. > > After that it's all smooth sailing. If there is desire to create/maintain a *BSD pf port within the communtiy I would love to see that team formed. I have direct feedback from some community that would like to see FreeBSD update its pf code, is there some people who would like to take this work on? I had started a private conversation with Kristof on this just a few days ago, but was waiting to return to continue that conversation, but since a public one is happening lets just all go over to a list and discuss it? > -- > Mateusz Guzik -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-projects@freebsd.org Mon Apr 1 13:34:30 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1AAFE1563726 for ; Mon, 1 Apr 2019 13:34:30 +0000 (UTC) (envelope-from bu7cher@yandex.ru) Received: from forward102o.mail.yandex.net (forward102o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::602]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 82F836F5EF; Mon, 1 Apr 2019 13:34:29 +0000 (UTC) (envelope-from bu7cher@yandex.ru) Received: from mxback14o.mail.yandex.net (mxback14o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::65]) by forward102o.mail.yandex.net (Yandex) with ESMTP id 9834B66803EC; Mon, 1 Apr 2019 16:34:25 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback14o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id p8XKaZzpFO-YPxiBTLe; Mon, 01 Apr 2019 16:34:25 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1554125665; bh=sUBFzg/xjFBpxltW6JYr522Zyvi1QROoSsME03oMDpw=; h=In-Reply-To:From:To:Subject:Cc:Date:References:Message-ID; b=WPjbauNnuusLXBWS1U5XDU0lMC1xV+Rw2FS3EpnffTEENxtOKUutrQphq4AwGxlzF gWHyRzCNu3wtSM5JjL5BgbL+xIpWwd5iFL0dcQL0HK3DcV8PgTzkqCK36ZTsoVG3RP fDwFNvlJu/VMvfGBIyVyh1ttxwu+Rr5P7/sCe3YQ= Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id TQESqOS1NT-YOemQ25Y; Mon, 01 Apr 2019 16:34:24 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) Subject: Re: svn commit: r345760 - in head: contrib/pf sys/netpfil/pf sbin/pfctl To: rgrimes@freebsd.org, Mateusz Guzik Cc: Kristof Provost , src-committers@freebsd.org, svn-src-projects@freebsd.org References: <201904011330.x31DUCYY015185@gndrsh.dnsmgr.net> From: "Andrey V. Elsukov" Openpgp: id=E6591E1B41DA1516F0C9BC0001C5EA0410C8A17A Autocrypt: addr=bu7cher@yandex.ru; prefer-encrypt=mutual; keydata= mQENBEwBF1kBCADB9sXFhBEUy8qQ4X63Y8eBatYMHGEFWN9ypS5lI3RE6qQW2EYbxNk7qUC5 21YIIS1mMFVBEfvR7J9uc7yaYgFCEb6Sce1RSO4ULN2mRKGHP3/Sl0ijZEjWHV91hY1YTHEF ZW/0GYinDf56sYpDDehaBF5wkWIo1+QK5nmj3vl0DIDCMNd7QEiWpyLVwECgLX2eOAXByT8B bCqVhJGcG6iFP7/B9Ll6uX5gb8thM9LM+ibwErDBVDGiOgvfxqidab7fdkh893IBCXa82H9N CNwnEtcgzh+BSKK5BgvPohFMgRwjti37TSxwLu63QejRGbZWSz3OK3jMOoF63tCgn7FvABEB AAG0JUFuZHJleSBWLiBFbHN1a292IDxidTdjaGVyQHlhbmRleC5ydT6JATgEEwECACIFAkwB F1kCGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEAHF6gQQyKF6qmYIAI6ekfm1VA4T vqankI1ISE6ku4jV7UlpIQlEbE7/8n3Zd6teJ+pGOQhN5qk8QE7utdPdbktAzi+x7LIJVzUw 4TywZLXGrkP7VKYkfg6oyCGyzITghefQeJtr2TN4hYCkzPWpylkue8MtmqfZv/6royqwTbN+ +E09FQNvTgRUYJYTeQ1qOsxNRycwvw3dr2rOfuxShbzaHBB1pBIjGrMg8fC5pd65ACH5zuFV A0CoTNGMDrEZSfBkTW604UUHFFXeCoC3dwDZRKOWJ3GmMXns65Ai5YkA63BSHEE1Qle3VBhd cG1w0CB5FBV3pB27UVnf0jEbysrDqW4qN7XMRFSWNAy5AQ0ETAEXWQEIAJ2p6l9LBoqdH/0J PEFDY2t2gTvAuzz+8zs3R03dFuHcNbOwjvWCG0aOmVpAzkRa8egn5JB4sZaFUtKPYJEQ1Iu+ LUBwgvtXf4vWpzC67zs2dDuiW4LamH5p6xkTD61aHR7mCB3bg2TUjrDWn2Jt44cvoYxj3dz4 S49U1rc9ZPgD5axCNv45j72tggWlZvpefThP7xT1OlNTUqye2gAwQravXpZkl5JG4eOqJVIU X316iE3qso0iXRUtO7OseBf0PiVmk+wCahdreHOeOxK5jMhYkPKVn7z1sZiB7W2H2TojbmcK HZC22sz7Z/H36Lhg1+/RCnGzdEcjGc8oFHXHCxUAEQEAAYkBHwQYAQIACQUCTAEXWQIbDAAK CRABxeoEEMihegkYCAC3ivGYNe2taNm/4Nx5GPdzuaAJGKWksV+w9mo7dQvU+NmI2az5w8vw 98OmX7G0OV9snxMW+6cyNqBrVFTu33VVNzz9pnqNCHxGvj5dL5ltP160JV2zw2bUwJBYsgYQ WfyJJIM7l3gv5ZS3DGqaGIm9gOK1ANxfrR5PgPzvI9VxDhlr2juEVMZYAqPLEJe+SSxbwLoz BcFCNdDAyXcaAzXsx/E02YWm1hIWNRxanAe7Vlg7OL+gvLpdtrYCMg28PNqKNyrQ87LQ49O9 50IIZDOtNFeR0FGucjcLPdS9PiEqCoH7/waJxWp6ydJ+g4OYRBYNM0EmMgy1N85JJrV1mi5i Message-ID: <78dda390-9357-2d5a-1737-7efd6901658a@yandex.ru> Date: Mon, 1 Apr 2019 16:32:28 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <201904011330.x31DUCYY015185@gndrsh.dnsmgr.net> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rZGnFAE40N1XGEMlRMhwTe1hzjD24vREN" X-Rspamd-Queue-Id: 82F836F5EF X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.99 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.99)[-0.988,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 13:34:30 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --rZGnFAE40N1XGEMlRMhwTe1hzjD24vREN Content-Type: multipart/mixed; boundary="UqQnglXTRPqsD6v6Bty6V8ziwFn27y3Wi"; protected-headers="v1" From: "Andrey V. Elsukov" To: rgrimes@freebsd.org, Mateusz Guzik Cc: Kristof Provost , src-committers@freebsd.org, svn-src-projects@freebsd.org Message-ID: <78dda390-9357-2d5a-1737-7efd6901658a@yandex.ru> Subject: Re: svn commit: r345760 - in head: contrib/pf sys/netpfil/pf sbin/pfctl References: <201904011330.x31DUCYY015185@gndrsh.dnsmgr.net> In-Reply-To: <201904011330.x31DUCYY015185@gndrsh.dnsmgr.net> --UqQnglXTRPqsD6v6Bty6V8ziwFn27y3Wi Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 01.04.2019 16:30, Rodney W. Grimes wrote: >> I think a reasonable course of action would be to maintain a portable = pf >> port as a join effort with NetBSD. To that end you can start with >> replacing FreeBSD network stack with theirs to increase compatibility.= >> >> After that it's all smooth sailing. >=20 > If there is desire to create/maintain a *BSD pf port within > the communtiy I would love to see that team formed. I have > direct feedback from some community that would like to see > FreeBSD update its pf code, is there some people who would like > to take this work on? It seems it is too late: https://marc.info/?l=3Dopenbsd-tech&m=3D155409489427092&w=3D2 http://mail-index.netbsd.org/tech-kern/2019/03/29/msg024883.html --=20 WBR, Andrey V. Elsukov --UqQnglXTRPqsD6v6Bty6V8ziwFn27y3Wi-- --rZGnFAE40N1XGEMlRMhwTe1hzjD24vREN Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ iQEzBAEBCAAdFiEE5lkeG0HaFRbwybwAAcXqBBDIoXoFAlyiEuwACgkQAcXqBBDI oXof3ggAigcTfz0eFL7jDklbJjlf2iCwP4LZQfR7EKaVqa6d2zIO1Q/HWPqlLCnN pLXkDuTByHy/+cGDULdtdzlYiNtYFDxQZB48AU3omH8NbYHatdTjIel30IeDJ/my B/FB/xAwuo9RVd8GhZl016Hg1Or8lT7UnFxYcEQSH+dOT2B5Sd4uzaNZgShMmW8q iQCnyf6bLv0jijAqkjRv+vg6zeL9ob4OUVh+WaJHGrHCz3JQHSUWre9STAuxuwoM TXYGPYGaqdaDnutuJFrYS9CVQaZxJk8/McE9xVjXxIyaZIlR+B/GzPqtvqBqOEWf Jm9y/Ql9Q+6gsb07171LGR73sm3Thw== =sWGu -----END PGP SIGNATURE----- --rZGnFAE40N1XGEMlRMhwTe1hzjD24vREN-- From owner-svn-src-projects@freebsd.org Mon Apr 1 13:48:10 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B58341563CAE for ; Mon, 1 Apr 2019 13:48:10 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 32E8A6FD9B; Mon, 1 Apr 2019 13:48:09 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id x31Dm8t2015298; Mon, 1 Apr 2019 06:48:08 -0700 (PDT) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id x31Dm86D015297; Mon, 1 Apr 2019 06:48:08 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201904011348.x31Dm86D015297@gndrsh.dnsmgr.net> Subject: Re: svn commit: r345760 - in head: contrib/pf sys/netpfil/pf sbin/pfctl In-Reply-To: <78dda390-9357-2d5a-1737-7efd6901658a@yandex.ru> To: "Andrey V. Elsukov" Date: Mon, 1 Apr 2019 06:48:08 -0700 (PDT) CC: rgrimes@freebsd.org, Mateusz Guzik , Kristof Provost , src-committers@freebsd.org, svn-src-projects@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 32E8A6FD9B X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.97 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.97)[-0.966,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 13:48:10 -0000 [ Charset UTF-8 unsupported, converting... ] > On 01.04.2019 16:30, Rodney W. Grimes wrote: > >> I think a reasonable course of action would be to maintain a portable pf > >> port as a join effort with NetBSD. To that end you can start with > >> replacing FreeBSD network stack with theirs to increase compatibility. > >> > >> After that it's all smooth sailing. > > > > If there is desire to create/maintain a *BSD pf port within > > the communtiy I would love to see that team formed. I have > > direct feedback from some community that would like to see > > FreeBSD update its pf code, is there some people who would like > > to take this work on? > > It seems it is too late: > https://marc.info/?l=openbsd-tech&m=155409489427092&w=2 I am wondering on the above as it has a date of: Date: 2019-04-01 5:01:03 which would be in line with Kristof's joke. > http://mail-index.netbsd.org/tech-kern/2019/03/29/msg024883.html This is inline with what is being proposed here, NetBSD has old rotted code that needs updated. Rather than do that work twice, do it 1.5 times (implementing the same technology in 2 OS's should be less work than doing it twice.) I believe there is grant money avaliable from a non Foundation source that could be used to do this work. > -- > WBR, Andrey V. Elsukov -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-projects@freebsd.org Mon Apr 1 14:23:44 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C39C91564938 for ; Mon, 1 Apr 2019 14:23:44 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6A86671284; Mon, 1 Apr 2019 14:23:44 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 44DADFA83; Mon, 1 Apr 2019 14:23:44 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x31ENii4045853; Mon, 1 Apr 2019 14:23:44 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31ENhtx045849; Mon, 1 Apr 2019 14:23:43 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904011423.x31ENhtx045849@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Mon, 1 Apr 2019 14:23:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345766 - projects/fuse2/sys/fs/fuse X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: projects/fuse2/sys/fs/fuse X-SVN-Commit-Revision: 345766 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 6A86671284 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.964,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 14:23:45 -0000 Author: asomers Date: Mon Apr 1 14:23:43 2019 New Revision: 345766 URL: https://svnweb.freebsd.org/changeset/base/345766 Log: fusefs: replace obsolete array idioms r345742 replaced fusefs's fufh array with a fufh list. But it left a few array idioms in place. This commit replaces those idioms with more efficient list idioms. One location is in fuse_filehandle_close, which now takes a pointer argument. Three other locations are places that had to loop over all of a vnode's fuse filehandles. Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/sys/fs/fuse/fuse_file.c projects/fuse2/sys/fs/fuse/fuse_file.h projects/fuse2/sys/fs/fuse/fuse_internal.c projects/fuse2/sys/fs/fuse/fuse_vnops.c Modified: projects/fuse2/sys/fs/fuse/fuse_file.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_file.c Mon Apr 1 14:21:32 2019 (r345765) +++ projects/fuse2/sys/fs/fuse/fuse_file.c Mon Apr 1 14:23:43 2019 (r345766) @@ -154,21 +154,15 @@ out: } int -fuse_filehandle_close(struct vnode *vp, fufh_type_t fufh_type, +fuse_filehandle_close(struct vnode *vp, struct fuse_filehandle *fufh, struct thread *td, struct ucred *cred) { struct fuse_dispatcher fdi; struct fuse_release_in *fri; - struct fuse_filehandle *fufh = NULL; int err = 0; int op = FUSE_RELEASE; - if (fuse_filehandle_get(vp, fufh_type, &fufh)) { - panic("FUSE: fuse_filehandle_close called on invalid fufh " - "(type=%d)", fufh_type); - /* NOTREACHED */ - } if (fuse_isdeadfs(vp)) { goto out; } @@ -178,7 +172,7 @@ fuse_filehandle_close(struct vnode *vp, fufh_type_t fu fdisp_make_vp(&fdi, op, vp, td, cred); fri = fdi.indata; fri->fh = fufh->fh_id; - fri->flags = fuse_filehandle_xlate_to_oflags(fufh_type); + fri->flags = fufh->flags; err = fdisp_wait_answ(&fdi); fdisp_destroy(&fdi); @@ -221,10 +215,10 @@ fuse_filehandle_get(struct vnode *vp, fufh_type_t fufh struct fuse_vnode_data *fvdat = VTOFUD(vp); struct fuse_filehandle *fufh; - /* TODO: Find a list entry with the same mode, pid, gid, and uid */ - /* Fallback: find a list entry with the right mode */ + /* TODO: Find a list entry with the same flags, pid, gid, and uid */ + /* Fallback: find a list entry with the right flags */ LIST_FOREACH(fufh, &fvdat->handles, next) { - if (fufh->mode == fufh_type) + if (fufh->flags == fufh_type) break; } @@ -258,7 +252,7 @@ fuse_filehandle_init(struct vnode *vp, fufh_type_t fuf M_WAITOK); MPASS(fufh != NULL); fufh->fh_id = fh_id; - fufh->mode = fufh_type; + fufh->flags = fufh_type; /* TODO: initialize fufh credentials and open flags */ if (!FUFH_IS_VALID(fufh)) { panic("FUSE: init: invalid filehandle id (type=%d)", fufh_type); Modified: projects/fuse2/sys/fs/fuse/fuse_file.h ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_file.h Mon Apr 1 14:21:32 2019 (r345765) +++ projects/fuse2/sys/fs/fuse/fuse_file.h Mon Apr 1 14:23:43 2019 (r345766) @@ -66,12 +66,16 @@ #include #include +/* + * The fufh type is the access mode of the fuse file handle. It's the portion + * of the open(2) flags related to permission. + */ typedef enum fufh_type { FUFH_INVALID = -1, FUFH_RDONLY = 0, FUFH_WRONLY = 1, FUFH_RDWR = 2, - FUFH_MAXTYPE = 3, + /* TODO: add FUFH_EXEC */ } fufh_type_t; _Static_assert(FUFH_RDONLY == O_RDONLY, "RDONLY"); _Static_assert(FUFH_WRONLY == O_WRONLY, "WRONLY"); @@ -86,8 +90,8 @@ struct fuse_filehandle { /* flags returned by FUSE_OPEN */ uint32_t fuse_open_flags; - /* The mode used to open(2) the file (using O_RDONLY, not FREAD) */ - uint32_t mode; + /* The flags used to open(2) the file (using O_RDONLY, not FREAD) */ + uint32_t flags; /* Credentials used to open the file */ gid_t gid; @@ -95,7 +99,7 @@ struct fuse_filehandle { uid_t uid; }; -#define FUFH_IS_VALID(f) ((f)->mode != FUFH_INVALID) +#define FUFH_IS_VALID(f) ((f)->flags != FUFH_INVALID) static inline fufh_type_t fuse_filehandle_xlate_from_fflags(int fflags) @@ -140,7 +144,7 @@ void fuse_filehandle_init(struct vnode *vp, fufh_type_ int fuse_filehandle_open(struct vnode *vp, fufh_type_t fufh_type, struct fuse_filehandle **fufhp, struct thread *td, struct ucred *cred); -int fuse_filehandle_close(struct vnode *vp, fufh_type_t fufh_type, +int fuse_filehandle_close(struct vnode *vp, struct fuse_filehandle *fufh, struct thread *td, struct ucred *cred); #endif /* _FUSE_FILE_H_ */ Modified: projects/fuse2/sys/fs/fuse/fuse_internal.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_internal.c Mon Apr 1 14:21:32 2019 (r345765) +++ projects/fuse2/sys/fs/fuse/fuse_internal.c Mon Apr 1 14:23:43 2019 (r345766) @@ -285,36 +285,37 @@ fuse_internal_fsync(struct vnode *vp, struct fuse_fsync_in *ffsi; struct fuse_dispatcher fdi; struct fuse_filehandle *fufh; + struct fuse_vnode_data *fvdat = VTOFUD(vp); int op = FUSE_FSYNC; - int type = 0; int err = 0; if (!fsess_isimpl(vnode_mount(vp), (vnode_vtype(vp) == VDIR ? FUSE_FSYNCDIR : FUSE_FSYNC))) { return 0; } - for (type = 0; type < FUFH_MAXTYPE; type++) { - if (fuse_filehandle_get(vp, type, &fufh) == 0) { - if (vnode_isdir(vp)) { - op = FUSE_FSYNCDIR; - } - fdisp_init(&fdi, sizeof(*ffsi)); - fdisp_make_vp(&fdi, op, vp, td, NULL); - ffsi = fdi.indata; - ffsi->fh = fufh->fh_id; + if (vnode_isdir(vp)) + op = FUSE_FSYNCDIR; + /* + * fsync every open file handle for this file, because we can't be sure + * which file handle the caller is really referring to. + */ + LIST_FOREACH(fufh, &fvdat->handles, next) { + fdisp_init(&fdi, sizeof(*ffsi)); + fdisp_make_vp(&fdi, op, vp, td, NULL); + ffsi = fdi.indata; + ffsi->fh = fufh->fh_id; - if (datasync) - ffsi->fsync_flags = 1; + if (datasync) + ffsi->fsync_flags = 1; - if (waitfor == MNT_WAIT) { - err = fdisp_wait_answ(&fdi); - } else { - fuse_insert_callback(fdi.tick, - fuse_internal_fsync_callback); - fuse_insert_message(fdi.tick); - } - fdisp_destroy(&fdi); + if (waitfor == MNT_WAIT) { + err = fdisp_wait_answ(&fdi); + } else { + fuse_insert_callback(fdi.tick, + fuse_internal_fsync_callback); + fuse_insert_message(fdi.tick); } + fdisp_destroy(&fdi); } return err; Modified: projects/fuse2/sys/fs/fuse/fuse_vnops.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_vnops.c Mon Apr 1 14:21:32 2019 (r345765) +++ projects/fuse2/sys/fs/fuse/fuse_vnops.c Mon Apr 1 14:23:43 2019 (r345766) @@ -278,33 +278,22 @@ fuse_vnop_close(struct vop_close_args *ap) struct vnode *vp = ap->a_vp; struct ucred *cred = ap->a_cred; int fflag = ap->a_fflag; - fufh_type_t fufh_type; if (fuse_isdeadfs(vp)) { return 0; } if (vnode_isdir(vp)) { - if (fuse_filehandle_valid(vp, FUFH_RDONLY)) { - fuse_filehandle_close(vp, FUFH_RDONLY, NULL, cred); + struct fuse_filehandle *fufh; + + if (fuse_filehandle_get(vp, O_RDONLY, &fufh)) { + fuse_filehandle_close(vp, fufh, NULL, cred); } return 0; } if (fflag & IO_NDELAY) { return 0; } - fufh_type = fuse_filehandle_xlate_from_fflags(fflag); - - if (!fuse_filehandle_valid(vp, fufh_type)) { - int i; - - for (i = 0; i < FUFH_MAXTYPE; i++) - if (fuse_filehandle_valid(vp, i)) - break; - if (i == FUFH_MAXTYPE) - panic("FUSE: fufh type %d found to be invalid in close" - " (fflag=0x%x)\n", - fufh_type, fflag); - } + /* TODO: close the file handle, if we're sure it's no longer used */ if ((VTOFUD(vp)->flag & FN_SIZECHANGE) != 0) { fuse_vnode_savesize(vp, cred); } @@ -601,25 +590,23 @@ fuse_vnop_inactive(struct vop_inactive_args *ap) struct thread *td = ap->a_td; struct fuse_vnode_data *fvdat = VTOFUD(vp); - struct fuse_filehandle *fufh = NULL; + struct fuse_filehandle *fufh, *fufh_tmp; - int type, need_flush = 1; + int need_flush = 1; - for (type = 0; type < FUFH_MAXTYPE; type++) { - if (!fuse_filehandle_get(vp, type, &fufh)) { - if (need_flush && vp->v_type == VREG) { - if ((VTOFUD(vp)->flag & FN_SIZECHANGE) != 0) { - fuse_vnode_savesize(vp, NULL); - } - if (fuse_data_cache_invalidate || - (fvdat->flag & FN_REVOKED) != 0) - fuse_io_invalbuf(vp, td); - else - fuse_io_flushbuf(vp, MNT_WAIT, td); - need_flush = 0; + LIST_FOREACH_SAFE(fufh, &fvdat->handles, next, fufh_tmp) { + if (need_flush && vp->v_type == VREG) { + if ((VTOFUD(vp)->flag & FN_SIZECHANGE) != 0) { + fuse_vnode_savesize(vp, NULL); } - fuse_filehandle_close(vp, type, td, NULL); + if (fuse_data_cache_invalidate || + (fvdat->flag & FN_REVOKED) != 0) + fuse_io_invalbuf(vp, td); + else + fuse_io_flushbuf(vp, MNT_WAIT, td); + need_flush = 0; } + fuse_filehandle_close(vp, fufh, td, NULL); } if ((fvdat->flag & FN_REVOKED) != 0 && fuse_reclaim_revoked) { @@ -1317,13 +1304,11 @@ fuse_vnop_readdir(struct vop_readdir_args *ap) return EINVAL; } - if (!fuse_filehandle_valid(vp, FUFH_RDONLY)) { + if ((err = fuse_filehandle_get(vp, O_RDONLY, &fufh)) != 0) { SDT_PROBE2(fuse, , vnops, trace, 1, "calling readdir() before open()"); - err = fuse_filehandle_open(vp, FUFH_RDONLY, &fufh, NULL, cred); + err = fuse_filehandle_open(vp, O_RDONLY, &fufh, NULL, cred); freefufh = 1; - } else { - err = fuse_filehandle_get(vp, FUFH_RDONLY, &fufh); } if (err) { return (err); @@ -1334,9 +1319,9 @@ fuse_vnop_readdir(struct vop_readdir_args *ap) err = fuse_internal_readdir(vp, uio, fufh, &cookediov); fiov_teardown(&cookediov); - if (freefufh) { - fuse_filehandle_close(vp, FUFH_RDONLY, NULL, cred); - } + if (freefufh) + fuse_filehandle_close(vp, fufh, NULL, cred); + return err; } @@ -1393,20 +1378,16 @@ fuse_vnop_reclaim(struct vop_reclaim_args *ap) { struct vnode *vp = ap->a_vp; struct thread *td = ap->a_td; - struct fuse_vnode_data *fvdat = VTOFUD(vp); + struct fuse_filehandle *fufh, *fufh_tmp; - int type; - if (!fvdat) { panic("FUSE: no vnode data during recycling"); } - for (type = 0; type < FUFH_MAXTYPE; type++) { - if (fuse_filehandle_get(vp, type, NULL) == 0) { - printf("FUSE: vnode being reclaimed but fufh (type=%d) is valid", - type); - fuse_filehandle_close(vp, type, td, NULL); - } + LIST_FOREACH_SAFE(fufh, &fvdat->handles, next, fufh_tmp) { + printf("FUSE: vnode being reclaimed with open fufh " + "(flags=%#x)", fufh->flags); + fuse_filehandle_close(vp, fufh, td, NULL); } if ((!fuse_isdeadfs(vp)) && (fvdat->nlookup)) { From owner-svn-src-projects@freebsd.org Mon Apr 1 15:25:53 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7A9461566B01 for ; Mon, 1 Apr 2019 15:25:53 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EA3FD73C70; Mon, 1 Apr 2019 15:25:52 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-pl1-x634.google.com with SMTP id m10so4653907plt.10; Mon, 01 Apr 2019 08:25:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=H7FJuuGi5bwnpHPc3DaIebSbbvDjyCqxj67IjTWYIa4=; b=Vl18AGi3eMy7PLE6C1wjJclJFplZJZtStXqsVN+XRqgF/C0Dlb2rmEHcMh8UsyLF28 2B5VGogGCF09fJw7Gn/KlMcvSUS50elWRoDx3iu1CyFQsEdJQ38WnTsyJMS66j5LCDNo bSAfctIsVM2XeVX7DRVOofkDdaSE0Y7DzahoQjZpK3eq5gOEUrDLoN2pN9nJTE4OGMof taQqClpng/zjjcCz6BTlvA8RcRc+14AvZaRgFA1Pm4FA0rAkBriVy2KHbMJvCvSUmzvk /xI9S1QDqaswr/eZ0lZ16xUEtmfjTmRi66DIK+W0QsV0sVT+GvpmkmW9LXN6ofZEFzxq nleg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=H7FJuuGi5bwnpHPc3DaIebSbbvDjyCqxj67IjTWYIa4=; b=cHdic5Oo/3AsbfBkm9DZ1cFfD26h9oCYu0PWwYyA3cSFY1Dkxpynn5v4sQFwX1RtzT 2yKZORLrF6BLP8ZcpHImKJfxb3nM0iBFj0WKYezbcOSSQ0zta0YZvMdFr3oxpwOew0Lf t//LLOE6SCqanfcrVfkjRiFvZb2VmUN6PFWQzizpL8ZucqTmsKmBH9r+iuWjywl1nmw6 T2igE3GQnekzYpZl0V+dlQWdgOWwp7SPTxsBY6y86Mnb1i5nKG8eU0+WyvixkYwUkhFG 2x84n4/U3b4nt+QxBnvDEu8hJj3yzD+jzNXU3/ldGd+idLMkDjmh09o0AAVwcokae1kt Tntg== X-Gm-Message-State: APjAAAXSYR+jrp/c6tg0pZv2WAUYsOTHB1jevODMw/XJ0cC1sg+14XAr WTHSrvBEhFkwBQeAqJOomPeFmvLcSJA= X-Google-Smtp-Source: APXvYqyzbK7xAJMIvGe0HDFfXAQzAplPq1AtKFC+CBG+8Z4Gjbqr5zwvakGSZ8QD0RyUz9lAd1wnTQ== X-Received: by 2002:a17:902:28a7:: with SMTP id f36mr65506524plb.169.1554132351028; Mon, 01 Apr 2019 08:25:51 -0700 (PDT) Received: from [192.168.20.22] (c-73-19-52-228.hsd1.wa.comcast.net. [73.19.52.228]) by smtp.gmail.com with ESMTPSA id e123sm13802195pgc.14.2019.04.01.08.25.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Apr 2019 08:25:50 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (1.0) Subject: Re: svn commit: r345760 - in head: contrib/pf sys/netpfil/pf sbin/pfctl From: Enji Cooper X-Mailer: iPhone Mail (16E227) In-Reply-To: <20190401055318.GI7163@vega.codepro.be> Date: Mon, 1 Apr 2019 08:25:49 -0700 Cc: src-committers@freebsd.org, svn-src-projects@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20190401055318.GI7163@vega.codepro.be> To: Kristof Provost X-Rspamd-Queue-Id: EA3FD73C70 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.97 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.97)[-0.966,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 15:25:53 -0000 > On Mar 31, 2019, at 22:53, Kristof Provost wrote: >=20 > Author: kp > Date: Mon Apr 1 06:51:32 2019 > New Revision: 345760 > URL: https://svnweb.freebsd.org/changeset/base/345625 > Log: > pf: Remove obsolete pf >=20 > pf in FreeBSD lags years behind OpenBSD's pf. > Remove it. >=20 > Users are advised to migrate to ipf. Well played prank, sir. Well played. Cheers, -Enji PS For those not getting the gag, the svn link oddly doesn=E2=80=99t match t= he revision number ;).. also, note the commit date :).= From owner-svn-src-projects@freebsd.org Mon Apr 1 16:15:30 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 553D215682D5 for ; Mon, 1 Apr 2019 16:15:30 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EB3E075EDD; Mon, 1 Apr 2019 16:15:29 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C294C18DA1; Mon, 1 Apr 2019 16:15:29 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x31GFTIu004480; Mon, 1 Apr 2019 16:15:29 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31GFT6J004479; Mon, 1 Apr 2019 16:15:29 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904011615.x31GFT6J004479@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Mon, 1 Apr 2019 16:15:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345767 - projects/fuse2/sys/fs/fuse X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: projects/fuse2/sys/fs/fuse X-SVN-Commit-Revision: 345767 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: EB3E075EDD X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.974,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 16:15:30 -0000 Author: asomers Date: Mon Apr 1 16:15:29 2019 New Revision: 345767 URL: https://svnweb.freebsd.org/changeset/base/345767 Log: fusefs: fix an inverted error check in my last commit This should be merged alongside 345766 Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/sys/fs/fuse/fuse_vnops.c Modified: projects/fuse2/sys/fs/fuse/fuse_vnops.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_vnops.c Mon Apr 1 14:23:43 2019 (r345766) +++ projects/fuse2/sys/fs/fuse/fuse_vnops.c Mon Apr 1 16:15:29 2019 (r345767) @@ -285,9 +285,8 @@ fuse_vnop_close(struct vop_close_args *ap) if (vnode_isdir(vp)) { struct fuse_filehandle *fufh; - if (fuse_filehandle_get(vp, O_RDONLY, &fufh)) { + if (fuse_filehandle_get(vp, O_RDONLY, &fufh) == 0) fuse_filehandle_close(vp, fufh, NULL, cred); - } return 0; } if (fflag & IO_NDELAY) { From owner-svn-src-projects@freebsd.org Mon Apr 1 16:16:55 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6C5551568322 for ; Mon, 1 Apr 2019 16:16:55 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0E2EA75FF8; Mon, 1 Apr 2019 16:16:55 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from venus.codepro.be (venus.codepro.be [5.9.86.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.codepro.be", Issuer "Let's Encrypt Authority X3" (verified OK)) (Authenticated sender: kp) by smtp.freebsd.org (Postfix) with ESMTPSA id 9857B1DDA3; Mon, 1 Apr 2019 16:16:54 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from [10.0.2.193] (ptr-8rh08jzj3mphveqp3q8.18120a2.ip6.access.telenet.be [IPv6:2a02:1811:240e:402:6058:a09a:1f67:6120]) (Authenticated sender: kp) by venus.codepro.be (Postfix) with ESMTPSA id 8BDD830492; Mon, 1 Apr 2019 18:16:52 +0200 (CEST) From: "Kristof Provost" To: rgrimes@freebsd.org Cc: "Andrey V. Elsukov" , "Mateusz Guzik" , src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: Re: svn commit: r345760 - in head: contrib/pf sys/netpfil/pf sbin/pfctl Date: Mon, 01 Apr 2019 18:16:51 +0200 X-Mailer: MailMate (2.0BETAr6135) Message-ID: In-Reply-To: <201904011348.x31Dm86D015297@gndrsh.dnsmgr.net> References: <201904011348.x31Dm86D015297@gndrsh.dnsmgr.net> MIME-Version: 1.0 X-Rspamd-Queue-Id: 0E2EA75FF8 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.97 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.97)[-0.966,0] Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 16:16:55 -0000 On 1 Apr 2019, at 15:48, Rodney W. Grimes wrote: > [ Charset UTF-8 unsupported, converting... ] >> On 01.04.2019 16:30, Rodney W. Grimes wrote: >> It seems it is too late: >> https://marc.info/?l=openbsd-tech&m=155409489427092&w=2 > > I am wondering on the above as it has a date of: > Date: 2019-04-01 5:01:03 > > which would be in line with Kristof's joke. > Yes, OpenBSD are clearly joking as well. >> http://mail-index.netbsd.org/tech-kern/2019/03/29/msg024883.html > This is inline with what is being proposed here, NetBSD has > old rotted code that needs updated. [Disclaimer: I do not speak for NetBSD, and based this on my reading of that thread] NetBSD however are serious. Their situation is slightly different, in that their primary reason is that they don’t have a maintainer for their pf version and it’s suffering from significant bitrot. Our situation is somewhat better. Our pf is maintained and does get bug fixes and improvements. Not as many as I’d like, but there’s something. > Rather than do that work > twice, do it 1.5 times (implementing the same technology in > 2 OS's should be less work than doing it twice.) > > I believe there is grant money avaliable from a non Foundation > source that could be used to do this work. > I’m not at all opposed to updating our pf, but there are a few obstacles (technical: performance, syntax and vimage. Practical: this is a lot of work). If people are interested in that discussion I’d propose someone start a new thread on freebsd-pf@, and I’ll expand on what I think the problems are and what needs to be done. I’d also be interested in knowing what people are looking for from an updated pf in FreeBSD. What are the improvements in OpenBSD that you’d really like to see in FreeBSD? Regards, Kristof From owner-svn-src-projects@freebsd.org Mon Apr 1 16:36:05 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 889831568DEC for ; Mon, 1 Apr 2019 16:36:05 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2BCF076A93; Mon, 1 Apr 2019 16:36:05 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 09AF8190FC; Mon, 1 Apr 2019 16:36:05 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x31Ga4cD014758; Mon, 1 Apr 2019 16:36:04 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31Ga3Rv014748; Mon, 1 Apr 2019 16:36:03 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904011636.x31Ga3Rv014748@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Mon, 1 Apr 2019 16:36:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345768 - in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Commit-Revision: 345768 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 2BCF076A93 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.975,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 16:36:05 -0000 Author: asomers Date: Mon Apr 1 16:36:02 2019 New Revision: 345768 URL: https://svnweb.freebsd.org/changeset/base/345768 Log: fusefs: allow opening files O_EXEC O_EXEC is useful for fexecve(2) and fchdir(2). Treat it as another fufh type alongside the existing RDONLY, WRONLY, and RDWR. Prior to r345742 this would've caused a memory and performance penalty. PR: 236329 Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/sys/fs/fuse/fuse_file.c projects/fuse2/sys/fs/fuse/fuse_file.h projects/fuse2/sys/fs/fuse/fuse_vnops.c projects/fuse2/tests/sys/fs/fusefs/mockfs.cc projects/fuse2/tests/sys/fs/fusefs/open.cc projects/fuse2/tests/sys/fs/fusefs/opendir.cc projects/fuse2/tests/sys/fs/fusefs/readdir.cc projects/fuse2/tests/sys/fs/fusefs/releasedir.cc projects/fuse2/tests/sys/fs/fusefs/utils.cc Modified: projects/fuse2/sys/fs/fuse/fuse_file.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_file.c Mon Apr 1 16:15:29 2019 (r345767) +++ projects/fuse2/sys/fs/fuse/fuse_file.c Mon Apr 1 16:36:02 2019 (r345768) @@ -121,12 +121,8 @@ fuse_filehandle_open(struct vnode *vp, fufh_type_t fuf if (vnode_isdir(vp)) { op = FUSE_OPENDIR; - if (fufh_type != FUFH_RDONLY) { - SDT_PROBE2(fuse, , file, trace, 1, - "non-rdonly fh requested for a directory?"); - printf("FUSE:non-rdonly fh requested for a directory?\n"); - fufh_type = FUFH_RDONLY; - } + /* vn_open_vnode already rejects FWRITE on directories */ + MPASS(fufh_type == FUFH_RDONLY || fufh_type == FUFH_EXEC); } fdisp_init(&fdi, sizeof(*foi)); fdisp_make_vp(&fdi, op, vp, td, cred); Modified: projects/fuse2/sys/fs/fuse/fuse_file.h ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_file.h Mon Apr 1 16:15:29 2019 (r345767) +++ projects/fuse2/sys/fs/fuse/fuse_file.h Mon Apr 1 16:36:02 2019 (r345768) @@ -72,14 +72,11 @@ */ typedef enum fufh_type { FUFH_INVALID = -1, - FUFH_RDONLY = 0, - FUFH_WRONLY = 1, - FUFH_RDWR = 2, - /* TODO: add FUFH_EXEC */ + FUFH_RDONLY = O_RDONLY, + FUFH_WRONLY = O_WRONLY, + FUFH_RDWR = O_RDWR, + FUFH_EXEC = O_EXEC, } fufh_type_t; -_Static_assert(FUFH_RDONLY == O_RDONLY, "RDONLY"); -_Static_assert(FUFH_WRONLY == O_WRONLY, "WRONLY"); -_Static_assert(FUFH_RDWR == O_RDWR, "RDWR"); struct fuse_filehandle { LIST_ENTRY(fuse_filehandle) next; @@ -110,6 +107,8 @@ fuse_filehandle_xlate_from_fflags(int fflags) return FUFH_WRONLY; else if (fflags & (FREAD)) return FUFH_RDONLY; + else if (fflags & (FEXEC)) + return FUFH_EXEC; else panic("FUSE: What kind of a flag is this (%x)?", fflags); } @@ -123,6 +122,7 @@ fuse_filehandle_xlate_to_oflags(fufh_type_t type) case FUFH_RDONLY: case FUFH_WRONLY: case FUFH_RDWR: + case FUFH_EXEC: oflags = type; break; default: Modified: projects/fuse2/sys/fs/fuse/fuse_vnops.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_vnops.c Mon Apr 1 16:15:29 2019 (r345767) +++ projects/fuse2/sys/fs/fuse/fuse_vnops.c Mon Apr 1 16:36:02 2019 (r345768) @@ -285,7 +285,8 @@ fuse_vnop_close(struct vop_close_args *ap) if (vnode_isdir(vp)) { struct fuse_filehandle *fufh; - if (fuse_filehandle_get(vp, O_RDONLY, &fufh) == 0) + if ((fuse_filehandle_get(vp, O_RDONLY, &fufh) == 0) || + (fuse_filehandle_get(vp, O_EXEC, &fufh) == 0)) fuse_filehandle_close(vp, fufh, NULL, cred); return 0; } @@ -1201,16 +1202,12 @@ fuse_vnop_open(struct vop_open_args *ap) return ENXIO; if (vp->v_type == VCHR || vp->v_type == VBLK || vp->v_type == VFIFO) return (EOPNOTSUPP); - if ((mode & (FREAD | FWRITE)) == 0) + if ((mode & (FREAD | FWRITE | FEXEC)) == 0) return EINVAL; fvdat = VTOFUD(vp); - if (vnode_isdir(vp)) { - fufh_type = FUFH_RDONLY; - } else { - fufh_type = fuse_filehandle_xlate_from_fflags(mode); - } + fufh_type = fuse_filehandle_xlate_from_fflags(mode); if (fuse_filehandle_validrw(vp, fufh_type) != FUFH_INVALID) { fuse_vnode_open(vp, 0, td); @@ -1303,7 +1300,7 @@ fuse_vnop_readdir(struct vop_readdir_args *ap) return EINVAL; } - if ((err = fuse_filehandle_get(vp, O_RDONLY, &fufh)) != 0) { + if ((err = fuse_filehandle_get(vp, FUFH_RDONLY, &fufh)) != 0) { SDT_PROBE2(fuse, , vnops, trace, 1, "calling readdir() before open()"); err = fuse_filehandle_open(vp, O_RDONLY, &fufh, NULL, cred); Modified: projects/fuse2/tests/sys/fs/fusefs/mockfs.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/mockfs.cc Mon Apr 1 16:15:29 2019 (r345767) +++ projects/fuse2/tests/sys/fs/fusefs/mockfs.cc Mon Apr 1 16:36:02 2019 (r345768) @@ -200,7 +200,8 @@ void debug_fuseop(const mockfs_buf_in *in) in->body.read.size); break; case FUSE_READDIR: - printf(" offset=%lu size=%u", in->body.readdir.offset, + printf(" fh=%#lx offset=%lu size=%u", + in->body.readdir.fh, in->body.readdir.offset, in->body.readdir.size); break; case FUSE_RELEASE: Modified: projects/fuse2/tests/sys/fs/fusefs/open.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/open.cc Mon Apr 1 16:15:29 2019 (r345767) +++ projects/fuse2/tests/sys/fs/fusefs/open.cc Mon Apr 1 16:36:02 2019 (r345768) @@ -250,8 +250,7 @@ TEST_F(Open, o_excl) test_ok(O_WRONLY | O_EXCL, O_WRONLY); } -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236329 */ -TEST_F(Open, DISABLED_o_exec) +TEST_F(Open, o_exec) { test_ok(O_EXEC, O_EXEC); } Modified: projects/fuse2/tests/sys/fs/fusefs/opendir.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/opendir.cc Mon Apr 1 16:15:29 2019 (r345767) +++ projects/fuse2/tests/sys/fs/fusefs/opendir.cc Mon Apr 1 16:36:02 2019 (r345768) @@ -44,6 +44,29 @@ void expect_lookup(const char *relpath, uint64_t ino) { FuseTest::expect_lookup(relpath, ino, S_IFDIR | 0755, 0, 1); } + +void expect_opendir(uint64_t ino, uint32_t flags, ProcessMockerT r) +{ + /* opendir(3) calls fstatfs */ + EXPECT_CALL(*m_mock, process( + ResultOf([](auto in) { + return (in->header.opcode == FUSE_STATFS); + }, Eq(true)), + _) + ).WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto out) { + SET_OUT_HEADER_LEN(out, statfs); + }))); + + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in->header.opcode == FUSE_OPENDIR && + in->header.nodeid == ino && + in->body.opendir.flags == flags); + }, Eq(true)), + _) + ).WillOnce(Invoke(r)); +} + }; @@ -59,14 +82,8 @@ TEST_F(Opendir, enoent) uint64_t ino = 42; expect_lookup(RELPATH, ino); + expect_opendir(ino, O_RDONLY, ReturnErrno(ENOENT)); - EXPECT_CALL(*m_mock, process( - ResultOf([=](auto in) { - return (in->header.opcode == FUSE_OPENDIR && - in->header.nodeid == ino); - }, Eq(true)), - _) - ).WillOnce(Invoke(ReturnErrno(ENOENT))); EXPECT_NE(0, open(FULLPATH, O_DIRECTORY)); EXPECT_EQ(ENOENT, errno); } @@ -82,15 +99,8 @@ TEST_F(Opendir, eperm) uint64_t ino = 42; expect_lookup(RELPATH, ino); + expect_opendir(ino, O_RDONLY, ReturnErrno(EPERM)); - EXPECT_CALL(*m_mock, process( - ResultOf([=](auto in) { - return (in->header.opcode == FUSE_OPENDIR && - in->header.nodeid == ino); - }, Eq(true)), - _) - ).WillOnce(Invoke(ReturnErrno(EPERM))); - EXPECT_NE(0, open(FULLPATH, O_DIRECTORY)); EXPECT_EQ(EPERM, errno); } @@ -102,45 +112,43 @@ TEST_F(Opendir, open) uint64_t ino = 42; expect_lookup(RELPATH, ino); - - EXPECT_CALL(*m_mock, process( - ResultOf([=](auto in) { - return (in->header.opcode == FUSE_OPENDIR && - in->header.nodeid == ino); - }, Eq(true)), - _) - ).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) { + expect_opendir(ino, O_RDONLY, + ReturnImmediate([=](auto in __unused, auto out) { SET_OUT_HEADER_LEN(out, open); - }))); + })); EXPECT_LE(0, open(FULLPATH, O_DIRECTORY)) << strerror(errno); } -TEST_F(Opendir, opendir) +/* Directories can be opened O_EXEC for stuff like fchdir(2) */ +TEST_F(Opendir, open_exec) { const char FULLPATH[] = "mountpoint/some_dir"; const char RELPATH[] = "some_dir"; uint64_t ino = 42; + int fd; expect_lookup(RELPATH, ino); - EXPECT_CALL(*m_mock, process( - ResultOf([](auto in) { - return (in->header.opcode == FUSE_STATFS); - }, Eq(true)), - _) - ).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) { - SET_OUT_HEADER_LEN(out, statfs); - }))); + expect_opendir(ino, O_EXEC, + ReturnImmediate([=](auto in __unused, auto out) { + SET_OUT_HEADER_LEN(out, open); + })); - EXPECT_CALL(*m_mock, process( - ResultOf([=](auto in) { - return (in->header.opcode == FUSE_OPENDIR && - in->header.nodeid == ino); - }, Eq(true)), - _) - ).WillOnce(Invoke(ReturnImmediate([=](auto in __unused, auto out) { + fd = open(FULLPATH, O_EXEC | O_DIRECTORY); + ASSERT_LE(0, fd) << strerror(errno); +} + +TEST_F(Opendir, opendir) +{ + const char FULLPATH[] = "mountpoint/some_dir"; + const char RELPATH[] = "some_dir"; + uint64_t ino = 42; + + expect_lookup(RELPATH, ino); + expect_opendir(ino, O_RDONLY, + ReturnImmediate([=](auto in __unused, auto out) { SET_OUT_HEADER_LEN(out, open); - }))); + })); errno = 0; EXPECT_NE(NULL, opendir(FULLPATH)) << strerror(errno); Modified: projects/fuse2/tests/sys/fs/fusefs/readdir.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/readdir.cc Mon Apr 1 16:15:29 2019 (r345767) +++ projects/fuse2/tests/sys/fs/fusefs/readdir.cc Mon Apr 1 16:36:02 2019 (r345768) @@ -52,6 +52,7 @@ void expect_readdir(uint64_t ino, uint64_t off, vector ResultOf([=](auto in) { return (in->header.opcode == FUSE_READDIR && in->header.nodeid == ino && + in->body.readdir.fh == FH && in->body.readdir.offset == off); }, Eq(true)), _) Modified: projects/fuse2/tests/sys/fs/fusefs/releasedir.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/releasedir.cc Mon Apr 1 16:15:29 2019 (r345767) +++ projects/fuse2/tests/sys/fs/fusefs/releasedir.cc Mon Apr 1 16:36:02 2019 (r345768) @@ -30,6 +30,7 @@ extern "C" { #include +#include } #include "mockfs.hh" @@ -106,4 +107,22 @@ TEST_F(ReleaseDir, ok) ASSERT_NE(NULL, dir) << strerror(errno); ASSERT_EQ(0, closedir(dir)) << strerror(errno); +} + +/* Directories opened O_EXEC should be properly released, too */ +TEST_F(ReleaseDir, o_exec) +{ + const char FULLPATH[] = "mountpoint/some_dir"; + const char RELPATH[] = "some_dir"; + uint64_t ino = 42; + int fd; + + expect_lookup(RELPATH, ino); + expect_opendir(ino); + expect_releasedir(ino, ReturnErrno(0)); + + fd = open(FULLPATH, O_EXEC | O_DIRECTORY); + EXPECT_LE(0, fd) << strerror(errno); + + ASSERT_EQ(0, close(fd)) << strerror(errno); } Modified: projects/fuse2/tests/sys/fs/fusefs/utils.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/utils.cc Mon Apr 1 16:15:29 2019 (r345767) +++ projects/fuse2/tests/sys/fs/fusefs/utils.cc Mon Apr 1 16:36:02 2019 (r345768) @@ -166,6 +166,7 @@ void FuseTest::expect_open(uint64_t ino, uint32_t flag void FuseTest::expect_opendir(uint64_t ino) { + /* opendir(3) calls fstatfs */ EXPECT_CALL(*m_mock, process( ResultOf([](auto in) { return (in->header.opcode == FUSE_STATFS); From owner-svn-src-projects@freebsd.org Mon Apr 1 18:09:29 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A7B2E156B169 for ; Mon, 1 Apr 2019 18:09:29 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5A12B82A0B; Mon, 1 Apr 2019 18:09:29 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 353D81A0EA; Mon, 1 Apr 2019 18:09:29 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x31I9T2v062972; Mon, 1 Apr 2019 18:09:29 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31I9RsI062962; Mon, 1 Apr 2019 18:09:27 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904011809.x31I9RsI062962@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Mon, 1 Apr 2019 18:09:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345771 - in projects/capsicum-test: contrib/bsnmp/snmpd contrib/googletest/googletest/test lib/libbe sbin/bectl/tests sys/arm/broadcom/bcm2835 sys/dev/md sys/dev/usb/wlan tests/sys/audit X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: in projects/capsicum-test: contrib/bsnmp/snmpd contrib/googletest/googletest/test lib/libbe sbin/bectl/tests sys/arm/broadcom/bcm2835 sys/dev/md sys/dev/usb/wlan tests/sys/audit X-SVN-Commit-Revision: 345771 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5A12B82A0B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.972,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 18:09:30 -0000 Author: ngie Date: Mon Apr 1 18:09:26 2019 New Revision: 345771 URL: https://svnweb.freebsd.org/changeset/base/345771 Log: MFhead@r345770 Replaced: projects/capsicum-test/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc - copied unchanged from r345770, head/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc Modified: projects/capsicum-test/contrib/bsnmp/snmpd/trap.c projects/capsicum-test/lib/libbe/be.c projects/capsicum-test/sbin/bectl/tests/bectl_test.sh projects/capsicum-test/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c projects/capsicum-test/sys/dev/md/md.c projects/capsicum-test/sys/dev/usb/wlan/if_run.c projects/capsicum-test/sys/dev/usb/wlan/if_uath.c projects/capsicum-test/sys/dev/usb/wlan/if_urtw.c projects/capsicum-test/tests/sys/audit/Makefile projects/capsicum-test/tests/sys/audit/process-control.c Directory Properties: projects/capsicum-test/ (props changed) Modified: projects/capsicum-test/contrib/bsnmp/snmpd/trap.c ============================================================================== --- projects/capsicum-test/contrib/bsnmp/snmpd/trap.c Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/contrib/bsnmp/snmpd/trap.c Mon Apr 1 18:09:26 2019 (r345771) @@ -726,8 +726,7 @@ target_activate_address(struct target_address *addrs) sa.sin_addr.s_addr = htonl((addrs->address[0] << 24) | (addrs->address[1] << 16) | (addrs->address[2] << 8) | (addrs->address[3] << 0)); - sa.sin_port = htons(addrs->address[4]) << 8 | - htons(addrs->address[5]) << 0; + sa.sin_port = htons(addrs->address[4] << 8 | addrs->address[5]); if (connect(addrs->socket, (struct sockaddr *)&sa, sa.sin_len) == -1) { syslog(LOG_ERR, "connect(%s,%u): %m", Copied: projects/capsicum-test/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc (from r345770, head/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/capsicum-test/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc Mon Apr 1 18:09:26 2019 (r345771, copy of r345770, head/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc) @@ -0,0 +1,60 @@ +// Copyright 2019, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// This test verifies that skipping in the environment results in the +// testcases being skipped. +// +// This is a reproduction case for +// https://github.com/google/googletest/issues/2189 . + +#include +#include + +class SetupEnvironment : public testing::Environment { +public: + void SetUp() override { + GTEST_SKIP() << "Skipping the entire environment"; + } +}; + +TEST(Test, AlwaysPasses) { + EXPECT_EQ(true, true); +} + +TEST(Test, AlwaysFails) { + EXPECT_EQ(true, false); +} + +int main(int argc, char **argv) { + testing::InitGoogleTest(&argc, argv); + + testing::AddGlobalTestEnvironment(new SetupEnvironment()); + + return (RUN_ALL_TESTS()); +} Modified: projects/capsicum-test/lib/libbe/be.c ============================================================================== --- projects/capsicum-test/lib/libbe/be.c Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/lib/libbe/be.c Mon Apr 1 18:09:26 2019 (r345771) @@ -265,6 +265,16 @@ be_destroy(libbe_handle_t *lbh, const char *name, int zfs_prop_get(fs, ZFS_PROP_ORIGIN, origin, sizeof(origin), NULL, NULL, 0, 1) != 0) return (set_error(lbh, BE_ERR_NOORIGIN)); + + /* Don't destroy a mounted dataset unless force is specified */ + if ((mounted = zfs_is_mounted(fs, NULL)) != 0) { + if (force) { + zfs_unmount(fs, NULL, 0); + } else { + free(bdd.snapname); + return (set_error(lbh, BE_ERR_DESTROYMNT)); + } + } } else { if (!zfs_dataset_exists(lbh->lzh, path, ZFS_TYPE_SNAPSHOT)) return (set_error(lbh, BE_ERR_NOENT)); @@ -277,16 +287,6 @@ be_destroy(libbe_handle_t *lbh, const char *name, int if (fs == NULL) { free(bdd.snapname); return (set_error(lbh, BE_ERR_ZFSOPEN)); - } - } - - /* Check if mounted, unmount if force is specified */ - if ((mounted = zfs_is_mounted(fs, NULL)) != 0) { - if (force) { - zfs_unmount(fs, NULL, 0); - } else { - free(bdd.snapname); - return (set_error(lbh, BE_ERR_DESTROYMNT)); } } Modified: projects/capsicum-test/sbin/bectl/tests/bectl_test.sh ============================================================================== --- projects/capsicum-test/sbin/bectl/tests/bectl_test.sh Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/sbin/bectl/tests/bectl_test.sh Mon Apr 1 18:09:26 2019 (r345771) @@ -123,12 +123,21 @@ bectl_destroy_body() zpool=$(make_zpool_name) disk=${cwd}/disk.img mount=${cwd}/mnt + root=${mount}/root bectl_create_setup ${zpool} ${disk} ${mount} atf_check bectl -r ${zpool}/ROOT create -e default default2 atf_check -o not-empty zfs get mountpoint ${zpool}/ROOT/default2 atf_check -e ignore bectl -r ${zpool}/ROOT destroy default2 atf_check -e not-empty -s not-exit:0 zfs get mountpoint ${zpool}/ROOT/default2 + + # Test origin snapshot deletion when the snapshot to be destroyed + # belongs to a mounted dataset, see PR 236043. + atf_check mkdir -p ${root} + atf_check -o not-empty bectl -r ${zpool}/ROOT mount default ${root} + atf_check bectl -r ${zpool}/ROOT create -e default default3 + atf_check bectl -r ${zpool}/ROOT destroy -o default3 + atf_check bectl -r ${zpool}/ROOT unmount default } bectl_destroy_cleanup() { Modified: projects/capsicum-test/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c ============================================================================== --- projects/capsicum-test/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Mon Apr 1 18:09:26 2019 (r345771) @@ -66,8 +66,17 @@ __FBSDID("$FreeBSD$"); #define NUM_DMA_SEGS 2 #ifdef DEBUG -#define dprintf(fmt, args...) do { printf("%s(): ", __func__); \ - printf(fmt,##args); } while (0) +static int bcm2835_sdhci_debug = 0; + +TUNABLE_INT("hw.bcm2835.sdhci.debug", &bcm2835_sdhci_debug); +SYSCTL_INT(_hw_sdhci, OID_AUTO, bcm2835_sdhci_debug, CTLFLAG_RWTUN, + &bcm2835_sdhci_debug, 0, "bcm2835 SDHCI debug level"); + +#define dprintf(fmt, args...) \ + do { \ + if (bcm2835_sdhci_debug) \ + printf("%s: " fmt, __func__, ##args); \ + } while (0) #else #define dprintf(fmt, args...) #endif Modified: projects/capsicum-test/sys/dev/md/md.c ============================================================================== --- projects/capsicum-test/sys/dev/md/md.c Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/sys/dev/md/md.c Mon Apr 1 18:09:26 2019 (r345771) @@ -110,6 +110,7 @@ #define MD_SHUTDOWN 0x10000 /* Tell worker thread to terminate. */ #define MD_EXITING 0x20000 /* Worker thread is exiting. */ +#define MD_PROVIDERGONE 0x40000 /* Safe to free the softc */ #ifndef MD_NSECT #define MD_NSECT (10000 * 2) @@ -199,6 +200,7 @@ static g_start_t g_md_start; static g_access_t g_md_access; static void g_md_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g_consumer *cp __unused, struct g_provider *pp); +static g_provgone_t g_md_providergone; static struct cdev *status_dev = NULL; static struct sx md_sx; @@ -220,6 +222,7 @@ struct g_class g_md_class = { .start = g_md_start, .access = g_md_access, .dumpconf = g_md_dumpconf, + .providergone = g_md_providergone, }; DECLARE_GEOM_CLASS(g_md_class, g_md); @@ -481,8 +484,8 @@ g_md_start(struct bio *bp) } mtx_lock(&sc->queue_mtx); bioq_disksort(&sc->bio_queue, bp); - mtx_unlock(&sc->queue_mtx); wakeup(sc); + mtx_unlock(&sc->queue_mtx); } #define MD_MALLOC_MOVE_ZERO 1 @@ -1496,17 +1499,30 @@ bad: return (error); } +static void +g_md_providergone(struct g_provider *pp) +{ + struct md_s *sc = pp->geom->softc; + + mtx_lock(&sc->queue_mtx); + sc->flags |= MD_PROVIDERGONE; + wakeup(&sc->flags); + mtx_unlock(&sc->queue_mtx); +} + static int mddestroy(struct md_s *sc, struct thread *td) { if (sc->gp) { - sc->gp->softc = NULL; g_topology_lock(); g_wither_geom(sc->gp, ENXIO); g_topology_unlock(); - sc->gp = NULL; - sc->pp = NULL; + + mtx_lock(&sc->queue_mtx); + while (!(sc->flags & MD_PROVIDERGONE)) + msleep(&sc->flags, &sc->queue_mtx, PRIBIO, "mddestroy", 0); + mtx_unlock(&sc->queue_mtx); } if (sc->devstat) { devstat_remove_entry(sc->devstat); Modified: projects/capsicum-test/sys/dev/usb/wlan/if_run.c ============================================================================== --- projects/capsicum-test/sys/dev/usb/wlan/if_run.c Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/sys/dev/usb/wlan/if_run.c Mon Apr 1 18:09:26 2019 (r345771) @@ -2851,10 +2851,6 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uin } if (flags & RT2860_RX_L2PAD) { - /* - * XXX OpenBSD removes padding between header - * and payload here... - */ RUN_DPRINTF(sc, RUN_DEBUG_RECV, "received RT2860_RX_L2PAD frame\n"); len += 2; @@ -2865,8 +2861,8 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uin wh = mtod(m, struct ieee80211_frame *); - /* XXX wrong for monitor mode */ - if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { + if ((wh->i_fc[1] & IEEE80211_FC1_PROTECTED) != 0 && + (flags & RT2860_RX_DEC) != 0) { wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED; m->m_flags |= M_WEP; } @@ -2896,6 +2892,8 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uin uint16_t phy; tap->wr_flags = 0; + if (flags & RT2860_RX_L2PAD) + tap->wr_flags |= IEEE80211_RADIOTAP_F_DATAPAD; tap->wr_antsignal = rssi; tap->wr_antenna = ant; tap->wr_dbm_antsignal = run_rssi2dbm(sc, rssi, ant); @@ -3162,14 +3160,23 @@ tr_setup: vap = data->ni->ni_vap; if (ieee80211_radiotap_active_vap(vap)) { + const struct ieee80211_frame *wh; struct run_tx_radiotap_header *tap = &sc->sc_txtap; struct rt2860_txwi *txwi = (struct rt2860_txwi *)(&data->desc + sizeof(struct rt2870_txd)); + int has_l2pad; + + wh = mtod(m, struct ieee80211_frame *); + has_l2pad = IEEE80211_HAS_ADDR4(wh) != + IEEE80211_QOS_HAS_SEQ(wh); + tap->wt_flags = 0; tap->wt_rate = rt2860_rates[data->ridx].rate; tap->wt_hwqueue = index; if (le16toh(txwi->phy) & RT2860_PHY_SHPRE) tap->wt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE; + if (has_l2pad) + tap->wt_flags |= IEEE80211_RADIOTAP_F_DATAPAD; ieee80211_radiotap_tx(vap, m); } Modified: projects/capsicum-test/sys/dev/usb/wlan/if_uath.c ============================================================================== --- projects/capsicum-test/sys/dev/usb/wlan/if_uath.c Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/sys/dev/usb/wlan/if_uath.c Mon Apr 1 18:09:26 2019 (r345771) @@ -1276,8 +1276,8 @@ uath_watchdog(void *arg) if (sc->sc_tx_timer > 0) { if (--sc->sc_tx_timer == 0) { device_printf(sc->sc_dev, "device timeout\n"); - /*uath_init(sc); XXX needs a process context! */ counter_u64_add(ic->ic_oerrors, 1); + ieee80211_restart_all(ic); return; } callout_reset(&sc->watchdog_ch, hz, uath_watchdog, sc); Modified: projects/capsicum-test/sys/dev/usb/wlan/if_urtw.c ============================================================================== --- projects/capsicum-test/sys/dev/usb/wlan/if_urtw.c Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/sys/dev/usb/wlan/if_urtw.c Mon Apr 1 18:09:26 2019 (r345771) @@ -1891,11 +1891,13 @@ static void urtw_watchdog(void *arg) { struct urtw_softc *sc = arg; + struct ieee80211com *ic = &sc->sc_ic; if (sc->sc_txtimer > 0) { if (--sc->sc_txtimer == 0) { device_printf(sc->sc_dev, "device timeout\n"); - counter_u64_add(sc->sc_ic.ic_oerrors, 1); + counter_u64_add(ic->ic_oerrors, 1); + ieee80211_restart_all(ic); return; } callout_reset(&sc->sc_watchdog_ch, hz, urtw_watchdog, sc); Modified: projects/capsicum-test/tests/sys/audit/Makefile ============================================================================== --- projects/capsicum-test/tests/sys/audit/Makefile Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/tests/sys/audit/Makefile Mon Apr 1 18:09:26 2019 (r345771) @@ -55,4 +55,6 @@ WARNS?= 6 LDFLAGS+= -lbsm -lutil +CFLAGS.process-control.c+= -I${SRCTOP}/tests + .include Modified: projects/capsicum-test/tests/sys/audit/process-control.c ============================================================================== --- projects/capsicum-test/tests/sys/audit/process-control.c Mon Apr 1 18:07:48 2019 (r345770) +++ projects/capsicum-test/tests/sys/audit/process-control.c Mon Apr 1 18:09:26 2019 (r345771) @@ -48,6 +48,8 @@ #include "utils.h" +#include "freebsd_test_suite/macros.h" + static pid_t pid; static int filedesc, status; static struct pollfd fds[1]; @@ -1512,15 +1514,8 @@ ATF_TC_HEAD(cap_enter_success, tc) ATF_TC_BODY(cap_enter_success, tc) { - int capinfo; - size_t len = sizeof(capinfo); - const char *capname = "kern.features.security_capability_mode"; - ATF_REQUIRE_EQ(0, sysctlbyname(capname, &capinfo, &len, NULL, 0)); + ATF_REQUIRE_FEATURE("security_capability_mode"); - /* Without CAPABILITY_MODE enabled, cap_enter() returns ENOSYS */ - if (!capinfo) - atf_tc_skip("Capsicum is not enabled in the system"); - FILE *pipefd = setup(fds, auclass); ATF_REQUIRE((pid = fork()) != -1); if (pid) { @@ -1550,14 +1545,9 @@ ATF_TC_HEAD(cap_getmode_success, tc) ATF_TC_BODY(cap_getmode_success, tc) { - int capinfo, modep; - size_t len = sizeof(capinfo); - const char *capname = "kern.features.security_capability_mode"; - ATF_REQUIRE_EQ(0, sysctlbyname(capname, &capinfo, &len, NULL, 0)); + int modep; - /* Without CAPABILITY_MODE enabled, cap_getmode() returns ENOSYS */ - if (!capinfo) - atf_tc_skip("Capsicum is not enabled in the system"); + ATF_REQUIRE_FEATURE("security_capability_mode"); pid = getpid(); snprintf(pcregex, sizeof(pcregex), "cap_getmode.*%d.*success", pid); From owner-svn-src-projects@freebsd.org Mon Apr 1 18:17:49 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2174C156B89D for ; Mon, 1 Apr 2019 18:17:49 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BC8CC831D4; Mon, 1 Apr 2019 18:17:48 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 999721A299; Mon, 1 Apr 2019 18:17:48 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x31IHmeA068459; Mon, 1 Apr 2019 18:17:48 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31IHm8B068458; Mon, 1 Apr 2019 18:17:48 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904011817.x31IHm8B068458@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Mon, 1 Apr 2019 18:17:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345772 - projects/capsicum-test/contrib/capsicum-test X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/capsicum-test/contrib/capsicum-test X-SVN-Commit-Revision: 345772 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: BC8CC831D4 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.969,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 18:17:49 -0000 Author: ngie Date: Mon Apr 1 18:17:48 2019 New Revision: 345772 URL: https://svnweb.freebsd.org/changeset/base/345772 Log: Fix build for Linux In order for the test to build/run, I needed to add an `Execveat` subclass of `Execve`, then use `TEST_F(..)` for the test in order to leverage `exec_prog_`. This wasn't caught previously, because FreeBSD lacks an execveat(2) call, unlike Linux. Reported by: David Drysdale Pull Request: https://github.com/google/capsicum-test/pull/41 (WIP) Modified: projects/capsicum-test/contrib/capsicum-test/fexecve.cc Modified: projects/capsicum-test/contrib/capsicum-test/fexecve.cc ============================================================================== --- projects/capsicum-test/contrib/capsicum-test/fexecve.cc Mon Apr 1 18:09:26 2019 (r345771) +++ projects/capsicum-test/contrib/capsicum-test/fexecve.cc Mon Apr 1 18:17:48 2019 (r345772) @@ -167,7 +167,12 @@ FORK_TEST_F(FexecveWithScript, CapModeScriptFail) { } #ifdef HAVE_EXECVEAT -TEST(Execveat, NoUpwardTraversal) { +class Execveat : public Execve { + public: + Execveat() : Execve() {} +}; + +TEST_F(Execveat, NoUpwardTraversal) { char *abspath = realpath(exec_prog_, NULL); char cwd[1024]; getcwd(cwd, sizeof(cwd)); From owner-svn-src-projects@freebsd.org Mon Apr 1 18:25:15 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BEE54156BCD9 for ; Mon, 1 Apr 2019 18:25:15 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 64DF08375E; Mon, 1 Apr 2019 18:25:15 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3A9F71A467; Mon, 1 Apr 2019 18:25:15 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x31IPFWR073385; Mon, 1 Apr 2019 18:25:15 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31IPFYV073384; Mon, 1 Apr 2019 18:25:15 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904011825.x31IPFYV073384@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Mon, 1 Apr 2019 18:25:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345773 - projects/capsicum-test/contrib/capsicum-test X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/capsicum-test/contrib/capsicum-test X-SVN-Commit-Revision: 345773 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 64DF08375E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.969,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 18:25:16 -0000 Author: ngie Date: Mon Apr 1 18:25:14 2019 New Revision: 345773 URL: https://svnweb.freebsd.org/changeset/base/345773 Log: Import review changes 1. Collapse the declaration/assignment for `trap_enotcap_enabled_len` to reduce complexity. 2. Move the `GTEST_SKIP()` backwards compatible definition out into the global space. 3. Sort conditional platform #includes with __FreeBSD__ before __linux__. Requested by: David Drysdale [1,2], emaste [3] Pull Request: https://github.com/google/capsicum-test/pull/42 Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc ============================================================================== --- projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Mon Apr 1 18:17:48 2019 (r345772) +++ projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Mon Apr 1 18:25:14 2019 (r345773) @@ -1,9 +1,9 @@ #include -#if defined(__FreeBSD__) -#include -#elif defined(__linux__) +#ifdef __linux__ #include #include +#elif defined(__FreeBSD__) +#include #endif #include #include @@ -16,6 +16,11 @@ #include "gtest/gtest.h" #include "capsicum-test.h" +// For versions of googletest that lack GTEST_SKIP. +#ifndef GTEST_SKIP +#define GTEST_SKIP GTEST_FAIL +#endif + std::string tmpdir; class SetupEnvironment : public ::testing::Environment @@ -33,19 +38,11 @@ class SetupEnvironment : public ::testing::Environment std::cerr << tmpdir << std::endl; } void CheckCapsicumSupport() { - // For versions of googletest that lack GTEST_SKIP. -#ifndef GTEST_SKIP -#define GTEST_SKIP GTEST_FAIL -#define GTEST_SKIP_defined -#endif - #ifdef __FreeBSD__ - size_t trap_enotcap_enabled_len; int rc; bool trap_enotcap_enabled; + size_t trap_enotcap_enabled_len = sizeof(trap_enotcap_enabled); - trap_enotcap_enabled_len = sizeof(trap_enotcap_enabled); - if (feature_present("security_capabilities") == 0) { GTEST_SKIP() << "Skipping tests because capsicum support is not " << "enabled in the kernel."; @@ -61,10 +58,6 @@ class SetupEnvironment : public ::testing::Environment << "Skipping tests to avoid non-determinism with results"; } #endif /* FreeBSD */ - -#ifdef GTEST_SKIP_defined -#undef GTEST_SKIP -#endif } void CreateTemporaryRoot() { char *tmpdir_name = tempnam(nullptr, "cptst"); From owner-svn-src-projects@freebsd.org Mon Apr 1 18:35:28 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2047D156BFBC for ; Mon, 1 Apr 2019 18:35:28 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A686583C7F; Mon, 1 Apr 2019 18:35:27 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 82D8E1A63C; Mon, 1 Apr 2019 18:35:27 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x31IZRx8078690; Mon, 1 Apr 2019 18:35:27 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31IZRvg078689; Mon, 1 Apr 2019 18:35:27 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904011835.x31IZRvg078689@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Mon, 1 Apr 2019 18:35:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345774 - projects/capsicum-test/contrib/capsicum-test X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/capsicum-test/contrib/capsicum-test X-SVN-Commit-Revision: 345774 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: A686583C7F X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.969,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 18:35:28 -0000 Author: ngie Date: Mon Apr 1 18:35:27 2019 New Revision: 345774 URL: https://svnweb.freebsd.org/changeset/base/345774 Log: Add a missing trailing period with the skip message for the `kern.trap_enotcap` check Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc ============================================================================== --- projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Mon Apr 1 18:25:14 2019 (r345773) +++ projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Mon Apr 1 18:35:27 2019 (r345774) @@ -55,7 +55,7 @@ class SetupEnvironment : public ::testing::Environment } if (trap_enotcap_enabled) { GTEST_SKIP() << "Sysctl " << oid << " enabled. " - << "Skipping tests to avoid non-determinism with results"; + << "Skipping tests to avoid non-determinism with results."; } #endif /* FreeBSD */ } From owner-svn-src-projects@freebsd.org Mon Apr 1 20:02:27 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C0786156D8B6 for ; Mon, 1 Apr 2019 20:02:27 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5ECFC86B82; Mon, 1 Apr 2019 20:02:27 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 360281B4CE; Mon, 1 Apr 2019 20:02:27 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x31K2RWV027206; Mon, 1 Apr 2019 20:02:27 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31K2RM4027205; Mon, 1 Apr 2019 20:02:27 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904012002.x31K2RM4027205@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Mon, 1 Apr 2019 20:02:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345779 - projects/capsicum-test/contrib/capsicum-test X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/capsicum-test/contrib/capsicum-test X-SVN-Commit-Revision: 345779 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5ECFC86B82 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.965,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 20:02:27 -0000 Author: ngie Date: Mon Apr 1 20:02:26 2019 New Revision: 345779 URL: https://svnweb.freebsd.org/changeset/base/345779 Log: Clarify why `kern.trap_enotcap` being set should cause the tests to be skipped. Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc ============================================================================== --- projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Mon Apr 1 19:19:51 2019 (r345778) +++ projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Mon Apr 1 20:02:26 2019 (r345779) @@ -47,6 +47,8 @@ class SetupEnvironment : public ::testing::Environment GTEST_SKIP() << "Skipping tests because capsicum support is not " << "enabled in the kernel."; } + // If this OID is enabled, it will send SIGTRAP to the process when + // `ENOTCAPABLE` is returned. const char *oid = "kern.trap_enotcap"; rc = sysctlbyname(oid, &trap_enotcap_enabled, &trap_enotcap_enabled_len, nullptr, 0); @@ -54,8 +56,9 @@ class SetupEnvironment : public ::testing::Environment GTEST_FAIL() << "sysctlbyname failed: " << strerror(errno); } if (trap_enotcap_enabled) { - GTEST_SKIP() << "Sysctl " << oid << " enabled. " - << "Skipping tests to avoid non-determinism with results."; + GTEST_SKIP() << "Debug sysctl " << oid << " enabled. " + << "Skipping tests because it's enablement invalidates the " + << "test results."; } #endif /* FreeBSD */ } From owner-svn-src-projects@freebsd.org Mon Apr 1 20:03:54 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D3623156D93B for ; Mon, 1 Apr 2019 20:03:54 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 70B1086CEF; Mon, 1 Apr 2019 20:03:54 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4B4E51B5F7; Mon, 1 Apr 2019 20:03:54 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x31K3sbf027302; Mon, 1 Apr 2019 20:03:54 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31K3s6K027301; Mon, 1 Apr 2019 20:03:54 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904012003.x31K3s6K027301@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Mon, 1 Apr 2019 20:03:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345780 - projects/capsicum-test/contrib/capsicum-test X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/capsicum-test/contrib/capsicum-test X-SVN-Commit-Revision: 345780 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 70B1086CEF X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.97)[-0.965,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 20:03:55 -0000 Author: ngie Date: Mon Apr 1 20:03:53 2019 New Revision: 345780 URL: https://svnweb.freebsd.org/changeset/base/345780 Log: Fix grammar nit in skip message Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc ============================================================================== --- projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Mon Apr 1 20:02:26 2019 (r345779) +++ projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Mon Apr 1 20:03:53 2019 (r345780) @@ -56,7 +56,7 @@ class SetupEnvironment : public ::testing::Environment GTEST_FAIL() << "sysctlbyname failed: " << strerror(errno); } if (trap_enotcap_enabled) { - GTEST_SKIP() << "Debug sysctl " << oid << " enabled. " + GTEST_SKIP() << "Debug sysctl, " << oid << ", enabled. " << "Skipping tests because it's enablement invalidates the " << "test results."; } From owner-svn-src-projects@freebsd.org Mon Apr 1 20:42:18 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3E4DF156EC53 for ; Mon, 1 Apr 2019 20:42:18 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D86FE89100; Mon, 1 Apr 2019 20:42:17 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B50C31BD0F; Mon, 1 Apr 2019 20:42:17 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x31KgHcr050042; Mon, 1 Apr 2019 20:42:17 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31KgFqO050033; Mon, 1 Apr 2019 20:42:15 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904012042.x31KgFqO050033@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Mon, 1 Apr 2019 20:42:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345781 - in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Commit-Revision: 345781 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D86FE89100 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.978,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 20:42:18 -0000 Author: asomers Date: Mon Apr 1 20:42:15 2019 New Revision: 345781 URL: https://svnweb.freebsd.org/changeset/base/345781 Log: fusefs: send FUSE_OPEN for every open(2) with unique credentials By default, FUSE performs authorization in the server. That means that it's insecure for the client to reuse FUSE file handles between different users, groups, or processes. Linux handles this problem by creating a different FUSE file handle for every file descriptor. FreeBSD can't, due to differences in our VFS design. This commit adds credential information to each fuse_filehandle. During open(2), fusefs will now only reuse a file handle if it matches the exact same access mode, pid, uid, and gid of the calling process. PR: 236844 Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/sys/fs/fuse/fuse_file.c projects/fuse2/sys/fs/fuse/fuse_file.h projects/fuse2/sys/fs/fuse/fuse_io.c projects/fuse2/sys/fs/fuse/fuse_io.h projects/fuse2/sys/fs/fuse/fuse_node.c projects/fuse2/sys/fs/fuse/fuse_node.h projects/fuse2/sys/fs/fuse/fuse_vnops.c projects/fuse2/tests/sys/fs/fusefs/allow_other.cc projects/fuse2/tests/sys/fs/fusefs/open.cc Modified: projects/fuse2/sys/fs/fuse/fuse_file.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_file.c Mon Apr 1 20:03:53 2019 (r345780) +++ projects/fuse2/sys/fs/fuse/fuse_file.c Mon Apr 1 20:42:15 2019 (r345781) @@ -109,11 +109,6 @@ fuse_filehandle_open(struct vnode *vp, fufh_type_t fuf int oflags = 0; int op = FUSE_OPEN; - if (fuse_filehandle_valid(vp, fufh_type)) { - panic("FUSE: filehandle_open called despite valid fufh (type=%d)", - fufh_type); - /* NOTREACHED */ - } /* * Note that this means we are effectively FILTERING OUT open() flags. */ @@ -140,7 +135,8 @@ fuse_filehandle_open(struct vnode *vp, fufh_type_t fuf } foo = fdi.answ; - fuse_filehandle_init(vp, fufh_type, fufhp, foo->fh); + fuse_filehandle_init(vp, fufh_type, fufhp, td->td_proc->p_pid, cred, + foo->fh); fuse_vnode_open(vp, foo->open_flags, td); @@ -181,37 +177,66 @@ out: return err; } -int -fuse_filehandle_valid(struct vnode *vp, fufh_type_t fufh_type) -{ - return (0 == fuse_filehandle_get(vp, fufh_type, NULL)); -} - /* * Check for a valid file handle, first the type requested, but if that * isn't valid, try for FUFH_RDWR. - * Return the FUFH type that is valid or FUFH_INVALID if there are none. - * This is a variant of fuse_filehandle_valid() analogous to - * fuse_filehandle_getrw(). + * Return true if there is any file handle with the correct credentials and + * a fufh type that includes the provided one. + * A pid of 0 means "don't care" */ -fufh_type_t -fuse_filehandle_validrw(struct vnode *vp, fufh_type_t fufh_type) +bool +fuse_filehandle_validrw(struct vnode *vp, fufh_type_t fufh_type, + struct ucred *cred, pid_t pid) { - if (fuse_filehandle_get(vp, fufh_type, NULL) == 0) - return (fufh_type); - if (fuse_filehandle_get(vp, FUFH_RDWR, NULL) == 0) - return (FUFH_RDWR); - return (FUFH_INVALID); + struct fuse_vnode_data *fvdat = VTOFUD(vp); + struct fuse_filehandle *fufh; + + /* + * Unlike fuse_filehandle_get, we want to search for a filehandle with + * the exact cred, and no fallback + */ + LIST_FOREACH(fufh, &fvdat->handles, next) { + if (fufh->flags == fufh_type && + fufh->uid == cred->cr_uid && + fufh->gid == cred->cr_rgid && + (pid == 0 || fufh->pid == pid)) + return true; + } + + if (fufh_type == FUFH_EXEC) + return false; + + /* Fallback: find a RDWR list entry with the right cred */ + LIST_FOREACH(fufh, &fvdat->handles, next) { + if (fufh->flags == FUFH_RDWR && + fufh->uid == cred->cr_uid && + fufh->gid == cred->cr_rgid && + (pid == 0 || fufh->pid == pid)) + return true; + } + + return false; } int fuse_filehandle_get(struct vnode *vp, fufh_type_t fufh_type, - struct fuse_filehandle **fufhp) + struct fuse_filehandle **fufhp, struct ucred *cred, pid_t pid) { struct fuse_vnode_data *fvdat = VTOFUD(vp); struct fuse_filehandle *fufh; - /* TODO: Find a list entry with the same flags, pid, gid, and uid */ + if (cred == NULL) + goto fallback; + + LIST_FOREACH(fufh, &fvdat->handles, next) { + if (fufh->flags == fufh_type && + fufh->uid == cred->cr_uid && + fufh->gid == cred->cr_rgid && + (pid == 0 || fufh->pid == pid)) + goto found; + } + +fallback: /* Fallback: find a list entry with the right flags */ LIST_FOREACH(fufh, &fvdat->handles, next) { if (fufh->flags == fufh_type) @@ -220,6 +245,8 @@ fuse_filehandle_get(struct vnode *vp, fufh_type_t fufh if (fufh == NULL) return EBADF; + +found: if (fufhp != NULL) *fufhp = fufh; return 0; @@ -227,19 +254,20 @@ fuse_filehandle_get(struct vnode *vp, fufh_type_t fufh int fuse_filehandle_getrw(struct vnode *vp, fufh_type_t fufh_type, - struct fuse_filehandle **fufhp) + struct fuse_filehandle **fufhp, struct ucred *cred, pid_t pid) { int err; - err = fuse_filehandle_get(vp, fufh_type, fufhp); + err = fuse_filehandle_get(vp, fufh_type, fufhp, cred, pid); if (err) - err = fuse_filehandle_get(vp, FUFH_RDWR, fufhp); + err = fuse_filehandle_get(vp, FUFH_RDWR, fufhp, cred, pid); return err; } void fuse_filehandle_init(struct vnode *vp, fufh_type_t fufh_type, - struct fuse_filehandle **fufhp, uint64_t fh_id) + struct fuse_filehandle **fufhp, pid_t pid, struct ucred *cred, + uint64_t fh_id) { struct fuse_vnode_data *fvdat = VTOFUD(vp); struct fuse_filehandle *fufh; @@ -249,7 +277,10 @@ fuse_filehandle_init(struct vnode *vp, fufh_type_t fuf MPASS(fufh != NULL); fufh->fh_id = fh_id; fufh->flags = fufh_type; - /* TODO: initialize fufh credentials and open flags */ + fufh->gid = cred->cr_rgid; + fufh->uid = cred->cr_uid; + fufh->pid = pid; + /* TODO: initialize open flags */ if (!FUFH_IS_VALID(fufh)) { panic("FUSE: init: invalid filehandle id (type=%d)", fufh_type); } Modified: projects/fuse2/sys/fs/fuse/fuse_file.h ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_file.h Mon Apr 1 20:03:53 2019 (r345780) +++ projects/fuse2/sys/fs/fuse/fuse_file.h Mon Apr 1 20:42:15 2019 (r345781) @@ -78,6 +78,56 @@ typedef enum fufh_type { FUFH_EXEC = O_EXEC, } fufh_type_t; +/* + * FUSE File Handles + * + * The FUSE protocol says that a server may assign a unique 64-bit file handle + * every time that a file is opened. Effectively, that's once for each file + * descriptor. + * + * Unfortunately, the VFS doesn't help us here. VOPs don't have a + * struct file* argument. fileops do, but many syscalls bypass the fileops + * layer and go straight to a vnode. Some, like writing from cache, can't + * track a file handle even in theory. The entire concept of the file handle + * is a product of FUSE's Linux origins; Linux lacks vnodes and almost every + * file system operation takes a struct file* argument. + * + * Since FreeBSD's VFS is more file descriptor-agnostic, we must store FUSE + * filehandles in the vnode. One option would be to only store a single file + * handle and never open FUSE files concurrently. That's what NetBSD does. + * But that violates FUSE's security model. FUSE expects the server to do all + * authorization (except when mounted with -o default_permissions). In order + * to do that, the server needs us to send FUSE_OPEN every time somebody opens + * a new file descriptor. + * + * Another option would be to never open FUSE files concurrently, but send a + * FUSE_ACCESS prior to every open after the first. That would give the server + * the opportunity to authorize the access. Unfortunately, the FUSE protocol + * makes ACCESS optional. File systems that don't implement it are assumed to + * authorize everything. A survey of 32 fuse file systems showed that only 14 + * implemented access. Among the laggards were a few that really ought to be + * doing server-side authorization. + * + * So we do something hacky, similar to what OpenBSD, Illumos, and OSXFuse do. + * we store a list of file handles, one for each combination of vnode, uid, + * gid, pid, and access mode. When opening a file, we first check whether + * there's already a matching file handle. If so, we reuse it. If not, we + * send FUSE_OPEN and create a new file handle. That minimizes the number of + * open file handles while still allowing the server to authorize stuff. + * + * VOPs that need a file handle search through the list for a close match. + * They can't be guaranteed of finding an exact match because, for example, a + * process may have changed its UID since opening the file. Also, most VOPs + * don't know exactly what permission they need. Is O_RDWR required or is + * O_RDONLY good enough? So the file handle we end up using may not be exactly + * the one we're supposed to use with that file descriptor. But if the FUSE + * file system isn't too picky, it will work. (FWIW even Linux sometimes + * guesses the file handle, during writes from cache or most SETATTR + * operations). + * + * I suspect this mess is part of the reason why neither NFS nor 9P have an + * equivalent of FUSE file handles. + */ struct fuse_filehandle { LIST_ENTRY(fuse_filehandle) next; @@ -132,15 +182,18 @@ fuse_filehandle_xlate_to_oflags(fufh_type_t type) return oflags; } -int fuse_filehandle_valid(struct vnode *vp, fufh_type_t fufh_type); -fufh_type_t fuse_filehandle_validrw(struct vnode *vp, fufh_type_t fufh_type); +bool fuse_filehandle_validrw(struct vnode *vp, fufh_type_t fufh_type, + struct ucred *cred, pid_t pid); int fuse_filehandle_get(struct vnode *vp, fufh_type_t fufh_type, - struct fuse_filehandle **fufhp); + struct fuse_filehandle **fufhp, struct ucred *cred, + pid_t pid); int fuse_filehandle_getrw(struct vnode *vp, fufh_type_t fufh_type, - struct fuse_filehandle **fufhp); + struct fuse_filehandle **fufhp, struct ucred *cred, + pid_t pid); void fuse_filehandle_init(struct vnode *vp, fufh_type_t fufh_type, - struct fuse_filehandle **fufhp, uint64_t fh_id); + struct fuse_filehandle **fufhp, pid_t pid, + struct ucred *cred, uint64_t fh_id); int fuse_filehandle_open(struct vnode *vp, fufh_type_t fufh_type, struct fuse_filehandle **fufhp, struct thread *td, struct ucred *cred); Modified: projects/fuse2/sys/fs/fuse/fuse_io.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_io.c Mon Apr 1 20:03:53 2019 (r345780) +++ projects/fuse2/sys/fs/fuse/fuse_io.c Mon Apr 1 20:42:15 2019 (r345781) @@ -111,27 +111,28 @@ fuse_read_directbackend(struct vnode *vp, struct uio * struct ucred *cred, struct fuse_filehandle *fufh); static int fuse_read_biobackend(struct vnode *vp, struct uio *uio, - struct ucred *cred, struct fuse_filehandle *fufh); + struct ucred *cred, struct fuse_filehandle *fufh, pid_t pid); static int fuse_write_directbackend(struct vnode *vp, struct uio *uio, struct ucred *cred, struct fuse_filehandle *fufh, int ioflag); static int fuse_write_biobackend(struct vnode *vp, struct uio *uio, - struct ucred *cred, struct fuse_filehandle *fufh, int ioflag); + struct ucred *cred, struct fuse_filehandle *fufh, int ioflag, pid_t pid); SDT_PROBE_DEFINE5(fuse, , io, io_dispatch, "struct vnode*", "struct uio*", "int", "struct ucred*", "struct fuse_filehandle*"); int fuse_io_dispatch(struct vnode *vp, struct uio *uio, int ioflag, - struct ucred *cred) + struct ucred *cred, pid_t pid) { struct fuse_filehandle *fufh; int err, directio; + fufh_type_t fufh_type; MPASS(vp->v_type == VREG || vp->v_type == VDIR); - err = fuse_filehandle_getrw(vp, - (uio->uio_rw == UIO_READ) ? FUFH_RDONLY : FUFH_WRONLY, &fufh); + fufh_type = (uio->uio_rw == UIO_READ) ? FUFH_RDONLY : FUFH_WRONLY; + err = fuse_filehandle_getrw(vp, fufh_type, &fufh, cred, pid); if (err) { printf("FUSE: io dispatch: filehandles are closed\n"); return err; @@ -159,7 +160,7 @@ fuse_io_dispatch(struct vnode *vp, struct uio *uio, in } else { SDT_PROBE2(fuse, , io, trace, 1, "buffered read of vnode"); - err = fuse_read_biobackend(vp, uio, cred, fufh); + err = fuse_read_biobackend(vp, uio, cred, fufh, pid); } break; case UIO_WRITE: @@ -172,11 +173,13 @@ fuse_io_dispatch(struct vnode *vp, struct uio *uio, in if (directio || fuse_data_cache_mode == FUSE_CACHE_WT) { SDT_PROBE2(fuse, , io, trace, 1, "direct write of vnode"); - err = fuse_write_directbackend(vp, uio, cred, fufh, ioflag); + err = fuse_write_directbackend(vp, uio, cred, fufh, + ioflag); } else { SDT_PROBE2(fuse, , io, trace, 1, "buffered write of vnode"); - err = fuse_write_biobackend(vp, uio, cred, fufh, ioflag); + err = fuse_write_biobackend(vp, uio, cred, fufh, ioflag, + pid); } break; default: @@ -191,7 +194,7 @@ SDT_PROBE_DEFINE2(fuse, , io, read_bio_backend_feed, " SDT_PROBE_DEFINE3(fuse, , io, read_bio_backend_end, "int", "ssize_t", "int"); static int fuse_read_biobackend(struct vnode *vp, struct uio *uio, - struct ucred *cred, struct fuse_filehandle *fufh) + struct ucred *cred, struct fuse_filehandle *fufh, pid_t pid) { struct buf *bp; daddr_t lbn; @@ -405,7 +408,7 @@ SDT_PROBE_DEFINE2(fuse, , io, write_biobackend_append_ static int fuse_write_biobackend(struct vnode *vp, struct uio *uio, - struct ucred *cred, struct fuse_filehandle *fufh, int ioflag) + struct ucred *cred, struct fuse_filehandle *fufh, int ioflag, pid_t pid) { struct fuse_vnode_data *fvdat = VTOFUD(vp); struct buf *bp; @@ -625,7 +628,7 @@ again: } while (uio->uio_resid > 0 && n > 0); if (fuse_sync_resize && (fvdat->flag & FN_SIZECHANGE) != 0) - fuse_vnode_savesize(vp, cred); + fuse_vnode_savesize(vp, cred, pid); return (err); } @@ -640,14 +643,18 @@ fuse_io_strategy(struct vnode *vp, struct buf *bp) struct uio uio; struct iovec io; int error = 0; + fufh_type_t fufh_type; + /* We don't know the true pid when we're dealing with the cache */ + pid_t pid = 0; const int biosize = fuse_iosize(vp); MPASS(vp->v_type == VREG || vp->v_type == VDIR); MPASS(bp->b_iocmd == BIO_READ || bp->b_iocmd == BIO_WRITE); - error = fuse_filehandle_getrw(vp, - (bp->b_iocmd == BIO_READ) ? FUFH_RDONLY : FUFH_WRONLY, &fufh); + fufh_type = bp->b_iocmd == BIO_READ ? FUFH_RDONLY : FUFH_WRONLY; + cred = bp->b_iocmd == BIO_READ ? bp->b_rcred : bp->b_wcred; + error = fuse_filehandle_getrw(vp, fufh_type, &fufh, cred, pid); if (bp->b_iocmd == BIO_READ && error == EBADF) { /* * This may be a read-modify-write operation on a cached file @@ -655,7 +662,8 @@ fuse_io_strategy(struct vnode *vp, struct buf *bp) * * TODO: eliminate this hacky check once the FUFH table is gone */ - error = fuse_filehandle_get(vp, FUFH_WRONLY, &fufh); + fufh_type = FUFH_WRONLY; + error = fuse_filehandle_get(vp, fufh_type, &fufh, cred, pid); } if (error) { printf("FUSE: strategy: filehandles are closed\n"); @@ -664,7 +672,6 @@ fuse_io_strategy(struct vnode *vp, struct buf *bp) bufdone(bp); return (error); } - cred = bp->b_iocmd == BIO_READ ? bp->b_rcred : bp->b_wcred; uiop = &uio; uiop->uio_iov = &io; Modified: projects/fuse2/sys/fs/fuse/fuse_io.h ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_io.h Mon Apr 1 20:03:53 2019 (r345780) +++ projects/fuse2/sys/fs/fuse/fuse_io.h Mon Apr 1 20:42:15 2019 (r345781) @@ -61,7 +61,7 @@ #define _FUSE_IO_H_ int fuse_io_dispatch(struct vnode *vp, struct uio *uio, int ioflag, - struct ucred *cred); + struct ucred *cred, pid_t pid); int fuse_io_strategy(struct vnode *vp, struct buf *bp); int fuse_io_flushbuf(struct vnode *vp, int waitfor, struct thread *td); int fuse_io_invalbuf(struct vnode *vp, struct thread *td); Modified: projects/fuse2/sys/fs/fuse/fuse_node.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_node.c Mon Apr 1 20:03:53 2019 (r345780) +++ projects/fuse2/sys/fs/fuse/fuse_node.c Mon Apr 1 20:42:15 2019 (r345781) @@ -345,7 +345,7 @@ fuse_vnode_open(struct vnode *vp, int32_t fuse_open_fl } int -fuse_vnode_savesize(struct vnode *vp, struct ucred *cred) +fuse_vnode_savesize(struct vnode *vp, struct ucred *cred, pid_t pid) { struct fuse_vnode_data *fvdat = VTOFUD(vp); struct thread *td = curthread; @@ -377,7 +377,7 @@ fuse_vnode_savesize(struct vnode *vp, struct ucred *cr fsai->size = fvdat->filesize; fsai->valid |= FATTR_SIZE; - fuse_filehandle_getrw(vp, FUFH_WRONLY, &fufh); + fuse_filehandle_getrw(vp, FUFH_WRONLY, &fufh, cred, pid); if (fufh) { fsai->fh = fufh->fh_id; fsai->valid |= FATTR_FH; Modified: projects/fuse2/sys/fs/fuse/fuse_node.h ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_node.h Mon Apr 1 20:03:53 2019 (r345780) +++ projects/fuse2/sys/fs/fuse/fuse_node.h Mon Apr 1 20:42:15 2019 (r345781) @@ -126,7 +126,7 @@ void fuse_vnode_open(struct vnode *vp, int32_t fuse_op int fuse_vnode_refreshsize(struct vnode *vp, struct ucred *cred); -int fuse_vnode_savesize(struct vnode *vp, struct ucred *cred); +int fuse_vnode_savesize(struct vnode *vp, struct ucred *cred, pid_t pid); int fuse_vnode_setsize(struct vnode *vp, struct ucred *cred, off_t newsize); Modified: projects/fuse2/sys/fs/fuse/fuse_vnops.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_vnops.c Mon Apr 1 20:03:53 2019 (r345780) +++ projects/fuse2/sys/fs/fuse/fuse_vnops.c Mon Apr 1 20:42:15 2019 (r345781) @@ -216,6 +216,16 @@ uma_zone_t fuse_pbuf_zone; #define fuse_vm_page_lock_queues() ((void)0) #define fuse_vm_page_unlock_queues() ((void)0) +/* Get a filehandle for a directory */ +static int +fuse_filehandle_get_dir(struct vnode *vp, struct fuse_filehandle **fufhp, + struct ucred *cred, pid_t pid) +{ + if (fuse_filehandle_get(vp, FUFH_RDONLY, fufhp, cred, pid) == 0) + return 0; + return fuse_filehandle_get(vp, FUFH_EXEC, fufhp, cred, pid); +} + /* struct vnop_access_args { struct vnode *a_vp; @@ -278,6 +288,8 @@ fuse_vnop_close(struct vop_close_args *ap) struct vnode *vp = ap->a_vp; struct ucred *cred = ap->a_cred; int fflag = ap->a_fflag; + struct thread *td = ap->a_td; + pid_t pid = td->td_proc->p_pid; if (fuse_isdeadfs(vp)) { return 0; @@ -285,8 +297,7 @@ fuse_vnop_close(struct vop_close_args *ap) if (vnode_isdir(vp)) { struct fuse_filehandle *fufh; - if ((fuse_filehandle_get(vp, O_RDONLY, &fufh) == 0) || - (fuse_filehandle_get(vp, O_EXEC, &fufh) == 0)) + if (fuse_filehandle_get_dir(vp, &fufh, cred, pid) == 0) fuse_filehandle_close(vp, fufh, NULL, cred); return 0; } @@ -295,7 +306,7 @@ fuse_vnop_close(struct vop_close_args *ap) } /* TODO: close the file handle, if we're sure it's no longer used */ if ((VTOFUD(vp)->flag & FN_SIZECHANGE) != 0) { - fuse_vnode_savesize(vp, cred); + fuse_vnode_savesize(vp, cred, td->td_proc->p_pid); } return 0; } @@ -432,7 +443,8 @@ fuse_vnop_create(struct vop_create_args *ap) } ASSERT_VOP_ELOCKED(*vpp, "fuse_vnop_create"); - fuse_filehandle_init(*vpp, FUFH_RDWR, NULL, foo->fh); + fuse_filehandle_init(*vpp, FUFH_RDWR, NULL, td->td_proc->p_pid, cred, + foo->fh); fuse_vnode_open(*vpp, foo->open_flags, td); cache_purge_negative(dvp); @@ -597,7 +609,7 @@ fuse_vnop_inactive(struct vop_inactive_args *ap) LIST_FOREACH_SAFE(fufh, &fvdat->handles, next, fufh_tmp) { if (need_flush && vp->v_type == VREG) { if ((VTOFUD(vp)->flag & FN_SIZECHANGE) != 0) { - fuse_vnode_savesize(vp, NULL); + fuse_vnode_savesize(vp, NULL, 0); } if (fuse_data_cache_invalidate || (fvdat->flag & FN_REVOKED) != 0) @@ -1194,6 +1206,7 @@ fuse_vnop_open(struct vop_open_args *ap) int mode = ap->a_mode; struct thread *td = ap->a_td; struct ucred *cred = ap->a_cred; + pid_t pid = td->td_proc->p_pid; fufh_type_t fufh_type; struct fuse_vnode_data *fvdat; @@ -1209,7 +1222,7 @@ fuse_vnop_open(struct vop_open_args *ap) fufh_type = fuse_filehandle_xlate_from_fflags(mode); - if (fuse_filehandle_validrw(vp, fufh_type) != FUFH_INVALID) { + if (fuse_filehandle_validrw(vp, fufh_type, cred, pid)) { fuse_vnode_open(vp, 0, td); return 0; } @@ -1257,6 +1270,7 @@ fuse_vnop_read(struct vop_read_args *ap) struct uio *uio = ap->a_uio; int ioflag = ap->a_ioflag; struct ucred *cred = ap->a_cred; + pid_t pid = curthread->td_proc->p_pid; if (fuse_isdeadfs(vp)) { return ENXIO; @@ -1266,7 +1280,7 @@ fuse_vnop_read(struct vop_read_args *ap) ioflag |= IO_DIRECT; } - return fuse_io_dispatch(vp, uio, ioflag, cred); + return fuse_io_dispatch(vp, uio, ioflag, cred, pid); } /* @@ -1285,12 +1299,11 @@ fuse_vnop_readdir(struct vop_readdir_args *ap) struct vnode *vp = ap->a_vp; struct uio *uio = ap->a_uio; struct ucred *cred = ap->a_cred; - struct fuse_filehandle *fufh = NULL; struct fuse_iov cookediov; - int err = 0; int freefufh = 0; + pid_t pid = curthread->td_proc->p_pid; if (fuse_isdeadfs(vp)) { return ENXIO; @@ -1300,7 +1313,7 @@ fuse_vnop_readdir(struct vop_readdir_args *ap) return EINVAL; } - if ((err = fuse_filehandle_get(vp, FUFH_RDONLY, &fufh)) != 0) { + if ((err = fuse_filehandle_get_dir(vp, &fufh, cred, pid)) != 0) { SDT_PROBE2(fuse, , vnops, trace, 1, "calling readdir() before open()"); err = fuse_filehandle_open(vp, O_RDONLY, &fufh, NULL, cred); @@ -1550,6 +1563,7 @@ fuse_vnop_setattr(struct vop_setattr_args *ap) struct fuse_dispatcher fdi; struct fuse_setattr_in *fsai; struct fuse_access_param facp; + pid_t pid = td->td_proc->p_pid; int err = 0; enum vtype vtyp; @@ -1589,7 +1603,7 @@ fuse_vnop_setattr(struct vop_setattr_args *ap) newsize = vap->va_size; fsai->valid |= FATTR_SIZE; - fuse_filehandle_getrw(vp, FUFH_WRONLY, &fufh); + fuse_filehandle_getrw(vp, FUFH_WRONLY, &fufh, cred, pid); if (fufh) { fsai->fh = fufh->fh_id; fsai->valid |= FATTR_FH; @@ -1760,6 +1774,7 @@ fuse_vnop_write(struct vop_write_args *ap) struct uio *uio = ap->a_uio; int ioflag = ap->a_ioflag; struct ucred *cred = ap->a_cred; + pid_t pid = curthread->td_proc->p_pid; int err; if (fuse_isdeadfs(vp)) { @@ -1773,7 +1788,7 @@ fuse_vnop_write(struct vop_write_args *ap) ioflag |= IO_DIRECT; } - return fuse_io_dispatch(vp, uio, ioflag, cred); + return fuse_io_dispatch(vp, uio, ioflag, cred, pid); } SDT_PROBE_DEFINE1(fuse, , vnops, vnop_getpages_error, "int"); @@ -1797,6 +1812,7 @@ fuse_vnop_getpages(struct vop_getpages_args *ap) struct thread *td; struct ucred *cred; vm_page_t *pages; + pid_t pid = curthread->td_proc->p_pid; vp = ap->a_vp; KASSERT(vp->v_object, ("objectless vp passed to getpages")); @@ -1846,7 +1862,7 @@ fuse_vnop_getpages(struct vop_getpages_args *ap) uio.uio_rw = UIO_READ; uio.uio_td = td; - error = fuse_io_dispatch(vp, &uio, IO_DIRECT, cred); + error = fuse_io_dispatch(vp, &uio, IO_DIRECT, cred, pid); pmap_qremove(kva, npages); uma_zfree(fuse_pbuf_zone, bp); @@ -1929,6 +1945,7 @@ fuse_vnop_putpages(struct vop_putpages_args *ap) struct ucred *cred; vm_page_t *pages; vm_ooffset_t fsize; + pid_t pid = curthread->td_proc->p_pid; vp = ap->a_vp; KASSERT(vp->v_object, ("objectless vp passed to putpages")); @@ -1978,7 +1995,7 @@ fuse_vnop_putpages(struct vop_putpages_args *ap) uio.uio_rw = UIO_WRITE; uio.uio_td = td; - error = fuse_io_dispatch(vp, &uio, IO_DIRECT, cred); + error = fuse_io_dispatch(vp, &uio, IO_DIRECT, cred, pid); pmap_qremove(kva, npages); uma_zfree(fuse_pbuf_zone, bp); Modified: projects/fuse2/tests/sys/fs/fusefs/allow_other.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/allow_other.cc Mon Apr 1 20:03:53 2019 (r345780) +++ projects/fuse2/tests/sys/fs/fusefs/allow_other.cc Mon Apr 1 20:42:15 2019 (r345781) @@ -99,8 +99,7 @@ TEST_F(AllowOther, allowed) * visible to root. The second process is unprivileged and shouldn't be able * to open the file, but does thanks to the bug */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236844 */ -TEST_F(AllowOther, DISABLED_privilege_escalation) +TEST_F(AllowOther, privilege_escalation) { const static char FULLPATH[] = "mountpoint/some_file.txt"; const static char RELPATH[] = "some_file.txt"; Modified: projects/fuse2/tests/sys/fs/fusefs/open.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/open.cc Mon Apr 1 20:03:53 2019 (r345780) +++ projects/fuse2/tests/sys/fs/fusefs/open.cc Mon Apr 1 20:42:15 2019 (r345781) @@ -165,8 +165,7 @@ TEST_F(Open, fifo) * credentials open the same file, even if they use the same mode. This is * necessary so that the daemon can validate each set of credentials. */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236844 */ -TEST_F(Open, DISABLED_multiple_creds) +TEST_F(Open, multiple_creds) { const static char FULLPATH[] = "mountpoint/some_file.txt"; const static char RELPATH[] = "some_file.txt"; From owner-svn-src-projects@freebsd.org Mon Apr 1 21:04:14 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 18F31156F0EA for ; Mon, 1 Apr 2019 21:04:14 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AF03889A47; Mon, 1 Apr 2019 21:04:13 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 889611C0B9; Mon, 1 Apr 2019 21:04:13 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x31L4DrQ060295; Mon, 1 Apr 2019 21:04:13 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31L4DGg060294; Mon, 1 Apr 2019 21:04:13 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904012104.x31L4DGg060294@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Mon, 1 Apr 2019 21:04:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345782 - projects/capsicum-test/contrib/capsicum-test X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/capsicum-test/contrib/capsicum-test X-SVN-Commit-Revision: 345782 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: AF03889A47 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 21:04:14 -0000 Author: ngie Date: Mon Apr 1 21:04:13 2019 New Revision: 345782 URL: https://svnweb.freebsd.org/changeset/base/345782 Log: Fix grammar-o: it's -> its Thanks @emaste! Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc ============================================================================== --- projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Mon Apr 1 20:42:15 2019 (r345781) +++ projects/capsicum-test/contrib/capsicum-test/capsicum-test-main.cc Mon Apr 1 21:04:13 2019 (r345782) @@ -57,7 +57,7 @@ class SetupEnvironment : public ::testing::Environment } if (trap_enotcap_enabled) { GTEST_SKIP() << "Debug sysctl, " << oid << ", enabled. " - << "Skipping tests because it's enablement invalidates the " + << "Skipping tests because its enablement invalidates the " << "test results."; } #endif /* FreeBSD */ From owner-svn-src-projects@freebsd.org Mon Apr 1 21:13:17 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 42C54156F4D2 for ; Mon, 1 Apr 2019 21:13:17 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B87948A1D9; Mon, 1 Apr 2019 21:13:16 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-pf1-x42b.google.com with SMTP id b3so5195896pfd.1; Mon, 01 Apr 2019 14:13:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=BIYkOLeOLQtqtAfsO2IxJdbh7viYYwEQp3fYY+UO2Z8=; b=unOgn1j3TmIoeAqOVmiJmt8sD6MJDEoX5EWXy89TLh+ZP/A/L9nXEYRbSlyFPArzXg ytEPa2k+Pm6p3rlBYenC7kKZ2fyP/pbG9I7KdJLiMcgNAKSWtxwucjkDzQcWF++3RT3O 9xG62L/BuQv2NEKcXE2keHvUtYKvKbmvqO1s9f7uk1j3royUHEBl8UkHPC3vf+YpxfBY cN6WLtzRlHryjk7xnRjqarPP9kPF3KZuDzs6h6IBY38FuporvQfFE/ElYHKQiLv2mGGf YKVSZXcUg8gALG4P2YPOUPRpbIha7aPuC+MggH6zP7lU1Ez/HIDirRRyXLRFZgRsd5xo oyBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=BIYkOLeOLQtqtAfsO2IxJdbh7viYYwEQp3fYY+UO2Z8=; b=jWxCetD4H1CIBWiwMn1Qfm68IFWKt0A5MUTylTUMhdtzFXmw59JUNIlvzCIxsyQLJ0 lD765VHQPPyOTeM+OcFFaWPAqVBBUJXOzZ2sOvdWu8ZNFoIHY7CxxcQuVhR3NUPgD26l axdKbkCqyqMxfuMz7/9erC2/UJ+yHUYxwvNuAPobULM0nht4oGAinnSsrQIjQTvRpEzx RrxK2CqAhZPUHPQs9Bfpa36AyTZ6LYfQv8aP9gPa/YSqyaSTTil2C5/bRSMZEnNcKBgg y+9UXTELd/k4+x/1p5d6xvnIF91gUrgMpf6bRYz54XEqIKr2Sd8grsrEalTXsGXUWq+E G3/g== X-Gm-Message-State: APjAAAVR1ut1NX246sMhlbe3LS/qVpMElVBJyXWWtNvGoUk+v9Ct3owt q8MJrVYM3aR49rdAXU6Qv1aBkCVqYgU= X-Google-Smtp-Source: APXvYqzTLnJr5oYgLjS+PrqUjTRw7tqm7LKD5pceuorKPqfFNxDwY4m0G6MyaNP6HiUm47jIS36ilQ== X-Received: by 2002:a62:6490:: with SMTP id y138mr51672673pfb.230.1554153194968; Mon, 01 Apr 2019 14:13:14 -0700 (PDT) Received: from [192.168.20.7] (c-73-19-52-228.hsd1.wa.comcast.net. [73.19.52.228]) by smtp.gmail.com with ESMTPSA id k12sm14191725pfk.109.2019.04.01.14.13.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Apr 2019 14:13:14 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: svn commit: r345782 - projects/capsicum-test/contrib/capsicum-test From: Enji Cooper In-Reply-To: <201904012104.x31L4DGg060294@repo.freebsd.org> Date: Mon, 1 Apr 2019 14:13:13 -0700 Cc: src-committers , svn-src-projects@freebsd.org Content-Transfer-Encoding: 7bit Message-Id: References: <201904012104.x31L4DGg060294@repo.freebsd.org> To: Enji Cooper X-Mailer: Apple Mail (2.3445.102.3) X-Rspamd-Queue-Id: B87948A1D9 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.98 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.98)[-0.977,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 21:13:17 -0000 > On Apr 1, 2019, at 2:04 PM, Enji Cooper wrote: > > Author: ngie > Date: Mon Apr 1 21:04:13 2019 > New Revision: 345782 > URL: https://svnweb.freebsd.org/changeset/base/345782 > > Log: > Fix grammar-o: it's -> its > > Thanks @emaste! Ah, I meant @markj, not @emaste :D.. From owner-svn-src-projects@freebsd.org Mon Apr 1 21:26:06 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1BE87156FA61 for ; Mon, 1 Apr 2019 21:26:06 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8F5948ABAF; Mon, 1 Apr 2019 21:26:05 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6A0F91C499; Mon, 1 Apr 2019 21:26:05 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x31LQ5e6071368; Mon, 1 Apr 2019 21:26:05 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31LQ5ed071367; Mon, 1 Apr 2019 21:26:05 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904012126.x31LQ5ed071367@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Mon, 1 Apr 2019 21:26:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345784 - projects/capsicum-test X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/capsicum-test X-SVN-Commit-Revision: 345784 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8F5948ABAF X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 21:26:06 -0000 Author: ngie Date: Mon Apr 1 21:26:05 2019 New Revision: 345784 URL: https://svnweb.freebsd.org/changeset/base/345784 Log: Prune project branch, integrated into ^/head as r345783 Deleted: projects/capsicum-test/ From owner-svn-src-projects@freebsd.org Mon Apr 1 21:28:11 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AB8AA156FA94 for ; Mon, 1 Apr 2019 21:28:10 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5768E8ACE0; Mon, 1 Apr 2019 21:28:10 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 340B91C49C; Mon, 1 Apr 2019 21:28:10 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x31LSA7v071560; Mon, 1 Apr 2019 21:28:10 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31LS4bS071533; Mon, 1 Apr 2019 21:28:04 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904012128.x31LS4bS071533@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Mon, 1 Apr 2019 21:28:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345785 - in projects/kyua-use-googletest-test-interface: contrib/bsnmp/snmpd contrib/capsicum-test contrib/googletest/googletest contrib/googletest/googletest/docs contrib/googletest/g... X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: in projects/kyua-use-googletest-test-interface: contrib/bsnmp/snmpd contrib/capsicum-test contrib/googletest/googletest contrib/googletest/googletest/docs contrib/googletest/googletest/src contrib/goo... X-SVN-Commit-Revision: 345785 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5768E8ACE0 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.978,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 21:28:11 -0000 Author: ngie Date: Mon Apr 1 21:28:04 2019 New Revision: 345785 URL: https://svnweb.freebsd.org/changeset/base/345785 Log: MFhead@r345784 Added: projects/kyua-use-googletest-test-interface/contrib/capsicum-test/ - copied from r345784, head/contrib/capsicum-test/ projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc - copied unchanged from r345784, head/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc Modified: projects/kyua-use-googletest-test-interface/contrib/bsnmp/snmpd/trap.c projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/CMakeLists.txt projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/Makefile.am projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/docs/advanced.md projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/src/gtest.cc projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/test/BUILD.bazel projects/kyua-use-googletest-test-interface/gnu/usr.bin/gdb/gdb/Makefile projects/kyua-use-googletest-test-interface/gnu/usr.bin/gdb/kgdb/Makefile projects/kyua-use-googletest-test-interface/lib/googletest/gtest_main/tests/Makefile projects/kyua-use-googletest-test-interface/lib/libbe/be.c projects/kyua-use-googletest-test-interface/sbin/bectl/tests/bectl_test.sh projects/kyua-use-googletest-test-interface/sys/arm/allwinner/aw_mmc.c projects/kyua-use-googletest-test-interface/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c projects/kyua-use-googletest-test-interface/sys/cam/cam_ccb.h projects/kyua-use-googletest-test-interface/sys/cam/mmc/mmc_da.c projects/kyua-use-googletest-test-interface/sys/dev/md/md.c projects/kyua-use-googletest-test-interface/sys/dev/pci/pci.c projects/kyua-use-googletest-test-interface/sys/dev/sdhci/sdhci.c projects/kyua-use-googletest-test-interface/sys/dev/usb/wlan/if_run.c projects/kyua-use-googletest-test-interface/sys/dev/usb/wlan/if_uath.c projects/kyua-use-googletest-test-interface/sys/dev/usb/wlan/if_urtw.c projects/kyua-use-googletest-test-interface/tests/sys/audit/Makefile projects/kyua-use-googletest-test-interface/tests/sys/audit/process-control.c projects/kyua-use-googletest-test-interface/tests/sys/capsicum/Makefile Directory Properties: projects/kyua-use-googletest-test-interface/ (props changed) projects/kyua-use-googletest-test-interface/gnu/usr.bin/gdb/ (props changed) Modified: projects/kyua-use-googletest-test-interface/contrib/bsnmp/snmpd/trap.c ============================================================================== --- projects/kyua-use-googletest-test-interface/contrib/bsnmp/snmpd/trap.c Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/contrib/bsnmp/snmpd/trap.c Mon Apr 1 21:28:04 2019 (r345785) @@ -726,8 +726,7 @@ target_activate_address(struct target_address *addrs) sa.sin_addr.s_addr = htonl((addrs->address[0] << 24) | (addrs->address[1] << 16) | (addrs->address[2] << 8) | (addrs->address[3] << 0)); - sa.sin_port = htons(addrs->address[4]) << 8 | - htons(addrs->address[5]) << 0; + sa.sin_port = htons(addrs->address[4] << 8 | addrs->address[5]); if (connect(addrs->socket, (struct sockaddr *)&sa, sa.sin_len) == -1) { syslog(LOG_ERR, "connect(%s,%u): %m", Modified: projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/CMakeLists.txt ============================================================================== --- projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/CMakeLists.txt Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/CMakeLists.txt Mon Apr 1 21:28:04 2019 (r345785) @@ -217,6 +217,7 @@ if (gtest_build_tests) test/gtest-typed-test2_test.cc) cxx_test(gtest_unittest gtest_main) cxx_test(gtest-unittest-api_test gtest) + cxx_test(gtest_skip_in_environment_setup_test gtest_main) cxx_test(gtest_skip_test gtest_main) ############################################################ Modified: projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/Makefile.am ============================================================================== --- projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/Makefile.am Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/Makefile.am Mon Apr 1 21:28:04 2019 (r345785) @@ -290,6 +290,12 @@ test_gtest_all_test_SOURCES = test/gtest_all_test.cc test_gtest_all_test_LDADD = lib/libgtest_main.la \ lib/libgtest.la +TESTS += test/gtest_skip_in_environment_setup_test +check_PROGRAMS += test/gtest_skip_in_environment_setup_test +test_gtest_skip_in_environment_setup_test_SOURCES = test/gtest_skip_in_environment_setup_test.cc +test_gtest_skip_in_environment_setup_test_LDADD= lib/libgtest_main.la \ + lib/libgtest.la + # Tests that fused gtest files compile and work. FUSED_GTEST_SRC = \ fused-src/gtest/gtest-all.cc \ Modified: projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/docs/advanced.md ============================================================================== --- projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/docs/advanced.md Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/docs/advanced.md Mon Apr 1 21:28:04 2019 (r345785) @@ -1289,8 +1289,10 @@ Environment* AddGlobalTestEnvironment(Environment* env ``` Now, when `RUN_ALL_TESTS()` is called, it first calls the `SetUp()` method of -the environment object, then runs the tests if there was no fatal failures, and -finally calls `TearDown()` of the environment object. +each environment object, then runs the tests if none of the environments +reported fatal failures and `GTEST_SKIP()` was not called. `RUN_ALL_TESTS()` +always calls `TearDown()` with each environment object, regardless of whether +or not the tests were run. It's OK to register multiple environment objects. In this case, their `SetUp()` will be called in the order they are registered, and their `TearDown()` will be Modified: projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/src/gtest.cc ============================================================================== --- projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/src/gtest.cc Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/src/gtest.cc Mon Apr 1 21:28:04 2019 (r345785) @@ -5243,9 +5243,23 @@ bool UnitTestImpl::RunAllTests() { ForEach(environments_, SetUpEnvironment); repeater->OnEnvironmentsSetUpEnd(*parent_); - // Runs the tests only if there was no fatal failure during global - // set-up. - if (!Test::HasFatalFailure()) { + // Runs the tests only if there was no fatal failure or skip triggered + // during global set-up. + if (Test::IsSkipped()) { + // Emit diagnostics when global set-up calls skip, as it will not be + // emitted by default. + TestResult& test_result = + *internal::GetUnitTestImpl()->current_test_result(); + for (int j = 0; j < test_result.total_part_count(); ++j) { + const TestPartResult& test_part_result = + test_result.GetTestPartResult(j); + if (test_part_result.type() == TestPartResult::kSkip) { + const std::string& result = test_part_result.message(); + printf("%s\n", result.c_str()); + } + } + fflush(stdout); + } else if (!Test::HasFatalFailure()) { for (int test_index = 0; test_index < total_test_case_count(); test_index++) { GetMutableTestCase(test_index)->Run(); Modified: projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/test/BUILD.bazel ============================================================================== --- projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/test/BUILD.bazel Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/test/BUILD.bazel Mon Apr 1 21:28:04 2019 (r345785) @@ -311,6 +311,13 @@ cc_binary( deps = ["//:gtest"], ) +cc_test( + name = "gtest_skip_in_environment_setup_test", + size = "small", + srcs = ["gtest_skip_in_environment_setup_test.cc"], + deps = ["//:gtest_main"], +) + py_test( name = "googletest-list-tests-unittest", size = "small", Copied: projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc (from r345784, head/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/kyua-use-googletest-test-interface/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc Mon Apr 1 21:28:04 2019 (r345785, copy of r345784, head/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc) @@ -0,0 +1,60 @@ +// Copyright 2019, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// This test verifies that skipping in the environment results in the +// testcases being skipped. +// +// This is a reproduction case for +// https://github.com/google/googletest/issues/2189 . + +#include +#include + +class SetupEnvironment : public testing::Environment { +public: + void SetUp() override { + GTEST_SKIP() << "Skipping the entire environment"; + } +}; + +TEST(Test, AlwaysPasses) { + EXPECT_EQ(true, true); +} + +TEST(Test, AlwaysFails) { + EXPECT_EQ(true, false); +} + +int main(int argc, char **argv) { + testing::InitGoogleTest(&argc, argv); + + testing::AddGlobalTestEnvironment(new SetupEnvironment()); + + return (RUN_ALL_TESTS()); +} Modified: projects/kyua-use-googletest-test-interface/gnu/usr.bin/gdb/gdb/Makefile ============================================================================== --- projects/kyua-use-googletest-test-interface/gnu/usr.bin/gdb/gdb/Makefile Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/gnu/usr.bin/gdb/gdb/Makefile Mon Apr 1 21:28:04 2019 (r345785) @@ -3,9 +3,10 @@ PROG= gdb${GDB_SUFFIX} SRCS= gdb.c -BULIBS= ${OBJ_BU}/libbfd/libbfd.a ${OBJ_BU}/libopcodes/libopcodes.a \ - ${OBJ_BU}/libiberty/libiberty.a -GDBLIBS= ${OBJ_GDB}/libgdb/libgdb.a +BULIBS= ${OBJ_BU}/libbfd/libbfd${PIE_SUFFIX}.a \ + ${OBJ_BU}/libopcodes/libopcodes${PIE_SUFFIX}.a \ + ${OBJ_BU}/libiberty/libiberty${PIE_SUFFIX}.a +GDBLIBS= ${OBJ_GDB}/libgdb/libgdb${PIE_SUFFIX}.a # libthread_db.so calls back into gdb for the proc services. Make all the # global symbols visible. Modified: projects/kyua-use-googletest-test-interface/gnu/usr.bin/gdb/kgdb/Makefile ============================================================================== --- projects/kyua-use-googletest-test-interface/gnu/usr.bin/gdb/kgdb/Makefile Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/gnu/usr.bin/gdb/kgdb/Makefile Mon Apr 1 21:28:04 2019 (r345785) @@ -4,9 +4,10 @@ PROG= kgdb${GDB_SUFFIX} SRCS= main.c kld.c kthr.c trgt.c trgt_${TARGET_CPUARCH}.c WARNS?= 2 -BULIBS= ${OBJ_BU}/libbfd/libbfd.a ${OBJ_BU}/libopcodes/libopcodes.a \ - ${OBJ_BU}/libiberty/libiberty.a -GDBLIBS= ${OBJ_GDB}/libgdb/libgdb.a +BULIBS= ${OBJ_BU}/libbfd/libbfd${PIE_SUFFIX}.a \ + ${OBJ_BU}/libopcodes/libopcodes${PIE_SUFFIX}.a \ + ${OBJ_BU}/libiberty/libiberty${PIE_SUFFIX}.a +GDBLIBS= ${OBJ_GDB}/libgdb/libgdb${PIE_SUFFIX}.a DPADD= ${GDBLIBS} ${BULIBS} LDADD= ${GDBLIBS} ${BULIBS} Modified: projects/kyua-use-googletest-test-interface/lib/googletest/gtest_main/tests/Makefile ============================================================================== --- projects/kyua-use-googletest-test-interface/lib/googletest/gtest_main/tests/Makefile Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/lib/googletest/gtest_main/tests/Makefile Mon Apr 1 21:28:04 2019 (r345785) @@ -19,6 +19,7 @@ GTESTS+= gtest_sole_header_test GTESTS+= googletest-test-part-test GTESTS+= gtest-typed-test_test GTESTS+= gtest_skip_test +GTESTS+= gtest_skip_in_environment_setup_test GTESTS+= gtest_unittest # This test cannot selectively run a single test, as it verifies results when Modified: projects/kyua-use-googletest-test-interface/lib/libbe/be.c ============================================================================== --- projects/kyua-use-googletest-test-interface/lib/libbe/be.c Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/lib/libbe/be.c Mon Apr 1 21:28:04 2019 (r345785) @@ -265,6 +265,16 @@ be_destroy(libbe_handle_t *lbh, const char *name, int zfs_prop_get(fs, ZFS_PROP_ORIGIN, origin, sizeof(origin), NULL, NULL, 0, 1) != 0) return (set_error(lbh, BE_ERR_NOORIGIN)); + + /* Don't destroy a mounted dataset unless force is specified */ + if ((mounted = zfs_is_mounted(fs, NULL)) != 0) { + if (force) { + zfs_unmount(fs, NULL, 0); + } else { + free(bdd.snapname); + return (set_error(lbh, BE_ERR_DESTROYMNT)); + } + } } else { if (!zfs_dataset_exists(lbh->lzh, path, ZFS_TYPE_SNAPSHOT)) return (set_error(lbh, BE_ERR_NOENT)); @@ -277,16 +287,6 @@ be_destroy(libbe_handle_t *lbh, const char *name, int if (fs == NULL) { free(bdd.snapname); return (set_error(lbh, BE_ERR_ZFSOPEN)); - } - } - - /* Check if mounted, unmount if force is specified */ - if ((mounted = zfs_is_mounted(fs, NULL)) != 0) { - if (force) { - zfs_unmount(fs, NULL, 0); - } else { - free(bdd.snapname); - return (set_error(lbh, BE_ERR_DESTROYMNT)); } } Modified: projects/kyua-use-googletest-test-interface/sbin/bectl/tests/bectl_test.sh ============================================================================== --- projects/kyua-use-googletest-test-interface/sbin/bectl/tests/bectl_test.sh Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/sbin/bectl/tests/bectl_test.sh Mon Apr 1 21:28:04 2019 (r345785) @@ -123,12 +123,21 @@ bectl_destroy_body() zpool=$(make_zpool_name) disk=${cwd}/disk.img mount=${cwd}/mnt + root=${mount}/root bectl_create_setup ${zpool} ${disk} ${mount} atf_check bectl -r ${zpool}/ROOT create -e default default2 atf_check -o not-empty zfs get mountpoint ${zpool}/ROOT/default2 atf_check -e ignore bectl -r ${zpool}/ROOT destroy default2 atf_check -e not-empty -s not-exit:0 zfs get mountpoint ${zpool}/ROOT/default2 + + # Test origin snapshot deletion when the snapshot to be destroyed + # belongs to a mounted dataset, see PR 236043. + atf_check mkdir -p ${root} + atf_check -o not-empty bectl -r ${zpool}/ROOT mount default ${root} + atf_check bectl -r ${zpool}/ROOT create -e default default3 + atf_check bectl -r ${zpool}/ROOT destroy -o default3 + atf_check bectl -r ${zpool}/ROOT unmount default } bectl_destroy_cleanup() { Modified: projects/kyua-use-googletest-test-interface/sys/arm/allwinner/aw_mmc.c ============================================================================== --- projects/kyua-use-googletest-test-interface/sys/arm/allwinner/aw_mmc.c Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/sys/arm/allwinner/aw_mmc.c Mon Apr 1 21:28:04 2019 (r345785) @@ -256,6 +256,8 @@ aw_mmc_cam_action(struct cam_sim *sim, union ccb *ccb) cts->proto_specific.mmc.host_f_min = sc->aw_host.f_min; cts->proto_specific.mmc.host_f_max = sc->aw_host.f_max; cts->proto_specific.mmc.host_caps = sc->aw_host.caps; + cts->proto_specific.mmc.host_max_data = (sc->aw_mmc_conf->dma_xferlen * + AW_MMC_DMA_SEGS) / MMC_SECTOR_SIZE; memcpy(&cts->proto_specific.mmc.ios, &sc->aw_host.ios, sizeof(struct mmc_ios)); ccb->ccb_h.status = CAM_REQ_CMP; break; Modified: projects/kyua-use-googletest-test-interface/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c ============================================================================== --- projects/kyua-use-googletest-test-interface/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Mon Apr 1 21:28:04 2019 (r345785) @@ -66,8 +66,17 @@ __FBSDID("$FreeBSD$"); #define NUM_DMA_SEGS 2 #ifdef DEBUG -#define dprintf(fmt, args...) do { printf("%s(): ", __func__); \ - printf(fmt,##args); } while (0) +static int bcm2835_sdhci_debug = 0; + +TUNABLE_INT("hw.bcm2835.sdhci.debug", &bcm2835_sdhci_debug); +SYSCTL_INT(_hw_sdhci, OID_AUTO, bcm2835_sdhci_debug, CTLFLAG_RWTUN, + &bcm2835_sdhci_debug, 0, "bcm2835 SDHCI debug level"); + +#define dprintf(fmt, args...) \ + do { \ + if (bcm2835_sdhci_debug) \ + printf("%s: " fmt, __func__, ##args); \ + } while (0) #else #define dprintf(fmt, args...) #endif Modified: projects/kyua-use-googletest-test-interface/sys/cam/cam_ccb.h ============================================================================== --- projects/kyua-use-googletest-test-interface/sys/cam/cam_ccb.h Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/sys/cam/cam_ccb.h Mon Apr 1 21:28:04 2019 (r345785) @@ -1051,6 +1051,7 @@ struct ccb_trans_settings_mmc { #define MMC_CAP_8_BIT_DATA (1 << 1) /* Can do 8-bit data transfers */ #define MMC_CAP_HSPEED (1 << 2) /* Can do High Speed transfers */ uint32_t host_caps; + uint32_t host_max_data; }; /* Get/Set transfer rate/width/disconnection/tag queueing settings */ Modified: projects/kyua-use-googletest-test-interface/sys/cam/mmc/mmc_da.c ============================================================================== --- projects/kyua-use-googletest-test-interface/sys/cam/mmc/mmc_da.c Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/sys/cam/mmc/mmc_da.c Mon Apr 1 21:28:04 2019 (r345785) @@ -150,6 +150,17 @@ struct sdda_softc { struct timeval log_time; }; +static const char *mmc_errmsg[] = +{ + "None", + "Timeout", + "Bad CRC", + "Fifo", + "Failed", + "Invalid", + "NO MEMORY" +}; + #define ccb_bp ppriv_ptr1 static disk_strategy_t sddastrategy; @@ -165,6 +176,7 @@ static void sddadone(struct cam_periph *periph, static int sddaerror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags); +static int mmc_handle_reply(union ccb *ccb); static uint16_t get_rca(struct cam_periph *periph); static void sdda_start_init(void *context, union ccb *start_ccb); static void sdda_start_init_task(void *context, int pending); @@ -218,6 +230,37 @@ get_rca(struct cam_periph *periph) { return periph->path->device->mmc_ident_data.card_rca; } +/* + * Figure out if CCB execution resulted in error. + * Look at both CAM-level errors and on MMC protocol errors. +*/ +static int +mmc_handle_reply(union ccb *ccb) +{ + + KASSERT(ccb->ccb_h.func_code == XPT_MMC_IO, + ("ccb %p: cannot handle non-XPT_MMC_IO errors, got func_code=%d", + ccb, ccb->ccb_h.func_code)); + + /* TODO: maybe put MMC-specific handling into cam.c/cam_error_print altogether */ + if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP)) { + if (ccb->mmcio.cmd.error != 0) { + xpt_print_path(ccb->ccb_h.path); + printf("CMD%d failed, err %d (%s)\n", + ccb->mmcio.cmd.opcode, + ccb->mmcio.cmd.error, + mmc_errmsg[ccb->mmcio.cmd.error]); + return (EIO); + } + } else { + cam_error_print(ccb, CAM_ESF_ALL, CAM_EPF_ALL); + return (EIO); + } + + return (0); /* Normal return */ +} + + static uint32_t mmc_get_bits(uint32_t *bits, int bit_len, int start, int size) { @@ -777,11 +820,12 @@ mmc_exec_app_cmd(struct cam_periph *periph, union ccb /*mmc_data*/ NULL, /*timeout*/ 0); - err = cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + err = mmc_handle_reply(ccb); if (err != 0) - return err; + return (err); if (!(ccb->mmcio.cmd.resp[0] & R1_APP_CMD)) - return MMC_ERR_FAILED; + return (EIO); /* Now exec actual command */ int flags = 0; @@ -803,12 +847,14 @@ mmc_exec_app_cmd(struct cam_periph *periph, union ccb /*mmc_data*/ cmd->data, /*timeout*/ 0); - err = cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + err = mmc_handle_reply(ccb); + if (err != 0) + return (err); memcpy(cmd->resp, ccb->mmcio.cmd.resp, sizeof(cmd->resp)); cmd->error = ccb->mmcio.cmd.error; - if (err != 0) - return err; - return 0; + + return (0); } static int @@ -858,10 +904,9 @@ mmc_send_ext_csd(struct cam_periph *periph, union ccb /*mmc_data*/ &d, /*timeout*/ 0); - err = cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); - if (err != 0) - return (err); - return (MMC_ERR_NONE); + cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + err = mmc_handle_reply(ccb); + return (err); } static void @@ -904,7 +949,7 @@ mmc_switch_fill_mmcio(union ccb *ccb, static int mmc_select_card(struct cam_periph *periph, union ccb *ccb, uint32_t rca) { - int flags; + int flags, err; flags = (rca ? MMC_RSP_R1B : MMC_RSP_NONE) | MMC_CMD_AC; cam_fill_mmcio(&ccb->mmcio, @@ -918,42 +963,20 @@ mmc_select_card(struct cam_periph *periph, union ccb * /*timeout*/ 0); cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); - - if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP)) { - if (ccb->mmcio.cmd.error != 0) { - CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_PERIPH, - ("%s: MMC_SELECT command failed", __func__)); - return EIO; - } - return 0; /* Normal return */ - } else { - CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_PERIPH, - ("%s: CAM request failed\n", __func__)); - return EIO; - } + err = mmc_handle_reply(ccb); + return (err); } static int mmc_switch(struct cam_periph *periph, union ccb *ccb, uint8_t set, uint8_t index, uint8_t value, u_int timeout) { + int err; mmc_switch_fill_mmcio(ccb, set, index, value, timeout); cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); - - if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP)) { - if (ccb->mmcio.cmd.error != 0) { - CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_PERIPH, - ("%s: MMC command failed", __func__)); - return (EIO); - } - return (0); /* Normal return */ - } else { - CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_PERIPH, - ("%s: CAM request failed\n", __func__)); - return (EIO); - } - + err = mmc_handle_reply(ccb); + return (err); } static uint32_t @@ -987,6 +1010,7 @@ mmc_sd_switch(struct cam_periph *periph, union ccb *cc struct mmc_data mmc_d; uint32_t arg; + int err; memset(res, 0, 64); mmc_d.len = 64; @@ -1009,19 +1033,8 @@ mmc_sd_switch(struct cam_periph *periph, union ccb *cc /*timeout*/ 0); cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); - - if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP)) { - if (ccb->mmcio.cmd.error != 0) { - CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_PERIPH, - ("%s: MMC command failed", __func__)); - return EIO; - } - return 0; /* Normal return */ - } else { - CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_PERIPH, - ("%s: CAM request failed\n", __func__)); - return EIO; - } + err = mmc_handle_reply(ccb); + return (err); } static int @@ -1195,6 +1208,27 @@ sdda_get_host_caps(struct cam_periph *periph, union cc return (cts->host_caps); } +static uint32_t +sdda_get_max_data(struct cam_periph *periph, union ccb *ccb) +{ + struct ccb_trans_settings_mmc *cts; + + cts = &ccb->cts.proto_specific.mmc; + memset(cts, 0, sizeof(struct ccb_trans_settings_mmc)); + + ccb->ccb_h.func_code = XPT_GET_TRAN_SETTINGS; + ccb->ccb_h.flags = CAM_DIR_NONE; + ccb->ccb_h.retry_count = 0; + ccb->ccb_h.timeout = 100; + ccb->ccb_h.cbfcnp = NULL; + xpt_action(ccb); + + if (ccb->ccb_h.status != CAM_REQ_CMP) + panic("Cannot get host max data"); + KASSERT(cts->host_max_data != 0, ("host_max_data == 0?!")); + return (cts->host_max_data); +} + static void sdda_start_init(void *context, union ccb *start_ccb) { @@ -1420,7 +1454,6 @@ sdda_add_part(struct cam_periph *periph, u_int type, c struct sdda_softc *sc = (struct sdda_softc *)periph->softc; struct sdda_part *part; struct ccb_pathinq cpi; - u_int maxio; CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, ("Partition type '%s', size %ju %s\n", @@ -1479,12 +1512,9 @@ sdda_add_part(struct cam_periph *periph, u_int type, c part->disk->d_gone = sddadiskgonecb; part->disk->d_name = part->name; part->disk->d_drv1 = part; - maxio = cpi.maxio; /* Honor max I/O size of SIM */ - if (maxio == 0) - maxio = DFLTPHYS; /* traditional default */ - else if (maxio > MAXPHYS) - maxio = MAXPHYS; /* for safety */ - part->disk->d_maxsize = maxio; + part->disk->d_maxsize = + MIN(MAXPHYS, sdda_get_max_data(periph, + (union ccb *)&cpi) * mmc_get_sector_size(periph)); part->disk->d_unit = cnt; part->disk->d_flags = 0; strlcpy(part->disk->d_descr, sc->card_id_string, Modified: projects/kyua-use-googletest-test-interface/sys/dev/md/md.c ============================================================================== --- projects/kyua-use-googletest-test-interface/sys/dev/md/md.c Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/sys/dev/md/md.c Mon Apr 1 21:28:04 2019 (r345785) @@ -110,6 +110,7 @@ #define MD_SHUTDOWN 0x10000 /* Tell worker thread to terminate. */ #define MD_EXITING 0x20000 /* Worker thread is exiting. */ +#define MD_PROVIDERGONE 0x40000 /* Safe to free the softc */ #ifndef MD_NSECT #define MD_NSECT (10000 * 2) @@ -199,6 +200,7 @@ static g_start_t g_md_start; static g_access_t g_md_access; static void g_md_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g_consumer *cp __unused, struct g_provider *pp); +static g_provgone_t g_md_providergone; static struct cdev *status_dev = NULL; static struct sx md_sx; @@ -220,6 +222,7 @@ struct g_class g_md_class = { .start = g_md_start, .access = g_md_access, .dumpconf = g_md_dumpconf, + .providergone = g_md_providergone, }; DECLARE_GEOM_CLASS(g_md_class, g_md); @@ -481,8 +484,8 @@ g_md_start(struct bio *bp) } mtx_lock(&sc->queue_mtx); bioq_disksort(&sc->bio_queue, bp); - mtx_unlock(&sc->queue_mtx); wakeup(sc); + mtx_unlock(&sc->queue_mtx); } #define MD_MALLOC_MOVE_ZERO 1 @@ -1496,17 +1499,30 @@ bad: return (error); } +static void +g_md_providergone(struct g_provider *pp) +{ + struct md_s *sc = pp->geom->softc; + + mtx_lock(&sc->queue_mtx); + sc->flags |= MD_PROVIDERGONE; + wakeup(&sc->flags); + mtx_unlock(&sc->queue_mtx); +} + static int mddestroy(struct md_s *sc, struct thread *td) { if (sc->gp) { - sc->gp->softc = NULL; g_topology_lock(); g_wither_geom(sc->gp, ENXIO); g_topology_unlock(); - sc->gp = NULL; - sc->pp = NULL; + + mtx_lock(&sc->queue_mtx); + while (!(sc->flags & MD_PROVIDERGONE)) + msleep(&sc->flags, &sc->queue_mtx, PRIBIO, "mddestroy", 0); + mtx_unlock(&sc->queue_mtx); } if (sc->devstat) { devstat_remove_entry(sc->devstat); Modified: projects/kyua-use-googletest-test-interface/sys/dev/pci/pci.c ============================================================================== --- projects/kyua-use-googletest-test-interface/sys/dev/pci/pci.c Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/sys/dev/pci/pci.c Mon Apr 1 21:28:04 2019 (r345785) @@ -31,6 +31,7 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_acpi.h" #include "opt_bus.h" #include @@ -5693,13 +5694,34 @@ pci_get_resource_list (device_t dev, device_t child) return (&dinfo->resources); } +#ifdef ACPI_DMAR +bus_dma_tag_t dmar_get_dma_tag(device_t dev, device_t child); bus_dma_tag_t pci_get_dma_tag(device_t bus, device_t dev) { + bus_dma_tag_t tag; + struct pci_softc *sc; + + if (device_get_parent(dev) == bus) { + /* try dmar and return if it works */ + tag = dmar_get_dma_tag(bus, dev); + } else + tag = NULL; + if (tag == NULL) { + sc = device_get_softc(bus); + tag = sc->sc_dma_tag; + } + return (tag); +} +#else +bus_dma_tag_t +pci_get_dma_tag(device_t bus, device_t dev) +{ struct pci_softc *sc = device_get_softc(bus); return (sc->sc_dma_tag); } +#endif uint32_t pci_read_config_method(device_t dev, device_t child, int reg, int width) Modified: projects/kyua-use-googletest-test-interface/sys/dev/sdhci/sdhci.c ============================================================================== --- projects/kyua-use-googletest-test-interface/sys/dev/sdhci/sdhci.c Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/sys/dev/sdhci/sdhci.c Mon Apr 1 21:28:04 2019 (r345785) @@ -2580,6 +2580,7 @@ sdhci_cam_action(struct cam_sim *sim, union ccb *ccb) case XPT_GET_TRAN_SETTINGS: { struct ccb_trans_settings *cts = &ccb->cts; + uint32_t max_data; if (sdhci_debug > 1) slot_printf(slot, "Got XPT_GET_TRAN_SETTINGS\n"); @@ -2593,6 +2594,19 @@ sdhci_cam_action(struct cam_sim *sim, union ccb *ccb) cts->proto_specific.mmc.host_f_min = slot->host.f_min; cts->proto_specific.mmc.host_f_max = slot->host.f_max; cts->proto_specific.mmc.host_caps = slot->host.caps; + /* + * Re-tuning modes 1 and 2 restrict the maximum data length + * per read/write command to 4 MiB. + */ + if (slot->opt & SDHCI_TUNING_ENABLED && + (slot->retune_mode == SDHCI_RETUNE_MODE_1 || + slot->retune_mode == SDHCI_RETUNE_MODE_2)) { + max_data = 4 * 1024 * 1024 / MMC_SECTOR_SIZE; + } else { + max_data = 65535; + } + cts->proto_specific.mmc.host_max_data = max_data; + memcpy(&cts->proto_specific.mmc.ios, &slot->host.ios, sizeof(struct mmc_ios)); ccb->ccb_h.status = CAM_REQ_CMP; break; Modified: projects/kyua-use-googletest-test-interface/sys/dev/usb/wlan/if_run.c ============================================================================== --- projects/kyua-use-googletest-test-interface/sys/dev/usb/wlan/if_run.c Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/sys/dev/usb/wlan/if_run.c Mon Apr 1 21:28:04 2019 (r345785) @@ -2851,10 +2851,6 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uin } if (flags & RT2860_RX_L2PAD) { - /* - * XXX OpenBSD removes padding between header - * and payload here... - */ RUN_DPRINTF(sc, RUN_DEBUG_RECV, "received RT2860_RX_L2PAD frame\n"); len += 2; @@ -2865,8 +2861,8 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uin wh = mtod(m, struct ieee80211_frame *); - /* XXX wrong for monitor mode */ - if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { + if ((wh->i_fc[1] & IEEE80211_FC1_PROTECTED) != 0 && + (flags & RT2860_RX_DEC) != 0) { wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED; m->m_flags |= M_WEP; } @@ -2896,6 +2892,8 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uin uint16_t phy; tap->wr_flags = 0; + if (flags & RT2860_RX_L2PAD) + tap->wr_flags |= IEEE80211_RADIOTAP_F_DATAPAD; tap->wr_antsignal = rssi; tap->wr_antenna = ant; tap->wr_dbm_antsignal = run_rssi2dbm(sc, rssi, ant); @@ -3162,14 +3160,23 @@ tr_setup: vap = data->ni->ni_vap; if (ieee80211_radiotap_active_vap(vap)) { + const struct ieee80211_frame *wh; struct run_tx_radiotap_header *tap = &sc->sc_txtap; struct rt2860_txwi *txwi = (struct rt2860_txwi *)(&data->desc + sizeof(struct rt2870_txd)); + int has_l2pad; + + wh = mtod(m, struct ieee80211_frame *); + has_l2pad = IEEE80211_HAS_ADDR4(wh) != + IEEE80211_QOS_HAS_SEQ(wh); + tap->wt_flags = 0; tap->wt_rate = rt2860_rates[data->ridx].rate; tap->wt_hwqueue = index; if (le16toh(txwi->phy) & RT2860_PHY_SHPRE) tap->wt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE; + if (has_l2pad) + tap->wt_flags |= IEEE80211_RADIOTAP_F_DATAPAD; ieee80211_radiotap_tx(vap, m); } Modified: projects/kyua-use-googletest-test-interface/sys/dev/usb/wlan/if_uath.c ============================================================================== --- projects/kyua-use-googletest-test-interface/sys/dev/usb/wlan/if_uath.c Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/sys/dev/usb/wlan/if_uath.c Mon Apr 1 21:28:04 2019 (r345785) @@ -1276,8 +1276,8 @@ uath_watchdog(void *arg) if (sc->sc_tx_timer > 0) { if (--sc->sc_tx_timer == 0) { device_printf(sc->sc_dev, "device timeout\n"); - /*uath_init(sc); XXX needs a process context! */ counter_u64_add(ic->ic_oerrors, 1); + ieee80211_restart_all(ic); return; } callout_reset(&sc->watchdog_ch, hz, uath_watchdog, sc); Modified: projects/kyua-use-googletest-test-interface/sys/dev/usb/wlan/if_urtw.c ============================================================================== --- projects/kyua-use-googletest-test-interface/sys/dev/usb/wlan/if_urtw.c Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/sys/dev/usb/wlan/if_urtw.c Mon Apr 1 21:28:04 2019 (r345785) @@ -1891,11 +1891,13 @@ static void urtw_watchdog(void *arg) { struct urtw_softc *sc = arg; + struct ieee80211com *ic = &sc->sc_ic; if (sc->sc_txtimer > 0) { if (--sc->sc_txtimer == 0) { device_printf(sc->sc_dev, "device timeout\n"); - counter_u64_add(sc->sc_ic.ic_oerrors, 1); + counter_u64_add(ic->ic_oerrors, 1); + ieee80211_restart_all(ic); return; } callout_reset(&sc->sc_watchdog_ch, hz, urtw_watchdog, sc); Modified: projects/kyua-use-googletest-test-interface/tests/sys/audit/Makefile ============================================================================== --- projects/kyua-use-googletest-test-interface/tests/sys/audit/Makefile Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/tests/sys/audit/Makefile Mon Apr 1 21:28:04 2019 (r345785) @@ -55,4 +55,6 @@ WARNS?= 6 LDFLAGS+= -lbsm -lutil +CFLAGS.process-control.c+= -I${SRCTOP}/tests + .include Modified: projects/kyua-use-googletest-test-interface/tests/sys/audit/process-control.c ============================================================================== --- projects/kyua-use-googletest-test-interface/tests/sys/audit/process-control.c Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/tests/sys/audit/process-control.c Mon Apr 1 21:28:04 2019 (r345785) @@ -48,6 +48,8 @@ #include "utils.h" +#include "freebsd_test_suite/macros.h" + static pid_t pid; static int filedesc, status; static struct pollfd fds[1]; @@ -1512,15 +1514,8 @@ ATF_TC_HEAD(cap_enter_success, tc) ATF_TC_BODY(cap_enter_success, tc) { - int capinfo; - size_t len = sizeof(capinfo); - const char *capname = "kern.features.security_capability_mode"; - ATF_REQUIRE_EQ(0, sysctlbyname(capname, &capinfo, &len, NULL, 0)); + ATF_REQUIRE_FEATURE("security_capability_mode"); - /* Without CAPABILITY_MODE enabled, cap_enter() returns ENOSYS */ - if (!capinfo) - atf_tc_skip("Capsicum is not enabled in the system"); - FILE *pipefd = setup(fds, auclass); ATF_REQUIRE((pid = fork()) != -1); if (pid) { @@ -1550,14 +1545,9 @@ ATF_TC_HEAD(cap_getmode_success, tc) ATF_TC_BODY(cap_getmode_success, tc) { - int capinfo, modep; - size_t len = sizeof(capinfo); - const char *capname = "kern.features.security_capability_mode"; - ATF_REQUIRE_EQ(0, sysctlbyname(capname, &capinfo, &len, NULL, 0)); + int modep; - /* Without CAPABILITY_MODE enabled, cap_getmode() returns ENOSYS */ - if (!capinfo) - atf_tc_skip("Capsicum is not enabled in the system"); + ATF_REQUIRE_FEATURE("security_capability_mode"); pid = getpid(); snprintf(pcregex, sizeof(pcregex), "cap_getmode.*%d.*success", pid); Modified: projects/kyua-use-googletest-test-interface/tests/sys/capsicum/Makefile ============================================================================== --- projects/kyua-use-googletest-test-interface/tests/sys/capsicum/Makefile Mon Apr 1 21:26:05 2019 (r345784) +++ projects/kyua-use-googletest-test-interface/tests/sys/capsicum/Makefile Mon Apr 1 21:28:04 2019 (r345785) @@ -1,11 +1,56 @@ # $FreeBSD$ +.include + TESTSDIR= ${TESTSBASE}/sys/capsicum ATF_TESTS_C+= bindat_connectat ATF_TESTS_C+= ioctls_test CFLAGS+= -I${SRCTOP}/tests + +.if ${MK_GOOGLETEST} != no + +.PATH: ${SRCTOP}/contrib/capsicum-test + +GTESTS+= capsicum-test + +SRCS.capsicum-test+= \ + capsicum-test-main.cc \ + capsicum-test.cc \ + capability-fd.cc \ + fexecve.cc \ + procdesc.cc \ + capmode.cc \ + fcntl.cc \ + ioctl.cc \ + openat.cc \ + sysctl.cc \ + select.cc \ + mqueue.cc \ + socket.cc \ + sctp.cc \ + capability-fd-pair.cc \ + overhead.cc \ + rename.cc + +LIBADD.capsicum-test+= gtest pthread +TEST_METADATA.capsicum-test= required_user="unprivileged" + +.for p in mini-me mini-me.noexec mini-me.setuid +PROGS+= $p +NO_SHARED.$p= +SRCS.$p= mini-me.c +.endfor + +BINDIR= ${TESTSDIR} + +BINMODE.mini-me.noexec= ${NOBINMODE} +BINMODE.mini-me.setuid= 4555 + +WARNS.capsicum-test= 3 + +.endif WARNS?= 6 From owner-svn-src-projects@freebsd.org Mon Apr 1 23:37:23 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 060781571DCA for ; Mon, 1 Apr 2019 23:37:23 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9A48B8E314; Mon, 1 Apr 2019 23:37:22 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 73A151DAD6; Mon, 1 Apr 2019 23:37:22 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x31NbMQQ039062; Mon, 1 Apr 2019 23:37:22 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x31NbM4m039061; Mon, 1 Apr 2019 23:37:22 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904012337.x31NbM4m039061@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Mon, 1 Apr 2019 23:37:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345788 - projects/fuse2/tests/sys/fs/fusefs X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: projects/fuse2/tests/sys/fs/fusefs X-SVN-Commit-Revision: 345788 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9A48B8E314 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.951,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2019 23:37:23 -0000 Author: asomers Date: Mon Apr 1 23:37:21 2019 New Revision: 345788 URL: https://svnweb.freebsd.org/changeset/base/345788 Log: Respond to ngie's comments in D19752 Better Makefile syntax. Note that this commit is to the project branch, but the review concerns the merge to head. Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/tests/sys/fs/fusefs/Makefile Modified: projects/fuse2/tests/sys/fs/fusefs/Makefile ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/Makefile Mon Apr 1 22:19:15 2019 (r345787) +++ projects/fuse2/tests/sys/fs/fusefs/Makefile Mon Apr 1 23:37:21 2019 (r345788) @@ -38,166 +38,24 @@ GTESTS+= unlink GTESTS+= write GTESTS+= xattr -SRCS.access+= access.cc -SRCS.access+= getmntopts.c -SRCS.access+= mockfs.cc -SRCS.access+= utils.cc +.for p in ${GTESTS} +SRCS.$p+= ${p}.cc +SRCS.$p+= getmntopts.c +SRCS.$p+= mockfs.cc +SRCS.$p+= utils.cc +.endfor -SRCS.allow_other+= allow_other.cc -SRCS.allow_other+= getmntopts.c -SRCS.allow_other+= mockfs.cc -SRCS.allow_other+= utils.cc - -SRCS.create+= create.cc -SRCS.create+= getmntopts.c -SRCS.create+= mockfs.cc -SRCS.create+= utils.cc - -SRCS.default_permissions+= default_permissions.cc -SRCS.default_permissions+= getmntopts.c -SRCS.default_permissions+= mockfs.cc -SRCS.default_permissions+= utils.cc TEST_METADATA.default_permissions+= required_user="unprivileged" - -SRCS.destroy+= destroy.cc -SRCS.destroy+= getmntopts.c -SRCS.destroy+= mockfs.cc -SRCS.destroy+= utils.cc - -SRCS.flush+= flush.cc -SRCS.flush+= getmntopts.c -SRCS.flush+= mockfs.cc -SRCS.flush+= utils.cc - -SRCS.fsync+= fsync.cc -SRCS.fsync+= getmntopts.c -SRCS.fsync+= mockfs.cc -SRCS.fsync+= utils.cc - -SRCS.fsyncdir+= fsyncdir.cc -SRCS.fsyncdir+= getmntopts.c -SRCS.fsyncdir+= mockfs.cc -SRCS.fsyncdir+= utils.cc - -SRCS.getattr+= getattr.cc -SRCS.getattr+= getmntopts.c -SRCS.getattr+= mockfs.cc -SRCS.getattr+= utils.cc - -SRCS.interrupt+= interrupt.cc -SRCS.interrupt+= getmntopts.c -SRCS.interrupt+= mockfs.cc -SRCS.interrupt+= utils.cc - -SRCS.link+= getmntopts.c -SRCS.link+= link.cc -SRCS.link+= mockfs.cc -SRCS.link+= utils.cc - -SRCS.locks+= locks.cc -SRCS.locks+= getmntopts.c -SRCS.locks+= mockfs.cc -SRCS.locks+= utils.cc - -SRCS.lookup+= getmntopts.c -SRCS.lookup+= lookup.cc -SRCS.lookup+= mockfs.cc -SRCS.lookup+= utils.cc - -SRCS.mkdir+= getmntopts.c -SRCS.mkdir+= mockfs.cc -SRCS.mkdir+= mkdir.cc -SRCS.mkdir+= utils.cc - -SRCS.mknod+= getmntopts.c -SRCS.mknod+= mockfs.cc -SRCS.mknod+= mknod.cc -SRCS.mknod+= utils.cc TEST_METADATA.mknod+= required_user="root" -SRCS.open+= getmntopts.c -SRCS.open+= mockfs.cc -SRCS.open+= open.cc -SRCS.open+= utils.cc - -SRCS.opendir+= getmntopts.c -SRCS.opendir+= mockfs.cc -SRCS.opendir+= opendir.cc -SRCS.opendir+= utils.cc - -SRCS.read+= getmntopts.c -SRCS.read+= mockfs.cc -SRCS.read+= read.cc -SRCS.read+= utils.cc - -SRCS.readdir+= getmntopts.c -SRCS.readdir+= mockfs.cc -SRCS.readdir+= readdir.cc -SRCS.readdir+= utils.cc - -SRCS.readlink+= getmntopts.c -SRCS.readlink+= mockfs.cc -SRCS.readlink+= readlink.cc -SRCS.readlink+= utils.cc - -SRCS.release+= getmntopts.c -SRCS.release+= mockfs.cc -SRCS.release+= release.cc -SRCS.release+= utils.cc - -SRCS.releasedir+= getmntopts.c -SRCS.releasedir+= mockfs.cc -SRCS.releasedir+= releasedir.cc -SRCS.releasedir+= utils.cc - -SRCS.rename+= getmntopts.c -SRCS.rename+= mockfs.cc -SRCS.rename+= rename.cc -SRCS.rename+= utils.cc - -SRCS.rmdir+= getmntopts.c -SRCS.rmdir+= mockfs.cc -SRCS.rmdir+= rmdir.cc -SRCS.rmdir+= utils.cc - -SRCS.setattr+= getmntopts.c -SRCS.setattr+= mockfs.cc -SRCS.setattr+= setattr.cc -SRCS.setattr+= utils.cc - -SRCS.statfs+= getmntopts.c -SRCS.statfs+= mockfs.cc -SRCS.statfs+= statfs.cc -SRCS.statfs+= utils.cc - -SRCS.symlink+= getmntopts.c -SRCS.symlink+= mockfs.cc -SRCS.symlink+= symlink.cc -SRCS.symlink+= utils.cc - -SRCS.unlink+= getmntopts.c -SRCS.unlink+= mockfs.cc -SRCS.unlink+= unlink.cc -SRCS.unlink+= utils.cc - -SRCS.write+= getmntopts.c -SRCS.write+= mockfs.cc -SRCS.write+= write.cc -SRCS.write+= utils.cc - -SRCS.xattr+= getmntopts.c -SRCS.xattr+= mockfs.cc -SRCS.xattr+= xattr.cc -SRCS.xattr+= utils.cc - # TODO: drastically increase timeout after test development is mostly complete TEST_METADATA+= timeout=10 -FUSEFS= ${.CURDIR:H:H:H:H}/sys/fs/fuse -MOUNT= ${.CURDIR:H:H:H:H}/sbin/mount -CFLAGS+= -I${.CURDIR:H:H:H} -CFLAGS+= -I${FUSEFS} -CFLAGS+= -I${MOUNT} +FUSEFS= ${SRCTOP}/sys/fs/fuse +MOUNT= ${SRCTOP}/sbin/mount +CXXFLAGS+= -I${SRCTOP}/tests +CXXFLAGS+= -I${FUSEFS} +CXXFLAGS+= -I${MOUNT} .PATH: ${MOUNT} CXXSTD= c++14 From owner-svn-src-projects@freebsd.org Tue Apr 2 18:09:41 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 801EF156ECE0 for ; Tue, 2 Apr 2019 18:09:41 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 25760703EC; Tue, 2 Apr 2019 18:09:41 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 025AA1ABF; Tue, 2 Apr 2019 18:09:41 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x32I9egR020901; Tue, 2 Apr 2019 18:09:40 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32I9eNR020898; Tue, 2 Apr 2019 18:09:40 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904021809.x32I9eNR020898@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Tue, 2 Apr 2019 18:09:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345808 - projects/fuse2/sys/fs/fuse X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: projects/fuse2/sys/fs/fuse X-SVN-Commit-Revision: 345808 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 25760703EC X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.969,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 18:09:41 -0000 Author: asomers Date: Tue Apr 2 18:09:40 2019 New Revision: 345808 URL: https://svnweb.freebsd.org/changeset/base/345808 Log: fusefs: cleanup and refactor some recent commits This commit cleans up after recent commits, especially 345766, 345768, and 345781. There is no functional change. The most important change is to add comments documenting why we can't send flags like O_APPEND in FUSE_WRITE_OPEN. PR: 236340 Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/sys/fs/fuse/fuse_file.c projects/fuse2/sys/fs/fuse/fuse_file.h projects/fuse2/sys/fs/fuse/fuse_vnops.c Modified: projects/fuse2/sys/fs/fuse/fuse_file.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_file.c Tue Apr 2 18:01:54 2019 (r345807) +++ projects/fuse2/sys/fs/fuse/fuse_file.c Tue Apr 2 18:09:40 2019 (r345808) @@ -97,22 +97,75 @@ static int fuse_fh_count = 0; SYSCTL_INT(_vfs_fusefs, OID_AUTO, filehandle_count, CTLFLAG_RD, &fuse_fh_count, 0, "number of open FUSE filehandles"); +/* Get the FUFH type for a particular access mode */ +static inline fufh_type_t +fflags_2_fufh_type(int fflags) +{ + if ((fflags & FREAD) && (fflags & FWRITE)) + return FUFH_RDWR; + else if (fflags & (FWRITE)) + return FUFH_WRONLY; + else if (fflags & (FREAD)) + return FUFH_RDONLY; + else if (fflags & (FEXEC)) + return FUFH_EXEC; + else + panic("FUSE: What kind of a flag is this (%x)?", fflags); +} + +/* + * Get the flags to use for FUSE_CREATE, FUSE_OPEN and FUSE_RELEASE + * + * These are supposed to be the same as the flags argument to open(2). + * However, since we can't reliably associate a fuse_filehandle with a specific + * file descriptor it would would be dangerous to include anything more than + * the access mode flags. For example, suppose we open a file twice, once with + * O_APPEND and once without. Then the user pwrite(2)s to offset using the + * second file descriptor. If fusefs uses the first file handle, then the + * server may append the write to the end of the file rather than at offset 0. + * To prevent problems like this, we only ever send the portion of flags + * related to access mode. + * + * It's essential to send that portion, because FUSE uses it for server-side + * authorization. + * + * TODO: consider sending O_APPEND after upgrading to protocol 7.9, which + * includes flags in fuse_write_in. + */ +static inline int +fufh_type_2_fflags(fufh_type_t type) +{ + int oflags = -1; + + switch (type) { + case FUFH_RDONLY: + case FUFH_WRONLY: + case FUFH_RDWR: + case FUFH_EXEC: + oflags = type; + break; + default: + break; + } + + return oflags; +} + int -fuse_filehandle_open(struct vnode *vp, fufh_type_t fufh_type, +fuse_filehandle_open(struct vnode *vp, int a_mode, struct fuse_filehandle **fufhp, struct thread *td, struct ucred *cred) { struct fuse_dispatcher fdi; struct fuse_open_in *foi; struct fuse_open_out *foo; + fufh_type_t fufh_type; int err = 0; int oflags = 0; int op = FUSE_OPEN; - /* - * Note that this means we are effectively FILTERING OUT open() flags. - */ - oflags = fuse_filehandle_xlate_to_oflags(fufh_type); + fufh_type = fflags_2_fufh_type(a_mode); + oflags = fufh_type_2_fflags(fufh_type); if (vnode_isdir(vp)) { op = FUSE_OPENDIR; @@ -136,7 +189,7 @@ fuse_filehandle_open(struct vnode *vp, fufh_type_t fuf foo = fdi.answ; fuse_filehandle_init(vp, fufh_type, fufhp, td->td_proc->p_pid, cred, - foo->fh); + foo); fuse_vnode_open(vp, foo->open_flags, td); @@ -164,7 +217,7 @@ fuse_filehandle_close(struct vnode *vp, struct fuse_fi fdisp_make_vp(&fdi, op, vp, td, cred); fri = fdi.indata; fri->fh = fufh->fh_id; - fri->flags = fufh->flags; + fri->flags = fufh_type_2_fflags(fufh->fufh_type); err = fdisp_wait_answ(&fdi); fdisp_destroy(&fdi); @@ -185,18 +238,19 @@ out: * A pid of 0 means "don't care" */ bool -fuse_filehandle_validrw(struct vnode *vp, fufh_type_t fufh_type, +fuse_filehandle_validrw(struct vnode *vp, int mode, struct ucred *cred, pid_t pid) { struct fuse_vnode_data *fvdat = VTOFUD(vp); struct fuse_filehandle *fufh; + fufh_type_t fufh_type = fflags_2_fufh_type(mode); /* * Unlike fuse_filehandle_get, we want to search for a filehandle with * the exact cred, and no fallback */ LIST_FOREACH(fufh, &fvdat->handles, next) { - if (fufh->flags == fufh_type && + if (fufh->fufh_type == fufh_type && fufh->uid == cred->cr_uid && fufh->gid == cred->cr_rgid && (pid == 0 || fufh->pid == pid)) @@ -208,7 +262,7 @@ fuse_filehandle_validrw(struct vnode *vp, fufh_type_t /* Fallback: find a RDWR list entry with the right cred */ LIST_FOREACH(fufh, &fvdat->handles, next) { - if (fufh->flags == FUFH_RDWR && + if (fufh->fufh_type == FUFH_RDWR && fufh->uid == cred->cr_uid && fufh->gid == cred->cr_rgid && (pid == 0 || fufh->pid == pid)) @@ -229,7 +283,7 @@ fuse_filehandle_get(struct vnode *vp, fufh_type_t fufh goto fallback; LIST_FOREACH(fufh, &fvdat->handles, next) { - if (fufh->flags == fufh_type && + if (fufh->fufh_type == fufh_type && fufh->uid == cred->cr_uid && fufh->gid == cred->cr_rgid && (pid == 0 || fufh->pid == pid)) @@ -239,7 +293,7 @@ fuse_filehandle_get(struct vnode *vp, fufh_type_t fufh fallback: /* Fallback: find a list entry with the right flags */ LIST_FOREACH(fufh, &fvdat->handles, next) { - if (fufh->flags == fufh_type) + if (fufh->fufh_type == fufh_type) break; } @@ -267,7 +321,7 @@ fuse_filehandle_getrw(struct vnode *vp, fufh_type_t fu void fuse_filehandle_init(struct vnode *vp, fufh_type_t fufh_type, struct fuse_filehandle **fufhp, pid_t pid, struct ucred *cred, - uint64_t fh_id) + struct fuse_open_out *foo) { struct fuse_vnode_data *fvdat = VTOFUD(vp); struct fuse_filehandle *fufh; @@ -275,12 +329,12 @@ fuse_filehandle_init(struct vnode *vp, fufh_type_t fuf fufh = malloc(sizeof(struct fuse_filehandle), M_FUSE_FILEHANDLE, M_WAITOK); MPASS(fufh != NULL); - fufh->fh_id = fh_id; - fufh->flags = fufh_type; + fufh->fh_id = foo->fh; + fufh->fufh_type = fufh_type; fufh->gid = cred->cr_rgid; fufh->uid = cred->cr_uid; fufh->pid = pid; - /* TODO: initialize open flags */ + fufh->fuse_open_flags = foo->open_flags; if (!FUFH_IS_VALID(fufh)) { panic("FUSE: init: invalid filehandle id (type=%d)", fufh_type); } Modified: projects/fuse2/sys/fs/fuse/fuse_file.h ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_file.h Tue Apr 2 18:01:54 2019 (r345807) +++ projects/fuse2/sys/fs/fuse/fuse_file.h Tue Apr 2 18:09:40 2019 (r345808) @@ -137,8 +137,8 @@ struct fuse_filehandle { /* flags returned by FUSE_OPEN */ uint32_t fuse_open_flags; - /* The flags used to open(2) the file (using O_RDONLY, not FREAD) */ - uint32_t flags; + /* The access mode of the file handle */ + fufh_type_t fufh_type; /* Credentials used to open the file */ gid_t gid; @@ -146,43 +146,9 @@ struct fuse_filehandle { uid_t uid; }; -#define FUFH_IS_VALID(f) ((f)->flags != FUFH_INVALID) +#define FUFH_IS_VALID(f) ((f)->fufh_type != FUFH_INVALID) -static inline fufh_type_t -fuse_filehandle_xlate_from_fflags(int fflags) -{ - if ((fflags & FREAD) && (fflags & FWRITE)) - return FUFH_RDWR; - else if (fflags & (FWRITE)) - return FUFH_WRONLY; - else if (fflags & (FREAD)) - return FUFH_RDONLY; - else if (fflags & (FEXEC)) - return FUFH_EXEC; - else - panic("FUSE: What kind of a flag is this (%x)?", fflags); -} - -static inline int -fuse_filehandle_xlate_to_oflags(fufh_type_t type) -{ - int oflags = -1; - - switch (type) { - case FUFH_RDONLY: - case FUFH_WRONLY: - case FUFH_RDWR: - case FUFH_EXEC: - oflags = type; - break; - default: - break; - } - - return oflags; -} - -bool fuse_filehandle_validrw(struct vnode *vp, fufh_type_t fufh_type, +bool fuse_filehandle_validrw(struct vnode *vp, int mode, struct ucred *cred, pid_t pid); int fuse_filehandle_get(struct vnode *vp, fufh_type_t fufh_type, struct fuse_filehandle **fufhp, struct ucred *cred, @@ -193,8 +159,8 @@ int fuse_filehandle_getrw(struct vnode *vp, fufh_type_ void fuse_filehandle_init(struct vnode *vp, fufh_type_t fufh_type, struct fuse_filehandle **fufhp, pid_t pid, - struct ucred *cred, uint64_t fh_id); -int fuse_filehandle_open(struct vnode *vp, fufh_type_t fufh_type, + struct ucred *cred, struct fuse_open_out *foo); +int fuse_filehandle_open(struct vnode *vp, int mode, struct fuse_filehandle **fufhp, struct thread *td, struct ucred *cred); int fuse_filehandle_close(struct vnode *vp, struct fuse_filehandle *fufh, Modified: projects/fuse2/sys/fs/fuse/fuse_vnops.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_vnops.c Tue Apr 2 18:01:54 2019 (r345807) +++ projects/fuse2/sys/fs/fuse/fuse_vnops.c Tue Apr 2 18:09:40 2019 (r345808) @@ -365,7 +365,15 @@ fuse_vnop_create(struct vop_create_args *ap) uint64_t parentnid = VTOFUD(dvp)->nid; mode_t mode = MAKEIMODE(vap->va_type, vap->va_mode); enum fuse_opcode op; + int flags; + /* + * VOP_CREATE doesn't tell us the open(2) flags, so we guess. Only a + * writable mode makes sense, and we might as well include readability + * too. + */ + flags = O_RDWR; + if (fuse_isdeadfs(dvp)) { return ENXIO; } @@ -385,7 +393,7 @@ fuse_vnop_create(struct vop_create_args *ap) fdisp_make(fdip, op, vnode_mount(dvp), parentnid, td, cred); foi = fdip->indata; foi->mode = mode; - foi->flags = O_CREAT | O_RDWR; + foi->flags = O_CREAT | flags; memcpy((char *)fdip->indata + sizeof(*foi), cnp->cn_nameptr, cnp->cn_namelen); ((char *)fdip->indata)[sizeof(*foi) + cnp->cn_namelen] = '\0'; @@ -420,7 +428,7 @@ fuse_vnop_create(struct vop_create_args *ap) cred); foi = fdip2->indata; foi->mode = mode; - foi->flags = O_RDWR; + foi->flags = flags; err = fdisp_wait_answ(fdip2); if (err) goto out; @@ -436,7 +444,7 @@ fuse_vnop_create(struct vop_create_args *ap) fdisp_make(fdip, FUSE_RELEASE, mp, nodeid, td, cred); fri = fdip->indata; fri->fh = fh_id; - fri->flags = fuse_filehandle_xlate_to_oflags(FUFH_RDWR); + fri->flags = flags; fuse_insert_callback(fdip->tick, fuse_internal_forget_callback); fuse_insert_message(fdip->tick); goto out; @@ -444,7 +452,7 @@ fuse_vnop_create(struct vop_create_args *ap) ASSERT_VOP_ELOCKED(*vpp, "fuse_vnop_create"); fuse_filehandle_init(*vpp, FUFH_RDWR, NULL, td->td_proc->p_pid, cred, - foo->fh); + foo); fuse_vnode_open(*vpp, foo->open_flags, td); cache_purge_negative(dvp); @@ -1203,31 +1211,27 @@ static int fuse_vnop_open(struct vop_open_args *ap) { struct vnode *vp = ap->a_vp; - int mode = ap->a_mode; + int a_mode = ap->a_mode; struct thread *td = ap->a_td; struct ucred *cred = ap->a_cred; pid_t pid = td->td_proc->p_pid; - - fufh_type_t fufh_type; struct fuse_vnode_data *fvdat; if (fuse_isdeadfs(vp)) return ENXIO; if (vp->v_type == VCHR || vp->v_type == VBLK || vp->v_type == VFIFO) return (EOPNOTSUPP); - if ((mode & (FREAD | FWRITE | FEXEC)) == 0) + if ((a_mode & (FREAD | FWRITE | FEXEC)) == 0) return EINVAL; fvdat = VTOFUD(vp); - fufh_type = fuse_filehandle_xlate_from_fflags(mode); - - if (fuse_filehandle_validrw(vp, fufh_type, cred, pid)) { + if (fuse_filehandle_validrw(vp, a_mode, cred, pid)) { fuse_vnode_open(vp, 0, td); return 0; } - return fuse_filehandle_open(vp, fufh_type, NULL, td, cred); + return fuse_filehandle_open(vp, a_mode, NULL, td, cred); } static int @@ -1395,7 +1399,7 @@ fuse_vnop_reclaim(struct vop_reclaim_args *ap) } LIST_FOREACH_SAFE(fufh, &fvdat->handles, next, fufh_tmp) { printf("FUSE: vnode being reclaimed with open fufh " - "(flags=%#x)", fufh->flags); + "(type=%#x)", fufh->fufh_type); fuse_filehandle_close(vp, fufh, td, NULL); } From owner-svn-src-projects@freebsd.org Tue Apr 2 18:44:02 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5FF14156FCD8 for ; Tue, 2 Apr 2019 18:44:02 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 020F071909; Tue, 2 Apr 2019 18:44:02 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CF7A921A9; Tue, 2 Apr 2019 18:44:01 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x32Ii1O9041320; Tue, 2 Apr 2019 18:44:01 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32Ii1wR041319; Tue, 2 Apr 2019 18:44:01 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904021844.x32Ii1wR041319@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Tue, 2 Apr 2019 18:44:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345809 - projects/fuse2/tests/sys/fs/fusefs X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: projects/fuse2/tests/sys/fs/fusefs X-SVN-Commit-Revision: 345809 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 020F071909 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.99 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.99)[-0.987,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 18:44:02 -0000 Author: asomers Date: Tue Apr 2 18:44:01 2019 New Revision: 345809 URL: https://svnweb.freebsd.org/changeset/base/345809 Log: fusefs: check return value of wait(2) in fork tests Reported by: ngie Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/tests/sys/fs/fusefs/utils.cc Modified: projects/fuse2/tests/sys/fs/fusefs/utils.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/utils.cc Tue Apr 2 18:09:40 2019 (r345808) +++ projects/fuse2/tests/sys/fs/fusefs/utils.cc Tue Apr 2 18:44:01 2019 (r345809) @@ -321,7 +321,7 @@ out: /* Signal the child process to go */ ASSERT_EQ(0, sem_post(sem)) << strerror(errno); - wait(&child_status); + ASSERT_LE(0, wait(&child_status)) << strerror(errno); ASSERT_EQ(0, WEXITSTATUS(child_status)); } else { FAIL() << strerror(errno); From owner-svn-src-projects@freebsd.org Tue Apr 2 18:45:28 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7801C156FD14 for ; Tue, 2 Apr 2019 18:45:28 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E0D0B719F6; Tue, 2 Apr 2019 18:45:27 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-pf1-x42d.google.com with SMTP id i17so6817740pfo.6; Tue, 02 Apr 2019 11:45:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=IsoEgyjcvJCxWS1QJSPZ/CCKCOKuSNNmzC4QVFTfpPY=; b=gxrWcsMJh4wVWzvk9I2BBLl6fRVrt02/0fS/RI9V9B+U2HwBNgLfugFc5ohmUuy2KL fsIcP7MpaH+swGY/mQiIwltJy6/KtYo+LRJSjqWJ/bnGlo+K9Sgg8rieI6TOnMxCoeYP XU7fphcvlBA4n2BRaF0iXfKVUW4frgTdezpMhF8xH1onZUod1OauvAj2PcUEdT+cA3Ik KNSV3nQGHSx+/xQDPbj+tYg359I6AGSsIFdLNXV9a6qmrAT5IbAuYmDvCgdJkOm7QQlD vFWChcADLafj9tTnpZAvY07kZ8zOyqb1/3VYAzM4GyHBbtplnUGZK8B8agcjcdHelQwz GDjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=IsoEgyjcvJCxWS1QJSPZ/CCKCOKuSNNmzC4QVFTfpPY=; b=daHQV6GbQFXvf8BUneaX3kDpFprLZSTKSzvMXGUWnct8A1sTaGyPO9EeEALc+C76Vy xzUQN8HBDuv11v6/8ZdWryrJSIwP6pLsBuzYHcuG3HwjnMSAGjAIlss5vtqUr+ZwnL5Y Zd7ZkP8UR6NaffGfoHyeJzBdOwHPKl2GDUC7rZJ+Yi4396E+Wf8Isiq++n9jQNNPOx+k Auf5k83wQ134+eXRV2musc2emkO8Mh+uxHjSTpZ77ZQLUikHiFUpM1zv/zNgGWiLdErO UWeWsU3SNAAzKmWEabu31wy7pdyg0rFuckLa6aYPhT6mp4jJnGWyQRYzYdWd4F/asVgD McWA== X-Gm-Message-State: APjAAAUzxxNBDO1yWT4bQVUm0/2eQ9tCjgtbxEuMjmLYFZIZD+5yxQ98 gJUkZVnZPt6DJ+3V99Q3p4rf66oa468= X-Google-Smtp-Source: APXvYqzmZZ1bNjuJMOxi0aE3dKMZzaj2T5fvCy7i2t6wIHB1boKPU6NtpYvsniv31xHQKnRKkZ5Vmg== X-Received: by 2002:aa7:8d17:: with SMTP id j23mr834803pfe.62.1554230725842; Tue, 02 Apr 2019 11:45:25 -0700 (PDT) Received: from [192.168.20.7] (c-73-19-52-228.hsd1.wa.comcast.net. [73.19.52.228]) by smtp.gmail.com with ESMTPSA id 10sm20067740pft.83.2019.04.02.11.45.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Apr 2019 11:45:25 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: svn commit: r345809 - projects/fuse2/tests/sys/fs/fusefs From: Enji Cooper In-Reply-To: <201904021844.x32Ii1wR041319@repo.freebsd.org> Date: Tue, 2 Apr 2019 11:45:24 -0700 Cc: src-committers@freebsd.org, svn-src-projects@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <77D06D49-8CE8-483C-90FF-D8CD0122599E@gmail.com> References: <201904021844.x32Ii1wR041319@repo.freebsd.org> To: Alan Somers X-Mailer: Apple Mail (2.3445.102.3) X-Rspamd-Queue-Id: E0D0B719F6 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.99 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.99)[-0.993,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 18:45:28 -0000 > On Apr 2, 2019, at 11:44 AM, Alan Somers wrote: >=20 > Author: asomers > Date: Tue Apr 2 18:44:01 2019 > New Revision: 345809 > URL: https://svnweb.freebsd.org/changeset/base/345809 >=20 > Log: > fusefs: check return value of wait(2) in fork tests >=20 > Reported by: ngie > Sponsored by: The FreeBSD Foundation >=20 > Modified: > projects/fuse2/tests/sys/fs/fusefs/utils.cc >=20 > Modified: projects/fuse2/tests/sys/fs/fusefs/utils.cc > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- projects/fuse2/tests/sys/fs/fusefs/utils.cc Tue Apr 2 = 18:09:40 2019 (r345808) > +++ projects/fuse2/tests/sys/fs/fusefs/utils.cc Tue Apr 2 = 18:44:01 2019 (r345809) > @@ -321,7 +321,7 @@ out: > /* Signal the child process to go */ > ASSERT_EQ(0, sem_post(sem)) << strerror(errno); >=20 > - wait(&child_status); > + ASSERT_LE(0, wait(&child_status)) << strerror(errno); Don=E2=80=99t you want ASSERT_GE here, since you=E2=80=99re testing that = wait succeeded? -Enji= From owner-svn-src-projects@freebsd.org Tue Apr 2 18:49:50 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D4E63156FED4 for ; Tue, 2 Apr 2019 18:49:50 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6222771DAB; Tue, 2 Apr 2019 18:49:50 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-lj1-f195.google.com with SMTP id f23so12566251ljc.0; Tue, 02 Apr 2019 11:49:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=aDWDcvRRrZ3W7zJ/6ytdNtvvA3vcsIEKvj83SWW82VY=; b=nCYof8gXhNclQ3NaKbpBHFiUAYIhZYIdazfsGWGHCK+o8DPZkRtgXw8hExuU8m39Sv DHdQUrgtjuLwmdvt9XdsxEA33opWb/K3gUAOwnnTdQQcT2JuylvYrGZLy4nacJDYVi1o gsCHTzYMRCovlRvFYrLo0SGFZxW1I3+XIxQi9R9E/aSqR0t/Y4A5tGpEz58B0AOtECeA RAghZfy6HWVtGCbnjPoETrNBa+uB478p2XPjeJI5IGuzLsGOoxRwPg1ARzWmivojnSnW RTEedtFKomLFr81L4G3xUAC8840Qkq4UkPx4Bi/mecL66W2+RH3yPWV/tQb3U4sUi9CN ey5w== X-Gm-Message-State: APjAAAU2KxZog/OC6u9bofCMJNd9P9BWgZcRzqc/3XAS2gAZ7FGqlKLD 50dVW3nDFnWtiPdVdqC+6KTjLSBo6Z9gkY0q7KI= X-Google-Smtp-Source: APXvYqz0DCVTkJZDUInnv498/cM3/Ghf99uhUb1kEia85ug3moC2HLlgkVxNF3luGXlpPJHAOGdXYcOyE7uMkkR68Lg= X-Received: by 2002:a2e:9753:: with SMTP id f19mr34377788ljj.54.1554230983091; Tue, 02 Apr 2019 11:49:43 -0700 (PDT) MIME-Version: 1.0 References: <201904021844.x32Ii1wR041319@repo.freebsd.org> <77D06D49-8CE8-483C-90FF-D8CD0122599E@gmail.com> In-Reply-To: <77D06D49-8CE8-483C-90FF-D8CD0122599E@gmail.com> From: Alan Somers Date: Tue, 2 Apr 2019 12:49:31 -0600 Message-ID: Subject: Re: svn commit: r345809 - projects/fuse2/tests/sys/fs/fusefs To: Enji Cooper Cc: src-committers , svn-src-projects@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 6222771DAB X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.99 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.99)[-0.994,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 18:49:51 -0000 On Tue, Apr 2, 2019 at 12:45 PM Enji Cooper wrote: > > > > On Apr 2, 2019, at 11:44 AM, Alan Somers wrote: > > > > Author: asomers > > Date: Tue Apr 2 18:44:01 2019 > > New Revision: 345809 > > URL: https://svnweb.freebsd.org/changeset/base/345809 > > > > Log: > > fusefs: check return value of wait(2) in fork tests > > > > Reported by: ngie > > Sponsored by: The FreeBSD Foundation > > > > Modified: > > projects/fuse2/tests/sys/fs/fusefs/utils.cc > > > > Modified: projects/fuse2/tests/sys/fs/fusefs/utils.cc > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- projects/fuse2/tests/sys/fs/fusefs/utils.cc Tue Apr 2 18:09:= 40 2019 (r345808) > > +++ projects/fuse2/tests/sys/fs/fusefs/utils.cc Tue Apr 2 18:44:= 01 2019 (r345809) > > @@ -321,7 +321,7 @@ out: > > /* Signal the child process to go */ > > ASSERT_EQ(0, sem_post(sem)) << strerror(errno); > > > > - wait(&child_status); > > + ASSERT_LE(0, wait(&child_status)) << strerror(errno); > > Don=E2=80=99t you want ASSERT_GE here, since you=E2=80=99re testing that = wait succeeded? > -Enji Opposite operand order. I'm asserting that 0 is less than or equal to wait's return value. -Alan From owner-svn-src-projects@freebsd.org Tue Apr 2 18:51:04 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 134C91570112 for ; Tue, 2 Apr 2019 18:51:04 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9B5AE721BF; Tue, 2 Apr 2019 18:51:02 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-pl1-x62f.google.com with SMTP id w24so318072plp.2; Tue, 02 Apr 2019 11:51:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=0r3dyu4gPQV/0ZI5C2ryoJAfgk5K3GaxT3DbTuAWh5c=; b=bmLlftprRtxnieWqX6lwAEaqvW9/n883LH6m8LCUT+oNTTXUuzclcHznVpjOjhcg88 UDBkV2L1hKNWfzxUdm38kO8oxR5rizYWvu8CLaPvZlI4qc/LVj7RMTQESEXrR/9UteZt TF9yptGxqOpbdlfBLWtQfrremGbdpGRXG3FZOV0UB+HijmPqseQxVODfX6p901U7TXpH XYT+XbHvtbhFcWjTeQb4oOznvVvJbNh6J+9Usr3n68T5TIOljiVuRYoSmBDhuXJ3bIjF lLEXWF7aVRTXh/PV8w6aK9Ur1WpWgilfx46TxvfeKiRleB0lKjA33Qs+6h6dQO4Ewsoa t+hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=0r3dyu4gPQV/0ZI5C2ryoJAfgk5K3GaxT3DbTuAWh5c=; b=c+ISgUrnkv2lPSO+D6evKa6h50kfRhdF84fYklmwtEhfpRZL5Yb4tAUHolQ/R+RR3U UWk9Q1QNpsQ2duDGHjiZ1Kn/6khoCdG2TR+ppdmbZ2B6PRbftadGQ/yxaxnN5F0tx7PZ nN5iTy0Jo6bWVAcxHTDkStzHSvHVdd+q08+avMXbZDoVj/5blmoh9ywDPWnzxNJr/BY6 +kW6SOK9i1AIZMaZSnvZtBgrxNkcG2Czx5t7sIxKT6EgKg8nbo1SWP4CdqgILxp3sbP0 ZED0XCwNjXhLbaxqSb1zbZAjZsRcSIWMTmIfa/HUYD28RVXMJsqTYk739nBxN4RDtwAl 6tzw== X-Gm-Message-State: APjAAAVbSP/zeYMtORn0w2qnhZUDP064yCPdso6HiQIQZpBpaqD/Demj lGId5QyNuriZ2tiQeILs9CeCuenpwAw= X-Google-Smtp-Source: APXvYqwPVafnRVtPwk9aTb12GQHLqaPYAhgKidrvmlQQoUhm4wUqChYCp+9ixsMZdo9NiYGa+ucTIQ== X-Received: by 2002:a17:902:f089:: with SMTP id go9mr31826442plb.309.1554231058364; Tue, 02 Apr 2019 11:50:58 -0700 (PDT) Received: from [192.168.20.7] (c-73-19-52-228.hsd1.wa.comcast.net. [73.19.52.228]) by smtp.gmail.com with ESMTPSA id t64sm33852261pfa.86.2019.04.02.11.50.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Apr 2019 11:50:57 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: svn commit: r345809 - projects/fuse2/tests/sys/fs/fusefs From: Enji Cooper In-Reply-To: Date: Tue, 2 Apr 2019 11:50:56 -0700 Cc: src-committers , svn-src-projects@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <1590D5B3-58F2-4086-8717-804AB5F89B69@gmail.com> References: <201904021844.x32Ii1wR041319@repo.freebsd.org> <77D06D49-8CE8-483C-90FF-D8CD0122599E@gmail.com> To: Alan Somers X-Mailer: Apple Mail (2.3445.102.3) X-Rspamd-Queue-Id: 9B5AE721BF X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.99 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.99)[-0.992,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 18:51:04 -0000 > On Apr 2, 2019, at 11:49 AM, Alan Somers wrote: >=20 > On Tue, Apr 2, 2019 at 12:45 PM Enji Cooper = wrote: >>=20 >>=20 >>> On Apr 2, 2019, at 11:44 AM, Alan Somers = wrote: >>>=20 >>> Author: asomers >>> Date: Tue Apr 2 18:44:01 2019 >>> New Revision: 345809 >>> URL: https://svnweb.freebsd.org/changeset/base/345809 >>>=20 >>> Log: >>> fusefs: check return value of wait(2) in fork tests >>>=20 >>> Reported by: ngie >>> Sponsored by: The FreeBSD Foundation >>>=20 >>> Modified: >>> projects/fuse2/tests/sys/fs/fusefs/utils.cc >>>=20 >>> Modified: projects/fuse2/tests/sys/fs/fusefs/utils.cc >>> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >>> --- projects/fuse2/tests/sys/fs/fusefs/utils.cc Tue Apr 2 = 18:09:40 2019 (r345808) >>> +++ projects/fuse2/tests/sys/fs/fusefs/utils.cc Tue Apr 2 = 18:44:01 2019 (r345809) >>> @@ -321,7 +321,7 @@ out: >>> /* Signal the child process to go */ >>> ASSERT_EQ(0, sem_post(sem)) << strerror(errno); >>>=20 >>> - wait(&child_status); >>> + ASSERT_LE(0, wait(&child_status)) << strerror(errno); >>=20 >> Don=E2=80=99t you want ASSERT_GE here, since you=E2=80=99re testing = that wait succeeded? >> -Enji >=20 > Opposite operand order. I'm asserting that 0 is less than or equal to > wait's return value. Ah, yes. Derp. Thank you for correcting me on that :D. -Enji From owner-svn-src-projects@freebsd.org Tue Apr 2 19:20:56 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 48B581570D0C for ; Tue, 2 Apr 2019 19:20:56 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E0C2573537; Tue, 2 Apr 2019 19:20:55 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BBC562734; Tue, 2 Apr 2019 19:20:55 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x32JKt73058256; Tue, 2 Apr 2019 19:20:55 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x32JKts3058255; Tue, 2 Apr 2019 19:20:55 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904021920.x32JKts3058255@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Tue, 2 Apr 2019 19:20:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345814 - projects/fuse2/sys/fs/fuse X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: projects/fuse2/sys/fs/fuse X-SVN-Commit-Revision: 345814 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E0C2573537 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.954,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 19:20:56 -0000 Author: asomers Date: Tue Apr 2 19:20:55 2019 New Revision: 345814 URL: https://svnweb.freebsd.org/changeset/base/345814 Log: fusefs: fix a just-introduced panic in readdir r345808 changed the interface of fuse_filehandle_open, but failed to update one caller. Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/sys/fs/fuse/fuse_vnops.c Modified: projects/fuse2/sys/fs/fuse/fuse_vnops.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_vnops.c Tue Apr 2 19:08:06 2019 (r345813) +++ projects/fuse2/sys/fs/fuse/fuse_vnops.c Tue Apr 2 19:20:55 2019 (r345814) @@ -1320,7 +1320,11 @@ fuse_vnop_readdir(struct vop_readdir_args *ap) if ((err = fuse_filehandle_get_dir(vp, &fufh, cred, pid)) != 0) { SDT_PROBE2(fuse, , vnops, trace, 1, "calling readdir() before open()"); - err = fuse_filehandle_open(vp, O_RDONLY, &fufh, NULL, cred); + /* + * This was seen to happen in getdirentries as used by + * shells/fish, but I can't reproduce it. + */ + err = fuse_filehandle_open(vp, FREAD, &fufh, NULL, cred); freefufh = 1; } if (err) { From owner-svn-src-projects@freebsd.org Wed Apr 3 02:29:57 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 38D0A155794B for ; Wed, 3 Apr 2019 02:29:57 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D40188B53C; Wed, 3 Apr 2019 02:29:56 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AF6F67473; Wed, 3 Apr 2019 02:29:56 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x332TugG086699; Wed, 3 Apr 2019 02:29:56 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x332Tusu086697; Wed, 3 Apr 2019 02:29:56 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904030229.x332Tusu086697@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Wed, 3 Apr 2019 02:29:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345823 - in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Commit-Revision: 345823 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D40188B53C X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.967,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 02:29:57 -0000 Author: asomers Date: Wed Apr 3 02:29:56 2019 New Revision: 345823 URL: https://svnweb.freebsd.org/changeset/base/345823 Log: fusefs: during ftruncate, discard cached data past truncation point During truncate, fusefs was discarding entire cached blocks, but it wasn't zeroing out the unused portion of a final partial block. This resulted in reads returning stale data. PR: 233783 Reported by: fsx Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/sys/fs/fuse/fuse_node.c projects/fuse2/tests/sys/fs/fusefs/setattr.cc Modified: projects/fuse2/sys/fs/fuse/fuse_node.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_node.c Wed Apr 3 01:30:59 2019 (r345822) +++ projects/fuse2/sys/fs/fuse/fuse_node.c Wed Apr 3 02:29:56 2019 (r345823) @@ -79,6 +79,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -413,17 +414,45 @@ fuse_vnode_setsize(struct vnode *vp, struct ucred *cre { struct fuse_vnode_data *fvdat = VTOFUD(vp); off_t oldsize; + size_t iosize; + struct buf *bp = NULL; int err = 0; ASSERT_VOP_ELOCKED(vp, "fuse_vnode_setsize"); + iosize = fuse_iosize(vp); oldsize = fvdat->filesize; fvdat->filesize = newsize; fvdat->flag |= FN_SIZECHANGE; if (newsize < oldsize) { + daddr_t lbn; + size_t zsize; + err = vtruncbuf(vp, cred, newsize, fuse_iosize(vp)); + if (err) + goto out; + if (newsize % iosize == 0) + goto out; + /* + * Zero the contents of the last partial block. + * Sure seems like vtruncbuf should do this for us. + */ + + lbn = newsize / iosize; + bp = getblk(vp, lbn, iosize, PCATCH, 0, 0); + if (!bp) { + err = EINTR; + goto out; + } + if (!(bp->b_flags & B_CACHE)) + goto out; /* Nothing to do */ + zsize = (lbn + 1) * iosize - newsize; + bzero(bp->b_data + newsize - lbn * iosize, zsize); } +out: + if (bp) + brelse(bp); vnode_pager_setsize(vp, newsize); return err; } Modified: projects/fuse2/tests/sys/fs/fusefs/setattr.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/setattr.cc Wed Apr 3 01:30:59 2019 (r345822) +++ projects/fuse2/tests/sys/fs/fusefs/setattr.cc Wed Apr 3 02:29:56 2019 (r345823) @@ -366,6 +366,116 @@ TEST_F(Setattr, truncate) { EXPECT_EQ(0, truncate(FULLPATH, newsize)) << strerror(errno); } +/* + * Truncating a file should discard cached data past the truncation point. + * This is a regression test for bug 233783. The bug only applies when + * vfs.fusefs.data_cache_mode=1 or 2, but the test should pass regardless. + */ +TEST_F(Setattr, truncate_discards_cached_data) { + const char FULLPATH[] = "mountpoint/some_file.txt"; + const char RELPATH[] = "some_file.txt"; + void *w0buf, *rbuf, *expected; + off_t w0_offset = 0x1b8df; + size_t w0_size = 0x61e8; + off_t r_offset = 0xe1e6; + off_t r_size = 0xe229; + size_t trunc0_size = 0x10016; + size_t trunc1_size = 131072; + size_t cur_size = 0; + const uint64_t ino = 42; + mode_t mode = S_IFREG | 0644; + int fd; + + w0buf = malloc(w0_size); + ASSERT_NE(NULL, w0buf) << strerror(errno); + memset(w0buf, 'X', w0_size); + + rbuf = malloc(r_size); + ASSERT_NE(NULL, rbuf) << strerror(errno); + + expected = malloc(r_size); + ASSERT_NE(NULL, expected) << strerror(errno); + memset(expected, 0, r_size); + + expect_lookup(RELPATH, ino, mode, 0, 1); + expect_open(ino, O_RDWR, 1); + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in->header.opcode == FUSE_GETATTR && + in->header.nodeid == ino); + }, Eq(true)), + _) + ).WillRepeatedly(Invoke(ReturnImmediate([&](auto i __unused, auto out) { + SET_OUT_HEADER_LEN(out, attr); + out->body.attr.attr.ino = ino; + out->body.attr.attr.mode = mode; + out->body.attr.attr.size = cur_size; + }))); + /* + * The exact pattern of FUSE_WRITE operations depends on the setting of + * vfs.fusefs.data_cache_mode. But it's not important for this test. + * Just set the mocks to accept anything + */ + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in->header.opcode == FUSE_WRITE); + }, Eq(true)), + _) + ).WillRepeatedly(Invoke(ReturnImmediate([&](auto in, auto out) { + SET_OUT_HEADER_LEN(out, write); + out->body.attr.attr.ino = ino; + out->body.write.size = in->body.write.size; + cur_size = std::max(cur_size, + in->body.write.size + in->body.write.offset); + }))); + + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in->header.opcode == FUSE_SETATTR && + in->header.nodeid == ino && + (in->body.setattr.valid & FATTR_SIZE)); + }, Eq(true)), + _) + ).WillRepeatedly(Invoke(ReturnImmediate([&](auto in, auto out) { + auto trunc_size = in->body.setattr.size; + SET_OUT_HEADER_LEN(out, attr); + out->body.attr.attr.ino = ino; + out->body.attr.attr.mode = mode; + out->body.attr.attr.size = trunc_size; + cur_size = trunc_size; + }))); + + /* exact pattern of FUSE_READ depends on vfs.fusefs.data_cache_mode */ + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in->header.opcode == FUSE_READ); + }, Eq(true)), + _) + ).WillRepeatedly(Invoke(ReturnImmediate([&](auto in, auto out) { + auto osize = std::min(cur_size - in->body.read.offset, + (size_t)in->body.read.size); + out->header.len = sizeof(struct fuse_out_header) + osize; + bzero(out->body.bytes, osize); + }))); + + fd = open(FULLPATH, O_RDWR, 0644); + ASSERT_LE(0, fd) << strerror(errno); + + ASSERT_EQ((ssize_t)w0_size, pwrite(fd, w0buf, w0_size, w0_offset)); + /* 1st truncate should discard cached data */ + EXPECT_EQ(0, ftruncate(fd, trunc0_size)) << strerror(errno); + /* 2nd truncate extends file into previously cached data */ + EXPECT_EQ(0, ftruncate(fd, trunc1_size)) << strerror(errno); + /* Read should return all zeros */ + ASSERT_EQ((ssize_t)r_size, pread(fd, rbuf, r_size, r_offset)); + + ASSERT_EQ(0, memcmp(expected, rbuf, r_size)); + + free(expected); + free(rbuf); + free(w0buf); +} + /* Change a file's timestamps */ TEST_F(Setattr, utimensat) { const char FULLPATH[] = "mountpoint/some_file.txt"; From owner-svn-src-projects@freebsd.org Wed Apr 3 02:46:58 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 513B815587E4 for ; Wed, 3 Apr 2019 02:46:58 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EA92F8C09E; Wed, 3 Apr 2019 02:46:57 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C310C77DC; Wed, 3 Apr 2019 02:46:57 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x332kvOQ096863; Wed, 3 Apr 2019 02:46:57 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x332kvpk096862; Wed, 3 Apr 2019 02:46:57 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904030246.x332kvpk096862@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Wed, 3 Apr 2019 02:46:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345824 - projects/runtime-coverage-v2 X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/runtime-coverage-v2 X-SVN-Commit-Revision: 345824 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: EA92F8C09E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.965,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 02:46:58 -0000 Author: ngie Date: Wed Apr 3 02:46:57 2019 New Revision: 345824 URL: https://svnweb.freebsd.org/changeset/base/345824 Log: Restart work started as ^/projects/runtime-coverage The intent of this project branch is as follows (using r320180's commit message): ``` Start project branch for integrating runtime coverage instrumentation in to the build Runtime coverage instrumentation is typically used/useful with gcov/lcov, and helps developers gather information about how many times lines/branches are hit, etc in order to help them improve tests for libraries/programs. gcov statistics are separate from gprof statistics. ``` Added: - copied from r345823, head/ Directory Properties: projects/runtime-coverage-v2/ (props changed) From owner-svn-src-projects@freebsd.org Wed Apr 3 03:23:51 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 578221559C4D for ; Wed, 3 Apr 2019 03:23:51 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EFBD38D963; Wed, 3 Apr 2019 03:23:50 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CB6F97F16; Wed, 3 Apr 2019 03:23:50 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x333NoZY018885; Wed, 3 Apr 2019 03:23:50 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x333Nkcp018859; Wed, 3 Apr 2019 03:23:46 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904030323.x333Nkcp018859@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Wed, 3 Apr 2019 03:23:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345825 - in projects/runtime-coverage-v2: . etc etc/mtree libexec/rtld-elf share/man/man7 share/mk stand tests tests/tools tools/build/options X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: in projects/runtime-coverage-v2: . etc etc/mtree libexec/rtld-elf share/man/man7 share/mk stand tests tests/tools tools/build/options X-SVN-Commit-Revision: 345825 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: EFBD38D963 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.981,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 03:23:51 -0000 Author: ngie Date: Wed Apr 3 03:23:45 2019 New Revision: 345825 URL: https://svnweb.freebsd.org/changeset/base/345825 Log: Merge all changes over from ^/projects/runtime-coverage This is being done to provide a starting point for this branch, given lessons learned doing the work on that branch. Added: projects/runtime-coverage-v2/etc/mtree/BSD.coverage.dist (contents, props changed) projects/runtime-coverage-v2/share/mk/bsd.cov.mk (contents, props changed) projects/runtime-coverage-v2/tests/tools/ projects/runtime-coverage-v2/tests/tools/Makefile (contents, props changed) projects/runtime-coverage-v2/tests/tools/gather_coverage.sh (contents, props changed) projects/runtime-coverage-v2/tools/build/options/WITH_COVERAGE (contents, props changed) Modified: projects/runtime-coverage-v2/Makefile projects/runtime-coverage-v2/Makefile.inc1 projects/runtime-coverage-v2/Makefile.libcompat projects/runtime-coverage-v2/etc/Makefile projects/runtime-coverage-v2/etc/mtree/BSD.tests.dist projects/runtime-coverage-v2/etc/mtree/Makefile projects/runtime-coverage-v2/libexec/rtld-elf/Makefile projects/runtime-coverage-v2/share/man/man7/hier.7 projects/runtime-coverage-v2/share/mk/Makefile projects/runtime-coverage-v2/share/mk/bsd.lib.mk projects/runtime-coverage-v2/share/mk/bsd.opts.mk projects/runtime-coverage-v2/share/mk/bsd.own.mk projects/runtime-coverage-v2/share/mk/bsd.prog.mk projects/runtime-coverage-v2/share/mk/meta.autodep.mk projects/runtime-coverage-v2/share/mk/src.opts.mk projects/runtime-coverage-v2/share/mk/suite.test.mk projects/runtime-coverage-v2/stand/defs.mk projects/runtime-coverage-v2/tests/Makefile Modified: projects/runtime-coverage-v2/Makefile ============================================================================== --- projects/runtime-coverage-v2/Makefile Wed Apr 3 02:46:57 2019 (r345824) +++ projects/runtime-coverage-v2/Makefile Wed Apr 3 03:23:45 2019 (r345825) @@ -497,7 +497,7 @@ TARGET_ARCHES_riscv?= riscv64 TARGET_ARCHES_${target}?= ${target} .endfor -MAKE_PARAMS_riscv?= CROSS_TOOLCHAIN=riscv64-gcc +MAKE_PARAMS_riscv?= CROSS_TOOLCHAIN=riscv64-gcc MK_COVERAGE=no # XXX Remove architectures only supported by external toolchain from universe # if required toolchain packages are missing. Modified: projects/runtime-coverage-v2/Makefile.inc1 ============================================================================== --- projects/runtime-coverage-v2/Makefile.inc1 Wed Apr 3 02:46:57 2019 (r345824) +++ projects/runtime-coverage-v2/Makefile.inc1 Wed Apr 3 03:23:45 2019 (r345825) @@ -248,7 +248,7 @@ WANT_COMPILER_VERSION!= \ awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3}' \ ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown .endif -.export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_VERSION +.export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_TYPE WANT_COMPILER_VERSION .endif # !defined(WANT_COMPILER_FREEBSD_VERSION) # It needs to be the same revision as we would build for the bootstrap. @@ -688,7 +688,7 @@ BSARGS= DESTDIR= \ BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \ BWPHASE=${.TARGET:C,^_,,} \ SSP_CFLAGS= \ - MK_HTML=no NO_LINT=yes MK_MAN=no \ + MK_COVERAGE=no MK_HTML=no NO_LINT=yes MK_MAN=no \ -DNO_PIC MK_PROFILE=no -DNO_SHARED \ -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \ MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \ @@ -734,7 +734,7 @@ KTMAKE= \ MAKEOBJDIRPREFIX= \ BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \ SSP_CFLAGS= \ - MK_HTML=no -DNO_LINT MK_MAN=no \ + MK_COVERAGE=no MK_HTML=no -DNO_LINT MK_MAN=no \ -DNO_PIC MK_PROFILE=no -DNO_SHARED \ -DNO_CPU_CFLAGS MK_RETPOLINE=no MK_WARNS=no MK_CTF=no @@ -1361,6 +1361,10 @@ distributeworld installworld stageworld: _installcheck -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \ -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null +.if ${MK_COVERAGE} != "no" + mtree -deU -f ${.CURDIR}/etc/mtree/BSD.cov.dist \ + -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null +.endif .if ${MK_DEBUG_FILES} != "no" ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null @@ -2712,6 +2716,14 @@ _prereq_libs= lib/libcompiler_rt _prereq_libs+= gnu/lib/libssp/libssp_nonshared .endif +# +# The coverage libraries must be built for the target prior to ${_startup_libs} +# for world to have runtime coverage instrumentation. +# +.if ${MK_COVERAGE} != "no" +_prereq_libs+= lib/libclang_rt/profile +.endif + # These dependencies are not automatically generated: # # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before @@ -2960,7 +2972,7 @@ ${_lib}__PL: .PHONY .MAKE if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \ ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \ DIRPRFX=${_lib}/ all; \ - ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \ + ${MAKE} MK_COVERAGE=no MK_TESTS=no MK_PROFILE=no -DNO_PIC \ DIRPRFX=${_lib}/ install .endif .endfor @@ -2972,7 +2984,7 @@ ${_lib}__L: .PHONY .MAKE cd ${.CURDIR}/${_lib}; \ if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \ ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \ - ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install + ${MAKE} MK_COVERAGE=no MK_TESTS=no DIRPRFX=${_lib}/ install .endif .endfor @@ -3239,7 +3251,7 @@ XDEV_CPUTYPE?=${CPUTYPE} XDEV_CPUTYPE?=${TARGET_CPUTYPE} .endif -NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \ +NOFUN= MK_COVERAGE=no -DNO_FSCHG MK_HTML=no -DNO_LINT \ MK_MAN=no MK_NLS=no MK_PROFILE=no \ MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \ TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ Modified: projects/runtime-coverage-v2/Makefile.libcompat ============================================================================== --- projects/runtime-coverage-v2/Makefile.libcompat Wed Apr 3 02:46:57 2019 (r345824) +++ projects/runtime-coverage-v2/Makefile.libcompat Wed Apr 3 03:23:45 2019 (r345825) @@ -122,6 +122,7 @@ LIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \ CPP="${XCPP} ${LIBCOMPATCFLAGS}" \ DESTDIR=${LIBCOMPATTMP} \ -DNO_CPU_CFLAGS \ + MK_COVERAGE=no \ MK_CTF=no \ -DNO_LINT \ MK_TESTS=no Modified: projects/runtime-coverage-v2/etc/Makefile ============================================================================== --- projects/runtime-coverage-v2/etc/Makefile Wed Apr 3 02:46:57 2019 (r345824) +++ projects/runtime-coverage-v2/etc/Makefile Wed Apr 3 03:23:45 2019 (r345825) @@ -126,18 +126,22 @@ MTREES= mtree/BSD.root.dist / \ mtree/BSD.var.dist /var \ mtree/BSD.usr.dist /usr \ mtree/BSD.include.dist /usr/include \ + mtree/BSD.coverage.dist /usr/lib \ mtree/BSD.debug.dist /usr/lib .if ${MK_LIB32} != "no" -MTREES+= mtree/BSD.lib32.dist /usr -MTREES+= mtree/BSD.lib32.dist /usr/lib/debug/usr +.for dir in /usr /usr/lib/cov/usr /usr/lib/debug/usr +MTREES+= mtree/BSD.lib32.dist ${dir} +.endfor .endif .if ${MK_LIBSOFT} != "no" -MTREES+= mtree/BSD.libsoft.dist /usr -MTREES+= mtree/BSD.libsoft.dist /usr/lib/debug/usr +.for dir in /usr /usr/lib/cov/usr /usr/lib/debug/usr +MTREES+= mtree/BSD.libsoft.dist ${dir} +.endfor .endif .if ${MK_TESTS} != "no" -MTREES+= mtree/BSD.tests.dist ${TESTSBASE} -MTREES+= mtree/BSD.tests.dist /usr/lib/debug/${TESTSBASE} +.for dir in ${TESTSBASE} /usr/lib/cov/${TESTSBASE} /usr/lib/debug/${TESTSBASE} +MTREES+= mtree/BSD.tests.dist ${dir} +.endfor .endif .if ${MK_SENDMAIL} != "no" MTREES+= mtree/BSD.sendmail.dist / Added: projects/runtime-coverage-v2/etc/mtree/BSD.coverage.dist ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/runtime-coverage-v2/etc/mtree/BSD.coverage.dist Wed Apr 3 03:23:45 2019 (r345825) @@ -0,0 +1,70 @@ +# $FreeBSD$ +# +# Please see the file src/etc/mtree/README before making changes to this file. +# + +/set type=dir uname=root gname=wheel mode=0755 +. + cov + bin + .. + boot + kernel + .. + modules + .. + .. + lib + casper + .. + geom + .. + .. + libexec + .. + sbin + .. + usr + bin + .. + lib + clang + 8.0.0 + include + sanitizer + .. + .. + lib + freebsd + .. + .. + .. + .. + engines + .. + i18n + .. + libxo + encoder + .. + .. + .. + libexec + bsdinstall + .. + lpr + ru + .. + .. + sendmail + .. + sm.bin + .. + .. + sbin + .. + tests + .. + .. + .. +.. Modified: projects/runtime-coverage-v2/etc/mtree/BSD.tests.dist ============================================================================== --- projects/runtime-coverage-v2/etc/mtree/BSD.tests.dist Wed Apr 3 02:46:57 2019 (r345824) +++ projects/runtime-coverage-v2/etc/mtree/BSD.tests.dist Wed Apr 3 03:23:45 2019 (r345825) @@ -825,6 +825,8 @@ vm .. .. + tools + .. usr.bin apply .. Modified: projects/runtime-coverage-v2/etc/mtree/Makefile ============================================================================== --- projects/runtime-coverage-v2/etc/mtree/Makefile Wed Apr 3 02:46:57 2019 (r345824) +++ projects/runtime-coverage-v2/etc/mtree/Makefile Wed Apr 3 03:23:45 2019 (r345825) @@ -5,6 +5,7 @@ # NOTE: BSD.debug.dist is unconditionally installed for developer ease-of-use. FILES= \ BSD.debug.dist \ + ${_BSD.coverage.dist} \ BSD.include.dist \ BSD.root.dist \ ${_BSD.lib32.dist} \ @@ -14,6 +15,9 @@ FILES= \ BSD.usr.dist \ BSD.var.dist +.if ${MK_COVERAGE} != "no" +_BSD.coverage.dist= BSD.coverage.dist +.endif .if ${MK_LIB32} != "no" _BSD.lib32.dist= BSD.lib32.dist .endif Modified: projects/runtime-coverage-v2/libexec/rtld-elf/Makefile ============================================================================== --- projects/runtime-coverage-v2/libexec/rtld-elf/Makefile Wed Apr 3 02:46:57 2019 (r345824) +++ projects/runtime-coverage-v2/libexec/rtld-elf/Makefile Wed Apr 3 03:23:45 2019 (r345825) @@ -6,6 +6,7 @@ .include PACKAGE= clibs +MK_COVERAGE= no MK_PIE= no # Always position independent using local rules MK_SSP= no Modified: projects/runtime-coverage-v2/share/man/man7/hier.7 ============================================================================== --- projects/runtime-coverage-v2/share/man/man7/hier.7 Wed Apr 3 02:46:57 2019 (r345824) +++ projects/runtime-coverage-v2/share/man/man7/hier.7 Wed Apr 3 03:23:45 2019 (r345825) @@ -359,6 +359,8 @@ shared libraries for compatibility .It Pa aout/ a.out backward compatibility libraries .El +.It Pa cov/ +standalone coverage data for base system libraries and binaries .It Pa debug/ standalone debug data for the kernel and base system libraries and binaries .It Pa dtrace/ Modified: projects/runtime-coverage-v2/share/mk/Makefile ============================================================================== --- projects/runtime-coverage-v2/share/mk/Makefile Wed Apr 3 02:46:57 2019 (r345824) +++ projects/runtime-coverage-v2/share/mk/Makefile Wed Apr 3 03:23:45 2019 (r345825) @@ -71,6 +71,10 @@ FILES= \ FILESDIR= ${BINDIR}/mk +.if ${MK_COVERAGE} != "no" +FILES+= bsd.cov.mk +.endif + .if ${MK_TESTS} != "no" FILES+= atf.test.mk FILES+= googletest.test.inc.mk Added: projects/runtime-coverage-v2/share/mk/bsd.cov.mk ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/runtime-coverage-v2/share/mk/bsd.cov.mk Wed Apr 3 03:23:45 2019 (r345825) @@ -0,0 +1,38 @@ +# $FreeBSD$ +# +# Snippet for dealing with runtime coverage logic. +# +# .gcno files are generated from files that are compiled from source, e.g., +# foo.gcno is foo.c or foo.cpp's file. In order for the libraries and programs +# to be properly instrumented, the .gcno files must be installed to a prefix +# common to the object files. +# +# See gcov(1) for more details. + +.include + +FILESGROUPS?= FILES + +.if !empty(GCNOS) + +GCNOSOWN?= ${BINOWN} +GCNOSGRP?= ${BINGRP} +GCNOSMODE?= 0644 +GCNOSDIRMODE?= 0755 + +GCNOS:= ${GCNOS:O:u} +FILESGROUPS+= GCNOS +CLEANFILES+= ${GCNOS} + +.for _gcno in ${GCNOS} +_gcno_dir:= ${COVERAGEDIR}${_gcno:H:tA} +GCNOSDIR_${_gcno:T}:= ${_gcno_dir} +# Create _gcno_dir if it doesn't already exist. +.if !target(${DESTDIR}${_gcno_dir}) +${DESTDIR}${_gcno_dir}: + ${INSTALL} -d -o ${GCNOSOWN} -g ${GCNOSGRP} -m ${GCNOSDIRMODE} \ + ${.TARGET}/ +beforeinstall: ${DESTDIR}${_gcno_dir} +.endif +.endfor +.endif Modified: projects/runtime-coverage-v2/share/mk/bsd.lib.mk ============================================================================== --- projects/runtime-coverage-v2/share/mk/bsd.lib.mk Wed Apr 3 02:46:57 2019 (r345824) +++ projects/runtime-coverage-v2/share/mk/bsd.lib.mk Wed Apr 3 03:23:45 2019 (r345825) @@ -3,6 +3,7 @@ # .include +.include .if defined(LIB_CXX) || defined(SHLIB_CXX) _LD= ${CXX} @@ -54,6 +55,7 @@ CFLAGS+= ${DEBUG_FLAGS} .if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != "" CTFFLAGS+= -g .endif +_WANTS_DEBUG= .else STRIP?= -s .endif @@ -111,6 +113,10 @@ PO_FLAG=-pg ${CTFCONVERT_CMD} .c.pico: + ${CC} ${PICFLAG} -DPIC ${SHARED_CFLAGS} ${_COV_FLAG} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} + ${CTFCONVERT_CMD} + +.c.ppico: ${CC} ${PICFLAG} -DPIC ${SHARED_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} ${CTFCONVERT_CMD} @@ -126,6 +132,9 @@ PO_FLAG=-pg ${CXX} ${PO_FLAG} ${STATIC_CXXFLAGS} ${PO_CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} .cc.pico .C.pico .cpp.pico .cxx.pico: + ${CXX} ${PICFLAG} -DPIC ${SHARED_CXXFLAGS} ${_COV_FLAG} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} + +.cc.ppico .C.ppico .cpp.ppico .cxx.ppico: ${CXX} ${PICFLAG} -DPIC ${SHARED_CXXFLAGS} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} .cc.nossppico .C.nossppico .cpp.nossppico .cxx.nossppico: @@ -196,6 +205,12 @@ _SHLIBDIR:=${SHLIBDIR} .if defined(SHLIB_NAME) .if ${MK_DEBUG_FILES} != "no" SHLIB_NAME_FULL=${SHLIB_NAME}.full +.if ${MK_COVERAGE} != "no" +COVERAGEFILEDIR=${COVERAGEDIR}${_SHLIBDIR} +.if !exists(${DESTDIR}${COVERAGEFILEDIR}) +COVERAGEMKDIR= +.endif +.endif # Use ${DEBUGDIR} for base system debug files, else .debug subdirectory .if ${_SHLIBDIR} == "/boot" ||\ ${SHLIBDIR:C%/lib(/.*)?$%/lib%} == "/lib" ||\ @@ -275,6 +290,9 @@ CLEANFILES+= ${SOBJS} .if defined(SHLIB_NAME) _LIBS+= ${SHLIB_NAME} +.if defined(_COV_FLAG) +SOLINKOPTS+= ${_COV_FLAG} +.endif SOLINKOPTS+= -shared -Wl,-x .if defined(LD_FATAL_WARNINGS) && ${LD_FATAL_WARNINGS} == "no" SOLINKOPTS+= -Wl,--no-fatal-warnings @@ -332,10 +350,18 @@ ${SHLIB_NAME}.debug: ${SHLIB_NAME_FULL} .if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no" _LIBS+= lib${LIB_PRIVATE}${LIB}_pic.a -lib${LIB_PRIVATE}${LIB}_pic.a: ${SOBJS} +.if ${MK_COVERAGE} != "no" +PIC_OBJS:= ${SOBJS:.pico=.ppico} +DEPENDOBJS+= ${PIC_OBJS} +CLEANFILES+= ${PIC_OBJS} +.else +PIC_OBJS:= ${SOBJS} +.endif + +lib${LIB_PRIVATE}${LIB}_pic.a: ${PIC_OBJS} @${ECHO} building special pic ${LIB} library @rm -f ${.TARGET} - ${AR} ${ARFLAGS} ${.TARGET} ${SOBJS} ${ARADD} + ${AR} ${ARFLAGS} ${.TARGET} ${PIC_OBJS} ${ARADD} ${RANLIB} ${RANLIBFLAGS} ${.TARGET} .endif @@ -429,6 +455,14 @@ _libinstall: ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \ ${SHLIB_NAME} ${DESTDIR}${_SHLIBDIR}/ .if ${MK_DEBUG_FILES} != "no" +.if ${MK_COVERAGE} != "no" +.if defined(COVERAGEMKDIR) + ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},coverage} -d ${DESTDIR}${COVERAGEFILEDIR}/ +.endif + ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},coverage} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${_INSTALLFLAGS} \ + ${SHLIB_NAME}.full ${DESTDIR}${COVERAGEFILEDIR}/${SHLIB_NAME} +.endif .if defined(DEBUGMKDIR) ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},debug} -d ${DESTDIR}${DEBUGFILEDIR}/ .endif @@ -509,6 +543,7 @@ OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.po+= $ defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) .for _S in ${SRCS:N*.[hly]} OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.pico+= ${_S} +OBJS_DEPEND_GUESS.${_S:R}.ppico+= ${_S} .endfor .endif .if defined(BUILD_NOSSP_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) Modified: projects/runtime-coverage-v2/share/mk/bsd.opts.mk ============================================================================== --- projects/runtime-coverage-v2/share/mk/bsd.opts.mk Wed Apr 3 02:46:57 2019 (r345824) +++ projects/runtime-coverage-v2/share/mk/bsd.opts.mk Wed Apr 3 03:23:45 2019 (r345825) @@ -71,10 +71,12 @@ __DEFAULT_YES_OPTIONS = \ __DEFAULT_NO_OPTIONS = \ BIND_NOW \ CCACHE_BUILD \ + COVERAGE \ CTF \ INSTALL_AS_USER \ PIE \ RETPOLINE \ + MAKE_CHECK_TEST_WITH_COVERAGE \ STALE_STAGED __DEFAULT_DEPENDENT_OPTIONS = \ @@ -85,6 +87,10 @@ __DEFAULT_DEPENDENT_OPTIONS = \ .include + +.if ${MK_COVERAGE} == "no" || ${MK_MAKE_CHECK_USE_SANDBOX} == "no" +MK_MAKE_CHECK_TEST_WITH_COVERAGE:= no +.endif # # Supported NO_* options (if defined, MK_* will be forced to "no", Modified: projects/runtime-coverage-v2/share/mk/bsd.own.mk ============================================================================== --- projects/runtime-coverage-v2/share/mk/bsd.own.mk Wed Apr 3 02:46:57 2019 (r345824) +++ projects/runtime-coverage-v2/share/mk/bsd.own.mk Wed Apr 3 03:23:45 2019 (r345825) @@ -40,6 +40,7 @@ # # LIBMODE Library mode. [${NOBINMODE}] # +# COVERAGEDIR Base path for coverage files. [/usr/lib/cov] # # DEBUGDIR Base path for standalone debug files. [/usr/lib/debug] # @@ -184,6 +185,8 @@ SHLIBDIR?= ${LIBDIR} LIBOWN?= ${BINOWN} LIBGRP?= ${BINGRP} LIBMODE?= ${NOBINMODE} + +COVERAGEDIR?= /usr/lib/cov DEBUGDIR?= /usr/lib/debug DEBUGMODE?= ${NOBINMODE} Modified: projects/runtime-coverage-v2/share/mk/bsd.prog.mk ============================================================================== --- projects/runtime-coverage-v2/share/mk/bsd.prog.mk Wed Apr 3 02:46:57 2019 (r345824) +++ projects/runtime-coverage-v2/share/mk/bsd.prog.mk Wed Apr 3 03:23:45 2019 (r345825) @@ -55,12 +55,15 @@ LDFLAGS+= -Wl,-zretpolineplt .if defined(CRUNCH_CFLAGS) CFLAGS+=${CRUNCH_CFLAGS} .else -.if ${MK_DEBUG_FILES} != "no" && empty(DEBUG_FLAGS:M-g) && \ - empty(DEBUG_FLAGS:M-gdwarf-*) +.if ${MK_DEBUG_FILES} != "no" +.if empty(DEBUG_FLAGS:M-g) && empty(DEBUG_FLAGS:M-gdwarf-*) CFLAGS+= ${DEBUG_FILES_CFLAGS} +CXXFLAGS+= -g CTFFLAGS+= -g .endif +_WANTS_DEBUG= .endif +.endif .if !defined(DEBUG_FLAGS) STRIP?= -s @@ -75,7 +78,13 @@ TAG_ARGS= -T ${TAGS:[*]:S/ /,/g} .if defined(NO_SHARED) && ${NO_SHARED:tl} != "no" LDFLAGS+= -static +.else +.if defined(_WANTS_DEBUG) && ${MK_COVERAGE} != "no" && ${COMPILER_FEATURES:Mc++11} +_COV_FLAG= --coverage -fprofile-dir=${COVERAGEDIR} +CFLAGS+= ${_COV_FLAG} +CXXFLAGS+= ${_COV_FLAG} .endif +.endif .if ${MK_DEBUG_FILES} != "no" PROG_FULL=${PROG}.full @@ -91,6 +100,12 @@ DEBUGFILEDIR= ${DEBUGDIR}${BINDIR} .else DEBUGFILEDIR?= ${BINDIR}/.debug .endif +.if ${MK_COVERAGE} != "no" +_COVERAGEDIR= ${COVERAGEDIR}${BINDIR} +.if !exists(${DESTDIR}${_COVERAGEDIR}) +COVERAGEMKDIR= +.endif +.endif .if !exists(${DESTDIR}${DEBUGFILEDIR}) DEBUGMKDIR= .endif @@ -255,6 +270,13 @@ _proginstall: ${INSTALL} ${TAG_ARGS} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} .if ${MK_DEBUG_FILES} != "no" +.if ${MK_COVERAGE} != "no" +.if defined(COVERAGEMKDIR) + ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},coverage} -d ${DESTDIR}${_COVERAGEDIR}/ +.endif + ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},coverage} -o ${BINOWN} -g ${BINGRP} -m ${DEBUGMODE} \ + ${PROG_FULL} ${DESTDIR}${_COVERAGEDIR}/${PROGNAME} +.endif .if defined(DEBUGMKDIR) ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},debug} -d ${DESTDIR}${DEBUGFILEDIR}/ .endif @@ -301,6 +323,15 @@ NLSNAME?= ${PROG} .include .include +.if defined(_COV_FLAG) && !empty(SRCS) +_GCNO_SRCS= ${SRCS:M*.c} ${SRCS:M*.cc} ${SRCS:M*.cpp} ${SRCS:M*.cxx} ${SRCS:M*.C} +GCNOS:= ${_GCNO_SRCS:R:S/$/.gcno/g} +.undef _GCNO_SRCS +.for _gcno in ${GCNOS} +${_gcno}: ${_gcno:R}.o +.endfor +.include +.endif .include .include Modified: projects/runtime-coverage-v2/share/mk/meta.autodep.mk ============================================================================== --- projects/runtime-coverage-v2/share/mk/meta.autodep.mk Wed Apr 3 02:46:57 2019 (r345824) +++ projects/runtime-coverage-v2/share/mk/meta.autodep.mk Wed Apr 3 03:23:45 2019 (r345825) @@ -22,11 +22,12 @@ __${_this}__: .NOTMAIN .-include PICO?= .pico +PPICO?= .ppico NOSSPPICO?= .nossppico .if defined(SRCS) # it would be nice to be able to query .SUFFIXES -OBJ_EXTENSIONS+= .o .po .lo ${PICO} ${NOSSPPICO} +OBJ_EXTENSIONS+= .o .po .lo ${PICO} ${PPICO} ${NOSSPPICO} # explicit dependencies help short-circuit .SUFFIX searches SRCS_DEP_FILTER+= N*.[hly] @@ -182,7 +183,7 @@ DEPEND_SUFFIXES += .c .h .cpp .hpp .cxx .hxx .cc .hh @case "${.MAKE.META.FILES:T:M*.po.*}" in \ *.po.*) mv $@.${.MAKE.PID} $@;; \ *) { cat $@.${.MAKE.PID}; \ - sed 's,\${NOSSPPICO}:,.o:,;s,\${PICO}:,.o:,;s,\.o:,.po:,' $@.${.MAKE.PID}; } | sort -u > $@; \ + sed 's,\${NOSSPPICO}:,.o:,;s,\${PICO}:,.o:,;s,\${PPICO}:,.o:,;s,\.o:,.po:,' $@.${.MAKE.PID}; } | sort -u > $@; \ rm -f $@.${.MAKE.PID};; \ esac .else Modified: projects/runtime-coverage-v2/share/mk/src.opts.mk ============================================================================== --- projects/runtime-coverage-v2/share/mk/src.opts.mk Wed Apr 3 02:46:57 2019 (r345824) +++ projects/runtime-coverage-v2/share/mk/src.opts.mk Wed Apr 3 03:23:45 2019 (r345825) @@ -295,6 +295,12 @@ __DEFAULT_NO_OPTIONS+=LLVM_TARGET_BPF # This means that architectures that have GCC 4.2 as default can not # build Clang without using an external compiler. +# Note about MK_COVERAGE: +# +# clang and gcc 4.8+ (c++11 supporting compilers) support -fprofile-dir and +# can compile lib/libclang_rt/profile . libgcov, etc, in base is a dead end +# that I do not wish to support. + .if ${COMPILER_FEATURES:Mc++11} && (${__T} == "aarch64" || \ ${__T} == "amd64" || ${__TT} == "arm" || ${__T} == "i386") # Clang is enabled, and will be installed as the default /usr/bin/cc. @@ -534,6 +540,7 @@ MK_LLD_BOOTSTRAP:= no .if ${MK_TOOLCHAIN} == "no" MK_BINUTILS:= no MK_CLANG:= no +MK_COVERAGE:= no MK_GCC:= no MK_GDB:= no MK_INCLUDES:= no Modified: projects/runtime-coverage-v2/share/mk/suite.test.mk ============================================================================== --- projects/runtime-coverage-v2/share/mk/suite.test.mk Wed Apr 3 02:46:57 2019 (r345824) +++ projects/runtime-coverage-v2/share/mk/suite.test.mk Wed Apr 3 03:23:45 2019 (r345825) @@ -79,6 +79,39 @@ Kyuafile: Makefile KYUA= ${LOCALBASE}/bin/kyua +MAKE_CHECK_SANDBOX_DIR= checkdir +CLEANDIRS+= ${MAKE_CHECK_SANDBOX_DIR} + +.if ${MK_MAKE_CHECK_USE_SANDBOX} != "no" && make(check) +DESTDIR:= ${.OBJDIR}/${MAKE_CHECK_SANDBOX_DIR} + +.if ${MK_MAKE_CHECK_TEST_WITH_COVERAGE} != "no" +GCOV?= gcov +GCOV_PREFIX?= ${DESTDIR} +TESTS_ENV+= GCOV=${GCOV} GCOV_PREFIX=${GCOV_PREFIX} +.endif + +beforecheck: +.for t in clean depend all +.for dir in ${SRCTOP}/tests/tools ${.CURDIR} + @cd ${dir} && ${MAKE} $t +.endfor +.endfor + @cd ${SRCTOP} && ${MAKE} hierarchy DESTDIR=${DESTDIR} +.for dir in ${SRCTOP}/tests/tools ${.CURDIR} + @cd ${dir} && ${MAKE} install DESTDIR=${DESTDIR} +.endfor + +# NOTE: this is intentional to ensure that "make check" can be run multiple +# times. "aftercheck" won't be run if "make check" fails, is interrupted, +# etc. +aftercheck: +.if ${MK_MAKE_CHECK_TEST_WITH_COVERAGE} != "no" + @env ${TESTS_ENV:Q} ${DESTDIR}${TESTSBASE}/tools/gather_coverage +.endif + @cd ${.CURDIR} && ${MAKE} clean +.endif + # Definition of the "make check" target and supporting variables. # # This target, by necessity, can only work for native builds (i.e. a FreeBSD Modified: projects/runtime-coverage-v2/stand/defs.mk ============================================================================== --- projects/runtime-coverage-v2/stand/defs.mk Wed Apr 3 02:46:57 2019 (r345824) +++ projects/runtime-coverage-v2/stand/defs.mk Wed Apr 3 03:23:45 2019 (r345825) @@ -7,6 +7,7 @@ __BOOT_DEFS_MK__=${MFILE} # because it includes bsd.own.mk which needs the right MK_ values, # espeically MK_CTF. +MK_COVERAGE= no MK_CTF= no MK_SSP= no MK_PROFILE= no Modified: projects/runtime-coverage-v2/tests/Makefile ============================================================================== --- projects/runtime-coverage-v2/tests/Makefile Wed Apr 3 02:46:57 2019 (r345824) +++ projects/runtime-coverage-v2/tests/Makefile Wed Apr 3 03:23:45 2019 (r345825) @@ -10,6 +10,7 @@ KYUAFILE= yes SUBDIR+= etc SUBDIR+= sys +SUBDIR+= tools SUBDIR_PARALLEL= Added: projects/runtime-coverage-v2/tests/tools/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/runtime-coverage-v2/tests/tools/Makefile Wed Apr 3 03:23:45 2019 (r345825) @@ -0,0 +1,11 @@ +# $FreeBSD$ + +.include + +BINDIR= ${TESTSBASE}/tools + +.if ${MK_COVERAGE} != "no" +SCRIPTS+= gather_coverage +.endif + +.include Added: projects/runtime-coverage-v2/tests/tools/gather_coverage.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/runtime-coverage-v2/tests/tools/gather_coverage.sh Wed Apr 3 03:23:45 2019 (r345825) @@ -0,0 +1,75 @@ +#!/bin/sh +# +# Copyright (c) 2017 Ngie Cooper +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ + +# usage: gather_coverage + +SCRIPT=${0##*/} + +: ${COVERAGE_OUTPUT=coverage-output} +: ${GCOV=gcov} +: ${GCOV_PREFIX=$(pwd)} + +error() +{ + printf >&2 "${SCRIPT}: ERROR: %s\n" "$@" +} + +require_command() +{ + local cmd=$1; shift + + if ! command -v $cmd >/dev/null; then + error "required command not found: $cmd" + if [ $# -gt 0 ]; then + printf >&2 "%s\n" "$@" + fi + exit 1 + fi +} + + + +require_command ${GCOV} \ + 'Install gcov from base, or specify alternate version, e.g., from ports, using $GCOV.' +for cmd in lcov genhtml; do + require_command ${cmd} "Install devel/lcov from ports." +done + +if ! COVERAGE_TMP=$(mktemp -d tmp.XXXXXX); then + error "failed to create COVERAGE_TMP." + exit 1 +fi +trap "rm -Rf '$COVERAGE_TMP'" EXIT INT TERM + +set -e + +lcov --gcov-tool ${GCOV} --capture --directory ${GCOV_PREFIX} --output-file \ + ${COVERAGE_TMP}/coverage.info +genhtml ${COVERAGE_TMP}/coverage.info --output-directory ${COVERAGE_OUTPUT} + +printf "${SCRIPT}: INFO: coverage output successfully placed in ${COVERAGE_OUTPUT}\n" Added: projects/runtime-coverage-v2/tools/build/options/WITH_COVERAGE ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/runtime-coverage-v2/tools/build/options/WITH_COVERAGE Wed Apr 3 03:23:45 2019 (r345825) @@ -0,0 +1,17 @@ +.\" $FreeBSD$ +Set to build profiled libraries for use with +.Xr gcov 1 , +.Xr lcov 1 , +etc. +.Em Warning: +this option is experimental. +Profiled libraries and binaries with runtime instrumentation built in will +consume large amounts of disk space (somewhere on the order of several +gigabytes). +.\" TODO: put this in build(7)? +GCDA files are installed to the +.Pa /usr/lib/cov +prefix. +.\" TODO: verify this claim in an e2e test. +The install directory mirrors the install path for the object directory, e.g., +.Pa /usr/lib/cov/usr/obj/lib/libc/stdio/vfprintf.gcda From owner-svn-src-projects@freebsd.org Wed Apr 3 05:08:17 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4D2C1155C97F for ; Wed, 3 Apr 2019 05:08:17 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E6C7A90FCD; Wed, 3 Apr 2019 05:08:16 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BB37990A9; Wed, 3 Apr 2019 05:08:16 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x3358GUa072023; Wed, 3 Apr 2019 05:08:16 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x3358G90072022; Wed, 3 Apr 2019 05:08:16 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904030508.x3358G90072022@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Wed, 3 Apr 2019 05:08:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345832 - projects/runtime-coverage-v2/share/mk X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/runtime-coverage-v2/share/mk X-SVN-Commit-Revision: 345832 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E6C7A90FCD X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.967,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 05:08:17 -0000 Author: ngie Date: Wed Apr 3 05:08:16 2019 New Revision: 345832 URL: https://svnweb.freebsd.org/changeset/base/345832 Log: bsd.prog.mk: fix some MK_COVERAGE logic * Remove a misleading test for clang and newer versions of gcc that support `--coverage` properly. * Handle .y (yacc) sources when defining `GCNOS` to unbreak the build with `bin/expr`. Modified: projects/runtime-coverage-v2/share/mk/bsd.prog.mk Modified: projects/runtime-coverage-v2/share/mk/bsd.prog.mk ============================================================================== --- projects/runtime-coverage-v2/share/mk/bsd.prog.mk Wed Apr 3 04:01:08 2019 (r345831) +++ projects/runtime-coverage-v2/share/mk/bsd.prog.mk Wed Apr 3 05:08:16 2019 (r345832) @@ -79,7 +79,7 @@ TAG_ARGS= -T ${TAGS:[*]:S/ /,/g} .if defined(NO_SHARED) && ${NO_SHARED:tl} != "no" LDFLAGS+= -static .else -.if defined(_WANTS_DEBUG) && ${MK_COVERAGE} != "no" && ${COMPILER_FEATURES:Mc++11} +.if defined(_WANTS_DEBUG) && ${MK_COVERAGE} != "no" _COV_FLAG= --coverage -fprofile-dir=${COVERAGEDIR} CFLAGS+= ${_COV_FLAG} CXXFLAGS+= ${_COV_FLAG} @@ -324,7 +324,7 @@ NLSNAME?= ${PROG} .include .if defined(_COV_FLAG) && !empty(SRCS) -_GCNO_SRCS= ${SRCS:M*.c} ${SRCS:M*.cc} ${SRCS:M*.cpp} ${SRCS:M*.cxx} ${SRCS:M*.C} +_GCNO_SRCS= ${SRCS:M*.c} ${SRCS:M*.cc} ${SRCS:M*.cpp} ${SRCS:M*.cxx} ${SRCS:M*.C} ${SRCS:M*.y} GCNOS:= ${_GCNO_SRCS:R:S/$/.gcno/g} .undef _GCNO_SRCS .for _gcno in ${GCNOS} From owner-svn-src-projects@freebsd.org Wed Apr 3 05:40:05 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C6A2D155D9A1 for ; Wed, 3 Apr 2019 05:40:05 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6967C9230E; Wed, 3 Apr 2019 05:40:05 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2A05695C5; Wed, 3 Apr 2019 05:40:05 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x335e5df088543; Wed, 3 Apr 2019 05:40:05 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x335e5K5088542; Wed, 3 Apr 2019 05:40:05 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904030540.x335e5K5088542@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Wed, 3 Apr 2019 05:40:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345833 - projects/runtime-coverage X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/runtime-coverage X-SVN-Commit-Revision: 345833 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 6967C9230E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.965,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 05:40:05 -0000 Author: ngie Date: Wed Apr 3 05:40:04 2019 New Revision: 345833 URL: https://svnweb.freebsd.org/changeset/base/345833 Log: Prune outdated branch ^/projects/runtime-coverage has been superseded by ^/projects/runtime-coverage-v2 . Deleted: projects/runtime-coverage/ From owner-svn-src-projects@freebsd.org Wed Apr 3 05:43:33 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0E858155DCD8 for ; Wed, 3 Apr 2019 05:43:33 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9F85E927A9; Wed, 3 Apr 2019 05:43:32 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7494E976D; Wed, 3 Apr 2019 05:43:32 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x335hWsf093337; Wed, 3 Apr 2019 05:43:32 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x335hW9b093336; Wed, 3 Apr 2019 05:43:32 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904030543.x335hW9b093336@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Wed, 3 Apr 2019 05:43:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345834 - projects/runtime-coverage-v2/share/mk X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/runtime-coverage-v2/share/mk X-SVN-Commit-Revision: 345834 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9F85E927A9 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.967,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 05:43:33 -0000 Author: ngie Date: Wed Apr 3 05:43:32 2019 New Revision: 345834 URL: https://svnweb.freebsd.org/changeset/base/345834 Log: --coverage should apply to static programs too Statically compiled programs, like `/usr/tests/sys/capsicum-test/mini-me*`, should have coverage compile time/linker flags applied to them as well as the objects are compiled with with `--coverage`, etc. This fixes a linker error with `tests/sys/capsicum:mini-me`. Modified: projects/runtime-coverage-v2/share/mk/bsd.prog.mk Modified: projects/runtime-coverage-v2/share/mk/bsd.prog.mk ============================================================================== --- projects/runtime-coverage-v2/share/mk/bsd.prog.mk Wed Apr 3 05:40:04 2019 (r345833) +++ projects/runtime-coverage-v2/share/mk/bsd.prog.mk Wed Apr 3 05:43:32 2019 (r345834) @@ -78,12 +78,11 @@ TAG_ARGS= -T ${TAGS:[*]:S/ /,/g} .if defined(NO_SHARED) && ${NO_SHARED:tl} != "no" LDFLAGS+= -static -.else +.endif .if defined(_WANTS_DEBUG) && ${MK_COVERAGE} != "no" _COV_FLAG= --coverage -fprofile-dir=${COVERAGEDIR} CFLAGS+= ${_COV_FLAG} CXXFLAGS+= ${_COV_FLAG} -.endif .endif .if ${MK_DEBUG_FILES} != "no" From owner-svn-src-projects@freebsd.org Wed Apr 3 07:31:47 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4B324156205B for ; Wed, 3 Apr 2019 07:31:47 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BB8B097D83; Wed, 3 Apr 2019 07:31:46 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id x337ViJu025443; Wed, 3 Apr 2019 00:31:44 -0700 (PDT) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id x337VibS025442; Wed, 3 Apr 2019 00:31:44 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201904030731.x337VibS025442@gndrsh.dnsmgr.net> Subject: Re: svn commit: r345833 - projects/runtime-coverage In-Reply-To: <201904030540.x335e5K5088542@repo.freebsd.org> To: Enji Cooper Date: Wed, 3 Apr 2019 00:31:44 -0700 (PDT) CC: src-committers@freebsd.org, svn-src-projects@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: BB8B097D83 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.99 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.99)[-0.988,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 07:31:47 -0000 > Author: ngie > Date: Wed Apr 3 05:40:04 2019 > New Revision: 345833 > URL: https://svnweb.freebsd.org/changeset/base/345833 > > Log: > Prune outdated branch > > ^/projects/runtime-coverage has been superseded by > ^/projects/runtime-coverage-v2 . > > Deleted: > projects/runtime-coverage/ You do know that it makes finding these prior work things very hard? Why do they need to be deleted since they are just a top level project directory that you need to checkout explicitly. -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-projects@freebsd.org Wed Apr 3 19:59:49 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5C3DB155163C for ; Wed, 3 Apr 2019 19:59:49 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0C4DC6ACD8; Wed, 3 Apr 2019 19:59:49 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EA2591ABE0; Wed, 3 Apr 2019 19:59:48 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x33Jxm8n047918; Wed, 3 Apr 2019 19:59:48 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x33JxkKS047902; Wed, 3 Apr 2019 19:59:46 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904031959.x33JxkKS047902@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Wed, 3 Apr 2019 19:59:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345852 - in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Commit-Revision: 345852 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 0C4DC6ACD8 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.98)[-0.981,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 19:59:49 -0000 Author: asomers Date: Wed Apr 3 19:59:45 2019 New Revision: 345852 URL: https://svnweb.freebsd.org/changeset/base/345852 Log: fusefs: send FUSE_FLUSH during VOP_CLOSE The FUSE protocol says that FUSE_FLUSH should be send every time a file descriptor is closed. That's not quite possible in FreeBSD because multiple file descriptors can share a single struct file, and closef doesn't call fo_close until the last close. However, we can still send FUSE_FLUSH on every VOP_CLOSE, which is probably good enough. There are two purposes for FUSE_FLUSH. One is to allow file systems to return EIO if they have an error when writing data that's cached server-side. The other is to release POSIX file locks (which fusefs(5) does not yet support). PR: 236405, 236327 Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/sys/fs/fuse/fuse_file.c projects/fuse2/sys/fs/fuse/fuse_file.h projects/fuse2/sys/fs/fuse/fuse_io.c projects/fuse2/sys/fs/fuse/fuse_node.c projects/fuse2/sys/fs/fuse/fuse_vnops.c projects/fuse2/tests/sys/fs/fusefs/allow_other.cc projects/fuse2/tests/sys/fs/fusefs/flush.cc projects/fuse2/tests/sys/fs/fusefs/fsync.cc projects/fuse2/tests/sys/fs/fusefs/mockfs.cc projects/fuse2/tests/sys/fs/fusefs/open.cc projects/fuse2/tests/sys/fs/fusefs/release.cc projects/fuse2/tests/sys/fs/fusefs/utils.cc projects/fuse2/tests/sys/fs/fusefs/utils.hh projects/fuse2/tests/sys/fs/fusefs/write.cc Modified: projects/fuse2/sys/fs/fuse/fuse_file.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_file.c Wed Apr 3 19:35:07 2019 (r345851) +++ projects/fuse2/sys/fs/fuse/fuse_file.c Wed Apr 3 19:59:45 2019 (r345852) @@ -273,12 +273,14 @@ fuse_filehandle_validrw(struct vnode *vp, int mode, } int -fuse_filehandle_get(struct vnode *vp, fufh_type_t fufh_type, +fuse_filehandle_get(struct vnode *vp, int fflag, struct fuse_filehandle **fufhp, struct ucred *cred, pid_t pid) { struct fuse_vnode_data *fvdat = VTOFUD(vp); struct fuse_filehandle *fufh; + fufh_type_t fufh_type; + fufh_type = fflags_2_fufh_type(fflag); if (cred == NULL) goto fallback; @@ -307,14 +309,14 @@ found: } int -fuse_filehandle_getrw(struct vnode *vp, fufh_type_t fufh_type, +fuse_filehandle_getrw(struct vnode *vp, int fflag, struct fuse_filehandle **fufhp, struct ucred *cred, pid_t pid) { int err; - err = fuse_filehandle_get(vp, fufh_type, fufhp, cred, pid); + err = fuse_filehandle_get(vp, fflag, fufhp, cred, pid); if (err) - err = fuse_filehandle_get(vp, FUFH_RDWR, fufhp, cred, pid); + err = fuse_filehandle_get(vp, FREAD | FWRITE, fufhp, cred, pid); return err; } Modified: projects/fuse2/sys/fs/fuse/fuse_file.h ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_file.h Wed Apr 3 19:35:07 2019 (r345851) +++ projects/fuse2/sys/fs/fuse/fuse_file.h Wed Apr 3 19:59:45 2019 (r345852) @@ -150,10 +150,10 @@ struct fuse_filehandle { bool fuse_filehandle_validrw(struct vnode *vp, int mode, struct ucred *cred, pid_t pid); -int fuse_filehandle_get(struct vnode *vp, fufh_type_t fufh_type, +int fuse_filehandle_get(struct vnode *vp, int fflag, struct fuse_filehandle **fufhp, struct ucred *cred, pid_t pid); -int fuse_filehandle_getrw(struct vnode *vp, fufh_type_t fufh_type, +int fuse_filehandle_getrw(struct vnode *vp, int fflag, struct fuse_filehandle **fufhp, struct ucred *cred, pid_t pid); Modified: projects/fuse2/sys/fs/fuse/fuse_io.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_io.c Wed Apr 3 19:35:07 2019 (r345851) +++ projects/fuse2/sys/fs/fuse/fuse_io.c Wed Apr 3 19:59:45 2019 (r345852) @@ -127,12 +127,12 @@ fuse_io_dispatch(struct vnode *vp, struct uio *uio, in { struct fuse_filehandle *fufh; int err, directio; - fufh_type_t fufh_type; + int fflag; MPASS(vp->v_type == VREG || vp->v_type == VDIR); - fufh_type = (uio->uio_rw == UIO_READ) ? FUFH_RDONLY : FUFH_WRONLY; - err = fuse_filehandle_getrw(vp, fufh_type, &fufh, cred, pid); + fflag = (uio->uio_rw == UIO_READ) ? FREAD : FWRITE; + err = fuse_filehandle_getrw(vp, fflag, &fufh, cred, pid); if (err) { printf("FUSE: io dispatch: filehandles are closed\n"); return err; @@ -643,7 +643,7 @@ fuse_io_strategy(struct vnode *vp, struct buf *bp) struct uio uio; struct iovec io; int error = 0; - fufh_type_t fufh_type; + int fflag; /* We don't know the true pid when we're dealing with the cache */ pid_t pid = 0; @@ -652,9 +652,9 @@ fuse_io_strategy(struct vnode *vp, struct buf *bp) MPASS(vp->v_type == VREG || vp->v_type == VDIR); MPASS(bp->b_iocmd == BIO_READ || bp->b_iocmd == BIO_WRITE); - fufh_type = bp->b_iocmd == BIO_READ ? FUFH_RDONLY : FUFH_WRONLY; + fflag = bp->b_iocmd == BIO_READ ? FREAD : FWRITE; cred = bp->b_iocmd == BIO_READ ? bp->b_rcred : bp->b_wcred; - error = fuse_filehandle_getrw(vp, fufh_type, &fufh, cred, pid); + error = fuse_filehandle_getrw(vp, fflag, &fufh, cred, pid); if (bp->b_iocmd == BIO_READ && error == EBADF) { /* * This may be a read-modify-write operation on a cached file @@ -662,8 +662,7 @@ fuse_io_strategy(struct vnode *vp, struct buf *bp) * * TODO: eliminate this hacky check once the FUFH table is gone */ - fufh_type = FUFH_WRONLY; - error = fuse_filehandle_get(vp, fufh_type, &fufh, cred, pid); + error = fuse_filehandle_get(vp, FWRITE, &fufh, cred, pid); } if (error) { printf("FUSE: strategy: filehandles are closed\n"); Modified: projects/fuse2/sys/fs/fuse/fuse_node.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_node.c Wed Apr 3 19:35:07 2019 (r345851) +++ projects/fuse2/sys/fs/fuse/fuse_node.c Wed Apr 3 19:59:45 2019 (r345852) @@ -378,7 +378,7 @@ fuse_vnode_savesize(struct vnode *vp, struct ucred *cr fsai->size = fvdat->filesize; fsai->valid |= FATTR_SIZE; - fuse_filehandle_getrw(vp, FUFH_WRONLY, &fufh, cred, pid); + fuse_filehandle_getrw(vp, FWRITE, &fufh, cred, pid); if (fufh) { fsai->fh = fufh->fh_id; fsai->valid |= FATTR_FH; Modified: projects/fuse2/sys/fs/fuse/fuse_vnops.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_vnops.c Wed Apr 3 19:35:07 2019 (r345851) +++ projects/fuse2/sys/fs/fuse/fuse_vnops.c Wed Apr 3 19:59:45 2019 (r345852) @@ -221,11 +221,43 @@ static int fuse_filehandle_get_dir(struct vnode *vp, struct fuse_filehandle **fufhp, struct ucred *cred, pid_t pid) { - if (fuse_filehandle_get(vp, FUFH_RDONLY, fufhp, cred, pid) == 0) + if (fuse_filehandle_get(vp, FREAD, fufhp, cred, pid) == 0) return 0; - return fuse_filehandle_get(vp, FUFH_EXEC, fufhp, cred, pid); + return fuse_filehandle_get(vp, FEXEC, fufhp, cred, pid); } +/* Send FUSE_FLUSH for this vnode */ +static int +fuse_flush(struct vnode *vp, struct ucred *cred, pid_t pid, int fflag) +{ + struct fuse_flush_in *ffi; + struct fuse_filehandle *fufh; + struct fuse_dispatcher fdi; + struct thread *td = curthread; + struct mount *mp = vnode_mount(vp); + int err; + + if (!fsess_isimpl(vnode_mount(vp), FUSE_FLUSH)) + return 0; + + err = fuse_filehandle_get(vp, fflag, &fufh, cred, pid); + if (err) + return err; + + fdisp_init(&fdi, sizeof(*ffi)); + fdisp_make_vp(&fdi, FUSE_FLUSH, vp, td, cred); + ffi = fdi.indata; + ffi->fh = fufh->fh_id; + + err = fdisp_wait_answ(&fdi); + if (err == ENOSYS) { + fsess_set_notimpl(mp, FUSE_FLUSH); + err = 0; + } + fdisp_destroy(&fdi); + return err; +} + /* struct vnop_access_args { struct vnode *a_vp; @@ -275,7 +307,7 @@ fuse_vnop_access(struct vop_access_args *ap) } /* - struct vnop_close_args { + struct vop_close_args { struct vnode *a_vp; int a_fflag; struct ucred *a_cred; @@ -290,6 +322,7 @@ fuse_vnop_close(struct vop_close_args *ap) int fflag = ap->a_fflag; struct thread *td = ap->a_td; pid_t pid = td->td_proc->p_pid; + int err = 0; if (fuse_isdeadfs(vp)) { return 0; @@ -297,6 +330,8 @@ fuse_vnop_close(struct vop_close_args *ap) if (vnode_isdir(vp)) { struct fuse_filehandle *fufh; + // XXX: what if two file descriptors have the same directory + // opened? We shouldn't close the file handle too soon. if (fuse_filehandle_get_dir(vp, &fufh, cred, pid) == 0) fuse_filehandle_close(vp, fufh, NULL, cred); return 0; @@ -304,11 +339,12 @@ fuse_vnop_close(struct vop_close_args *ap) if (fflag & IO_NDELAY) { return 0; } + err = fuse_flush(vp, cred, pid, fflag); /* TODO: close the file handle, if we're sure it's no longer used */ if ((VTOFUD(vp)->flag & FN_SIZECHANGE) != 0) { fuse_vnode_savesize(vp, cred, td->td_proc->p_pid); } - return 0; + return err; } static void @@ -1611,7 +1647,7 @@ fuse_vnop_setattr(struct vop_setattr_args *ap) newsize = vap->va_size; fsai->valid |= FATTR_SIZE; - fuse_filehandle_getrw(vp, FUFH_WRONLY, &fufh, cred, pid); + fuse_filehandle_getrw(vp, FWRITE, &fufh, cred, pid); if (fufh) { fsai->fh = fufh->fh_id; fsai->valid |= FATTR_FH; Modified: projects/fuse2/tests/sys/fs/fusefs/allow_other.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/allow_other.cc Wed Apr 3 19:35:07 2019 (r345851) +++ projects/fuse2/tests/sys/fs/fusefs/allow_other.cc Wed Apr 3 19:59:45 2019 (r345852) @@ -78,6 +78,7 @@ TEST_F(AllowOther, allowed) expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1); expect_open(ino, 0, 1); + expect_flush(ino, 1, ReturnErrno(0)); expect_release(ino, FH); expect_getattr(ino, 0); }, []() { Modified: projects/fuse2/tests/sys/fs/fusefs/flush.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/flush.cc Wed Apr 3 19:35:07 2019 (r345851) +++ projects/fuse2/tests/sys/fs/fusefs/flush.cc Wed Apr 3 19:59:45 2019 (r345852) @@ -41,7 +41,8 @@ using namespace testing; class Flush: public FuseTest { public: -void expect_flush(uint64_t ino, int times, pid_t lo, ProcessMockerT r) +void +expect_flush(uint64_t ino, int times, pid_t lo, ProcessMockerT r) { EXPECT_CALL(*m_mock, process( ResultOf([=](auto in) { @@ -55,9 +56,9 @@ void expect_flush(uint64_t ino, int times, pid_t lo, P .WillRepeatedly(Invoke(r)); } -void expect_lookup(const char *relpath, uint64_t ino) +void expect_lookup(const char *relpath, uint64_t ino, int times) { - FuseTest::expect_lookup(relpath, ino, S_IFREG | 0644, 0, 1); + FuseTest::expect_lookup(relpath, ino, S_IFREG | 0644, 0, times); } /* @@ -82,16 +83,18 @@ class FlushWithLocks: public Flush { } }; -/* If a file descriptor is duplicated, every close causes FLUSH */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236405 */ -TEST_F(Flush, DISABLED_dup) +/* + * If multiple file descriptors refer to the same file handle, closing each + * should send FUSE_FLUSH + */ +TEST_F(Flush, open_twice) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; uint64_t ino = 42; int fd, fd2; - expect_lookup(RELPATH, ino); + expect_lookup(RELPATH, ino, 2); expect_open(ino, 0, 1); expect_getattr(ino, 0); expect_flush(ino, 2, 0, ReturnErrno(0)); @@ -100,10 +103,11 @@ TEST_F(Flush, DISABLED_dup) fd = open(FULLPATH, O_WRONLY); EXPECT_LE(0, fd) << strerror(errno); - fd2 = dup(fd); + fd2 = open(FULLPATH, O_WRONLY); + EXPECT_LE(0, fd2) << strerror(errno); - ASSERT_EQ(0, close(fd2)) << strerror(errno); - ASSERT_EQ(0, close(fd)) << strerror(errno); + EXPECT_EQ(0, close(fd2)) << strerror(errno); + EXPECT_EQ(0, close(fd)) << strerror(errno); } /* @@ -114,15 +118,14 @@ TEST_F(Flush, DISABLED_dup) * all. */ /* http://pubs.opengroup.org/onlinepubs/9699919799/functions/close.html */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236405 */ -TEST_F(Flush, DISABLED_eio) +TEST_F(Flush, eio) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; uint64_t ino = 42; int fd; - expect_lookup(RELPATH, ino); + expect_lookup(RELPATH, ino, 1); expect_open(ino, 0, 1); expect_getattr(ino, 0); expect_flush(ino, 1, 0, ReturnErrno(EIO)); @@ -138,41 +141,48 @@ TEST_F(Flush, DISABLED_eio) * If the filesystem returns ENOSYS, it will be treated as success and * no more FUSE_FLUSH operations will be sent to the daemon */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236405 */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236557 */ -TEST_F(Flush, DISABLED_enosys) +TEST_F(Flush, enosys) { - const char FULLPATH[] = "mountpoint/some_file.txt"; - const char RELPATH[] = "some_file.txt"; - uint64_t ino = 42; - int fd, fd2; + const char FULLPATH0[] = "mountpoint/some_file.txt"; + const char RELPATH0[] = "some_file.txt"; + const char FULLPATH1[] = "mountpoint/other_file.txt"; + const char RELPATH1[] = "other_file.txt"; + uint64_t ino0 = 42; + uint64_t ino1 = 43; + int fd0, fd1; - expect_lookup(RELPATH, ino); - expect_open(ino, 0, 1); - expect_getattr(ino, 0); + expect_lookup(RELPATH0, ino0, 1); + expect_open(ino0, 0, 1); + expect_getattr(ino0, 0); /* On the 2nd close, FUSE_FLUSH won't be sent at all */ - expect_flush(ino, 1, 0, ReturnErrno(ENOSYS)); + expect_flush(ino0, 1, 0, ReturnErrno(ENOSYS)); expect_release(); - fd = open(FULLPATH, O_WRONLY); - EXPECT_LE(0, fd) << strerror(errno); + expect_lookup(RELPATH1, ino1, 1); + expect_open(ino1, 0, 1); + expect_getattr(ino1, 0); + /* On the 2nd close, FUSE_FLUSH won't be sent at all */ + expect_release(); - fd2 = dup(fd); + fd0 = open(FULLPATH0, O_WRONLY); + ASSERT_LE(0, fd0) << strerror(errno); - EXPECT_EQ(0, close(fd2)) << strerror(errno); - EXPECT_EQ(0, close(fd)) << strerror(errno); + fd1 = open(FULLPATH1, O_WRONLY); + ASSERT_LE(0, fd1) << strerror(errno); + + EXPECT_EQ(0, close(fd0)) << strerror(errno); + EXPECT_EQ(0, close(fd1)) << strerror(errno); } /* A FUSE_FLUSH should be sent on close(2) */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236405 */ -TEST_F(Flush, DISABLED_flush) +TEST_F(Flush, flush) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; uint64_t ino = 42; int fd; - expect_lookup(RELPATH, ino); + expect_lookup(RELPATH, ino, 1); expect_open(ino, 0, 1); expect_getattr(ino, 0); expect_flush(ino, 1, 0, ReturnErrno(0)); @@ -188,7 +198,6 @@ TEST_F(Flush, DISABLED_flush) * When closing a file with a POSIX file lock, flush should release the lock, * _even_if_ it's not the process's last file descriptor for this file. */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236405 */ /* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=234581 */ TEST_F(FlushWithLocks, DISABLED_unlock_on_close) { @@ -199,7 +208,7 @@ TEST_F(FlushWithLocks, DISABLED_unlock_on_close) struct flock fl; pid_t pid = getpid(); - expect_lookup(RELPATH, ino); + expect_lookup(RELPATH, ino, 1); expect_open(ino, 0, 1); expect_getattr(ino, 0); EXPECT_CALL(*m_mock, process( Modified: projects/fuse2/tests/sys/fs/fusefs/fsync.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/fsync.cc Wed Apr 3 19:35:07 2019 (r345851) +++ projects/fuse2/tests/sys/fs/fusefs/fsync.cc Wed Apr 3 19:59:45 2019 (r345852) @@ -139,6 +139,7 @@ TEST_F(Fsync, close) }, Eq(true)), _) ).Times(0); + expect_flush(ino, 1, ReturnErrno(0)); expect_release(ino, FH); fd = open(FULLPATH, O_RDWR); Modified: projects/fuse2/tests/sys/fs/fusefs/mockfs.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/mockfs.cc Wed Apr 3 19:35:07 2019 (r345851) +++ projects/fuse2/tests/sys/fs/fusefs/mockfs.cc Wed Apr 3 19:59:45 2019 (r345852) @@ -169,7 +169,8 @@ void debug_fuseop(const mockfs_buf_in *in) in->body.open.flags, name); break; case FUSE_FLUSH: - printf(" lock_owner=%lu", in->body.flush.lock_owner); + printf(" fh=%#lx lock_owner=%lu", in->body.flush.fh, + in->body.flush.lock_owner); break; case FUSE_FORGET: printf(" nlookup=%lu", in->body.forget.nlookup); Modified: projects/fuse2/tests/sys/fs/fusefs/open.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/open.cc Wed Apr 3 19:35:07 2019 (r345851) +++ projects/fuse2/tests/sys/fs/fusefs/open.cc Wed Apr 3 19:59:45 2019 (r345852) @@ -205,6 +205,7 @@ TEST_F(Open, multiple_creds) SET_OUT_HEADER_LEN(out, open); }))); expect_getattr(ino, 0); + expect_flush(ino, 2, ReturnErrno(0)); expect_release(ino, fh0); expect_release(ino, fh1); Modified: projects/fuse2/tests/sys/fs/fusefs/release.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/release.cc Wed Apr 3 19:35:07 2019 (r345851) +++ projects/fuse2/tests/sys/fs/fusefs/release.cc Wed Apr 3 19:59:45 2019 (r345852) @@ -82,6 +82,7 @@ TEST_F(Release, dup) expect_lookup(RELPATH, ino, 1); expect_open(ino, 0, 1); expect_getattr(ino, 0); + expect_flush(ino, 1, ReturnErrno(0)); expect_release(ino, 0, O_RDONLY, 0); fd = open(FULLPATH, O_RDONLY); @@ -111,6 +112,7 @@ TEST_F(Release, eio) expect_lookup(RELPATH, ino, 1); expect_open(ino, 0, 1); expect_getattr(ino, 0); + expect_flush(ino, 1, ReturnErrno(0)); expect_release(ino, 0, O_WRONLY, EIO); fd = open(FULLPATH, O_WRONLY); @@ -133,6 +135,7 @@ TEST_F(Release, DISABLED_flags) expect_lookup(RELPATH, ino, 1); expect_open(ino, 0, 1); expect_getattr(ino, 0); + expect_flush(ino, 1, ReturnErrno(0)); expect_release(ino, 0, O_RDWR | O_APPEND, 0); fd = open(FULLPATH, O_RDWR | O_APPEND); @@ -156,6 +159,7 @@ TEST_F(Release, multiple_opens) expect_lookup(RELPATH, ino, 2); expect_open(ino, 0, 2); expect_getattr(ino, 0); + expect_flush(ino, 2, ReturnErrno(0)); expect_release(ino, 0, O_RDONLY, 0); fd = open(FULLPATH, O_RDONLY); @@ -179,6 +183,7 @@ TEST_F(Release, ok) expect_lookup(RELPATH, ino, 1); expect_open(ino, 0, 1); expect_getattr(ino, 0); + expect_flush(ino, 1, ReturnErrno(0)); expect_release(ino, 0, O_RDONLY, 0); fd = open(FULLPATH, O_RDONLY); @@ -212,6 +217,7 @@ TEST_F(ReleaseWithLocks, DISABLED_unlock_on_close) SET_OUT_HEADER_LEN(out, setlk); out->body.setlk.lk = in->body.setlk.lk; }))); + expect_flush(ino, 1, ReturnErrno(0)); expect_release(ino, (uint64_t)pid, O_RDWR, 0); fd = open(FULLPATH, O_RDWR); Modified: projects/fuse2/tests/sys/fs/fusefs/utils.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/utils.cc Wed Apr 3 19:35:07 2019 (r345851) +++ projects/fuse2/tests/sys/fs/fusefs/utils.cc Wed Apr 3 19:59:45 2019 (r345852) @@ -114,6 +114,19 @@ FuseTest::expect_access(uint64_t ino, mode_t access_mo ).WillOnce(Invoke(ReturnErrno(error))); } +void +FuseTest::expect_flush(uint64_t ino, int times, ProcessMockerT r) +{ + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in->header.opcode == FUSE_FLUSH && + in->header.nodeid == ino); + }, Eq(true)), + _) + ).Times(times) + .WillRepeatedly(Invoke(r)); +} + void FuseTest::expect_getattr(uint64_t ino, uint64_t size) { /* Until the attr cache is working, we may send an additional GETATTR */ Modified: projects/fuse2/tests/sys/fs/fusefs/utils.hh ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/utils.hh Wed Apr 3 19:35:07 2019 (r345851) +++ projects/fuse2/tests/sys/fs/fusefs/utils.hh Wed Apr 3 19:59:45 2019 (r345852) @@ -70,10 +70,16 @@ class FuseTest : public ::testing::Test { } /* - * Create an expectation that FUSE_ACCESS will be called oncde for the + * Create an expectation that FUSE_ACCESS will be called once for the * given inode with the given access_mode, returning the given errno */ void expect_access(uint64_t ino, mode_t access_mode, int error); + + /* + * Create an expectation that FUSE_FLUSH will be called times times for + * the given inode + */ + void expect_flush(uint64_t ino, int times, ProcessMockerT r); /* * Create an expectation that FUSE_GETATTR will be called for the given Modified: projects/fuse2/tests/sys/fs/fusefs/write.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/write.cc Wed Apr 3 19:35:07 2019 (r345851) +++ projects/fuse2/tests/sys/fs/fusefs/write.cc Wed Apr 3 19:59:45 2019 (r345852) @@ -374,6 +374,7 @@ TEST_F(Write, DISABLED_mmap) * pid, so they must set FUSE_WRITE_CACHE */ expect_write(ino, 0, len, len, FUSE_WRITE_CACHE, expected); + expect_flush(ino, 1, ReturnErrno(0)); expect_release(ino, ReturnErrno(0)); fd = open(FULLPATH, O_RDWR); @@ -512,6 +513,7 @@ TEST_F(WriteBack, close) SET_OUT_HEADER_LEN(out, attr); out->body.attr.attr.ino = ino; // Must match nodeid }))); + expect_flush(ino, 1, ReturnErrno(0)); expect_release(ino, ReturnErrno(0)); fd = open(FULLPATH, O_RDWR); From owner-svn-src-projects@freebsd.org Wed Apr 3 20:57:45 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9FA1E1553548 for ; Wed, 3 Apr 2019 20:57:45 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 36D7A6D852; Wed, 3 Apr 2019 20:57:45 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0DB121B6A4; Wed, 3 Apr 2019 20:57:45 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x33KviEY081274; Wed, 3 Apr 2019 20:57:44 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x33Kvinu081270; Wed, 3 Apr 2019 20:57:44 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904032057.x33Kvinu081270@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Wed, 3 Apr 2019 20:57:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345854 - in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Commit-Revision: 345854 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 36D7A6D852 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.99 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.99)[-0.989,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 20:57:45 -0000 Author: asomers Date: Wed Apr 3 20:57:43 2019 New Revision: 345854 URL: https://svnweb.freebsd.org/changeset/base/345854 Log: fusefs: fix a panic in VOP_READDIR The original fusefs import, r238402, contained a bug in fuse_vnop_close that could close a directory's file handle while there were still other open file descriptors. The code looks deliberate, but there is no explanation for it. This necessitated a workaround in fuse_vnop_readdir that would open a new file handle if, "for some mysterious reason", that vnode didn't have any open file handles. r345781 had the effect of causing the workaround to panic, making the problem more visible. This commit removes the workaround and the original bug, which also fixes the panic. Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/sys/fs/fuse/fuse_vnops.c projects/fuse2/tests/sys/fs/fusefs/readdir.cc projects/fuse2/tests/sys/fs/fusefs/releasedir.cc projects/fuse2/tests/sys/fs/fusefs/utils.cc projects/fuse2/tests/sys/fs/fusefs/utils.hh Modified: projects/fuse2/sys/fs/fuse/fuse_vnops.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_vnops.c Wed Apr 3 20:37:14 2019 (r345853) +++ projects/fuse2/sys/fs/fuse/fuse_vnops.c Wed Apr 3 20:57:43 2019 (r345854) @@ -324,21 +324,13 @@ fuse_vnop_close(struct vop_close_args *ap) pid_t pid = td->td_proc->p_pid; int err = 0; - if (fuse_isdeadfs(vp)) { + if (fuse_isdeadfs(vp)) return 0; - } - if (vnode_isdir(vp)) { - struct fuse_filehandle *fufh; - - // XXX: what if two file descriptors have the same directory - // opened? We shouldn't close the file handle too soon. - if (fuse_filehandle_get_dir(vp, &fufh, cred, pid) == 0) - fuse_filehandle_close(vp, fufh, NULL, cred); + if (vnode_isdir(vp)) return 0; - } - if (fflag & IO_NDELAY) { + if (fflag & IO_NDELAY) return 0; - } + err = fuse_flush(vp, cred, pid, fflag); /* TODO: close the file handle, if we're sure it's no longer used */ if ((VTOFUD(vp)->flag & FN_SIZECHANGE) != 0) { @@ -1342,7 +1334,6 @@ fuse_vnop_readdir(struct vop_readdir_args *ap) struct fuse_filehandle *fufh = NULL; struct fuse_iov cookediov; int err = 0; - int freefufh = 0; pid_t pid = curthread->td_proc->p_pid; if (fuse_isdeadfs(vp)) { @@ -1353,27 +1344,15 @@ fuse_vnop_readdir(struct vop_readdir_args *ap) return EINVAL; } - if ((err = fuse_filehandle_get_dir(vp, &fufh, cred, pid)) != 0) { - SDT_PROBE2(fuse, , vnops, trace, 1, - "calling readdir() before open()"); - /* - * This was seen to happen in getdirentries as used by - * shells/fish, but I can't reproduce it. - */ - err = fuse_filehandle_open(vp, FREAD, &fufh, NULL, cred); - freefufh = 1; - } - if (err) { + err = fuse_filehandle_get_dir(vp, &fufh, cred, pid); + if (err) return (err); - } #define DIRCOOKEDSIZE FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + MAXNAMLEN + 1) fiov_init(&cookediov, DIRCOOKEDSIZE); err = fuse_internal_readdir(vp, uio, fufh, &cookediov); fiov_teardown(&cookediov); - if (freefufh) - fuse_filehandle_close(vp, fufh, NULL, cred); return err; } Modified: projects/fuse2/tests/sys/fs/fusefs/readdir.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/readdir.cc Wed Apr 3 20:37:14 2019 (r345853) +++ projects/fuse2/tests/sys/fs/fusefs/readdir.cc Wed Apr 3 20:57:43 2019 (r345854) @@ -213,13 +213,59 @@ TEST_F(Readdir, getdirentries) out->header.len = sizeof(out->header); }))); - errno = 0; fd = open(FULLPATH, O_DIRECTORY); ASSERT_LE(0, fd) << strerror(errno); r = getdirentries(fd, buf, sizeof(buf), 0); - ASSERT_EQ(0, r); + ASSERT_EQ(0, r) << strerror(errno); /* Deliberately leak fd. RELEASEDIR will be tested separately */ +} + +/* + * Nothing bad should happen if getdirentries is called on two file descriptors + * which were concurrently open, but one has already been closed. + * This is a regression test for a specific bug dating from r238402. + */ +TEST_F(Readdir, getdirentries_concurrent) +{ + const char FULLPATH[] = "mountpoint/some_dir"; + const char RELPATH[] = "some_dir"; + uint64_t ino = 42; + int fd0, fd1; + char buf[8192]; + ssize_t r; + + FuseTest::expect_lookup(RELPATH, ino, S_IFDIR | 0755, 0, 2); + expect_opendir(ino); + + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in->header.opcode == FUSE_READDIR && + in->header.nodeid == ino && + in->body.readdir.size == 8192); + }, Eq(true)), + _) + ).Times(2) + .WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto out) { + out->header.error = 0; + out->header.len = sizeof(out->header); + }))); + + fd0 = open(FULLPATH, O_DIRECTORY); + ASSERT_LE(0, fd0) << strerror(errno); + + fd1 = open(FULLPATH, O_DIRECTORY); + ASSERT_LE(0, fd1) << strerror(errno); + + r = getdirentries(fd0, buf, sizeof(buf), 0); + ASSERT_EQ(0, r) << strerror(errno); + + EXPECT_EQ(0, close(fd0)) << strerror(errno); + + r = getdirentries(fd1, buf, sizeof(buf), 0); + ASSERT_EQ(0, r) << strerror(errno); + + /* Deliberately leak fd1. */ } /* Modified: projects/fuse2/tests/sys/fs/fusefs/releasedir.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/releasedir.cc Wed Apr 3 20:37:14 2019 (r345853) +++ projects/fuse2/tests/sys/fs/fusefs/releasedir.cc Wed Apr 3 20:57:43 2019 (r345854) @@ -45,18 +45,6 @@ void expect_lookup(const char *relpath, uint64_t ino) { FuseTest::expect_lookup(relpath, ino, S_IFDIR | 0755, 0, 1); } - -void expect_releasedir(uint64_t ino, ProcessMockerT r) -{ - EXPECT_CALL(*m_mock, process( - ResultOf([=](auto in) { - return (in->header.opcode == FUSE_RELEASEDIR && - in->header.nodeid == ino && - in->body.release.fh == FH); - }, Eq(true)), - _) - ).WillOnce(Invoke(r)); -} }; /* If a file descriptor is duplicated, only the last close causes RELEASE */ Modified: projects/fuse2/tests/sys/fs/fusefs/utils.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/utils.cc Wed Apr 3 20:37:14 2019 (r345853) +++ projects/fuse2/tests/sys/fs/fusefs/utils.cc Wed Apr 3 20:57:43 2019 (r345854) @@ -232,6 +232,18 @@ void FuseTest::expect_release(uint64_t ino, uint64_t f ).WillOnce(Invoke(ReturnErrno(0))); } +void FuseTest::expect_releasedir(uint64_t ino, ProcessMockerT r) +{ + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in->header.opcode == FUSE_RELEASEDIR && + in->header.nodeid == ino && + in->body.release.fh == FH); + }, Eq(true)), + _) + ).WillOnce(Invoke(r)); +} + void FuseTest::expect_write(uint64_t ino, uint64_t offset, uint64_t isize, uint64_t osize, uint32_t flags, const void *contents) { Modified: projects/fuse2/tests/sys/fs/fusefs/utils.hh ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/utils.hh Wed Apr 3 20:37:14 2019 (r345853) +++ projects/fuse2/tests/sys/fs/fusefs/utils.hh Wed Apr 3 20:57:43 2019 (r345854) @@ -124,6 +124,12 @@ class FuseTest : public ::testing::Test { void expect_release(uint64_t ino, uint64_t fh); /* + * Create an expectation that FUSE_RELEASEDIR will be called exactly + * once for the given inode + */ + void expect_releasedir(uint64_t ino, ProcessMockerT r); + + /* * Create an expectation that FUSE_WRITE will be called exactly once * for the given inode, at offset offset, with write_flags flags, * size isize and buffer contents. It will return osize From owner-svn-src-projects@freebsd.org Wed Apr 3 21:30:32 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 030CF1553F71 for ; Wed, 3 Apr 2019 21:30:32 +0000 (UTC) (envelope-from gnn@neville-neil.com) Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DE4486E7CA; Wed, 3 Apr 2019 21:30:29 +0000 (UTC) (envelope-from gnn@neville-neil.com) Received: from [10.37.129.2] (unknown [65.88.88.178]) (Authenticated sender: gnn@neville-neil.com) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 10B14240005; Wed, 3 Apr 2019 21:30:20 +0000 (UTC) From: "George Neville-Neil" To: "Kristof Provost" Cc: rgrimes@freebsd.org, "Andrey V. Elsukov" , "Mateusz Guzik" , src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: Re: svn commit: r345760 - in head: contrib/pf sys/netpfil/pf sbin/pfctl Date: Wed, 03 Apr 2019 17:27:26 -0400 X-Mailer: MailMate (1.12.4r5594) Message-ID: <7A8504D1-7A27-4B8D-8263-9AC54EABBF88@neville-neil.com> In-Reply-To: References: <201904011348.x31Dm86D015297@gndrsh.dnsmgr.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: DE4486E7CA X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of gnn@neville-neil.com designates 217.70.178.230 as permitted sender) smtp.mailfrom=gnn@neville-neil.com X-Spamd-Result: default: False [-4.36 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[230.178.70.217.list.dnswl.org : 127.0.5.1]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:217.70.176.0/21]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[neville-neil.com]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; RCPT_COUNT_FIVE(0.00)[6]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MX_GOOD(-0.01)[spool.mail.gandi.net,fb.mail.gandi.net,spool.mail.gandi.net,fb.mail.gandi.net,spool.mail.gandi.net,fb.mail.gandi.net]; NEURAL_HAM_SHORT(-0.99)[-0.992,0]; IP_SCORE(-0.95)[ip: (-1.66), ipnet: 217.70.176.0/20(-1.72), asn: 29169(-1.38), country: FR(-0.01)]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:29169, ipnet:217.70.176.0/20, country:FR]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 21:30:32 -0000 On 1 Apr 2019, at 12:16, Kristof Provost wrote: > On 1 Apr 2019, at 15:48, Rodney W. Grimes wrote: >> [ Charset UTF-8 unsupported, converting... ] >>> On 01.04.2019 16:30, Rodney W. Grimes wrote: >>> It seems it is too late: >>> https://marc.info/?l=openbsd-tech&m=155409489427092&w=2 >> >> I am wondering on the above as it has a date of: >> Date: 2019-04-01 5:01:03 >> >> which would be in line with Kristof's joke. >> > Yes, OpenBSD are clearly joking as well. > >>> http://mail-index.netbsd.org/tech-kern/2019/03/29/msg024883.html >> This is inline with what is being proposed here, NetBSD has >> old rotted code that needs updated. > > [Disclaimer: I do not speak for NetBSD, and based this on my reading > of that thread] > > NetBSD however are serious. > Their situation is slightly different, in that their primary reason is > that they don’t have a maintainer for their pf version and it’s > suffering from significant bitrot. > > Our situation is somewhat better. Our pf is maintained and does get > bug fixes and improvements. Not as many as I’d like, but there’s > something. > >> Rather than do that work >> twice, do it 1.5 times (implementing the same technology in >> 2 OS's should be less work than doing it twice.) >> >> I believe there is grant money avaliable from a non Foundation >> source that could be used to do this work. >> > I’m not at all opposed to updating our pf, but there are a few > obstacles (technical: performance, syntax and vimage. Practical: this > is a lot of work). If people are interested in that discussion I’d > propose someone start a new thread on freebsd-pf@, and I’ll expand > on what I think the problems are and what needs to be done. > > I’d also be interested in knowing what people are looking for from > an updated pf in FreeBSD. What are the improvements in OpenBSD that > you’d really like to see in FreeBSD? > In the age of NAT do we really need a firewall? Yes, it's April 3rd but, you did start it :-) Best George From owner-svn-src-projects@freebsd.org Thu Apr 4 16:51:36 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5BF761576992 for ; Thu, 4 Apr 2019 16:51:36 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 089DA8224D; Thu, 4 Apr 2019 16:51:36 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D689E29A; Thu, 4 Apr 2019 16:51:35 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x34GpZ6s017256; Thu, 4 Apr 2019 16:51:35 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x34GpYcs017250; Thu, 4 Apr 2019 16:51:34 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904041651.x34GpYcs017250@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Thu, 4 Apr 2019 16:51:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345876 - in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Commit-Revision: 345876 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 089DA8224D X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.966,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Apr 2019 16:51:36 -0000 Author: asomers Date: Thu Apr 4 16:51:34 2019 New Revision: 345876 URL: https://svnweb.freebsd.org/changeset/base/345876 Log: fusefs: correctly handle short writes If a FUSE daemon returns FOPEN_DIRECT_IO when a file is opened, then it's allowed to write less data than was requested during a FUSE_WRITE operation on that file handle. fusefs should simply return a short write to userland. The old code attempted to resend the unsent data. Not only was that incorrect behavior, but it did it in an ineffective way, by attempting to "rewind" the uio and uiomove the unsent data again. This commit correctly handles short writes by returning directly to userland if FOPEN_DIRECT_IO was set. If it wasn't set (making the short write technically a protocol violation), then we resend the unsent data. But instead of rewinding the uio, just resend the data that's already in the kernel. That necessitated a few changes to fuse_ipc.c to reduce the amount of bzero activity. fusefs may be marginally faster as a result. PR: 236381 Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/sys/fs/fuse/fuse_internal.c projects/fuse2/sys/fs/fuse/fuse_io.c projects/fuse2/sys/fs/fuse/fuse_ipc.c projects/fuse2/sys/fs/fuse/fuse_ipc.h projects/fuse2/sys/fs/fuse/fuse_vnops.c projects/fuse2/tests/sys/fs/fusefs/mockfs.cc projects/fuse2/tests/sys/fs/fusefs/write.cc Modified: projects/fuse2/sys/fs/fuse/fuse_internal.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_internal.c Thu Apr 4 16:32:27 2019 (r345875) +++ projects/fuse2/sys/fs/fuse/fuse_internal.c Thu Apr 4 16:51:34 2019 (r345876) @@ -282,7 +282,7 @@ fuse_internal_fsync(struct vnode *vp, int waitfor, bool datasync) { - struct fuse_fsync_in *ffsi; + struct fuse_fsync_in *ffsi = NULL; struct fuse_dispatcher fdi; struct fuse_filehandle *fufh; struct fuse_vnode_data *fvdat = VTOFUD(vp); @@ -295,15 +295,20 @@ fuse_internal_fsync(struct vnode *vp, } if (vnode_isdir(vp)) op = FUSE_FSYNCDIR; + + fdisp_init(&fdi, sizeof(*ffsi)); /* * fsync every open file handle for this file, because we can't be sure * which file handle the caller is really referring to. */ LIST_FOREACH(fufh, &fvdat->handles, next) { - fdisp_init(&fdi, sizeof(*ffsi)); - fdisp_make_vp(&fdi, op, vp, td, NULL); + if (ffsi == NULL) + fdisp_make_vp(&fdi, op, vp, td, NULL); + else + fdisp_refresh_vp(&fdi, op, vp, td, NULL); ffsi = fdi.indata; ffsi->fh = fufh->fh_id; + ffsi->fsync_flags = 0; if (datasync) ffsi->fsync_flags = 1; @@ -315,8 +320,8 @@ fuse_internal_fsync(struct vnode *vp, fuse_internal_fsync_callback); fuse_insert_message(fdi.tick); } - fdisp_destroy(&fdi); } + fdisp_destroy(&fdi); return err; } @@ -331,7 +336,7 @@ fuse_internal_readdir(struct vnode *vp, { int err = 0; struct fuse_dispatcher fdi; - struct fuse_read_in *fri; + struct fuse_read_in *fri = NULL; if (uio_resid(uio) == 0) { return 0; @@ -344,9 +349,11 @@ fuse_internal_readdir(struct vnode *vp, */ while (uio_resid(uio) > 0) { - fdi.iosize = sizeof(*fri); - fdisp_make_vp(&fdi, FUSE_READDIR, vp, NULL, NULL); + if (fri == NULL) + fdisp_make_vp(&fdi, FUSE_READDIR, vp, NULL, NULL); + else + fdisp_refresh_vp(&fdi, FUSE_READDIR, vp, NULL, NULL); fri = fdi.indata; fri->fh = fufh->fh_id; @@ -419,8 +426,8 @@ fuse_internal_readdir_processdata(struct uio *uio, err = -1; break; } - fiov_refresh(cookediov); fiov_adjust(cookediov, bytesavail); + bzero(cookediov->base, bytesavail); de = (struct dirent *)cookediov->base; de->d_fileno = fudge->ino; Modified: projects/fuse2/sys/fs/fuse/fuse_io.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_io.c Thu Apr 4 16:32:27 2019 (r345875) +++ projects/fuse2/sys/fs/fuse/fuse_io.c Thu Apr 4 16:51:34 2019 (r345876) @@ -341,10 +341,14 @@ fuse_write_directbackend(struct vnode *vp, struct uio { struct fuse_vnode_data *fvdat = VTOFUD(vp); struct fuse_write_in *fwi; + struct fuse_write_out *fwo; struct fuse_dispatcher fdi; size_t chunksize; + void *fwi_data; + off_t as_written_offset; int diff; int err = 0; + bool direct_io = fufh->fuse_open_flags & FOPEN_DIRECT_IO; if (uio->uio_resid == 0) return (0); @@ -364,36 +368,61 @@ fuse_write_directbackend(struct vnode *vp, struct uio fwi->fh = fufh->fh_id; fwi->offset = uio->uio_offset; fwi->size = chunksize; + fwi_data = (char *)fdi.indata + sizeof(*fwi); - if ((err = uiomove((char *)fdi.indata + sizeof(*fwi), - chunksize, uio))) + if ((err = uiomove(fwi_data, chunksize, uio))) break; +retry: if ((err = fdisp_wait_answ(&fdi))) break; + fwo = ((struct fuse_write_out *)fdi.answ); + /* Adjust the uio in the case of short writes */ - diff = chunksize - ((struct fuse_write_out *)fdi.answ)->size; - if (diff < 0) { - err = EINVAL; - break; - } else if (diff > 0 && !(ioflag & IO_DIRECT)) { - /* - * XXX We really should be directly checking whether - * the file was opened with FOPEN_DIRECT_IO, not - * IO_DIRECT. IO_DIRECT can be set in multiple ways. - */ - SDT_PROBE2(fuse, , io, trace, 1, - "misbehaving filesystem: short writes are only " - "allowed with direct_io"); - } - uio->uio_resid += diff; - uio->uio_offset -= diff; + diff = fwi->size - fwo->size; + as_written_offset = uio->uio_offset - diff; - if (uio->uio_offset > fvdat->filesize && + if (as_written_offset - diff > fvdat->filesize && fuse_data_cache_mode != FUSE_CACHE_UC) { - fuse_vnode_setsize(vp, cred, uio->uio_offset); + fuse_vnode_setsize(vp, cred, as_written_offset); fvdat->flag &= ~FN_SIZECHANGE; + } + + if (diff < 0) { + printf("WARNING: misbehaving FUSE filesystem " + "wrote more data than we provided it\n"); + err = EINVAL; + break; + } else if (diff > 0) { + /* Short write */ + if (!direct_io) { + printf("WARNING: misbehaving FUSE filesystem: " + "short writes are only allowed with " + "direct_io\n"); + } + if (ioflag & IO_DIRECT) { + /* Return early */ + uio->uio_resid += diff; + uio->uio_offset -= diff; + break; + } else { + /* Resend the unwritten portion of data */ + fdi.iosize = sizeof(*fwi) + diff; + /* Refresh fdi without clearing data buffer */ + fdisp_refresh_vp(&fdi, FUSE_WRITE, vp, + uio->uio_td, cred); + fwi = fdi.indata; + MPASS2(fwi == fdi.indata, "FUSE dispatcher " + "reallocated despite no increase in " + "size?"); + void *src = (char*)fwi_data + fwo->size; + memmove(fwi_data, src, diff); + fwi->fh = fufh->fh_id; + fwi->offset = as_written_offset; + fwi->size = diff; + goto retry; + } } } Modified: projects/fuse2/sys/fs/fuse/fuse_ipc.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_ipc.c Thu Apr 4 16:32:27 2019 (r345875) +++ projects/fuse2/sys/fs/fuse/fuse_ipc.c Thu Apr 4 16:51:34 2019 (r345876) @@ -92,6 +92,7 @@ SDT_PROVIDER_DECLARE(fuse); */ SDT_PROBE_DEFINE2(fuse, , ipc, trace, "int", "char*"); +static void fiov_clear(struct fuse_iov *fiov); static struct fuse_ticket *fticket_alloc(struct fuse_data *data); static void fticket_refresh(struct fuse_ticket *ftick); static void fticket_destroy(struct fuse_ticket *ftick); @@ -185,11 +186,19 @@ fiov_adjust(struct fuse_iov *fiov, size_t size) fiov->len = size; } +/* Clear the fiov's data buffer */ +static void +fiov_clear(struct fuse_iov *fiov) +{ + bzero(fiov->base, fiov->len); +} + +/* Resize the fiov if needed, and clear it's buffer */ void fiov_refresh(struct fuse_iov *fiov) { - bzero(fiov->base, fiov->len); fiov_adjust(fiov, 0); + bzero(fiov->base, fiov->len); } static int @@ -267,7 +276,7 @@ fticket_destroy(struct fuse_ticket *ftick) return uma_zfree(ticket_zone, ftick); } -static inline +static inline void fticket_refresh(struct fuse_ticket *ftick) { @@ -290,6 +299,27 @@ fticket_refresh(struct fuse_ticket *ftick) ftick->tk_flag = 0; } +/* Prepar the ticket to be reused, but don't clear its data buffers */ +static inline void +fticket_reset(struct fuse_ticket *ftick) +{ + FUSE_ASSERT_MS_DONE(ftick); + FUSE_ASSERT_AW_DONE(ftick); + + ftick->tk_ms_bufdata = NULL; + ftick->tk_ms_bufsize = 0; + ftick->tk_ms_type = FT_M_FIOV; + + bzero(&ftick->tk_aw_ohead, sizeof(struct fuse_out_header)); + + ftick->tk_aw_errno = 0; + ftick->tk_aw_bufdata = NULL; + ftick->tk_aw_bufsize = 0; + ftick->tk_aw_type = FT_A_FIOV; + + ftick->tk_flag = 0; +} + static int fticket_wait_answer(struct fuse_ticket *ftick) { @@ -703,7 +733,26 @@ fuse_standard_handler(struct fuse_ticket *ftick, struc return err; } -void +/* + * Reinitialize a dispatcher from a pid and node id, without resizing or + * clearing its data buffers + */ +static void +fdisp_refresh_pid(struct fuse_dispatcher *fdip, enum fuse_opcode op, + struct mount *mp, uint64_t nid, pid_t pid, struct ucred *cred) +{ + MPASS(fdip->tick); + fticket_reset(fdip->tick); + + FUSE_DIMALLOC(&fdip->tick->tk_ms_fiov, fdip->finh, + fdip->indata, fdip->iosize); + + fuse_setup_ihead(fdip->finh, fdip->tick, nid, op, fdip->iosize, pid, + cred); +} + +/* Initialize a dispatcher from a pid and node id */ +static void fdisp_make_pid(struct fuse_dispatcher *fdip, enum fuse_opcode op, struct mount *mp, uint64_t nid, pid_t pid, struct ucred *cred) { @@ -737,6 +786,22 @@ fdisp_make_vp(struct fuse_dispatcher *fdip, enum fuse_ RECTIFY_TDCR(td, cred); return fdisp_make_pid(fdip, op, vnode_mount(vp), VTOI(vp), td->td_proc->p_pid, cred); +} + +/* Refresh a fuse_dispatcher so it can be reused, but don't zero its data */ +void +fdisp_refresh_vp(struct fuse_dispatcher *fdip, enum fuse_opcode op, + struct vnode *vp, struct thread *td, struct ucred *cred) +{ + RECTIFY_TDCR(td, cred); + return fdisp_refresh_pid(fdip, op, vnode_mount(vp), VTOI(vp), + td->td_proc->p_pid, cred); +} + +void +fdisp_refresh(struct fuse_dispatcher *fdip) +{ + fticket_refresh(fdip->tick); } SDT_PROBE_DEFINE2(fuse, , ipc, fdisp_wait_answ_error, "char*", "int"); Modified: projects/fuse2/sys/fs/fuse/fuse_ipc.h ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_ipc.h Thu Apr 4 16:32:27 2019 (r345875) +++ projects/fuse2/sys/fs/fuse/fuse_ipc.h Thu Apr 4 16:51:34 2019 (r345876) @@ -374,13 +374,15 @@ fdisp_destroy(struct fuse_dispatcher *fdisp) #endif } +void fdisp_refresh(struct fuse_dispatcher *fdip); + void fdisp_make(struct fuse_dispatcher *fdip, enum fuse_opcode op, struct mount *mp, uint64_t nid, struct thread *td, struct ucred *cred); -void fdisp_make_pid(struct fuse_dispatcher *fdip, enum fuse_opcode op, - struct mount *mp, uint64_t nid, pid_t pid, struct ucred *cred); - void fdisp_make_vp(struct fuse_dispatcher *fdip, enum fuse_opcode op, + struct vnode *vp, struct thread *td, struct ucred *cred); + +void fdisp_refresh_vp(struct fuse_dispatcher *fdip, enum fuse_opcode op, struct vnode *vp, struct thread *td, struct ucred *cred); int fdisp_wait_answ(struct fuse_dispatcher *fdip); Modified: projects/fuse2/sys/fs/fuse/fuse_vnops.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_vnops.c Thu Apr 4 16:32:27 2019 (r345875) +++ projects/fuse2/sys/fs/fuse/fuse_vnops.c Thu Apr 4 16:51:34 2019 (r345876) @@ -2313,9 +2313,10 @@ fuse_vnop_listextattr(struct vop_listextattr_args *ap) /* * Retrieve Linux / FUSE compatible list values. */ - fdisp_make_vp(&fdi, FUSE_LISTXATTR, vp, td, cred); + fdisp_refresh_vp(&fdi, FUSE_LISTXATTR, vp, td, cred); list_xattr_in = fdi.indata; list_xattr_in->size = linux_list_len + sizeof(*list_xattr_out); + list_xattr_in->flags = 0; attr_str = (char *)fdi.indata + sizeof(*list_xattr_in); snprintf(attr_str, len, "%s%c", prefix, extattr_namespace_separator); Modified: projects/fuse2/tests/sys/fs/fusefs/mockfs.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/mockfs.cc Thu Apr 4 16:32:27 2019 (r345875) +++ projects/fuse2/tests/sys/fs/fusefs/mockfs.cc Thu Apr 4 16:51:34 2019 (r345876) @@ -246,7 +246,8 @@ void debug_fuseop(const mockfs_buf_in *in) printf(" %s=%s", name, value); break; case FUSE_WRITE: - printf(" offset=%lu size=%u flags=%u", + printf(" fh=%#lx offset=%lu size=%u flags=%u", + in->body.write.fh, in->body.write.offset, in->body.write.size, in->body.write.write_flags); break; Modified: projects/fuse2/tests/sys/fs/fusefs/write.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/write.cc Thu Apr 4 16:32:27 2019 (r345875) +++ projects/fuse2/tests/sys/fs/fusefs/write.cc Thu Apr 4 16:51:34 2019 (r345876) @@ -270,12 +270,43 @@ TEST_F(Write, DISABLED_direct_io_evicts_cache) /* Deliberately leak fd. close(2) will be tested in release.cc */ } +/* + * If the server doesn't return FOPEN_DIRECT_IO during FUSE_OPEN, then it's not + * allowed to return a short write for that file handle. However, if it does + * then we should still do our darndest to handle it by resending the unwritten + * portion. + */ +TEST_F(Write, indirect_io_short_write) +{ + const char FULLPATH[] = "mountpoint/some_file.txt"; + const char RELPATH[] = "some_file.txt"; + const char *CONTENTS = "abcdefghijklmnop"; + uint64_t ino = 42; + int fd; + ssize_t bufsize = strlen(CONTENTS); + ssize_t bufsize0 = 11; + ssize_t bufsize1 = strlen(CONTENTS) - bufsize0; + const char *contents1 = CONTENTS + bufsize0; + + expect_lookup(RELPATH, ino, 0); + expect_open(ino, 0, 1); + expect_getattr(ino, 0); + expect_write(ino, 0, bufsize, bufsize0, 0, CONTENTS); + expect_write(ino, bufsize0, bufsize1, bufsize1, 0, + contents1); + + fd = open(FULLPATH, O_WRONLY); + EXPECT_LE(0, fd) << strerror(errno); + + ASSERT_EQ(bufsize, write(fd, CONTENTS, bufsize)) << strerror(errno); + /* Deliberately leak fd. close(2) will be tested in release.cc */ +} + /* * When the direct_io option is used, filesystems are allowed to write less - * data than requested + * data than requested. We should return the short write to userland. */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236381 */ -TEST_F(Write, DISABLED_direct_io_short_write) +TEST_F(Write, direct_io_short_write) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; @@ -284,19 +315,16 @@ TEST_F(Write, DISABLED_direct_io_short_write) int fd; ssize_t bufsize = strlen(CONTENTS); ssize_t halfbufsize = bufsize / 2; - const char *halfcontents = CONTENTS + halfbufsize; expect_lookup(RELPATH, ino, 0); expect_open(ino, FOPEN_DIRECT_IO, 1); expect_getattr(ino, 0); expect_write(ino, 0, bufsize, halfbufsize, 0, CONTENTS); - expect_write(ino, halfbufsize, halfbufsize, halfbufsize, 0, - halfcontents); fd = open(FULLPATH, O_WRONLY); EXPECT_LE(0, fd) << strerror(errno); - ASSERT_EQ(bufsize, write(fd, CONTENTS, bufsize)) << strerror(errno); + ASSERT_EQ(halfbufsize, write(fd, CONTENTS, bufsize)) << strerror(errno); /* Deliberately leak fd. close(2) will be tested in release.cc */ } @@ -305,15 +333,13 @@ TEST_F(Write, DISABLED_direct_io_short_write) * difference between what we requested and what it actually wrote crosses an * iov element boundary */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236381 */ -TEST_F(Write, DISABLED_direct_io_short_write_iov) +TEST_F(Write, direct_io_short_write_iov) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; const char *CONTENTS0 = "abcdefgh"; const char *CONTENTS1 = "ijklmnop"; const char *EXPECTED0 = "abcdefghijklmnop"; - const char *EXPECTED1 = "hijklmnop"; uint64_t ino = 42; int fd; ssize_t size0 = strlen(CONTENTS0) - 1; @@ -325,7 +351,6 @@ TEST_F(Write, DISABLED_direct_io_short_write_iov) expect_open(ino, FOPEN_DIRECT_IO, 1); expect_getattr(ino, 0); expect_write(ino, 0, totalsize, size0, 0, EXPECTED0); - expect_write(ino, size0, size1, size1, 0, EXPECTED1); fd = open(FULLPATH, O_WRONLY); EXPECT_LE(0, fd) << strerror(errno); @@ -334,7 +359,7 @@ TEST_F(Write, DISABLED_direct_io_short_write_iov) iov[0].iov_len = strlen(CONTENTS0); iov[1].iov_base = (void*)CONTENTS1; iov[1].iov_len = strlen(CONTENTS1); - ASSERT_EQ(totalsize, writev(fd, iov, 2)) << strerror(errno); + ASSERT_EQ(size0, writev(fd, iov, 2)) << strerror(errno); /* Deliberately leak fd. close(2) will be tested in release.cc */ } From owner-svn-src-projects@freebsd.org Thu Apr 4 17:20:56 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6635B15318B1 for ; Thu, 4 Apr 2019 17:20:56 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 071EF8353C; Thu, 4 Apr 2019 17:20:56 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D80D17A2; Thu, 4 Apr 2019 17:20:55 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x34HKtrI029031; Thu, 4 Apr 2019 17:20:55 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x34HKtYn029030; Thu, 4 Apr 2019 17:20:55 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904041720.x34HKtYn029030@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Thu, 4 Apr 2019 17:20:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345877 - projects/fuse2-googletest-engine X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/fuse2-googletest-engine X-SVN-Commit-Revision: 345877 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 071EF8353C X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.949,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Apr 2019 17:20:56 -0000 Author: ngie Date: Thu Apr 4 17:20:55 2019 New Revision: 345877 URL: https://svnweb.freebsd.org/changeset/base/345877 Log: Copy ^/projects/fuse2 to ^/projects/fuse2-googletest-engine The purpose of this branch is to overlay the changes I'm proposing as part of ^/projects/kyua-use-googletest-test-interface with the work that asomers is doing, with the intent of making sure that the tests continue to function when the Google Test support is added to Kyua (see https://github.com/jmmv/kyua/pull/203 for more details). Added: - copied from r345876, projects/fuse2/ Directory Properties: projects/fuse2-googletest-engine/ (props changed) From owner-svn-src-projects@freebsd.org Thu Apr 4 18:11:58 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 814981551BB8 for ; Thu, 4 Apr 2019 18:11:58 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 244A685D96; Thu, 4 Apr 2019 18:11:58 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F2AF811C7; Thu, 4 Apr 2019 18:11:57 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x34IBvE2059841; Thu, 4 Apr 2019 18:11:57 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x34IBvUT059837; Thu, 4 Apr 2019 18:11:57 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904041811.x34IBvUT059837@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Thu, 4 Apr 2019 18:11:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345883 - in projects/fuse2-googletest-engine: lib/googletest/gmock/tests lib/googletest/gtest/tests lib/googletest/gtest_main/tests share/mk X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: in projects/fuse2-googletest-engine: lib/googletest/gmock/tests lib/googletest/gtest/tests lib/googletest/gtest_main/tests share/mk X-SVN-Commit-Revision: 345883 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 244A685D96 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.972,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Apr 2019 18:11:58 -0000 Author: ngie Date: Thu Apr 4 18:11:56 2019 New Revision: 345883 URL: https://svnweb.freebsd.org/changeset/base/345883 Log: Merge changes from ^/projects/kyua-use-googletest-test-interface svn merge -c 345749,345750 ^/projects/kyua-use-googletest-test-interface Modified: projects/fuse2-googletest-engine/lib/googletest/gmock/tests/Makefile projects/fuse2-googletest-engine/lib/googletest/gtest/tests/Makefile projects/fuse2-googletest-engine/lib/googletest/gtest_main/tests/Makefile projects/fuse2-googletest-engine/share/mk/googletest.test.mk Directory Properties: projects/fuse2-googletest-engine/ (props changed) Modified: projects/fuse2-googletest-engine/lib/googletest/gmock/tests/Makefile ============================================================================== --- projects/fuse2-googletest-engine/lib/googletest/gmock/tests/Makefile Thu Apr 4 17:29:43 2019 (r345882) +++ projects/fuse2-googletest-engine/lib/googletest/gmock/tests/Makefile Thu Apr 4 18:11:56 2019 (r345883) @@ -8,6 +8,11 @@ GTESTS+= gmock_stress_test LIBADD+= pthread gtest gmock +# This test cannot selectively run a single test, as it verifies results when +# `--gtest_list_tests` is run: +# https://github.com/google/googletest/issues/2204 +TEST_INTERFACE.gmock_stress_test= plain + # The next release will resolve a number of build warnings issues. NO_WERROR= Modified: projects/fuse2-googletest-engine/lib/googletest/gtest/tests/Makefile ============================================================================== --- projects/fuse2-googletest-engine/lib/googletest/gtest/tests/Makefile Thu Apr 4 17:29:43 2019 (r345882) +++ projects/fuse2-googletest-engine/lib/googletest/gtest/tests/Makefile Thu Apr 4 18:11:56 2019 (r345883) @@ -36,6 +36,17 @@ SRCS.googletest-param-test-test= \ LIBADD+= gtest +# These tests confuse the kyua googletest engine, as they don't conform to the +# googletest spec; they're functional unit tests for the library. +TEST_INTERFACE.gtest_environment_test= plain +TEST_INTERFACE.gtest_no_test_unittest= plain +TEST_INTERFACE.gtest_repeat_test= plain +TEST_INTERFACE.gtest_stress_test= plain +TEST_INTERFACE.gtest_throw_on_failure_ex_test= plain +# This test program cannot selectively run test suites/testcases: +# https://github.com/google/googletest/issues/2205 +TEST_INTERFACE.gtest-unittest-api_test= plain + # XXX: explicitly listing -lpthread is incorrect. src.libnames.mk should be # handling this. LIBADD.gtest_stress_test+= pthread Modified: projects/fuse2-googletest-engine/lib/googletest/gtest_main/tests/Makefile ============================================================================== --- projects/fuse2-googletest-engine/lib/googletest/gtest_main/tests/Makefile Thu Apr 4 17:29:43 2019 (r345882) +++ projects/fuse2-googletest-engine/lib/googletest/gtest_main/tests/Makefile Thu Apr 4 18:11:56 2019 (r345883) @@ -21,6 +21,11 @@ GTESTS+= gtest-typed-test_test GTESTS+= gtest_skip_test GTESTS+= gtest_unittest +# This test cannot selectively run a single test, as it verifies results when +# `--gtest_list_tests` is run: +# https://github.com/google/googletest/issues/2204 +TEST_INTERFACE.googletest-listener-test= plain + CXXFLAGS+= -I${GOOGLETEST_SRCROOT}/include CXXFLAGS+= -I${GOOGLETEST_SRCROOT} Modified: projects/fuse2-googletest-engine/share/mk/googletest.test.mk ============================================================================== --- projects/fuse2-googletest-engine/share/mk/googletest.test.mk Thu Apr 4 17:29:43 2019 (r345882) +++ projects/fuse2-googletest-engine/share/mk/googletest.test.mk Thu Apr 4 18:11:56 2019 (r345883) @@ -26,6 +26,16 @@ # manpage. GTESTS?= +# Default test interface for googletest +# +# This knob should be used if the version of kyua in use doesn't support the +# `googletest` test interface. +.ifdef GTESTS_USE_PLAIN_TEST_INTERFACE +GTESTS_DEFAULT_TEST_INTERFACE= plain +.else +GTESTS_DEFAULT_TEST_INTERFACE= googletest +.endif + .if !empty(GTESTS) .include @@ -36,6 +46,6 @@ BINDIR.${_T}= ${TESTSDIR} CXXFLAGS.${_T}+= ${GTESTS_CXXFLAGS} MAN.${_T}?= # empty SRCS.${_T}?= ${_T}.cc -TEST_INTERFACE.${_T}= plain +TEST_INTERFACE.${_T}?= ${GTESTS_DEFAULT_TEST_INTERFACE} .endfor .endif From owner-svn-src-projects@freebsd.org Thu Apr 4 18:13:02 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C47451551C18 for ; Thu, 4 Apr 2019 18:13:02 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6344C85EE4; Thu, 4 Apr 2019 18:13:02 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 35CAA11F1; Thu, 4 Apr 2019 18:13:02 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x34ID2P8060659; Thu, 4 Apr 2019 18:13:02 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x34ID2wY060658; Thu, 4 Apr 2019 18:13:02 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904041813.x34ID2wY060658@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Thu, 4 Apr 2019 18:13:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345884 - projects/fuse2-googletest-engine/sys/fs/fuse X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/fuse2-googletest-engine/sys/fs/fuse X-SVN-Commit-Revision: 345884 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 6344C85EE4 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.97)[-0.970,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Apr 2019 18:13:02 -0000 Author: ngie Date: Thu Apr 4 18:13:01 2019 New Revision: 345884 URL: https://svnweb.freebsd.org/changeset/base/345884 Log: Unbreak the fusefs module build with GENERIC-NODEBUG by merging ^/head@r345689 Modified: projects/fuse2-googletest-engine/sys/fs/fuse/fuse_ipc.c Directory Properties: projects/fuse2-googletest-engine/ (props changed) Modified: projects/fuse2-googletest-engine/sys/fs/fuse/fuse_ipc.c ============================================================================== --- projects/fuse2-googletest-engine/sys/fs/fuse/fuse_ipc.c Thu Apr 4 18:11:56 2019 (r345883) +++ projects/fuse2-googletest-engine/sys/fs/fuse/fuse_ipc.c Thu Apr 4 18:13:01 2019 (r345884) @@ -229,7 +229,9 @@ fticket_ctor(void *mem, int size, void *arg, int flags static void fticket_dtor(void *mem, int size, void *arg) { +#ifdef INVARIANTS struct fuse_ticket *ftick = mem; +#endif FUSE_ASSERT_MS_DONE(ftick); FUSE_ASSERT_AW_DONE(ftick); From owner-svn-src-projects@freebsd.org Thu Apr 4 18:26:34 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AE04A1552A72 for ; Thu, 4 Apr 2019 18:26:33 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CBB48675A; Thu, 4 Apr 2019 18:26:33 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 390C013D3; Thu, 4 Apr 2019 18:26:33 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x34IQXA9066145; Thu, 4 Apr 2019 18:26:33 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x34IQWOs066141; Thu, 4 Apr 2019 18:26:32 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904041826.x34IQWOs066141@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Thu, 4 Apr 2019 18:26:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345885 - in projects/fuse2: contrib/bsnmp/gensnmptree contrib/bsnmp/lib contrib/bsnmp/snmp_mibII contrib/bsnmp/snmpd contrib/capsicum-test contrib/elftoolchain/strings contrib/googlete... X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in projects/fuse2: contrib/bsnmp/gensnmptree contrib/bsnmp/lib contrib/bsnmp/snmp_mibII contrib/bsnmp/snmpd contrib/capsicum-test contrib/elftoolchain/strings contrib/googletest/googletest contrib/goo... X-SVN-Commit-Revision: 345885 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4CBB48675A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.970,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Apr 2019 18:26:34 -0000 Author: asomers Date: Thu Apr 4 18:26:32 2019 New Revision: 345885 URL: https://svnweb.freebsd.org/changeset/base/345885 Log: MFHead@r345880 Added: projects/fuse2/contrib/bsnmp/snmpd/trans_inet.c - copied unchanged from r345880, head/contrib/bsnmp/snmpd/trans_inet.c projects/fuse2/contrib/bsnmp/snmpd/trans_inet.h - copied unchanged from r345880, head/contrib/bsnmp/snmpd/trans_inet.h projects/fuse2/contrib/capsicum-test/ - copied from r345880, head/contrib/capsicum-test/ projects/fuse2/contrib/libxo/libxo/xo_explicit.h - copied unchanged from r345880, head/contrib/libxo/libxo/xo_explicit.h projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.H.err - copied unchanged from r345880, head/contrib/libxo/tests/xo/saved/xo_02.H.err projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.H.out - copied unchanged from r345880, head/contrib/libxo/tests/xo/saved/xo_02.H.out projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.HIPx.err - copied unchanged from r345880, head/contrib/libxo/tests/xo/saved/xo_02.HIPx.err projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.HIPx.out - copied unchanged from r345880, head/contrib/libxo/tests/xo/saved/xo_02.HIPx.out projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.HP.err - copied unchanged from r345880, head/contrib/libxo/tests/xo/saved/xo_02.HP.err projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.HP.out - copied unchanged from r345880, head/contrib/libxo/tests/xo/saved/xo_02.HP.out projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.J.err - copied unchanged from r345880, head/contrib/libxo/tests/xo/saved/xo_02.J.err projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.J.out - copied unchanged from r345880, head/contrib/libxo/tests/xo/saved/xo_02.J.out projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.JP.err - copied unchanged from r345880, head/contrib/libxo/tests/xo/saved/xo_02.JP.err projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.JP.out - copied unchanged from r345880, head/contrib/libxo/tests/xo/saved/xo_02.JP.out projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.T.err - copied unchanged from r345880, head/contrib/libxo/tests/xo/saved/xo_02.T.err projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.T.out - copied unchanged from r345880, head/contrib/libxo/tests/xo/saved/xo_02.T.out projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.X.err - copied unchanged from r345880, head/contrib/libxo/tests/xo/saved/xo_02.X.err projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.X.out - copied unchanged from r345880, head/contrib/libxo/tests/xo/saved/xo_02.X.out projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.XP.err - copied unchanged from r345880, head/contrib/libxo/tests/xo/saved/xo_02.XP.err projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.XP.out - copied unchanged from r345880, head/contrib/libxo/tests/xo/saved/xo_02.XP.out projects/fuse2/contrib/libxo/tests/xo/xo_02.sh - copied unchanged from r345880, head/contrib/libxo/tests/xo/xo_02.sh projects/fuse2/lib/libc/aarch64/static_tls.h - copied unchanged from r345880, head/lib/libc/aarch64/static_tls.h projects/fuse2/lib/libc/amd64/static_tls.h - copied unchanged from r345880, head/lib/libc/amd64/static_tls.h projects/fuse2/lib/libc/arm/static_tls.h - copied unchanged from r345880, head/lib/libc/arm/static_tls.h projects/fuse2/lib/libc/i386/static_tls.h - copied unchanged from r345880, head/lib/libc/i386/static_tls.h projects/fuse2/lib/libc/mips/static_tls.h - copied unchanged from r345880, head/lib/libc/mips/static_tls.h projects/fuse2/lib/libc/powerpc/static_tls.h - copied unchanged from r345880, head/lib/libc/powerpc/static_tls.h projects/fuse2/lib/libc/powerpc64/static_tls.h - copied unchanged from r345880, head/lib/libc/powerpc64/static_tls.h projects/fuse2/lib/libc/riscv/static_tls.h - copied unchanged from r345880, head/lib/libc/riscv/static_tls.h projects/fuse2/lib/libc/sparc64/static_tls.h - copied unchanged from r345880, head/lib/libc/sparc64/static_tls.h projects/fuse2/lib/libsecureboot/pass_manifest.c - copied unchanged from r345880, head/lib/libsecureboot/pass_manifest.c projects/fuse2/lib/libthr/arch/aarch64/include/pthread_tls.h - copied unchanged from r345880, head/lib/libthr/arch/aarch64/include/pthread_tls.h projects/fuse2/lib/libthr/arch/amd64/include/pthread_tls.h - copied unchanged from r345880, head/lib/libthr/arch/amd64/include/pthread_tls.h projects/fuse2/lib/libthr/arch/arm/include/pthread_tls.h - copied unchanged from r345880, head/lib/libthr/arch/arm/include/pthread_tls.h projects/fuse2/lib/libthr/arch/i386/include/pthread_tls.h - copied unchanged from r345880, head/lib/libthr/arch/i386/include/pthread_tls.h projects/fuse2/lib/libthr/arch/mips/include/pthread_tls.h - copied unchanged from r345880, head/lib/libthr/arch/mips/include/pthread_tls.h projects/fuse2/lib/libthr/arch/powerpc/include/pthread_tls.h - copied unchanged from r345880, head/lib/libthr/arch/powerpc/include/pthread_tls.h projects/fuse2/lib/libthr/arch/riscv/include/pthread_tls.h - copied unchanged from r345880, head/lib/libthr/arch/riscv/include/pthread_tls.h projects/fuse2/lib/libthr/arch/sparc64/include/pthread_tls.h - copied unchanged from r345880, head/lib/libthr/arch/sparc64/include/pthread_tls.h projects/fuse2/sys/security/mac_veriexec_parser/ - copied from r345880, head/sys/security/mac_veriexec_parser/ projects/fuse2/tests/sys/geom/class/eli/online_resize_test.sh - copied unchanged from r345880, head/tests/sys/geom/class/eli/online_resize_test.sh projects/fuse2/tools/build/options/WITH_LOADER_VERIEXEC_PASS_MANFIEST - copied unchanged from r345880, head/tools/build/options/WITH_LOADER_VERIEXEC_PASS_MANFIEST Modified: projects/fuse2/contrib/bsnmp/gensnmptree/gensnmptree.1 projects/fuse2/contrib/bsnmp/gensnmptree/gensnmptree.c projects/fuse2/contrib/bsnmp/lib/snmpclient.c projects/fuse2/contrib/bsnmp/lib/snmpclient.h projects/fuse2/contrib/bsnmp/lib/tc.def projects/fuse2/contrib/bsnmp/snmp_mibII/mibII_interfaces.c projects/fuse2/contrib/bsnmp/snmpd/BEGEMOT-SNMPD.txt projects/fuse2/contrib/bsnmp/snmpd/main.c projects/fuse2/contrib/bsnmp/snmpd/snmpd.config projects/fuse2/contrib/bsnmp/snmpd/snmpd.h projects/fuse2/contrib/bsnmp/snmpd/snmpmod.h projects/fuse2/contrib/bsnmp/snmpd/trans_lsock.c projects/fuse2/contrib/bsnmp/snmpd/trans_udp.c projects/fuse2/contrib/bsnmp/snmpd/trap.c projects/fuse2/contrib/bsnmp/snmpd/tree.def projects/fuse2/contrib/elftoolchain/strings/strings.c projects/fuse2/contrib/googletest/googletest/CMakeLists.txt projects/fuse2/contrib/googletest/googletest/Makefile.am projects/fuse2/contrib/googletest/googletest/docs/advanced.md projects/fuse2/contrib/googletest/googletest/src/gtest.cc projects/fuse2/contrib/googletest/googletest/test/BUILD.bazel projects/fuse2/contrib/libxo/configure.ac projects/fuse2/contrib/libxo/doc/api.rst projects/fuse2/contrib/libxo/doc/libxo-manual.html projects/fuse2/contrib/libxo/doc/xo.rst projects/fuse2/contrib/libxo/libxo/Makefile.am projects/fuse2/contrib/libxo/libxo/libxo.c projects/fuse2/contrib/libxo/libxo/xo.h projects/fuse2/contrib/libxo/libxo/xo_attr.3 projects/fuse2/contrib/libxo/libxo/xo_buf.h projects/fuse2/contrib/libxo/libxo/xo_emit.3 projects/fuse2/contrib/libxo/libxo/xo_emit_f.3 projects/fuse2/contrib/libxo/libxo/xo_finish.3 projects/fuse2/contrib/libxo/libxo/xo_flush.3 projects/fuse2/contrib/libxo/libxo/xo_open_container.3 projects/fuse2/contrib/libxo/libxo/xo_open_list.3 projects/fuse2/contrib/libxo/libxo/xo_open_marker.3 projects/fuse2/contrib/libxo/libxo/xo_set_writer.3 projects/fuse2/contrib/libxo/tests/core/saved/test_01.J.out projects/fuse2/contrib/libxo/tests/core/saved/test_02.J.out projects/fuse2/contrib/libxo/tests/core/saved/test_03.J.out projects/fuse2/contrib/libxo/tests/core/saved/test_04.J.out projects/fuse2/contrib/libxo/tests/core/saved/test_05.J.out projects/fuse2/contrib/libxo/tests/core/saved/test_05.JP.out projects/fuse2/contrib/libxo/tests/core/saved/test_06.J.out projects/fuse2/contrib/libxo/tests/core/saved/test_07.J.out projects/fuse2/contrib/libxo/tests/core/saved/test_08.J.out projects/fuse2/contrib/libxo/tests/core/saved/test_09.J.out projects/fuse2/contrib/libxo/tests/core/saved/test_10.J.out projects/fuse2/contrib/libxo/tests/core/saved/test_11.J.out projects/fuse2/contrib/libxo/tests/core/saved/test_12.E.err projects/fuse2/contrib/libxo/tests/core/saved/test_12.E.out projects/fuse2/contrib/libxo/tests/core/saved/test_12.H.err projects/fuse2/contrib/libxo/tests/core/saved/test_12.H.out projects/fuse2/contrib/libxo/tests/core/saved/test_12.HIPx.err projects/fuse2/contrib/libxo/tests/core/saved/test_12.HIPx.out projects/fuse2/contrib/libxo/tests/core/saved/test_12.HP.err projects/fuse2/contrib/libxo/tests/core/saved/test_12.HP.out projects/fuse2/contrib/libxo/tests/core/saved/test_12.J.err projects/fuse2/contrib/libxo/tests/core/saved/test_12.J.out projects/fuse2/contrib/libxo/tests/core/saved/test_12.JP.err projects/fuse2/contrib/libxo/tests/core/saved/test_12.JP.out projects/fuse2/contrib/libxo/tests/core/saved/test_12.T.err projects/fuse2/contrib/libxo/tests/core/saved/test_12.T.out projects/fuse2/contrib/libxo/tests/core/saved/test_12.X.err projects/fuse2/contrib/libxo/tests/core/saved/test_12.X.out projects/fuse2/contrib/libxo/tests/core/saved/test_12.XP.err projects/fuse2/contrib/libxo/tests/core/saved/test_12.XP.out projects/fuse2/contrib/libxo/tests/core/test_12.c projects/fuse2/contrib/libxo/tests/gettext/po/pig_latin/strerror.po projects/fuse2/contrib/libxo/tests/gettext/saved/gt_01.J.out projects/fuse2/contrib/libxo/tests/xo/Makefile.am projects/fuse2/contrib/libxo/tests/xo/saved/xo_01.H.out projects/fuse2/contrib/libxo/tests/xo/saved/xo_01.HIPx.out projects/fuse2/contrib/libxo/tests/xo/saved/xo_01.HP.out projects/fuse2/contrib/libxo/tests/xo/saved/xo_01.J.out projects/fuse2/contrib/libxo/tests/xo/saved/xo_01.JP.out projects/fuse2/contrib/libxo/tests/xo/saved/xo_01.T.out projects/fuse2/contrib/libxo/tests/xo/xo_01.sh projects/fuse2/contrib/libxo/xo/xo.1 projects/fuse2/contrib/libxo/xo/xo.c projects/fuse2/contrib/llvm/tools/clang/lib/CodeGen/CGObjCGNU.cpp projects/fuse2/gnu/usr.bin/gdb/gdb/Makefile projects/fuse2/gnu/usr.bin/gdb/kgdb/Makefile projects/fuse2/lib/clang/llvm.build.mk projects/fuse2/lib/geom/eli/geli.8 projects/fuse2/lib/geom/eli/geom_eli.c projects/fuse2/lib/googletest/gtest_main/tests/Makefile projects/fuse2/lib/libbe/be.c projects/fuse2/lib/libbsnmp/libbsnmp/Makefile projects/fuse2/lib/libc++/Makefile projects/fuse2/lib/libc++experimental/Makefile projects/fuse2/lib/libc++fs/Makefile projects/fuse2/lib/libc/gen/Symbol.map projects/fuse2/lib/libc/gen/elf_utils.c projects/fuse2/lib/libc/include/libc_private.h projects/fuse2/lib/libc/sys/interposing_table.c projects/fuse2/lib/libc/tests/stdlib/Makefile projects/fuse2/lib/libcam/Makefile projects/fuse2/lib/libclang_rt/Makefile.inc projects/fuse2/lib/libcxxrt/Makefile projects/fuse2/lib/libgcc_eh/Makefile.inc projects/fuse2/lib/libomp/Makefile projects/fuse2/lib/libsecureboot/Makefile.libsa.inc projects/fuse2/lib/libsecureboot/h/verify_file.h projects/fuse2/lib/libsecureboot/libsecureboot-priv.h projects/fuse2/lib/libsecureboot/verify_file.c projects/fuse2/lib/libthr/Makefile projects/fuse2/lib/libthr/pthread.map projects/fuse2/lib/libthr/thread/thr_list.c projects/fuse2/lib/libthr/thread/thr_private.h projects/fuse2/lib/libvgl/main.c projects/fuse2/lib/libvgl/mouse.c projects/fuse2/lib/libxo/xo_config.h projects/fuse2/lib/ofed/libibnetdisc/Makefile projects/fuse2/libexec/rc/rc.d/random projects/fuse2/libexec/rtld-elf/arm/reloc.c projects/fuse2/libexec/rtld-elf/mips/reloc.c projects/fuse2/libexec/rtld-elf/rtld.c projects/fuse2/libexec/rtld-elf/rtld.h projects/fuse2/libexec/save-entropy/save-entropy.sh projects/fuse2/release/Makefile.vm projects/fuse2/release/tools/ec2.conf projects/fuse2/release/tools/vmimage.subr projects/fuse2/sbin/bectl/bectl.8 projects/fuse2/sbin/bectl/tests/bectl_test.sh projects/fuse2/sbin/devd/devd.conf.5 projects/fuse2/sbin/fsck_msdosfs/dir.c projects/fuse2/share/man/man4/asmc.4 projects/fuse2/share/mk/bsd.progs.mk projects/fuse2/share/mk/bsd.sys.mk projects/fuse2/share/mk/googletest.test.inc.mk projects/fuse2/share/mk/src.opts.mk projects/fuse2/stand/common/boot.c projects/fuse2/stand/common/module.c projects/fuse2/stand/loader.mk projects/fuse2/sys/amd64/acpica/acpi_machdep.c projects/fuse2/sys/arm/allwinner/aw_mmc.c projects/fuse2/sys/arm/allwinner/clkng/aw_clk_nm.c projects/fuse2/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c projects/fuse2/sys/arm/ti/cpsw/if_cpsw.c projects/fuse2/sys/arm64/acpica/acpi_machdep.c projects/fuse2/sys/cam/ata/ata_all.c projects/fuse2/sys/cam/cam.c projects/fuse2/sys/cam/cam_ccb.h projects/fuse2/sys/cam/cam_periph.c projects/fuse2/sys/cam/mmc/mmc_da.c projects/fuse2/sys/cam/nvme/nvme_all.c projects/fuse2/sys/cam/nvme/nvme_all.h projects/fuse2/sys/cam/nvme/nvme_da.c projects/fuse2/sys/cam/nvme/nvme_xpt.c projects/fuse2/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c projects/fuse2/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c projects/fuse2/sys/compat/freebsd32/freebsd32_misc.c projects/fuse2/sys/compat/linuxkpi/common/include/linux/etherdevice.h projects/fuse2/sys/compat/linuxkpi/common/include/linux/random.h projects/fuse2/sys/conf/NOTES projects/fuse2/sys/conf/files projects/fuse2/sys/conf/ldscript.powerpc64 projects/fuse2/sys/contrib/dev/acpica/changes.txt projects/fuse2/sys/contrib/dev/acpica/common/acfileio.c projects/fuse2/sys/contrib/dev/acpica/common/adisasm.c projects/fuse2/sys/contrib/dev/acpica/common/adwalk.c projects/fuse2/sys/contrib/dev/acpica/common/ahpredef.c projects/fuse2/sys/contrib/dev/acpica/common/ahtable.c projects/fuse2/sys/contrib/dev/acpica/common/dmrestag.c projects/fuse2/sys/contrib/dev/acpica/common/dmtable.c projects/fuse2/sys/contrib/dev/acpica/common/dmtables.c projects/fuse2/sys/contrib/dev/acpica/compiler/aslanalyze.c projects/fuse2/sys/contrib/dev/acpica/compiler/aslcodegen.c projects/fuse2/sys/contrib/dev/acpica/compiler/aslcompiler.l projects/fuse2/sys/contrib/dev/acpica/compiler/asldefine.h projects/fuse2/sys/contrib/dev/acpica/compiler/aslerror.c projects/fuse2/sys/contrib/dev/acpica/compiler/aslload.c projects/fuse2/sys/contrib/dev/acpica/compiler/aslmessages.c projects/fuse2/sys/contrib/dev/acpica/compiler/aslmethod.c projects/fuse2/sys/contrib/dev/acpica/compiler/asloffset.c projects/fuse2/sys/contrib/dev/acpica/compiler/asloperands.c projects/fuse2/sys/contrib/dev/acpica/compiler/aslopt.c projects/fuse2/sys/contrib/dev/acpica/compiler/aslpredef.c projects/fuse2/sys/contrib/dev/acpica/compiler/asltransform.c projects/fuse2/sys/contrib/dev/acpica/compiler/aslutils.c projects/fuse2/sys/contrib/dev/acpica/compiler/aslxref.c projects/fuse2/sys/contrib/dev/acpica/compiler/dtcompile.c projects/fuse2/sys/contrib/dev/acpica/compiler/dttemplate.c projects/fuse2/sys/contrib/dev/acpica/components/debugger/dbexec.c projects/fuse2/sys/contrib/dev/acpica/components/debugger/dbnames.c projects/fuse2/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c projects/fuse2/sys/contrib/dev/acpica/components/disassembler/dmnames.c projects/fuse2/sys/contrib/dev/acpica/components/dispatcher/dsfield.c projects/fuse2/sys/contrib/dev/acpica/components/dispatcher/dsinit.c projects/fuse2/sys/contrib/dev/acpica/components/events/evgpeinit.c projects/fuse2/sys/contrib/dev/acpica/components/executer/exnames.c projects/fuse2/sys/contrib/dev/acpica/components/namespace/nsaccess.c projects/fuse2/sys/contrib/dev/acpica/components/namespace/nsdump.c projects/fuse2/sys/contrib/dev/acpica/components/namespace/nsinit.c projects/fuse2/sys/contrib/dev/acpica/components/namespace/nsnames.c projects/fuse2/sys/contrib/dev/acpica/components/namespace/nsobject.c projects/fuse2/sys/contrib/dev/acpica/components/namespace/nsparse.c projects/fuse2/sys/contrib/dev/acpica/components/namespace/nsrepair.c projects/fuse2/sys/contrib/dev/acpica/components/namespace/nsrepair2.c projects/fuse2/sys/contrib/dev/acpica/components/namespace/nsutils.c projects/fuse2/sys/contrib/dev/acpica/components/namespace/nsxfname.c projects/fuse2/sys/contrib/dev/acpica/components/parser/psargs.c projects/fuse2/sys/contrib/dev/acpica/components/resources/rsxface.c projects/fuse2/sys/contrib/dev/acpica/components/tables/tbdata.c projects/fuse2/sys/contrib/dev/acpica/components/tables/tbfind.c projects/fuse2/sys/contrib/dev/acpica/components/tables/tbinstal.c projects/fuse2/sys/contrib/dev/acpica/components/tables/tbprint.c projects/fuse2/sys/contrib/dev/acpica/components/tables/tbutils.c projects/fuse2/sys/contrib/dev/acpica/components/tables/tbxface.c projects/fuse2/sys/contrib/dev/acpica/components/tables/tbxfload.c projects/fuse2/sys/contrib/dev/acpica/components/utilities/utascii.c projects/fuse2/sys/contrib/dev/acpica/components/utilities/utdecode.c projects/fuse2/sys/contrib/dev/acpica/components/utilities/utmisc.c projects/fuse2/sys/contrib/dev/acpica/components/utilities/utpredef.c projects/fuse2/sys/contrib/dev/acpica/components/utilities/utstring.c projects/fuse2/sys/contrib/dev/acpica/include/aclocal.h projects/fuse2/sys/contrib/dev/acpica/include/acpixf.h projects/fuse2/sys/contrib/dev/acpica/include/actbl.h projects/fuse2/sys/contrib/dev/acpica/include/actypes.h projects/fuse2/sys/dev/acpica/Osd/OsdTable.c projects/fuse2/sys/dev/acpica/acpi_quirk.c projects/fuse2/sys/dev/cxgbe/common/t4_hw.c projects/fuse2/sys/dev/cxgbe/offload.h projects/fuse2/sys/dev/cxgbe/t4_main.c projects/fuse2/sys/dev/cxgbe/tom/t4_cpl_io.c projects/fuse2/sys/dev/cxgbe/tom/t4_ddp.c projects/fuse2/sys/dev/cxgbe/tom/t4_tls.c projects/fuse2/sys/dev/fdt/fdt_common.c projects/fuse2/sys/dev/ioat/ioat.c projects/fuse2/sys/dev/ioat/ioat_internal.h projects/fuse2/sys/dev/ioat/ioat_test.c projects/fuse2/sys/dev/ioat/ioat_test.h projects/fuse2/sys/dev/ipmi/ipmi_opal.c projects/fuse2/sys/dev/md/md.c projects/fuse2/sys/dev/pci/pci.c projects/fuse2/sys/dev/sdhci/sdhci.c projects/fuse2/sys/dev/tpm/tpm20.c projects/fuse2/sys/dev/usb/wlan/if_run.c projects/fuse2/sys/dev/usb/wlan/if_uath.c projects/fuse2/sys/dev/usb/wlan/if_urtw.c projects/fuse2/sys/dev/usb/wlan/if_urtwvar.h projects/fuse2/sys/dev/xen/blkfront/blkfront.c projects/fuse2/sys/fs/fuse/fuse_ipc.c projects/fuse2/sys/fs/msdosfs/msdosfs_denode.c projects/fuse2/sys/fs/tmpfs/tmpfs.h projects/fuse2/sys/fs/tmpfs/tmpfs_fifoops.c projects/fuse2/sys/fs/tmpfs/tmpfs_subr.c projects/fuse2/sys/fs/tmpfs/tmpfs_vfsops.c projects/fuse2/sys/fs/tmpfs/tmpfs_vnops.c projects/fuse2/sys/geom/eli/g_eli.c projects/fuse2/sys/geom/eli/g_eli.h projects/fuse2/sys/geom/eli/g_eli_ctl.c projects/fuse2/sys/geom/eli/g_eli_key_cache.c projects/fuse2/sys/geom/geom_dev.c projects/fuse2/sys/i386/acpica/acpi_machdep.c projects/fuse2/sys/kern/imgact_elf.c projects/fuse2/sys/net/if_spppsubr.c projects/fuse2/sys/net/if_stf.c projects/fuse2/sys/netinet/in_pcb.c projects/fuse2/sys/netinet/tcp_output.c projects/fuse2/sys/netinet/tcp_var.h projects/fuse2/sys/netinet6/in6.c projects/fuse2/sys/netinet6/in6_ifattach.c projects/fuse2/sys/netinet6/nd6.c projects/fuse2/sys/netipsec/key.c projects/fuse2/sys/netipsec/key.h projects/fuse2/sys/netipsec/xform_esp.c projects/fuse2/sys/netpfil/pf/pf.c projects/fuse2/sys/powerpc/fpu/fpu_sqrt.c projects/fuse2/sys/powerpc/include/trap.h projects/fuse2/sys/powerpc/powernv/opal.h projects/fuse2/sys/powerpc/powernv/opal_async.c projects/fuse2/sys/powerpc/powernv/opal_dev.c projects/fuse2/sys/powerpc/powerpc/exec_machdep.c projects/fuse2/sys/powerpc/powerpc/trap.c projects/fuse2/sys/riscv/riscv/plic.c projects/fuse2/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c projects/fuse2/sys/sys/ata.h projects/fuse2/sys/vm/vm_kern.c projects/fuse2/sys/vm/vm_map.c projects/fuse2/sys/vm/vm_map.h projects/fuse2/sys/x86/iommu/busdma_dmar.c projects/fuse2/tests/sys/audit/Makefile projects/fuse2/tests/sys/audit/process-control.c projects/fuse2/tests/sys/capsicum/Makefile projects/fuse2/tests/sys/capsicum/ioctls_test.c projects/fuse2/tests/sys/geom/class/eli/Makefile projects/fuse2/tests/sys/geom/class/eli/configure_test.sh projects/fuse2/tools/build/Makefile projects/fuse2/tools/tools/ioat/ioatcontrol.8 projects/fuse2/tools/tools/ioat/ioatcontrol.c projects/fuse2/usr.bin/dtc/Makefile projects/fuse2/usr.bin/rctl/rctl.c projects/fuse2/usr.bin/strings/Makefile projects/fuse2/usr.bin/systat/devs.c projects/fuse2/usr.bin/systat/devs.h projects/fuse2/usr.bin/systat/iostat.c projects/fuse2/usr.bin/systat/swap.c projects/fuse2/usr.bin/systat/systat.h projects/fuse2/usr.bin/systat/vmstat.c projects/fuse2/usr.bin/systat/zarc.c projects/fuse2/usr.bin/top/display.c projects/fuse2/usr.bin/xohtml/xohtml.sh projects/fuse2/usr.sbin/acpi/acpidump/acpi.c projects/fuse2/usr.sbin/bsnmpd/bsnmpd/Makefile projects/fuse2/usr.sbin/bsnmpd/bsnmpd/snmpd.config projects/fuse2/usr.sbin/iostat/iostat.c projects/fuse2/usr.sbin/pmc/Makefile Directory Properties: projects/fuse2/ (props changed) projects/fuse2/contrib/elftoolchain/ (props changed) projects/fuse2/contrib/libxo/ (props changed) projects/fuse2/contrib/llvm/ (props changed) projects/fuse2/contrib/llvm/tools/clang/ (props changed) projects/fuse2/gnu/usr.bin/gdb/ (props changed) projects/fuse2/sys/cddl/contrib/opensolaris/ (props changed) projects/fuse2/sys/contrib/dev/acpica/ (props changed) Modified: projects/fuse2/contrib/bsnmp/gensnmptree/gensnmptree.1 ============================================================================== --- projects/fuse2/contrib/bsnmp/gensnmptree/gensnmptree.1 Thu Apr 4 18:13:01 2019 (r345884) +++ projects/fuse2/contrib/bsnmp/gensnmptree/gensnmptree.1 Thu Apr 4 18:26:32 2019 (r345885) @@ -31,7 +31,7 @@ .\" .\" $Begemot: gensnmptree.1 383 2006-05-30 07:40:49Z brandt_h $ .\" -.Dd June 29, 2018 +.Dd April 2, 2019 .Dt GENSNMPTREE 1 .Os .Sh NAME @@ -100,25 +100,11 @@ is the length of the OID. is the last component of the OID. .El .It Fl F -Together with -.Fl E -causes -.Nm -instead of the generation of enum definitions the generation of -functions for checking a value to be one of the enumeration variants and -for conversion between strings and the enum. The file is sent to standard -output and is meant to be included into a C-file for compilation. +emit definitions for C-functions includeable in a C-file that do some basic +stuff on enums like value checking and conversion between value and strings. .It Fl f -This flag can be used together with -.Fl E -or when generating the tree files. It causes -.Nm -to emit static inline functions for checking a value to be one of the -enumeration values and for conversion between strings and the enum. -If used when generating the tree files, the preprocessor symbol -.Ar SNMPTREE_TYPES -must be defined when including the tree header file for these definitions -to become visible. +emit definitions for inline C-functions that do some basic +stuff on enums like value checking and conversion between value and strings. .It Fl h Print a short help page. .It Fl I Ar directory @@ -136,36 +122,6 @@ Instead of normal output print the resulting tree. Prefix the file names and the table name with .Ar prefix . .El -.Pp -The following functions are generated by -.Fl f -or -.Fl F : -.Pp -.Ft static inline int -.Fn isok_EnumName "enum EnumName" ; -.Pp -.Ft static inline const char * -.Fn tostr_EnumName "enum EnumName" ; -.Pp -.Ft static inline int -.Fn fromstr_EnumName "const char *" "enum EnumName *" ; -.Pp -The -.Fa EnumName -is replaced with the enumeration name. -.Fn isok_EnumName -returns 1 if the argument is one of the valid enum values and 0 otherwise. -.Fn tostr_EnumName -returns a string representation of the enumeration value. -If the values is not one of the legal values -.Ar EnumName??? -is returned. -.Fn fromstr_EnumName -returns 1 if the string represents one of the legal enumeration values and -0 otherwise. -If 1 is return the variable pointed to by the second argument is set to -the enumeration value. .Sh MIBS The syntax of the MIB description file can formally be specified as follows: .Bd -unfilled -offset indent Modified: projects/fuse2/contrib/bsnmp/gensnmptree/gensnmptree.c ============================================================================== --- projects/fuse2/contrib/bsnmp/gensnmptree/gensnmptree.c Thu Apr 4 18:13:01 2019 (r345884) +++ projects/fuse2/contrib/bsnmp/gensnmptree/gensnmptree.c Thu Apr 4 18:26:32 2019 (r345885) @@ -110,7 +110,6 @@ static int debug; static const char usgtxt[] = "\ Generate SNMP tables.\n\ -$Id$\n\ usage: gensnmptree [-dEeFfhlt] [-I directory] [-i infile] [-p prefix]\n\ [name]...\n\ options:\n\ @@ -127,6 +126,37 @@ options:\n\ -t generate a .def file\n\ "; +/** + * Program operation. + */ +enum op { + /** generate the tree */ + OP_GEN, + + /** extract OIDs */ + OP_EXTRACT, + + /** print the parsed tree */ + OP_TREE, + + /** extract enums */ + OP_ENUMS, +}; + +/** + * Which functions to create. + */ +enum gen_funcs { + /** none */ + GEN_FUNCS_NONE, + + /** functions for header files */ + GEN_FUNCS_H, + + /** functions for C files */ + GEN_FUNCS_C, +}; + /* * A node in the OID tree */ @@ -162,15 +192,18 @@ struct node { uint32_t index; /* index for table entry */ char *func; /* function for tables */ struct node_list subs; + char *subtypes[SNMP_INDEXES_MAX]; } entry; struct leaf { enum snmp_syntax syntax; /* syntax for this leaf */ char *func; /* function name */ + char *subtype; /* subtype */ } leaf; struct column { enum snmp_syntax syntax; /* syntax for this column */ + char *subtype; /* subtype */ } column; } u; }; @@ -214,7 +247,7 @@ xalloc(size_t size) { void *ptr; - if ((ptr = malloc(size)) == NULL) + if ((ptr = calloc(1, size)) == NULL) err(1, "allocing %zu bytes", size); return (ptr); @@ -710,12 +743,14 @@ make_type(const char *s) * token. */ static u_int -parse_type(enum tok *tok, struct type *t, const char *vname) +parse_type(enum tok *tok, struct type *t, const char *vname, char **subtype) { u_int syntax; struct enums *e; syntax = val; + if (subtype != NULL) + *subtype = NULL; if (*tok == TOK_ENUM || *tok == TOK_BITS) { if (t == NULL && vname != NULL) { @@ -759,6 +794,8 @@ parse_type(enum tok *tok, struct type *t, const char * if ((*tok = gettoken()) == '|') { if (gettoken() != TOK_STR) report("subtype expected after '|'"); + if (subtype != NULL) + *subtype = savetok(); *tok = gettoken(); } } @@ -794,18 +831,21 @@ parse(enum tok tok) if ((tok = gettoken()) == TOK_TYPE || tok == TOK_DEFTYPE || tok == TOK_ENUM || tok == TOK_BITS) { /* LEAF or COLUM */ - u_int syntax = parse_type(&tok, NULL, node->name); + char *subtype; + u_int syntax = parse_type(&tok, NULL, node->name, &subtype); if (tok == TOK_STR) { /* LEAF */ node->type = NODE_LEAF; node->u.leaf.func = savetok(); node->u.leaf.syntax = syntax; + node->u.leaf.subtype = subtype; tok = gettoken(); } else { /* COLUMN */ node->type = NODE_COLUMN; node->u.column.syntax = syntax; + node->u.column.subtype = subtype; } while (tok != ')') { @@ -825,9 +865,12 @@ parse(enum tok tok) tok = gettoken(); while (tok == TOK_TYPE || tok == TOK_DEFTYPE || tok == TOK_ENUM || tok == TOK_BITS) { - u_int syntax = parse_type(&tok, NULL, node->name); - if (index_count++ == SNMP_INDEXES_MAX) + char *subtype; + u_int syntax = parse_type(&tok, NULL, node->name, + &subtype); + if (index_count == SNMP_INDEXES_MAX) report("too many table indexes"); + node->u.entry.subtypes[index_count++] = subtype; node->u.entry.index |= syntax << (SNMP_INDEX_SHIFT * index_count); } @@ -882,7 +925,8 @@ parse_top(enum tok tok) tok = gettoken(); t->is_enum = (tok == TOK_ENUM); t->is_bits = (tok == TOK_BITS); - t->syntax = parse_type(&tok, t, NULL); + + t->syntax = parse_type(&tok, t, NULL, NULL); pushback(tok); return (NULL); @@ -903,7 +947,7 @@ parse_top(enum tok tok) * Generate the C-code table part for one node. */ static void -gen_node(FILE *fp, struct node *np, struct asn_oid *oid, u_int idx, +gen_node(FILE *fp, const struct node *np, struct asn_oid *oid, u_int idx, const char *func) { u_int n; @@ -1008,7 +1052,7 @@ gen_node(FILE *fp, struct node *np, struct asn_oid *oi * Generate the header file with the function declarations. */ static void -gen_header(FILE *fp, struct node *np, u_int oidlen, const char *func) +gen_header(FILE *fp, const struct node *np, u_int oidlen, const char *func) { char f[MAXSTR + 4]; struct node *sub; @@ -1058,7 +1102,7 @@ gen_header(FILE *fp, struct node *np, u_int oidlen, co * Generate the OID table. */ static void -gen_table(FILE *fp, struct node *node) +gen_table(FILE *fp, const struct node *node) { struct asn_oid oid; @@ -1067,7 +1111,6 @@ gen_table(FILE *fp, struct node *node) #ifdef HAVE_STDINT_H fprintf(fp, "#include \n"); #endif - fprintf(fp, "#include \n"); if (localincs) { fprintf(fp, "#include \"asn1.h\"\n"); fprintf(fp, "#include \"snmp.h\"\n"); @@ -1118,6 +1161,8 @@ gen_tree(const struct node *np, int level) case NODE_LEAF: print_syntax(np->u.leaf.syntax); + if (np->u.leaf.subtype != NULL) + printf(" | %s", np->u.leaf.subtype); printf(" %s%s%s)\n", np->u.leaf.func, (np->flags & FL_GET) ? " GET" : "", (np->flags & FL_SET) ? " SET" : ""); @@ -1137,8 +1182,11 @@ gen_tree(const struct node *np, int level) case NODE_ENTRY: printf(" :"); - for (i = 0; i < SNMP_INDEX_COUNT(np->u.entry.index); i++) + for (i = 0; i < SNMP_INDEX_COUNT(np->u.entry.index); i++) { print_syntax(SNMP_INDEX(np->u.entry.index, i)); + if (np->u.entry.subtypes[i] != NULL) + printf(" | %s", np->u.entry.subtypes[i]); + } printf(" %s\n", np->u.entry.func); TAILQ_FOREACH(sp, &np->u.entry.subs, link) gen_tree(sp, level + 1); @@ -1147,6 +1195,8 @@ gen_tree(const struct node *np, int level) case NODE_COLUMN: print_syntax(np->u.column.syntax); + if (np->u.column.subtype != NULL) + printf(" | %s", np->u.column.subtype); printf("%s%s)\n", (np->flags & FL_GET) ? " GET" : "", (np->flags & FL_SET) ? " SET" : ""); break; @@ -1194,15 +1244,6 @@ extract(FILE *fp, const struct node *np, struct asn_oi return (1); } -/** - * Extract the named OID. - * - * \param fp file to extract to - * \param root root of the tree - * \param object name of the object to extract - * - * \return 0 on success, -1 if the object was not found - */ static int gen_extract(FILE *fp, const struct node *root, char *object) { @@ -1391,45 +1432,6 @@ unminus(FILE *fp, const char *s) } /** - * Generate a definition for the enum packed into a guard against multiple - * definitions. - * - * \param fp file to write definition to - * \param t type - */ -static void -gen_enum(FILE *fp, const struct type *t) -{ - const struct enums *e; - long min = LONG_MAX; - - fprintf(fp, "\n"); - fprintf(fp, "#ifndef %s_defined__\n", t->name); - fprintf(fp, "#define %s_defined__\n", t->name); - fprintf(fp, "/*\n"); - fprintf(fp, " * From %s:%u\n", t->from_fname, t->from_lno); - fprintf(fp, " */\n"); - fprintf(fp, "enum %s {\n", t->name); - TAILQ_FOREACH(e, &t->enums, link) { - fprintf(fp, "\t%s_", t->name); - unminus(fp, e->name); - fprintf(fp, " = %ld,\n", e->value); - if (e->value < min) - min = e->value; - } - fprintf(fp, "};\n"); - fprintf(fp, "#define STROFF_%s %ld\n", t->name, min); - fprintf(fp, "#define STRING_%s \\\n", t->name); - TAILQ_FOREACH(e, &t->enums, link) { - fprintf(fp, "\t[%ld] = \"%s_", e->value - min, t->name); - unminus(fp, e->name); - fprintf(fp, "\",\\\n"); - } - fprintf(fp, "\n"); - fprintf(fp, "#endif /* %s_defined__ */\n", t->name); -} - -/** * Generate helper functions for an enum. * * We always generate a switch statement for the isok function. The compiler @@ -1494,6 +1496,54 @@ gen_enum_funcs(FILE *fp, const struct type *t, int cco } /** + * Generate a definition for the enum packed into a guard against multiple + * definitions. + * + * \param fp file to write definition to + * \param t type + * \param dof generate functions too + */ +static void +gen_enum(FILE *fp, const struct type *t, int dof) +{ + const struct enums *e; + long min = LONG_MAX; + + fprintf(fp, "\n"); + fprintf(fp, "#ifndef %s_defined__\n", t->name); + fprintf(fp, "#define %s_defined__\n", t->name); + fprintf(fp, "/*\n"); + fprintf(fp, " * From %s:%u\n", t->from_fname, t->from_lno); + fprintf(fp, " */\n"); + fprintf(fp, "enum %s {\n", t->name); + TAILQ_FOREACH(e, &t->enums, link) { + fprintf(fp, "\t%s_", t->name); + unminus(fp, e->name); + fprintf(fp, " = %ld,\n", e->value); + if (e->value < min) + min = e->value; + } + fprintf(fp, "};\n"); + fprintf(fp, "#define STROFF_%s %ld\n", t->name, min); + fprintf(fp, "#define STRING_%s \\\n", t->name); + TAILQ_FOREACH(e, &t->enums, link) { + fprintf(fp, "\t[%ld] = \"%s_", e->value - min, t->name); + unminus(fp, e->name); + fprintf(fp, "\",\\\n"); + } + fprintf(fp, "\n"); + if (dof) { + fprintf(fp, "#ifdef SNMPENUM_FUNCS\n"); + fprintf(fp, "\n"); + gen_enum_funcs(fp, t, 0); + fprintf(fp, "\n"); + fprintf(fp, "#endif\n"); + fprintf(fp, "\n"); + } + fprintf(fp, "#endif /* %s_defined__ */\n", t->name); +} + +/** * Generate helper functions for an enum. This generates code for a c file. * * \param fp file to write to @@ -1529,6 +1579,16 @@ gen_all_enum_funcs(FILE *fp, int ccode) gen_enum_funcs(fp, t, ccode); } +static void +gen_enums(FILE *fp, int dof) +{ + const struct type *t; + + LIST_FOREACH(t, &types, link) + if (t->is_enum || t->is_bits) + gen_enum(fp, t, dof); +} + /** * Extract a given enum to the specified file and optionally generate static * inline helper functions for them. @@ -1546,9 +1606,7 @@ extract_enum(FILE *fp, const char *name, int gen_funcs LIST_FOREACH(t, &types, link) if ((t->is_enum || t->is_bits) && strcmp(t->name, name) == 0) { - gen_enum(fp, t); - if (gen_funcs) - gen_enum_funcs(fp, t, 0); + gen_enum(fp, t, gen_funcs); return (0); } return (-1); @@ -1567,11 +1625,8 @@ extract_all_enums(FILE *fp, int gen_funcs) const struct type *t; LIST_FOREACH(t, &types, link) - if (t->is_enum || t->is_bits) { - gen_enum(fp, t); - if (gen_funcs) - gen_enum_funcs(fp, t, 0); - } + if (t->is_enum || t->is_bits) + gen_enum(fp, t, gen_funcs); } /** @@ -1579,13 +1634,12 @@ extract_all_enums(FILE *fp, int gen_funcs) * * \param argc number of arguments * \param argv arguments (enum names) - * \param gen_funcs_h generate functions into the header file - * \param gen_funcs_c generate a .c file with functions + * \param gen_funcs which functions to generate */ static void -make_enums(int argc, char *argv[], int gen_funcs_h, int gen_funcs_c) +make_enums(int argc, char *argv[], enum gen_funcs gen_funcs) { - if (gen_funcs_c) { + if (gen_funcs == GEN_FUNCS_C) { if (argc == 0) gen_all_enum_funcs(stdout, 1); else { @@ -1595,30 +1649,58 @@ make_enums(int argc, char *argv[], int gen_funcs_h, in } } else { if (argc == 0) - extract_all_enums(stdout, gen_funcs_h); + extract_all_enums(stdout, gen_funcs == GEN_FUNCS_H); else { for (int i = 0; i < argc; i++) - if (extract_enum(stdout, argv[i], gen_funcs_h)) + if (extract_enum(stdout, argv[i], + gen_funcs == GEN_FUNCS_H)) errx(1, "enum not found: %s", argv[i]); } } } +/** + * Produce the operation tables for the daemon or a module. + * + * \param root tree root + * \param gen_funcs generate enum funcs + */ +static void +make_table(const struct node *root, int gen_funcs) +{ + FILE *fp; + + char fname[MAXPATHLEN + 1]; + sprintf(fname, "%stree.h", file_prefix); + if ((fp = fopen(fname, "w")) == NULL) + err(1, "%s: ", fname); + gen_header(fp, root, PREFIX_LEN, NULL); + + fprintf(fp, "\n#ifdef SNMPTREE_TYPES\n"); + gen_enums(fp, gen_funcs); + fprintf(fp, "\n#endif /* SNMPTREE_TYPES */\n\n"); + + fprintf(fp, "#define %sCTREE_SIZE %u\n", file_prefix, tree_size); + fprintf(fp, "extern const struct snmp_node %sctree[];\n", file_prefix); + + fclose(fp); + + sprintf(fname, "%stree.c", file_prefix); + if ((fp = fopen(fname, "w")) == NULL) + err(1, "%s: ", fname); + gen_table(fp, root); + fclose(fp); +} + int main(int argc, char *argv[]) { - int do_extract = 0; - int do_tree = 0; - int do_enums = 0; - int gen_funcs_h = 0; - int gen_funcs_c = 0; - int opt; - struct node *root; - char fname[MAXPATHLEN + 1]; - int tok; - FILE *fp; + enum op op = OP_GEN; + enum gen_funcs gen_funcs = GEN_FUNCS_NONE; + char *infile = NULL; + int opt; while ((opt = getopt(argc, argv, "dEeFfhI:i:lp:t")) != EOF) switch (opt) { @@ -1627,19 +1709,29 @@ main(int argc, char *argv[]) break; case 'E': - do_enums = 1; + if (op != OP_GEN && op != OP_ENUMS) + errx(1, "-E conflicts with earlier options"); + op = OP_ENUMS; break; case 'e': - do_extract = 1; + if (op != OP_GEN && op != OP_EXTRACT) + errx(1, "-e conflicts with earlier options"); + op = OP_EXTRACT; break; case 'F': - gen_funcs_c = 1; + if (gen_funcs != GEN_FUNCS_NONE && + gen_funcs != GEN_FUNCS_C) + errx(1, "-F conflicts with -f"); + gen_funcs = GEN_FUNCS_C; break; case 'f': - gen_funcs_h = 1; + if (gen_funcs != GEN_FUNCS_NONE && + gen_funcs != GEN_FUNCS_H) + errx(1, "-f conflicts with -F"); + gen_funcs = GEN_FUNCS_H; break; case 'h': @@ -1666,75 +1758,61 @@ main(int argc, char *argv[]) break; case 't': - do_tree = 1; + if (op != OP_GEN && op != OP_TREE) + errx(1, "-t conflicts with earlier options"); + op = OP_TREE; break; } - if (do_extract + do_tree + do_enums > 1) - errx(1, "conflicting options -e/-t/-E"); - if (!do_extract && !do_enums && argc != optind) - errx(1, "no arguments allowed"); - if (do_extract && argc == optind) - errx(1, "no objects specified"); + argc -= optind; + argv += optind; - if ((gen_funcs_h || gen_funcs_c) && (do_extract || do_tree)) - errx(1, "-f and -F not allowed with -e or -t"); - if (gen_funcs_c && !do_enums) - errx(1, "-F requires -E"); - if (gen_funcs_h && gen_funcs_c) - errx(1, "-f and -F are mutually exclusive"); - + /* open input */ if (infile == NULL) { input_new(stdin, NULL, ""); } else { + FILE *fp; if ((fp = fopen(infile, "r")) == NULL) err(1, "%s", infile); input_new(fp, NULL, infile); } - root = parse_top(gettoken()); + /* parse and check input */ + struct node *root = parse_top(gettoken()); + + int tok; while ((tok = gettoken()) != TOK_EOF) merge(&root, parse_top(tok)); if (root) check_tree(root); - if (do_extract) { - while (optind < argc) { - if (gen_extract(stdout, root, argv[optind])) - errx(1, "object not found: %s", argv[optind]); - optind++; - } + /* do what the user has requested */ + switch (op) { + + case OP_EXTRACT: + if (argc == 0) + errx(1, "-e requires arguments"); + + for (int i = 0; i < argc; i++) + if (gen_extract(stdout, root, argv[i])) + errx(1, "object not found: %s", argv[i]); return (0); - } - if (do_enums) { - make_enums(argc - optind, argv + optind, - gen_funcs_h, gen_funcs_c); + + case OP_ENUMS: + make_enums(argc, argv, gen_funcs); return (0); - } - if (do_tree) { + + case OP_TREE: + if (argc != 0) + errx(1, "-t allows no arguments"); gen_tree(root, 0); return (0); - } - sprintf(fname, "%stree.h", file_prefix); - if ((fp = fopen(fname, "w")) == NULL) - err(1, "%s: ", fname); - gen_header(fp, root, PREFIX_LEN, NULL); - fprintf(fp, "\n#ifdef SNMPTREE_TYPES\n"); - extract_all_enums(fp, gen_funcs_h); - fprintf(fp, "\n#endif /* SNMPTREE_TYPES */\n\n"); - - fprintf(fp, "#define %sCTREE_SIZE %u\n", file_prefix, tree_size); - fprintf(fp, "extern const struct snmp_node %sctree[];\n", file_prefix); - - fclose(fp); - - sprintf(fname, "%stree.c", file_prefix); - if ((fp = fopen(fname, "w")) == NULL) - err(1, "%s: ", fname); - gen_table(fp, root); - fclose(fp); - - return (0); + case OP_GEN: + if (argc != 0) + errx(1, "tree generation allows no arguments"); + make_table(root, gen_funcs == GEN_FUNCS_H); + return (0); + } } Modified: projects/fuse2/contrib/bsnmp/lib/snmpclient.c ============================================================================== --- projects/fuse2/contrib/bsnmp/lib/snmpclient.c Thu Apr 4 18:13:01 2019 (r345884) +++ projects/fuse2/contrib/bsnmp/lib/snmpclient.c Thu Apr 4 18:26:32 2019 (r345885) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2005 + * Copyright (c) 2004-2005,2018 * Hartmut Brandt. * All rights reserved. * Copyright (c) 2001-2003 @@ -34,11 +34,13 @@ * * Support functions for SNMP clients. */ -#include +#include #include #include #include #include +#include +#include #include #include #include @@ -58,12 +60,16 @@ #include #endif +#include + #include "support.h" #include "asn1.h" #include "snmp.h" #include "snmpclient.h" #include "snmppriv.h" +#define DEBUG_PARSE 0 + /* global context */ struct snmp_client snmp_client; @@ -924,7 +930,8 @@ open_client_udp(const char *host, const char *port) /* open connection */ memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_CANONNAME; - hints.ai_family = AF_INET; + hints.ai_family = snmp_client.trans == SNMP_TRANS_UDP ? AF_INET: + AF_INET6; hints.ai_socktype = SOCK_DGRAM; hints.ai_protocol = 0; error = getaddrinfo(snmp_client.chost, snmp_client.cport, &hints, &res0); @@ -1068,6 +1075,7 @@ snmp_open(const char *host, const char *port, const ch switch (snmp_client.trans) { case SNMP_TRANS_UDP: + case SNMP_TRANS_UDP6: if (open_client_udp(host, port) != 0) return (-1); break; @@ -1866,99 +1874,412 @@ snmp_client_set_port(struct snmp_client *cl, const cha return (0); } -/* - * parse a server specification +static const char *const trans_list[] = { + [SNMP_TRANS_UDP] = "udp::", + [SNMP_TRANS_LOC_DGRAM] = "dgram::", + [SNMP_TRANS_LOC_STREAM] = "stream::", + [SNMP_TRANS_UDP6] = "udp6::", +}; + +/** + * Try to get a transport identifier which is a leading alphanumeric string + * terminated by a double colon. The string may not be empty. The transport + * identifier is optional. * - * [trans::][community@][server][:port] + * \param sc client struct to set errors + * \param strp possible start of transport; updated to point to + * the next character to parse + * + * \return transport identifier */ -int -snmp_parse_server(struct snmp_client *sc, const char *str) +static inline int +get_transp(struct snmp_client *sc, const char **strp) { - const char *p, *s = str; + const char *p; + size_t i; - /* look for a double colon */ - for (p = s; *p != '\0'; p++) { - if (*p == '\\' && p[1] != '\0') { - p++; + for (i = 0; i < nitems(trans_list); i++) { + if (trans_list[i] == NULL || *trans_list[i] == '\0') continue; + p = strstr(*strp, trans_list[i]); + if (p == *strp) { + *strp += strlen(trans_list[i]); + return ((int)i); } - if (*p == ':' && p[1] == ':') - break; } - if (*p != '\0') { - if (p > s) { - if (p - s == 3 && strncmp(s, "udp", 3) == 0) - sc->trans = SNMP_TRANS_UDP; - else if (p - s == 6 && strncmp(s, "stream", 6) == 0) - sc->trans = SNMP_TRANS_LOC_STREAM; - else if (p - s == 5 && strncmp(s, "dgram", 5) == 0) - sc->trans = SNMP_TRANS_LOC_DGRAM; - else { - seterr(sc, "unknown SNMP transport '%.*s'", - (int)(p - s), s); - return (-1); - } - } - s = p + 2; + + p = *strp; + if (p[0] == ':' && p[1] == ':') { + seterr(sc, "empty transport specifier"); + return (-1); } + /* by default assume UDP */ + return (SNMP_TRANS_UDP); +} - /* look for a @ */ - for (p = s; *p != '\0'; p++) { - if (*p == '\\' && p[1] != '\0') { - p++; - continue; - } - if (*p == '@') - break; +/** + * Try to get community string. Eat everything up to the last @ (if there is + * any) but only if it is not longer than SNMP_COMMUNITY_MAXLEN. Empty + * community strings are legal. + * + * \param sc client struct to set errors + * \param strp possible start of community; updated to the point to + * the next character to parse + * + * \return end of community; equals *strp if there is none; NULL if there + * was an error + */ +static inline const char * +get_comm(struct snmp_client *sc, const char **strp) +{ + const char *p = strrchr(*strp, '@'); + + if (p == NULL) + /* no community string */ + return (*strp); + + if (p - *strp > SNMP_COMMUNITY_MAXLEN) { + seterr(sc, "community string too long '%.*s'", + p - *strp, *strp); + return (NULL); } - if (*p != '\0') { - if (p - s > SNMP_COMMUNITY_MAXLEN) { - seterr(sc, "community string too long"); - return (-1); + *strp = p + 1; + return (p); +} + +/** + * Try to get an IPv6 address. This starts with an [ and should end with an ] + * and everything between should be not longer than INET6_ADDRSTRLEN and + * parseable by inet_pton(). + * + * \param sc client struct to set errors + * \param strp possible start of IPv6 address (the '['); updated to point to + * the next character to parse (the one after the closing ']') + * + * \return end of address (equals *strp + 1 if there is none) or NULL + * on errors + */ +static inline const char * +get_ipv6(struct snmp_client *sc, const char **strp) +{ + char str[INET6_ADDRSTRLEN + IF_NAMESIZE]; + struct addrinfo hints, *res; + int error; + + if (**strp != '[') + return (*strp + 1); + + const char *p = *strp + 1; + while (*p != ']' ) { + if (*p == '\0') { + seterr(sc, "unterminated IPv6 address '%.*s'", + p - *strp, *strp); + return (NULL); } - strncpy(sc->read_community, s, p - s); - sc->read_community[p - s] = '\0'; - strncpy(sc->write_community, s, p - s); - sc->write_community[p - s] = '\0'; - s = p + 1; + p++; } - /* look for a colon */ - for (p = s; *p != '\0'; p++) { - if (*p == '\\' && p[1] != '\0') { - p++; - continue; - } - if (*p == ':') - break; + if (p - *strp > INET6_ADDRSTRLEN + IF_NAMESIZE) { + seterr(sc, "IPv6 address too long '%.*s'", p - *strp, *strp); + return (NULL); } - if (*p == ':') { - if (p > s) { - /* host:port */ - free(sc->chost); - if ((sc->chost = malloc(p - s + 1)) == NULL) { - seterr(sc, "%s", strerror(errno)); - return (-1); - } - strncpy(sc->chost, s, p - s); - sc->chost[p - s] = '\0'; - } - /* port */ - free(sc->cport); - if ((sc->cport = strdup(p + 1)) == NULL) { - seterr(sc, "%s", strerror(errno)); - return (-1); - } + strncpy(str, *strp + 1, p - (*strp + 1)); + str[p - (*strp + 1)] = '\0'; - } else if (p > s) { - /* host */ - free(sc->chost); - if ((sc->chost = strdup(s)) == NULL) { - seterr(sc, "%s", strerror(errno)); + memset(&hints, 0, sizeof(hints)); + hints.ai_flags = AI_CANONNAME | AI_NUMERICHOST; + hints.ai_family = AF_INET6; + hints.ai_socktype = SOCK_DGRAM; + hints.ai_protocol = IPPROTO_UDP; + error = getaddrinfo(str, NULL, &hints, &res); + if (error != 0) { + seterr(sc, "%s: %s", str, gai_strerror(error)); + return (NULL); + } + freeaddrinfo(res); + *strp = p + 1; + return (p); +} + +/** + * Try to get an IPv4 address. This starts with a digit and consists of digits + * and dots, is not longer INET_ADDRSTRLEN and must be parseable by + * inet_aton(). + * + * \param sc client struct to set errors + * \param strp possible start of IPv4 address; updated to point to the + * next character to parse + * + * \return end of address (equals *strp if there is none) or NULL + * on errors + */ +static inline const char * +get_ipv4(struct snmp_client *sc, const char **strp) +{ + const char *p = *strp; + + while (isascii(*p) && (isdigit(*p) || *p == '.')) + p++; + + if (p - *strp > INET_ADDRSTRLEN) { + seterr(sc, "IPv4 address too long '%.*s'", p - *strp, *strp); + return (NULL); + } + if (*strp == p) + return *strp; + + char str[INET_ADDRSTRLEN + 1]; + strncpy(str, *strp, p - *strp); + str[p - *strp] = '\0'; + + struct in_addr addr; + if (inet_aton(str, &addr) != 1) { + seterr(sc, "illegal IPv4 address '%s'", str); + return (NULL); + } + + *strp = p; + return (p); +} + +/** + * Try to get a hostname. This includes everything up to but not including + * the last colon (if any). There is no length restriction. + * + * \param sc client struct to set errors + * \param strp possible start of hostname; updated to point to the next + * character to parse (the trailing NUL character or the last + * colon) + * *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-projects@freebsd.org Thu Apr 4 18:37:32 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8DB521552F0D for ; Thu, 4 Apr 2019 18:37:32 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 35C1786CE3; Thu, 4 Apr 2019 18:37:32 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0E2D4157F; Thu, 4 Apr 2019 18:37:32 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x34IbWH4071757; Thu, 4 Apr 2019 18:37:32 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x34IbVEI071753; Thu, 4 Apr 2019 18:37:31 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904041837.x34IbVEI071753@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Thu, 4 Apr 2019 18:37:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345886 - in projects/fuse2-googletest-engine: contrib/bsnmp/gensnmptree contrib/bsnmp/lib contrib/bsnmp/snmp_mibII contrib/bsnmp/snmpd contrib/capsicum-test contrib/elftoolchain/string... X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: in projects/fuse2-googletest-engine: contrib/bsnmp/gensnmptree contrib/bsnmp/lib contrib/bsnmp/snmp_mibII contrib/bsnmp/snmpd contrib/capsicum-test contrib/elftoolchain/strings contrib/googletest/goog... X-SVN-Commit-Revision: 345886 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 35C1786CE3 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.97)[-0.970,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Apr 2019 18:37:33 -0000 Author: ngie Date: Thu Apr 4 18:37:30 2019 New Revision: 345886 URL: https://svnweb.freebsd.org/changeset/base/345886 Log: MFprojects/fuse2@r345885 Added: projects/fuse2-googletest-engine/contrib/bsnmp/snmpd/trans_inet.c - copied unchanged from r345885, projects/fuse2/contrib/bsnmp/snmpd/trans_inet.c projects/fuse2-googletest-engine/contrib/bsnmp/snmpd/trans_inet.h - copied unchanged from r345885, projects/fuse2/contrib/bsnmp/snmpd/trans_inet.h projects/fuse2-googletest-engine/contrib/capsicum-test/ - copied from r345885, projects/fuse2/contrib/capsicum-test/ projects/fuse2-googletest-engine/contrib/libxo/libxo/xo_explicit.h - copied unchanged from r345885, projects/fuse2/contrib/libxo/libxo/xo_explicit.h projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_02.H.err - copied unchanged from r345885, projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.H.err projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_02.H.out - copied unchanged from r345885, projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.H.out projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_02.HIPx.err - copied unchanged from r345885, projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.HIPx.err projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_02.HIPx.out - copied unchanged from r345885, projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.HIPx.out projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_02.HP.err - copied unchanged from r345885, projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.HP.err projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_02.HP.out - copied unchanged from r345885, projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.HP.out projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_02.J.err - copied unchanged from r345885, projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.J.err projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_02.J.out - copied unchanged from r345885, projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.J.out projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_02.JP.err - copied unchanged from r345885, projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.JP.err projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_02.JP.out - copied unchanged from r345885, projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.JP.out projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_02.T.err - copied unchanged from r345885, projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.T.err projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_02.T.out - copied unchanged from r345885, projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.T.out projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_02.X.err - copied unchanged from r345885, projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.X.err projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_02.X.out - copied unchanged from r345885, projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.X.out projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_02.XP.err - copied unchanged from r345885, projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.XP.err projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_02.XP.out - copied unchanged from r345885, projects/fuse2/contrib/libxo/tests/xo/saved/xo_02.XP.out projects/fuse2-googletest-engine/contrib/libxo/tests/xo/xo_02.sh - copied unchanged from r345885, projects/fuse2/contrib/libxo/tests/xo/xo_02.sh projects/fuse2-googletest-engine/lib/libc/aarch64/static_tls.h - copied unchanged from r345885, projects/fuse2/lib/libc/aarch64/static_tls.h projects/fuse2-googletest-engine/lib/libc/amd64/static_tls.h - copied unchanged from r345885, projects/fuse2/lib/libc/amd64/static_tls.h projects/fuse2-googletest-engine/lib/libc/arm/static_tls.h - copied unchanged from r345885, projects/fuse2/lib/libc/arm/static_tls.h projects/fuse2-googletest-engine/lib/libc/i386/static_tls.h - copied unchanged from r345885, projects/fuse2/lib/libc/i386/static_tls.h projects/fuse2-googletest-engine/lib/libc/mips/static_tls.h - copied unchanged from r345885, projects/fuse2/lib/libc/mips/static_tls.h projects/fuse2-googletest-engine/lib/libc/powerpc/static_tls.h - copied unchanged from r345885, projects/fuse2/lib/libc/powerpc/static_tls.h projects/fuse2-googletest-engine/lib/libc/powerpc64/static_tls.h - copied unchanged from r345885, projects/fuse2/lib/libc/powerpc64/static_tls.h projects/fuse2-googletest-engine/lib/libc/riscv/static_tls.h - copied unchanged from r345885, projects/fuse2/lib/libc/riscv/static_tls.h projects/fuse2-googletest-engine/lib/libc/sparc64/static_tls.h - copied unchanged from r345885, projects/fuse2/lib/libc/sparc64/static_tls.h projects/fuse2-googletest-engine/lib/libsecureboot/pass_manifest.c - copied unchanged from r345885, projects/fuse2/lib/libsecureboot/pass_manifest.c projects/fuse2-googletest-engine/lib/libthr/arch/aarch64/include/pthread_tls.h - copied unchanged from r345885, projects/fuse2/lib/libthr/arch/aarch64/include/pthread_tls.h projects/fuse2-googletest-engine/lib/libthr/arch/amd64/include/pthread_tls.h - copied unchanged from r345885, projects/fuse2/lib/libthr/arch/amd64/include/pthread_tls.h projects/fuse2-googletest-engine/lib/libthr/arch/arm/include/pthread_tls.h - copied unchanged from r345885, projects/fuse2/lib/libthr/arch/arm/include/pthread_tls.h projects/fuse2-googletest-engine/lib/libthr/arch/i386/include/pthread_tls.h - copied unchanged from r345885, projects/fuse2/lib/libthr/arch/i386/include/pthread_tls.h projects/fuse2-googletest-engine/lib/libthr/arch/mips/include/pthread_tls.h - copied unchanged from r345885, projects/fuse2/lib/libthr/arch/mips/include/pthread_tls.h projects/fuse2-googletest-engine/lib/libthr/arch/powerpc/include/pthread_tls.h - copied unchanged from r345885, projects/fuse2/lib/libthr/arch/powerpc/include/pthread_tls.h projects/fuse2-googletest-engine/lib/libthr/arch/riscv/include/pthread_tls.h - copied unchanged from r345885, projects/fuse2/lib/libthr/arch/riscv/include/pthread_tls.h projects/fuse2-googletest-engine/lib/libthr/arch/sparc64/include/pthread_tls.h - copied unchanged from r345885, projects/fuse2/lib/libthr/arch/sparc64/include/pthread_tls.h projects/fuse2-googletest-engine/sys/security/mac_veriexec_parser/ - copied from r345885, projects/fuse2/sys/security/mac_veriexec_parser/ projects/fuse2-googletest-engine/tests/sys/geom/class/eli/online_resize_test.sh - copied unchanged from r345885, projects/fuse2/tests/sys/geom/class/eli/online_resize_test.sh projects/fuse2-googletest-engine/tools/build/options/WITH_LOADER_VERIEXEC_PASS_MANFIEST - copied unchanged from r345885, projects/fuse2/tools/build/options/WITH_LOADER_VERIEXEC_PASS_MANFIEST Modified: projects/fuse2-googletest-engine/contrib/bsnmp/gensnmptree/gensnmptree.1 projects/fuse2-googletest-engine/contrib/bsnmp/gensnmptree/gensnmptree.c projects/fuse2-googletest-engine/contrib/bsnmp/lib/snmpclient.c projects/fuse2-googletest-engine/contrib/bsnmp/lib/snmpclient.h projects/fuse2-googletest-engine/contrib/bsnmp/lib/tc.def projects/fuse2-googletest-engine/contrib/bsnmp/snmp_mibII/mibII_interfaces.c projects/fuse2-googletest-engine/contrib/bsnmp/snmpd/BEGEMOT-SNMPD.txt projects/fuse2-googletest-engine/contrib/bsnmp/snmpd/main.c projects/fuse2-googletest-engine/contrib/bsnmp/snmpd/snmpd.config projects/fuse2-googletest-engine/contrib/bsnmp/snmpd/snmpd.h projects/fuse2-googletest-engine/contrib/bsnmp/snmpd/snmpmod.h projects/fuse2-googletest-engine/contrib/bsnmp/snmpd/trans_lsock.c projects/fuse2-googletest-engine/contrib/bsnmp/snmpd/trans_udp.c projects/fuse2-googletest-engine/contrib/bsnmp/snmpd/trap.c projects/fuse2-googletest-engine/contrib/bsnmp/snmpd/tree.def projects/fuse2-googletest-engine/contrib/elftoolchain/strings/strings.c projects/fuse2-googletest-engine/contrib/googletest/googletest/CMakeLists.txt projects/fuse2-googletest-engine/contrib/googletest/googletest/Makefile.am projects/fuse2-googletest-engine/contrib/googletest/googletest/docs/advanced.md projects/fuse2-googletest-engine/contrib/googletest/googletest/src/gtest.cc projects/fuse2-googletest-engine/contrib/googletest/googletest/test/BUILD.bazel projects/fuse2-googletest-engine/contrib/libxo/configure.ac projects/fuse2-googletest-engine/contrib/libxo/doc/api.rst projects/fuse2-googletest-engine/contrib/libxo/doc/libxo-manual.html projects/fuse2-googletest-engine/contrib/libxo/doc/xo.rst projects/fuse2-googletest-engine/contrib/libxo/libxo/Makefile.am projects/fuse2-googletest-engine/contrib/libxo/libxo/libxo.c projects/fuse2-googletest-engine/contrib/libxo/libxo/xo.h projects/fuse2-googletest-engine/contrib/libxo/libxo/xo_attr.3 projects/fuse2-googletest-engine/contrib/libxo/libxo/xo_buf.h projects/fuse2-googletest-engine/contrib/libxo/libxo/xo_emit.3 projects/fuse2-googletest-engine/contrib/libxo/libxo/xo_emit_f.3 projects/fuse2-googletest-engine/contrib/libxo/libxo/xo_finish.3 projects/fuse2-googletest-engine/contrib/libxo/libxo/xo_flush.3 projects/fuse2-googletest-engine/contrib/libxo/libxo/xo_open_container.3 projects/fuse2-googletest-engine/contrib/libxo/libxo/xo_open_list.3 projects/fuse2-googletest-engine/contrib/libxo/libxo/xo_open_marker.3 projects/fuse2-googletest-engine/contrib/libxo/libxo/xo_set_writer.3 projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_01.J.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_02.J.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_03.J.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_04.J.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_05.J.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_05.JP.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_06.J.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_07.J.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_08.J.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_09.J.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_10.J.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_11.J.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_12.E.err projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_12.E.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_12.H.err projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_12.H.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_12.HIPx.err projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_12.HIPx.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_12.HP.err projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_12.HP.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_12.J.err projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_12.J.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_12.JP.err projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_12.JP.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_12.T.err projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_12.T.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_12.X.err projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_12.X.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_12.XP.err projects/fuse2-googletest-engine/contrib/libxo/tests/core/saved/test_12.XP.out projects/fuse2-googletest-engine/contrib/libxo/tests/core/test_12.c projects/fuse2-googletest-engine/contrib/libxo/tests/gettext/po/pig_latin/strerror.po projects/fuse2-googletest-engine/contrib/libxo/tests/gettext/saved/gt_01.J.out projects/fuse2-googletest-engine/contrib/libxo/tests/xo/Makefile.am projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_01.H.out projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_01.HIPx.out projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_01.HP.out projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_01.J.out projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_01.JP.out projects/fuse2-googletest-engine/contrib/libxo/tests/xo/saved/xo_01.T.out projects/fuse2-googletest-engine/contrib/libxo/tests/xo/xo_01.sh projects/fuse2-googletest-engine/contrib/libxo/xo/xo.1 projects/fuse2-googletest-engine/contrib/libxo/xo/xo.c projects/fuse2-googletest-engine/contrib/llvm/tools/clang/lib/CodeGen/CGObjCGNU.cpp projects/fuse2-googletest-engine/gnu/usr.bin/gdb/gdb/Makefile projects/fuse2-googletest-engine/gnu/usr.bin/gdb/kgdb/Makefile projects/fuse2-googletest-engine/lib/clang/llvm.build.mk projects/fuse2-googletest-engine/lib/geom/eli/geli.8 projects/fuse2-googletest-engine/lib/geom/eli/geom_eli.c projects/fuse2-googletest-engine/lib/googletest/gtest_main/tests/Makefile projects/fuse2-googletest-engine/lib/libbe/be.c projects/fuse2-googletest-engine/lib/libbsnmp/libbsnmp/Makefile projects/fuse2-googletest-engine/lib/libc++/Makefile projects/fuse2-googletest-engine/lib/libc++experimental/Makefile projects/fuse2-googletest-engine/lib/libc++fs/Makefile projects/fuse2-googletest-engine/lib/libc/gen/Symbol.map projects/fuse2-googletest-engine/lib/libc/gen/elf_utils.c projects/fuse2-googletest-engine/lib/libc/include/libc_private.h projects/fuse2-googletest-engine/lib/libc/sys/interposing_table.c projects/fuse2-googletest-engine/lib/libc/tests/stdlib/Makefile projects/fuse2-googletest-engine/lib/libcam/Makefile projects/fuse2-googletest-engine/lib/libclang_rt/Makefile.inc projects/fuse2-googletest-engine/lib/libcxxrt/Makefile projects/fuse2-googletest-engine/lib/libgcc_eh/Makefile.inc projects/fuse2-googletest-engine/lib/libomp/Makefile projects/fuse2-googletest-engine/lib/libsecureboot/Makefile.libsa.inc projects/fuse2-googletest-engine/lib/libsecureboot/h/verify_file.h projects/fuse2-googletest-engine/lib/libsecureboot/libsecureboot-priv.h projects/fuse2-googletest-engine/lib/libsecureboot/verify_file.c projects/fuse2-googletest-engine/lib/libthr/Makefile projects/fuse2-googletest-engine/lib/libthr/pthread.map projects/fuse2-googletest-engine/lib/libthr/thread/thr_list.c projects/fuse2-googletest-engine/lib/libthr/thread/thr_private.h projects/fuse2-googletest-engine/lib/libvgl/main.c projects/fuse2-googletest-engine/lib/libvgl/mouse.c projects/fuse2-googletest-engine/lib/libxo/xo_config.h projects/fuse2-googletest-engine/lib/ofed/libibnetdisc/Makefile projects/fuse2-googletest-engine/libexec/rc/rc.d/random projects/fuse2-googletest-engine/libexec/rtld-elf/arm/reloc.c projects/fuse2-googletest-engine/libexec/rtld-elf/mips/reloc.c projects/fuse2-googletest-engine/libexec/rtld-elf/rtld.c projects/fuse2-googletest-engine/libexec/rtld-elf/rtld.h projects/fuse2-googletest-engine/libexec/save-entropy/save-entropy.sh projects/fuse2-googletest-engine/release/Makefile.vm projects/fuse2-googletest-engine/release/tools/ec2.conf projects/fuse2-googletest-engine/release/tools/vmimage.subr projects/fuse2-googletest-engine/sbin/bectl/bectl.8 projects/fuse2-googletest-engine/sbin/bectl/tests/bectl_test.sh projects/fuse2-googletest-engine/sbin/devd/devd.conf.5 projects/fuse2-googletest-engine/sbin/fsck_msdosfs/dir.c projects/fuse2-googletest-engine/share/man/man4/asmc.4 projects/fuse2-googletest-engine/share/mk/bsd.progs.mk projects/fuse2-googletest-engine/share/mk/bsd.sys.mk projects/fuse2-googletest-engine/share/mk/googletest.test.inc.mk projects/fuse2-googletest-engine/share/mk/src.opts.mk projects/fuse2-googletest-engine/stand/common/boot.c projects/fuse2-googletest-engine/stand/common/module.c projects/fuse2-googletest-engine/stand/loader.mk projects/fuse2-googletest-engine/sys/amd64/acpica/acpi_machdep.c projects/fuse2-googletest-engine/sys/arm/allwinner/aw_mmc.c projects/fuse2-googletest-engine/sys/arm/allwinner/clkng/aw_clk_nm.c projects/fuse2-googletest-engine/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c projects/fuse2-googletest-engine/sys/arm/ti/cpsw/if_cpsw.c projects/fuse2-googletest-engine/sys/arm64/acpica/acpi_machdep.c projects/fuse2-googletest-engine/sys/cam/ata/ata_all.c projects/fuse2-googletest-engine/sys/cam/cam.c projects/fuse2-googletest-engine/sys/cam/cam_ccb.h projects/fuse2-googletest-engine/sys/cam/cam_periph.c projects/fuse2-googletest-engine/sys/cam/mmc/mmc_da.c projects/fuse2-googletest-engine/sys/cam/nvme/nvme_all.c projects/fuse2-googletest-engine/sys/cam/nvme/nvme_all.h projects/fuse2-googletest-engine/sys/cam/nvme/nvme_da.c projects/fuse2-googletest-engine/sys/cam/nvme/nvme_xpt.c projects/fuse2-googletest-engine/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c projects/fuse2-googletest-engine/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c projects/fuse2-googletest-engine/sys/compat/freebsd32/freebsd32_misc.c projects/fuse2-googletest-engine/sys/compat/linuxkpi/common/include/linux/etherdevice.h projects/fuse2-googletest-engine/sys/compat/linuxkpi/common/include/linux/random.h projects/fuse2-googletest-engine/sys/conf/NOTES projects/fuse2-googletest-engine/sys/conf/files projects/fuse2-googletest-engine/sys/conf/ldscript.powerpc64 projects/fuse2-googletest-engine/sys/contrib/dev/acpica/changes.txt projects/fuse2-googletest-engine/sys/contrib/dev/acpica/common/acfileio.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/common/adisasm.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/common/adwalk.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/common/ahpredef.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/common/ahtable.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/common/dmrestag.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/common/dmtable.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/common/dmtables.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/compiler/aslanalyze.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/compiler/aslcodegen.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/compiler/aslcompiler.l projects/fuse2-googletest-engine/sys/contrib/dev/acpica/compiler/asldefine.h projects/fuse2-googletest-engine/sys/contrib/dev/acpica/compiler/aslerror.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/compiler/aslload.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/compiler/aslmessages.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/compiler/aslmethod.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/compiler/asloffset.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/compiler/asloperands.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/compiler/aslopt.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/compiler/aslpredef.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/compiler/asltransform.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/compiler/aslutils.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/compiler/aslxref.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/compiler/dtcompile.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/compiler/dttemplate.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/debugger/dbexec.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/debugger/dbnames.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/disassembler/dmnames.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/dispatcher/dsfield.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/dispatcher/dsinit.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/events/evgpeinit.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/executer/exnames.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/namespace/nsaccess.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/namespace/nsdump.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/namespace/nsinit.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/namespace/nsnames.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/namespace/nsobject.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/namespace/nsparse.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/namespace/nsrepair.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/namespace/nsrepair2.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/namespace/nsutils.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/namespace/nsxfname.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/parser/psargs.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/resources/rsxface.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/tables/tbdata.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/tables/tbfind.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/tables/tbinstal.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/tables/tbprint.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/tables/tbutils.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/tables/tbxface.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/tables/tbxfload.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/utilities/utascii.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/utilities/utdecode.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/utilities/utmisc.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/utilities/utpredef.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/components/utilities/utstring.c projects/fuse2-googletest-engine/sys/contrib/dev/acpica/include/aclocal.h projects/fuse2-googletest-engine/sys/contrib/dev/acpica/include/acpixf.h projects/fuse2-googletest-engine/sys/contrib/dev/acpica/include/actbl.h projects/fuse2-googletest-engine/sys/contrib/dev/acpica/include/actypes.h projects/fuse2-googletest-engine/sys/dev/acpica/Osd/OsdTable.c projects/fuse2-googletest-engine/sys/dev/acpica/acpi_quirk.c projects/fuse2-googletest-engine/sys/dev/cxgbe/common/t4_hw.c projects/fuse2-googletest-engine/sys/dev/cxgbe/offload.h projects/fuse2-googletest-engine/sys/dev/cxgbe/t4_main.c projects/fuse2-googletest-engine/sys/dev/cxgbe/tom/t4_cpl_io.c projects/fuse2-googletest-engine/sys/dev/cxgbe/tom/t4_ddp.c projects/fuse2-googletest-engine/sys/dev/cxgbe/tom/t4_tls.c projects/fuse2-googletest-engine/sys/dev/fdt/fdt_common.c projects/fuse2-googletest-engine/sys/dev/ioat/ioat.c projects/fuse2-googletest-engine/sys/dev/ioat/ioat_internal.h projects/fuse2-googletest-engine/sys/dev/ioat/ioat_test.c projects/fuse2-googletest-engine/sys/dev/ioat/ioat_test.h projects/fuse2-googletest-engine/sys/dev/ipmi/ipmi_opal.c projects/fuse2-googletest-engine/sys/dev/md/md.c projects/fuse2-googletest-engine/sys/dev/pci/pci.c projects/fuse2-googletest-engine/sys/dev/sdhci/sdhci.c projects/fuse2-googletest-engine/sys/dev/tpm/tpm20.c projects/fuse2-googletest-engine/sys/dev/usb/wlan/if_run.c projects/fuse2-googletest-engine/sys/dev/usb/wlan/if_uath.c projects/fuse2-googletest-engine/sys/dev/usb/wlan/if_urtw.c projects/fuse2-googletest-engine/sys/dev/usb/wlan/if_urtwvar.h projects/fuse2-googletest-engine/sys/dev/xen/blkfront/blkfront.c projects/fuse2-googletest-engine/sys/fs/msdosfs/msdosfs_denode.c projects/fuse2-googletest-engine/sys/fs/tmpfs/tmpfs.h projects/fuse2-googletest-engine/sys/fs/tmpfs/tmpfs_fifoops.c projects/fuse2-googletest-engine/sys/fs/tmpfs/tmpfs_subr.c projects/fuse2-googletest-engine/sys/fs/tmpfs/tmpfs_vfsops.c projects/fuse2-googletest-engine/sys/fs/tmpfs/tmpfs_vnops.c projects/fuse2-googletest-engine/sys/geom/eli/g_eli.c projects/fuse2-googletest-engine/sys/geom/eli/g_eli.h projects/fuse2-googletest-engine/sys/geom/eli/g_eli_ctl.c projects/fuse2-googletest-engine/sys/geom/eli/g_eli_key_cache.c projects/fuse2-googletest-engine/sys/geom/geom_dev.c projects/fuse2-googletest-engine/sys/i386/acpica/acpi_machdep.c projects/fuse2-googletest-engine/sys/kern/imgact_elf.c projects/fuse2-googletest-engine/sys/net/if_spppsubr.c projects/fuse2-googletest-engine/sys/net/if_stf.c projects/fuse2-googletest-engine/sys/netinet/in_pcb.c projects/fuse2-googletest-engine/sys/netinet/tcp_output.c projects/fuse2-googletest-engine/sys/netinet/tcp_var.h projects/fuse2-googletest-engine/sys/netinet6/in6.c projects/fuse2-googletest-engine/sys/netinet6/in6_ifattach.c projects/fuse2-googletest-engine/sys/netinet6/nd6.c projects/fuse2-googletest-engine/sys/netipsec/key.c projects/fuse2-googletest-engine/sys/netipsec/key.h projects/fuse2-googletest-engine/sys/netipsec/xform_esp.c projects/fuse2-googletest-engine/sys/netpfil/pf/pf.c projects/fuse2-googletest-engine/sys/powerpc/fpu/fpu_sqrt.c projects/fuse2-googletest-engine/sys/powerpc/include/trap.h projects/fuse2-googletest-engine/sys/powerpc/powernv/opal.h projects/fuse2-googletest-engine/sys/powerpc/powernv/opal_async.c projects/fuse2-googletest-engine/sys/powerpc/powernv/opal_dev.c projects/fuse2-googletest-engine/sys/powerpc/powerpc/exec_machdep.c projects/fuse2-googletest-engine/sys/powerpc/powerpc/trap.c projects/fuse2-googletest-engine/sys/riscv/riscv/plic.c projects/fuse2-googletest-engine/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c projects/fuse2-googletest-engine/sys/sys/ata.h projects/fuse2-googletest-engine/sys/vm/vm_kern.c projects/fuse2-googletest-engine/sys/vm/vm_map.c projects/fuse2-googletest-engine/sys/vm/vm_map.h projects/fuse2-googletest-engine/sys/x86/iommu/busdma_dmar.c projects/fuse2-googletest-engine/tests/sys/audit/Makefile projects/fuse2-googletest-engine/tests/sys/audit/process-control.c projects/fuse2-googletest-engine/tests/sys/capsicum/Makefile projects/fuse2-googletest-engine/tests/sys/capsicum/ioctls_test.c projects/fuse2-googletest-engine/tests/sys/geom/class/eli/Makefile projects/fuse2-googletest-engine/tests/sys/geom/class/eli/configure_test.sh projects/fuse2-googletest-engine/tools/build/Makefile projects/fuse2-googletest-engine/tools/tools/ioat/ioatcontrol.8 projects/fuse2-googletest-engine/tools/tools/ioat/ioatcontrol.c projects/fuse2-googletest-engine/usr.bin/dtc/Makefile projects/fuse2-googletest-engine/usr.bin/rctl/rctl.c projects/fuse2-googletest-engine/usr.bin/strings/Makefile projects/fuse2-googletest-engine/usr.bin/systat/devs.c projects/fuse2-googletest-engine/usr.bin/systat/devs.h projects/fuse2-googletest-engine/usr.bin/systat/iostat.c projects/fuse2-googletest-engine/usr.bin/systat/swap.c projects/fuse2-googletest-engine/usr.bin/systat/systat.h projects/fuse2-googletest-engine/usr.bin/systat/vmstat.c projects/fuse2-googletest-engine/usr.bin/systat/zarc.c projects/fuse2-googletest-engine/usr.bin/top/display.c projects/fuse2-googletest-engine/usr.bin/xohtml/xohtml.sh projects/fuse2-googletest-engine/usr.sbin/acpi/acpidump/acpi.c projects/fuse2-googletest-engine/usr.sbin/bsnmpd/bsnmpd/Makefile projects/fuse2-googletest-engine/usr.sbin/bsnmpd/bsnmpd/snmpd.config projects/fuse2-googletest-engine/usr.sbin/iostat/iostat.c projects/fuse2-googletest-engine/usr.sbin/pmc/Makefile Directory Properties: projects/fuse2-googletest-engine/ (props changed) projects/fuse2-googletest-engine/contrib/elftoolchain/ (props changed) projects/fuse2-googletest-engine/contrib/libxo/ (props changed) projects/fuse2-googletest-engine/contrib/llvm/ (props changed) projects/fuse2-googletest-engine/contrib/llvm/tools/clang/ (props changed) projects/fuse2-googletest-engine/gnu/usr.bin/gdb/ (props changed) projects/fuse2-googletest-engine/sys/cddl/contrib/opensolaris/ (props changed) projects/fuse2-googletest-engine/sys/contrib/dev/acpica/ (props changed) Modified: projects/fuse2-googletest-engine/contrib/bsnmp/gensnmptree/gensnmptree.1 ============================================================================== --- projects/fuse2-googletest-engine/contrib/bsnmp/gensnmptree/gensnmptree.1 Thu Apr 4 18:26:32 2019 (r345885) +++ projects/fuse2-googletest-engine/contrib/bsnmp/gensnmptree/gensnmptree.1 Thu Apr 4 18:37:30 2019 (r345886) @@ -31,7 +31,7 @@ .\" .\" $Begemot: gensnmptree.1 383 2006-05-30 07:40:49Z brandt_h $ .\" -.Dd June 29, 2018 +.Dd April 2, 2019 .Dt GENSNMPTREE 1 .Os .Sh NAME @@ -100,25 +100,11 @@ is the length of the OID. is the last component of the OID. .El .It Fl F -Together with -.Fl E -causes -.Nm -instead of the generation of enum definitions the generation of -functions for checking a value to be one of the enumeration variants and -for conversion between strings and the enum. The file is sent to standard -output and is meant to be included into a C-file for compilation. +emit definitions for C-functions includeable in a C-file that do some basic +stuff on enums like value checking and conversion between value and strings. .It Fl f -This flag can be used together with -.Fl E -or when generating the tree files. It causes -.Nm -to emit static inline functions for checking a value to be one of the -enumeration values and for conversion between strings and the enum. -If used when generating the tree files, the preprocessor symbol -.Ar SNMPTREE_TYPES -must be defined when including the tree header file for these definitions -to become visible. +emit definitions for inline C-functions that do some basic +stuff on enums like value checking and conversion between value and strings. .It Fl h Print a short help page. .It Fl I Ar directory @@ -136,36 +122,6 @@ Instead of normal output print the resulting tree. Prefix the file names and the table name with .Ar prefix . .El -.Pp -The following functions are generated by -.Fl f -or -.Fl F : -.Pp -.Ft static inline int -.Fn isok_EnumName "enum EnumName" ; -.Pp -.Ft static inline const char * -.Fn tostr_EnumName "enum EnumName" ; -.Pp -.Ft static inline int -.Fn fromstr_EnumName "const char *" "enum EnumName *" ; -.Pp -The -.Fa EnumName -is replaced with the enumeration name. -.Fn isok_EnumName -returns 1 if the argument is one of the valid enum values and 0 otherwise. -.Fn tostr_EnumName -returns a string representation of the enumeration value. -If the values is not one of the legal values -.Ar EnumName??? -is returned. -.Fn fromstr_EnumName -returns 1 if the string represents one of the legal enumeration values and -0 otherwise. -If 1 is return the variable pointed to by the second argument is set to -the enumeration value. .Sh MIBS The syntax of the MIB description file can formally be specified as follows: .Bd -unfilled -offset indent Modified: projects/fuse2-googletest-engine/contrib/bsnmp/gensnmptree/gensnmptree.c ============================================================================== --- projects/fuse2-googletest-engine/contrib/bsnmp/gensnmptree/gensnmptree.c Thu Apr 4 18:26:32 2019 (r345885) +++ projects/fuse2-googletest-engine/contrib/bsnmp/gensnmptree/gensnmptree.c Thu Apr 4 18:37:30 2019 (r345886) @@ -110,7 +110,6 @@ static int debug; static const char usgtxt[] = "\ Generate SNMP tables.\n\ -$Id$\n\ usage: gensnmptree [-dEeFfhlt] [-I directory] [-i infile] [-p prefix]\n\ [name]...\n\ options:\n\ @@ -127,6 +126,37 @@ options:\n\ -t generate a .def file\n\ "; +/** + * Program operation. + */ +enum op { + /** generate the tree */ + OP_GEN, + + /** extract OIDs */ + OP_EXTRACT, + + /** print the parsed tree */ + OP_TREE, + + /** extract enums */ + OP_ENUMS, +}; + +/** + * Which functions to create. + */ +enum gen_funcs { + /** none */ + GEN_FUNCS_NONE, + + /** functions for header files */ + GEN_FUNCS_H, + + /** functions for C files */ + GEN_FUNCS_C, +}; + /* * A node in the OID tree */ @@ -162,15 +192,18 @@ struct node { uint32_t index; /* index for table entry */ char *func; /* function for tables */ struct node_list subs; + char *subtypes[SNMP_INDEXES_MAX]; } entry; struct leaf { enum snmp_syntax syntax; /* syntax for this leaf */ char *func; /* function name */ + char *subtype; /* subtype */ } leaf; struct column { enum snmp_syntax syntax; /* syntax for this column */ + char *subtype; /* subtype */ } column; } u; }; @@ -214,7 +247,7 @@ xalloc(size_t size) { void *ptr; - if ((ptr = malloc(size)) == NULL) + if ((ptr = calloc(1, size)) == NULL) err(1, "allocing %zu bytes", size); return (ptr); @@ -710,12 +743,14 @@ make_type(const char *s) * token. */ static u_int -parse_type(enum tok *tok, struct type *t, const char *vname) +parse_type(enum tok *tok, struct type *t, const char *vname, char **subtype) { u_int syntax; struct enums *e; syntax = val; + if (subtype != NULL) + *subtype = NULL; if (*tok == TOK_ENUM || *tok == TOK_BITS) { if (t == NULL && vname != NULL) { @@ -759,6 +794,8 @@ parse_type(enum tok *tok, struct type *t, const char * if ((*tok = gettoken()) == '|') { if (gettoken() != TOK_STR) report("subtype expected after '|'"); + if (subtype != NULL) + *subtype = savetok(); *tok = gettoken(); } } @@ -794,18 +831,21 @@ parse(enum tok tok) if ((tok = gettoken()) == TOK_TYPE || tok == TOK_DEFTYPE || tok == TOK_ENUM || tok == TOK_BITS) { /* LEAF or COLUM */ - u_int syntax = parse_type(&tok, NULL, node->name); + char *subtype; + u_int syntax = parse_type(&tok, NULL, node->name, &subtype); if (tok == TOK_STR) { /* LEAF */ node->type = NODE_LEAF; node->u.leaf.func = savetok(); node->u.leaf.syntax = syntax; + node->u.leaf.subtype = subtype; tok = gettoken(); } else { /* COLUMN */ node->type = NODE_COLUMN; node->u.column.syntax = syntax; + node->u.column.subtype = subtype; } while (tok != ')') { @@ -825,9 +865,12 @@ parse(enum tok tok) tok = gettoken(); while (tok == TOK_TYPE || tok == TOK_DEFTYPE || tok == TOK_ENUM || tok == TOK_BITS) { - u_int syntax = parse_type(&tok, NULL, node->name); - if (index_count++ == SNMP_INDEXES_MAX) + char *subtype; + u_int syntax = parse_type(&tok, NULL, node->name, + &subtype); + if (index_count == SNMP_INDEXES_MAX) report("too many table indexes"); + node->u.entry.subtypes[index_count++] = subtype; node->u.entry.index |= syntax << (SNMP_INDEX_SHIFT * index_count); } @@ -882,7 +925,8 @@ parse_top(enum tok tok) tok = gettoken(); t->is_enum = (tok == TOK_ENUM); t->is_bits = (tok == TOK_BITS); - t->syntax = parse_type(&tok, t, NULL); + + t->syntax = parse_type(&tok, t, NULL, NULL); pushback(tok); return (NULL); @@ -903,7 +947,7 @@ parse_top(enum tok tok) * Generate the C-code table part for one node. */ static void -gen_node(FILE *fp, struct node *np, struct asn_oid *oid, u_int idx, +gen_node(FILE *fp, const struct node *np, struct asn_oid *oid, u_int idx, const char *func) { u_int n; @@ -1008,7 +1052,7 @@ gen_node(FILE *fp, struct node *np, struct asn_oid *oi * Generate the header file with the function declarations. */ static void -gen_header(FILE *fp, struct node *np, u_int oidlen, const char *func) +gen_header(FILE *fp, const struct node *np, u_int oidlen, const char *func) { char f[MAXSTR + 4]; struct node *sub; @@ -1058,7 +1102,7 @@ gen_header(FILE *fp, struct node *np, u_int oidlen, co * Generate the OID table. */ static void -gen_table(FILE *fp, struct node *node) +gen_table(FILE *fp, const struct node *node) { struct asn_oid oid; @@ -1067,7 +1111,6 @@ gen_table(FILE *fp, struct node *node) #ifdef HAVE_STDINT_H fprintf(fp, "#include \n"); #endif - fprintf(fp, "#include \n"); if (localincs) { fprintf(fp, "#include \"asn1.h\"\n"); fprintf(fp, "#include \"snmp.h\"\n"); @@ -1118,6 +1161,8 @@ gen_tree(const struct node *np, int level) case NODE_LEAF: print_syntax(np->u.leaf.syntax); + if (np->u.leaf.subtype != NULL) + printf(" | %s", np->u.leaf.subtype); printf(" %s%s%s)\n", np->u.leaf.func, (np->flags & FL_GET) ? " GET" : "", (np->flags & FL_SET) ? " SET" : ""); @@ -1137,8 +1182,11 @@ gen_tree(const struct node *np, int level) case NODE_ENTRY: printf(" :"); - for (i = 0; i < SNMP_INDEX_COUNT(np->u.entry.index); i++) + for (i = 0; i < SNMP_INDEX_COUNT(np->u.entry.index); i++) { print_syntax(SNMP_INDEX(np->u.entry.index, i)); + if (np->u.entry.subtypes[i] != NULL) + printf(" | %s", np->u.entry.subtypes[i]); + } printf(" %s\n", np->u.entry.func); TAILQ_FOREACH(sp, &np->u.entry.subs, link) gen_tree(sp, level + 1); @@ -1147,6 +1195,8 @@ gen_tree(const struct node *np, int level) case NODE_COLUMN: print_syntax(np->u.column.syntax); + if (np->u.column.subtype != NULL) + printf(" | %s", np->u.column.subtype); printf("%s%s)\n", (np->flags & FL_GET) ? " GET" : "", (np->flags & FL_SET) ? " SET" : ""); break; @@ -1194,15 +1244,6 @@ extract(FILE *fp, const struct node *np, struct asn_oi return (1); } -/** - * Extract the named OID. - * - * \param fp file to extract to - * \param root root of the tree - * \param object name of the object to extract - * - * \return 0 on success, -1 if the object was not found - */ static int gen_extract(FILE *fp, const struct node *root, char *object) { @@ -1391,45 +1432,6 @@ unminus(FILE *fp, const char *s) } /** - * Generate a definition for the enum packed into a guard against multiple - * definitions. - * - * \param fp file to write definition to - * \param t type - */ -static void -gen_enum(FILE *fp, const struct type *t) -{ - const struct enums *e; - long min = LONG_MAX; - - fprintf(fp, "\n"); - fprintf(fp, "#ifndef %s_defined__\n", t->name); - fprintf(fp, "#define %s_defined__\n", t->name); - fprintf(fp, "/*\n"); - fprintf(fp, " * From %s:%u\n", t->from_fname, t->from_lno); - fprintf(fp, " */\n"); - fprintf(fp, "enum %s {\n", t->name); - TAILQ_FOREACH(e, &t->enums, link) { - fprintf(fp, "\t%s_", t->name); - unminus(fp, e->name); - fprintf(fp, " = %ld,\n", e->value); - if (e->value < min) - min = e->value; - } - fprintf(fp, "};\n"); - fprintf(fp, "#define STROFF_%s %ld\n", t->name, min); - fprintf(fp, "#define STRING_%s \\\n", t->name); - TAILQ_FOREACH(e, &t->enums, link) { - fprintf(fp, "\t[%ld] = \"%s_", e->value - min, t->name); - unminus(fp, e->name); - fprintf(fp, "\",\\\n"); - } - fprintf(fp, "\n"); - fprintf(fp, "#endif /* %s_defined__ */\n", t->name); -} - -/** * Generate helper functions for an enum. * * We always generate a switch statement for the isok function. The compiler @@ -1494,6 +1496,54 @@ gen_enum_funcs(FILE *fp, const struct type *t, int cco } /** + * Generate a definition for the enum packed into a guard against multiple + * definitions. + * + * \param fp file to write definition to + * \param t type + * \param dof generate functions too + */ +static void +gen_enum(FILE *fp, const struct type *t, int dof) +{ + const struct enums *e; + long min = LONG_MAX; + + fprintf(fp, "\n"); + fprintf(fp, "#ifndef %s_defined__\n", t->name); + fprintf(fp, "#define %s_defined__\n", t->name); + fprintf(fp, "/*\n"); + fprintf(fp, " * From %s:%u\n", t->from_fname, t->from_lno); + fprintf(fp, " */\n"); + fprintf(fp, "enum %s {\n", t->name); + TAILQ_FOREACH(e, &t->enums, link) { + fprintf(fp, "\t%s_", t->name); + unminus(fp, e->name); + fprintf(fp, " = %ld,\n", e->value); + if (e->value < min) + min = e->value; + } + fprintf(fp, "};\n"); + fprintf(fp, "#define STROFF_%s %ld\n", t->name, min); + fprintf(fp, "#define STRING_%s \\\n", t->name); + TAILQ_FOREACH(e, &t->enums, link) { + fprintf(fp, "\t[%ld] = \"%s_", e->value - min, t->name); + unminus(fp, e->name); + fprintf(fp, "\",\\\n"); + } + fprintf(fp, "\n"); + if (dof) { + fprintf(fp, "#ifdef SNMPENUM_FUNCS\n"); + fprintf(fp, "\n"); + gen_enum_funcs(fp, t, 0); + fprintf(fp, "\n"); + fprintf(fp, "#endif\n"); + fprintf(fp, "\n"); + } + fprintf(fp, "#endif /* %s_defined__ */\n", t->name); +} + +/** * Generate helper functions for an enum. This generates code for a c file. * * \param fp file to write to @@ -1529,6 +1579,16 @@ gen_all_enum_funcs(FILE *fp, int ccode) gen_enum_funcs(fp, t, ccode); } +static void +gen_enums(FILE *fp, int dof) +{ + const struct type *t; + + LIST_FOREACH(t, &types, link) + if (t->is_enum || t->is_bits) + gen_enum(fp, t, dof); +} + /** * Extract a given enum to the specified file and optionally generate static * inline helper functions for them. @@ -1546,9 +1606,7 @@ extract_enum(FILE *fp, const char *name, int gen_funcs LIST_FOREACH(t, &types, link) if ((t->is_enum || t->is_bits) && strcmp(t->name, name) == 0) { - gen_enum(fp, t); - if (gen_funcs) - gen_enum_funcs(fp, t, 0); + gen_enum(fp, t, gen_funcs); return (0); } return (-1); @@ -1567,11 +1625,8 @@ extract_all_enums(FILE *fp, int gen_funcs) const struct type *t; LIST_FOREACH(t, &types, link) - if (t->is_enum || t->is_bits) { - gen_enum(fp, t); - if (gen_funcs) - gen_enum_funcs(fp, t, 0); - } + if (t->is_enum || t->is_bits) + gen_enum(fp, t, gen_funcs); } /** @@ -1579,13 +1634,12 @@ extract_all_enums(FILE *fp, int gen_funcs) * * \param argc number of arguments * \param argv arguments (enum names) - * \param gen_funcs_h generate functions into the header file - * \param gen_funcs_c generate a .c file with functions + * \param gen_funcs which functions to generate */ static void -make_enums(int argc, char *argv[], int gen_funcs_h, int gen_funcs_c) +make_enums(int argc, char *argv[], enum gen_funcs gen_funcs) { - if (gen_funcs_c) { + if (gen_funcs == GEN_FUNCS_C) { if (argc == 0) gen_all_enum_funcs(stdout, 1); else { @@ -1595,30 +1649,58 @@ make_enums(int argc, char *argv[], int gen_funcs_h, in } } else { if (argc == 0) - extract_all_enums(stdout, gen_funcs_h); + extract_all_enums(stdout, gen_funcs == GEN_FUNCS_H); else { for (int i = 0; i < argc; i++) - if (extract_enum(stdout, argv[i], gen_funcs_h)) + if (extract_enum(stdout, argv[i], + gen_funcs == GEN_FUNCS_H)) errx(1, "enum not found: %s", argv[i]); } } } +/** + * Produce the operation tables for the daemon or a module. + * + * \param root tree root + * \param gen_funcs generate enum funcs + */ +static void +make_table(const struct node *root, int gen_funcs) +{ + FILE *fp; + + char fname[MAXPATHLEN + 1]; + sprintf(fname, "%stree.h", file_prefix); + if ((fp = fopen(fname, "w")) == NULL) + err(1, "%s: ", fname); + gen_header(fp, root, PREFIX_LEN, NULL); + + fprintf(fp, "\n#ifdef SNMPTREE_TYPES\n"); + gen_enums(fp, gen_funcs); + fprintf(fp, "\n#endif /* SNMPTREE_TYPES */\n\n"); + + fprintf(fp, "#define %sCTREE_SIZE %u\n", file_prefix, tree_size); + fprintf(fp, "extern const struct snmp_node %sctree[];\n", file_prefix); + + fclose(fp); + + sprintf(fname, "%stree.c", file_prefix); + if ((fp = fopen(fname, "w")) == NULL) + err(1, "%s: ", fname); + gen_table(fp, root); + fclose(fp); +} + int main(int argc, char *argv[]) { - int do_extract = 0; - int do_tree = 0; - int do_enums = 0; - int gen_funcs_h = 0; - int gen_funcs_c = 0; - int opt; - struct node *root; - char fname[MAXPATHLEN + 1]; - int tok; - FILE *fp; + enum op op = OP_GEN; + enum gen_funcs gen_funcs = GEN_FUNCS_NONE; + char *infile = NULL; + int opt; while ((opt = getopt(argc, argv, "dEeFfhI:i:lp:t")) != EOF) switch (opt) { @@ -1627,19 +1709,29 @@ main(int argc, char *argv[]) break; case 'E': - do_enums = 1; + if (op != OP_GEN && op != OP_ENUMS) + errx(1, "-E conflicts with earlier options"); + op = OP_ENUMS; break; case 'e': - do_extract = 1; + if (op != OP_GEN && op != OP_EXTRACT) + errx(1, "-e conflicts with earlier options"); + op = OP_EXTRACT; break; case 'F': - gen_funcs_c = 1; + if (gen_funcs != GEN_FUNCS_NONE && + gen_funcs != GEN_FUNCS_C) + errx(1, "-F conflicts with -f"); + gen_funcs = GEN_FUNCS_C; break; case 'f': - gen_funcs_h = 1; + if (gen_funcs != GEN_FUNCS_NONE && + gen_funcs != GEN_FUNCS_H) + errx(1, "-f conflicts with -F"); + gen_funcs = GEN_FUNCS_H; break; case 'h': @@ -1666,75 +1758,61 @@ main(int argc, char *argv[]) break; case 't': - do_tree = 1; + if (op != OP_GEN && op != OP_TREE) + errx(1, "-t conflicts with earlier options"); + op = OP_TREE; break; } - if (do_extract + do_tree + do_enums > 1) - errx(1, "conflicting options -e/-t/-E"); - if (!do_extract && !do_enums && argc != optind) - errx(1, "no arguments allowed"); - if (do_extract && argc == optind) - errx(1, "no objects specified"); + argc -= optind; + argv += optind; - if ((gen_funcs_h || gen_funcs_c) && (do_extract || do_tree)) - errx(1, "-f and -F not allowed with -e or -t"); - if (gen_funcs_c && !do_enums) - errx(1, "-F requires -E"); - if (gen_funcs_h && gen_funcs_c) - errx(1, "-f and -F are mutually exclusive"); - + /* open input */ if (infile == NULL) { input_new(stdin, NULL, ""); } else { + FILE *fp; if ((fp = fopen(infile, "r")) == NULL) err(1, "%s", infile); input_new(fp, NULL, infile); } - root = parse_top(gettoken()); + /* parse and check input */ + struct node *root = parse_top(gettoken()); + + int tok; while ((tok = gettoken()) != TOK_EOF) merge(&root, parse_top(tok)); if (root) check_tree(root); - if (do_extract) { - while (optind < argc) { - if (gen_extract(stdout, root, argv[optind])) - errx(1, "object not found: %s", argv[optind]); - optind++; - } + /* do what the user has requested */ + switch (op) { + + case OP_EXTRACT: + if (argc == 0) + errx(1, "-e requires arguments"); + + for (int i = 0; i < argc; i++) + if (gen_extract(stdout, root, argv[i])) + errx(1, "object not found: %s", argv[i]); return (0); - } - if (do_enums) { - make_enums(argc - optind, argv + optind, - gen_funcs_h, gen_funcs_c); + + case OP_ENUMS: + make_enums(argc, argv, gen_funcs); return (0); - } - if (do_tree) { + + case OP_TREE: + if (argc != 0) + errx(1, "-t allows no arguments"); gen_tree(root, 0); return (0); - } - sprintf(fname, "%stree.h", file_prefix); - if ((fp = fopen(fname, "w")) == NULL) - err(1, "%s: ", fname); - gen_header(fp, root, PREFIX_LEN, NULL); - fprintf(fp, "\n#ifdef SNMPTREE_TYPES\n"); - extract_all_enums(fp, gen_funcs_h); - fprintf(fp, "\n#endif /* SNMPTREE_TYPES */\n\n"); - - fprintf(fp, "#define %sCTREE_SIZE %u\n", file_prefix, tree_size); - fprintf(fp, "extern const struct snmp_node %sctree[];\n", file_prefix); - - fclose(fp); - - sprintf(fname, "%stree.c", file_prefix); - if ((fp = fopen(fname, "w")) == NULL) - err(1, "%s: ", fname); - gen_table(fp, root); - fclose(fp); - - return (0); + case OP_GEN: + if (argc != 0) + errx(1, "tree generation allows no arguments"); + make_table(root, gen_funcs == GEN_FUNCS_H); + return (0); + } } Modified: projects/fuse2-googletest-engine/contrib/bsnmp/lib/snmpclient.c ============================================================================== --- projects/fuse2-googletest-engine/contrib/bsnmp/lib/snmpclient.c Thu Apr 4 18:26:32 2019 (r345885) +++ projects/fuse2-googletest-engine/contrib/bsnmp/lib/snmpclient.c Thu Apr 4 18:37:30 2019 (r345886) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2005 + * Copyright (c) 2004-2005,2018 * Hartmut Brandt. * All rights reserved. * Copyright (c) 2001-2003 @@ -34,11 +34,13 @@ * * Support functions for SNMP clients. */ -#include +#include #include #include #include #include +#include +#include #include #include #include @@ -58,12 +60,16 @@ #include #endif +#include + #include "support.h" #include "asn1.h" #include "snmp.h" #include "snmpclient.h" #include "snmppriv.h" +#define DEBUG_PARSE 0 + /* global context */ struct snmp_client snmp_client; @@ -924,7 +930,8 @@ open_client_udp(const char *host, const char *port) /* open connection */ memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_CANONNAME; - hints.ai_family = AF_INET; + hints.ai_family = snmp_client.trans == SNMP_TRANS_UDP ? AF_INET: + AF_INET6; hints.ai_socktype = SOCK_DGRAM; hints.ai_protocol = 0; error = getaddrinfo(snmp_client.chost, snmp_client.cport, &hints, &res0); @@ -1068,6 +1075,7 @@ snmp_open(const char *host, const char *port, const ch switch (snmp_client.trans) { case SNMP_TRANS_UDP: + case SNMP_TRANS_UDP6: if (open_client_udp(host, port) != 0) return (-1); break; @@ -1866,99 +1874,412 @@ snmp_client_set_port(struct snmp_client *cl, const cha return (0); } -/* - * parse a server specification +static const char *const trans_list[] = { + [SNMP_TRANS_UDP] = "udp::", + [SNMP_TRANS_LOC_DGRAM] = "dgram::", + [SNMP_TRANS_LOC_STREAM] = "stream::", + [SNMP_TRANS_UDP6] = "udp6::", +}; + +/** + * Try to get a transport identifier which is a leading alphanumeric string + * terminated by a double colon. The string may not be empty. The transport + * identifier is optional. * - * [trans::][community@][server][:port] + * \param sc client struct to set errors + * \param strp possible start of transport; updated to point to + * the next character to parse + * + * \return transport identifier */ -int -snmp_parse_server(struct snmp_client *sc, const char *str) +static inline int +get_transp(struct snmp_client *sc, const char **strp) { - const char *p, *s = str; + const char *p; + size_t i; - /* look for a double colon */ - for (p = s; *p != '\0'; p++) { - if (*p == '\\' && p[1] != '\0') { - p++; + for (i = 0; i < nitems(trans_list); i++) { + if (trans_list[i] == NULL || *trans_list[i] == '\0') continue; + p = strstr(*strp, trans_list[i]); + if (p == *strp) { + *strp += strlen(trans_list[i]); + return ((int)i); } - if (*p == ':' && p[1] == ':') - break; } - if (*p != '\0') { - if (p > s) { - if (p - s == 3 && strncmp(s, "udp", 3) == 0) - sc->trans = SNMP_TRANS_UDP; - else if (p - s == 6 && strncmp(s, "stream", 6) == 0) - sc->trans = SNMP_TRANS_LOC_STREAM; - else if (p - s == 5 && strncmp(s, "dgram", 5) == 0) - sc->trans = SNMP_TRANS_LOC_DGRAM; - else { - seterr(sc, "unknown SNMP transport '%.*s'", - (int)(p - s), s); - return (-1); - } - } - s = p + 2; + + p = *strp; + if (p[0] == ':' && p[1] == ':') { + seterr(sc, "empty transport specifier"); + return (-1); } + /* by default assume UDP */ + return (SNMP_TRANS_UDP); +} - /* look for a @ */ - for (p = s; *p != '\0'; p++) { - if (*p == '\\' && p[1] != '\0') { - p++; - continue; - } - if (*p == '@') - break; +/** + * Try to get community string. Eat everything up to the last @ (if there is + * any) but only if it is not longer than SNMP_COMMUNITY_MAXLEN. Empty + * community strings are legal. + * + * \param sc client struct to set errors + * \param strp possible start of community; updated to the point to + * the next character to parse + * + * \return end of community; equals *strp if there is none; NULL if there + * was an error + */ +static inline const char * +get_comm(struct snmp_client *sc, const char **strp) +{ + const char *p = strrchr(*strp, '@'); + + if (p == NULL) + /* no community string */ + return (*strp); + + if (p - *strp > SNMP_COMMUNITY_MAXLEN) { + seterr(sc, "community string too long '%.*s'", + p - *strp, *strp); + return (NULL); } - if (*p != '\0') { - if (p - s > SNMP_COMMUNITY_MAXLEN) { - seterr(sc, "community string too long"); - return (-1); + *strp = p + 1; + return (p); +} + +/** + * Try to get an IPv6 address. This starts with an [ and should end with an ] + * and everything between should be not longer than INET6_ADDRSTRLEN and + * parseable by inet_pton(). + * + * \param sc client struct to set errors + * \param strp possible start of IPv6 address (the '['); updated to point to + * the next character to parse (the one after the closing ']') + * + * \return end of address (equals *strp + 1 if there is none) or NULL + * on errors + */ +static inline const char * +get_ipv6(struct snmp_client *sc, const char **strp) +{ + char str[INET6_ADDRSTRLEN + IF_NAMESIZE]; + struct addrinfo hints, *res; + int error; + + if (**strp != '[') + return (*strp + 1); + + const char *p = *strp + 1; + while (*p != ']' ) { + if (*p == '\0') { + seterr(sc, "unterminated IPv6 address '%.*s'", + p - *strp, *strp); + return (NULL); } - strncpy(sc->read_community, s, p - s); - sc->read_community[p - s] = '\0'; - strncpy(sc->write_community, s, p - s); - sc->write_community[p - s] = '\0'; - s = p + 1; + p++; } - /* look for a colon */ - for (p = s; *p != '\0'; p++) { - if (*p == '\\' && p[1] != '\0') { - p++; - continue; - } - if (*p == ':') - break; + if (p - *strp > INET6_ADDRSTRLEN + IF_NAMESIZE) { + seterr(sc, "IPv6 address too long '%.*s'", p - *strp, *strp); + return (NULL); } - if (*p == ':') { - if (p > s) { - /* host:port */ - free(sc->chost); - if ((sc->chost = malloc(p - s + 1)) == NULL) { - seterr(sc, "%s", strerror(errno)); - return (-1); - } - strncpy(sc->chost, s, p - s); - sc->chost[p - s] = '\0'; - } - /* port */ - free(sc->cport); - if ((sc->cport = strdup(p + 1)) == NULL) { - seterr(sc, "%s", strerror(errno)); - return (-1); - } + strncpy(str, *strp + 1, p - (*strp + 1)); + str[p - (*strp + 1)] = '\0'; - } else if (p > s) { - /* host */ - free(sc->chost); - if ((sc->chost = strdup(s)) == NULL) { - seterr(sc, "%s", strerror(errno)); + memset(&hints, 0, sizeof(hints)); + hints.ai_flags = AI_CANONNAME | AI_NUMERICHOST; + hints.ai_family = AF_INET6; + hints.ai_socktype = SOCK_DGRAM; + hints.ai_protocol = IPPROTO_UDP; + error = getaddrinfo(str, NULL, &hints, &res); + if (error != 0) { + seterr(sc, "%s: %s", str, gai_strerror(error)); + return (NULL); + } + freeaddrinfo(res); + *strp = p + 1; + return (p); +} + +/** + * Try to get an IPv4 address. This starts with a digit and consists of digits + * and dots, is not longer INET_ADDRSTRLEN and must be parseable by + * inet_aton(). + * + * \param sc client struct to set errors + * \param strp possible start of IPv4 address; updated to point to the + * next character to parse + * + * \return end of address (equals *strp if there is none) or NULL + * on errors + */ +static inline const char * +get_ipv4(struct snmp_client *sc, const char **strp) +{ + const char *p = *strp; + + while (isascii(*p) && (isdigit(*p) || *p == '.')) + p++; + + if (p - *strp > INET_ADDRSTRLEN) { + seterr(sc, "IPv4 address too long '%.*s'", p - *strp, *strp); + return (NULL); + } + if (*strp == p) + return *strp; + + char str[INET_ADDRSTRLEN + 1]; + strncpy(str, *strp, p - *strp); + str[p - *strp] = '\0'; + + struct in_addr addr; + if (inet_aton(str, &addr) != 1) { + seterr(sc, "illegal IPv4 address '%s'", str); + return (NULL); + } + + *strp = p; + return (p); +} + +/** + * Try to get a hostname. This includes everything up to but not including + * the last colon (if any). There is no length restriction. + * + * \param sc client struct to set errors + * \param strp possible start of hostname; updated to point to the next + * character to parse (the trailing NUL character or the last + * colon) + * *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-projects@freebsd.org Thu Apr 4 20:24:59 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 672D21556817 for ; Thu, 4 Apr 2019 20:24:59 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 05E6B8B1DF; Thu, 4 Apr 2019 20:24:59 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CFF9C28C7; Thu, 4 Apr 2019 20:24:58 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x34KOw3v029547; Thu, 4 Apr 2019 20:24:58 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x34KOwMB029546; Thu, 4 Apr 2019 20:24:58 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904042024.x34KOwMB029546@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Thu, 4 Apr 2019 20:24:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345890 - projects/fuse2/sys/fs/fuse X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: projects/fuse2/sys/fs/fuse X-SVN-Commit-Revision: 345890 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 05E6B8B1DF X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.964,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Apr 2019 20:24:59 -0000 Author: asomers Date: Thu Apr 4 20:24:58 2019 New Revision: 345890 URL: https://svnweb.freebsd.org/changeset/base/345890 Log: fusefs: fix some uninitialized memory references This bug was long present, but was exacerbated by r345876. The problem is that fiov_refresh was bzero()ing a buffer _before_ it reallocated that buffer. That's obviously the wrong order. I fixed the order in r345876, which exposed the main problem. Previously, the first 160 bytes of the buffer were getting bzero()ed when it was first allocated in fiov_init. Subsequently, as that buffer got recycled between callers, the portion used by the _previous_ caller was getting bzero()ed by the current caller in fiov_refresh. The problem was never visible simply because no caller was trying to use more than 160 bytes. Now the buffer gets properly bzero()ed both at initialization time and any time it gets enlarged or reallocated. Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/sys/fs/fuse/fuse_ipc.c Modified: projects/fuse2/sys/fs/fuse/fuse_ipc.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_ipc.c Thu Apr 4 19:59:31 2019 (r345889) +++ projects/fuse2/sys/fs/fuse/fuse_ipc.c Thu Apr 4 20:24:58 2019 (r345890) @@ -182,6 +182,11 @@ fiov_adjust(struct fuse_iov *fiov, size_t size) } fiov->allocated_size = FU_AT_LEAST(size); fiov->credit = fuse_iov_credit; + /* Clear data buffer after reallocation */ + bzero(fiov->base, size); + } else if (size > fiov->len) { + /* Clear newly extended portion of data buffer */ + bzero((char*)fiov->base + fiov->len, size - fiov->len); } fiov->len = size; } @@ -198,7 +203,6 @@ void fiov_refresh(struct fuse_iov *fiov) { fiov_adjust(fiov, 0); - bzero(fiov->base, fiov->len); } static int @@ -744,6 +748,8 @@ fdisp_refresh_pid(struct fuse_dispatcher *fdip, enum f struct mount *mp, uint64_t nid, pid_t pid, struct ucred *cred) { MPASS(fdip->tick); + MPASS2(sizeof(fdip->finh) + fdip->iosize <= fdip->tick->tk_ms_fiov.len, + "Must use fdisp_make_pid to increase the size of the fiov"); fticket_reset(fdip->tick); FUSE_DIMALLOC(&fdip->tick->tk_ms_fiov, fdip->finh, @@ -766,6 +772,7 @@ fdisp_make_pid(struct fuse_dispatcher *fdip, enum fuse fdip->tick = fuse_ticket_fetch(data); } + /* FUSE_DIMALLOC will bzero the fiovs when it enlarges them */ FUSE_DIMALLOC(&fdip->tick->tk_ms_fiov, fdip->finh, fdip->indata, fdip->iosize); From owner-svn-src-projects@freebsd.org Thu Apr 4 20:30:16 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CF3631556A74 for ; Thu, 4 Apr 2019 20:30:16 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 780708B69C; Thu, 4 Apr 2019 20:30:16 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 460F028D3; Thu, 4 Apr 2019 20:30:16 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x34KUGMb030143; Thu, 4 Apr 2019 20:30:16 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x34KUFSw030138; Thu, 4 Apr 2019 20:30:15 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904042030.x34KUFSw030138@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Thu, 4 Apr 2019 20:30:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345892 - in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Commit-Revision: 345892 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 780708B69C X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.965,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Apr 2019 20:30:17 -0000 Author: asomers Date: Thu Apr 4 20:30:14 2019 New Revision: 345892 URL: https://svnweb.freebsd.org/changeset/base/345892 Log: fusefs: properly handle FOPEN_KEEP_CACHE If a fuse file system returne FOPEN_KEEP_CACHE in the open or create response, then the client is supposed to _not_ clear its caches for that file. I don't know why clearing the caches would be the default given that there's a separate flag to bypass the cache altogether, but that's the way it is. fusefs(5) will now honor this flag. Our behavior is slightly different than Linux's because we reuse file handles. That means that open(2) wont't clear the cache if there's a reusable file handle, even if the file server wouldn't have sent FOPEN_KEEP_CACHE had we opened a new file handle like Linux does. PR: 236560 Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/sys/fs/fuse/fuse_file.c projects/fuse2/sys/fs/fuse/fuse_file.h projects/fuse2/sys/fs/fuse/fuse_node.c projects/fuse2/sys/fs/fuse/fuse_vnops.c projects/fuse2/tests/sys/fs/fusefs/read.cc Modified: projects/fuse2/sys/fs/fuse/fuse_file.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_file.c Thu Apr 4 20:27:13 2019 (r345891) +++ projects/fuse2/sys/fs/fuse/fuse_file.c Thu Apr 4 20:30:14 2019 (r345892) @@ -79,6 +79,7 @@ __FBSDID("$FreeBSD$"); #include "fuse.h" #include "fuse_file.h" #include "fuse_internal.h" +#include "fuse_io.h" #include "fuse_ipc.h" #include "fuse_node.h" @@ -188,9 +189,7 @@ fuse_filehandle_open(struct vnode *vp, int a_mode, } foo = fdi.answ; - fuse_filehandle_init(vp, fufh_type, fufhp, td->td_proc->p_pid, cred, - foo); - + fuse_filehandle_init(vp, fufh_type, fufhp, td, cred, foo); fuse_vnode_open(vp, foo->open_flags, td); out: @@ -322,7 +321,7 @@ fuse_filehandle_getrw(struct vnode *vp, int fflag, void fuse_filehandle_init(struct vnode *vp, fufh_type_t fufh_type, - struct fuse_filehandle **fufhp, pid_t pid, struct ucred *cred, + struct fuse_filehandle **fufhp, struct thread *td, struct ucred *cred, struct fuse_open_out *foo) { struct fuse_vnode_data *fvdat = VTOFUD(vp); @@ -335,7 +334,7 @@ fuse_filehandle_init(struct vnode *vp, fufh_type_t fuf fufh->fufh_type = fufh_type; fufh->gid = cred->cr_rgid; fufh->uid = cred->cr_uid; - fufh->pid = pid; + fufh->pid = td->td_proc->p_pid; fufh->fuse_open_flags = foo->open_flags; if (!FUFH_IS_VALID(fufh)) { panic("FUSE: init: invalid filehandle id (type=%d)", fufh_type); @@ -345,4 +344,15 @@ fuse_filehandle_init(struct vnode *vp, fufh_type_t fuf *fufhp = fufh; atomic_add_acq_int(&fuse_fh_count, 1); + + if (foo->open_flags & FOPEN_DIRECT_IO) { + ASSERT_VOP_ELOCKED(vp, __func__); + VTOFUD(vp)->flag |= FN_DIRECTIO; + fuse_io_invalbuf(vp, td); + } else { + if ((foo->open_flags & FOPEN_KEEP_CACHE) == 0) + fuse_io_invalbuf(vp, td); + VTOFUD(vp)->flag &= ~FN_DIRECTIO; + } + } Modified: projects/fuse2/sys/fs/fuse/fuse_file.h ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_file.h Thu Apr 4 20:27:13 2019 (r345891) +++ projects/fuse2/sys/fs/fuse/fuse_file.h Thu Apr 4 20:30:14 2019 (r345892) @@ -158,7 +158,7 @@ int fuse_filehandle_getrw(struct vnode *vp, int fflag, pid_t pid); void fuse_filehandle_init(struct vnode *vp, fufh_type_t fufh_type, - struct fuse_filehandle **fufhp, pid_t pid, + struct fuse_filehandle **fufhp, struct thread *td, struct ucred *cred, struct fuse_open_out *foo); int fuse_filehandle_open(struct vnode *vp, int mode, struct fuse_filehandle **fufhp, struct thread *td, Modified: projects/fuse2/sys/fs/fuse/fuse_node.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_node.c Thu Apr 4 20:27:13 2019 (r345891) +++ projects/fuse2/sys/fs/fuse/fuse_node.c Thu Apr 4 20:30:14 2019 (r345892) @@ -329,16 +329,6 @@ fuse_vnode_open(struct vnode *vp, int32_t fuse_open_fl * * XXXIP: Handle fd based DIRECT_IO */ - if (fuse_open_flags & FOPEN_DIRECT_IO) { - ASSERT_VOP_ELOCKED(vp, __func__); - VTOFUD(vp)->flag |= FN_DIRECTIO; - fuse_io_invalbuf(vp, td); - } else { - if ((fuse_open_flags & FOPEN_KEEP_CACHE) == 0) - fuse_io_invalbuf(vp, td); - VTOFUD(vp)->flag &= ~FN_DIRECTIO; - } - if (vnode_vtype(vp) == VREG) { /* XXXIP prevent getattr, by using cached node size */ vnode_create_vobject(vp, 0, td); Modified: projects/fuse2/sys/fs/fuse/fuse_vnops.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_vnops.c Thu Apr 4 20:27:13 2019 (r345891) +++ projects/fuse2/sys/fs/fuse/fuse_vnops.c Thu Apr 4 20:30:14 2019 (r345892) @@ -479,8 +479,7 @@ fuse_vnop_create(struct vop_create_args *ap) } ASSERT_VOP_ELOCKED(*vpp, "fuse_vnop_create"); - fuse_filehandle_init(*vpp, FUFH_RDWR, NULL, td->td_proc->p_pid, cred, - foo); + fuse_filehandle_init(*vpp, FUFH_RDWR, NULL, td, cred, foo); fuse_vnode_open(*vpp, foo->open_flags, td); cache_purge_negative(dvp); Modified: projects/fuse2/tests/sys/fs/fusefs/read.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/read.cc Thu Apr 4 20:27:13 2019 (r345891) +++ projects/fuse2/tests/sys/fs/fusefs/read.cc Thu Apr 4 20:30:14 2019 (r345892) @@ -398,8 +398,7 @@ TEST_F(Read, eio) * With the keep_cache option, the kernel may keep its read cache across * multiple open(2)s. */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236560 */ -TEST_F(Read, DISABLED_keep_cache) +TEST_F(Read, keep_cache) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; @@ -410,7 +409,7 @@ TEST_F(Read, DISABLED_keep_cache) char buf[bufsize]; FuseTest::expect_lookup(RELPATH, ino, S_IFREG | 0644, bufsize, 2); - expect_open(ino, FOPEN_KEEP_CACHE, 1); + expect_open(ino, FOPEN_KEEP_CACHE, 2); expect_getattr(ino, bufsize); expect_read(ino, 0, bufsize, bufsize, CONTENTS); @@ -418,7 +417,7 @@ TEST_F(Read, DISABLED_keep_cache) ASSERT_LE(0, fd0) << strerror(errno); ASSERT_EQ(bufsize, read(fd0, buf, bufsize)) << strerror(errno); - fd1 = open(FULLPATH, O_RDONLY); + fd1 = open(FULLPATH, O_RDWR); ASSERT_LE(0, fd1) << strerror(errno); /* @@ -445,7 +444,7 @@ TEST_F(Read, keep_cache_disabled) char buf[bufsize]; FuseTest::expect_lookup(RELPATH, ino, S_IFREG | 0644, bufsize, 2); - expect_open(ino, FOPEN_KEEP_CACHE, 1); + expect_open(ino, 0, 2); expect_getattr(ino, bufsize); expect_read(ino, 0, bufsize, bufsize, CONTENTS); @@ -453,7 +452,7 @@ TEST_F(Read, keep_cache_disabled) ASSERT_LE(0, fd0) << strerror(errno); ASSERT_EQ(bufsize, read(fd0, buf, bufsize)) << strerror(errno); - fd1 = open(FULLPATH, O_RDONLY); + fd1 = open(FULLPATH, O_RDWR); ASSERT_LE(0, fd1) << strerror(errno); /* From owner-svn-src-projects@freebsd.org Fri Apr 5 03:35:41 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3240B1567273 for ; Fri, 5 Apr 2019 03:35:41 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B89BA7338D; Fri, 5 Apr 2019 03:35:40 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 90FC675C6; Fri, 5 Apr 2019 03:35:40 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x353ZeRs057980; Fri, 5 Apr 2019 03:35:40 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x353ZeZx057979; Fri, 5 Apr 2019 03:35:40 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904050335.x353ZeZx057979@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Fri, 5 Apr 2019 03:35:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345903 - projects/fuse2/contrib/googletest/googletest/test X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/fuse2/contrib/googletest/googletest/test X-SVN-Commit-Revision: 345903 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B89BA7338D X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.964,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Apr 2019 03:35:41 -0000 Author: ngie Date: Fri Apr 5 03:35:40 2019 New Revision: 345903 URL: https://svnweb.freebsd.org/changeset/base/345903 Log: Fix the branch build Copy gtest_skip_in_environment_setup_test.cc (added in r345770) from ^/head . Added: projects/fuse2/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc - copied unchanged from r345902, head/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc Copied: projects/fuse2/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc (from r345902, head/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/fuse2/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc Fri Apr 5 03:35:40 2019 (r345903, copy of r345902, head/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc) @@ -0,0 +1,60 @@ +// Copyright 2019, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// This test verifies that skipping in the environment results in the +// testcases being skipped. +// +// This is a reproduction case for +// https://github.com/google/googletest/issues/2189 . + +#include +#include + +class SetupEnvironment : public testing::Environment { +public: + void SetUp() override { + GTEST_SKIP() << "Skipping the entire environment"; + } +}; + +TEST(Test, AlwaysPasses) { + EXPECT_EQ(true, true); +} + +TEST(Test, AlwaysFails) { + EXPECT_EQ(true, false); +} + +int main(int argc, char **argv) { + testing::InitGoogleTest(&argc, argv); + + testing::AddGlobalTestEnvironment(new SetupEnvironment()); + + return (RUN_ALL_TESTS()); +} From owner-svn-src-projects@freebsd.org Fri Apr 5 03:37:19 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F321F1567295 for ; Fri, 5 Apr 2019 03:37:18 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8F5CA73498; Fri, 5 Apr 2019 03:37:18 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 690FC75C9; Fri, 5 Apr 2019 03:37:18 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x353bIaW058118; Fri, 5 Apr 2019 03:37:18 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x353bHmX058112; Fri, 5 Apr 2019 03:37:17 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904050337.x353bHmX058112@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Fri, 5 Apr 2019 03:37:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345904 - in projects/fuse2-googletest-engine: contrib/googletest/googletest/test sys/fs/fuse tests/sys/fs/fusefs X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: in projects/fuse2-googletest-engine: contrib/googletest/googletest/test sys/fs/fuse tests/sys/fs/fusefs X-SVN-Commit-Revision: 345904 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8F5CA73498 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.966,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Apr 2019 03:37:19 -0000 Author: ngie Date: Fri Apr 5 03:37:16 2019 New Revision: 345904 URL: https://svnweb.freebsd.org/changeset/base/345904 Log: MFprojects/fuse2@r345903 Added: projects/fuse2-googletest-engine/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc - copied unchanged from r345903, projects/fuse2/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc Modified: projects/fuse2-googletest-engine/sys/fs/fuse/fuse_file.c projects/fuse2-googletest-engine/sys/fs/fuse/fuse_file.h projects/fuse2-googletest-engine/sys/fs/fuse/fuse_ipc.c projects/fuse2-googletest-engine/sys/fs/fuse/fuse_node.c projects/fuse2-googletest-engine/sys/fs/fuse/fuse_vnops.c projects/fuse2-googletest-engine/tests/sys/fs/fusefs/read.cc Directory Properties: projects/fuse2-googletest-engine/ (props changed) Copied: projects/fuse2-googletest-engine/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc (from r345903, projects/fuse2/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/fuse2-googletest-engine/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc Fri Apr 5 03:37:16 2019 (r345904, copy of r345903, projects/fuse2/contrib/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc) @@ -0,0 +1,60 @@ +// Copyright 2019, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// This test verifies that skipping in the environment results in the +// testcases being skipped. +// +// This is a reproduction case for +// https://github.com/google/googletest/issues/2189 . + +#include +#include + +class SetupEnvironment : public testing::Environment { +public: + void SetUp() override { + GTEST_SKIP() << "Skipping the entire environment"; + } +}; + +TEST(Test, AlwaysPasses) { + EXPECT_EQ(true, true); +} + +TEST(Test, AlwaysFails) { + EXPECT_EQ(true, false); +} + +int main(int argc, char **argv) { + testing::InitGoogleTest(&argc, argv); + + testing::AddGlobalTestEnvironment(new SetupEnvironment()); + + return (RUN_ALL_TESTS()); +} Modified: projects/fuse2-googletest-engine/sys/fs/fuse/fuse_file.c ============================================================================== --- projects/fuse2-googletest-engine/sys/fs/fuse/fuse_file.c Fri Apr 5 03:35:40 2019 (r345903) +++ projects/fuse2-googletest-engine/sys/fs/fuse/fuse_file.c Fri Apr 5 03:37:16 2019 (r345904) @@ -79,6 +79,7 @@ __FBSDID("$FreeBSD$"); #include "fuse.h" #include "fuse_file.h" #include "fuse_internal.h" +#include "fuse_io.h" #include "fuse_ipc.h" #include "fuse_node.h" @@ -188,9 +189,7 @@ fuse_filehandle_open(struct vnode *vp, int a_mode, } foo = fdi.answ; - fuse_filehandle_init(vp, fufh_type, fufhp, td->td_proc->p_pid, cred, - foo); - + fuse_filehandle_init(vp, fufh_type, fufhp, td, cred, foo); fuse_vnode_open(vp, foo->open_flags, td); out: @@ -322,7 +321,7 @@ fuse_filehandle_getrw(struct vnode *vp, int fflag, void fuse_filehandle_init(struct vnode *vp, fufh_type_t fufh_type, - struct fuse_filehandle **fufhp, pid_t pid, struct ucred *cred, + struct fuse_filehandle **fufhp, struct thread *td, struct ucred *cred, struct fuse_open_out *foo) { struct fuse_vnode_data *fvdat = VTOFUD(vp); @@ -335,7 +334,7 @@ fuse_filehandle_init(struct vnode *vp, fufh_type_t fuf fufh->fufh_type = fufh_type; fufh->gid = cred->cr_rgid; fufh->uid = cred->cr_uid; - fufh->pid = pid; + fufh->pid = td->td_proc->p_pid; fufh->fuse_open_flags = foo->open_flags; if (!FUFH_IS_VALID(fufh)) { panic("FUSE: init: invalid filehandle id (type=%d)", fufh_type); @@ -345,4 +344,15 @@ fuse_filehandle_init(struct vnode *vp, fufh_type_t fuf *fufhp = fufh; atomic_add_acq_int(&fuse_fh_count, 1); + + if (foo->open_flags & FOPEN_DIRECT_IO) { + ASSERT_VOP_ELOCKED(vp, __func__); + VTOFUD(vp)->flag |= FN_DIRECTIO; + fuse_io_invalbuf(vp, td); + } else { + if ((foo->open_flags & FOPEN_KEEP_CACHE) == 0) + fuse_io_invalbuf(vp, td); + VTOFUD(vp)->flag &= ~FN_DIRECTIO; + } + } Modified: projects/fuse2-googletest-engine/sys/fs/fuse/fuse_file.h ============================================================================== --- projects/fuse2-googletest-engine/sys/fs/fuse/fuse_file.h Fri Apr 5 03:35:40 2019 (r345903) +++ projects/fuse2-googletest-engine/sys/fs/fuse/fuse_file.h Fri Apr 5 03:37:16 2019 (r345904) @@ -158,7 +158,7 @@ int fuse_filehandle_getrw(struct vnode *vp, int fflag, pid_t pid); void fuse_filehandle_init(struct vnode *vp, fufh_type_t fufh_type, - struct fuse_filehandle **fufhp, pid_t pid, + struct fuse_filehandle **fufhp, struct thread *td, struct ucred *cred, struct fuse_open_out *foo); int fuse_filehandle_open(struct vnode *vp, int mode, struct fuse_filehandle **fufhp, struct thread *td, Modified: projects/fuse2-googletest-engine/sys/fs/fuse/fuse_ipc.c ============================================================================== --- projects/fuse2-googletest-engine/sys/fs/fuse/fuse_ipc.c Fri Apr 5 03:35:40 2019 (r345903) +++ projects/fuse2-googletest-engine/sys/fs/fuse/fuse_ipc.c Fri Apr 5 03:37:16 2019 (r345904) @@ -182,6 +182,11 @@ fiov_adjust(struct fuse_iov *fiov, size_t size) } fiov->allocated_size = FU_AT_LEAST(size); fiov->credit = fuse_iov_credit; + /* Clear data buffer after reallocation */ + bzero(fiov->base, size); + } else if (size > fiov->len) { + /* Clear newly extended portion of data buffer */ + bzero((char*)fiov->base + fiov->len, size - fiov->len); } fiov->len = size; } @@ -198,7 +203,6 @@ void fiov_refresh(struct fuse_iov *fiov) { fiov_adjust(fiov, 0); - bzero(fiov->base, fiov->len); } static int @@ -744,6 +748,8 @@ fdisp_refresh_pid(struct fuse_dispatcher *fdip, enum f struct mount *mp, uint64_t nid, pid_t pid, struct ucred *cred) { MPASS(fdip->tick); + MPASS2(sizeof(fdip->finh) + fdip->iosize <= fdip->tick->tk_ms_fiov.len, + "Must use fdisp_make_pid to increase the size of the fiov"); fticket_reset(fdip->tick); FUSE_DIMALLOC(&fdip->tick->tk_ms_fiov, fdip->finh, @@ -766,6 +772,7 @@ fdisp_make_pid(struct fuse_dispatcher *fdip, enum fuse fdip->tick = fuse_ticket_fetch(data); } + /* FUSE_DIMALLOC will bzero the fiovs when it enlarges them */ FUSE_DIMALLOC(&fdip->tick->tk_ms_fiov, fdip->finh, fdip->indata, fdip->iosize); Modified: projects/fuse2-googletest-engine/sys/fs/fuse/fuse_node.c ============================================================================== --- projects/fuse2-googletest-engine/sys/fs/fuse/fuse_node.c Fri Apr 5 03:35:40 2019 (r345903) +++ projects/fuse2-googletest-engine/sys/fs/fuse/fuse_node.c Fri Apr 5 03:37:16 2019 (r345904) @@ -329,16 +329,6 @@ fuse_vnode_open(struct vnode *vp, int32_t fuse_open_fl * * XXXIP: Handle fd based DIRECT_IO */ - if (fuse_open_flags & FOPEN_DIRECT_IO) { - ASSERT_VOP_ELOCKED(vp, __func__); - VTOFUD(vp)->flag |= FN_DIRECTIO; - fuse_io_invalbuf(vp, td); - } else { - if ((fuse_open_flags & FOPEN_KEEP_CACHE) == 0) - fuse_io_invalbuf(vp, td); - VTOFUD(vp)->flag &= ~FN_DIRECTIO; - } - if (vnode_vtype(vp) == VREG) { /* XXXIP prevent getattr, by using cached node size */ vnode_create_vobject(vp, 0, td); Modified: projects/fuse2-googletest-engine/sys/fs/fuse/fuse_vnops.c ============================================================================== --- projects/fuse2-googletest-engine/sys/fs/fuse/fuse_vnops.c Fri Apr 5 03:35:40 2019 (r345903) +++ projects/fuse2-googletest-engine/sys/fs/fuse/fuse_vnops.c Fri Apr 5 03:37:16 2019 (r345904) @@ -479,8 +479,7 @@ fuse_vnop_create(struct vop_create_args *ap) } ASSERT_VOP_ELOCKED(*vpp, "fuse_vnop_create"); - fuse_filehandle_init(*vpp, FUFH_RDWR, NULL, td->td_proc->p_pid, cred, - foo); + fuse_filehandle_init(*vpp, FUFH_RDWR, NULL, td, cred, foo); fuse_vnode_open(*vpp, foo->open_flags, td); cache_purge_negative(dvp); Modified: projects/fuse2-googletest-engine/tests/sys/fs/fusefs/read.cc ============================================================================== --- projects/fuse2-googletest-engine/tests/sys/fs/fusefs/read.cc Fri Apr 5 03:35:40 2019 (r345903) +++ projects/fuse2-googletest-engine/tests/sys/fs/fusefs/read.cc Fri Apr 5 03:37:16 2019 (r345904) @@ -398,8 +398,7 @@ TEST_F(Read, eio) * With the keep_cache option, the kernel may keep its read cache across * multiple open(2)s. */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236560 */ -TEST_F(Read, DISABLED_keep_cache) +TEST_F(Read, keep_cache) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; @@ -410,7 +409,7 @@ TEST_F(Read, DISABLED_keep_cache) char buf[bufsize]; FuseTest::expect_lookup(RELPATH, ino, S_IFREG | 0644, bufsize, 2); - expect_open(ino, FOPEN_KEEP_CACHE, 1); + expect_open(ino, FOPEN_KEEP_CACHE, 2); expect_getattr(ino, bufsize); expect_read(ino, 0, bufsize, bufsize, CONTENTS); @@ -418,7 +417,7 @@ TEST_F(Read, DISABLED_keep_cache) ASSERT_LE(0, fd0) << strerror(errno); ASSERT_EQ(bufsize, read(fd0, buf, bufsize)) << strerror(errno); - fd1 = open(FULLPATH, O_RDONLY); + fd1 = open(FULLPATH, O_RDWR); ASSERT_LE(0, fd1) << strerror(errno); /* @@ -445,7 +444,7 @@ TEST_F(Read, keep_cache_disabled) char buf[bufsize]; FuseTest::expect_lookup(RELPATH, ino, S_IFREG | 0644, bufsize, 2); - expect_open(ino, FOPEN_KEEP_CACHE, 1); + expect_open(ino, 0, 2); expect_getattr(ino, bufsize); expect_read(ino, 0, bufsize, bufsize, CONTENTS); @@ -453,7 +452,7 @@ TEST_F(Read, keep_cache_disabled) ASSERT_LE(0, fd0) << strerror(errno); ASSERT_EQ(bufsize, read(fd0, buf, bufsize)) << strerror(errno); - fd1 = open(FULLPATH, O_RDONLY); + fd1 = open(FULLPATH, O_RDWR); ASSERT_LE(0, fd1) << strerror(errno); /* From owner-svn-src-projects@freebsd.org Fri Apr 5 15:04:26 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 88AFB1579A9A for ; Fri, 5 Apr 2019 15:04:26 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2BD779562E; Fri, 5 Apr 2019 15:04:26 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EDB76EC44; Fri, 5 Apr 2019 15:04:25 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x35F4Pv2048362; Fri, 5 Apr 2019 15:04:25 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x35F4PBc048360; Fri, 5 Apr 2019 15:04:25 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904051504.x35F4PBc048360@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 5 Apr 2019 15:04:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345949 - projects/fuse2/tests/sys/fs/fusefs X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: projects/fuse2/tests/sys/fs/fusefs X-SVN-Commit-Revision: 345949 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 2BD779562E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.971,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Apr 2019 15:04:26 -0000 Author: asomers Date: Fri Apr 5 15:04:25 2019 New Revision: 345949 URL: https://svnweb.freebsd.org/changeset/base/345949 Log: fusefs: reenable some fsyncdir tests These tests were actually fixed by r345398, r345390 and r345392, but I neglected to reenable them. Too bad googletest doesn't have the notion of an Expected Failure like ATF does. PR: 236474, 236473 Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/tests/sys/fs/fusefs/fsync.cc projects/fuse2/tests/sys/fs/fusefs/fsyncdir.cc Modified: projects/fuse2/tests/sys/fs/fusefs/fsync.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/fsync.cc Fri Apr 5 14:44:23 2019 (r345948) +++ projects/fuse2/tests/sys/fs/fusefs/fsync.cc Fri Apr 5 15:04:25 2019 (r345949) @@ -56,6 +56,11 @@ void expect_fsync(uint64_t ino, uint32_t flags, int er ResultOf([=](auto in) { return (in->header.opcode == FUSE_FSYNC && in->header.nodeid == ino && + /* + * TODO: reenable pid check after fixing + * bug 236379 + */ + //(pid_t)in->header.pid == getpid() && in->body.fsync.fh == FH && in->body.fsync.fsync_flags == flags); }, Eq(true)), @@ -76,7 +81,7 @@ void expect_write(uint64_t ino, uint64_t size, const v }; /* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236379 */ -TEST_F(Fsync, DISABLED_aio_fsync) +TEST_F(Fsync, aio_fsync) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; Modified: projects/fuse2/tests/sys/fs/fusefs/fsyncdir.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/fsyncdir.cc Fri Apr 5 14:44:23 2019 (r345948) +++ projects/fuse2/tests/sys/fs/fusefs/fsyncdir.cc Fri Apr 5 15:04:25 2019 (r345949) @@ -56,6 +56,10 @@ void expect_fsyncdir(uint64_t ino, uint32_t flags, int ResultOf([=](auto in) { return (in->header.opcode == FUSE_FSYNCDIR && in->header.nodeid == ino && + /* + * TODO: reenable pid check after fixing + * bug 236379 + */ //(pid_t)in->header.pid == getpid() && in->body.fsyncdir.fh == FH && in->body.fsyncdir.fsync_flags == flags); @@ -72,9 +76,7 @@ void expect_lookup(const char *relpath, uint64_t ino) }; /* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236379 */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236473 */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236474 */ -TEST_F(FsyncDir, DISABLED_aio_fsync) +TEST_F(FsyncDir, aio_fsync) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; @@ -98,9 +100,7 @@ TEST_F(FsyncDir, DISABLED_aio_fsync) /* Deliberately leak fd. close(2) will be tested in release.cc */ } -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236473 */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236474 */ -TEST_F(FsyncDir, DISABLED_eio) +TEST_F(FsyncDir, eio) { const char FULLPATH[] = "mountpoint/some_dir"; const char RELPATH[] = "some_dir"; @@ -124,7 +124,6 @@ TEST_F(FsyncDir, DISABLED_eio) * subsequent calls to VOP_FSYNC will succeed automatically without being sent * to the filesystem daemon */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236474 */ /* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236557 */ TEST_F(FsyncDir, DISABLED_enosys) { @@ -147,8 +146,7 @@ TEST_F(FsyncDir, DISABLED_enosys) /* Deliberately leak fd. close(2) will be tested in release.cc */ } -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236474 */ -TEST_F(FsyncDir, DISABLED_fsyncdata) +TEST_F(FsyncDir, fsyncdata) { const char FULLPATH[] = "mountpoint/some_dir"; const char RELPATH[] = "some_dir"; @@ -170,9 +168,7 @@ TEST_F(FsyncDir, DISABLED_fsyncdata) * Unlike regular files, the kernel doesn't know whether a directory is or * isn't dirty, so fuse(4) should always send FUSE_FSYNCDIR on fsync(2) */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236473 */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236474 */ -TEST_F(FsyncDir, DISABLED_fsync) +TEST_F(FsyncDir, fsync) { const char FULLPATH[] = "mountpoint/some_dir"; const char RELPATH[] = "some_dir"; From owner-svn-src-projects@freebsd.org Fri Apr 5 15:33:46 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2CB87157A5B9 for ; Fri, 5 Apr 2019 15:33:46 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C2A3096AE6; Fri, 5 Apr 2019 15:33:45 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 993C6F165; Fri, 5 Apr 2019 15:33:45 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x35FXjgO064538; Fri, 5 Apr 2019 15:33:45 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x35FXi7h064532; Fri, 5 Apr 2019 15:33:44 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904051533.x35FXi7h064532@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 5 Apr 2019 15:33:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345950 - in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Commit-Revision: 345950 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C2A3096AE6 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.966,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Apr 2019 15:33:46 -0000 Author: asomers Date: Fri Apr 5 15:33:43 2019 New Revision: 345950 URL: https://svnweb.freebsd.org/changeset/base/345950 Log: fusefs: correctly return EROFS from VOP_ACCESS Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/sys/fs/fuse/fuse_internal.c projects/fuse2/tests/sys/fs/fusefs/access.cc projects/fuse2/tests/sys/fs/fusefs/mockfs.cc projects/fuse2/tests/sys/fs/fusefs/mockfs.hh projects/fuse2/tests/sys/fs/fusefs/utils.cc projects/fuse2/tests/sys/fs/fusefs/utils.hh Modified: projects/fuse2/sys/fs/fuse/fuse_internal.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_internal.c Fri Apr 5 15:04:25 2019 (r345949) +++ projects/fuse2/sys/fs/fuse/fuse_internal.c Fri Apr 5 15:33:43 2019 (r345950) @@ -137,7 +137,7 @@ fuse_internal_access(struct vnode *vp, dataflags = data->dataflags; if ((mode & VWRITE) && vfs_isrdonly(mp)) { - return EACCES; + return EROFS; } /* Unless explicitly permitted, deny everyone except the fs owner. */ if (vnode_isvroot(vp) && !(facp->facc_flags & FACCESS_NOCHECKSPY)) { Modified: projects/fuse2/tests/sys/fs/fusefs/access.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/access.cc Fri Apr 5 15:04:25 2019 (r345949) +++ projects/fuse2/tests/sys/fs/fusefs/access.cc Fri Apr 5 15:33:43 2019 (r345950) @@ -46,6 +46,14 @@ void expect_lookup(const char *relpath, uint64_t ino) } }; +class RofsAccess: public Access { +public: +virtual void SetUp() { + m_ro = true; + Access::SetUp(); +} +}; + /* The error case of FUSE_ACCESS. */ /* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236291 */ TEST_F(Access, DISABLED_eaccess) @@ -81,6 +89,19 @@ TEST_F(Access, DISABLED_enosys) ASSERT_EQ(0, access(FULLPATH, access_mode)) << strerror(errno); ASSERT_EQ(0, access(FULLPATH, access_mode)) << strerror(errno); +} + +TEST_F(RofsAccess, erofs) +{ + const char FULLPATH[] = "mountpoint/some_file.txt"; + const char RELPATH[] = "some_file.txt"; + uint64_t ino = 42; + mode_t access_mode = W_OK; + + expect_lookup(RELPATH, ino); + + ASSERT_NE(0, access(FULLPATH, access_mode)); + ASSERT_EQ(EROFS, errno); } /* The successful case of FUSE_ACCESS. */ Modified: projects/fuse2/tests/sys/fs/fusefs/mockfs.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/mockfs.cc Fri Apr 5 15:04:25 2019 (r345949) +++ projects/fuse2/tests/sys/fs/fusefs/mockfs.cc Fri Apr 5 15:33:43 2019 (r345950) @@ -258,7 +258,7 @@ void debug_fuseop(const mockfs_buf_in *in) } MockFS::MockFS(int max_readahead, bool allow_other, bool default_permissions, - bool push_symlinks_in, uint32_t flags) + bool push_symlinks_in, bool ro, uint32_t flags) { struct iovec *iov = NULL; int iovlen = 0; @@ -305,6 +305,10 @@ MockFS::MockFS(int max_readahead, bool allow_other, bo } if (push_symlinks_in) { build_iovec(&iov, &iovlen, "push_symlinks_in", + __DECONST(void*, &trueval), sizeof(bool)); + } + if (ro) { + build_iovec(&iov, &iovlen, "ro", __DECONST(void*, &trueval), sizeof(bool)); } if (nmount(iov, iovlen, 0)) Modified: projects/fuse2/tests/sys/fs/fusefs/mockfs.hh ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/mockfs.hh Fri Apr 5 15:04:25 2019 (r345949) +++ projects/fuse2/tests/sys/fs/fusefs/mockfs.hh Fri Apr 5 15:33:43 2019 (r345950) @@ -216,7 +216,7 @@ class MockFS { /* Create a new mockfs and mount it to a tempdir */ MockFS(int max_readahead, bool allow_other, - bool default_permissions, bool push_symlinks_in, + bool default_permissions, bool push_symlinks_in, bool ro, uint32_t flags); virtual ~MockFS(); Modified: projects/fuse2/tests/sys/fs/fusefs/utils.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/utils.cc Fri Apr 5 15:04:25 2019 (r345949) +++ projects/fuse2/tests/sys/fs/fusefs/utils.cc Fri Apr 5 15:33:43 2019 (r345950) @@ -94,7 +94,7 @@ void FuseTest::SetUp() { try { m_mock = new MockFS(m_maxreadahead, m_allow_other, - m_default_permissions, m_push_symlinks_in, + m_default_permissions, m_push_symlinks_in, m_ro, m_init_flags); } catch (std::system_error err) { FAIL() << err.what(); Modified: projects/fuse2/tests/sys/fs/fusefs/utils.hh ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/utils.hh Fri Apr 5 15:04:25 2019 (r345949) +++ projects/fuse2/tests/sys/fs/fusefs/utils.hh Fri Apr 5 15:33:43 2019 (r345950) @@ -44,6 +44,7 @@ class FuseTest : public ::testing::Test { bool m_allow_other; bool m_default_permissions; bool m_push_symlinks_in; + bool m_ro; MockFS *m_mock = NULL; const static uint64_t FH = 0xdeadbeef1a7ebabe; @@ -59,7 +60,8 @@ class FuseTest : public ::testing::Test { m_init_flags(0), m_allow_other(false), m_default_permissions(false), - m_push_symlinks_in(false) + m_push_symlinks_in(false), + m_ro(false) {} virtual void SetUp(); From owner-svn-src-projects@freebsd.org Fri Apr 5 17:21:24 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A95AC155293B for ; Fri, 5 Apr 2019 17:21:24 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DFCE6C3F8; Fri, 5 Apr 2019 17:21:24 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 244C618314; Fri, 5 Apr 2019 17:21:24 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x35HLOwT020008; Fri, 5 Apr 2019 17:21:24 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x35HLNIX020006; Fri, 5 Apr 2019 17:21:23 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904051721.x35HLNIX020006@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 5 Apr 2019 17:21:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345958 - in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Commit-Revision: 345958 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4DFCE6C3F8 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.985,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Apr 2019 17:21:24 -0000 Author: asomers Date: Fri Apr 5 17:21:23 2019 New Revision: 345958 URL: https://svnweb.freebsd.org/changeset/base/345958 Log: fusefs: enforce -onoallow_other even beneath the mountpoint When -o allow_other is not in use, fusefs is supposed to prevent access to the filesystem by any user other than the one who owns the daemon. Our fusefs implementation was only enforcing that restriction at the mountpoint itself. That was usually good enough because lookup usually descends from the mountpoint. However, there are cases when it doesn't, such as when using openat relative to a file beneath the mountpoint. PR: 237052 Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/sys/fs/fuse/fuse_internal.c projects/fuse2/tests/sys/fs/fusefs/allow_other.cc Modified: projects/fuse2/sys/fs/fuse/fuse_internal.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_internal.c Fri Apr 5 16:54:20 2019 (r345957) +++ projects/fuse2/sys/fs/fuse/fuse_internal.c Fri Apr 5 17:21:23 2019 (r345958) @@ -140,7 +140,7 @@ fuse_internal_access(struct vnode *vp, return EROFS; } /* Unless explicitly permitted, deny everyone except the fs owner. */ - if (vnode_isvroot(vp) && !(facp->facc_flags & FACCESS_NOCHECKSPY)) { + if (!(facp->facc_flags & FACCESS_NOCHECKSPY)) { if (!(dataflags & FSESS_DAEMON_CAN_SPY)) { int denied = fuse_match_cred(data->daemoncred, cred); @@ -149,6 +149,10 @@ fuse_internal_access(struct vnode *vp, return EPERM; } } + /* + * Set the "skip cred check" flag so future callers that share + * facp can skip fuse_match_cred. + */ facp->facc_flags |= FACCESS_NOCHECKSPY; } if (!(facp->facc_flags & FACCESS_DO_ACCESS)) { Modified: projects/fuse2/tests/sys/fs/fusefs/allow_other.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/allow_other.cc Fri Apr 5 16:54:20 2019 (r345957) +++ projects/fuse2/tests/sys/fs/fusefs/allow_other.cc Fri Apr 5 17:21:23 2019 (r345958) @@ -179,3 +179,48 @@ TEST_F(NoAllowOther, disallowed) } ); } + +/* + * When -o allow_other is not used, users other than the owner aren't allowed + * to open anything inside of the mount point, not just the mountpoint itself + * This is a regression test for bug 237052 + */ +TEST_F(NoAllowOther, disallowed_beneath_root) +{ + const static char FULLPATH[] = "mountpoint/some_dir"; + const static char RELPATH[] = "some_dir"; + const static char RELPATH2[] = "other_dir"; + const static uint64_t ino = 42; + const static uint64_t ino2 = 43; + int dfd; + + expect_lookup(RELPATH, ino, S_IFDIR | 0755, 0, 1); + EXPECT_LOOKUP(ino, RELPATH2) + .WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto out) { + SET_OUT_HEADER_LEN(out, entry); + out->body.entry.attr.mode = S_IFREG | 0644; + out->body.entry.nodeid = ino2; + out->body.entry.attr.nlink = 1; + out->body.entry.attr_valid = UINT64_MAX; + }))); + expect_opendir(ino); + dfd = open(FULLPATH, O_DIRECTORY); + ASSERT_LE(0, dfd) << strerror(errno); + + fork(true, [] { + }, [&]() { + int fd; + + fd = openat(dfd, RELPATH2, O_RDONLY); + if (fd >= 0) { + fprintf(stderr, "openat should've failed\n"); + return(1); + } else if (errno != EPERM) { + fprintf(stderr, "Unexpected error: %s\n", + strerror(errno)); + return(1); + } + return 0; + } + ); +} From owner-svn-src-projects@freebsd.org Fri Apr 5 18:37:50 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9E2011556738 for ; Fri, 5 Apr 2019 18:37:50 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 419D26E8D2; Fri, 5 Apr 2019 18:37:50 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F03DE19082; Fri, 5 Apr 2019 18:37:49 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x35Ibnui059567; Fri, 5 Apr 2019 18:37:49 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x35Ibm4X059559; Fri, 5 Apr 2019 18:37:48 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904051837.x35Ibm4X059559@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 5 Apr 2019 18:37:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345962 - in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs X-SVN-Commit-Revision: 345962 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 419D26E8D2 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.95)[-0.953,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Apr 2019 18:37:51 -0000 Author: asomers Date: Fri Apr 5 18:37:48 2019 New Revision: 345962 URL: https://svnweb.freebsd.org/changeset/base/345962 Log: fusefs: implement VOP_ACCESS VOP_ACCESS was never fully implemented in fusefs. This change: * Removes the FACCESS_DO_ACCESS flag, which pretty much disabled the whole vop. * Removes a quixotic special case for VEXEC on regular files. I don't know why that was in there. * Removes another confusing special case for VADMIN. * Removes the FACCESS_NOCHECKSPY flag. It seemed to be a performance optimization, but I'm unconvinced that it was a net positive. * Updates test cases. This change does NOT implement -o default_permissions. That will be handled separately. PR: 236291 Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/sys/fs/fuse/fuse_internal.c projects/fuse2/sys/fs/fuse/fuse_internal.h projects/fuse2/tests/sys/fs/fusefs/access.cc projects/fuse2/tests/sys/fs/fusefs/mockfs.cc projects/fuse2/tests/sys/fs/fusefs/utils.cc Modified: projects/fuse2/sys/fs/fuse/fuse_internal.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_internal.c Fri Apr 5 18:17:11 2019 (r345961) +++ projects/fuse2/sys/fs/fuse/fuse_internal.c Fri Apr 5 18:37:48 2019 (r345962) @@ -115,7 +115,7 @@ fuse_internal_access(struct vnode *vp, struct ucred *cred) { int err = 0; - uint32_t mask = 0; + uint32_t mask = F_OK; int dataflags; int vtype; struct mount *mp; @@ -123,13 +123,6 @@ fuse_internal_access(struct vnode *vp, struct fuse_access_in *fai; struct fuse_data *data; - /* NOT YET DONE */ - /* - * If this vnop gives you trouble, just return 0 here for a lazy - * kludge. - */ - /* return 0;*/ - mp = vnode_mount(vp); vtype = vnode_vtype(vp); @@ -139,65 +132,37 @@ fuse_internal_access(struct vnode *vp, if ((mode & VWRITE) && vfs_isrdonly(mp)) { return EROFS; } + /* Unless explicitly permitted, deny everyone except the fs owner. */ - if (!(facp->facc_flags & FACCESS_NOCHECKSPY)) { + if (!(facp->facc_flags)) { if (!(dataflags & FSESS_DAEMON_CAN_SPY)) { - int denied = fuse_match_cred(data->daemoncred, - cred); + int denied = fuse_match_cred(data->daemoncred, cred); - if (denied) { + if (denied) return EPERM; - } } - /* - * Set the "skip cred check" flag so future callers that share - * facp can skip fuse_match_cred. - */ - facp->facc_flags |= FACCESS_NOCHECKSPY; } - if (!(facp->facc_flags & FACCESS_DO_ACCESS)) { + + if (dataflags & FSESS_DEFAULT_PERMISSIONS) { + /* TODO: Implement me! Bug 216391 */ return 0; } - if (((vtype == VREG) && (mode & VEXEC))) { -#ifdef NEED_MOUNT_ARGUMENT_FOR_THIS - /* Let the kernel handle this through open / close heuristics.*/ - return ENOTSUP; -#else - /* Let the kernel handle this. */ - return 0; -#endif - } - if (!fsess_isimpl(mp, FUSE_ACCESS)) { - /* Let the kernel handle this. */ - return 0; - } - if (dataflags & FSESS_DEFAULT_PERMISSIONS) { - /* Let the kernel handle this. */ - return 0; - } - if ((mode & VADMIN) != 0) { - err = priv_check_cred(cred, PRIV_VFS_ADMIN); - if (err) { - return err; - } - } - if ((mode & (VWRITE | VAPPEND | VADMIN)) != 0) { + + if (!fsess_isimpl(mp, FUSE_ACCESS)) + return 0; + + if ((mode & (VWRITE | VAPPEND | VADMIN)) != 0) mask |= W_OK; - } - if ((mode & VREAD) != 0) { + if ((mode & VREAD) != 0) mask |= R_OK; - } - if ((mode & VEXEC) != 0) { + if ((mode & VEXEC) != 0) mask |= X_OK; - } - bzero(&fdi, sizeof(fdi)); fdisp_init(&fdi, sizeof(*fai)); fdisp_make_vp(&fdi, FUSE_ACCESS, vp, td, cred); fai = fdi.indata; - fai->mask = F_OK; - fai->mask |= mask; + fai->mask = mask; err = fdisp_wait_answ(&fdi); fdisp_destroy(&fdi); Modified: projects/fuse2/sys/fs/fuse/fuse_internal.h ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_internal.h Fri Apr 5 18:17:11 2019 (r345961) +++ projects/fuse2/sys/fs/fuse/fuse_internal.h Fri Apr 5 18:37:48 2019 (r345962) @@ -155,7 +155,6 @@ fuse_iosize(struct vnode *vp) #define FVP_ACCESS_NOOP 0x01 #define FACCESS_VA_VALID 0x01 -#define FACCESS_DO_ACCESS 0x02 /* * Caller must be the directory's owner, or the superuser, or the sticky bit * must not be set @@ -163,7 +162,6 @@ fuse_iosize(struct vnode *vp) #define FACCESS_STICKY 0x04 /* Caller requires access to change file's owner */ #define FACCESS_CHOWN 0x08 -#define FACCESS_NOCHECKSPY 0x10 #define FACCESS_SETGID 0x12 #define FACCESS_XQUERIES (FACCESS_STICKY | FACCESS_CHOWN | FACCESS_SETGID) Modified: projects/fuse2/tests/sys/fs/fusefs/access.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/access.cc Fri Apr 5 18:17:11 2019 (r345961) +++ projects/fuse2/tests/sys/fs/fusefs/access.cc Fri Apr 5 18:37:48 2019 (r345962) @@ -55,14 +55,14 @@ virtual void SetUp() { }; /* The error case of FUSE_ACCESS. */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236291 */ -TEST_F(Access, DISABLED_eaccess) +TEST_F(Access, eaccess) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; uint64_t ino = 42; mode_t access_mode = X_OK; + expect_access(1, X_OK, 0); expect_lookup(RELPATH, ino); expect_access(ino, access_mode, EACCES); @@ -75,17 +75,15 @@ TEST_F(Access, DISABLED_eaccess) * and subsequent VOP_ACCESS calls will succeed automatically without querying * the daemon. */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236557 */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236291 */ -TEST_F(Access, DISABLED_enosys) +TEST_F(Access, enosys) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; uint64_t ino = 42; mode_t access_mode = R_OK; - expect_lookup(RELPATH, ino); - expect_access(ino, access_mode, ENOSYS); + expect_access(1, X_OK, ENOSYS); + FuseTest::expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 2); ASSERT_EQ(0, access(FULLPATH, access_mode)) << strerror(errno); ASSERT_EQ(0, access(FULLPATH, access_mode)) << strerror(errno); @@ -98,6 +96,7 @@ TEST_F(RofsAccess, erofs) uint64_t ino = 42; mode_t access_mode = W_OK; + expect_access(1, X_OK, 0); expect_lookup(RELPATH, ino); ASSERT_NE(0, access(FULLPATH, access_mode)); @@ -105,14 +104,14 @@ TEST_F(RofsAccess, erofs) } /* The successful case of FUSE_ACCESS. */ -/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236291 */ -TEST_F(Access, DISABLED_ok) +TEST_F(Access, ok) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; uint64_t ino = 42; mode_t access_mode = R_OK; + expect_access(1, X_OK, 0); expect_lookup(RELPATH, ino); expect_access(ino, access_mode, 0); Modified: projects/fuse2/tests/sys/fs/fusefs/mockfs.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/mockfs.cc Fri Apr 5 18:17:11 2019 (r345961) +++ projects/fuse2/tests/sys/fs/fusefs/mockfs.cc Fri Apr 5 18:37:48 2019 (r345962) @@ -162,6 +162,9 @@ void debug_fuseop(const mockfs_buf_in *in) switch (in->header.opcode) { const char *name, *value; + case FUSE_ACCESS: + printf(" mask=%#x", in->body.access.mask); + break; case FUSE_CREATE: name = (const char*)in->body.bytes + sizeof(fuse_open_in); Modified: projects/fuse2/tests/sys/fs/fusefs/utils.cc ============================================================================== --- projects/fuse2/tests/sys/fs/fusefs/utils.cc Fri Apr 5 18:17:11 2019 (r345961) +++ projects/fuse2/tests/sys/fs/fusefs/utils.cc Fri Apr 5 18:37:48 2019 (r345962) @@ -96,6 +96,21 @@ void FuseTest::SetUp() { m_mock = new MockFS(m_maxreadahead, m_allow_other, m_default_permissions, m_push_symlinks_in, m_ro, m_init_flags); + /* + * FUSE_ACCESS is called almost universally. Expecting it in + * each test case would be super-annoying. Instead, set a + * default expectation for FUSE_ACCESS and return ENOSYS. + * + * Individual test cases can override this expectation since + * googlemock evaluates expectations in LIFO order. + */ + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in->header.opcode == FUSE_ACCESS); + }, Eq(true)), + _) + ).Times(AnyNumber()) + .WillRepeatedly(Invoke(ReturnErrno(ENOSYS))); } catch (std::system_error err) { FAIL() << err.what(); } From owner-svn-src-projects@freebsd.org Sat Apr 6 01:49:38 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0898D15672AE for ; Sat, 6 Apr 2019 01:49:38 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9F6AA88731; Sat, 6 Apr 2019 01:49:37 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 931451DA18; Sat, 6 Apr 2019 01:49:37 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x361nbko094083; Sat, 6 Apr 2019 01:49:37 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x361nb4b094082; Sat, 6 Apr 2019 01:49:37 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904060149.x361nb4b094082@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Sat, 6 Apr 2019 01:49:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345973 - projects/runtime-coverage-v2/share/mk X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/runtime-coverage-v2/share/mk X-SVN-Commit-Revision: 345973 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9F6AA88731 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.974,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Apr 2019 01:49:38 -0000 Author: ngie Date: Sat Apr 6 01:49:37 2019 New Revision: 345973 URL: https://svnweb.freebsd.org/changeset/base/345973 Log: Force MK_COVERAGE off if not building with a C++11 capable compiler This will unbreak the build with powerpc*, etc. Modified: projects/runtime-coverage-v2/share/mk/src.opts.mk Modified: projects/runtime-coverage-v2/share/mk/src.opts.mk ============================================================================== --- projects/runtime-coverage-v2/share/mk/src.opts.mk Fri Apr 5 23:34:46 2019 (r345972) +++ projects/runtime-coverage-v2/share/mk/src.opts.mk Sat Apr 6 01:49:37 2019 (r345973) @@ -295,12 +295,6 @@ __DEFAULT_NO_OPTIONS+=LLVM_TARGET_BPF # This means that architectures that have GCC 4.2 as default can not # build Clang without using an external compiler. -# Note about MK_COVERAGE: -# -# clang and gcc 4.8+ (c++11 supporting compilers) support -fprofile-dir and -# can compile lib/libclang_rt/profile . libgcov, etc, in base is a dead end -# that I do not wish to support. - .if ${COMPILER_FEATURES:Mc++11} && (${__T} == "aarch64" || \ ${__T} == "amd64" || ${__TT} == "arm" || ${__T} == "i386") # Clang is enabled, and will be installed as the default /usr/bin/cc. @@ -574,6 +568,12 @@ MK_${vv:H}:= ${MK_${vv:T}} # .if !${COMPILER_FEATURES:Mc++11} +# Note about MK_COVERAGE: +# +# clang and gcc 4.8+ (c++11 supporting compilers) support -fprofile-dir and +# can compile lib/libclang_rt/profile . libgcov, etc, in base would require +# backports from GPLv3 versions of the gcc toolchain in order to function. +MK_COVERAGE:= no MK_LLDB:= no .endif From owner-svn-src-projects@freebsd.org Sat Apr 6 03:55:18 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 316B8156B2E0 for ; Sat, 6 Apr 2019 03:55:18 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AF7FD8BFD6; Sat, 6 Apr 2019 03:55:17 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 873271F0C4; Sat, 6 Apr 2019 03:55:17 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x363tHfl061947; Sat, 6 Apr 2019 03:55:17 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x363tHgh061946; Sat, 6 Apr 2019 03:55:17 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904060355.x363tHgh061946@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Sat, 6 Apr 2019 03:55:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345977 - projects/fuse2-googletest-engine X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: projects/fuse2-googletest-engine X-SVN-Commit-Revision: 345977 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: AF7FD8BFD6 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.972,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Apr 2019 03:55:18 -0000 Author: ngie Date: Sat Apr 6 03:55:17 2019 New Revision: 345977 URL: https://svnweb.freebsd.org/changeset/base/345977 Log: Remove ^/projects/fuse2-googletest-engine I isolated the issue seen on the branch and developed a fix for my googletest engine enhancement PR: https://github.com/jmmv/kyua/pull/203 . Deleted: projects/fuse2-googletest-engine/ From owner-svn-src-projects@freebsd.org Sat Apr 6 03:59:23 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 13FB8156B423 for ; Sat, 6 Apr 2019 03:59:23 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B70F18C14A; Sat, 6 Apr 2019 03:59:22 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 788401F0CA; Sat, 6 Apr 2019 03:59:22 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x363xMe5062192; Sat, 6 Apr 2019 03:59:22 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x363xLdg062187; Sat, 6 Apr 2019 03:59:21 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904060359.x363xLdg062187@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Sat, 6 Apr 2019 03:59:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345978 - in projects/kyua-use-googletest-test-interface: . contrib/bsnmp/gensnmptree contrib/bsnmp/lib contrib/bsnmp/snmp_mibII contrib/bsnmp/snmpd contrib/elftoolchain/strings contrib... X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: in projects/kyua-use-googletest-test-interface: . contrib/bsnmp/gensnmptree contrib/bsnmp/lib contrib/bsnmp/snmp_mibII contrib/bsnmp/snmpd contrib/elftoolchain/strings contrib/libxo contrib/libxo/doc ... X-SVN-Commit-Revision: 345978 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B70F18C14A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Apr 2019 03:59:23 -0000 Author: ngie Date: Sat Apr 6 03:59:21 2019 New Revision: 345978 URL: https://svnweb.freebsd.org/changeset/base/345978 Log: MFhead@r345977 Added: projects/kyua-use-googletest-test-interface/contrib/bsnmp/snmpd/trans_inet.c - copied unchanged from r345977, head/contrib/bsnmp/snmpd/trans_inet.c projects/kyua-use-googletest-test-interface/contrib/bsnmp/snmpd/trans_inet.h - copied unchanged from r345977, head/contrib/bsnmp/snmpd/trans_inet.h projects/kyua-use-googletest-test-interface/contrib/libxo/libxo/xo_explicit.h - copied unchanged from r345977, head/contrib/libxo/libxo/xo_explicit.h projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_02.H.err - copied unchanged from r345977, head/contrib/libxo/tests/xo/saved/xo_02.H.err projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_02.H.out - copied unchanged from r345977, head/contrib/libxo/tests/xo/saved/xo_02.H.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_02.HIPx.err - copied unchanged from r345977, head/contrib/libxo/tests/xo/saved/xo_02.HIPx.err projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_02.HIPx.out - copied unchanged from r345977, head/contrib/libxo/tests/xo/saved/xo_02.HIPx.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_02.HP.err - copied unchanged from r345977, head/contrib/libxo/tests/xo/saved/xo_02.HP.err projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_02.HP.out - copied unchanged from r345977, head/contrib/libxo/tests/xo/saved/xo_02.HP.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_02.J.err - copied unchanged from r345977, head/contrib/libxo/tests/xo/saved/xo_02.J.err projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_02.J.out - copied unchanged from r345977, head/contrib/libxo/tests/xo/saved/xo_02.J.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_02.JP.err - copied unchanged from r345977, head/contrib/libxo/tests/xo/saved/xo_02.JP.err projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_02.JP.out - copied unchanged from r345977, head/contrib/libxo/tests/xo/saved/xo_02.JP.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_02.T.err - copied unchanged from r345977, head/contrib/libxo/tests/xo/saved/xo_02.T.err projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_02.T.out - copied unchanged from r345977, head/contrib/libxo/tests/xo/saved/xo_02.T.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_02.X.err - copied unchanged from r345977, head/contrib/libxo/tests/xo/saved/xo_02.X.err projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_02.X.out - copied unchanged from r345977, head/contrib/libxo/tests/xo/saved/xo_02.X.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_02.XP.err - copied unchanged from r345977, head/contrib/libxo/tests/xo/saved/xo_02.XP.err projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_02.XP.out - copied unchanged from r345977, head/contrib/libxo/tests/xo/saved/xo_02.XP.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/xo_02.sh - copied unchanged from r345977, head/contrib/libxo/tests/xo/xo_02.sh projects/kyua-use-googletest-test-interface/lib/libsecureboot/pass_manifest.c - copied unchanged from r345977, head/lib/libsecureboot/pass_manifest.c projects/kyua-use-googletest-test-interface/sys/security/mac_veriexec_parser/ - copied from r345977, head/sys/security/mac_veriexec_parser/ projects/kyua-use-googletest-test-interface/tests/sys/geom/class/eli/online_resize_test.sh - copied unchanged from r345977, head/tests/sys/geom/class/eli/online_resize_test.sh projects/kyua-use-googletest-test-interface/tools/build/options/WITH_LOADER_VERIEXEC_PASS_MANFIEST - copied unchanged from r345977, head/tools/build/options/WITH_LOADER_VERIEXEC_PASS_MANFIEST Modified: projects/kyua-use-googletest-test-interface/UPDATING projects/kyua-use-googletest-test-interface/contrib/bsnmp/gensnmptree/gensnmptree.1 projects/kyua-use-googletest-test-interface/contrib/bsnmp/gensnmptree/gensnmptree.c projects/kyua-use-googletest-test-interface/contrib/bsnmp/lib/snmpclient.c projects/kyua-use-googletest-test-interface/contrib/bsnmp/lib/snmpclient.h projects/kyua-use-googletest-test-interface/contrib/bsnmp/lib/tc.def projects/kyua-use-googletest-test-interface/contrib/bsnmp/snmp_mibII/mibII_interfaces.c projects/kyua-use-googletest-test-interface/contrib/bsnmp/snmpd/BEGEMOT-SNMPD.txt projects/kyua-use-googletest-test-interface/contrib/bsnmp/snmpd/main.c projects/kyua-use-googletest-test-interface/contrib/bsnmp/snmpd/snmpd.config projects/kyua-use-googletest-test-interface/contrib/bsnmp/snmpd/snmpd.h projects/kyua-use-googletest-test-interface/contrib/bsnmp/snmpd/snmpmod.h projects/kyua-use-googletest-test-interface/contrib/bsnmp/snmpd/trans_lsock.c projects/kyua-use-googletest-test-interface/contrib/bsnmp/snmpd/trans_udp.c projects/kyua-use-googletest-test-interface/contrib/bsnmp/snmpd/tree.def projects/kyua-use-googletest-test-interface/contrib/elftoolchain/strings/strings.c projects/kyua-use-googletest-test-interface/contrib/libxo/configure.ac projects/kyua-use-googletest-test-interface/contrib/libxo/doc/api.rst projects/kyua-use-googletest-test-interface/contrib/libxo/doc/libxo-manual.html projects/kyua-use-googletest-test-interface/contrib/libxo/doc/xo.rst projects/kyua-use-googletest-test-interface/contrib/libxo/libxo/Makefile.am projects/kyua-use-googletest-test-interface/contrib/libxo/libxo/libxo.c projects/kyua-use-googletest-test-interface/contrib/libxo/libxo/xo.h projects/kyua-use-googletest-test-interface/contrib/libxo/libxo/xo_attr.3 projects/kyua-use-googletest-test-interface/contrib/libxo/libxo/xo_buf.h projects/kyua-use-googletest-test-interface/contrib/libxo/libxo/xo_emit.3 projects/kyua-use-googletest-test-interface/contrib/libxo/libxo/xo_emit_f.3 projects/kyua-use-googletest-test-interface/contrib/libxo/libxo/xo_finish.3 projects/kyua-use-googletest-test-interface/contrib/libxo/libxo/xo_flush.3 projects/kyua-use-googletest-test-interface/contrib/libxo/libxo/xo_open_container.3 projects/kyua-use-googletest-test-interface/contrib/libxo/libxo/xo_open_list.3 projects/kyua-use-googletest-test-interface/contrib/libxo/libxo/xo_open_marker.3 projects/kyua-use-googletest-test-interface/contrib/libxo/libxo/xo_set_writer.3 projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_01.J.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_02.J.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_03.J.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_04.J.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_05.J.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_05.JP.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_06.J.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_07.J.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_08.J.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_09.J.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_10.J.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_11.J.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_12.E.err projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_12.E.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_12.H.err projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_12.H.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_12.HIPx.err projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_12.HIPx.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_12.HP.err projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_12.HP.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_12.J.err projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_12.J.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_12.JP.err projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_12.JP.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_12.T.err projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_12.T.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_12.X.err projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_12.X.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_12.XP.err projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/saved/test_12.XP.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/core/test_12.c projects/kyua-use-googletest-test-interface/contrib/libxo/tests/gettext/po/pig_latin/strerror.po projects/kyua-use-googletest-test-interface/contrib/libxo/tests/gettext/saved/gt_01.J.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/Makefile.am projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_01.H.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_01.HIPx.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_01.HP.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_01.J.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_01.JP.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/saved/xo_01.T.out projects/kyua-use-googletest-test-interface/contrib/libxo/tests/xo/xo_01.sh projects/kyua-use-googletest-test-interface/contrib/libxo/xo/xo.1 projects/kyua-use-googletest-test-interface/contrib/libxo/xo/xo.c projects/kyua-use-googletest-test-interface/contrib/llvm/tools/clang/lib/CodeGen/CGObjCGNU.cpp projects/kyua-use-googletest-test-interface/lib/atf/libatf-c++/tests/Makefile projects/kyua-use-googletest-test-interface/lib/atf/libatf-c/tests/Makefile projects/kyua-use-googletest-test-interface/lib/geom/eli/geli.8 projects/kyua-use-googletest-test-interface/lib/geom/eli/geom_eli.c projects/kyua-use-googletest-test-interface/lib/libbe/be.c projects/kyua-use-googletest-test-interface/lib/libbsnmp/libbsnmp/Makefile projects/kyua-use-googletest-test-interface/lib/libc/net/getnameinfo.c projects/kyua-use-googletest-test-interface/lib/libcam/Makefile projects/kyua-use-googletest-test-interface/lib/libdevctl/devctl.3 projects/kyua-use-googletest-test-interface/lib/libdevctl/devctl.c projects/kyua-use-googletest-test-interface/lib/libdevctl/devctl.h projects/kyua-use-googletest-test-interface/lib/libsecureboot/Makefile.libsa.inc projects/kyua-use-googletest-test-interface/lib/libsecureboot/h/verify_file.h projects/kyua-use-googletest-test-interface/lib/libsecureboot/libsecureboot-priv.h projects/kyua-use-googletest-test-interface/lib/libsecureboot/verify_file.c projects/kyua-use-googletest-test-interface/lib/libxo/xo_config.h projects/kyua-use-googletest-test-interface/libexec/rc/network.subr projects/kyua-use-googletest-test-interface/release/Makefile.vm projects/kyua-use-googletest-test-interface/release/tools/ec2.conf projects/kyua-use-googletest-test-interface/release/tools/vmimage.subr projects/kyua-use-googletest-test-interface/sbin/bectl/bectl.8 projects/kyua-use-googletest-test-interface/sbin/fsck_msdosfs/dir.c projects/kyua-use-googletest-test-interface/sbin/fsck_msdosfs/fat.c projects/kyua-use-googletest-test-interface/share/man/man4/asmc.4 projects/kyua-use-googletest-test-interface/share/man/man4/intro.4 projects/kyua-use-googletest-test-interface/share/mk/src.opts.mk projects/kyua-use-googletest-test-interface/stand/common/boot.c projects/kyua-use-googletest-test-interface/stand/common/module.c projects/kyua-use-googletest-test-interface/stand/loader.mk projects/kyua-use-googletest-test-interface/sys/amd64/conf/NOTES projects/kyua-use-googletest-test-interface/sys/amd64/vmm/io/ppt.c projects/kyua-use-googletest-test-interface/sys/arm/ti/cpsw/if_cpsw.c projects/kyua-use-googletest-test-interface/sys/cam/ata/ata_all.c projects/kyua-use-googletest-test-interface/sys/cam/cam.c projects/kyua-use-googletest-test-interface/sys/cam/cam_periph.c projects/kyua-use-googletest-test-interface/sys/cam/nvme/nvme_all.c projects/kyua-use-googletest-test-interface/sys/cam/nvme/nvme_all.h projects/kyua-use-googletest-test-interface/sys/cam/nvme/nvme_da.c projects/kyua-use-googletest-test-interface/sys/cam/nvme/nvme_xpt.c projects/kyua-use-googletest-test-interface/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c projects/kyua-use-googletest-test-interface/sys/compat/linuxkpi/common/include/linux/etherdevice.h projects/kyua-use-googletest-test-interface/sys/compat/linuxkpi/common/include/linux/random.h projects/kyua-use-googletest-test-interface/sys/conf/files projects/kyua-use-googletest-test-interface/sys/conf/newvers.sh projects/kyua-use-googletest-test-interface/sys/dev/cxgbe/common/t4_hw.c projects/kyua-use-googletest-test-interface/sys/dev/fdt/fdt_common.c projects/kyua-use-googletest-test-interface/sys/dev/iicbus/twsi/a10_twsi.c projects/kyua-use-googletest-test-interface/sys/dev/iicbus/twsi/twsi.c projects/kyua-use-googletest-test-interface/sys/dev/iicbus/twsi/twsi.h projects/kyua-use-googletest-test-interface/sys/dev/ioat/ioat.c projects/kyua-use-googletest-test-interface/sys/dev/ioat/ioat_internal.h projects/kyua-use-googletest-test-interface/sys/dev/ioat/ioat_test.c projects/kyua-use-googletest-test-interface/sys/dev/ioat/ioat_test.h projects/kyua-use-googletest-test-interface/sys/dev/ipmi/ipmi_opal.c projects/kyua-use-googletest-test-interface/sys/dev/pci/pci.c projects/kyua-use-googletest-test-interface/sys/dev/pci/pci_pci.c projects/kyua-use-googletest-test-interface/sys/dev/pci/pcivar.h projects/kyua-use-googletest-test-interface/sys/dev/smartpqi/smartpqi_cam.c projects/kyua-use-googletest-test-interface/sys/dev/smartpqi/smartpqi_defines.h projects/kyua-use-googletest-test-interface/sys/dev/tpm/tpm20.c projects/kyua-use-googletest-test-interface/sys/dev/usb/net/if_muge.c projects/kyua-use-googletest-test-interface/sys/fs/msdosfs/msdosfs_denode.c projects/kyua-use-googletest-test-interface/sys/fs/nfs/nfs_commonkrpc.c projects/kyua-use-googletest-test-interface/sys/fs/nfs/nfs_commonport.c projects/kyua-use-googletest-test-interface/sys/fs/nfs/nfs_commonsubs.c projects/kyua-use-googletest-test-interface/sys/fs/nfs/nfs_var.h projects/kyua-use-googletest-test-interface/sys/fs/nfsclient/nfs_clport.c projects/kyua-use-googletest-test-interface/sys/fs/tmpfs/tmpfs.h projects/kyua-use-googletest-test-interface/sys/fs/tmpfs/tmpfs_fifoops.c projects/kyua-use-googletest-test-interface/sys/fs/tmpfs/tmpfs_subr.c projects/kyua-use-googletest-test-interface/sys/fs/tmpfs/tmpfs_vfsops.c projects/kyua-use-googletest-test-interface/sys/fs/tmpfs/tmpfs_vnops.c projects/kyua-use-googletest-test-interface/sys/geom/eli/g_eli.c projects/kyua-use-googletest-test-interface/sys/geom/eli/g_eli.h projects/kyua-use-googletest-test-interface/sys/geom/eli/g_eli_ctl.c projects/kyua-use-googletest-test-interface/sys/geom/eli/g_eli_key_cache.c projects/kyua-use-googletest-test-interface/sys/i386/conf/NOTES projects/kyua-use-googletest-test-interface/sys/kern/bus_if.m projects/kyua-use-googletest-test-interface/sys/kern/subr_bus.c projects/kyua-use-googletest-test-interface/sys/kern/vfs_vnops.c projects/kyua-use-googletest-test-interface/sys/net/if_spppsubr.c projects/kyua-use-googletest-test-interface/sys/netinet/in.c projects/kyua-use-googletest-test-interface/sys/netinet/ip_input.c projects/kyua-use-googletest-test-interface/sys/netinet/ip_output.c projects/kyua-use-googletest-test-interface/sys/netinet/netdump/netdump_client.c projects/kyua-use-googletest-test-interface/sys/netinet/tcp_output.c projects/kyua-use-googletest-test-interface/sys/netipsec/key.c projects/kyua-use-googletest-test-interface/sys/netipsec/key.h projects/kyua-use-googletest-test-interface/sys/netipsec/xform_esp.c projects/kyua-use-googletest-test-interface/sys/netpfil/ipfw/nat64/nat64_translate.h projects/kyua-use-googletest-test-interface/sys/netpfil/pf/pf.c projects/kyua-use-googletest-test-interface/sys/powerpc/fpu/fpu_sqrt.c projects/kyua-use-googletest-test-interface/sys/powerpc/include/trap.h projects/kyua-use-googletest-test-interface/sys/powerpc/powernv/opal.h projects/kyua-use-googletest-test-interface/sys/powerpc/powernv/opal_async.c projects/kyua-use-googletest-test-interface/sys/powerpc/powernv/opal_dev.c projects/kyua-use-googletest-test-interface/sys/powerpc/powernv/opal_flash.c projects/kyua-use-googletest-test-interface/sys/powerpc/powerpc/exec_machdep.c projects/kyua-use-googletest-test-interface/sys/powerpc/powerpc/trap.c projects/kyua-use-googletest-test-interface/sys/riscv/riscv/plic.c projects/kyua-use-googletest-test-interface/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c projects/kyua-use-googletest-test-interface/sys/sparc64/conf/NOTES projects/kyua-use-googletest-test-interface/sys/sys/ata.h projects/kyua-use-googletest-test-interface/sys/sys/bus.h projects/kyua-use-googletest-test-interface/sys/vm/vm_map.c projects/kyua-use-googletest-test-interface/sys/x86/iommu/busdma_dmar.c projects/kyua-use-googletest-test-interface/tests/sys/geom/class/eli/Makefile projects/kyua-use-googletest-test-interface/tests/sys/geom/class/eli/configure_test.sh projects/kyua-use-googletest-test-interface/tools/build/Makefile projects/kyua-use-googletest-test-interface/tools/tools/ioat/ioatcontrol.8 projects/kyua-use-googletest-test-interface/tools/tools/ioat/ioatcontrol.c projects/kyua-use-googletest-test-interface/usr.bin/rctl/rctl.c projects/kyua-use-googletest-test-interface/usr.bin/sort/coll.c projects/kyua-use-googletest-test-interface/usr.bin/strings/Makefile projects/kyua-use-googletest-test-interface/usr.bin/systat/devs.c projects/kyua-use-googletest-test-interface/usr.bin/systat/devs.h projects/kyua-use-googletest-test-interface/usr.bin/systat/iostat.c projects/kyua-use-googletest-test-interface/usr.bin/systat/swap.c projects/kyua-use-googletest-test-interface/usr.bin/systat/systat.h projects/kyua-use-googletest-test-interface/usr.bin/systat/vmstat.c projects/kyua-use-googletest-test-interface/usr.bin/systat/zarc.c projects/kyua-use-googletest-test-interface/usr.bin/top/display.c projects/kyua-use-googletest-test-interface/usr.bin/xohtml/xohtml.sh projects/kyua-use-googletest-test-interface/usr.sbin/bhyve/pci_nvme.c projects/kyua-use-googletest-test-interface/usr.sbin/bsnmpd/bsnmpd/Makefile projects/kyua-use-googletest-test-interface/usr.sbin/bsnmpd/bsnmpd/snmpd.config projects/kyua-use-googletest-test-interface/usr.sbin/devctl/devctl.8 projects/kyua-use-googletest-test-interface/usr.sbin/devctl/devctl.c Directory Properties: projects/kyua-use-googletest-test-interface/ (props changed) projects/kyua-use-googletest-test-interface/contrib/elftoolchain/ (props changed) projects/kyua-use-googletest-test-interface/contrib/libxo/ (props changed) projects/kyua-use-googletest-test-interface/contrib/llvm/ (props changed) projects/kyua-use-googletest-test-interface/contrib/llvm/tools/clang/ (props changed) projects/kyua-use-googletest-test-interface/sys/cddl/contrib/opensolaris/ (props changed) Modified: projects/kyua-use-googletest-test-interface/UPDATING ============================================================================== --- projects/kyua-use-googletest-test-interface/UPDATING Sat Apr 6 03:55:17 2019 (r345977) +++ projects/kyua-use-googletest-test-interface/UPDATING Sat Apr 6 03:59:21 2019 (r345978) @@ -31,6 +31,14 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW: disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20190404: + r345895 reverts r320698. This implies that an nfsuserd(8) daemon + built from head sources between r320757 (July 6, 2017) and + r338192 (Aug. 22, 2018) will not work unless the "-use-udpsock" + is added to the command line. + nfsuserd daemons built from head sources that are post-r338192 are + not affected and should continue to work. + 20190320: The fuse(4) module has been renamed to fusefs(4) for consistency with other filesystems. You should update any kld_load="fuse" entries in Modified: projects/kyua-use-googletest-test-interface/contrib/bsnmp/gensnmptree/gensnmptree.1 ============================================================================== --- projects/kyua-use-googletest-test-interface/contrib/bsnmp/gensnmptree/gensnmptree.1 Sat Apr 6 03:55:17 2019 (r345977) +++ projects/kyua-use-googletest-test-interface/contrib/bsnmp/gensnmptree/gensnmptree.1 Sat Apr 6 03:59:21 2019 (r345978) @@ -31,7 +31,7 @@ .\" .\" $Begemot: gensnmptree.1 383 2006-05-30 07:40:49Z brandt_h $ .\" -.Dd June 29, 2018 +.Dd April 2, 2019 .Dt GENSNMPTREE 1 .Os .Sh NAME @@ -100,25 +100,11 @@ is the length of the OID. is the last component of the OID. .El .It Fl F -Together with -.Fl E -causes -.Nm -instead of the generation of enum definitions the generation of -functions for checking a value to be one of the enumeration variants and -for conversion between strings and the enum. The file is sent to standard -output and is meant to be included into a C-file for compilation. +emit definitions for C-functions includeable in a C-file that do some basic +stuff on enums like value checking and conversion between value and strings. .It Fl f -This flag can be used together with -.Fl E -or when generating the tree files. It causes -.Nm -to emit static inline functions for checking a value to be one of the -enumeration values and for conversion between strings and the enum. -If used when generating the tree files, the preprocessor symbol -.Ar SNMPTREE_TYPES -must be defined when including the tree header file for these definitions -to become visible. +emit definitions for inline C-functions that do some basic +stuff on enums like value checking and conversion between value and strings. .It Fl h Print a short help page. .It Fl I Ar directory @@ -136,36 +122,6 @@ Instead of normal output print the resulting tree. Prefix the file names and the table name with .Ar prefix . .El -.Pp -The following functions are generated by -.Fl f -or -.Fl F : -.Pp -.Ft static inline int -.Fn isok_EnumName "enum EnumName" ; -.Pp -.Ft static inline const char * -.Fn tostr_EnumName "enum EnumName" ; -.Pp -.Ft static inline int -.Fn fromstr_EnumName "const char *" "enum EnumName *" ; -.Pp -The -.Fa EnumName -is replaced with the enumeration name. -.Fn isok_EnumName -returns 1 if the argument is one of the valid enum values and 0 otherwise. -.Fn tostr_EnumName -returns a string representation of the enumeration value. -If the values is not one of the legal values -.Ar EnumName??? -is returned. -.Fn fromstr_EnumName -returns 1 if the string represents one of the legal enumeration values and -0 otherwise. -If 1 is return the variable pointed to by the second argument is set to -the enumeration value. .Sh MIBS The syntax of the MIB description file can formally be specified as follows: .Bd -unfilled -offset indent Modified: projects/kyua-use-googletest-test-interface/contrib/bsnmp/gensnmptree/gensnmptree.c ============================================================================== --- projects/kyua-use-googletest-test-interface/contrib/bsnmp/gensnmptree/gensnmptree.c Sat Apr 6 03:55:17 2019 (r345977) +++ projects/kyua-use-googletest-test-interface/contrib/bsnmp/gensnmptree/gensnmptree.c Sat Apr 6 03:59:21 2019 (r345978) @@ -110,7 +110,6 @@ static int debug; static const char usgtxt[] = "\ Generate SNMP tables.\n\ -$Id$\n\ usage: gensnmptree [-dEeFfhlt] [-I directory] [-i infile] [-p prefix]\n\ [name]...\n\ options:\n\ @@ -127,6 +126,37 @@ options:\n\ -t generate a .def file\n\ "; +/** + * Program operation. + */ +enum op { + /** generate the tree */ + OP_GEN, + + /** extract OIDs */ + OP_EXTRACT, + + /** print the parsed tree */ + OP_TREE, + + /** extract enums */ + OP_ENUMS, +}; + +/** + * Which functions to create. + */ +enum gen_funcs { + /** none */ + GEN_FUNCS_NONE, + + /** functions for header files */ + GEN_FUNCS_H, + + /** functions for C files */ + GEN_FUNCS_C, +}; + /* * A node in the OID tree */ @@ -162,15 +192,18 @@ struct node { uint32_t index; /* index for table entry */ char *func; /* function for tables */ struct node_list subs; + char *subtypes[SNMP_INDEXES_MAX]; } entry; struct leaf { enum snmp_syntax syntax; /* syntax for this leaf */ char *func; /* function name */ + char *subtype; /* subtype */ } leaf; struct column { enum snmp_syntax syntax; /* syntax for this column */ + char *subtype; /* subtype */ } column; } u; }; @@ -214,7 +247,7 @@ xalloc(size_t size) { void *ptr; - if ((ptr = malloc(size)) == NULL) + if ((ptr = calloc(1, size)) == NULL) err(1, "allocing %zu bytes", size); return (ptr); @@ -710,12 +743,14 @@ make_type(const char *s) * token. */ static u_int -parse_type(enum tok *tok, struct type *t, const char *vname) +parse_type(enum tok *tok, struct type *t, const char *vname, char **subtype) { u_int syntax; struct enums *e; syntax = val; + if (subtype != NULL) + *subtype = NULL; if (*tok == TOK_ENUM || *tok == TOK_BITS) { if (t == NULL && vname != NULL) { @@ -759,6 +794,8 @@ parse_type(enum tok *tok, struct type *t, const char * if ((*tok = gettoken()) == '|') { if (gettoken() != TOK_STR) report("subtype expected after '|'"); + if (subtype != NULL) + *subtype = savetok(); *tok = gettoken(); } } @@ -794,18 +831,21 @@ parse(enum tok tok) if ((tok = gettoken()) == TOK_TYPE || tok == TOK_DEFTYPE || tok == TOK_ENUM || tok == TOK_BITS) { /* LEAF or COLUM */ - u_int syntax = parse_type(&tok, NULL, node->name); + char *subtype; + u_int syntax = parse_type(&tok, NULL, node->name, &subtype); if (tok == TOK_STR) { /* LEAF */ node->type = NODE_LEAF; node->u.leaf.func = savetok(); node->u.leaf.syntax = syntax; + node->u.leaf.subtype = subtype; tok = gettoken(); } else { /* COLUMN */ node->type = NODE_COLUMN; node->u.column.syntax = syntax; + node->u.column.subtype = subtype; } while (tok != ')') { @@ -825,9 +865,12 @@ parse(enum tok tok) tok = gettoken(); while (tok == TOK_TYPE || tok == TOK_DEFTYPE || tok == TOK_ENUM || tok == TOK_BITS) { - u_int syntax = parse_type(&tok, NULL, node->name); - if (index_count++ == SNMP_INDEXES_MAX) + char *subtype; + u_int syntax = parse_type(&tok, NULL, node->name, + &subtype); + if (index_count == SNMP_INDEXES_MAX) report("too many table indexes"); + node->u.entry.subtypes[index_count++] = subtype; node->u.entry.index |= syntax << (SNMP_INDEX_SHIFT * index_count); } @@ -882,7 +925,8 @@ parse_top(enum tok tok) tok = gettoken(); t->is_enum = (tok == TOK_ENUM); t->is_bits = (tok == TOK_BITS); - t->syntax = parse_type(&tok, t, NULL); + + t->syntax = parse_type(&tok, t, NULL, NULL); pushback(tok); return (NULL); @@ -903,7 +947,7 @@ parse_top(enum tok tok) * Generate the C-code table part for one node. */ static void -gen_node(FILE *fp, struct node *np, struct asn_oid *oid, u_int idx, +gen_node(FILE *fp, const struct node *np, struct asn_oid *oid, u_int idx, const char *func) { u_int n; @@ -1008,7 +1052,7 @@ gen_node(FILE *fp, struct node *np, struct asn_oid *oi * Generate the header file with the function declarations. */ static void -gen_header(FILE *fp, struct node *np, u_int oidlen, const char *func) +gen_header(FILE *fp, const struct node *np, u_int oidlen, const char *func) { char f[MAXSTR + 4]; struct node *sub; @@ -1058,7 +1102,7 @@ gen_header(FILE *fp, struct node *np, u_int oidlen, co * Generate the OID table. */ static void -gen_table(FILE *fp, struct node *node) +gen_table(FILE *fp, const struct node *node) { struct asn_oid oid; @@ -1067,7 +1111,6 @@ gen_table(FILE *fp, struct node *node) #ifdef HAVE_STDINT_H fprintf(fp, "#include \n"); #endif - fprintf(fp, "#include \n"); if (localincs) { fprintf(fp, "#include \"asn1.h\"\n"); fprintf(fp, "#include \"snmp.h\"\n"); @@ -1118,6 +1161,8 @@ gen_tree(const struct node *np, int level) case NODE_LEAF: print_syntax(np->u.leaf.syntax); + if (np->u.leaf.subtype != NULL) + printf(" | %s", np->u.leaf.subtype); printf(" %s%s%s)\n", np->u.leaf.func, (np->flags & FL_GET) ? " GET" : "", (np->flags & FL_SET) ? " SET" : ""); @@ -1137,8 +1182,11 @@ gen_tree(const struct node *np, int level) case NODE_ENTRY: printf(" :"); - for (i = 0; i < SNMP_INDEX_COUNT(np->u.entry.index); i++) + for (i = 0; i < SNMP_INDEX_COUNT(np->u.entry.index); i++) { print_syntax(SNMP_INDEX(np->u.entry.index, i)); + if (np->u.entry.subtypes[i] != NULL) + printf(" | %s", np->u.entry.subtypes[i]); + } printf(" %s\n", np->u.entry.func); TAILQ_FOREACH(sp, &np->u.entry.subs, link) gen_tree(sp, level + 1); @@ -1147,6 +1195,8 @@ gen_tree(const struct node *np, int level) case NODE_COLUMN: print_syntax(np->u.column.syntax); + if (np->u.column.subtype != NULL) + printf(" | %s", np->u.column.subtype); printf("%s%s)\n", (np->flags & FL_GET) ? " GET" : "", (np->flags & FL_SET) ? " SET" : ""); break; @@ -1194,15 +1244,6 @@ extract(FILE *fp, const struct node *np, struct asn_oi return (1); } -/** - * Extract the named OID. - * - * \param fp file to extract to - * \param root root of the tree - * \param object name of the object to extract - * - * \return 0 on success, -1 if the object was not found - */ static int gen_extract(FILE *fp, const struct node *root, char *object) { @@ -1391,45 +1432,6 @@ unminus(FILE *fp, const char *s) } /** - * Generate a definition for the enum packed into a guard against multiple - * definitions. - * - * \param fp file to write definition to - * \param t type - */ -static void -gen_enum(FILE *fp, const struct type *t) -{ - const struct enums *e; - long min = LONG_MAX; - - fprintf(fp, "\n"); - fprintf(fp, "#ifndef %s_defined__\n", t->name); - fprintf(fp, "#define %s_defined__\n", t->name); - fprintf(fp, "/*\n"); - fprintf(fp, " * From %s:%u\n", t->from_fname, t->from_lno); - fprintf(fp, " */\n"); - fprintf(fp, "enum %s {\n", t->name); - TAILQ_FOREACH(e, &t->enums, link) { - fprintf(fp, "\t%s_", t->name); - unminus(fp, e->name); - fprintf(fp, " = %ld,\n", e->value); - if (e->value < min) - min = e->value; - } - fprintf(fp, "};\n"); - fprintf(fp, "#define STROFF_%s %ld\n", t->name, min); - fprintf(fp, "#define STRING_%s \\\n", t->name); - TAILQ_FOREACH(e, &t->enums, link) { - fprintf(fp, "\t[%ld] = \"%s_", e->value - min, t->name); - unminus(fp, e->name); - fprintf(fp, "\",\\\n"); - } - fprintf(fp, "\n"); - fprintf(fp, "#endif /* %s_defined__ */\n", t->name); -} - -/** * Generate helper functions for an enum. * * We always generate a switch statement for the isok function. The compiler @@ -1494,6 +1496,54 @@ gen_enum_funcs(FILE *fp, const struct type *t, int cco } /** + * Generate a definition for the enum packed into a guard against multiple + * definitions. + * + * \param fp file to write definition to + * \param t type + * \param dof generate functions too + */ +static void +gen_enum(FILE *fp, const struct type *t, int dof) +{ + const struct enums *e; + long min = LONG_MAX; + + fprintf(fp, "\n"); + fprintf(fp, "#ifndef %s_defined__\n", t->name); + fprintf(fp, "#define %s_defined__\n", t->name); + fprintf(fp, "/*\n"); + fprintf(fp, " * From %s:%u\n", t->from_fname, t->from_lno); + fprintf(fp, " */\n"); + fprintf(fp, "enum %s {\n", t->name); + TAILQ_FOREACH(e, &t->enums, link) { + fprintf(fp, "\t%s_", t->name); + unminus(fp, e->name); + fprintf(fp, " = %ld,\n", e->value); + if (e->value < min) + min = e->value; + } + fprintf(fp, "};\n"); + fprintf(fp, "#define STROFF_%s %ld\n", t->name, min); + fprintf(fp, "#define STRING_%s \\\n", t->name); + TAILQ_FOREACH(e, &t->enums, link) { + fprintf(fp, "\t[%ld] = \"%s_", e->value - min, t->name); + unminus(fp, e->name); + fprintf(fp, "\",\\\n"); + } + fprintf(fp, "\n"); + if (dof) { + fprintf(fp, "#ifdef SNMPENUM_FUNCS\n"); + fprintf(fp, "\n"); + gen_enum_funcs(fp, t, 0); + fprintf(fp, "\n"); + fprintf(fp, "#endif\n"); + fprintf(fp, "\n"); + } + fprintf(fp, "#endif /* %s_defined__ */\n", t->name); +} + +/** * Generate helper functions for an enum. This generates code for a c file. * * \param fp file to write to @@ -1529,6 +1579,16 @@ gen_all_enum_funcs(FILE *fp, int ccode) gen_enum_funcs(fp, t, ccode); } +static void +gen_enums(FILE *fp, int dof) +{ + const struct type *t; + + LIST_FOREACH(t, &types, link) + if (t->is_enum || t->is_bits) + gen_enum(fp, t, dof); +} + /** * Extract a given enum to the specified file and optionally generate static * inline helper functions for them. @@ -1546,9 +1606,7 @@ extract_enum(FILE *fp, const char *name, int gen_funcs LIST_FOREACH(t, &types, link) if ((t->is_enum || t->is_bits) && strcmp(t->name, name) == 0) { - gen_enum(fp, t); - if (gen_funcs) - gen_enum_funcs(fp, t, 0); + gen_enum(fp, t, gen_funcs); return (0); } return (-1); @@ -1567,11 +1625,8 @@ extract_all_enums(FILE *fp, int gen_funcs) const struct type *t; LIST_FOREACH(t, &types, link) - if (t->is_enum || t->is_bits) { - gen_enum(fp, t); - if (gen_funcs) - gen_enum_funcs(fp, t, 0); - } + if (t->is_enum || t->is_bits) + gen_enum(fp, t, gen_funcs); } /** @@ -1579,13 +1634,12 @@ extract_all_enums(FILE *fp, int gen_funcs) * * \param argc number of arguments * \param argv arguments (enum names) - * \param gen_funcs_h generate functions into the header file - * \param gen_funcs_c generate a .c file with functions + * \param gen_funcs which functions to generate */ static void -make_enums(int argc, char *argv[], int gen_funcs_h, int gen_funcs_c) +make_enums(int argc, char *argv[], enum gen_funcs gen_funcs) { - if (gen_funcs_c) { + if (gen_funcs == GEN_FUNCS_C) { if (argc == 0) gen_all_enum_funcs(stdout, 1); else { @@ -1595,30 +1649,58 @@ make_enums(int argc, char *argv[], int gen_funcs_h, in } } else { if (argc == 0) - extract_all_enums(stdout, gen_funcs_h); + extract_all_enums(stdout, gen_funcs == GEN_FUNCS_H); else { for (int i = 0; i < argc; i++) - if (extract_enum(stdout, argv[i], gen_funcs_h)) + if (extract_enum(stdout, argv[i], + gen_funcs == GEN_FUNCS_H)) errx(1, "enum not found: %s", argv[i]); } } } +/** + * Produce the operation tables for the daemon or a module. + * + * \param root tree root + * \param gen_funcs generate enum funcs + */ +static void +make_table(const struct node *root, int gen_funcs) +{ + FILE *fp; + + char fname[MAXPATHLEN + 1]; + sprintf(fname, "%stree.h", file_prefix); + if ((fp = fopen(fname, "w")) == NULL) + err(1, "%s: ", fname); + gen_header(fp, root, PREFIX_LEN, NULL); + + fprintf(fp, "\n#ifdef SNMPTREE_TYPES\n"); + gen_enums(fp, gen_funcs); + fprintf(fp, "\n#endif /* SNMPTREE_TYPES */\n\n"); + + fprintf(fp, "#define %sCTREE_SIZE %u\n", file_prefix, tree_size); + fprintf(fp, "extern const struct snmp_node %sctree[];\n", file_prefix); + + fclose(fp); + + sprintf(fname, "%stree.c", file_prefix); + if ((fp = fopen(fname, "w")) == NULL) + err(1, "%s: ", fname); + gen_table(fp, root); + fclose(fp); +} + int main(int argc, char *argv[]) { - int do_extract = 0; - int do_tree = 0; - int do_enums = 0; - int gen_funcs_h = 0; - int gen_funcs_c = 0; - int opt; - struct node *root; - char fname[MAXPATHLEN + 1]; - int tok; - FILE *fp; + enum op op = OP_GEN; + enum gen_funcs gen_funcs = GEN_FUNCS_NONE; + char *infile = NULL; + int opt; while ((opt = getopt(argc, argv, "dEeFfhI:i:lp:t")) != EOF) switch (opt) { @@ -1627,19 +1709,29 @@ main(int argc, char *argv[]) break; case 'E': - do_enums = 1; + if (op != OP_GEN && op != OP_ENUMS) + errx(1, "-E conflicts with earlier options"); + op = OP_ENUMS; break; case 'e': - do_extract = 1; + if (op != OP_GEN && op != OP_EXTRACT) + errx(1, "-e conflicts with earlier options"); + op = OP_EXTRACT; break; case 'F': - gen_funcs_c = 1; + if (gen_funcs != GEN_FUNCS_NONE && + gen_funcs != GEN_FUNCS_C) + errx(1, "-F conflicts with -f"); + gen_funcs = GEN_FUNCS_C; break; case 'f': - gen_funcs_h = 1; + if (gen_funcs != GEN_FUNCS_NONE && + gen_funcs != GEN_FUNCS_H) + errx(1, "-f conflicts with -F"); + gen_funcs = GEN_FUNCS_H; break; case 'h': @@ -1666,75 +1758,61 @@ main(int argc, char *argv[]) break; case 't': - do_tree = 1; + if (op != OP_GEN && op != OP_TREE) + errx(1, "-t conflicts with earlier options"); + op = OP_TREE; break; } - if (do_extract + do_tree + do_enums > 1) - errx(1, "conflicting options -e/-t/-E"); - if (!do_extract && !do_enums && argc != optind) - errx(1, "no arguments allowed"); - if (do_extract && argc == optind) - errx(1, "no objects specified"); + argc -= optind; + argv += optind; - if ((gen_funcs_h || gen_funcs_c) && (do_extract || do_tree)) - errx(1, "-f and -F not allowed with -e or -t"); - if (gen_funcs_c && !do_enums) - errx(1, "-F requires -E"); - if (gen_funcs_h && gen_funcs_c) - errx(1, "-f and -F are mutually exclusive"); - + /* open input */ if (infile == NULL) { input_new(stdin, NULL, ""); } else { + FILE *fp; if ((fp = fopen(infile, "r")) == NULL) err(1, "%s", infile); input_new(fp, NULL, infile); } - root = parse_top(gettoken()); + /* parse and check input */ + struct node *root = parse_top(gettoken()); + + int tok; while ((tok = gettoken()) != TOK_EOF) merge(&root, parse_top(tok)); if (root) check_tree(root); - if (do_extract) { - while (optind < argc) { - if (gen_extract(stdout, root, argv[optind])) - errx(1, "object not found: %s", argv[optind]); - optind++; - } + /* do what the user has requested */ + switch (op) { + + case OP_EXTRACT: + if (argc == 0) + errx(1, "-e requires arguments"); + + for (int i = 0; i < argc; i++) + if (gen_extract(stdout, root, argv[i])) + errx(1, "object not found: %s", argv[i]); return (0); - } - if (do_enums) { - make_enums(argc - optind, argv + optind, - gen_funcs_h, gen_funcs_c); + + case OP_ENUMS: + make_enums(argc, argv, gen_funcs); return (0); - } - if (do_tree) { + + case OP_TREE: + if (argc != 0) + errx(1, "-t allows no arguments"); gen_tree(root, 0); return (0); - } - sprintf(fname, "%stree.h", file_prefix); - if ((fp = fopen(fname, "w")) == NULL) - err(1, "%s: ", fname); - gen_header(fp, root, PREFIX_LEN, NULL); - fprintf(fp, "\n#ifdef SNMPTREE_TYPES\n"); - extract_all_enums(fp, gen_funcs_h); - fprintf(fp, "\n#endif /* SNMPTREE_TYPES */\n\n"); - - fprintf(fp, "#define %sCTREE_SIZE %u\n", file_prefix, tree_size); - fprintf(fp, "extern const struct snmp_node %sctree[];\n", file_prefix); - - fclose(fp); - - sprintf(fname, "%stree.c", file_prefix); - if ((fp = fopen(fname, "w")) == NULL) - err(1, "%s: ", fname); - gen_table(fp, root); - fclose(fp); - - return (0); + case OP_GEN: + if (argc != 0) + errx(1, "tree generation allows no arguments"); + make_table(root, gen_funcs == GEN_FUNCS_H); + return (0); + } } Modified: projects/kyua-use-googletest-test-interface/contrib/bsnmp/lib/snmpclient.c ============================================================================== --- projects/kyua-use-googletest-test-interface/contrib/bsnmp/lib/snmpclient.c Sat Apr 6 03:55:17 2019 (r345977) +++ projects/kyua-use-googletest-test-interface/contrib/bsnmp/lib/snmpclient.c Sat Apr 6 03:59:21 2019 (r345978) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2005 + * Copyright (c) 2004-2005,2018 * Hartmut Brandt. * All rights reserved. * Copyright (c) 2001-2003 @@ -34,11 +34,13 @@ * * Support functions for SNMP clients. */ -#include +#include #include #include #include #include +#include +#include #include #include #include @@ -58,12 +60,16 @@ #include #endif +#include + #include "support.h" #include "asn1.h" #include "snmp.h" #include "snmpclient.h" #include "snmppriv.h" +#define DEBUG_PARSE 0 + /* global context */ struct snmp_client snmp_client; @@ -924,7 +930,8 @@ open_client_udp(const char *host, const char *port) /* open connection */ memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_CANONNAME; - hints.ai_family = AF_INET; + hints.ai_family = snmp_client.trans == SNMP_TRANS_UDP ? AF_INET: + AF_INET6; hints.ai_socktype = SOCK_DGRAM; hints.ai_protocol = 0; error = getaddrinfo(snmp_client.chost, snmp_client.cport, &hints, &res0); @@ -1068,6 +1075,7 @@ snmp_open(const char *host, const char *port, const ch switch (snmp_client.trans) { case SNMP_TRANS_UDP: + case SNMP_TRANS_UDP6: if (open_client_udp(host, port) != 0) return (-1); break; @@ -1866,99 +1874,412 @@ snmp_client_set_port(struct snmp_client *cl, const cha return (0); } -/* - * parse a server specification +static const char *const trans_list[] = { + [SNMP_TRANS_UDP] = "udp::", + [SNMP_TRANS_LOC_DGRAM] = "dgram::", + [SNMP_TRANS_LOC_STREAM] = "stream::", + [SNMP_TRANS_UDP6] = "udp6::", +}; + +/** + * Try to get a transport identifier which is a leading alphanumeric string + * terminated by a double colon. The string may not be empty. The transport + * identifier is optional. * - * [trans::][community@][server][:port] + * \param sc client struct to set errors + * \param strp possible start of transport; updated to point to + * the next character to parse + * + * \return transport identifier */ -int -snmp_parse_server(struct snmp_client *sc, const char *str) +static inline int +get_transp(struct snmp_client *sc, const char **strp) { - const char *p, *s = str; + const char *p; + size_t i; - /* look for a double colon */ - for (p = s; *p != '\0'; p++) { - if (*p == '\\' && p[1] != '\0') { - p++; + for (i = 0; i < nitems(trans_list); i++) { + if (trans_list[i] == NULL || *trans_list[i] == '\0') continue; + p = strstr(*strp, trans_list[i]); + if (p == *strp) { + *strp += strlen(trans_list[i]); + return ((int)i); } - if (*p == ':' && p[1] == ':') - break; } - if (*p != '\0') { - if (p > s) { - if (p - s == 3 && strncmp(s, "udp", 3) == 0) - sc->trans = SNMP_TRANS_UDP; - else if (p - s == 6 && strncmp(s, "stream", 6) == 0) - sc->trans = SNMP_TRANS_LOC_STREAM; - else if (p - s == 5 && strncmp(s, "dgram", 5) == 0) - sc->trans = SNMP_TRANS_LOC_DGRAM; - else { - seterr(sc, "unknown SNMP transport '%.*s'", - (int)(p - s), s); - return (-1); - } - } - s = p + 2; + + p = *strp; + if (p[0] == ':' && p[1] == ':') { + seterr(sc, "empty transport specifier"); + return (-1); } + /* by default assume UDP */ + return (SNMP_TRANS_UDP); +} - /* look for a @ */ - for (p = s; *p != '\0'; p++) { - if (*p == '\\' && p[1] != '\0') { - p++; - continue; - } - if (*p == '@') - break; +/** + * Try to get community string. Eat everything up to the last @ (if there is + * any) but only if it is not longer than SNMP_COMMUNITY_MAXLEN. Empty + * community strings are legal. + * + * \param sc client struct to set errors + * \param strp possible start of community; updated to the point to + * the next character to parse + * + * \return end of community; equals *strp if there is none; NULL if there + * was an error + */ +static inline const char * +get_comm(struct snmp_client *sc, const char **strp) +{ + const char *p = strrchr(*strp, '@'); + + if (p == NULL) + /* no community string */ + return (*strp); + + if (p - *strp > SNMP_COMMUNITY_MAXLEN) { + seterr(sc, "community string too long '%.*s'", + p - *strp, *strp); + return (NULL); } - if (*p != '\0') { - if (p - s > SNMP_COMMUNITY_MAXLEN) { - seterr(sc, "community string too long"); - return (-1); + *strp = p + 1; + return (p); +} + +/** + * Try to get an IPv6 address. This starts with an [ and should end with an ] + * and everything between should be not longer than INET6_ADDRSTRLEN and + * parseable by inet_pton(). + * + * \param sc client struct to set errors + * \param strp possible start of IPv6 address (the '['); updated to point to + * the next character to parse (the one after the closing ']') + * + * \return end of address (equals *strp + 1 if there is none) or NULL + * on errors + */ +static inline const char * +get_ipv6(struct snmp_client *sc, const char **strp) +{ + char str[INET6_ADDRSTRLEN + IF_NAMESIZE]; + struct addrinfo hints, *res; + int error; + + if (**strp != '[') + return (*strp + 1); + + const char *p = *strp + 1; + while (*p != ']' ) { + if (*p == '\0') { + seterr(sc, "unterminated IPv6 address '%.*s'", + p - *strp, *strp); + return (NULL); } - strncpy(sc->read_community, s, p - s); - sc->read_community[p - s] = '\0'; - strncpy(sc->write_community, s, p - s); - sc->write_community[p - s] = '\0'; - s = p + 1; + p++; } - /* look for a colon */ - for (p = s; *p != '\0'; p++) { - if (*p == '\\' && p[1] != '\0') { - p++; - continue; - } - if (*p == ':') - break; + if (p - *strp > INET6_ADDRSTRLEN + IF_NAMESIZE) { + seterr(sc, "IPv6 address too long '%.*s'", p - *strp, *strp); + return (NULL); } - if (*p == ':') { - if (p > s) { - /* host:port */ - free(sc->chost); - if ((sc->chost = malloc(p - s + 1)) == NULL) { - seterr(sc, "%s", strerror(errno)); - return (-1); - } - strncpy(sc->chost, s, p - s); - sc->chost[p - s] = '\0'; - } - /* port */ - free(sc->cport); - if ((sc->cport = strdup(p + 1)) == NULL) { - seterr(sc, "%s", strerror(errno)); - return (-1); - } + strncpy(str, *strp + 1, p - (*strp + 1)); + str[p - (*strp + 1)] = '\0'; - } else if (p > s) { - /* host */ - free(sc->chost); - if ((sc->chost = strdup(s)) == NULL) { - seterr(sc, "%s", strerror(errno)); + memset(&hints, 0, sizeof(hints)); + hints.ai_flags = AI_CANONNAME | AI_NUMERICHOST; + hints.ai_family = AF_INET6; + hints.ai_socktype = SOCK_DGRAM; + hints.ai_protocol = IPPROTO_UDP; + error = getaddrinfo(str, NULL, &hints, &res); + if (error != 0) { + seterr(sc, "%s: %s", str, gai_strerror(error)); + return (NULL); + } + freeaddrinfo(res); + *strp = p + 1; + return (p); +} + +/** + * Try to get an IPv4 address. This starts with a digit and consists of digits + * and dots, is not longer INET_ADDRSTRLEN and must be parseable by + * inet_aton(). + * + * \param sc client struct to set errors + * \param strp possible start of IPv4 address; updated to point to the + * next character to parse + * + * \return end of address (equals *strp if there is none) or NULL + * on errors + */ +static inline const char * +get_ipv4(struct snmp_client *sc, const char **strp) +{ + const char *p = *strp; + + while (isascii(*p) && (isdigit(*p) || *p == '.')) + p++; + + if (p - *strp > INET_ADDRSTRLEN) { + seterr(sc, "IPv4 address too long '%.*s'", p - *strp, *strp); + return (NULL); + } + if (*strp == p) + return *strp; + + char str[INET_ADDRSTRLEN + 1]; + strncpy(str, *strp, p - *strp); + str[p - *strp] = '\0'; + + struct in_addr addr; + if (inet_aton(str, &addr) != 1) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-projects@freebsd.org Sat Apr 6 05:34:52 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C77ED156D2EE for ; Sat, 6 Apr 2019 05:34:52 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 64A098EA25; Sat, 6 Apr 2019 05:34:52 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 415532025A; Sat, 6 Apr 2019 05:34:52 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x365YqdX015366; Sat, 6 Apr 2019 05:34:52 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x365YpBc015364; Sat, 6 Apr 2019 05:34:51 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201904060534.x365YpBc015364@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Sat, 6 Apr 2019 05:34:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r345979 - in projects/runtime-coverage-v2: . share/mk X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: in projects/runtime-coverage-v2: . share/mk X-SVN-Commit-Revision: 345979 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 64A098EA25 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.962,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Apr 2019 05:34:53 -0000 Author: ngie Date: Sat Apr 6 05:34:51 2019 New Revision: 345979 URL: https://svnweb.freebsd.org/changeset/base/345979 Log: Build libclang_rt.profile as a cross-tools dependency Long story short, make tinderbox was failing because it was looking for libclang_rt.profile under a different path from there make libraries installs it. Add a new MK knob to control building `lib/libclang_rt/profile` in buildworld: MK_COVERAGE_SUPPORT. MK_COVERAGE_SUPPORT is to `lib/libclang_rt/profile`, as MK_TESTS_SUPPORT is to lib/atf/...: it serves to separate out building infrastructure from the resulting code. This commit is untested, but I'm hopeful that it's a move in the right direction. Modified: projects/runtime-coverage-v2/Makefile.inc1 projects/runtime-coverage-v2/share/mk/src.opts.mk Modified: projects/runtime-coverage-v2/Makefile.inc1 ============================================================================== --- projects/runtime-coverage-v2/Makefile.inc1 Sat Apr 6 03:59:21 2019 (r345978) +++ projects/runtime-coverage-v2/Makefile.inc1 Sat Apr 6 05:34:51 2019 (r345979) @@ -688,7 +688,8 @@ BSARGS= DESTDIR= \ BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \ BWPHASE=${.TARGET:C,^_,,} \ SSP_CFLAGS= \ - MK_COVERAGE=no MK_HTML=no NO_LINT=yes MK_MAN=no \ + MK_COVERAGE=no MK_COVERAGE_SUPPORT=${MK_COVERAGE} \ + MK_HTML=no NO_LINT=yes MK_MAN=no \ -DNO_PIC MK_PROFILE=no -DNO_SHARED \ -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \ MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \ @@ -734,7 +735,8 @@ KTMAKE= \ MAKEOBJDIRPREFIX= \ BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \ SSP_CFLAGS= \ - MK_COVERAGE=no MK_HTML=no -DNO_LINT MK_MAN=no \ + MK_COVERAGE=no MK_COVERAGE_SUPPORT=${MK_COVERAGE} \ + MK_HTML=no -DNO_LINT MK_MAN=no \ -DNO_PIC MK_PROFILE=no -DNO_SHARED \ -DNO_CPU_CFLAGS MK_RETPOLINE=no MK_WARNS=no MK_CTF=no @@ -2463,7 +2465,10 @@ _elftctools= lib/libelftc \ .if ${MK_CLANG_BOOTSTRAP} != "no" _clang= usr.bin/clang +.if ${MK_COVERAGE_SUPPORT} != "no" +_coverage_libs= lib/libclang_rt/profile .endif +.endif .if ${MK_LLD_BOOTSTRAP} != "no" _lld= usr.bin/clang/lld .endif @@ -2487,6 +2492,7 @@ cross-tools: .MAKE .PHONY ${_ar} \ ${_clang_libs} \ ${_clang} \ + ${_coverage_libs} \ ${_lld} \ ${_binutils} \ ${_elftctools} \ @@ -2720,7 +2726,7 @@ _prereq_libs+= gnu/lib/libssp/libssp_nonshared # The coverage libraries must be built for the target prior to ${_startup_libs} # for world to have runtime coverage instrumentation. # -.if ${MK_COVERAGE} != "no" +.if ${MK_COVERAGE_SUPPORT} != "no" _prereq_libs+= lib/libclang_rt/profile .endif @@ -3339,6 +3345,7 @@ XDEVDIRS= \ ${_elftctools} \ usr.bin/ar \ ${_clang} \ + ${_coverage_libs} \ ${_gcc} _xb-cross-tools: .PHONY Modified: projects/runtime-coverage-v2/share/mk/src.opts.mk ============================================================================== --- projects/runtime-coverage-v2/share/mk/src.opts.mk Sat Apr 6 03:59:21 2019 (r345978) +++ projects/runtime-coverage-v2/share/mk/src.opts.mk Sat Apr 6 05:34:51 2019 (r345979) @@ -230,6 +230,7 @@ __DEFAULT_DEPENDENT_OPTIONS= \ .for var in \ BLACKLIST \ BZIP2 \ + COVERAGE \ INET \ INET6 \ KERBEROS \