From owner-svn-src-projects@freebsd.org Thu Jun 7 02:32:01 2018 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 D6D17FEF814 for ; Thu, 7 Jun 2018 02:32:00 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 66E2978456; Thu, 7 Jun 2018 02:30:49 +0000 (UTC) (envelope-from rmacklem@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 49A5519F5F; Thu, 7 Jun 2018 02:30:49 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w572Un2u003958; Thu, 7 Jun 2018 02:30:49 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w572UngO003957; Thu, 7 Jun 2018 02:30:49 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201806070230.w572UngO003957@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Thu, 7 Jun 2018 02:30:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r334751 - in projects/pnfs-planb-server: sys/fs/nfs usr.sbin/nfsd X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: in projects/pnfs-planb-server: sys/fs/nfs usr.sbin/nfsd X-SVN-Commit-Revision: 334751 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.26 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, 07 Jun 2018 02:32:01 -0000 Author: rmacklem Date: Thu Jun 7 02:30:48 2018 New Revision: 334751 URL: https://svnweb.freebsd.org/changeset/base/334751 Log: Fix some things found during a "make universe". A couple of signed vs unsigned comparisons and declaring "optarg" local to a function were minor ones. The main one was the alignment for sockaddr_in is stricter than sockaddr for MIPS. To deal with this, I copied the sockaddr into a sockaddr_in. (I actually suspect that getaddrinfo() returns a well aligned ptr, but...) Modified: projects/pnfs-planb-server/sys/fs/nfs/nfsproto.h projects/pnfs-planb-server/usr.sbin/nfsd/nfsd.c Modified: projects/pnfs-planb-server/sys/fs/nfs/nfsproto.h ============================================================================== --- projects/pnfs-planb-server/sys/fs/nfs/nfsproto.h Thu Jun 7 02:20:27 2018 (r334750) +++ projects/pnfs-planb-server/sys/fs/nfs/nfsproto.h Thu Jun 7 02:30:48 2018 (r334751) @@ -278,6 +278,7 @@ /* variants for multiple versions */ #define NFSX_STATFS(v3) ((v3) ? NFSX_V3STATFS : NFSX_V2STATFS) +#if defined(_KERNEL) || defined(KERNEL) /* nfs rpc procedure numbers (before version mapping) */ #define NFSPROC_NULL 0 #define NFSPROC_GETATTR 1 @@ -359,6 +360,7 @@ #define NFSV41_NPROCS 56 #endif /* NFS_V3NPROCS */ +#endif /* _KERNEL */ /* * Define NFS_NPROCS as NFSV4_NPROCS for the experimental kernel code. Modified: projects/pnfs-planb-server/usr.sbin/nfsd/nfsd.c ============================================================================== --- projects/pnfs-planb-server/usr.sbin/nfsd/nfsd.c Thu Jun 7 02:20:27 2018 (r334750) +++ projects/pnfs-planb-server/usr.sbin/nfsd/nfsd.c Thu Jun 7 02:30:48 2018 (r334751) @@ -1175,15 +1175,16 @@ backup_stable(__unused int signo) * Parse the pNFS string and extract the DS servers and ports numbers. */ static void -parse_dsserver(const char *optarg, struct nfsd_nfsd_args *nfsdargp) +parse_dsserver(const char *optionarg, struct nfsd_nfsd_args *nfsdargp) { char *ad, *cp, *cp2, *dsaddr, *dshost, *dspath, *dsvol, nfsprt[9]; - int adsiz, dsaddrcnt, dshostcnt, dspathcnt, ecode, hostsiz, pathsiz; + int ecode; + u_int adsiz, dsaddrcnt, dshostcnt, dspathcnt, hostsiz, pathsiz; size_t dsaddrsiz, dshostsiz, dspathsiz, nfsprtsiz; struct addrinfo hints, *ai_tcp; - struct sockaddr_in *sin; + struct sockaddr_in sin; - cp = strdup(optarg); + cp = strdup(optionarg); if (cp == NULL) errx(1, "Out of memory"); @@ -1248,12 +1249,14 @@ parse_dsserver(const char *optarg, struct nfsd_nfsd_ar if (ecode != 0) err(1, "getaddrinfo pnfs: %s %s", cp, gai_strerror(ecode)); - sin = (struct sockaddr_in *)ai_tcp->ai_addr; - if (sin->sin_family != AF_INET) + if (ai_tcp->ai_addr->sa_family != AF_INET || + ai_tcp->ai_addr->sa_len < sizeof(sin)) err(1, "getaddrinfo() returned non-INET address"); + /* Mips cares about sockaddr_in alignment, so copy the addr. */ + memcpy(&sin, ai_tcp->ai_addr, sizeof(sin)); /* Append this address to dsaddr. */ - ad = inet_ntoa(sin->sin_addr); + ad = inet_ntoa(sin.sin_addr); adsiz = strlen(ad); if (dsaddrcnt + adsiz + nfsprtsiz + 1 > dsaddrsiz) { dsaddrsiz *= 2; @@ -1279,12 +1282,6 @@ parse_dsserver(const char *optarg, struct nfsd_nfsd_ar cp = cp2; } while (cp != NULL); - /* - * At the point, ai_tcp refers to the last DS server host and - * sin is set to point to the sockaddr structure in it. - * Set the port# for the DS Mount protocol and get the DS root FH. - */ - sin->sin_port = htons(2049); nfsdargp->addr = dsaddr; nfsdargp->addrlen = dsaddrcnt; nfsdargp->dnshost = dshost; @@ -1293,5 +1290,4 @@ parse_dsserver(const char *optarg, struct nfsd_nfsd_ar nfsdargp->dspathlen = dspathcnt; freeaddrinfo(ai_tcp); } -