From owner-svn-src-stable-11@freebsd.org Sun Aug 25 00:57:52 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 77DD5D0AD9; Sun, 25 Aug 2019 00:57:52 +0000 (UTC) (envelope-from eugen@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 46GGvh2cLmz4MG5; Sun, 25 Aug 2019 00:57:52 +0000 (UTC) (envelope-from eugen@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 1CE63D9F9; Sun, 25 Aug 2019 00:57:52 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7P0vpx8064376; Sun, 25 Aug 2019 00:57:51 GMT (envelope-from eugen@FreeBSD.org) Received: (from eugen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7P0vpCf064375; Sun, 25 Aug 2019 00:57:51 GMT (envelope-from eugen@FreeBSD.org) Message-Id: <201908250057.x7P0vpCf064375@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eugen set sender to eugen@FreeBSD.org using -f From: Eugene Grosbein Date: Sun, 25 Aug 2019 00:57:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351466 - stable/11/release/picobsd/tinyware/simple_httpd X-SVN-Group: stable-11 X-SVN-Commit-Author: eugen X-SVN-Commit-Paths: stable/11/release/picobsd/tinyware/simple_httpd X-SVN-Commit-Revision: 351466 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Aug 2019 00:57:52 -0000 Author: eugen Date: Sun Aug 25 00:57:51 2019 New Revision: 351466 URL: https://svnweb.freebsd.org/changeset/base/351466 Log: MFC r351179: simple_httpd was not buildable for some time due to multiple missing "static" keywords and -Werror,-Wmissing-variable-declarations This change adds needed "static" so it builds again with WARNS?=6 No functional changes. Modified: stable/11/release/picobsd/tinyware/simple_httpd/simple_httpd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/release/picobsd/tinyware/simple_httpd/simple_httpd.c ============================================================================== --- stable/11/release/picobsd/tinyware/simple_httpd/simple_httpd.c Sun Aug 25 00:55:41 2019 (r351465) +++ stable/11/release/picobsd/tinyware/simple_httpd/simple_httpd.c Sun Aug 25 00:57:51 2019 (r351466) @@ -48,33 +48,33 @@ #include #include -int http_port = 80; -int daemonize = 1; -int verbose = 0; -int http_sock, con_sock; +static int http_port = 80; +static int daemonize = 1; +static int verbose = 0; +static int http_sock, con_sock; -const char *fetch_mode = NULL; -char homedir[100]; -char logfile[80]; -char *adate(void); -void init_servconnection(void); -void http_date(void); -void http_output(const char *html); -void http_request(void); -void log_line(char *req); -void wait_connection(void); +static const char *fetch_mode = NULL; +static char homedir[100]; +static char logfile[80]; +static char *adate(void); +static void init_servconnection(void); +static void http_date(void); +static void http_output(const char *html); +static void http_request(void); +static void log_line(char *req); +static void wait_connection(void); -struct hostent *hst; -struct sockaddr_in source; +static struct hostent *hst; +static struct sockaddr_in source; /* HTTP basics */ static char httpd_server_ident[] = "Server: FreeBSD/PicoBSD simple_httpd 1.1\r"; static char http_200[] = "HTTP/1.0 200 OK\r"; -const char *default_mime_type = "application/octet-stream"; +static const char *default_mime_type = "application/octet-stream"; -const char *mime_type[][2] = { +static const char *mime_type[][2] = { { "txt", "text/plain" }, { "htm", "text/html" }, { "html", "text/html" }, @@ -83,7 +83,7 @@ const char *mime_type[][2] = { { "mp3", "audio/mpeg" } }; -const int mime_type_max = sizeof(mime_type) / sizeof(mime_type[0]) - 1; +static const int mime_type_max = sizeof(mime_type) / sizeof(mime_type[0]) - 1; /* Two parts, HTTP Header and then HTML */ static const char *http_404[2] = @@ -101,7 +101,7 @@ This server only supports GET and HEAD requests.\n Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E3FC7D0EA9; Sun, 25 Aug 2019 01:09:31 +0000 (UTC) (envelope-from cy@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 46GH975lL3z4Mvj; Sun, 25 Aug 2019 01:09:31 +0000 (UTC) (envelope-from cy@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 A836BDBE0; Sun, 25 Aug 2019 01:09:31 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7P19VKZ070514; Sun, 25 Aug 2019 01:09:31 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7P19VgS070513; Sun, 25 Aug 2019 01:09:31 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908250109.x7P19VgS070513@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sun, 25 Aug 2019 01:09:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351468 - in stable: 10/sys/contrib/ipfilter/netinet 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-11 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 10/sys/contrib/ipfilter/netinet 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Commit-Revision: 351468 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Aug 2019 01:09:32 -0000 Author: cy Date: Sun Aug 25 01:09:31 2019 New Revision: 351468 URL: https://svnweb.freebsd.org/changeset/base/351468 Log: MFC r351380: Specifying array sizes for fully initialized tables at compile time is redundant. Modified: stable/11/sys/contrib/ipfilter/netinet/fil.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/10/sys/contrib/ipfilter/netinet/fil.c stable/12/sys/contrib/ipfilter/netinet/fil.c Directory Properties: stable/10/ (props changed) stable/12/ (props changed) Modified: stable/11/sys/contrib/ipfilter/netinet/fil.c ============================================================================== --- stable/11/sys/contrib/ipfilter/netinet/fil.c Sun Aug 25 01:05:01 2019 (r351467) +++ stable/11/sys/contrib/ipfilter/netinet/fil.c Sun Aug 25 01:09:31 2019 (r351468) @@ -194,7 +194,7 @@ static int ppsratecheck(struct timeval *, int *, int) * hand side to allow for binary searching of the array and include a trailer * with a 0 for the bitmask for linear searches to easily find the end with. */ -static const struct optlist ipopts[20] = { +static const struct optlist ipopts[] = { { IPOPT_NOP, 0x000001 }, { IPOPT_RR, 0x000002 }, { IPOPT_ZSU, 0x000004 }, @@ -235,7 +235,7 @@ static const struct optlist ip6exthdr[] = { /* * bit values for identifying presence of individual IP security options */ -static const struct optlist secopt[8] = { +static const struct optlist secopt[] = { { IPSO_CLASS_RES4, 0x01 }, { IPSO_CLASS_TOPS, 0x02 }, { IPSO_CLASS_SECR, 0x04 }, From owner-svn-src-stable-11@freebsd.org Sun Aug 25 04:56:34 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A41F1D5219; Sun, 25 Aug 2019 04:56:34 +0000 (UTC) (envelope-from cy@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 46GNC63qLkz4X5Y; Sun, 25 Aug 2019 04:56:34 +0000 (UTC) (envelope-from cy@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 79DDA1862A; Sun, 25 Aug 2019 04:56:34 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7P4uYpT006479; Sun, 25 Aug 2019 04:56:34 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7P4uY6s006477; Sun, 25 Aug 2019 04:56:34 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908250456.x7P4uY6s006477@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sun, 25 Aug 2019 04:56:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351470 - in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-11 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Commit-Revision: 351470 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Aug 2019 04:56:34 -0000 Author: cy Date: Sun Aug 25 04:56:33 2019 New Revision: 351470 URL: https://svnweb.freebsd.org/changeset/base/351470 Log: MFC r350880: r272552 applied the patch from ipfilter upstream fil.c r1.129 to fix broken ipfilter rule matches (upstream bug #554). The upstream patch was incomplete, it resolved all but one rule compare issue. The issue fixed here is when "{to, reply-to, dup-to} interface" are used in conjuncion with "on interface". The match was only made if the on keyword was specified in the same order in each case referencing the same rule. This commit fixes this. The reason for this is that interface name strings and comment keyword comments are stored in a a variable length field starting at fr_names in the frentry struct. These strings are placed into this variable length in the order they are encountered by ipf_y.y and indexed through index pointers in fr_ifnames, fr_comment or one of the frdest struct fd_name fields. (Three frdest structs are within frentry.) Order matters and this patch takes this into account. While in here it was discovered that though ipfilter is designed to pport multiple interface specifiations per rule (up to four), this undocumented (the man page makes no mention of it) feature does not work. A todo is to fix the multiple interfaces feature at a later date. To understand the design decision as to why only four were intended, it is suspected that the decision was made because Sun workstations and PCs rarely if ever exceeded four NICs at the time, this is not true in 2019. PR: 238796 Reported by: WHR Modified: stable/11/sys/contrib/ipfilter/netinet/fil.c stable/11/sys/contrib/ipfilter/netinet/ip_fil.h Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/sys/contrib/ipfilter/netinet/fil.c stable/12/sys/contrib/ipfilter/netinet/ip_fil.h Directory Properties: stable/12/ (props changed) Modified: stable/11/sys/contrib/ipfilter/netinet/fil.c ============================================================================== --- stable/11/sys/contrib/ipfilter/netinet/fil.c Sun Aug 25 02:38:45 2019 (r351469) +++ stable/11/sys/contrib/ipfilter/netinet/fil.c Sun Aug 25 04:56:33 2019 (r351470) @@ -4418,6 +4418,28 @@ ipf_matchicmpqueryreply(v, ic, icmp, rev) } +/* + * IFNAMES are located in the variable length field starting at + * frentry.fr_names. As pointers within the struct cannot be passed + * to the kernel from ipf(8), an offset is used. An offset of -1 means it + * is unused (invalid). If it is used (valid) it is an offset to the + * character string of an interface name or a comment. The following + * macros will assist those who follow to understand the code. + */ +#define IPF_IFNAME_VALID(_a) (_a != -1) +#define IPF_IFNAME_INVALID(_a) (_a == -1) +#define IPF_IFNAMES_DIFFERENT(_a) \ + !((IPF_IFNAME_INVALID(fr1->_a) && \ + IPF_IFNAME_INVALID(fr2->_a)) || \ + (IPF_IFNAME_VALID(fr1->_a) && \ + IPF_IFNAME_VALID(fr2->_a) && \ + !strcmp(FR_NAME(fr1, _a), FR_NAME(fr2, _a)))) +#define IPF_FRDEST_DIFFERENT(_a) \ + (memcmp(&fr1->_a.fd_addr, &fr2->_a.fd_addr, \ + offsetof(frdest_t, fd_name) - offsetof(frdest_t, fd_addr)) || \ + IPF_IFNAMES_DIFFERENT(_a.fd_name)) + + /* ------------------------------------------------------------------------ */ /* Function: ipf_rule_compare */ /* Parameters: fr1(I) - first rule structure to compare */ @@ -4430,22 +4452,50 @@ ipf_matchicmpqueryreply(v, ic, icmp, rev) static int ipf_rule_compare(frentry_t *fr1, frentry_t *fr2) { + int i; + if (fr1->fr_cksum != fr2->fr_cksum) return (1); if (fr1->fr_size != fr2->fr_size) return (2); if (fr1->fr_dsize != fr2->fr_dsize) return (3); - if (bcmp((char *)&fr1->fr_func, (char *)&fr2->fr_func, FR_CMPSIZ(fr1)) + if (bcmp((char *)&fr1->fr_func, (char *)&fr2->fr_func, FR_CMPSIZ) != 0) return (4); + /* + * XXX: There is still a bug here as different rules with the + * the same interfaces but in a different order will compare + * differently. But since multiple interfaces in a rule doesn't + * work anyway a simple straightforward compare is performed + * here. Ultimately frentry_t creation will need to be + * revisited in ipf_y.y. While the other issue, recognition + * of only the first interface in a list of interfaces will + * need to be separately addressed along with why only four. + */ + for (i = 0; i < FR_NUM(fr1->fr_ifnames); i++) { + /* + * XXX: It's either the same index or uninitialized. + * We assume this because multiple interfaces + * referenced by the same rule doesn't work anyway. + */ + if (IPF_IFNAMES_DIFFERENT(fr_ifnames[i])) + return(5); + } + + if (IPF_FRDEST_DIFFERENT(fr_tif)) + return (6); + if (IPF_FRDEST_DIFFERENT(fr_rif)) + return (7); + if (IPF_FRDEST_DIFFERENT(fr_dif)) + return (8); if (!fr1->fr_data && !fr2->fr_data) return (0); /* move along, nothing to see here */ if (fr1->fr_data && fr2->fr_data) { if (bcmp(fr1->fr_caddr, fr2->fr_caddr, fr1->fr_dsize) == 0) return (0); /* same */ } - return (5); + return (9); } Modified: stable/11/sys/contrib/ipfilter/netinet/ip_fil.h ============================================================================== --- stable/11/sys/contrib/ipfilter/netinet/ip_fil.h Sun Aug 25 02:38:45 2019 (r351469) +++ stable/11/sys/contrib/ipfilter/netinet/ip_fil.h Sun Aug 25 04:56:33 2019 (r351470) @@ -735,12 +735,9 @@ typedef struct frentry { u_char fr_icode; /* return ICMP code */ int fr_group; /* group to which this rule belongs */ int fr_grhead; /* group # which this rule starts */ - int fr_ifnames[4]; int fr_isctag; int fr_rpc; /* XID Filtering */ ipftag_t fr_nattag; - frdest_t fr_tifs[2]; /* "to"/"reply-to" interface */ - frdest_t fr_dif; /* duplicate packet interface */ /* * These are all options related to stateful filtering */ @@ -750,6 +747,12 @@ typedef struct frentry { int fr_icmphead; /* ICMP group for state options */ u_int fr_age[2]; /* non-TCP state timeouts */ /* + * These are compared separately. + */ + int fr_ifnames[4]; + frdest_t fr_tifs[2]; /* "to"/"reply-to" interface */ + frdest_t fr_dif; /* duplicate packet interface */ + /* * How big is the name buffer at the end? */ int fr_namelen; @@ -827,9 +830,10 @@ typedef struct frentry { #define FR_NOLOGTAG 0 -#define FR_CMPSIZ(_f) ((_f)->fr_size - \ - offsetof(struct frentry, fr_func)) +#define FR_CMPSIZ (offsetof(struct frentry, fr_ifnames) - \ + offsetof(struct frentry, fr_func)) #define FR_NAME(_f, _n) (_f)->fr_names + (_f)->_n +#define FR_NUM(_a) (sizeof(_a) / sizeof(*_a)) /* From owner-svn-src-stable-11@freebsd.org Sun Aug 25 13:36:21 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B7E7EE012D; Sun, 25 Aug 2019 13:36:21 +0000 (UTC) (envelope-from cy@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 46Gbks4VpYz3yGF; Sun, 25 Aug 2019 13:36:21 +0000 (UTC) (envelope-from cy@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 62FF21E48D; Sun, 25 Aug 2019 13:36:21 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7PDaLq7013872; Sun, 25 Aug 2019 13:36:21 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7PDaKjM013870; Sun, 25 Aug 2019 13:36:20 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908251336.x7PDaKjM013870@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sun, 25 Aug 2019 13:36:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351479 - in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-11 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Commit-Revision: 351479 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Aug 2019 13:36:21 -0000 Author: cy Date: Sun Aug 25 13:36:20 2019 New Revision: 351479 URL: https://svnweb.freebsd.org/changeset/base/351479 Log: MFC r350881: Calculate the number interface array elements using the new FR_NUM macro instead of the hard-coded value of 4. This is a precursor to increasing the number of interfaces speficied in "on {interface, ..., interface}". Note that though this feature is coded in ipf_y.y, it is partially supported in the ipfilter kld, meaning it does not work yet (and is yet to be documented in ipf.5 too). Modified: stable/11/sys/contrib/ipfilter/netinet/fil.c stable/11/sys/contrib/ipfilter/netinet/ip_state.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/sys/contrib/ipfilter/netinet/fil.c stable/12/sys/contrib/ipfilter/netinet/ip_state.c Directory Properties: stable/12/ (props changed) Modified: stable/11/sys/contrib/ipfilter/netinet/fil.c ============================================================================== --- stable/11/sys/contrib/ipfilter/netinet/fil.c Sun Aug 25 13:26:06 2019 (r351478) +++ stable/11/sys/contrib/ipfilter/netinet/fil.c Sun Aug 25 13:36:20 2019 (r351479) @@ -4023,7 +4023,7 @@ ipf_synclist(softc, fr, ifp) /* * Lookup all the interface names that are part of the rule. */ - for (i = 0; i < 4; i++) { + for (i = 0; i < FR_NUM(fr->fr_ifas); i++) { if ((ifp != NULL) && (fr->fr_ifas[i] != ifp)) continue; if (fr->fr_ifnames[i] == -1) Modified: stable/11/sys/contrib/ipfilter/netinet/ip_state.c ============================================================================== --- stable/11/sys/contrib/ipfilter/netinet/ip_state.c Sun Aug 25 13:26:06 2019 (r351478) +++ stable/11/sys/contrib/ipfilter/netinet/ip_state.c Sun Aug 25 13:36:20 2019 (r351479) @@ -975,7 +975,7 @@ ipf_state_putent(softc, softs, data) /* * Look up all the interface names in the rule. */ - for (i = 0; i < 4; i++) { + for (i = 0; i < FR_NUM(fr->fr_ifnames); i++) { if (fr->fr_ifnames[i] == -1) { fr->fr_ifas[i] = NULL; continue; @@ -985,7 +985,7 @@ ipf_state_putent(softc, softs, data) fr->fr_family); } - for (i = 0; i < 4; i++) { + for (i = 0; i < FR_NUM(isn->is_ifname); i++) { name = isn->is_ifname[i]; isn->is_ifp[i] = ipf_resolvenic(softc, name, isn->is_v); @@ -1076,7 +1076,7 @@ ipf_state_insert(softc, is, rev) /* * Look up all the interface names in the state entry. */ - for (i = 0; i < 4; i++) { + for (i = 0; i < FR_NUM(is->is_ifp); i++) { if (is->is_ifp[i] != NULL) continue; is->is_ifp[i] = ipf_resolvenic(softc, is->is_ifname[i], @@ -3574,7 +3574,7 @@ ipf_state_sync(softc, ifp) /* * Look up all the interface names in the state entry. */ - for (i = 0; i < 4; i++) { + for (i = 0; i < FR_NUM(is->is_ifp); i++) { if (ifp == NULL || ifp == is->is_ifp[i]) is->is_ifp[i] = ipf_resolvenic(softc, is->is_ifname[i], From owner-svn-src-stable-11@freebsd.org Mon Aug 26 08:07:47 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B4D18D40CC; Mon, 26 Aug 2019 08:07:47 +0000 (UTC) (envelope-from kib@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 46H4PH4N5Jz44ND; Mon, 26 Aug 2019 08:07:47 +0000 (UTC) (envelope-from kib@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 7824E2EE4; Mon, 26 Aug 2019 08:07:47 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7Q87lJH083745; Mon, 26 Aug 2019 08:07:47 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7Q87lVP083744; Mon, 26 Aug 2019 08:07:47 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201908260807.x7Q87lVP083744@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 26 Aug 2019 08:07:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351505 - stable/11/tests/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/tests/sys/kern X-SVN-Commit-Revision: 351505 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Aug 2019 08:07:47 -0000 Author: kib Date: Mon Aug 26 08:07:47 2019 New Revision: 351505 URL: https://svnweb.freebsd.org/changeset/base/351505 Log: MFC r351210: sys.kern.pdeathsig.signal_delivered_ptrace: fix debugger detach PR: 237657 Modified: stable/11/tests/sys/kern/pdeathsig.c Directory Properties: stable/11/ (props changed) Modified: stable/11/tests/sys/kern/pdeathsig.c ============================================================================== --- stable/11/tests/sys/kern/pdeathsig.c Mon Aug 26 08:07:10 2019 (r351504) +++ stable/11/tests/sys/kern/pdeathsig.c Mon Aug 26 08:07:47 2019 (r351505) @@ -305,7 +305,9 @@ ATF_TC_BODY(signal_delivered_ptrace, tc) WSTOPSIG(status)); assert(rc == 0); - ptrace(PT_DETACH, c_pid, 0, 0); + waitpid(c_pid, &status, 0); + if (!WIFEXITED(status)) + ptrace(PT_DETACH, c_pid, 0, 0); _exit(0); } From owner-svn-src-stable-11@freebsd.org Mon Aug 26 08:08:16 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 479CDD412A; Mon, 26 Aug 2019 08:08:16 +0000 (UTC) (envelope-from kib@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 46H4Pr1CFlz44V9; Mon, 26 Aug 2019 08:08:16 +0000 (UTC) (envelope-from kib@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 0B2D22EE6; Mon, 26 Aug 2019 08:08:16 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7Q88FeJ083841; Mon, 26 Aug 2019 08:08:15 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7Q88F3B083840; Mon, 26 Aug 2019 08:08:15 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201908260808.x7Q88F3B083840@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 26 Aug 2019 08:08:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351506 - stable/11/tests/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/tests/sys/kern X-SVN-Commit-Revision: 351506 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Aug 2019 08:08:16 -0000 Author: kib Date: Mon Aug 26 08:08:15 2019 New Revision: 351506 URL: https://svnweb.freebsd.org/changeset/base/351506 Log: MFC r351211: sys.kern.pdeathsig.signal_delivered_ptrace: fix startup. PR: 237657 Modified: stable/11/tests/sys/kern/pdeathsig.c Directory Properties: stable/11/ (props changed) Modified: stable/11/tests/sys/kern/pdeathsig.c ============================================================================== --- stable/11/tests/sys/kern/pdeathsig.c Mon Aug 26 08:07:47 2019 (r351505) +++ stable/11/tests/sys/kern/pdeathsig.c Mon Aug 26 08:08:15 2019 (r351506) @@ -229,6 +229,7 @@ ATF_TC_BODY(signal_delivered_ptrace, tc) int rc; int pipe_ca[2]; int pipe_db[2]; + int pipe_cd[2]; char buffer; int status; @@ -236,6 +237,8 @@ ATF_TC_BODY(signal_delivered_ptrace, tc) ATF_REQUIRE(rc == 0); rc = pipe(pipe_db); ATF_REQUIRE(rc == 0); + rc = pipe(pipe_cd); + assert(rc == 0); rc = fork(); ATF_REQUIRE(rc != -1); @@ -263,6 +266,9 @@ ATF_TC_BODY(signal_delivered_ptrace, tc) rc = procctl(P_PID, 0, PROC_PDEATHSIG_CTL, &signum); assert(rc == 0); + rc = write(pipe_cd[1], "x", 1); + assert(rc == 1); + /* wait for B to die and signal us... */ signum = 0xdeadbeef; rc = sigwait(&sigset, &signum); @@ -292,6 +298,9 @@ ATF_TC_BODY(signal_delivered_ptrace, tc) rc = ptrace(PT_CONTINUE, c_pid, (caddr_t) 1, 0); assert(rc == 0); + + rc = read(pipe_cd[0], &buffer, 1); + assert(rc == 1); /* tell B that we're ready for it to exit now */ rc = write(pipe_db[1], ".", 1); From owner-svn-src-stable-11@freebsd.org Mon Aug 26 17:34:08 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CD1D5E1331; Mon, 26 Aug 2019 17:34:08 +0000 (UTC) (envelope-from kevans@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 46HJym5116z3DPT; Mon, 26 Aug 2019 17:34:08 +0000 (UTC) (envelope-from kevans@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 8D9659941; Mon, 26 Aug 2019 17:34:08 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7QHY89K027002; Mon, 26 Aug 2019 17:34:08 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7QHY8Xv027000; Mon, 26 Aug 2019 17:34:08 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201908261734.x7QHY8Xv027000@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 26 Aug 2019 17:34:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351515 - in stable: 11/stand 11/stand/i386/boot2 11/stand/libsa 12/stand 12/stand/i386/boot2 12/stand/libsa X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/stand 11/stand/i386/boot2 11/stand/libsa 12/stand 12/stand/i386/boot2 12/stand/libsa X-SVN-Commit-Revision: 351515 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Aug 2019 17:34:08 -0000 Author: kevans Date: Mon Aug 26 17:34:07 2019 New Revision: 351515 URL: https://svnweb.freebsd.org/changeset/base/351515 Log: MFC r351119, r351135-r351136, r351412: stand xtoolchain-llvm90 fixes r351119: stand: push LIBC_SRC up into defs.mk Other parts of stand/ that don't use libsa will need to grab bits from libc shortly. Push LIBC_SRC up to defs.mk in advance of this so that they can use it, and rename it to LIBCSRC to match the convention of the rest of the *SRC variables in this file. r351135: stand: boot2: fix build with xtoolchain-llvm90 ufsread.c grows a dependency on __ashldi3 with llvm90. Grab ashldi3.c out of compiler-rt rather than trying to link against libsa (for now). -Wno-missing-prototypes is necessary to compile ashldi3.c standalone. r351136: stand: gptboot: fix build with xtoolchain-llvm90 ufsread.c grows a dependency on __ashldi3 with llvm90. For gptboot, just start pulling in ashldi3.c ashrdi3.c lshrdi3.c into libsa for all archs as the number of archs requiring one or more of them keeps growing. qdivrem.c and quad.h can be trivially kicked out of libsa if we start pulling these from compiler-rt as qdivrem was only used to implement umoddi3, divdi3, moddi3 (also in qdivrem.c). r351412: stand: boot2: fix amd64-xtoolchain-gcc build -Wno-missing-declarations is the GCC equivalent of -Wno-missing-prototypes... this was overlooked in r351135. Deleted: stable/11/stand/libsa/qdivrem.c stable/11/stand/libsa/quad.h Modified: stable/11/stand/defs.mk stable/11/stand/i386/boot2/Makefile stable/11/stand/libsa/Makefile Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Deleted: stable/12/stand/libsa/qdivrem.c stable/12/stand/libsa/quad.h Modified: stable/12/stand/defs.mk stable/12/stand/i386/boot2/Makefile stable/12/stand/libsa/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/11/stand/defs.mk ============================================================================== --- stable/11/stand/defs.mk Mon Aug 26 17:27:36 2019 (r351514) +++ stable/11/stand/defs.mk Mon Aug 26 17:34:07 2019 (r351515) @@ -33,6 +33,7 @@ SASRC= ${BOOTSRC}/libsa SYSDIR= ${SRCTOP}/sys UBOOTSRC= ${BOOTSRC}/uboot ZFSSRC= ${SASRC}/zfs +LIBCSRC= ${SRCTOP}/lib/libc BOOTOBJ= ${OBJTOP}/stand Modified: stable/11/stand/i386/boot2/Makefile ============================================================================== --- stable/11/stand/i386/boot2/Makefile Mon Aug 26 17:27:36 2019 (r351514) +++ stable/11/stand/i386/boot2/Makefile Mon Aug 26 17:34:07 2019 (r351515) @@ -78,7 +78,12 @@ boot2.ldr: boot2.bin: boot2.out ${OBJCOPY} -S -O binary boot2.out ${.TARGET} -boot2.out: ${BTXCRT} boot2.o sio.o +# For __ashldi3 +.PATH: ${SRCTOP}/contrib/compiler-rt/lib/builtins +CFLAGS.ashldi3.c= -Wno-missing-prototypes -Wno-missing-declarations +CLEANFILES+= ashldi3.o + +boot2.out: ${BTXCRT} boot2.o sio.o ashldi3.o ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} SRCS= boot2.c boot2.h Modified: stable/11/stand/libsa/Makefile ============================================================================== --- stable/11/stand/libsa/Makefile Mon Aug 26 17:27:36 2019 (r351514) +++ stable/11/stand/libsa/Makefile Mon Aug 26 17:34:07 2019 (r351515) @@ -9,7 +9,6 @@ .include LIBSA_CPUARCH?=${MACHINE_CPUARCH} -LIBC_SRC= ${SRCTOP}/lib/libc LIB?= sa @@ -21,20 +20,20 @@ SRCS+= gzguts.h zutil.h __main.c abort.c assert.c bcd. # private (pruned) versions of libc string functions SRCS+= strcasecmp.c -.PATH: ${LIBC_SRC}/net +.PATH: ${LIBCSRC}/net SRCS+= ntoh.c # string functions from libc -.PATH: ${LIBC_SRC}/string +.PATH: ${LIBCSRC}/string SRCS+= bcmp.c bcopy.c bzero.c ffs.c fls.c \ memccpy.c memchr.c memcmp.c memcpy.c memmove.c memset.c \ - qdivrem.c strcat.c strchr.c strcmp.c strcpy.c stpcpy.c stpncpy.c \ + strcat.c strchr.c strcmp.c strcpy.c stpcpy.c stpncpy.c \ strcspn.c strlcat.c strlcpy.c strlen.c strncat.c strncmp.c strncpy.c \ strnlen.c strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c # stdlib functions from libc -.PATH: ${LIBC_SRC}/stdlib +.PATH: ${LIBCSRC}/stdlib SRCS+= abs.c strtol.c strtoll.c strtoul.c strtoull.c # common boot code @@ -42,7 +41,7 @@ SRCS+= abs.c strtol.c strtoll.c strtoul.c strtoull.c SRCS+= subr_boot.c .if ${MACHINE_CPUARCH} == "arm" -.PATH: ${LIBC_SRC}/arm/gen +.PATH: ${LIBCSRC}/arm/gen # Do not generate movt/movw, because the relocation fixup for them does not # translate to the -Bsymbolic -pie format required by self_reloc() in loader(8). @@ -54,36 +53,30 @@ CFLAGS.clang+= -mno-movt .endif CFLAGS.clang+= -mfpu=none -# Compiler support functions -.PATH: ${SRCTOP}/contrib/compiler-rt/lib/builtins/ -# __clzsi2 and ctzsi2 for various builtin functions -SRCS+= clzsi2.c ctzsi2.c -# Divide and modulus functions called by the compiler -SRCS+= divmoddi4.c divmodsi4.c divdi3.c divsi3.c moddi3.c modsi3.c -SRCS+= udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c - .PATH: ${SRCTOP}/contrib/compiler-rt/lib/builtins/arm/ SRCS+= aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S SRCS+= aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S .endif .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv" -.PATH: ${LIBC_SRC}/${MACHINE_CPUARCH}/gen +.PATH: ${LIBCSRC}/${MACHINE_CPUARCH}/gen .endif -.if ${MACHINE_CPUARCH} == "powerpc" -.PATH: ${LIBC_SRC}/quad +# Compiler support functions +.PATH: ${SRCTOP}/contrib/compiler-rt/lib/builtins/ +# __clzsi2 and ctzsi2 for various builtin functions +SRCS+= clzsi2.c ctzsi2.c +# Divide and modulus functions called by the compiler +SRCS+= divmoddi4.c divmodsi4.c divdi3.c divsi3.c moddi3.c modsi3.c +SRCS+= udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c SRCS+= ashldi3.c ashrdi3.c lshrdi3.c + +.if ${MACHINE_CPUARCH} == "powerpc" SRCS+= syncicache.c .endif -.if ${MACHINE_CPUARCH} == "mips" -.PATH: ${LIBC_SRC}/quad -SRCS+= ashldi3.c ashrdi3.c lshrdi3.c -.endif - # uuid functions from libc -.PATH: ${LIBC_SRC}/uuid +.PATH: ${LIBCSRC}/uuid SRCS+= uuid_create_nil.c uuid_equal.c uuid_from_string.c uuid_is_nil.c uuid_to_string.c # _setjmp/_longjmp From owner-svn-src-stable-11@freebsd.org Tue Aug 27 00:29:31 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2CC68C1682; Tue, 27 Aug 2019 00:29:31 +0000 (UTC) (envelope-from jhb@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 46HVB30P1mz45Sm; Tue, 27 Aug 2019 00:29:31 +0000 (UTC) (envelope-from jhb@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 E38D0E6A6; Tue, 27 Aug 2019 00:29:30 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7R0TUCT068039; Tue, 27 Aug 2019 00:29:30 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7R0TURs068038; Tue, 27 Aug 2019 00:29:30 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201908270029.x7R0TURs068038@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Tue, 27 Aug 2019 00:29:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351523 - in stable: 11/sys/netinet 12/sys/netinet X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 11/sys/netinet 12/sys/netinet X-SVN-Commit-Revision: 351523 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 00:29:31 -0000 Author: jhb Date: Tue Aug 27 00:29:30 2019 New Revision: 351523 URL: https://svnweb.freebsd.org/changeset/base/351523 Log: MFC 349474: Reject attempts to register a TCP stack being unloaded. Modified: stable/11/sys/netinet/tcp_subr.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/sys/netinet/tcp_subr.c Directory Properties: stable/12/ (props changed) Modified: stable/11/sys/netinet/tcp_subr.c ============================================================================== --- stable/11/sys/netinet/tcp_subr.c Tue Aug 27 00:01:56 2019 (r351522) +++ stable/11/sys/netinet/tcp_subr.c Tue Aug 27 00:29:30 2019 (r351523) @@ -530,6 +530,9 @@ register_tcp_functions(struct tcp_function_block *blk, return (EINVAL); } } + if (blk->tfb_flags & TCP_FUNC_BEING_REMOVED) { + return (EINVAL); + } n = malloc(sizeof(struct tcp_function), M_TCPFUNCTIONS, wait); if (n == NULL) { return (ENOMEM); @@ -545,7 +548,6 @@ register_tcp_functions(struct tcp_function_block *blk, return (EALREADY); } refcount_init(&blk->tfb_refcnt, 0); - blk->tfb_flags = 0; TAILQ_INSERT_TAIL(&t_functions, n, tf_next); rw_wunlock(&tcp_function_lock); return(0); From owner-svn-src-stable-11@freebsd.org Wed Aug 28 20:20:38 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F18B1E55E1; Wed, 28 Aug 2019 20:20:38 +0000 (UTC) (envelope-from mav@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 46JcYy69THz4f03; Wed, 28 Aug 2019 20:20:38 +0000 (UTC) (envelope-from mav@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 B57D5CD5B; Wed, 28 Aug 2019 20:20:38 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7SKKc4A064618; Wed, 28 Aug 2019 20:20:38 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7SKKcE0064616; Wed, 28 Aug 2019 20:20:38 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908282020.x7SKKcE0064616@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 28 Aug 2019 20:20:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351579 - in stable/11: sbin/camcontrol sys/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/11: sbin/camcontrol sys/sys X-SVN-Commit-Revision: 351579 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Aug 2019 20:20:39 -0000 Author: mav Date: Wed Aug 28 20:20:38 2019 New Revision: 351579 URL: https://svnweb.freebsd.org/changeset/base/351579 Log: MFC r350393: Decode some more IDENTIFY DEVICE bits. Modified: stable/11/sbin/camcontrol/camcontrol.c stable/11/sys/sys/ata.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Wed Aug 28 20:05:55 2019 (r351578) +++ stable/11/sbin/camcontrol/camcontrol.c Wed Aug 28 20:20:38 2019 (r351579) @@ -1373,6 +1373,7 @@ atacapprint(struct ata_params *parm) printf("WWN %04x%04x%04x%04x\n", parm->wwn[0], parm->wwn[1], parm->wwn[2], parm->wwn[3]); } + printf("additional product id %.8s\n", parm->product_id); if (parm->enabled.extension & ATA_SUPPORT_MEDIASN) { printf("media serial number %.30s\n", parm->media_serial); @@ -1502,35 +1503,39 @@ atacapprint(struct ata_params *parm) } else printf("\n"); printf("Native Command Queuing (NCQ) "); - if (parm->satacapabilities != 0xffff && - (parm->satacapabilities & ATA_SUPPORT_NCQ)) { + if (atasata(parm) && (parm->satacapabilities & ATA_SUPPORT_NCQ)) { printf("yes %d tags\n", ATA_QUEUE_LEN(parm->queue) + 1); + printf("NCQ Priority Information %s\n", + parm->satacapabilities & ATA_SUPPORT_NCQ_PRIO ? + "yes" : "no"); + printf("NCQ Non-Data Command %s\n", + parm->satacapabilities2 & ATA_SUPPORT_NCQ_NON_DATA ? + "yes" : "no"); + printf("NCQ Streaming %s\n", + parm->satacapabilities2 & ATA_SUPPORT_NCQ_STREAM ? + "yes" : "no"); + printf("Receive & Send FPDMA Queued %s\n", + parm->satacapabilities2 & ATA_SUPPORT_RCVSND_FPDMA_QUEUED ? + "yes" : "no"); + printf("NCQ Autosense %s\n", + parm->satasupport & ATA_SUPPORT_NCQ_AUTOSENSE ? + "yes" : "no"); } else printf("no\n"); - printf("NCQ Queue Management %s\n", atasata(parm) && - parm->satacapabilities2 & ATA_SUPPORT_NCQ_QMANAGEMENT ? - "yes" : "no"); - printf("NCQ Streaming %s\n", atasata(parm) && - parm->satacapabilities2 & ATA_SUPPORT_NCQ_STREAM ? - "yes" : "no"); - printf("Receive & Send FPDMA Queued %s\n", atasata(parm) && - parm->satacapabilities2 & ATA_SUPPORT_RCVSND_FPDMA_QUEUED ? - "yes" : "no"); - printf("SMART %s %s\n", parm->support.command1 & ATA_SUPPORT_SMART ? "yes" : "no", parm->enabled.command1 & ATA_SUPPORT_SMART ? "yes" : "no"); - printf("microcode download %s %s\n", - parm->support.command2 & ATA_SUPPORT_MICROCODE ? "yes" : "no", - parm->enabled.command2 & ATA_SUPPORT_MICROCODE ? "yes" : "no"); printf("security %s %s\n", parm->support.command1 & ATA_SUPPORT_SECURITY ? "yes" : "no", parm->enabled.command1 & ATA_SUPPORT_SECURITY ? "yes" : "no"); printf("power management %s %s\n", parm->support.command1 & ATA_SUPPORT_POWERMGT ? "yes" : "no", parm->enabled.command1 & ATA_SUPPORT_POWERMGT ? "yes" : "no"); + printf("microcode download %s %s\n", + parm->support.command2 & ATA_SUPPORT_MICROCODE ? "yes" : "no", + parm->enabled.command2 & ATA_SUPPORT_MICROCODE ? "yes" : "no"); printf("advanced power management %s %s", parm->support.command2 & ATA_SUPPORT_APM ? "yes" : "no", parm->enabled.command2 & ATA_SUPPORT_APM ? "yes" : "no"); @@ -1573,6 +1578,15 @@ atacapprint(struct ata_params *parm) printf("free-fall %s %s\n", parm->support2 & ATA_SUPPORT_FREEFALL ? "yes" : "no", parm->enabled2 & ATA_SUPPORT_FREEFALL ? "yes" : "no"); + printf("sense data reporting %s %s\n", + parm->support2 & ATA_SUPPORT_SENSE_REPORT ? "yes" : "no", + parm->enabled2 & ATA_SUPPORT_SENSE_REPORT ? "yes" : "no"); + printf("extended power conditions %s %s\n", + parm->support2 & ATA_SUPPORT_EPC ? "yes" : "no", + parm->enabled2 & ATA_SUPPORT_EPC ? "yes" : "no"); + printf("device statistics notification %s %s\n", + parm->support2 & ATA_SUPPORT_DSN ? "yes" : "no", + parm->enabled2 & ATA_SUPPORT_DSN ? "yes" : "no"); printf("Data Set Management (DSM/TRIM) "); if (parm->support_dsm & ATA_SUPPORT_DSM_TRIM) { printf("yes\n"); @@ -1595,6 +1609,8 @@ atacapprint(struct ata_params *parm) } else { printf("no\n"); } + printf("encrypts all user data %s\n", + parm->support3 & ATA_ENCRYPTS_ALL_USER_DATA ? "yes" : "no"); printf("Sanitize "); if (parm->multi & ATA_SUPPORT_SANITIZE) { printf("yes\t\t%s%s%s\n", Modified: stable/11/sys/sys/ata.h ============================================================================== --- stable/11/sys/sys/ata.h Wed Aug 28 20:05:55 2019 (r351578) +++ stable/11/sys/sys/ata.h Wed Aug 28 20:20:38 2019 (r351579) @@ -141,7 +141,8 @@ struct ata_params { /*77*/ u_int16_t satacapabilities2; #define ATA_SATA_CURR_GEN_MASK 0x0006 #define ATA_SUPPORT_NCQ_STREAM 0x0010 -#define ATA_SUPPORT_NCQ_QMANAGEMENT 0x0020 +#define ATA_SUPPORT_NCQ_NON_DATA 0x0020 +#define ATA_SUPPORT_NCQ_QMANAGEMENT ATA_SUPPORT_NCQ_NON_DATA #define ATA_SUPPORT_RCVSND_FPDMA_QUEUED 0x0040 /*78*/ u_int16_t satasupport; #define ATA_SUPPORT_NONZERO 0x0002 @@ -150,6 +151,7 @@ struct ata_params { #define ATA_SUPPORT_INORDERDATA 0x0010 #define ATA_SUPPORT_ASYNCNOTIF 0x0020 #define ATA_SUPPORT_SOFTSETPRESERVE 0x0040 +#define ATA_SUPPORT_NCQ_AUTOSENSE 0x0080 /*79*/ u_int16_t sataenabled; #define ATA_ENABLED_DAPST 0x0080 @@ -283,7 +285,8 @@ struct ata_params { #define ATA_FORM_FACTOR_C_FAST 0x0009 /*169*/ u_int16_t support_dsm; #define ATA_SUPPORT_DSM_TRIM 0x0001 - u_int16_t reserved170[6]; +/*170*/ u_int8_t product_id[8]; /* Additional Product Identifier */ + u_int16_t reserved174[2]; /*176*/ u_int8_t media_serial[60]; /*206*/ u_int16_t sct; u_int16_t reserved207[2]; From owner-svn-src-stable-11@freebsd.org Wed Aug 28 20:21:35 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9F3EBE5663; Wed, 28 Aug 2019 20:21:35 +0000 (UTC) (envelope-from mav@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 46Jcb33hHjz4fGh; Wed, 28 Aug 2019 20:21:35 +0000 (UTC) (envelope-from mav@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 61508CEB8; Wed, 28 Aug 2019 20:21:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7SKLZt3066123; Wed, 28 Aug 2019 20:21:35 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7SKLZhH066122; Wed, 28 Aug 2019 20:21:35 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908282021.x7SKLZhH066122@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 28 Aug 2019 20:21:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351580 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/camcontrol X-SVN-Commit-Revision: 351580 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Aug 2019 20:21:35 -0000 Author: mav Date: Wed Aug 28 20:21:34 2019 New Revision: 351580 URL: https://svnweb.freebsd.org/changeset/base/351580 Log: MFC r350424: Use present now scsi_mode_sense_subpage(). Modified: stable/11/sbin/camcontrol/timestamp.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/timestamp.c ============================================================================== --- stable/11/sbin/camcontrol/timestamp.c Wed Aug 28 20:20:38 2019 (r351579) +++ stable/11/sbin/camcontrol/timestamp.c Wed Aug 28 20:21:34 2019 (r351580) @@ -79,7 +79,6 @@ set_restore_flags(struct cam_device *device, uint8_t * int error = 0; struct scsi_control_ext_page *control_page = NULL; struct scsi_mode_header_10 *mode_hdr = NULL; - struct scsi_mode_sense_10 *cdb = NULL; union ccb *ccb = NULL; unsigned long mode_buf_size = sizeof(struct scsi_mode_header_10) + sizeof(struct scsi_mode_blk_desc) + @@ -96,25 +95,19 @@ set_restore_flags(struct cam_device *device, uint8_t * * Get the control extension subpage, we'll send it back modified to * enable SCSI control over the tape drive's timestamp */ - scsi_mode_sense_len(&ccb->csio, + scsi_mode_sense_subpage(&ccb->csio, /*retries*/ retry_count, /*cbfcnp*/ NULL, /*tag_action*/ task_attr, /*dbd*/ 0, /*page_control*/ SMS_PAGE_CTRL_CURRENT, /*page*/ SCEP_PAGE_CODE, + /*subpage*/ SCEP_SUBPAGE_CODE, /*param_buf*/ &mode_buf[0], /*param_len*/ mode_buf_size, /*minimum_cmd_size*/ 10, /*sense_len*/ SSD_FULL_SIZE, /*timeout*/ timeout ? timeout : 5000); - /* - * scsi_mode_sense_len does not have a subpage argument at the moment, - * so we have to manually set the subpage code before calling - * cam_send_ccb(). - */ - cdb = (struct scsi_mode_sense_10 *)ccb->csio.cdb_io.cdb_bytes; - cdb->subpage = SCEP_SUBPAGE_CODE; ccb->ccb_h.flags |= CAM_DEV_QFRZDIS; if (retry_count > 0) From owner-svn-src-stable-11@freebsd.org Wed Aug 28 20:22:15 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 90F30E572A; Wed, 28 Aug 2019 20:22:15 +0000 (UTC) (envelope-from mav@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 46Jcbq2zXtz4fVk; Wed, 28 Aug 2019 20:22:15 +0000 (UTC) (envelope-from mav@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 47A3BCEEE; Wed, 28 Aug 2019 20:22:15 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7SKMFYG070144; Wed, 28 Aug 2019 20:22:15 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7SKMEKx070077; Wed, 28 Aug 2019 20:22:14 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908282022.x7SKMEKx070077@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 28 Aug 2019 20:22:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351581 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/camcontrol X-SVN-Commit-Revision: 351581 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Aug 2019 20:22:15 -0000 Author: mav Date: Wed Aug 28 20:22:14 2019 New Revision: 351581 URL: https://svnweb.freebsd.org/changeset/base/351581 Log: MFC r350457: Make `camcontrol modepage` to use 10 byte commands. While old devices may not support 10 byte MODE SENSE/MODE SELECT commands, new ones may not be able to report all mode pages with 6 byte commands. This patch makes camcontrol by default start with 10 byte commands and fall back to 6 byte on ILLEGAL REQUEST error, or 6 byte can be forced. Modified: stable/11/sbin/camcontrol/camcontrol.8 stable/11/sbin/camcontrol/camcontrol.c stable/11/sbin/camcontrol/camcontrol.h stable/11/sbin/camcontrol/modeedit.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.8 Wed Aug 28 20:21:34 2019 (r351580) +++ stable/11/sbin/camcontrol/camcontrol.8 Wed Aug 28 20:22:14 2019 (r351581) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 25, 2019 +.Dd July 30, 2019 .Dt CAMCONTROL 8 .Os .Sh NAME @@ -122,6 +122,7 @@ .Ic modepage .Op device id .Op generic args +.Op Fl 6 .Aq Fl m Ar page[,subpage] | Fl l .Op Fl P Ar pgctl .Op Fl b | Fl e @@ -723,6 +724,13 @@ The .Ic modepage command takes several arguments: .Bl -tag -width 12n +.It Fl 6 +Use 6 byte MODE commands instead of default 10 byte. +Old devices may not support 10 byte MODE commands, while new devices may +not be able to report all mode pages with 6 byte commands. +If not specified, +.Nm +starts with 10 byte commands and falls back to 6 byte on error. .It Fl d Disable block descriptors for mode sense. .It Fl b Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Wed Aug 28 20:21:34 2019 (r351580) +++ stable/11/sbin/camcontrol/camcontrol.c Wed Aug 28 20:22:14 2019 (r351581) @@ -224,7 +224,7 @@ static struct camcontrol_opts option_table[] = { {"devtype", CAM_CMD_DEVTYPE, CAM_ARG_NONE, ""}, #ifndef MINIMALISTIC {"periphlist", CAM_CMD_DEVLIST, CAM_ARG_NONE, NULL}, - {"modepage", CAM_CMD_MODE_PAGE, CAM_ARG_NONE, "bdelm:P:"}, + {"modepage", CAM_CMD_MODE_PAGE, CAM_ARG_NONE, "6bdelm:P:"}, {"tags", CAM_CMD_TAG, CAM_ARG_NONE, "N:q"}, {"negotiate", CAM_CMD_RATE, CAM_ARG_NONE, negotiate_opts}, {"rate", CAM_CMD_RATE, CAM_ARG_NONE, negotiate_opts}, @@ -4430,18 +4430,25 @@ reassignblocks(struct cam_device *device, u_int32_t *b #ifndef MINIMALISTIC void -mode_sense(struct cam_device *device, int dbd, int pc, int page, int subpage, - int task_attr, int retry_count, int timeout, u_int8_t *data, - int datalen) +mode_sense(struct cam_device *device, int *cdb_len, int dbd, int pc, int page, + int subpage, int task_attr, int retry_count, int timeout, u_int8_t *data, + int datalen) { union ccb *ccb; - int retval; + int error_code, sense_key, asc, ascq; ccb = cam_getccb(device); - if (ccb == NULL) errx(1, "mode_sense: couldn't allocate CCB"); +retry: + /* + * MODE SENSE(6) can't handle more then 255 bytes. If there are more, + * device must return error, so we should not get trucated data. + */ + if (*cdb_len == 6 && datalen > 255) + datalen = 255; + CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); scsi_mode_sense_subpage(&ccb->csio, @@ -4454,36 +4461,47 @@ mode_sense(struct cam_device *device, int dbd, int pc, /* subpage */ subpage, /* param_buf */ data, /* param_len */ datalen, - /* minimum_cmd_size */ 0, + /* minimum_cmd_size */ *cdb_len, /* sense_len */ SSD_FULL_SIZE, /* timeout */ timeout ? timeout : 5000); + /* Record what CDB size the above function really set. */ + *cdb_len = ccb->csio.cdb_len; + if (arglist & CAM_ARG_ERR_RECOVER) ccb->ccb_h.flags |= CAM_PASS_ERR_RECOVER; /* Disable freezing the device queue */ ccb->ccb_h.flags |= CAM_DEV_QFRZDIS; - if (((retval = cam_send_ccb(device, ccb)) < 0) - || ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)) { + if (cam_send_ccb(device, ccb) < 0) + err(1, "error sending mode sense command"); + + /* In case of ILLEGEL REQUEST try to fall back to 6-byte command. */ + if (*cdb_len != 6 && + ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_INVALID || + (scsi_extract_sense_ccb(ccb, &error_code, &sense_key, &asc, &ascq) + && sense_key == SSD_KEY_ILLEGAL_REQUEST))) { + *cdb_len = 6; + goto retry; + } + + if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { if (arglist & CAM_ARG_VERBOSE) { cam_error_print(device, ccb, CAM_ESF_ALL, CAM_EPF_ALL, stderr); } cam_freeccb(ccb); cam_close_device(device); - if (retval < 0) - err(1, "error sending mode sense command"); - else - errx(1, "error sending mode sense command"); + errx(1, "mode sense command returned error"); } cam_freeccb(ccb); } void -mode_select(struct cam_device *device, int save_pages, int task_attr, - int retry_count, int timeout, u_int8_t *data, int datalen) +mode_select(struct cam_device *device, int cdb_len, int save_pages, + int task_attr, int retry_count, int timeout, u_int8_t *data, int datalen) { union ccb *ccb; int retval; @@ -4495,7 +4513,7 @@ mode_select(struct cam_device *device, int save_pages, CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); - scsi_mode_select(&ccb->csio, + scsi_mode_select_len(&ccb->csio, /* retries */ retry_count, /* cbfcnp */ NULL, /* tag_action */ task_attr, @@ -4503,6 +4521,7 @@ mode_select(struct cam_device *device, int save_pages, /* save_pages */ save_pages, /* param_buf */ data, /* param_len */ datalen, + /* minimum_cmd_size */ cdb_len, /* sense_len */ SSD_FULL_SIZE, /* timeout */ timeout ? timeout : 5000); @@ -4537,10 +4556,13 @@ modepage(struct cam_device *device, int argc, char **a { char *str_subpage; int c, page = -1, subpage = -1, pc = 0; - int binary = 0, dbd = 0, edit = 0, list = 0; + int binary = 0, cdb_len = 10, dbd = 0, edit = 0, list = 0; while ((c = getopt(argc, argv, combinedopt)) != -1) { switch(c) { + case '6': + cdb_len = 6; + break; case 'b': binary = 1; break; @@ -4580,11 +4602,11 @@ modepage(struct cam_device *device, int argc, char **a errx(1, "you must specify a mode page!"); if (list != 0) { - mode_list(device, dbd, pc, list > 1, task_attr, retry_count, - timeout); + mode_list(device, cdb_len, dbd, pc, list > 1, task_attr, + retry_count, timeout); } else { - mode_edit(device, dbd, pc, page, subpage, edit, binary, - task_attr, retry_count, timeout); + mode_edit(device, cdb_len, dbd, pc, page, subpage, edit, + binary, task_attr, retry_count, timeout); } } Modified: stable/11/sbin/camcontrol/camcontrol.h ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.h Wed Aug 28 20:21:34 2019 (r351580) +++ stable/11/sbin/camcontrol/camcontrol.h Wed Aug 28 20:22:14 2019 (r351581) @@ -88,16 +88,17 @@ int epc(struct cam_device *device, int argc, char **ar int timestamp(struct cam_device *device, int argc, char **argv, char *combinedopt, int task_attr, int retry_count, int timeout, int verbosemode); -void mode_sense(struct cam_device *device, int dbd, int pc, int page, - int subpage, int task_attr, int retry_count, int timeout, - uint8_t *data, int datalen); -void mode_select(struct cam_device *device, int save_pages, int task_attr, - int retry_count, int timeout, u_int8_t *data, int datalen); -void mode_edit(struct cam_device *device, int dbd, int pc, int page, - int subpage, int edit, int binary, int task_attr, +void mode_sense(struct cam_device *device, int *cdb_len, int dbd, int pc, + int page, int subpage, int task_attr, int retry_count, + int timeout, uint8_t *data, int datalen); +void mode_select(struct cam_device *device, int cdb_len, int save_pages, + int task_attr, int retry_count, int timeout, u_int8_t *data, + int datalen); +void mode_edit(struct cam_device *device, int cdb_len, int dbd, int pc, + int page, int subpage, int edit, int binary, int task_attr, int retry_count, int timeout); -void mode_list(struct cam_device *device, int dbd, int pc, int subpages, - int task_attr, int retry_count, int timeout); +void mode_list(struct cam_device *device, int cdb_len, int dbd, int pc, + int subpages, int task_attr, int retry_count, int timeout); int scsidoinquiry(struct cam_device *device, int argc, char **argv, char *combinedopt, int task_attr, int retry_count, int timeout); Modified: stable/11/sbin/camcontrol/modeedit.c ============================================================================== --- stable/11/sbin/camcontrol/modeedit.c Wed Aug 28 20:21:34 2019 (r351580) +++ stable/11/sbin/camcontrol/modeedit.c Wed Aug 28 20:22:14 2019 (r351581) @@ -60,15 +60,9 @@ __FBSDID("$FreeBSD$"); #define PAGENAME_START '"' /* Page name delimiter. */ #define PAGENAME_END '"' /* Page name delimiter. */ #define PAGEENTRY_END ';' /* Page entry terminator (optional). */ -#define MAX_COMMAND_SIZE 255 /* Mode/Log sense data buffer size. */ +#define MAX_DATA_SIZE 4096 /* Mode/Log sense data buffer size. */ #define PAGE_CTRL_SHIFT 6 /* Bit offset to page control field. */ - -/* Macros for working with mode pages. */ -#define MODE_PAGE_HEADER(mh) \ - (struct scsi_mode_page_header *)find_mode_page_6(mh) - - struct editentry { STAILQ_ENTRY(editentry) link; char *name; @@ -106,13 +100,12 @@ static int editentry_save(void *hook, char *name); static struct editentry *editentry_lookup(char *name); static int editentry_set(char *name, char *newvalue, int editonly); -static void editlist_populate(struct cam_device *device, int dbd, - int pc, int page, int subpage, - int task_attr, int retries, - int timeout); -static void editlist_save(struct cam_device *device, int dbd, - int pc, int page, int subpage, - int task_attr, int retries, int timeout); +static void editlist_populate(struct cam_device *device, + int cdb_len, int dbd, int pc, int page, int subpage, + int task_attr, int retries, int timeout); +static void editlist_save(struct cam_device *device, int cdb_len, + int dbd, int pc, int page, int subpage, + int task_attr, int retries, int timeout); static void nameentry_create(int page, int subpage, char *name); static struct pagename *nameentry_lookup(int page, int subpage); static int load_format(const char *pagedb_path, int lpage, @@ -120,9 +113,9 @@ static int load_format(const char *pagedb_path, int static int modepage_write(FILE *file, int editonly); static int modepage_read(FILE *file); static void modepage_edit(void); -static void modepage_dump(struct cam_device *device, int dbd, - int pc, int page, int subpage, int task_attr, - int retries, int timeout); +static void modepage_dump(struct cam_device *device, int cdb_len, + int dbd, int pc, int page, int subpage, + int task_attr, int retries, int timeout); static void cleanup_editfile(void); @@ -552,12 +545,11 @@ load_format(const char *pagedb_path, int lpage, int ls } static void -editlist_populate(struct cam_device *device, int dbd, int pc, int page, - int subpage, int task_attr, int retries, int timeout) +editlist_populate(struct cam_device *device, int cdb_len, int dbd, int pc, + int page, int subpage, int task_attr, int retries, int timeout) { - u_int8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */ + u_int8_t data[MAX_DATA_SIZE];/* Buffer to hold sense data. */ u_int8_t *mode_pars; /* Pointer to modepage params. */ - struct scsi_mode_header_6 *mh; /* Location of mode header. */ struct scsi_mode_page_header *mph; struct scsi_mode_page_header_sp *mphsp; size_t len; @@ -565,11 +557,18 @@ editlist_populate(struct cam_device *device, int dbd, STAILQ_INIT(&editlist); /* Fetch changeable values; use to build initial editlist. */ - mode_sense(device, dbd, 1, page, subpage, task_attr, retries, timeout, - data, sizeof(data)); + mode_sense(device, &cdb_len, dbd, 1, page, subpage, task_attr, retries, + timeout, data, sizeof(data)); - mh = (struct scsi_mode_header_6 *)data; - mph = MODE_PAGE_HEADER(mh); + if (cdb_len == 6) { + struct scsi_mode_header_6 *mh = + (struct scsi_mode_header_6 *)data; + mph = find_mode_page_6(mh); + } else { + struct scsi_mode_header_10 *mh = + (struct scsi_mode_header_10 *)data; + mph = find_mode_page_10(mh); + } if ((mph->page_code & SMPH_SPF) == 0) { mode_pars = (uint8_t *)(mph + 1); len = mph->page_length; @@ -584,40 +583,80 @@ editlist_populate(struct cam_device *device, int dbd, buff_decode_visit(mode_pars, len, format, editentry_create, 0); /* Fetch the current/saved values; use to set editentry values. */ - mode_sense(device, dbd, pc, page, subpage, task_attr, retries, timeout, - data, sizeof(data)); + mode_sense(device, &cdb_len, dbd, pc, page, subpage, task_attr, + retries, timeout, data, sizeof(data)); buff_decode_visit(mode_pars, len, format, editentry_update, 0); } static void -editlist_save(struct cam_device *device, int dbd, int pc, int page, - int subpage, int task_attr, int retries, int timeout) +editlist_save(struct cam_device *device, int cdb_len, int dbd, int pc, + int page, int subpage, int task_attr, int retries, int timeout) { - u_int8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */ + u_int8_t data[MAX_DATA_SIZE];/* Buffer to hold sense data. */ u_int8_t *mode_pars; /* Pointer to modepage params. */ - struct scsi_mode_header_6 *mh; /* Location of mode header. */ struct scsi_mode_page_header *mph; struct scsi_mode_page_header_sp *mphsp; - size_t len, hlen; + size_t len, hlen, mphlen; /* Make sure that something changed before continuing. */ if (! editlist_changed) return; /* Preload the CDB buffer with the current mode page data. */ - mode_sense(device, dbd, pc, page, subpage, task_attr, retries, timeout, - data, sizeof(data)); + mode_sense(device, &cdb_len, dbd, pc, page, subpage, task_attr, + retries, timeout, data, sizeof(data)); /* Initial headers & offsets. */ - mh = (struct scsi_mode_header_6 *)data; - mph = MODE_PAGE_HEADER(mh); + /* + * Tape drives include write protect (WP), Buffered Mode and Speed + * settings in the device-specific parameter. Clearing this + * parameter on a mode select can have the effect of turning off + * write protect or buffered mode, or changing the speed setting of + * the tape drive. + * + * Disks report DPO/FUA support via the device specific parameter + * for MODE SENSE, but the bit is reserved for MODE SELECT. So we + * clear this for disks (and other non-tape devices) to avoid + * potential errors from the target device. + */ + if (cdb_len == 6) { + struct scsi_mode_header_6 *mh = + (struct scsi_mode_header_6 *)data; + hlen = sizeof(*mh); + /* Eliminate block descriptors. */ + if (mh->blk_desc_len > 0) { + bcopy(find_mode_page_6(mh), mh + 1, + mh->data_length + 1 - hlen - + mh->blk_desc_len); + mh->blk_desc_len = 0; + } + mh->data_length = 0; /* Reserved for MODE SELECT command. */ + if (device->pd_type != T_SEQUENTIAL) + mh->dev_spec = 0; /* See comment above */ + mph = find_mode_page_6(mh); + } else { + struct scsi_mode_header_10 *mh = + (struct scsi_mode_header_10 *)data; + hlen = sizeof(*mh); + /* Eliminate block descriptors. */ + if (scsi_2btoul(mh->blk_desc_len) > 0) { + bcopy(find_mode_page_10(mh), mh + 1, + scsi_2btoul(mh->data_length) + 1 - hlen - + scsi_2btoul(mh->blk_desc_len)); + scsi_ulto2b(0, mh->blk_desc_len); + } + scsi_ulto2b(0, mh->data_length); /* Reserved for MODE SELECT. */ + if (device->pd_type != T_SEQUENTIAL) + mh->dev_spec = 0; /* See comment above */ + mph = find_mode_page_10(mh); + } if ((mph->page_code & SMPH_SPF) == 0) { - hlen = sizeof(*mph); + mphlen = sizeof(*mph); mode_pars = (uint8_t *)(mph + 1); len = mph->page_length; } else { mphsp = (struct scsi_mode_page_header_sp *)mph; - hlen = sizeof(*mphsp); + mphlen = sizeof(*mphsp); mode_pars = (uint8_t *)(mphsp + 1); len = scsi_2btoul(mphsp->page_length); } @@ -626,27 +665,6 @@ editlist_save(struct cam_device *device, int dbd, int /* Encode the value data to be passed back to the device. */ buff_encode_visit(mode_pars, len, format, editentry_save, 0); - /* Eliminate block descriptors. */ - bcopy(mph, mh + 1, hlen + len); - - /* Recalculate headers & offsets. */ - mh->data_length = 0; /* Reserved for MODE SELECT command. */ - mh->blk_desc_len = 0; /* No block descriptors. */ - /* - * Tape drives include write protect (WP), Buffered Mode and Speed - * settings in the device-specific parameter. Clearing this - * parameter on a mode select can have the effect of turning off - * write protect or buffered mode, or changing the speed setting of - * the tape drive. - * - * Disks report DPO/FUA support via the device specific parameter - * for MODE SENSE, but the bit is reserved for MODE SELECT. So we - * clear this for disks (and other non-tape devices) to avoid - * potential errors from the target device. - */ - if (device->pd_type != T_SEQUENTIAL) - mh->dev_spec = 0; - mph = MODE_PAGE_HEADER(mh); mph->page_code &= ~SMPH_PS; /* Reserved for MODE SELECT command. */ /* @@ -654,9 +672,8 @@ editlist_save(struct cam_device *device, int dbd, int * page 3 (saved values) then request the changes be permanently * recorded. */ - mode_select(device, (pc << PAGE_CTRL_SHIFT == SMS_PAGE_CTRL_SAVED), - task_attr, retries, timeout, (u_int8_t *)mh, - sizeof(*mh) + hlen + len); + mode_select(device, cdb_len, (pc << PAGE_CTRL_SHIFT == SMS_PAGE_CTRL_SAVED), + task_attr, retries, timeout, data, hlen + mphlen + len); } static int @@ -825,21 +842,27 @@ modepage_edit(void) } static void -modepage_dump(struct cam_device *device, int dbd, int pc, int page, int subpage, - int task_attr, int retries, int timeout) +modepage_dump(struct cam_device *device, int cdb_len, int dbd, int pc, + int page, int subpage, int task_attr, int retries, int timeout) { - u_int8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */ + u_int8_t data[MAX_DATA_SIZE];/* Buffer to hold sense data. */ u_int8_t *mode_pars; /* Pointer to modepage params. */ - struct scsi_mode_header_6 *mh; /* Location of mode header. */ struct scsi_mode_page_header *mph; struct scsi_mode_page_header_sp *mphsp; size_t indx, len; - mode_sense(device, dbd, pc, page, subpage, task_attr, retries, timeout, - data, sizeof(data)); + mode_sense(device, &cdb_len, dbd, pc, page, subpage, task_attr, + retries, timeout, data, sizeof(data)); - mh = (struct scsi_mode_header_6 *)data; - mph = MODE_PAGE_HEADER(mh); + if (cdb_len == 6) { + struct scsi_mode_header_6 *mh = + (struct scsi_mode_header_6 *)data; + mph = find_mode_page_6(mh); + } else { + struct scsi_mode_header_10 *mh = + (struct scsi_mode_header_10 *)data; + mph = find_mode_page_10(mh); + } if ((mph->page_code & SMPH_SPF) == 0) { mode_pars = (uint8_t *)(mph + 1); len = mph->page_length; @@ -869,8 +892,9 @@ cleanup_editfile(void) } void -mode_edit(struct cam_device *device, int dbd, int pc, int page, int subpage, - int edit, int binary, int task_attr, int retry_count, int timeout) +mode_edit(struct cam_device *device, int cdb_len, int dbd, int pc, int page, + int subpage, int edit, int binary, int task_attr, int retry_count, + int timeout) { const char *pagedb_path; /* Path to modepage database. */ @@ -901,8 +925,8 @@ mode_edit(struct cam_device *device, int dbd, int pc, exit(EX_OSFILE); } - editlist_populate(device, dbd, pc, page, subpage, task_attr, - retry_count, timeout); + editlist_populate(device, cdb_len, dbd, pc, page, subpage, + task_attr, retry_count, timeout); } if (edit) { @@ -911,12 +935,12 @@ mode_edit(struct cam_device *device, int dbd, int pc, errx(EX_USAGE, "it only makes sense to edit page 0 " "(current) or page 3 (saved values)"); modepage_edit(); - editlist_save(device, dbd, pc, page, subpage, task_attr, - retry_count, timeout); + editlist_save(device, cdb_len, dbd, pc, page, subpage, + task_attr, retry_count, timeout); } else if (binary || STAILQ_EMPTY(&editlist)) { /* Display without formatting information. */ - modepage_dump(device, dbd, pc, page, subpage, task_attr, - retry_count, timeout); + modepage_dump(device, cdb_len, dbd, pc, page, subpage, + task_attr, retry_count, timeout); } else { /* Display with format. */ modepage_write(stdout, 0); @@ -924,16 +948,15 @@ mode_edit(struct cam_device *device, int dbd, int pc, } void -mode_list(struct cam_device *device, int dbd, int pc, int subpages, +mode_list(struct cam_device *device, int cdb_len, int dbd, int pc, int subpages, int task_attr, int retry_count, int timeout) { - u_int8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */ - struct scsi_mode_header_6 *mh; /* Location of mode header. */ + u_int8_t data[MAX_DATA_SIZE];/* Buffer to hold sense data. */ struct scsi_mode_page_header *mph; struct scsi_mode_page_header_sp *mphsp; struct pagename *nameentry; const char *pagedb_path; - int len, page, subpage; + int len, off, page, subpage; if ((pagedb_path = getenv("SCSI_MODES")) == NULL) pagedb_path = DEFAULT_SCSI_MODE_DB; @@ -944,26 +967,36 @@ mode_list(struct cam_device *device, int dbd, int pc, } /* Build the list of all mode pages by querying the "all pages" page. */ - mode_sense(device, dbd, pc, SMS_ALL_PAGES_PAGE, + mode_sense(device, &cdb_len, dbd, pc, SMS_ALL_PAGES_PAGE, subpages ? SMS_SUBPAGE_ALL : 0, task_attr, retry_count, timeout, data, sizeof(data)); - mh = (struct scsi_mode_header_6 *)data; - len = sizeof(*mh) + mh->blk_desc_len; /* Skip block descriptors. */ + /* Skip block descriptors. */ + if (cdb_len == 6) { + struct scsi_mode_header_6 *mh = + (struct scsi_mode_header_6 *)data; + len = mh->data_length; + off = sizeof(*mh) + mh->blk_desc_len; + } else { + struct scsi_mode_header_10 *mh = + (struct scsi_mode_header_10 *)data; + len = scsi_2btoul(mh->data_length); + off = sizeof(*mh) + scsi_2btoul(mh->blk_desc_len); + } /* Iterate through the pages in the reply. */ - while (len < mh->data_length) { + while (off < len) { /* Locate the next mode page header. */ - mph = (struct scsi_mode_page_header *)((intptr_t)mh + len); + mph = (struct scsi_mode_page_header *)(data + off); if ((mph->page_code & SMPH_SPF) == 0) { page = mph->page_code & SMS_PAGE_CODE; subpage = 0; - len += sizeof(*mph) + mph->page_length; + off += sizeof(*mph) + mph->page_length; } else { mphsp = (struct scsi_mode_page_header_sp *)mph; page = mphsp->page_code & SMS_PAGE_CODE; subpage = mphsp->subpage; - len += sizeof(*mphsp) + scsi_2btoul(mphsp->page_length); + off += sizeof(*mphsp) + scsi_2btoul(mphsp->page_length); } nameentry = nameentry_lookup(page, subpage); From owner-svn-src-stable-11@freebsd.org Wed Aug 28 20:23:10 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 11893E58E0; Wed, 28 Aug 2019 20:23:10 +0000 (UTC) (envelope-from mav@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 46Jcct05dXz4ffD; Wed, 28 Aug 2019 20:23:10 +0000 (UTC) (envelope-from mav@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 D8E80CF12; Wed, 28 Aug 2019 20:23:09 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7SKN94T070242; Wed, 28 Aug 2019 20:23:09 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7SKN8RL070234; Wed, 28 Aug 2019 20:23:08 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908282023.x7SKN8RL070234@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 28 Aug 2019 20:23:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351582 - in stable/11: sbin/camcontrol sys/cam/scsi X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/11: sbin/camcontrol sys/cam/scsi X-SVN-Commit-Revision: 351582 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Aug 2019 20:23:10 -0000 Author: mav Date: Wed Aug 28 20:23:08 2019 New Revision: 351582 URL: https://svnweb.freebsd.org/changeset/base/351582 Log: MFC r350676: Make `camcontrol modepage` support block descriptors. It allows to read and write block descriptors alike to mode page parameters. It allows to change block size or short-stroke HDDs or overprovision SSDs. Depenting on -P parameter the change can be either persistent or till reset. In case of block size change device may need reformat after the setting. In case of SSD overprovisioning format or sanitize may be needed to really free the flash. During implementation appeared that csio_encode_visit() can not handle integers of more then 4 bytes, that makes 8-byte LBA handling awkward. I had to split it into two 4-byte halves now. Relnotes: yes Sponsored by: iXsystems, Inc. Modified: stable/11/sbin/camcontrol/camcontrol.8 stable/11/sbin/camcontrol/camcontrol.c stable/11/sbin/camcontrol/camcontrol.h stable/11/sbin/camcontrol/modeedit.c stable/11/sys/cam/scsi/scsi_all.c stable/11/sys/cam/scsi/scsi_all.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.8 Wed Aug 28 20:22:14 2019 (r351581) +++ stable/11/sbin/camcontrol/camcontrol.8 Wed Aug 28 20:23:08 2019 (r351582) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 30, 2019 +.Dd August 6, 2019 .Dt CAMCONTROL 8 .Os .Sh NAME @@ -125,6 +125,8 @@ .Op Fl 6 .Aq Fl m Ar page[,subpage] | Fl l .Op Fl P Ar pgctl +.Op Fl D +.Op Fl L .Op Fl b | Fl e .Op Fl d .Nm @@ -733,6 +735,11 @@ If not specified, starts with 10 byte commands and falls back to 6 byte on error. .It Fl d Disable block descriptors for mode sense. +.It Fl D +Display/edit block descriptors instead of mode page. +.It Fl L +Use long LBA block descriptors. +Allows number of LBAs bigger then 2^^32. .It Fl b Displays mode page data in binary format. .It Fl e Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Wed Aug 28 20:22:14 2019 (r351581) +++ stable/11/sbin/camcontrol/camcontrol.c Wed Aug 28 20:23:08 2019 (r351582) @@ -224,7 +224,7 @@ static struct camcontrol_opts option_table[] = { {"devtype", CAM_CMD_DEVTYPE, CAM_ARG_NONE, ""}, #ifndef MINIMALISTIC {"periphlist", CAM_CMD_DEVLIST, CAM_ARG_NONE, NULL}, - {"modepage", CAM_CMD_MODE_PAGE, CAM_ARG_NONE, "6bdelm:P:"}, + {"modepage", CAM_CMD_MODE_PAGE, CAM_ARG_NONE, "6bdelm:DLP:"}, {"tags", CAM_CMD_TAG, CAM_ARG_NONE, "N:q"}, {"negotiate", CAM_CMD_RATE, CAM_ARG_NONE, negotiate_opts}, {"rate", CAM_CMD_RATE, CAM_ARG_NONE, negotiate_opts}, @@ -4430,9 +4430,9 @@ reassignblocks(struct cam_device *device, u_int32_t *b #ifndef MINIMALISTIC void -mode_sense(struct cam_device *device, int *cdb_len, int dbd, int pc, int page, - int subpage, int task_attr, int retry_count, int timeout, u_int8_t *data, - int datalen) +mode_sense(struct cam_device *device, int *cdb_len, int dbd, int llbaa, int pc, + int page, int subpage, int task_attr, int retry_count, int timeout, + u_int8_t *data, int datalen) { union ccb *ccb; int error_code, sense_key, asc, ascq; @@ -4464,6 +4464,11 @@ retry: /* minimum_cmd_size */ *cdb_len, /* sense_len */ SSD_FULL_SIZE, /* timeout */ timeout ? timeout : 5000); + if (llbaa && ccb->csio.cdb_len == 10) { + struct scsi_mode_sense_10 *cdb = + (struct scsi_mode_sense_10 *)ccb->csio.cdb_io.cdb_bytes; + cdb->byte2 |= SMS10_LLBAA; + } /* Record what CDB size the above function really set. */ *cdb_len = ccb->csio.cdb_len; @@ -4555,8 +4560,8 @@ modepage(struct cam_device *device, int argc, char **a int task_attr, int retry_count, int timeout) { char *str_subpage; - int c, page = -1, subpage = -1, pc = 0; - int binary = 0, cdb_len = 10, dbd = 0, edit = 0, list = 0; + int c, page = -1, subpage = -1, pc = 0, llbaa = 0; + int binary = 0, cdb_len = 10, dbd = 0, desc = 0, edit = 0, list = 0; while ((c = getopt(argc, argv, combinedopt)) != -1) { switch(c) { @@ -4588,6 +4593,12 @@ modepage(struct cam_device *device, int argc, char **a if (subpage < 0) errx(1, "invalid mode subpage %d", subpage); break; + case 'D': + desc = 1; + break; + case 'L': + llbaa = 1; + break; case 'P': pc = strtol(optarg, NULL, 0); if ((pc < 0) || (pc > 3)) @@ -4598,15 +4609,21 @@ modepage(struct cam_device *device, int argc, char **a } } - if (page == -1 && list == 0) + if (page == -1 && desc == 0 && list == 0) errx(1, "you must specify a mode page!"); + if (dbd && desc) + errx(1, "-d and -D are incompatible!"); + + if (llbaa && cdb_len != 10) + errx(1, "LLBAA bit is not present in MODE SENSE(6)!"); + if (list != 0) { mode_list(device, cdb_len, dbd, pc, list > 1, task_attr, retry_count, timeout); } else { - mode_edit(device, cdb_len, dbd, pc, page, subpage, edit, - binary, task_attr, retry_count, timeout); + mode_edit(device, cdb_len, desc, dbd, llbaa, pc, page, subpage, + edit, binary, task_attr, retry_count, timeout); } } Modified: stable/11/sbin/camcontrol/camcontrol.h ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.h Wed Aug 28 20:22:14 2019 (r351581) +++ stable/11/sbin/camcontrol/camcontrol.h Wed Aug 28 20:23:08 2019 (r351582) @@ -88,15 +88,15 @@ int epc(struct cam_device *device, int argc, char **ar int timestamp(struct cam_device *device, int argc, char **argv, char *combinedopt, int task_attr, int retry_count, int timeout, int verbosemode); -void mode_sense(struct cam_device *device, int *cdb_len, int dbd, int pc, - int page, int subpage, int task_attr, int retry_count, +void mode_sense(struct cam_device *device, int *cdb_len, int dbd, int llbaa, + int pc, int page, int subpage, int task_attr, int retry_count, int timeout, uint8_t *data, int datalen); void mode_select(struct cam_device *device, int cdb_len, int save_pages, int task_attr, int retry_count, int timeout, u_int8_t *data, int datalen); -void mode_edit(struct cam_device *device, int cdb_len, int dbd, int pc, - int page, int subpage, int edit, int binary, int task_attr, - int retry_count, int timeout); +void mode_edit(struct cam_device *device, int cdb_len, int desc, int dbd, + int llbaa, int pc, int page, int subpage, int edit, int binary, + int task_attr, int retry_count, int timeout); void mode_list(struct cam_device *device, int cdb_len, int dbd, int pc, int subpages, int task_attr, int retry_count, int timeout); int scsidoinquiry(struct cam_device *device, int argc, char **argv, Modified: stable/11/sbin/camcontrol/modeedit.c ============================================================================== --- stable/11/sbin/camcontrol/modeedit.c Wed Aug 28 20:22:14 2019 (r351581) +++ stable/11/sbin/camcontrol/modeedit.c Wed Aug 28 20:23:08 2019 (r351582) @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -96,6 +97,8 @@ static void editentry_create(void *hook, int letter, int count, char *name); static void editentry_update(void *hook, int letter, void *arg, int count, char *name); +static void editentry_create_desc(void *hook, int letter, void *arg, + int count, char *name); static int editentry_save(void *hook, char *name); static struct editentry *editentry_lookup(char *name); static int editentry_set(char *name, char *newvalue, @@ -103,9 +106,16 @@ static int editentry_set(char *name, char *newvalue, static void editlist_populate(struct cam_device *device, int cdb_len, int dbd, int pc, int page, int subpage, int task_attr, int retries, int timeout); +static void editlist_populate_desc(struct cam_device *device, + int cdb_len, int llbaa, int pc, int page, + int subpage, int task_attr, int retries, + int timeout); static void editlist_save(struct cam_device *device, int cdb_len, int dbd, int pc, int page, int subpage, int task_attr, int retries, int timeout); +static void editlist_save_desc(struct cam_device *device, int cdb_len, + int llbaa, int pc, int page, int subpage, + int task_attr, int retries, int timeout); static void nameentry_create(int page, int subpage, char *name); static struct pagename *nameentry_lookup(int page, int subpage); static int load_format(const char *pagedb_path, int lpage, @@ -116,6 +126,10 @@ static void modepage_edit(void); static void modepage_dump(struct cam_device *device, int cdb_len, int dbd, int pc, int page, int subpage, int task_attr, int retries, int timeout); +static void modepage_dump_desc(struct cam_device *device, + int cdb_len, int llbaa, int pc, int page, + int subpage, int task_attr, int retries, + int timeout); static void cleanup_editfile(void); @@ -182,6 +196,43 @@ editentry_update(void *hook __unused, int letter, void } } +static void +editentry_create_desc(void *hook __unused, int letter, void *arg, int count, + char *name) +{ + struct editentry *newentry; /* Buffer to hold new entry. */ + + /* Allocate memory for the new entry and a copy of the entry name. */ + if ((newentry = malloc(sizeof(struct editentry))) == NULL || + (newentry->name = strdup(name)) == NULL) + err(EX_OSERR, NULL); + + /* Trim any trailing whitespace for the entry name. */ + RTRIM(newentry->name); + + newentry->editable = 1; + newentry->type = letter; + newentry->size = count; + newentry->value.svalue = NULL; + + STAILQ_INSERT_TAIL(&editlist, newentry, link); + + switch (letter) { + case 'i': /* Byte-sized integral type. */ + case 'b': /* Bit-sized integral types. */ + case 't': + newentry->value.ivalue = (intptr_t)arg; + break; + + case 'c': /* Character array. */ + case 'z': /* Null-padded string. */ + editentry_set(name, (char *)arg, 0); + break; + default: + ; /* NOTREACHED */ + } +} + static int editentry_save(void *hook __unused, char *name) { @@ -238,7 +289,7 @@ editentry_set(char *name, char *newvalue, int editonly struct editentry *dest; /* Modepage entry to update. */ char *cval; /* Pointer to new string value. */ char *convertend; /* End-of-conversion pointer. */ - int ival; /* New integral value. */ + long long ival, newival; /* New integral value. */ int resolution; /* Resolution in bits for integer conversion. */ /* @@ -248,7 +299,7 @@ editentry_set(char *name, char *newvalue, int editonly * currently workaround it (even for int64's), so we have to kludge it. */ #define RESOLUTION_MAX(size) ((resolution * (size) == 32)? \ - INT_MAX: (1 << (resolution * (size))) - 1) + UINT_MAX: (1 << (resolution * (size))) - 1) assert(newvalue != NULL); if (*newvalue == '\0') @@ -265,13 +316,13 @@ editentry_set(char *name, char *newvalue, int editonly case 't': /* Convert the value string to an integer. */ resolution = (dest->type == 'i')? 8: 1; - ival = (int)strtol(newvalue, &convertend, 0); + ival = strtoll(newvalue, &convertend, 0); if (*convertend != '\0') returnerr(EINVAL); if (ival > RESOLUTION_MAX(dest->size) || ival < 0) { - int newival = (ival < 0)? 0: RESOLUTION_MAX(dest->size); - warnx("value %d is out of range for entry %s; clipping " - "to %d", ival, name, newival); + newival = (ival < 0) ? 0 : RESOLUTION_MAX(dest->size); + warnx("value %lld is out of range for entry %s; " + "clipping to %lld", ival, name, newival); ival = newival; } if (dest->value.ivalue != ival) @@ -548,7 +599,7 @@ static void editlist_populate(struct cam_device *device, int cdb_len, int dbd, int pc, int page, int subpage, int task_attr, int retries, int timeout) { - u_int8_t data[MAX_DATA_SIZE];/* Buffer to hold sense data. */ + u_int8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */ u_int8_t *mode_pars; /* Pointer to modepage params. */ struct scsi_mode_page_header *mph; struct scsi_mode_page_header_sp *mphsp; @@ -557,8 +608,8 @@ editlist_populate(struct cam_device *device, int cdb_l STAILQ_INIT(&editlist); /* Fetch changeable values; use to build initial editlist. */ - mode_sense(device, &cdb_len, dbd, 1, page, subpage, task_attr, retries, - timeout, data, sizeof(data)); + mode_sense(device, &cdb_len, dbd, 0, 1, page, subpage, task_attr, + retries, timeout, data, sizeof(data)); if (cdb_len == 6) { struct scsi_mode_header_6 *mh = @@ -583,16 +634,77 @@ editlist_populate(struct cam_device *device, int cdb_l buff_decode_visit(mode_pars, len, format, editentry_create, 0); /* Fetch the current/saved values; use to set editentry values. */ - mode_sense(device, &cdb_len, dbd, pc, page, subpage, task_attr, + mode_sense(device, &cdb_len, dbd, 0, pc, page, subpage, task_attr, retries, timeout, data, sizeof(data)); buff_decode_visit(mode_pars, len, format, editentry_update, 0); } static void +editlist_populate_desc(struct cam_device *device, int cdb_len, int llbaa, int pc, + int page, int subpage, int task_attr, int retries, int timeout) +{ + uint8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */ + uint8_t *desc; /* Pointer to block descriptor. */ + char num[8]; + struct sbuf sb; + size_t len; + u_int longlba, dlen, i; + + STAILQ_INIT(&editlist); + + /* Fetch the current/saved values. */ + mode_sense(device, &cdb_len, 0, llbaa, pc, page, subpage, task_attr, + retries, timeout, data, sizeof(data)); + + if (cdb_len == 6) { + struct scsi_mode_header_6 *mh = + (struct scsi_mode_header_6 *)data; + desc = (uint8_t *)(mh + 1); + len = mh->blk_desc_len; + longlba = 0; + } else { + struct scsi_mode_header_10 *mh = + (struct scsi_mode_header_10 *)data; + desc = (uint8_t *)(mh + 1); + len = scsi_2btoul(mh->blk_desc_len); + longlba = (mh->flags & SMH_LONGLBA) != 0; + } + dlen = longlba ? 16 : 8; + len = MIN(len, sizeof(data) - (desc - data)); + + sbuf_new(&sb, format, sizeof(format), SBUF_FIXEDLEN); + num[0] = 0; + for (i = 0; i * dlen < len; i++) { + if (i > 0) + snprintf(num, sizeof(num), " %d", i + 1); + if (longlba) { + sbuf_printf(&sb, "{Number of Logical Blocks%s High} i4\n", num); + sbuf_printf(&sb, "{Number of Logical Blocks%s} i4\n", num); + sbuf_cat(&sb, "{Reserved} *i4\n"); + sbuf_printf(&sb, "{Logical Block Length%s} i4\n", num); + } else if (device->pd_type == T_DIRECT) { + sbuf_printf(&sb, "{Number of Logical Blocks%s} i4\n", num); + sbuf_cat(&sb, "{Reserved} *i1\n"); + sbuf_printf(&sb, "{Logical Block Length%s} i3\n", num); + } else { + sbuf_printf(&sb, "{Density Code%s} i1\n", num); + sbuf_printf(&sb, "{Number of Logical Blocks%s} i3\n", num); + sbuf_cat(&sb, "{Reserved} *i1\n"); + sbuf_printf(&sb, "{Logical Block Length%s} i3\n", num); + } + } + sbuf_finish(&sb); + sbuf_delete(&sb); + + /* Decode the value data, creating edit_entries for each value. */ + buff_decode_visit(desc, len, format, editentry_create_desc, 0); +} + +static void editlist_save(struct cam_device *device, int cdb_len, int dbd, int pc, int page, int subpage, int task_attr, int retries, int timeout) { - u_int8_t data[MAX_DATA_SIZE];/* Buffer to hold sense data. */ + u_int8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */ u_int8_t *mode_pars; /* Pointer to modepage params. */ struct scsi_mode_page_header *mph; struct scsi_mode_page_header_sp *mphsp; @@ -603,7 +715,7 @@ editlist_save(struct cam_device *device, int cdb_len, return; /* Preload the CDB buffer with the current mode page data. */ - mode_sense(device, &cdb_len, dbd, pc, page, subpage, task_attr, + mode_sense(device, &cdb_len, dbd, 0, pc, page, subpage, task_attr, retries, timeout, data, sizeof(data)); /* Initial headers & offsets. */ @@ -676,6 +788,56 @@ editlist_save(struct cam_device *device, int cdb_len, task_attr, retries, timeout, data, hlen + mphlen + len); } +static void +editlist_save_desc(struct cam_device *device, int cdb_len, int llbaa, int pc, + int page, int subpage, int task_attr, int retries, int timeout) +{ + uint8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */ + uint8_t *desc; /* Pointer to block descriptor. */ + size_t len, hlen; + + /* Make sure that something changed before continuing. */ + if (! editlist_changed) + return; + + /* Preload the CDB buffer with the current mode page data. */ + mode_sense(device, &cdb_len, 0, llbaa, pc, page, subpage, task_attr, + retries, timeout, data, sizeof(data)); + + /* Initial headers & offsets. */ + if (cdb_len == 6) { + struct scsi_mode_header_6 *mh = + (struct scsi_mode_header_6 *)data; + hlen = sizeof(*mh); + desc = (uint8_t *)(mh + 1); + len = mh->blk_desc_len; + mh->data_length = 0; /* Reserved for MODE SELECT command. */ + if (device->pd_type != T_SEQUENTIAL) + mh->dev_spec = 0; /* See comment above */ + } else { + struct scsi_mode_header_10 *mh = + (struct scsi_mode_header_10 *)data; + hlen = sizeof(*mh); + desc = (uint8_t *)(mh + 1); + len = scsi_2btoul(mh->blk_desc_len); + scsi_ulto2b(0, mh->data_length); /* Reserved for MODE SELECT. */ + if (device->pd_type != T_SEQUENTIAL) + mh->dev_spec = 0; /* See comment above */ + } + len = MIN(len, sizeof(data) - (desc - data)); + + /* Encode the value data to be passed back to the device. */ + buff_encode_visit(desc, len, format, editentry_save, 0); + + /* + * Write the changes back to the device. If the user editted control + * page 3 (saved values) then request the changes be permanently + * recorded. + */ + mode_select(device, cdb_len, (pc << PAGE_CTRL_SHIFT == SMS_PAGE_CTRL_SAVED), + task_attr, retries, timeout, data, hlen + len); +} + static int modepage_write(FILE *file, int editonly) { @@ -689,7 +851,7 @@ modepage_write(FILE *file, int editonly) fprintf(file, "%s: %s\n", scan->name, scan->value.svalue); } else { - fprintf(file, "%s: %d\n", scan->name, + fprintf(file, "%s: %u\n", scan->name, scan->value.ivalue); } } @@ -845,13 +1007,13 @@ static void modepage_dump(struct cam_device *device, int cdb_len, int dbd, int pc, int page, int subpage, int task_attr, int retries, int timeout) { - u_int8_t data[MAX_DATA_SIZE];/* Buffer to hold sense data. */ + u_int8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */ u_int8_t *mode_pars; /* Pointer to modepage params. */ struct scsi_mode_page_header *mph; struct scsi_mode_page_header_sp *mphsp; size_t indx, len; - mode_sense(device, &cdb_len, dbd, pc, page, subpage, task_attr, + mode_sense(device, &cdb_len, dbd, 0, pc, page, subpage, task_attr, retries, timeout, data, sizeof(data)); if (cdb_len == 6) { @@ -880,7 +1042,38 @@ modepage_dump(struct cam_device *device, int cdb_len, } putchar('\n'); } +static void +modepage_dump_desc(struct cam_device *device, int cdb_len, int llbaa, int pc, + int page, int subpage, int task_attr, int retries, int timeout) +{ + uint8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */ + uint8_t *desc; /* Pointer to block descriptor. */ + size_t indx, len; + mode_sense(device, &cdb_len, 0, llbaa, pc, page, subpage, task_attr, + retries, timeout, data, sizeof(data)); + + if (cdb_len == 6) { + struct scsi_mode_header_6 *mh = + (struct scsi_mode_header_6 *)data; + desc = (uint8_t *)(mh + 1); + len = mh->blk_desc_len; + } else { + struct scsi_mode_header_10 *mh = + (struct scsi_mode_header_10 *)data; + desc = (uint8_t *)(mh + 1); + len = scsi_2btoul(mh->blk_desc_len); + } + len = MIN(len, sizeof(data) - (desc - data)); + + /* Print the raw mode page data with newlines each 8 bytes. */ + for (indx = 0; indx < len; indx++) { + printf("%02x%c", desc[indx], + (((indx + 1) % 8) == 0) ? '\n' : ' '); + } + putchar('\n'); +} + static void cleanup_editfile(void) { @@ -892,16 +1085,19 @@ cleanup_editfile(void) } void -mode_edit(struct cam_device *device, int cdb_len, int dbd, int pc, int page, - int subpage, int edit, int binary, int task_attr, int retry_count, - int timeout) +mode_edit(struct cam_device *device, int cdb_len, int desc, int dbd, int llbaa, + int pc, int page, int subpage, int edit, int binary, int task_attr, + int retry_count, int timeout) { const char *pagedb_path; /* Path to modepage database. */ - if (edit && binary) - errx(EX_USAGE, "cannot edit in binary mode."); - - if (! binary) { + if (binary) { + if (edit) + errx(EX_USAGE, "cannot edit in binary mode."); + } else if (desc) { + editlist_populate_desc(device, cdb_len, llbaa, pc, page, + subpage, task_attr, retry_count, timeout); + } else { if ((pagedb_path = getenv("SCSI_MODES")) == NULL) pagedb_path = DEFAULT_SCSI_MODE_DB; @@ -935,12 +1131,22 @@ mode_edit(struct cam_device *device, int cdb_len, int errx(EX_USAGE, "it only makes sense to edit page 0 " "(current) or page 3 (saved values)"); modepage_edit(); - editlist_save(device, cdb_len, dbd, pc, page, subpage, - task_attr, retry_count, timeout); + if (desc) { + editlist_save_desc(device, cdb_len, llbaa, pc, page, + subpage, task_attr, retry_count, timeout); + } else { + editlist_save(device, cdb_len, dbd, pc, page, subpage, + task_attr, retry_count, timeout); + } } else if (binary || STAILQ_EMPTY(&editlist)) { /* Display without formatting information. */ - modepage_dump(device, cdb_len, dbd, pc, page, subpage, - task_attr, retry_count, timeout); + if (desc) { + modepage_dump_desc(device, cdb_len, llbaa, pc, page, + subpage, task_attr, retry_count, timeout); + } else { + modepage_dump(device, cdb_len, dbd, pc, page, subpage, + task_attr, retry_count, timeout); + } } else { /* Display with format. */ modepage_write(stdout, 0); @@ -951,7 +1157,7 @@ void mode_list(struct cam_device *device, int cdb_len, int dbd, int pc, int subpages, int task_attr, int retry_count, int timeout) { - u_int8_t data[MAX_DATA_SIZE];/* Buffer to hold sense data. */ + u_int8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */ struct scsi_mode_page_header *mph; struct scsi_mode_page_header_sp *mphsp; struct pagename *nameentry; @@ -967,7 +1173,7 @@ mode_list(struct cam_device *device, int cdb_len, int } /* Build the list of all mode pages by querying the "all pages" page. */ - mode_sense(device, &cdb_len, dbd, pc, SMS_ALL_PAGES_PAGE, + mode_sense(device, &cdb_len, dbd, 0, pc, SMS_ALL_PAGES_PAGE, subpages ? SMS_SUBPAGE_ALL : 0, task_attr, retry_count, timeout, data, sizeof(data)); Modified: stable/11/sys/cam/scsi/scsi_all.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_all.c Wed Aug 28 20:22:14 2019 (r351581) +++ stable/11/sys/cam/scsi/scsi_all.c Wed Aug 28 20:23:08 2019 (r351582) @@ -2054,7 +2054,7 @@ static struct asc_table_entry asc_table[] = { { SST(0x30, 0x13, SS_RDEF, /* XXX TBD */ "Cleaning volume expired") }, /* DT WRO BK */ - { SST(0x31, 0x00, SS_RDEF, + { SST(0x31, 0x00, SS_FATAL | ENXIO, "Medium format corrupted") }, /* D L RO B */ { SST(0x31, 0x01, SS_RDEF, Modified: stable/11/sys/cam/scsi/scsi_all.h ============================================================================== --- stable/11/sys/cam/scsi/scsi_all.h Wed Aug 28 20:22:14 2019 (r351581) +++ stable/11/sys/cam/scsi/scsi_all.h Wed Aug 28 20:23:08 2019 (r351582) @@ -3574,7 +3574,9 @@ struct scsi_mode_header_10 u_int8_t data_length[2];/* Sense data length */ u_int8_t medium_type; u_int8_t dev_spec; - u_int8_t unused[2]; + u_int8_t flags; +#define SMH_LONGLBA 0x01 + u_int8_t unused; u_int8_t blk_desc_len[2]; }; From owner-svn-src-stable-11@freebsd.org Wed Aug 28 20:23:49 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F1A43E5996; Wed, 28 Aug 2019 20:23:49 +0000 (UTC) (envelope-from mav@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 46Jcdd68MSz4fn8; Wed, 28 Aug 2019 20:23:49 +0000 (UTC) (envelope-from mav@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 B4CABCF14; Wed, 28 Aug 2019 20:23:49 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7SKNnsh070322; Wed, 28 Aug 2019 20:23:49 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7SKNnaS070321; Wed, 28 Aug 2019 20:23:49 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908282023.x7SKNnaS070321@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 28 Aug 2019 20:23:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351583 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/camcontrol X-SVN-Commit-Revision: 351583 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Aug 2019 20:23:50 -0000 Author: mav Date: Wed Aug 28 20:23:49 2019 New Revision: 351583 URL: https://svnweb.freebsd.org/changeset/base/351583 Log: MFC r350677: Make GCC happy about math in r350676. Modified: stable/11/sbin/camcontrol/modeedit.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/modeedit.c ============================================================================== --- stable/11/sbin/camcontrol/modeedit.c Wed Aug 28 20:23:08 2019 (r351582) +++ stable/11/sbin/camcontrol/modeedit.c Wed Aug 28 20:23:49 2019 (r351583) @@ -295,11 +295,8 @@ editentry_set(char *name, char *newvalue, int editonly /* * Macro to determine the maximum value of the given size for the current * resolution. - * XXX Lovely x86's optimize out the case of shifting by 32 and gcc doesn't - * currently workaround it (even for int64's), so we have to kludge it. */ -#define RESOLUTION_MAX(size) ((resolution * (size) == 32)? \ - UINT_MAX: (1 << (resolution * (size))) - 1) +#define RESOLUTION_MAX(size) ((1LL << (resolution * (size))) - 1) assert(newvalue != NULL); if (*newvalue == '\0') From owner-svn-src-stable-11@freebsd.org Wed Aug 28 20:58:25 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A3A7EE6438; Wed, 28 Aug 2019 20:58:25 +0000 (UTC) (envelope-from mav@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 46JdPY3mVwz3DLF; Wed, 28 Aug 2019 20:58:25 +0000 (UTC) (envelope-from mav@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 5FC9AD482; Wed, 28 Aug 2019 20:58:25 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7SKwP6j088801; Wed, 28 Aug 2019 20:58:25 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7SKwPuG088800; Wed, 28 Aug 2019 20:58:25 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908282058.x7SKwPuG088800@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 28 Aug 2019 20:58:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351586 - stable/11/sys/dev/nvme X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/nvme X-SVN-Commit-Revision: 351586 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Aug 2019 20:58:25 -0000 Author: mav Date: Wed Aug 28 20:58:24 2019 New Revision: 351586 URL: https://svnweb.freebsd.org/changeset/base/351586 Log: MFC r351320: Formalize NVMe controller consumer life cycle. This fixes possible double call of fail_fn, for example on hot removal. It also allows ctrlr_fn to safely return NULL cookie in case of failure and not get useless ns_fn or fail_fn call with NULL cookie later. Modified: stable/11/sys/dev/nvme/nvme.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/nvme/nvme.c ============================================================================== --- stable/11/sys/dev/nvme/nvme.c Wed Aug 28 20:35:23 2019 (r351585) +++ stable/11/sys/dev/nvme/nvme.c Wed Aug 28 20:58:24 2019 (r351586) @@ -316,16 +316,21 @@ nvme_notify(struct nvme_consumer *cons, return; cmpset = atomic_cmpset_32(&ctrlr->notification_sent, 0, 1); - if (cmpset == 0) return; if (cons->ctrlr_fn != NULL) ctrlr_cookie = (*cons->ctrlr_fn)(ctrlr); else - ctrlr_cookie = NULL; + ctrlr_cookie = (void *)(uintptr_t)0xdeadc0dedeadc0de; ctrlr->cons_cookie[cons->id] = ctrlr_cookie; + + /* ctrlr_fn has failed. Nothing to notify here any more. */ + if (ctrlr_cookie == NULL) + return; + if (ctrlr->is_failed) { + ctrlr->cons_cookie[cons->id] = NULL; if (cons->fail_fn != NULL) (*cons->fail_fn)(ctrlr_cookie); /* @@ -381,13 +386,16 @@ nvme_notify_async_consumers(struct nvme_controller *ct uint32_t log_page_size) { struct nvme_consumer *cons; + void *ctrlr_cookie; uint32_t i; for (i = 0; i < NVME_MAX_CONSUMERS; i++) { cons = &nvme_consumer[i]; - if (cons->id != INVALID_CONSUMER_ID && cons->async_fn != NULL) - (*cons->async_fn)(ctrlr->cons_cookie[i], async_cpl, + if (cons->id != INVALID_CONSUMER_ID && cons->async_fn != NULL && + (ctrlr_cookie = ctrlr->cons_cookie[i]) != NULL) { + (*cons->async_fn)(ctrlr_cookie, async_cpl, log_page_id, log_page_buffer, log_page_size); + } } } @@ -395,6 +403,7 @@ void nvme_notify_fail_consumers(struct nvme_controller *ctrlr) { struct nvme_consumer *cons; + void *ctrlr_cookie; uint32_t i; /* @@ -408,8 +417,12 @@ nvme_notify_fail_consumers(struct nvme_controller *ctr for (i = 0; i < NVME_MAX_CONSUMERS; i++) { cons = &nvme_consumer[i]; - if (cons->id != INVALID_CONSUMER_ID && cons->fail_fn != NULL) - cons->fail_fn(ctrlr->cons_cookie[i]); + if (cons->id != INVALID_CONSUMER_ID && + (ctrlr_cookie = ctrlr->cons_cookie[i]) != NULL) { + ctrlr->cons_cookie[i] = NULL; + if (cons->fail_fn != NULL) + cons->fail_fn(ctrlr_cookie); + } } } From owner-svn-src-stable-11@freebsd.org Wed Aug 28 21:13:29 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8D0C0E6A76; Wed, 28 Aug 2019 21:13:29 +0000 (UTC) (envelope-from mav@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 46Jdkx3CX9z3FXB; Wed, 28 Aug 2019 21:13:29 +0000 (UTC) (envelope-from mav@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 4FFA3D80D; Wed, 28 Aug 2019 21:13:29 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7SLDTPW000859; Wed, 28 Aug 2019 21:13:29 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7SLDS8Q000857; Wed, 28 Aug 2019 21:13:28 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908282113.x7SLDS8Q000857@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 28 Aug 2019 21:13:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351588 - stable/11/sys/dev/nvme X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/nvme X-SVN-Commit-Revision: 351588 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Aug 2019 21:13:29 -0000 Author: mav Date: Wed Aug 28 21:13:28 2019 New Revision: 351588 URL: https://svnweb.freebsd.org/changeset/base/351588 Log: MFC r351352: Improve NVMe hot unplug handling. If device is unplugged from the system (CSTS register reads return 0xffffffff), it makes no sense to send any more recovery requests or expect any responses back. If there is a detach call in such state, just stop all activity and free resources. If there is no detach call (hot-plug is not supported), rely on normal timeout handling, but when it trigger controller reset, do not wait for impossible and quickly report failure. Sponsored by: iXsystems, Inc. Modified: stable/11/sys/dev/nvme/nvme_ctrlr.c stable/11/sys/dev/nvme/nvme_qpair.c Modified: stable/11/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- stable/11/sys/dev/nvme/nvme_ctrlr.c Wed Aug 28 21:01:51 2019 (r351587) +++ stable/11/sys/dev/nvme/nvme_ctrlr.c Wed Aug 28 21:13:28 2019 (r351588) @@ -202,10 +202,13 @@ nvme_ctrlr_fail(struct nvme_controller *ctrlr) int i; ctrlr->is_failed = TRUE; + nvme_admin_qpair_disable(&ctrlr->adminq); nvme_qpair_fail(&ctrlr->adminq); if (ctrlr->ioq != NULL) { - for (i = 0; i < ctrlr->num_io_queues; i++) + for (i = 0; i < ctrlr->num_io_queues; i++) { + nvme_io_qpair_disable(&ctrlr->ioq[i]); nvme_qpair_fail(&ctrlr->ioq[i]); + } } nvme_notify_fail_consumers(ctrlr); } @@ -244,17 +247,19 @@ nvme_ctrlr_wait_for_ready(struct nvme_controller *ctrl int ms_waited; union csts_register csts; - csts.raw = nvme_mmio_read_4(ctrlr, csts); - ms_waited = 0; - while (csts.bits.rdy != desired_val) { + while (1) { + csts.raw = nvme_mmio_read_4(ctrlr, csts); + if (csts.raw == 0xffffffff) /* Hot unplug. */ + return (ENXIO); + if (csts.bits.rdy == desired_val) + break; if (ms_waited++ > ctrlr->ready_timeout_in_ms) { nvme_printf(ctrlr, "controller ready did not become %d " "within %d ms\n", desired_val, ctrlr->ready_timeout_in_ms); return (ENXIO); } DELAY(1000); - csts.raw = nvme_mmio_read_4(ctrlr, csts); } return (0); @@ -1229,12 +1234,20 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, de void nvme_ctrlr_destruct(struct nvme_controller *ctrlr, device_t dev) { - int i; + int gone, i; if (ctrlr->resource == NULL) goto nores; - nvme_notify_fail_consumers(ctrlr); + /* + * Check whether it is a hot unplug or a clean driver detach. + * If device is not there any more, skip any shutdown commands. + */ + gone = (nvme_mmio_read_4(ctrlr, csts) == 0xffffffff); + if (gone) + nvme_ctrlr_fail(ctrlr); + else + nvme_notify_fail_consumers(ctrlr); for (i = 0; i < NVME_MAX_NAMESPACES; i++) nvme_ns_destruct(&ctrlr->ns[i]); @@ -1243,11 +1256,11 @@ nvme_ctrlr_destruct(struct nvme_controller *ctrlr, dev destroy_dev(ctrlr->cdev); for (i = 0; i < ctrlr->num_io_queues; i++) { - nvme_ctrlr_destroy_qpair(ctrlr, &ctrlr->ioq[i]); + if (!gone) + nvme_ctrlr_destroy_qpair(ctrlr, &ctrlr->ioq[i]); nvme_io_qpair_destroy(&ctrlr->ioq[i]); } free(ctrlr->ioq, M_NVME); - nvme_admin_qpair_destroy(&ctrlr->adminq); /* @@ -1257,9 +1270,11 @@ nvme_ctrlr_destruct(struct nvme_controller *ctrlr, dev * shutdown notification in case the system is shutdown before * reloading the driver. */ - nvme_ctrlr_shutdown(ctrlr); + if (!gone) + nvme_ctrlr_shutdown(ctrlr); - nvme_ctrlr_disable(ctrlr); + if (!gone) + nvme_ctrlr_disable(ctrlr); if (ctrlr->taskqueue) taskqueue_free(ctrlr->taskqueue); @@ -1296,14 +1311,19 @@ nvme_ctrlr_shutdown(struct nvme_controller *ctrlr) cc.raw = nvme_mmio_read_4(ctrlr, cc); cc.bits.shn = NVME_SHN_NORMAL; nvme_mmio_write_4(ctrlr, cc, cc.raw); - csts.raw = nvme_mmio_read_4(ctrlr, csts); - while ((csts.bits.shst != NVME_SHST_COMPLETE) && (ticks++ < 5*hz)) { - pause("nvme shn", 1); + while (1) { csts.raw = nvme_mmio_read_4(ctrlr, csts); + if (csts.raw == 0xffffffff) /* Hot unplug. */ + break; + if (csts.bits.shst == NVME_SHST_COMPLETE) + break; + if (ticks++ > 5*hz) { + nvme_printf(ctrlr, "did not complete shutdown within" + " 5 seconds of notification\n"); + break; + } + pause("nvme shn", 1); } - if (csts.bits.shst != NVME_SHST_COMPLETE) - nvme_printf(ctrlr, "did not complete shutdown within 5 seconds " - "of notification\n"); } void Modified: stable/11/sys/dev/nvme/nvme_qpair.c ============================================================================== --- stable/11/sys/dev/nvme/nvme_qpair.c Wed Aug 28 21:01:51 2019 (r351587) +++ stable/11/sys/dev/nvme/nvme_qpair.c Wed Aug 28 21:13:28 2019 (r351588) @@ -788,7 +788,8 @@ nvme_timeout(void *arg) nvme_abort_complete, tr); } else { nvme_printf(ctrlr, "Resetting controller due to a timeout%s.\n", - csts.bits.cfs ? " and fatal error status" : ""); + (csts.raw == 0xffffffff) ? " and possible hot unplug" : + (csts.bits.cfs ? " and fatal error status" : "")); nvme_ctrlr_reset(ctrlr); } } From owner-svn-src-stable-11@freebsd.org Thu Aug 29 19:13:31 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4F991DDECB; Thu, 29 Aug 2019 19:13:31 +0000 (UTC) (envelope-from cy@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 46KC2326tzz45Cj; Thu, 29 Aug 2019 19:13:31 +0000 (UTC) (envelope-from cy@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 0FBD7247F1; Thu, 29 Aug 2019 19:13:31 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7TJDUO5083982; Thu, 29 Aug 2019 19:13:30 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7TJDSK8083970; Thu, 29 Aug 2019 19:13:28 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908291913.x7TJDSK8083970@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Thu, 29 Aug 2019 19:13:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351611 - in stable: 11/contrib/wpa/hostapd 11/contrib/wpa/hs20/client 11/contrib/wpa/src/ap 11/contrib/wpa/src/common 11/contrib/wpa/src/crypto 11/contrib/wpa/src/drivers 11/contrib/wp... X-SVN-Group: stable-11 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 11/contrib/wpa/hostapd 11/contrib/wpa/hs20/client 11/contrib/wpa/src/ap 11/contrib/wpa/src/common 11/contrib/wpa/src/crypto 11/contrib/wpa/src/drivers 11/contrib/wpa/src/eap_common 11/contr... X-SVN-Commit-Revision: 351611 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Aug 2019 19:13:31 -0000 Author: cy Date: Thu Aug 29 19:13:27 2019 New Revision: 351611 URL: https://svnweb.freebsd.org/changeset/base/351611 Log: MFC r351397: MFV r346563: Update wpa 2.8 --> 2.9 hostapd: * SAE changes - disable use of groups using Brainpool curves - improved protection against side channel attacks [https://w1.fi/security/2019-6/] * EAP-pwd changes - disable use of groups using Brainpool curves - improved protection against side channel attacks [https://w1.fi/security/2019-6/] * fixed FT-EAP initial mobility domain association using PMKSA caching * added configuration of airtime policy * fixed FILS to and RSNE into (Re)Association Response frames * fixed DPP bootstrapping URI parser of channel list * added support for regulatory WMM limitation (for ETSI) * added support for MACsec Key Agreement using IEEE 802.1X/PSK * added experimental support for EAP-TEAP server (RFC 7170) * added experimental support for EAP-TLS server with TLS v1.3 * added support for two server certificates/keys (RSA/ECC) * added AKMSuiteSelector into "STA " control interface data to determine with AKM was used for an association * added eap_sim_id parameter to allow EAP-SIM/AKA server pseudonym and fast reauthentication use to be disabled * fixed an ECDH operation corner case with OpenSSL wpa_supplicant: * SAE changes - disable use of groups using Brainpool curves - improved protection against side channel attacks [https://w1.fi/security/2019-6/] * EAP-pwd changes - disable use of groups using Brainpool curves - allow the set of groups to be configured (eap_pwd_groups) - improved protection against side channel attacks [https://w1.fi/security/2019-6/] * fixed FT-EAP initial mobility domain association using PMKSA caching (disabled by default for backwards compatibility; can be enabled with ft_eap_pmksa_caching=1) * fixed a regression in OpenSSL 1.1+ engine loading * added validation of RSNE in (Re)Association Response frames * fixed DPP bootstrapping URI parser of channel list * extended EAP-SIM/AKA fast re-authentication to allow use with FILS * extended ca_cert_blob to support PEM format * improved robustness of P2P Action frame scheduling * added support for EAP-SIM/AKA using anonymous@realm identity * fixed Hotspot 2.0 credential selection based on roaming consortium to ignore credentials without a specific EAP method * added experimental support for EAP-TEAP peer (RFC 7170) * added experimental support for EAP-TLS peer with TLS v1.3 * fixed a regression in WMM parameter configuration for a TDLS peer * fixed a regression in operation with drivers that offload 802.1X 4-way handshake * fixed an ECDH operation corner case with OpenSSL Security: https://w1.fi/security/2019-6/\ sae-eap-pwd-side-channel-attack-update.txt Added: stable/11/contrib/wpa/src/ap/airtime_policy.c - copied unchanged from r351397, head/contrib/wpa/src/ap/airtime_policy.c stable/11/contrib/wpa/src/ap/airtime_policy.h - copied unchanged from r351397, head/contrib/wpa/src/ap/airtime_policy.h stable/11/contrib/wpa/src/ap/wpa_auth_kay.c - copied unchanged from r351397, head/contrib/wpa/src/ap/wpa_auth_kay.c stable/11/contrib/wpa/src/ap/wpa_auth_kay.h - copied unchanged from r351397, head/contrib/wpa/src/ap/wpa_auth_kay.h stable/11/contrib/wpa/src/common/dragonfly.c - copied unchanged from r351397, head/contrib/wpa/src/common/dragonfly.c stable/11/contrib/wpa/src/common/dragonfly.h - copied unchanged from r351397, head/contrib/wpa/src/common/dragonfly.h stable/11/contrib/wpa/src/drivers/driver_atheros.c - copied unchanged from r351397, head/contrib/wpa/src/drivers/driver_atheros.c stable/11/contrib/wpa/src/drivers/driver_hostap.c - copied unchanged from r351397, head/contrib/wpa/src/drivers/driver_hostap.c stable/11/contrib/wpa/src/drivers/nl80211_copy.h - copied unchanged from r351397, head/contrib/wpa/src/drivers/nl80211_copy.h stable/11/contrib/wpa/src/eap_common/eap_teap_common.c - copied unchanged from r351397, head/contrib/wpa/src/eap_common/eap_teap_common.c stable/11/contrib/wpa/src/eap_common/eap_teap_common.h - copied unchanged from r351397, head/contrib/wpa/src/eap_common/eap_teap_common.h stable/11/contrib/wpa/src/eap_peer/eap_teap.c - copied unchanged from r351397, head/contrib/wpa/src/eap_peer/eap_teap.c stable/11/contrib/wpa/src/eap_peer/eap_teap_pac.c - copied unchanged from r351397, head/contrib/wpa/src/eap_peer/eap_teap_pac.c stable/11/contrib/wpa/src/eap_peer/eap_teap_pac.h - copied unchanged from r351397, head/contrib/wpa/src/eap_peer/eap_teap_pac.h stable/11/contrib/wpa/src/eap_server/eap_server_teap.c - copied unchanged from r351397, head/contrib/wpa/src/eap_server/eap_server_teap.c Modified: stable/11/contrib/wpa/hostapd/ChangeLog stable/11/contrib/wpa/hostapd/config_file.c stable/11/contrib/wpa/hostapd/ctrl_iface.c stable/11/contrib/wpa/hostapd/defconfig stable/11/contrib/wpa/hostapd/eap_register.c stable/11/contrib/wpa/hostapd/hostapd.conf stable/11/contrib/wpa/hostapd/hostapd_cli.c stable/11/contrib/wpa/hostapd/main.c stable/11/contrib/wpa/hs20/client/osu_client.c stable/11/contrib/wpa/src/ap/accounting.c stable/11/contrib/wpa/src/ap/acs.c stable/11/contrib/wpa/src/ap/ap_config.c stable/11/contrib/wpa/src/ap/ap_config.h stable/11/contrib/wpa/src/ap/ap_drv_ops.c stable/11/contrib/wpa/src/ap/ap_drv_ops.h stable/11/contrib/wpa/src/ap/authsrv.c stable/11/contrib/wpa/src/ap/beacon.c stable/11/contrib/wpa/src/ap/ctrl_iface_ap.c stable/11/contrib/wpa/src/ap/dfs.c stable/11/contrib/wpa/src/ap/dpp_hostapd.c stable/11/contrib/wpa/src/ap/dpp_hostapd.h stable/11/contrib/wpa/src/ap/drv_callbacks.c stable/11/contrib/wpa/src/ap/gas_serv.c stable/11/contrib/wpa/src/ap/gas_serv.h stable/11/contrib/wpa/src/ap/hostapd.c stable/11/contrib/wpa/src/ap/hostapd.h stable/11/contrib/wpa/src/ap/hw_features.c stable/11/contrib/wpa/src/ap/ieee802_11.c stable/11/contrib/wpa/src/ap/ieee802_11.h stable/11/contrib/wpa/src/ap/ieee802_11_he.c stable/11/contrib/wpa/src/ap/ieee802_11_vht.c stable/11/contrib/wpa/src/ap/ieee802_1x.c stable/11/contrib/wpa/src/ap/ieee802_1x.h stable/11/contrib/wpa/src/ap/neighbor_db.c stable/11/contrib/wpa/src/ap/sta_info.c stable/11/contrib/wpa/src/ap/sta_info.h stable/11/contrib/wpa/src/ap/wmm.c stable/11/contrib/wpa/src/ap/wpa_auth.c stable/11/contrib/wpa/src/ap/wpa_auth.h stable/11/contrib/wpa/src/ap/wpa_auth_ft.c stable/11/contrib/wpa/src/ap/wpa_auth_glue.c stable/11/contrib/wpa/src/ap/wpa_auth_ie.c stable/11/contrib/wpa/src/common/dpp.c stable/11/contrib/wpa/src/common/dpp.h stable/11/contrib/wpa/src/common/hw_features_common.c stable/11/contrib/wpa/src/common/hw_features_common.h stable/11/contrib/wpa/src/common/ieee802_11_common.c stable/11/contrib/wpa/src/common/ieee802_11_common.h stable/11/contrib/wpa/src/common/ieee802_11_defs.h stable/11/contrib/wpa/src/common/qca-vendor.h stable/11/contrib/wpa/src/common/sae.c stable/11/contrib/wpa/src/common/sae.h stable/11/contrib/wpa/src/common/version.h stable/11/contrib/wpa/src/common/wpa_common.c stable/11/contrib/wpa/src/common/wpa_ctrl.h stable/11/contrib/wpa/src/crypto/aes_i.h stable/11/contrib/wpa/src/crypto/crypto.h stable/11/contrib/wpa/src/crypto/crypto_openssl.c stable/11/contrib/wpa/src/crypto/crypto_wolfssl.c stable/11/contrib/wpa/src/crypto/sha1-internal.c stable/11/contrib/wpa/src/crypto/sha1-prf.c stable/11/contrib/wpa/src/crypto/sha1-tlsprf.c stable/11/contrib/wpa/src/crypto/sha1-tprf.c stable/11/contrib/wpa/src/crypto/sha1.c stable/11/contrib/wpa/src/crypto/sha256-kdf.c stable/11/contrib/wpa/src/crypto/sha256-prf.c stable/11/contrib/wpa/src/crypto/sha256-tlsprf.c stable/11/contrib/wpa/src/crypto/sha256.h stable/11/contrib/wpa/src/crypto/sha384-kdf.c stable/11/contrib/wpa/src/crypto/sha384-prf.c stable/11/contrib/wpa/src/crypto/sha512-kdf.c stable/11/contrib/wpa/src/crypto/sha512-prf.c stable/11/contrib/wpa/src/crypto/tls.h stable/11/contrib/wpa/src/crypto/tls_openssl.c stable/11/contrib/wpa/src/crypto/tls_wolfssl.c stable/11/contrib/wpa/src/drivers/driver.h stable/11/contrib/wpa/src/drivers/driver_bsd.c stable/11/contrib/wpa/src/drivers/driver_common.c stable/11/contrib/wpa/src/drivers/driver_macsec_linux.c stable/11/contrib/wpa/src/drivers/driver_macsec_qca.c stable/11/contrib/wpa/src/drivers/driver_ndis.c stable/11/contrib/wpa/src/drivers/driver_nl80211.h stable/11/contrib/wpa/src/drivers/driver_nl80211_capa.c stable/11/contrib/wpa/src/drivers/driver_nl80211_event.c stable/11/contrib/wpa/src/drivers/driver_privsep.c stable/11/contrib/wpa/src/eap_common/eap_defs.h stable/11/contrib/wpa/src/eap_common/eap_pwd_common.c stable/11/contrib/wpa/src/eap_common/eap_sim_common.c stable/11/contrib/wpa/src/eap_common/eap_sim_common.h stable/11/contrib/wpa/src/eap_peer/eap.c stable/11/contrib/wpa/src/eap_peer/eap.h stable/11/contrib/wpa/src/eap_peer/eap_aka.c stable/11/contrib/wpa/src/eap_peer/eap_config.h stable/11/contrib/wpa/src/eap_peer/eap_eke.c stable/11/contrib/wpa/src/eap_peer/eap_leap.c stable/11/contrib/wpa/src/eap_peer/eap_methods.h stable/11/contrib/wpa/src/eap_peer/eap_peap.c stable/11/contrib/wpa/src/eap_peer/eap_pwd.c stable/11/contrib/wpa/src/eap_peer/eap_sim.c stable/11/contrib/wpa/src/eap_peer/eap_tls.c stable/11/contrib/wpa/src/eap_peer/eap_tls_common.c stable/11/contrib/wpa/src/eap_peer/eap_tls_common.h stable/11/contrib/wpa/src/eap_server/eap.h stable/11/contrib/wpa/src/eap_server/eap_i.h stable/11/contrib/wpa/src/eap_server/eap_methods.h stable/11/contrib/wpa/src/eap_server/eap_server.c stable/11/contrib/wpa/src/eap_server/eap_server_aka.c stable/11/contrib/wpa/src/eap_server/eap_server_pax.c stable/11/contrib/wpa/src/eap_server/eap_server_peap.c stable/11/contrib/wpa/src/eap_server/eap_server_pwd.c stable/11/contrib/wpa/src/eap_server/eap_server_sim.c stable/11/contrib/wpa/src/eap_server/eap_server_tls.c stable/11/contrib/wpa/src/eap_server/eap_server_tls_common.c stable/11/contrib/wpa/src/eap_server/eap_tls_common.h stable/11/contrib/wpa/src/eapol_auth/eapol_auth_sm.c stable/11/contrib/wpa/src/eapol_auth/eapol_auth_sm.h stable/11/contrib/wpa/src/eapol_supp/eapol_supp_sm.c stable/11/contrib/wpa/src/eapol_supp/eapol_supp_sm.h stable/11/contrib/wpa/src/p2p/p2p.c stable/11/contrib/wpa/src/p2p/p2p_go_neg.c stable/11/contrib/wpa/src/p2p/p2p_i.h stable/11/contrib/wpa/src/pae/ieee802_1x_kay.c stable/11/contrib/wpa/src/radius/radius_server.c stable/11/contrib/wpa/src/radius/radius_server.h stable/11/contrib/wpa/src/rsn_supp/wpa.c stable/11/contrib/wpa/src/rsn_supp/wpa.h stable/11/contrib/wpa/src/rsn_supp/wpa_ft.c stable/11/contrib/wpa/src/rsn_supp/wpa_i.h stable/11/contrib/wpa/src/tls/asn1.c stable/11/contrib/wpa/src/tls/libtommath.c stable/11/contrib/wpa/src/tls/x509v3.c stable/11/contrib/wpa/src/utils/common.c stable/11/contrib/wpa/src/utils/common.h stable/11/contrib/wpa/src/utils/trace.c stable/11/contrib/wpa/src/utils/wpa_debug.c stable/11/contrib/wpa/src/wps/wps.h stable/11/contrib/wpa/wpa_supplicant/Android.mk stable/11/contrib/wpa/wpa_supplicant/ChangeLog stable/11/contrib/wpa/wpa_supplicant/README-DPP stable/11/contrib/wpa/wpa_supplicant/ap.c stable/11/contrib/wpa/wpa_supplicant/ap.h stable/11/contrib/wpa/wpa_supplicant/bss.c stable/11/contrib/wpa/wpa_supplicant/config.c stable/11/contrib/wpa/wpa_supplicant/config.h stable/11/contrib/wpa/wpa_supplicant/config_file.c stable/11/contrib/wpa/wpa_supplicant/config_ssid.h stable/11/contrib/wpa/wpa_supplicant/ctrl_iface.c stable/11/contrib/wpa/wpa_supplicant/dbus/dbus_new_helpers.c stable/11/contrib/wpa/wpa_supplicant/defconfig stable/11/contrib/wpa/wpa_supplicant/dpp_supplicant.c stable/11/contrib/wpa/wpa_supplicant/dpp_supplicant.h stable/11/contrib/wpa/wpa_supplicant/driver_i.h stable/11/contrib/wpa/wpa_supplicant/eap_register.c stable/11/contrib/wpa/wpa_supplicant/eapol_test.c stable/11/contrib/wpa/wpa_supplicant/events.c stable/11/contrib/wpa/wpa_supplicant/ibss_rsn.c stable/11/contrib/wpa/wpa_supplicant/interworking.c stable/11/contrib/wpa/wpa_supplicant/mesh.c stable/11/contrib/wpa/wpa_supplicant/mesh_mpm.c stable/11/contrib/wpa/wpa_supplicant/notify.c stable/11/contrib/wpa/wpa_supplicant/notify.h stable/11/contrib/wpa/wpa_supplicant/op_classes.c stable/11/contrib/wpa/wpa_supplicant/p2p_supplicant.c stable/11/contrib/wpa/wpa_supplicant/preauth_test.c stable/11/contrib/wpa/wpa_supplicant/rrm.c stable/11/contrib/wpa/wpa_supplicant/sme.c stable/11/contrib/wpa/wpa_supplicant/wnm_sta.c stable/11/contrib/wpa/wpa_supplicant/wpa_cli.c stable/11/contrib/wpa/wpa_supplicant/wpa_supplicant.c stable/11/contrib/wpa/wpa_supplicant/wpa_supplicant.conf stable/11/contrib/wpa/wpa_supplicant/wpa_supplicant_i.h stable/11/contrib/wpa/wpa_supplicant/wpas_glue.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Added: stable/12/contrib/wpa/src/ap/airtime_policy.c - copied unchanged from r351397, head/contrib/wpa/src/ap/airtime_policy.c stable/12/contrib/wpa/src/ap/airtime_policy.h - copied unchanged from r351397, head/contrib/wpa/src/ap/airtime_policy.h stable/12/contrib/wpa/src/ap/wpa_auth_kay.c - copied unchanged from r351397, head/contrib/wpa/src/ap/wpa_auth_kay.c stable/12/contrib/wpa/src/ap/wpa_auth_kay.h - copied unchanged from r351397, head/contrib/wpa/src/ap/wpa_auth_kay.h stable/12/contrib/wpa/src/common/dragonfly.c - copied unchanged from r351397, head/contrib/wpa/src/common/dragonfly.c stable/12/contrib/wpa/src/common/dragonfly.h - copied unchanged from r351397, head/contrib/wpa/src/common/dragonfly.h stable/12/contrib/wpa/src/drivers/driver_atheros.c - copied unchanged from r351397, head/contrib/wpa/src/drivers/driver_atheros.c stable/12/contrib/wpa/src/drivers/driver_hostap.c - copied unchanged from r351397, head/contrib/wpa/src/drivers/driver_hostap.c stable/12/contrib/wpa/src/drivers/nl80211_copy.h - copied unchanged from r351397, head/contrib/wpa/src/drivers/nl80211_copy.h stable/12/contrib/wpa/src/eap_common/eap_teap_common.c - copied unchanged from r351397, head/contrib/wpa/src/eap_common/eap_teap_common.c stable/12/contrib/wpa/src/eap_common/eap_teap_common.h - copied unchanged from r351397, head/contrib/wpa/src/eap_common/eap_teap_common.h stable/12/contrib/wpa/src/eap_peer/eap_teap.c - copied unchanged from r351397, head/contrib/wpa/src/eap_peer/eap_teap.c stable/12/contrib/wpa/src/eap_peer/eap_teap_pac.c - copied unchanged from r351397, head/contrib/wpa/src/eap_peer/eap_teap_pac.c stable/12/contrib/wpa/src/eap_peer/eap_teap_pac.h - copied unchanged from r351397, head/contrib/wpa/src/eap_peer/eap_teap_pac.h stable/12/contrib/wpa/src/eap_server/eap_server_teap.c - copied unchanged from r351397, head/contrib/wpa/src/eap_server/eap_server_teap.c Modified: stable/12/contrib/wpa/hostapd/ChangeLog stable/12/contrib/wpa/hostapd/config_file.c stable/12/contrib/wpa/hostapd/ctrl_iface.c stable/12/contrib/wpa/hostapd/defconfig stable/12/contrib/wpa/hostapd/eap_register.c stable/12/contrib/wpa/hostapd/hostapd.conf stable/12/contrib/wpa/hostapd/hostapd_cli.c stable/12/contrib/wpa/hostapd/main.c stable/12/contrib/wpa/hs20/client/osu_client.c stable/12/contrib/wpa/src/ap/accounting.c stable/12/contrib/wpa/src/ap/acs.c stable/12/contrib/wpa/src/ap/ap_config.c stable/12/contrib/wpa/src/ap/ap_config.h stable/12/contrib/wpa/src/ap/ap_drv_ops.c stable/12/contrib/wpa/src/ap/ap_drv_ops.h stable/12/contrib/wpa/src/ap/authsrv.c stable/12/contrib/wpa/src/ap/beacon.c stable/12/contrib/wpa/src/ap/ctrl_iface_ap.c stable/12/contrib/wpa/src/ap/dfs.c stable/12/contrib/wpa/src/ap/dpp_hostapd.c stable/12/contrib/wpa/src/ap/dpp_hostapd.h stable/12/contrib/wpa/src/ap/drv_callbacks.c stable/12/contrib/wpa/src/ap/gas_serv.c stable/12/contrib/wpa/src/ap/gas_serv.h stable/12/contrib/wpa/src/ap/hostapd.c stable/12/contrib/wpa/src/ap/hostapd.h stable/12/contrib/wpa/src/ap/hw_features.c stable/12/contrib/wpa/src/ap/ieee802_11.c stable/12/contrib/wpa/src/ap/ieee802_11.h stable/12/contrib/wpa/src/ap/ieee802_11_he.c stable/12/contrib/wpa/src/ap/ieee802_11_vht.c stable/12/contrib/wpa/src/ap/ieee802_1x.c stable/12/contrib/wpa/src/ap/ieee802_1x.h stable/12/contrib/wpa/src/ap/neighbor_db.c stable/12/contrib/wpa/src/ap/sta_info.c stable/12/contrib/wpa/src/ap/sta_info.h stable/12/contrib/wpa/src/ap/wmm.c stable/12/contrib/wpa/src/ap/wpa_auth.c stable/12/contrib/wpa/src/ap/wpa_auth.h stable/12/contrib/wpa/src/ap/wpa_auth_ft.c stable/12/contrib/wpa/src/ap/wpa_auth_glue.c stable/12/contrib/wpa/src/ap/wpa_auth_ie.c stable/12/contrib/wpa/src/common/dpp.c stable/12/contrib/wpa/src/common/dpp.h stable/12/contrib/wpa/src/common/hw_features_common.c stable/12/contrib/wpa/src/common/hw_features_common.h stable/12/contrib/wpa/src/common/ieee802_11_common.c stable/12/contrib/wpa/src/common/ieee802_11_common.h stable/12/contrib/wpa/src/common/ieee802_11_defs.h stable/12/contrib/wpa/src/common/qca-vendor.h stable/12/contrib/wpa/src/common/sae.c stable/12/contrib/wpa/src/common/sae.h stable/12/contrib/wpa/src/common/version.h stable/12/contrib/wpa/src/common/wpa_common.c stable/12/contrib/wpa/src/common/wpa_ctrl.h stable/12/contrib/wpa/src/crypto/aes_i.h stable/12/contrib/wpa/src/crypto/crypto.h stable/12/contrib/wpa/src/crypto/crypto_openssl.c stable/12/contrib/wpa/src/crypto/crypto_wolfssl.c stable/12/contrib/wpa/src/crypto/sha1-internal.c stable/12/contrib/wpa/src/crypto/sha1-prf.c stable/12/contrib/wpa/src/crypto/sha1-tlsprf.c stable/12/contrib/wpa/src/crypto/sha1-tprf.c stable/12/contrib/wpa/src/crypto/sha1.c stable/12/contrib/wpa/src/crypto/sha256-kdf.c stable/12/contrib/wpa/src/crypto/sha256-prf.c stable/12/contrib/wpa/src/crypto/sha256-tlsprf.c stable/12/contrib/wpa/src/crypto/sha256.h stable/12/contrib/wpa/src/crypto/sha384-kdf.c stable/12/contrib/wpa/src/crypto/sha384-prf.c stable/12/contrib/wpa/src/crypto/sha512-kdf.c stable/12/contrib/wpa/src/crypto/sha512-prf.c stable/12/contrib/wpa/src/crypto/tls.h stable/12/contrib/wpa/src/crypto/tls_openssl.c stable/12/contrib/wpa/src/crypto/tls_wolfssl.c stable/12/contrib/wpa/src/drivers/driver.h stable/12/contrib/wpa/src/drivers/driver_bsd.c stable/12/contrib/wpa/src/drivers/driver_common.c stable/12/contrib/wpa/src/drivers/driver_macsec_linux.c stable/12/contrib/wpa/src/drivers/driver_macsec_qca.c stable/12/contrib/wpa/src/drivers/driver_ndis.c stable/12/contrib/wpa/src/drivers/driver_nl80211.h stable/12/contrib/wpa/src/drivers/driver_nl80211_capa.c stable/12/contrib/wpa/src/drivers/driver_nl80211_event.c stable/12/contrib/wpa/src/drivers/driver_privsep.c stable/12/contrib/wpa/src/eap_common/eap_defs.h stable/12/contrib/wpa/src/eap_common/eap_pwd_common.c stable/12/contrib/wpa/src/eap_common/eap_sim_common.c stable/12/contrib/wpa/src/eap_common/eap_sim_common.h stable/12/contrib/wpa/src/eap_peer/eap.c stable/12/contrib/wpa/src/eap_peer/eap.h stable/12/contrib/wpa/src/eap_peer/eap_aka.c stable/12/contrib/wpa/src/eap_peer/eap_config.h stable/12/contrib/wpa/src/eap_peer/eap_eke.c stable/12/contrib/wpa/src/eap_peer/eap_leap.c stable/12/contrib/wpa/src/eap_peer/eap_methods.h stable/12/contrib/wpa/src/eap_peer/eap_peap.c stable/12/contrib/wpa/src/eap_peer/eap_pwd.c stable/12/contrib/wpa/src/eap_peer/eap_sim.c stable/12/contrib/wpa/src/eap_peer/eap_tls.c stable/12/contrib/wpa/src/eap_peer/eap_tls_common.c stable/12/contrib/wpa/src/eap_peer/eap_tls_common.h stable/12/contrib/wpa/src/eap_server/eap.h stable/12/contrib/wpa/src/eap_server/eap_i.h stable/12/contrib/wpa/src/eap_server/eap_methods.h stable/12/contrib/wpa/src/eap_server/eap_server.c stable/12/contrib/wpa/src/eap_server/eap_server_aka.c stable/12/contrib/wpa/src/eap_server/eap_server_pax.c stable/12/contrib/wpa/src/eap_server/eap_server_peap.c stable/12/contrib/wpa/src/eap_server/eap_server_pwd.c stable/12/contrib/wpa/src/eap_server/eap_server_sim.c stable/12/contrib/wpa/src/eap_server/eap_server_tls.c stable/12/contrib/wpa/src/eap_server/eap_server_tls_common.c stable/12/contrib/wpa/src/eap_server/eap_tls_common.h stable/12/contrib/wpa/src/eapol_auth/eapol_auth_sm.c stable/12/contrib/wpa/src/eapol_auth/eapol_auth_sm.h stable/12/contrib/wpa/src/eapol_supp/eapol_supp_sm.c stable/12/contrib/wpa/src/eapol_supp/eapol_supp_sm.h stable/12/contrib/wpa/src/p2p/p2p.c stable/12/contrib/wpa/src/p2p/p2p_go_neg.c stable/12/contrib/wpa/src/p2p/p2p_i.h stable/12/contrib/wpa/src/pae/ieee802_1x_kay.c stable/12/contrib/wpa/src/radius/radius_server.c stable/12/contrib/wpa/src/radius/radius_server.h stable/12/contrib/wpa/src/rsn_supp/wpa.c stable/12/contrib/wpa/src/rsn_supp/wpa.h stable/12/contrib/wpa/src/rsn_supp/wpa_ft.c stable/12/contrib/wpa/src/rsn_supp/wpa_i.h stable/12/contrib/wpa/src/tls/asn1.c stable/12/contrib/wpa/src/tls/libtommath.c stable/12/contrib/wpa/src/tls/x509v3.c stable/12/contrib/wpa/src/utils/common.c stable/12/contrib/wpa/src/utils/common.h stable/12/contrib/wpa/src/utils/trace.c stable/12/contrib/wpa/src/utils/wpa_debug.c stable/12/contrib/wpa/src/wps/wps.h stable/12/contrib/wpa/wpa_supplicant/Android.mk stable/12/contrib/wpa/wpa_supplicant/ChangeLog stable/12/contrib/wpa/wpa_supplicant/README-DPP stable/12/contrib/wpa/wpa_supplicant/ap.c stable/12/contrib/wpa/wpa_supplicant/ap.h stable/12/contrib/wpa/wpa_supplicant/bss.c stable/12/contrib/wpa/wpa_supplicant/config.c stable/12/contrib/wpa/wpa_supplicant/config.h stable/12/contrib/wpa/wpa_supplicant/config_file.c stable/12/contrib/wpa/wpa_supplicant/config_ssid.h stable/12/contrib/wpa/wpa_supplicant/ctrl_iface.c stable/12/contrib/wpa/wpa_supplicant/dbus/dbus_new_helpers.c stable/12/contrib/wpa/wpa_supplicant/defconfig stable/12/contrib/wpa/wpa_supplicant/dpp_supplicant.c stable/12/contrib/wpa/wpa_supplicant/dpp_supplicant.h stable/12/contrib/wpa/wpa_supplicant/driver_i.h stable/12/contrib/wpa/wpa_supplicant/eap_register.c stable/12/contrib/wpa/wpa_supplicant/eapol_test.c stable/12/contrib/wpa/wpa_supplicant/events.c stable/12/contrib/wpa/wpa_supplicant/ibss_rsn.c stable/12/contrib/wpa/wpa_supplicant/interworking.c stable/12/contrib/wpa/wpa_supplicant/mesh.c stable/12/contrib/wpa/wpa_supplicant/mesh_mpm.c stable/12/contrib/wpa/wpa_supplicant/notify.c stable/12/contrib/wpa/wpa_supplicant/notify.h stable/12/contrib/wpa/wpa_supplicant/op_classes.c stable/12/contrib/wpa/wpa_supplicant/p2p_supplicant.c stable/12/contrib/wpa/wpa_supplicant/preauth_test.c stable/12/contrib/wpa/wpa_supplicant/rrm.c stable/12/contrib/wpa/wpa_supplicant/sme.c stable/12/contrib/wpa/wpa_supplicant/wnm_sta.c stable/12/contrib/wpa/wpa_supplicant/wpa_cli.c stable/12/contrib/wpa/wpa_supplicant/wpa_supplicant.c stable/12/contrib/wpa/wpa_supplicant/wpa_supplicant.conf stable/12/contrib/wpa/wpa_supplicant/wpa_supplicant_i.h stable/12/contrib/wpa/wpa_supplicant/wpas_glue.c Directory Properties: stable/12/ (props changed) Modified: stable/11/contrib/wpa/hostapd/ChangeLog ============================================================================== --- stable/11/contrib/wpa/hostapd/ChangeLog Thu Aug 29 18:53:00 2019 (r351610) +++ stable/11/contrib/wpa/hostapd/ChangeLog Thu Aug 29 19:13:27 2019 (r351611) @@ -1,5 +1,29 @@ ChangeLog for hostapd +2019-08-07 - v2.9 + * SAE changes + - disable use of groups using Brainpool curves + - improved protection against side channel attacks + [https://w1.fi/security/2019-6/] + * EAP-pwd changes + - disable use of groups using Brainpool curves + - improved protection against side channel attacks + [https://w1.fi/security/2019-6/] + * fixed FT-EAP initial mobility domain association using PMKSA caching + * added configuration of airtime policy + * fixed FILS to and RSNE into (Re)Association Response frames + * fixed DPP bootstrapping URI parser of channel list + * added support for regulatory WMM limitation (for ETSI) + * added support for MACsec Key Agreement using IEEE 802.1X/PSK + * added experimental support for EAP-TEAP server (RFC 7170) + * added experimental support for EAP-TLS server with TLS v1.3 + * added support for two server certificates/keys (RSA/ECC) + * added AKMSuiteSelector into "STA " control interface data to + determine with AKM was used for an association + * added eap_sim_id parameter to allow EAP-SIM/AKA server pseudonym and + fast reauthentication use to be disabled + * fixed an ECDH operation corner case with OpenSSL + 2019-04-21 - v2.8 * SAE changes - added support for SAE Password Identifier Modified: stable/11/contrib/wpa/hostapd/config_file.c ============================================================================== --- stable/11/contrib/wpa/hostapd/config_file.c Thu Aug 29 18:53:00 2019 (r351610) +++ stable/11/contrib/wpa/hostapd/config_file.c Thu Aug 29 19:13:27 2019 (r351611) @@ -24,14 +24,6 @@ #include "config_file.h" -#ifndef CONFIG_NO_RADIUS -#ifdef EAP_SERVER -static struct hostapd_radius_attr * -hostapd_parse_radius_attr(const char *value); -#endif /* EAP_SERVER */ -#endif /* CONFIG_NO_RADIUS */ - - #ifndef CONFIG_NO_VLAN static int hostapd_config_read_vlan_file(struct hostapd_bss_config *bss, const char *fname) @@ -660,76 +652,7 @@ hostapd_config_read_radius_addr(struct hostapd_radius_ } -static struct hostapd_radius_attr * -hostapd_parse_radius_attr(const char *value) -{ - const char *pos; - char syntax; - struct hostapd_radius_attr *attr; - size_t len; - attr = os_zalloc(sizeof(*attr)); - if (attr == NULL) - return NULL; - - attr->type = atoi(value); - - pos = os_strchr(value, ':'); - if (pos == NULL) { - attr->val = wpabuf_alloc(1); - if (attr->val == NULL) { - os_free(attr); - return NULL; - } - wpabuf_put_u8(attr->val, 0); - return attr; - } - - pos++; - if (pos[0] == '\0' || pos[1] != ':') { - os_free(attr); - return NULL; - } - syntax = *pos++; - pos++; - - switch (syntax) { - case 's': - attr->val = wpabuf_alloc_copy(pos, os_strlen(pos)); - break; - case 'x': - len = os_strlen(pos); - if (len & 1) - break; - len /= 2; - attr->val = wpabuf_alloc(len); - if (attr->val == NULL) - break; - if (hexstr2bin(pos, wpabuf_put(attr->val, len), len) < 0) { - wpabuf_free(attr->val); - os_free(attr); - return NULL; - } - break; - case 'd': - attr->val = wpabuf_alloc(4); - if (attr->val) - wpabuf_put_be32(attr->val, atoi(pos)); - break; - default: - os_free(attr); - return NULL; - } - - if (attr->val == NULL) { - os_free(attr); - return NULL; - } - - return attr; -} - - static int hostapd_parse_das_client(struct hostapd_bss_config *bss, char *val) { char *secret; @@ -2313,6 +2236,42 @@ static unsigned int parse_tls_flags(const char *val) #endif /* EAP_SERVER */ +#ifdef CONFIG_AIRTIME_POLICY +static int add_airtime_weight(struct hostapd_bss_config *bss, char *value) +{ + struct airtime_sta_weight *wt; + char *pos, *next; + + wt = os_zalloc(sizeof(*wt)); + if (!wt) + return -1; + + /* 02:01:02:03:04:05 10 */ + pos = value; + next = os_strchr(pos, ' '); + if (next) + *next++ = '\0'; + if (!next || hwaddr_aton(pos, wt->addr)) { + wpa_printf(MSG_ERROR, "Invalid station address: '%s'", pos); + os_free(wt); + return -1; + } + + pos = next; + wt->weight = atoi(pos); + if (!wt->weight) { + wpa_printf(MSG_ERROR, "Invalid weight: '%s'", pos); + os_free(wt); + return -1; + } + + wt->next = bss->airtime_weight_list; + bss->airtime_weight_list = wt; + return 0; +} +#endif /* CONFIG_AIRTIME_POLICY */ + + #ifdef CONFIG_SAE static int parse_sae_password(struct hostapd_bss_config *bss, const char *val) { @@ -2376,6 +2335,36 @@ fail: #endif /* CONFIG_SAE */ +#ifdef CONFIG_DPP2 +static int hostapd_dpp_controller_parse(struct hostapd_bss_config *bss, + const char *pos) +{ + struct dpp_controller_conf *conf; + char *val; + + conf = os_zalloc(sizeof(*conf)); + if (!conf) + return -1; + val = get_param(pos, "ipaddr="); + if (!val || hostapd_parse_ip_addr(val, &conf->ipaddr)) + goto fail; + os_free(val); + val = get_param(pos, "pkhash="); + if (!val || os_strlen(val) != 2 * SHA256_MAC_LEN || + hexstr2bin(val, conf->pkhash, SHA256_MAC_LEN) < 0) + goto fail; + os_free(val); + conf->next = bss->dpp_controller; + bss->dpp_controller = conf; + return 0; +fail: + os_free(val); + os_free(conf); + return -1; +} +#endif /* CONFIG_DPP2 */ + + static int hostapd_config_fill(struct hostapd_config *conf, struct hostapd_bss_config *bss, const char *buf, char *pos, int line) @@ -2496,7 +2485,11 @@ static int hostapd_config_fill(struct hostapd_config * } else if (os_strcmp(buf, "eapol_version") == 0) { int eapol_version = atoi(pos); +#ifdef CONFIG_MACSEC + if (eapol_version < 1 || eapol_version > 3) { +#else /* CONFIG_MACSEC */ if (eapol_version < 1 || eapol_version > 2) { +#endif /* CONFIG_MACSEC */ wpa_printf(MSG_ERROR, "Line %d: invalid EAPOL version (%d): '%s'.", line, eapol_version, pos); @@ -2519,12 +2512,21 @@ static int hostapd_config_fill(struct hostapd_config * } else if (os_strcmp(buf, "server_cert") == 0) { os_free(bss->server_cert); bss->server_cert = os_strdup(pos); + } else if (os_strcmp(buf, "server_cert2") == 0) { + os_free(bss->server_cert2); + bss->server_cert2 = os_strdup(pos); } else if (os_strcmp(buf, "private_key") == 0) { os_free(bss->private_key); bss->private_key = os_strdup(pos); + } else if (os_strcmp(buf, "private_key2") == 0) { + os_free(bss->private_key2); + bss->private_key2 = os_strdup(pos); } else if (os_strcmp(buf, "private_key_passwd") == 0) { os_free(bss->private_key_passwd); bss->private_key_passwd = os_strdup(pos); + } else if (os_strcmp(buf, "private_key_passwd2") == 0) { + os_free(bss->private_key_passwd2); + bss->private_key_passwd2 = os_strdup(pos); } else if (os_strcmp(buf, "check_cert_subject") == 0) { if (!pos[0]) { wpa_printf(MSG_ERROR, "Line %d: unknown check_cert_subject '%s'", @@ -2605,6 +2607,20 @@ static int hostapd_config_fill(struct hostapd_config * } else if (os_strcmp(buf, "pac_key_refresh_time") == 0) { bss->pac_key_refresh_time = atoi(pos); #endif /* EAP_SERVER_FAST */ +#ifdef EAP_SERVER_TEAP + } else if (os_strcmp(buf, "eap_teap_auth") == 0) { + int val = atoi(pos); + + if (val < 0 || val > 1) { + wpa_printf(MSG_ERROR, + "Line %d: Invalid eap_teap_auth value", + line); + return 1; + } + bss->eap_teap_auth = val; + } else if (os_strcmp(buf, "eap_teap_pac_no_inner") == 0) { + bss->eap_teap_pac_no_inner = atoi(pos); +#endif /* EAP_SERVER_TEAP */ #ifdef EAP_SERVER_SIM } else if (os_strcmp(buf, "eap_sim_db") == 0) { os_free(bss->eap_sim_db); @@ -2613,6 +2629,8 @@ static int hostapd_config_fill(struct hostapd_config * bss->eap_sim_db_timeout = atoi(pos); } else if (os_strcmp(buf, "eap_sim_aka_result_ind") == 0) { bss->eap_sim_aka_result_ind = atoi(pos); + } else if (os_strcmp(buf, "eap_sim_id") == 0) { + bss->eap_sim_id = atoi(pos); #endif /* EAP_SERVER_SIM */ #ifdef EAP_SERVER_TNC } else if (os_strcmp(buf, "tnc") == 0) { @@ -2816,6 +2834,9 @@ static int hostapd_config_fill(struct hostapd_config * a = a->next; a->next = attr; } + } else if (os_strcmp(buf, "radius_req_attr_sqlite") == 0) { + os_free(bss->radius_req_attr_sqlite); + bss->radius_req_attr_sqlite = os_strdup(pos); } else if (os_strcmp(buf, "radius_das_port") == 0) { bss->radius_das_port = atoi(pos); } else if (os_strcmp(buf, "radius_das_client") == 0) { @@ -3442,6 +3463,8 @@ static int hostapd_config_fill(struct hostapd_config * conf->he_op.he_twt_required = atoi(pos); } else if (os_strcmp(buf, "he_rts_threshold") == 0) { conf->he_op.he_rts_threshold = atoi(pos); + } else if (os_strcmp(buf, "he_basic_mcs_nss_set") == 0) { + conf->he_op.he_basic_mcs_nss_set = atoi(pos); } else if (os_strcmp(buf, "he_mu_edca_qos_info_param_count") == 0) { conf->he_mu_edca.he_qos_info |= set_he_cap(atoi(pos), HE_QOS_INFO_EDCA_PARAM_SET_COUNT); @@ -3526,6 +3549,20 @@ static int hostapd_config_fill(struct hostapd_config * } else if (os_strcmp(buf, "he_mu_edca_ac_vo_timer") == 0) { conf->he_mu_edca.he_mu_ac_vo_param[HE_MU_AC_PARAM_TIMER_IDX] = atoi(pos) & 0xff; + } else if (os_strcmp(buf, "he_spr_sr_control") == 0) { + conf->spr.sr_control = atoi(pos) & 0xff; + } else if (os_strcmp(buf, "he_spr_non_srg_obss_pd_max_offset") == 0) { + conf->spr.non_srg_obss_pd_max_offset = atoi(pos); + } else if (os_strcmp(buf, "he_spr_srg_obss_pd_min_offset") == 0) { + conf->spr.srg_obss_pd_min_offset = atoi(pos); + } else if (os_strcmp(buf, "he_spr_srg_obss_pd_max_offset") == 0) { + conf->spr.srg_obss_pd_max_offset = atoi(pos); + } else if (os_strcmp(buf, "he_oper_chwidth") == 0) { + conf->he_oper_chwidth = atoi(pos); + } else if (os_strcmp(buf, "he_oper_centr_freq_seg0_idx") == 0) { + conf->he_oper_centr_freq_seg0_idx = atoi(pos); + } else if (os_strcmp(buf, "he_oper_centr_freq_seg1_idx") == 0) { + conf->he_oper_centr_freq_seg1_idx = atoi(pos); #endif /* CONFIG_IEEE80211AX */ } else if (os_strcmp(buf, "max_listen_interval") == 0) { bss->max_listen_interval = atoi(pos); @@ -4298,6 +4335,11 @@ static int hostapd_config_fill(struct hostapd_config * } else if (os_strcmp(buf, "dpp_csign") == 0) { if (parse_wpabuf_hex(line, buf, &bss->dpp_csign, pos)) return 1; +#ifdef CONFIG_DPP2 + } else if (os_strcmp(buf, "dpp_controller") == 0) { + if (hostapd_dpp_controller_parse(bss, pos)) + return 1; +#endif /* CONFIG_DPP2 */ #endif /* CONFIG_DPP */ #ifdef CONFIG_OWE } else if (os_strcmp(buf, "owe_transition_bssid") == 0) { @@ -4349,6 +4391,121 @@ static int hostapd_config_fill(struct hostapd_config * conf->rssi_reject_assoc_timeout = atoi(pos); } else if (os_strcmp(buf, "pbss") == 0) { bss->pbss = atoi(pos); +#ifdef CONFIG_AIRTIME_POLICY + } else if (os_strcmp(buf, "airtime_mode") == 0) { + int val = atoi(pos); + + if (val < 0 || val > AIRTIME_MODE_MAX) { + wpa_printf(MSG_ERROR, "Line %d: Unknown airtime_mode", + line); + return 1; + } + conf->airtime_mode = val; + } else if (os_strcmp(buf, "airtime_update_interval") == 0) { + conf->airtime_update_interval = atoi(pos); + } else if (os_strcmp(buf, "airtime_bss_weight") == 0) { + bss->airtime_weight = atoi(pos); + } else if (os_strcmp(buf, "airtime_bss_limit") == 0) { + int val = atoi(pos); + + if (val < 0 || val > 1) { + wpa_printf(MSG_ERROR, + "Line %d: Invalid airtime_bss_limit (must be 0 or 1)", + line); + return 1; + } + bss->airtime_limit = val; + } else if (os_strcmp(buf, "airtime_sta_weight") == 0) { + if (add_airtime_weight(bss, pos) < 0) { + wpa_printf(MSG_ERROR, + "Line %d: Invalid airtime weight '%s'", + line, pos); + return 1; + } +#endif /* CONFIG_AIRTIME_POLICY */ +#ifdef CONFIG_MACSEC + } else if (os_strcmp(buf, "macsec_policy") == 0) { + int macsec_policy = atoi(pos); + + if (macsec_policy < 0 || macsec_policy > 1) { + wpa_printf(MSG_ERROR, + "Line %d: invalid macsec_policy (%d): '%s'.", + line, macsec_policy, pos); + return 1; + } + bss->macsec_policy = macsec_policy; + } else if (os_strcmp(buf, "macsec_integ_only") == 0) { + int macsec_integ_only = atoi(pos); + + if (macsec_integ_only < 0 || macsec_integ_only > 1) { + wpa_printf(MSG_ERROR, + "Line %d: invalid macsec_integ_only (%d): '%s'.", + line, macsec_integ_only, pos); + return 1; + } + bss->macsec_integ_only = macsec_integ_only; + } else if (os_strcmp(buf, "macsec_replay_protect") == 0) { + int macsec_replay_protect = atoi(pos); + + if (macsec_replay_protect < 0 || macsec_replay_protect > 1) { + wpa_printf(MSG_ERROR, + "Line %d: invalid macsec_replay_protect (%d): '%s'.", + line, macsec_replay_protect, pos); + return 1; + } + bss->macsec_replay_protect = macsec_replay_protect; + } else if (os_strcmp(buf, "macsec_replay_window") == 0) { + bss->macsec_replay_window = atoi(pos); + } else if (os_strcmp(buf, "macsec_port") == 0) { + int macsec_port = atoi(pos); + + if (macsec_port < 1 || macsec_port > 65534) { + wpa_printf(MSG_ERROR, + "Line %d: invalid macsec_port (%d): '%s'.", + line, macsec_port, pos); + return 1; + } + bss->macsec_port = macsec_port; + } else if (os_strcmp(buf, "mka_priority") == 0) { + int mka_priority = atoi(pos); + + if (mka_priority < 0 || mka_priority > 255) { + wpa_printf(MSG_ERROR, + "Line %d: invalid mka_priority (%d): '%s'.", + line, mka_priority, pos); + return 1; + } + bss->mka_priority = mka_priority; + } else if (os_strcmp(buf, "mka_cak") == 0) { + size_t len = os_strlen(pos); + + if (len > 2 * MACSEC_CAK_MAX_LEN || + (len != 2 * 16 && len != 2 * 32) || + hexstr2bin(pos, bss->mka_cak, len / 2)) { + wpa_printf(MSG_ERROR, "Line %d: Invalid MKA-CAK '%s'.", + line, pos); + return 1; + } + bss->mka_cak_len = len / 2; + bss->mka_psk_set |= MKA_PSK_SET_CAK; + } else if (os_strcmp(buf, "mka_ckn") == 0) { + size_t len = os_strlen(pos); + + if (len > 2 * MACSEC_CKN_MAX_LEN || /* too long */ + len < 2 || /* too short */ + len % 2 != 0 /* not an integral number of bytes */) { + wpa_printf(MSG_ERROR, "Line %d: Invalid MKA-CKN '%s'.", + line, pos); + return 1; + } + bss->mka_ckn_len = len / 2; + if (hexstr2bin(pos, bss->mka_ckn, bss->mka_ckn_len)) { + wpa_printf(MSG_ERROR, "Line %d: Invalid MKA-CKN '%s'.", + line, pos); + return -1; + } + bss->mka_psk_set |= MKA_PSK_SET_CKN; +#endif /* CONFIG_MACSEC */ } else { wpa_printf(MSG_ERROR, "Line %d: unknown configuration item '%s'", Modified: stable/11/contrib/wpa/hostapd/ctrl_iface.c ============================================================================== --- stable/11/contrib/wpa/hostapd/ctrl_iface.c Thu Aug 29 18:53:00 2019 (r351610) +++ stable/11/contrib/wpa/hostapd/ctrl_iface.c Thu Aug 29 19:13:27 2019 (r351611) @@ -1830,26 +1830,40 @@ static void hostapd_data_test_rx(void *ctx, const u8 * struct iphdr ip; const u8 *pos; unsigned int i; + char extra[30]; - if (len != HWSIM_PACKETLEN) + if (len < sizeof(*eth) + sizeof(ip) || len > HWSIM_PACKETLEN) { + wpa_printf(MSG_DEBUG, + "test data: RX - ignore unexpected length %d", + (int) len); return; + } eth = (const struct ether_header *) buf; os_memcpy(&ip, eth + 1, sizeof(ip)); pos = &buf[sizeof(*eth) + sizeof(ip)]; if (ip.ihl != 5 || ip.version != 4 || - ntohs(ip.tot_len) != HWSIM_IP_LEN) + ntohs(ip.tot_len) > HWSIM_IP_LEN) { + wpa_printf(MSG_DEBUG, + "test data: RX - ignore unexpect IP header"); return; + } - for (i = 0; i < HWSIM_IP_LEN - sizeof(ip); i++) { - if (*pos != (u8) i) + for (i = 0; i < ntohs(ip.tot_len) - sizeof(ip); i++) { + if (*pos != (u8) i) { + wpa_printf(MSG_DEBUG, + "test data: RX - ignore mismatching payload"); return; + } pos++; } - wpa_msg(hapd->msg_ctx, MSG_INFO, "DATA-TEST-RX " MACSTR " " MACSTR, - MAC2STR(eth->ether_dhost), MAC2STR(eth->ether_shost)); + extra[0] = '\0'; + if (ntohs(ip.tot_len) != HWSIM_IP_LEN) + os_snprintf(extra, sizeof(extra), " len=%d", ntohs(ip.tot_len)); + wpa_msg(hapd->msg_ctx, MSG_INFO, "DATA-TEST-RX " MACSTR " " MACSTR "%s", + MAC2STR(eth->ether_dhost), MAC2STR(eth->ether_shost), extra); } @@ -1894,7 +1908,7 @@ static int hostapd_ctrl_iface_data_test_config(struct static int hostapd_ctrl_iface_data_test_tx(struct hostapd_data *hapd, char *cmd) { u8 dst[ETH_ALEN], src[ETH_ALEN]; - char *pos; + char *pos, *pos2; int used; long int val; u8 tos; @@ -1903,11 +1917,12 @@ static int hostapd_ctrl_iface_data_test_tx(struct host struct iphdr *ip; u8 *dpos; unsigned int i; + size_t send_len = HWSIM_IP_LEN; if (hapd->l2_test == NULL) return -1; - /* format: */ + /* format: [len=] */ pos = cmd; used = hwaddr_aton2(pos, dst); @@ -1921,11 +1936,19 @@ static int hostapd_ctrl_iface_data_test_tx(struct host return -1; pos += used; - val = strtol(pos, NULL, 0); + val = strtol(pos, &pos2, 0); if (val < 0 || val > 0xff) return -1; tos = val; + pos = os_strstr(pos2, " len="); + if (pos) { + i = atoi(pos + 5); + if (i < sizeof(*ip) || i > HWSIM_IP_LEN) + return -1; + send_len = i; + } + eth = (struct ether_header *) &buf[2]; os_memcpy(eth->ether_dhost, dst, ETH_ALEN); os_memcpy(eth->ether_shost, src, ETH_ALEN); @@ -1936,17 +1959,17 @@ static int hostapd_ctrl_iface_data_test_tx(struct host ip->version = 4; ip->ttl = 64; ip->tos = tos; - ip->tot_len = htons(HWSIM_IP_LEN); + ip->tot_len = htons(send_len); ip->protocol = 1; ip->saddr = htonl(192U << 24 | 168 << 16 | 1 << 8 | 1); ip->daddr = htonl(192U << 24 | 168 << 16 | 1 << 8 | 2); ip->check = ipv4_hdr_checksum(ip, sizeof(*ip)); dpos = (u8 *) (ip + 1); - for (i = 0; i < HWSIM_IP_LEN - sizeof(*ip); i++) + for (i = 0; i < send_len - sizeof(*ip); i++) *dpos++ = i; if (l2_packet_send(hapd->l2_test, dst, ETHERTYPE_IP, &buf[2], - HWSIM_PACKETLEN) < 0) + sizeof(struct ether_header) + send_len) < 0) return -1; wpa_dbg(hapd->msg_ctx, MSG_DEBUG, "test data: TX dst=" MACSTR Modified: stable/11/contrib/wpa/hostapd/defconfig ============================================================================== --- stable/11/contrib/wpa/hostapd/defconfig Thu Aug 29 18:53:00 2019 (r351610) +++ stable/11/contrib/wpa/hostapd/defconfig Thu Aug 29 19:13:27 2019 (r351611) @@ -108,11 +108,18 @@ CONFIG_EAP_TTLS=y #CONFIG_EAP_GPSK_SHA256=y # EAP-FAST for the integrated EAP server -# Note: If OpenSSL is used as the TLS library, OpenSSL 1.0 or newer is needed -# for EAP-FAST support. Older OpenSSL releases would need to be patched, e.g., -# with openssl-0.9.8x-tls-extensions.patch, to add the needed functions. #CONFIG_EAP_FAST=y +# EAP-TEAP for the integrated EAP server +# Note: The current EAP-TEAP implementation is experimental and should not be +# enabled for production use. The IETF RFC 7170 that defines EAP-TEAP has number +# of conflicting statements and missing details and the implementation has +# vendor specific workarounds for those and as such, may not interoperate with +# any other implementation. This should not be used for anything else than +# experimentation and interoperability testing until those issues has been +# resolved. +#CONFIG_EAP_TEAP=y + # Wi-Fi Protected Setup (WPS) #CONFIG_WPS=y # Enable UPnP support for external WPS Registrars @@ -375,6 +382,9 @@ CONFIG_IPV6=y # Opportunistic Wireless Encryption (OWE) # Experimental implementation of draft-harkins-owe-07.txt #CONFIG_OWE=y + +# Airtime policy support +#CONFIG_AIRTIME_POLICY=y # Override default value for the wpa_disable_eapol_key_retries configuration # parameter. See that parameter in hostapd.conf for more details. Modified: stable/11/contrib/wpa/hostapd/eap_register.c ============================================================================== --- stable/11/contrib/wpa/hostapd/eap_register.c Thu Aug 29 18:53:00 2019 (r351610) +++ stable/11/contrib/wpa/hostapd/eap_register.c Thu Aug 29 19:13:27 2019 (r351611) @@ -121,6 +121,11 @@ int eap_server_register_methods(void) ret = eap_server_fast_register(); #endif /* EAP_SERVER_FAST */ +#ifdef EAP_SERVER_TEAP + if (ret == 0) + ret = eap_server_teap_register(); +#endif /* EAP_SERVER_TEAP */ + #ifdef EAP_SERVER_WSC if (ret == 0) ret = eap_server_wsc_register(); Modified: stable/11/contrib/wpa/hostapd/hostapd.conf ============================================================================== --- stable/11/contrib/wpa/hostapd/hostapd.conf Thu Aug 29 18:53:00 2019 (r351610) +++ stable/11/contrib/wpa/hostapd/hostapd.conf Thu Aug 29 19:13:27 2019 (r351611) @@ -782,10 +782,8 @@ wmm_ac_vo_acm=0 # 1 = supported #he_mu_beamformer=1 -# he_bss_color: BSS color -# 0 = no BSS color (default) -# unsigned integer = BSS color -#he_bss_color=0 +# he_bss_color: BSS color (1-63) +#he_bss_color=1 #he_default_pe_duration: The duration of PE field in an HE PPDU in us # Possible values are 0 us (default), 4 us, 8 us, 12 us, and 16 us @@ -801,6 +799,17 @@ wmm_ac_vo_acm=0 # unsigned integer = duration in units of 16 us #he_rts_threshold=0 +# HE operating channel information; see matching vht_* parameters for details. +#he_oper_chwidth +#he_oper_centr_freq_seg0_idx +#he_oper_centr_freq_seg1_idx + +#he_basic_mcs_nss_set: Basic NSS/MCS set +# 16-bit combination of 2-bit values of Max HE-MCS For 1..8 SS; each 2-bit +# value having following meaning: +# 0 = HE-MCS 0-7, 1 = HE-MCS 0-9, 2 = HE-MCS 0-11, 3 = not supported +#he_basic_mcs_nss_set + #he_mu_edca_qos_info_param_count #he_mu_edca_qos_info_q_ack #he_mu_edca_qos_info_queue_request=1 @@ -825,6 +834,12 @@ wmm_ac_vo_acm=0 #he_mu_edca_ac_vo_ecwmax=15 #he_mu_edca_ac_vo_timer=255 +# Spatial Reuse Parameter Set +#he_spr_sr_control +#he_spr_non_srg_obss_pd_max_offset +#he_spr_srg_obss_pd_min_offset +#he_spr_srg_obss_pd_max_offset + ##### IEEE 802.1X-2004 related configuration ################################## # Require IEEE 802.1X authorization @@ -836,6 +851,8 @@ wmm_ac_vo_acm=0 # the new version number correctly (they seem to drop the frames completely). # In order to make hostapd interoperate with these clients, the version number # can be set to the older version (1) with this configuration value. +# Note: When using MACsec, eapol_version shall be set to 3, which is +# defined in IEEE Std 802.1X-2010. #eapol_version=2 # Optional displayable message sent with EAP Request-Identity. The first \0 @@ -879,6 +896,54 @@ eapol_key_index_workaround=0 # ERP is enabled (eap_server_erp=1). #erp_domain=example.com +##### MACsec ################################################################## + +# macsec_policy: IEEE 802.1X/MACsec options +# This determines how sessions are secured with MACsec (only for MACsec +# drivers). +# 0: MACsec not in use (default) +# 1: MACsec enabled - Should secure, accept key server's advice to +# determine whether to use a secure session or not. +# +# macsec_integ_only: IEEE 802.1X/MACsec transmit mode +# This setting applies only when MACsec is in use, i.e., +# - macsec_policy is enabled +# - the key server has decided to enable MACsec +# 0: Encrypt traffic (default) +# 1: Integrity only +# +# macsec_replay_protect: IEEE 802.1X/MACsec replay protection +# This setting applies only when MACsec is in use, i.e., +# - macsec_policy is enabled +# - the key server has decided to enable MACsec +# 0: Replay protection disabled (default) +# 1: Replay protection enabled +# +# macsec_replay_window: IEEE 802.1X/MACsec replay protection window +# This determines a window in which replay is tolerated, to allow receipt +# of frames that have been misordered by the network. +# This setting applies only when MACsec replay protection active, i.e., +# - macsec_replay_protect is enabled +# - the key server has decided to enable MACsec +# 0: No replay window, strict check (default) +# 1..2^32-1: number of packets that could be misordered +# +# macsec_port: IEEE 802.1X/MACsec port +# Port component of the SCI +# Range: 1-65534 (default: 1) +# +# mka_priority (Priority of MKA Actor) +# Range: 0..255 (default: 255) +# +# mka_cak, mka_ckn, and mka_priority: IEEE 802.1X/MACsec pre-shared key mode +# This allows to configure MACsec with a pre-shared key using a (CAK,CKN) pair. +# In this mode, instances of hostapd can act as MACsec peers. The peer +# with lower priority will become the key server and start distributing SAKs. +# mka_cak (CAK = Secure Connectivity Association Key) takes a 16-byte (128-bit) +# hex-string (32 hex-digits) or a 32-byte (256-bit) hex-string (64 hex-digits) +# mka_ckn (CKN = CAK Name) takes a 1..32-bytes (8..256 bit) hex-string +# (2..64 hex-digits) + ##### Integrated EAP server ################################################### # Optionally, hostapd can be configured to use an integrated EAP server @@ -912,6 +977,23 @@ eap_server=0 # Passphrase for private key #private_key_passwd=secret passphrase +# An alternative server certificate and private key can be configured with the +# following parameters (with values just like the parameters above without the +# '2' suffix). The ca_cert file (in PEM encoding) is used to add the trust roots +# for both server certificates and/or client certificates). +# +# The main use case for this alternative server certificate configuration is to +# enable both RSA and ECC public keys. The server will pick which one to use +# based on the client preferences for the cipher suite (in the TLS ClientHello +# message). It should be noted that number of deployed EAP peer implementations +# do not filter out the cipher suite list based on their local configuration and +# as such, configuration of alternative types of certificates on the server may +# result in interoperability issues. +#server_cert2=/etc/hostapd.server-ecc.pem +#private_key2=/etc/hostapd.server-ecc.prv +#private_key_passwd2=secret passphrase + + # Server identity # EAP methods that provide mechanism for authenticated server identity delivery # use this value. If not set, "hostapd" is used as a default. @@ -1109,10 +1191,27 @@ eap_server=0 # (or fewer) of the lifetime remains. #pac_key_refresh_time=86400 +# EAP-TEAP authentication type +# 0 = inner EAP (default) +# 1 = Basic-Password-Auth +#eap_teap_auth=0 + +# EAP-TEAP authentication behavior when using PAC +# 0 = perform inner authentication (default) +# 1 = skip inner authentication (inner EAP/Basic-Password-Auth) +#eap_teap_pac_no_inner=0 + # EAP-SIM and EAP-AKA protected success/failure indication using AT_RESULT_IND # (default: 0 = disabled). #eap_sim_aka_result_ind=1 +# EAP-SIM and EAP-AKA identity options +# 0 = do not use pseudonyms or fast reauthentication +# 1 = use pseudonyms, but not fast reauthentication +# 2 = do not use pseudonyms, but use fast reauthentication +# 3 = use pseudonyms and use fast reauthentication (default) +#eap_sim_id=3 + # Trusted Network Connect (TNC) # If enabled, TNC validation will be required before the peer is allowed to # connect. Note: This is only used with EAP-TTLS and EAP-FAST. If any other @@ -1292,6 +1391,17 @@ own_ip_addr=127.0.0.1 # Operator-Name = "Operator" #radius_acct_req_attr=126:s:Operator +# If SQLite support is included, path to a database from which additional +# RADIUS request attributes are extracted based on the station MAC address. +# +# The schema for the radius_attributes table is: +# id | sta | reqtype | attr : multi-key (sta, reqtype) +# id = autonumber +# sta = station MAC address in `11:22:33:44:55:66` format. +# type = `auth` | `acct` | NULL (match any) +# attr = existing config file format, e.g. `126:s:Test Operator` +#radius_req_attr_sqlite=radius_attr.sqlite + # Dynamic Authorization Extensions (RFC 5176) # This mechanism can be used to allow dynamic changes to user session based on # commands from a RADIUS server (or some other disconnect client that has the @@ -2491,6 +2601,42 @@ own_ip_addr=127.0.0.1 # as a radio measurement even if the request doesn't contain a max age element # that allows sending of such data. Default: 0. #stationary_ap=0 + +##### Airtime policy configuration ########################################### + +# Set the airtime policy operating mode: +# 0 = disabled (default) +# 1 = static config +# 2 = per-BSS dynamic config +# 3 = per-BSS limit mode +#airtime_mode=0 + +# Interval (in milliseconds) to poll the kernel for updated station activity in +# dynamic and limit modes +#airtime_update_interval=200 + +# Static configuration of station weights (when airtime_mode=1). Kernel default +# weight is 256; set higher for larger airtime share, lower for smaller share. +# Each entry is a MAC address followed by a weight. +#airtime_sta_weight=02:01:02:03:04:05 256 +#airtime_sta_weight=02:01:02:03:04:06 512 + +# Per-BSS airtime weight. In multi-BSS mode, set for each BSS and hostapd will +# configure station weights to enforce the correct ratio between BSS weights +# depending on the number of active stations. The *ratios* between different +# BSSes is what's important, not the absolute numbers. +# Must be set for all BSSes if airtime_mode=2 or 3, has no effect otherwise. +#airtime_bss_weight=1 + +# Whether the current BSS should be limited (when airtime_mode=3). +# +# If set, the BSS weight ratio will be applied in the case where the current BSS +# would exceed the share defined by the BSS weight ratio. E.g., if two BSSes are +# set to the same weights, and one is set to limited, the limited BSS will get +# no more than half the available airtime, but if the non-limited BSS has more +# stations active, that *will* be allowed to exceed its half of the available +# airtime. +#airtime_bss_limit=1 ##### TESTING OPTIONS ######################################################### # Modified: stable/11/contrib/wpa/hostapd/hostapd_cli.c ============================================================================== --- stable/11/contrib/wpa/hostapd/hostapd_cli.c Thu Aug 29 18:53:00 2019 (r351610) +++ stable/11/contrib/wpa/hostapd/hostapd_cli.c Thu Aug 29 19:13:27 2019 (r351611) @@ -1214,6 +1214,13 @@ static int hostapd_cli_cmd_disable(struct wpa_ctrl *ct } +static int hostapd_cli_cmd_update_beacon(struct wpa_ctrl *ctrl, int argc, + char *argv[]) +{ + return wpa_ctrl_command(ctrl, "UPDATE_BEACON"); +} + + static int hostapd_cli_cmd_vendor(struct wpa_ctrl *ctrl, int argc, char *argv[]) { char cmd[256]; @@ -1617,6 +1624,8 @@ static const struct hostapd_cli_cmd hostapd_cli_comman "= reload configuration for current interface" }, { "disable", hostapd_cli_cmd_disable, NULL, "= disable hostapd on current interface" }, + { "update_beacon", hostapd_cli_cmd_update_beacon, NULL, + "= update Beacon frame contents\n"}, { "erp_flush", hostapd_cli_cmd_erp_flush, NULL, "= drop all ERP keys"}, { "log_level", hostapd_cli_cmd_log_level, NULL, Modified: stable/11/contrib/wpa/hostapd/main.c ============================================================================== --- stable/11/contrib/wpa/hostapd/main.c Thu Aug 29 18:53:00 2019 (r351610) +++ stable/11/contrib/wpa/hostapd/main.c Thu Aug 29 19:13:27 2019 (r351611) @@ -653,6 +653,9 @@ int main(int argc, char *argv[]) int start_ifaces_in_sync = 0; char **if_names = NULL; size_t if_names_size = 0; +#ifdef CONFIG_DPP + struct dpp_global_config dpp_conf; +#endif /* CONFIG_DPP */ if (os_program_init()) return -1; @@ -672,7 +675,9 @@ int main(int argc, char *argv[]) dl_list_init(&interfaces.eth_p_oui); #endif /* CONFIG_ETH_P_OUI */ #ifdef CONFIG_DPP - interfaces.dpp = dpp_global_init(); + os_memset(&dpp_conf, 0, sizeof(dpp_conf)); + /* TODO: dpp_conf.msg_ctx? */ + interfaces.dpp = dpp_global_init(&dpp_conf); if (!interfaces.dpp) return -1; #endif /* CONFIG_DPP */ Modified: stable/11/contrib/wpa/hs20/client/osu_client.c ============================================================================== --- stable/11/contrib/wpa/hs20/client/osu_client.c Thu Aug 29 18:53:00 2019 (r351610) +++ stable/11/contrib/wpa/hs20/client/osu_client.c Thu Aug 29 19:13:27 2019 (r351611) @@ -1588,6 +1588,7 @@ static void set_pps_cred_digital_cert(struct hs20_osu_ xml_node_t *node, const char *fqdn) { char buf[200], dir[200]; + int res; wpa_printf(MSG_INFO, "- Credential/DigitalCertificate"); @@ -1599,14 +1600,20 @@ static void set_pps_cred_digital_cert(struct hs20_osu_ wpa_printf(MSG_INFO, "Failed to set username"); } - snprintf(buf, sizeof(buf), "%s/SP/%s/client-cert.pem", dir, fqdn); + res = os_snprintf(buf, sizeof(buf), "%s/SP/%s/client-cert.pem", dir, + fqdn); + if (os_snprintf_error(sizeof(buf), res)) + return; if (os_file_exists(buf)) { if (set_cred_quoted(ctx->ifname, id, "client_cert", buf) < 0) { wpa_printf(MSG_INFO, "Failed to set client_cert"); } } - snprintf(buf, sizeof(buf), "%s/SP/%s/client-key.pem", dir, fqdn); + res = os_snprintf(buf, sizeof(buf), "%s/SP/%s/client-key.pem", dir, + fqdn); + if (os_snprintf_error(sizeof(buf), res)) + return; if (os_file_exists(buf)) { if (set_cred_quoted(ctx->ifname, id, "private_key", buf) < 0) { wpa_printf(MSG_INFO, "Failed to set private_key"); @@ -1620,6 +1627,7 @@ static void set_pps_cred_realm(struct hs20_osu_client { char *str = xml_node_get_text(ctx->xml, node); char buf[200], dir[200]; + int res; if (str == NULL) return; @@ -1634,7 +1642,9 @@ static void set_pps_cred_realm(struct hs20_osu_client if (getcwd(dir, sizeof(dir)) == NULL) return; - snprintf(buf, sizeof(buf), "%s/SP/%s/aaa-ca.pem", dir, fqdn); + res = os_snprintf(buf, sizeof(buf), "%s/SP/%s/aaa-ca.pem", dir, fqdn); + if (os_snprintf_error(sizeof(buf), res)) + return; if (os_file_exists(buf)) { if (set_cred_quoted(ctx->ifname, id, "ca_cert", buf) < 0) { wpa_printf(MSG_INFO, "Failed to set CA cert"); @@ -2717,6 +2727,8 @@ static int cmd_pol_upd(struct hs20_osu_client *ctx, co if (!pps_fname) { char buf[256]; + int res; + wpa_printf(MSG_INFO, "Determining PPS file based on Home SP information"); if (address && os_strncmp(address, "fqdn=", 5) == 0) { wpa_printf(MSG_INFO, "Use requested FQDN from command line"); @@ -2737,8 +2749,13 @@ static int cmd_pol_upd(struct hs20_osu_client *ctx, co "SP/%s/pps.xml", ctx->fqdn); pps_fname = pps_fname_buf; - os_snprintf(ca_fname_buf, sizeof(ca_fname_buf), "SP/%s/ca.pem", - buf); + res = os_snprintf(ca_fname_buf, sizeof(ca_fname_buf), + "SP/%s/ca.pem", buf); + if (os_snprintf_error(sizeof(ca_fname_buf), res)) { + os_free(ctx->fqdn); + ctx->fqdn = NULL; + return -1; + } ca_fname = ca_fname_buf; } Modified: stable/11/contrib/wpa/src/ap/accounting.c ============================================================================== --- stable/11/contrib/wpa/src/ap/accounting.c Thu Aug 29 18:53:00 2019 (r351610) +++ stable/11/contrib/wpa/src/ap/accounting.c Thu Aug 29 19:13:27 2019 (r351611) @@ -97,6 +97,9 @@ static struct radius_msg * accounting_msg(struct hosta msg) < 0) goto fail; + if (sta && add_sqlite_radius_attr(hapd, sta, msg, 1) < 0) + goto fail; + if (sta) { for (i = 0; ; i++) { val = ieee802_1x_get_radius_class(sta->eapol_sm, &len, Modified: stable/11/contrib/wpa/src/ap/acs.c ============================================================================== --- stable/11/contrib/wpa/src/ap/acs.c Thu Aug 29 18:53:00 2019 (r351610) +++ stable/11/contrib/wpa/src/ap/acs.c Thu Aug 29 19:13:27 2019 (r351611) @@ -594,12 +594,12 @@ acs_find_ideal_chan(struct hostapd_iface *iface) iface->conf->secondary_channel) n_chans = 2; - if (iface->conf->ieee80211ac) { - switch (iface->conf->vht_oper_chwidth) { - case VHT_CHANWIDTH_80MHZ: + if (iface->conf->ieee80211ac || iface->conf->ieee80211ax) { + switch (hostapd_get_oper_chwidth(iface->conf)) { + case CHANWIDTH_80MHZ: n_chans = 4; break; - case VHT_CHANWIDTH_160MHZ: + case CHANWIDTH_160MHZ: n_chans = 8; break; } @@ -607,7 +607,7 @@ acs_find_ideal_chan(struct hostapd_iface *iface) bw = num_chan_to_bw(n_chans); - /* TODO: VHT80+80. Update acs_adjust_vht_center_freq() too. */ + /* TODO: VHT/HE80+80. Update acs_adjust_center_freq() too. */ wpa_printf(MSG_DEBUG, "ACS: Survey analysis for selected bandwidth %d MHz", bw); @@ -647,9 +647,9 @@ acs_find_ideal_chan(struct hostapd_iface *iface) } if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A && - iface->conf->ieee80211ac) { - if (iface->conf->vht_oper_chwidth == *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Sat Aug 31 04:23:26 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B93D0E345B; Sat, 31 Aug 2019 04:23:26 +0000 (UTC) (envelope-from cy@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 46L3B64tMwz3yLr; Sat, 31 Aug 2019 04:23:26 +0000 (UTC) (envelope-from cy@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 701C7B400; Sat, 31 Aug 2019 04:23:26 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7V4NQ4U073831; Sat, 31 Aug 2019 04:23:26 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7V4NPrF073827; Sat, 31 Aug 2019 04:23:25 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908310423.x7V4NPrF073827@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sat, 31 Aug 2019 04:23:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351633 - in stable: 11/contrib/sqlite3 11/contrib/sqlite3/tea 12/contrib/sqlite3 12/contrib/sqlite3/tea X-SVN-Group: stable-11 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 11/contrib/sqlite3 11/contrib/sqlite3/tea 12/contrib/sqlite3 12/contrib/sqlite3/tea X-SVN-Commit-Revision: 351633 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Aug 2019 04:23:26 -0000 Author: cy Date: Sat Aug 31 04:23:25 2019 New Revision: 351633 URL: https://svnweb.freebsd.org/changeset/base/351633 Log: MFC r350103: MFV r350080: Update sqlite3-3.28.0 (3280000) --> sqlite3-3.29.0 (3290000) Modified: stable/11/contrib/sqlite3/configure stable/11/contrib/sqlite3/configure.ac stable/11/contrib/sqlite3/shell.c stable/11/contrib/sqlite3/sqlite3.c stable/11/contrib/sqlite3/sqlite3.h stable/11/contrib/sqlite3/tea/configure stable/11/contrib/sqlite3/tea/configure.ac Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/contrib/sqlite3/configure stable/12/contrib/sqlite3/configure.ac stable/12/contrib/sqlite3/shell.c stable/12/contrib/sqlite3/sqlite3.c stable/12/contrib/sqlite3/sqlite3.h stable/12/contrib/sqlite3/tea/configure stable/12/contrib/sqlite3/tea/configure.ac Directory Properties: stable/12/ (props changed) Modified: stable/11/contrib/sqlite3/configure ============================================================================== --- stable/11/contrib/sqlite3/configure Fri Aug 30 21:54:45 2019 (r351632) +++ stable/11/contrib/sqlite3/configure Sat Aug 31 04:23:25 2019 (r351633) @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for sqlite 3.28.0. +# Generated by GNU Autoconf 2.69 for sqlite 3.29.0. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='sqlite' PACKAGE_TARNAME='sqlite' -PACKAGE_VERSION='3.28.0' -PACKAGE_STRING='sqlite 3.28.0' +PACKAGE_VERSION='3.29.0' +PACKAGE_STRING='sqlite 3.29.0' PACKAGE_BUGREPORT='http://www.sqlite.org' PACKAGE_URL='' @@ -1341,7 +1341,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sqlite 3.28.0 to adapt to many kinds of systems. +\`configure' configures sqlite 3.29.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1412,7 +1412,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sqlite 3.28.0:";; + short | recursive ) echo "Configuration of sqlite 3.29.0:";; esac cat <<\_ACEOF @@ -1537,7 +1537,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sqlite configure 3.28.0 +sqlite configure 3.29.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1952,7 +1952,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sqlite $as_me 3.28.0, which was +It was created by sqlite $as_me 3.29.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2818,7 +2818,7 @@ fi # Define the identity of the package. PACKAGE='sqlite' - VERSION='3.28.0' + VERSION='3.29.0' cat >>confdefs.h <<_ACEOF @@ -14438,7 +14438,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sqlite $as_me 3.28.0, which was +This file was extended by sqlite $as_me 3.29.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14495,7 +14495,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -sqlite config.status 3.28.0 +sqlite config.status 3.29.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Modified: stable/11/contrib/sqlite3/configure.ac ============================================================================== --- stable/11/contrib/sqlite3/configure.ac Fri Aug 30 21:54:45 2019 (r351632) +++ stable/11/contrib/sqlite3/configure.ac Sat Aug 31 04:23:25 2019 (r351633) @@ -10,7 +10,7 @@ # AC_PREREQ(2.61) -AC_INIT(sqlite, 3.28.0, http://www.sqlite.org) +AC_INIT(sqlite, 3.29.0, http://www.sqlite.org) AC_CONFIG_SRCDIR([sqlite3.c]) AC_CONFIG_AUX_DIR([.]) Modified: stable/11/contrib/sqlite3/shell.c ============================================================================== --- stable/11/contrib/sqlite3/shell.c Fri Aug 30 21:54:45 2019 (r351632) +++ stable/11/contrib/sqlite3/shell.c Sat Aug 31 04:23:25 2019 (r351633) @@ -983,6 +983,7 @@ static void shellAddSchemaName( ** We need several support functions from the SQLite core. */ +/* #include "sqlite3.h" */ /* ** We need several things from the ANSI and MSVCRT headers. @@ -1336,6 +1337,7 @@ INT closedir( ** is used. If SIZE is included it must be one of the integers 224, 256, ** 384, or 512, to determine SHA3 hash variant that is computed. */ +/* #include "sqlite3ext.h" */ SQLITE_EXTENSION_INIT1 #include #include @@ -2099,6 +2101,7 @@ int sqlite3_shathree_init( ** And the paths returned in the "name" column of the table are also ** relative to directory $dir. */ +/* #include "sqlite3ext.h" */ SQLITE_EXTENSION_INIT1 #include #include @@ -3056,6 +3059,7 @@ int sqlite3_fileio_init( ** faster than any human can type. ** */ +/* #include "sqlite3ext.h" */ SQLITE_EXTENSION_INIT1 #include #include @@ -3572,6 +3576,7 @@ int sqlite3_completion_init( ** If the file being opened is not an appended database, then this shim is ** a pass-through into the default underlying VFS. **/ +/* #include "sqlite3ext.h" */ SQLITE_EXTENSION_INIT1 #include #include @@ -4228,6 +4233,7 @@ int sqlite3MemTraceDeactivate(void){ ** * No support for zip64 extensions ** * Only the "inflate/deflate" (zlib) compression method is supported */ +/* #include "sqlite3ext.h" */ SQLITE_EXTENSION_INIT1 #include #include @@ -6398,6 +6404,7 @@ int sqlite3_zipfile_init( ** for working with sqlar archives and used by the shell tool's built-in ** sqlar support. */ +/* #include "sqlite3ext.h" */ SQLITE_EXTENSION_INIT1 #include @@ -6520,6 +6527,7 @@ int sqlite3_sqlar_init( */ +/* #include "sqlite3.h" */ typedef struct sqlite3expert sqlite3expert; @@ -6688,6 +6696,7 @@ void sqlite3_expert_destroy(sqlite3expert*); ** ************************************************************************* */ +/* #include "sqlite3expert.h" */ #include #include #include @@ -8631,6 +8640,863 @@ void sqlite3_expert_destroy(sqlite3expert *p){ /************************* End ../ext/expert/sqlite3expert.c ********************/ +#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB) +/************************* Begin ../ext/misc/dbdata.c ******************/ +/* +** 2019-04-17 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This file contains an implementation of two eponymous virtual tables, +** "sqlite_dbdata" and "sqlite_dbptr". Both modules require that the +** "sqlite_dbpage" eponymous virtual table be available. +** +** SQLITE_DBDATA: +** sqlite_dbdata is used to extract data directly from a database b-tree +** page and its associated overflow pages, bypassing the b-tree layer. +** The table schema is equivalent to: +** +** CREATE TABLE sqlite_dbdata( +** pgno INTEGER, +** cell INTEGER, +** field INTEGER, +** value ANY, +** schema TEXT HIDDEN +** ); +** +** IMPORTANT: THE VIRTUAL TABLE SCHEMA ABOVE IS SUBJECT TO CHANGE. IN THE +** FUTURE NEW NON-HIDDEN COLUMNS MAY BE ADDED BETWEEN "value" AND +** "schema". +** +** Each page of the database is inspected. If it cannot be interpreted as +** a b-tree page, or if it is a b-tree page containing 0 entries, the +** sqlite_dbdata table contains no rows for that page. Otherwise, the +** table contains one row for each field in the record associated with +** each cell on the page. For intkey b-trees, the key value is stored in +** field -1. +** +** For example, for the database: +** +** CREATE TABLE t1(a, b); -- root page is page 2 +** INSERT INTO t1(rowid, a, b) VALUES(5, 'v', 'five'); +** INSERT INTO t1(rowid, a, b) VALUES(10, 'x', 'ten'); +** +** the sqlite_dbdata table contains, as well as from entries related to +** page 1, content equivalent to: +** +** INSERT INTO sqlite_dbdata(pgno, cell, field, value) VALUES +** (2, 0, -1, 5 ), +** (2, 0, 0, 'v' ), +** (2, 0, 1, 'five'), +** (2, 1, -1, 10 ), +** (2, 1, 0, 'x' ), +** (2, 1, 1, 'ten' ); +** +** If database corruption is encountered, this module does not report an +** error. Instead, it attempts to extract as much data as possible and +** ignores the corruption. +** +** SQLITE_DBPTR: +** The sqlite_dbptr table has the following schema: +** +** CREATE TABLE sqlite_dbptr( +** pgno INTEGER, +** child INTEGER, +** schema TEXT HIDDEN +** ); +** +** It contains one entry for each b-tree pointer between a parent and +** child page in the database. +*/ +#if !defined(SQLITEINT_H) +/* #include "sqlite3ext.h" */ + +/* typedef unsigned char u8; */ + +#endif +SQLITE_EXTENSION_INIT1 +#include +#include + +#define DBDATA_PADDING_BYTES 100 + +typedef struct DbdataTable DbdataTable; +typedef struct DbdataCursor DbdataCursor; + +/* Cursor object */ +struct DbdataCursor { + sqlite3_vtab_cursor base; /* Base class. Must be first */ + sqlite3_stmt *pStmt; /* For fetching database pages */ + + int iPgno; /* Current page number */ + u8 *aPage; /* Buffer containing page */ + int nPage; /* Size of aPage[] in bytes */ + int nCell; /* Number of cells on aPage[] */ + int iCell; /* Current cell number */ + int bOnePage; /* True to stop after one page */ + int szDb; + sqlite3_int64 iRowid; + + /* Only for the sqlite_dbdata table */ + u8 *pRec; /* Buffer containing current record */ + int nRec; /* Size of pRec[] in bytes */ + int nHdr; /* Size of header in bytes */ + int iField; /* Current field number */ + u8 *pHdrPtr; + u8 *pPtr; + + sqlite3_int64 iIntkey; /* Integer key value */ +}; + +/* Table object */ +struct DbdataTable { + sqlite3_vtab base; /* Base class. Must be first */ + sqlite3 *db; /* The database connection */ + sqlite3_stmt *pStmt; /* For fetching database pages */ + int bPtr; /* True for sqlite3_dbptr table */ +}; + +/* Column and schema definitions for sqlite_dbdata */ +#define DBDATA_COLUMN_PGNO 0 +#define DBDATA_COLUMN_CELL 1 +#define DBDATA_COLUMN_FIELD 2 +#define DBDATA_COLUMN_VALUE 3 +#define DBDATA_COLUMN_SCHEMA 4 +#define DBDATA_SCHEMA \ + "CREATE TABLE x(" \ + " pgno INTEGER," \ + " cell INTEGER," \ + " field INTEGER," \ + " value ANY," \ + " schema TEXT HIDDEN" \ + ")" + +/* Column and schema definitions for sqlite_dbptr */ +#define DBPTR_COLUMN_PGNO 0 +#define DBPTR_COLUMN_CHILD 1 +#define DBPTR_COLUMN_SCHEMA 2 +#define DBPTR_SCHEMA \ + "CREATE TABLE x(" \ + " pgno INTEGER," \ + " child INTEGER," \ + " schema TEXT HIDDEN" \ + ")" + +/* +** Connect to an sqlite_dbdata (pAux==0) or sqlite_dbptr (pAux!=0) virtual +** table. +*/ +static int dbdataConnect( + sqlite3 *db, + void *pAux, + int argc, const char *const*argv, + sqlite3_vtab **ppVtab, + char **pzErr +){ + DbdataTable *pTab = 0; + int rc = sqlite3_declare_vtab(db, pAux ? DBPTR_SCHEMA : DBDATA_SCHEMA); + + if( rc==SQLITE_OK ){ + pTab = (DbdataTable*)sqlite3_malloc64(sizeof(DbdataTable)); + if( pTab==0 ){ + rc = SQLITE_NOMEM; + }else{ + memset(pTab, 0, sizeof(DbdataTable)); + pTab->db = db; + pTab->bPtr = (pAux!=0); + } + } + + *ppVtab = (sqlite3_vtab*)pTab; + return rc; +} + +/* +** Disconnect from or destroy a sqlite_dbdata or sqlite_dbptr virtual table. +*/ +static int dbdataDisconnect(sqlite3_vtab *pVtab){ + DbdataTable *pTab = (DbdataTable*)pVtab; + if( pTab ){ + sqlite3_finalize(pTab->pStmt); + sqlite3_free(pVtab); + } + return SQLITE_OK; +} + +/* +** This function interprets two types of constraints: +** +** schema=? +** pgno=? +** +** If neither are present, idxNum is set to 0. If schema=? is present, +** the 0x01 bit in idxNum is set. If pgno=? is present, the 0x02 bit +** in idxNum is set. +** +** If both parameters are present, schema is in position 0 and pgno in +** position 1. +*/ +static int dbdataBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdx){ + DbdataTable *pTab = (DbdataTable*)tab; + int i; + int iSchema = -1; + int iPgno = -1; + int colSchema = (pTab->bPtr ? DBPTR_COLUMN_SCHEMA : DBDATA_COLUMN_SCHEMA); + + for(i=0; inConstraint; i++){ + struct sqlite3_index_constraint *p = &pIdx->aConstraint[i]; + if( p->op==SQLITE_INDEX_CONSTRAINT_EQ ){ + if( p->iColumn==colSchema ){ + if( p->usable==0 ) return SQLITE_CONSTRAINT; + iSchema = i; + } + if( p->iColumn==DBDATA_COLUMN_PGNO && p->usable ){ + iPgno = i; + } + } + } + + if( iSchema>=0 ){ + pIdx->aConstraintUsage[iSchema].argvIndex = 1; + pIdx->aConstraintUsage[iSchema].omit = 1; + } + if( iPgno>=0 ){ + pIdx->aConstraintUsage[iPgno].argvIndex = 1 + (iSchema>=0); + pIdx->aConstraintUsage[iPgno].omit = 1; + pIdx->estimatedCost = 100; + pIdx->estimatedRows = 50; + + if( pTab->bPtr==0 && pIdx->nOrderBy && pIdx->aOrderBy[0].desc==0 ){ + int iCol = pIdx->aOrderBy[0].iColumn; + if( pIdx->nOrderBy==1 ){ + pIdx->orderByConsumed = (iCol==0 || iCol==1); + }else if( pIdx->nOrderBy==2 && pIdx->aOrderBy[1].desc==0 && iCol==0 ){ + pIdx->orderByConsumed = (pIdx->aOrderBy[1].iColumn==1); + } + } + + }else{ + pIdx->estimatedCost = 100000000; + pIdx->estimatedRows = 1000000000; + } + pIdx->idxNum = (iSchema>=0 ? 0x01 : 0x00) | (iPgno>=0 ? 0x02 : 0x00); + return SQLITE_OK; +} + +/* +** Open a new sqlite_dbdata or sqlite_dbptr cursor. +*/ +static int dbdataOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ + DbdataCursor *pCsr; + + pCsr = (DbdataCursor*)sqlite3_malloc64(sizeof(DbdataCursor)); + if( pCsr==0 ){ + return SQLITE_NOMEM; + }else{ + memset(pCsr, 0, sizeof(DbdataCursor)); + pCsr->base.pVtab = pVTab; + } + + *ppCursor = (sqlite3_vtab_cursor *)pCsr; + return SQLITE_OK; +} + +/* +** Restore a cursor object to the state it was in when first allocated +** by dbdataOpen(). +*/ +static void dbdataResetCursor(DbdataCursor *pCsr){ + DbdataTable *pTab = (DbdataTable*)(pCsr->base.pVtab); + if( pTab->pStmt==0 ){ + pTab->pStmt = pCsr->pStmt; + }else{ + sqlite3_finalize(pCsr->pStmt); + } + pCsr->pStmt = 0; + pCsr->iPgno = 1; + pCsr->iCell = 0; + pCsr->iField = 0; + pCsr->bOnePage = 0; + sqlite3_free(pCsr->aPage); + sqlite3_free(pCsr->pRec); + pCsr->pRec = 0; + pCsr->aPage = 0; +} + +/* +** Close an sqlite_dbdata or sqlite_dbptr cursor. +*/ +static int dbdataClose(sqlite3_vtab_cursor *pCursor){ + DbdataCursor *pCsr = (DbdataCursor*)pCursor; + dbdataResetCursor(pCsr); + sqlite3_free(pCsr); + return SQLITE_OK; +} + +/* +** Utility methods to decode 16 and 32-bit big-endian unsigned integers. +*/ +static unsigned int get_uint16(unsigned char *a){ + return (a[0]<<8)|a[1]; +} +static unsigned int get_uint32(unsigned char *a){ + return ((unsigned int)a[0]<<24) + | ((unsigned int)a[1]<<16) + | ((unsigned int)a[2]<<8) + | ((unsigned int)a[3]); +} + +/* +** Load page pgno from the database via the sqlite_dbpage virtual table. +** If successful, set (*ppPage) to point to a buffer containing the page +** data, (*pnPage) to the size of that buffer in bytes and return +** SQLITE_OK. In this case it is the responsibility of the caller to +** eventually free the buffer using sqlite3_free(). +** +** Or, if an error occurs, set both (*ppPage) and (*pnPage) to 0 and +** return an SQLite error code. +*/ +static int dbdataLoadPage( + DbdataCursor *pCsr, /* Cursor object */ + unsigned int pgno, /* Page number of page to load */ + u8 **ppPage, /* OUT: pointer to page buffer */ + int *pnPage /* OUT: Size of (*ppPage) in bytes */ +){ + int rc2; + int rc = SQLITE_OK; + sqlite3_stmt *pStmt = pCsr->pStmt; + + *ppPage = 0; + *pnPage = 0; + sqlite3_bind_int64(pStmt, 2, pgno); + if( SQLITE_ROW==sqlite3_step(pStmt) ){ + int nCopy = sqlite3_column_bytes(pStmt, 0); + if( nCopy>0 ){ + u8 *pPage; + pPage = (u8*)sqlite3_malloc64(nCopy + DBDATA_PADDING_BYTES); + if( pPage==0 ){ + rc = SQLITE_NOMEM; + }else{ + const u8 *pCopy = sqlite3_column_blob(pStmt, 0); + memcpy(pPage, pCopy, nCopy); + memset(&pPage[nCopy], 0, DBDATA_PADDING_BYTES); + } + *ppPage = pPage; + *pnPage = nCopy; + } + } + rc2 = sqlite3_reset(pStmt); + if( rc==SQLITE_OK ) rc = rc2; + + return rc; +} + +/* +** Read a varint. Put the value in *pVal and return the number of bytes. +*/ +static int dbdataGetVarint(const u8 *z, sqlite3_int64 *pVal){ + sqlite3_int64 v = 0; + int i; + for(i=0; i<8; i++){ + v = (v<<7) + (z[i]&0x7f); + if( (z[i]&0x80)==0 ){ *pVal = v; return i+1; } + } + v = (v<<8) + (z[i]&0xff); + *pVal = v; + return 9; +} + +/* +** Return the number of bytes of space used by an SQLite value of type +** eType. +*/ +static int dbdataValueBytes(int eType){ + switch( eType ){ + case 0: case 8: case 9: + case 10: case 11: + return 0; + case 1: + return 1; + case 2: + return 2; + case 3: + return 3; + case 4: + return 4; + case 5: + return 6; + case 6: + case 7: + return 8; + default: + if( eType>0 ){ + return ((eType-12) / 2); + } + return 0; + } +} + +/* +** Load a value of type eType from buffer pData and use it to set the +** result of context object pCtx. +*/ +static void dbdataValue( + sqlite3_context *pCtx, + int eType, + u8 *pData, + int nData +){ + if( eType>=0 && dbdataValueBytes(eType)<=nData ){ + switch( eType ){ + case 0: + case 10: + case 11: + sqlite3_result_null(pCtx); + break; + + case 8: + sqlite3_result_int(pCtx, 0); + break; + case 9: + sqlite3_result_int(pCtx, 1); + break; + + case 1: case 2: case 3: case 4: case 5: case 6: case 7: { + sqlite3_uint64 v = (signed char)pData[0]; + pData++; + switch( eType ){ + case 7: + case 6: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2; + case 5: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2; + case 4: v = (v<<8) + pData[0]; pData++; + case 3: v = (v<<8) + pData[0]; pData++; + case 2: v = (v<<8) + pData[0]; pData++; + } + + if( eType==7 ){ + double r; + memcpy(&r, &v, sizeof(r)); + sqlite3_result_double(pCtx, r); + }else{ + sqlite3_result_int64(pCtx, (sqlite3_int64)v); + } + break; + } + + default: { + int n = ((eType-12) / 2); + if( eType % 2 ){ + sqlite3_result_text(pCtx, (const char*)pData, n, SQLITE_TRANSIENT); + }else{ + sqlite3_result_blob(pCtx, pData, n, SQLITE_TRANSIENT); + } + } + } + } +} + +/* +** Move an sqlite_dbdata or sqlite_dbptr cursor to the next entry. +*/ +static int dbdataNext(sqlite3_vtab_cursor *pCursor){ + DbdataCursor *pCsr = (DbdataCursor*)pCursor; + DbdataTable *pTab = (DbdataTable*)pCursor->pVtab; + + pCsr->iRowid++; + while( 1 ){ + int rc; + int iOff = (pCsr->iPgno==1 ? 100 : 0); + int bNextPage = 0; + + if( pCsr->aPage==0 ){ + while( 1 ){ + if( pCsr->bOnePage==0 && pCsr->iPgno>pCsr->szDb ) return SQLITE_OK; + rc = dbdataLoadPage(pCsr, pCsr->iPgno, &pCsr->aPage, &pCsr->nPage); + if( rc!=SQLITE_OK ) return rc; + if( pCsr->aPage ) break; + pCsr->iPgno++; + } + pCsr->iCell = pTab->bPtr ? -2 : 0; + pCsr->nCell = get_uint16(&pCsr->aPage[iOff+3]); + } + + if( pTab->bPtr ){ + if( pCsr->aPage[iOff]!=0x02 && pCsr->aPage[iOff]!=0x05 ){ + pCsr->iCell = pCsr->nCell; + } + pCsr->iCell++; + if( pCsr->iCell>=pCsr->nCell ){ + sqlite3_free(pCsr->aPage); + pCsr->aPage = 0; + if( pCsr->bOnePage ) return SQLITE_OK; + pCsr->iPgno++; + }else{ + return SQLITE_OK; + } + }else{ + /* If there is no record loaded, load it now. */ + if( pCsr->pRec==0 ){ + int bHasRowid = 0; + int nPointer = 0; + sqlite3_int64 nPayload = 0; + sqlite3_int64 nHdr = 0; + int iHdr; + int U, X; + int nLocal; + + switch( pCsr->aPage[iOff] ){ + case 0x02: + nPointer = 4; + break; + case 0x0a: + break; + case 0x0d: + bHasRowid = 1; + break; + default: + /* This is not a b-tree page with records on it. Continue. */ + pCsr->iCell = pCsr->nCell; + break; + } + + if( pCsr->iCell>=pCsr->nCell ){ + bNextPage = 1; + }else{ + + iOff += 8 + nPointer + pCsr->iCell*2; + if( iOff>pCsr->nPage ){ + bNextPage = 1; + }else{ + iOff = get_uint16(&pCsr->aPage[iOff]); + } + + /* For an interior node cell, skip past the child-page number */ + iOff += nPointer; + + /* Load the "byte of payload including overflow" field */ + if( bNextPage || iOff>pCsr->nPage ){ + bNextPage = 1; + }else{ + iOff += dbdataGetVarint(&pCsr->aPage[iOff], &nPayload); + } + + /* If this is a leaf intkey cell, load the rowid */ + if( bHasRowid && !bNextPage && iOffnPage ){ + iOff += dbdataGetVarint(&pCsr->aPage[iOff], &pCsr->iIntkey); + } + + /* Figure out how much data to read from the local page */ + U = pCsr->nPage; + if( bHasRowid ){ + X = U-35; + }else{ + X = ((U-12)*64/255)-23; + } + if( nPayload<=X ){ + nLocal = nPayload; + }else{ + int M, K; + M = ((U-12)*32/255)-23; + K = M+((nPayload-M)%(U-4)); + if( K<=X ){ + nLocal = K; + }else{ + nLocal = M; + } + } + + if( bNextPage || nLocal+iOff>pCsr->nPage ){ + bNextPage = 1; + }else{ + + /* Allocate space for payload. And a bit more to catch small buffer + ** overruns caused by attempting to read a varint or similar from + ** near the end of a corrupt record. */ + pCsr->pRec = (u8*)sqlite3_malloc64(nPayload+DBDATA_PADDING_BYTES); + if( pCsr->pRec==0 ) return SQLITE_NOMEM; + memset(pCsr->pRec, 0, nPayload+DBDATA_PADDING_BYTES); + pCsr->nRec = nPayload; + + /* Load the nLocal bytes of payload */ + memcpy(pCsr->pRec, &pCsr->aPage[iOff], nLocal); + iOff += nLocal; + + /* Load content from overflow pages */ + if( nPayload>nLocal ){ + sqlite3_int64 nRem = nPayload - nLocal; + unsigned int pgnoOvfl = get_uint32(&pCsr->aPage[iOff]); + while( nRem>0 ){ + u8 *aOvfl = 0; + int nOvfl = 0; + int nCopy; + rc = dbdataLoadPage(pCsr, pgnoOvfl, &aOvfl, &nOvfl); + assert( rc!=SQLITE_OK || aOvfl==0 || nOvfl==pCsr->nPage ); + if( rc!=SQLITE_OK ) return rc; + if( aOvfl==0 ) break; + + nCopy = U-4; + if( nCopy>nRem ) nCopy = nRem; + memcpy(&pCsr->pRec[nPayload-nRem], &aOvfl[4], nCopy); + nRem -= nCopy; + + pgnoOvfl = get_uint32(aOvfl); + sqlite3_free(aOvfl); + } + } + + iHdr = dbdataGetVarint(pCsr->pRec, &nHdr); + pCsr->nHdr = nHdr; + pCsr->pHdrPtr = &pCsr->pRec[iHdr]; + pCsr->pPtr = &pCsr->pRec[pCsr->nHdr]; + pCsr->iField = (bHasRowid ? -1 : 0); + } + } + }else{ + pCsr->iField++; + if( pCsr->iField>0 ){ + sqlite3_int64 iType; + if( pCsr->pHdrPtr>&pCsr->pRec[pCsr->nRec] ){ + bNextPage = 1; + }else{ + pCsr->pHdrPtr += dbdataGetVarint(pCsr->pHdrPtr, &iType); + pCsr->pPtr += dbdataValueBytes(iType); + } + } + } + + if( bNextPage ){ + sqlite3_free(pCsr->aPage); + sqlite3_free(pCsr->pRec); + pCsr->aPage = 0; + pCsr->pRec = 0; + if( pCsr->bOnePage ) return SQLITE_OK; + pCsr->iPgno++; + }else{ + if( pCsr->iField<0 || pCsr->pHdrPtr<&pCsr->pRec[pCsr->nHdr] ){ + return SQLITE_OK; + } + + /* Advance to the next cell. The next iteration of the loop will load + ** the record and so on. */ + sqlite3_free(pCsr->pRec); + pCsr->pRec = 0; + pCsr->iCell++; + } + } + } + + assert( !"can't get here" ); + return SQLITE_OK; +} + +/* +** Return true if the cursor is at EOF. +*/ +static int dbdataEof(sqlite3_vtab_cursor *pCursor){ + DbdataCursor *pCsr = (DbdataCursor*)pCursor; + return pCsr->aPage==0; +} + +/* +** Determine the size in pages of database zSchema (where zSchema is +** "main", "temp" or the name of an attached database) and set +** pCsr->szDb accordingly. If successful, return SQLITE_OK. Otherwise, +** an SQLite error code. +*/ +static int dbdataDbsize(DbdataCursor *pCsr, const char *zSchema){ + DbdataTable *pTab = (DbdataTable*)pCsr->base.pVtab; + char *zSql = 0; + int rc, rc2; + sqlite3_stmt *pStmt = 0; + + zSql = sqlite3_mprintf("PRAGMA %Q.page_count", zSchema); + if( zSql==0 ) return SQLITE_NOMEM; + rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pStmt, 0); + sqlite3_free(zSql); + if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ + pCsr->szDb = sqlite3_column_int(pStmt, 0); + } + rc2 = sqlite3_finalize(pStmt); + if( rc==SQLITE_OK ) rc = rc2; + return rc; +} + +/* +** xFilter method for sqlite_dbdata and sqlite_dbptr. +*/ +static int dbdataFilter( + sqlite3_vtab_cursor *pCursor, + int idxNum, const char *idxStr, + int argc, sqlite3_value **argv +){ + DbdataCursor *pCsr = (DbdataCursor*)pCursor; + DbdataTable *pTab = (DbdataTable*)pCursor->pVtab; + int rc = SQLITE_OK; + const char *zSchema = "main"; + + dbdataResetCursor(pCsr); + assert( pCsr->iPgno==1 ); + if( idxNum & 0x01 ){ + zSchema = (const char*)sqlite3_value_text(argv[0]); + } + if( idxNum & 0x02 ){ + pCsr->iPgno = sqlite3_value_int(argv[(idxNum & 0x01)]); + pCsr->bOnePage = 1; + }else{ + pCsr->nPage = dbdataDbsize(pCsr, zSchema); + rc = dbdataDbsize(pCsr, zSchema); + } + + if( rc==SQLITE_OK ){ + if( pTab->pStmt ){ + pCsr->pStmt = pTab->pStmt; + pTab->pStmt = 0; + }else{ + rc = sqlite3_prepare_v2(pTab->db, + "SELECT data FROM sqlite_dbpage(?) WHERE pgno=?", -1, + &pCsr->pStmt, 0 + ); + } + } + if( rc==SQLITE_OK ){ + rc = sqlite3_bind_text(pCsr->pStmt, 1, zSchema, -1, SQLITE_TRANSIENT); + }else{ + pTab->base.zErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pTab->db)); + } + if( rc==SQLITE_OK ){ + rc = dbdataNext(pCursor); + } + return rc; +} + +/* +** Return a column for the sqlite_dbdata or sqlite_dbptr table. +*/ +static int dbdataColumn( + sqlite3_vtab_cursor *pCursor, + sqlite3_context *ctx, + int i +){ + DbdataCursor *pCsr = (DbdataCursor*)pCursor; + DbdataTable *pTab = (DbdataTable*)pCursor->pVtab; + if( pTab->bPtr ){ + switch( i ){ + case DBPTR_COLUMN_PGNO: + sqlite3_result_int64(ctx, pCsr->iPgno); + break; + case DBPTR_COLUMN_CHILD: { + int iOff = pCsr->iPgno==1 ? 100 : 0; + if( pCsr->iCell<0 ){ + iOff += 8; + }else{ + iOff += 12 + pCsr->iCell*2; + if( iOff>pCsr->nPage ) return SQLITE_OK; + iOff = get_uint16(&pCsr->aPage[iOff]); + } + if( iOff<=pCsr->nPage ){ + sqlite3_result_int64(ctx, get_uint32(&pCsr->aPage[iOff])); + } + break; + } + } + }else{ + switch( i ){ + case DBDATA_COLUMN_PGNO: + sqlite3_result_int64(ctx, pCsr->iPgno); + break; + case DBDATA_COLUMN_CELL: + sqlite3_result_int(ctx, pCsr->iCell); + break; + case DBDATA_COLUMN_FIELD: + sqlite3_result_int(ctx, pCsr->iField); + break; + case DBDATA_COLUMN_VALUE: { + if( pCsr->iField<0 ){ + sqlite3_result_int64(ctx, pCsr->iIntkey); + }else{ + sqlite3_int64 iType; + dbdataGetVarint(pCsr->pHdrPtr, &iType); + dbdataValue( + ctx, iType, pCsr->pPtr, &pCsr->pRec[pCsr->nRec] - pCsr->pPtr + ); + } + break; + } + } + } + return SQLITE_OK; +} + +/* +** Return the rowid for an sqlite_dbdata or sqlite_dptr table. +*/ +static int dbdataRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){ + DbdataCursor *pCsr = (DbdataCursor*)pCursor; + *pRowid = pCsr->iRowid; + return SQLITE_OK; +} + + +/* +** Invoke this routine to register the "sqlite_dbdata" virtual table module +*/ +static int sqlite3DbdataRegister(sqlite3 *db){ + static sqlite3_module dbdata_module = { + 0, /* iVersion */ + 0, /* xCreate */ + dbdataConnect, /* xConnect */ + dbdataBestIndex, /* xBestIndex */ + dbdataDisconnect, /* xDisconnect */ + 0, /* xDestroy */ + dbdataOpen, /* xOpen - open a cursor */ + dbdataClose, /* xClose - close a cursor */ + dbdataFilter, /* xFilter - configure scan constraints */ + dbdataNext, /* xNext - advance a cursor */ + dbdataEof, /* xEof - check for end of scan */ + dbdataColumn, /* xColumn - read data */ + dbdataRowid, /* xRowid - read data */ + 0, /* xUpdate */ + 0, /* xBegin */ + 0, /* xSync */ + 0, /* xCommit */ + 0, /* xRollback */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Sat Aug 31 04:25:36 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3EFB1E3585; Sat, 31 Aug 2019 04:25:36 +0000 (UTC) (envelope-from cy@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 46L3Dc0ppxz3yc3; Sat, 31 Aug 2019 04:25:36 +0000 (UTC) (envelope-from cy@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 F1C88B407; Sat, 31 Aug 2019 04:25:35 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7V4PZSE074003; Sat, 31 Aug 2019 04:25:35 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7V4PZwx074002; Sat, 31 Aug 2019 04:25:35 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908310425.x7V4PZwx074002@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sat, 31 Aug 2019 04:25:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351634 - in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-11 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Commit-Revision: 351634 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Aug 2019 04:25:36 -0000 Author: cy Date: Sat Aug 31 04:25:35 2019 New Revision: 351634 URL: https://svnweb.freebsd.org/changeset/base/351634 Log: MFC r351561: Fixup typo in comment. Obtained from: NetBSD ip_nat.c r1.7 Modified: stable/11/sys/contrib/ipfilter/netinet/ip_nat.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/sys/contrib/ipfilter/netinet/ip_nat.c Directory Properties: stable/12/ (props changed) Modified: stable/11/sys/contrib/ipfilter/netinet/ip_nat.c ============================================================================== --- stable/11/sys/contrib/ipfilter/netinet/ip_nat.c Sat Aug 31 04:23:25 2019 (r351633) +++ stable/11/sys/contrib/ipfilter/netinet/ip_nat.c Sat Aug 31 04:25:35 2019 (r351634) @@ -3073,7 +3073,7 @@ ipf_nat_newrdr(fin, nat, ni) /* Attempts to create a new NAT entry. Does not actually change the packet */ /* in any way. */ /* */ -/* This fucntion is in three main parts: (1) deal with creating a new NAT */ +/* This function is in three main parts: (1) deal with creating a new NAT */ /* structure for a "MAP" rule (outgoing NAT translation); (2) deal with */ /* creating a new NAT structure for a "RDR" rule (incoming NAT translation) */ /* and (3) building that structure and putting it into the NAT table(s). */ From owner-svn-src-stable-11@freebsd.org Sat Aug 31 04:27:00 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 56F15E36B0; Sat, 31 Aug 2019 04:27:00 +0000 (UTC) (envelope-from cy@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 46L3GC50Hsz3yrW; Sat, 31 Aug 2019 04:26:59 +0000 (UTC) (envelope-from cy@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 8CE44B40B; Sat, 31 Aug 2019 04:26:59 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7V4Qx5Q074138; Sat, 31 Aug 2019 04:26:59 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7V4QxA6074137; Sat, 31 Aug 2019 04:26:59 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908310426.x7V4QxA6074137@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sat, 31 Aug 2019 04:26:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351635 - in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-11 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Commit-Revision: 351635 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Aug 2019 04:27:00 -0000 Author: cy Date: Sat Aug 31 04:26:59 2019 New Revision: 351635 URL: https://svnweb.freebsd.org/changeset/base/351635 Log: MFC r351562: Destroy the mutex in case of error. Obtained from: NetBSD ip_nat.c r1.7 Modified: stable/11/sys/contrib/ipfilter/netinet/ip_nat.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/sys/contrib/ipfilter/netinet/ip_nat.c Directory Properties: stable/12/ (props changed) Modified: stable/11/sys/contrib/ipfilter/netinet/ip_nat.c ============================================================================== --- stable/11/sys/contrib/ipfilter/netinet/ip_nat.c Sat Aug 31 04:25:35 2019 (r351634) +++ stable/11/sys/contrib/ipfilter/netinet/ip_nat.c Sat Aug 31 04:26:59 2019 (r351635) @@ -3078,7 +3078,7 @@ ipf_nat_newrdr(fin, nat, ni) /* creating a new NAT structure for a "RDR" rule (incoming NAT translation) */ /* and (3) building that structure and putting it into the NAT table(s). */ /* */ -/* NOTE: natsave should NOT be used top point back to an ipstate_t struct */ +/* NOTE: natsave should NOT be used to point back to an ipstate_t struct */ /* as it can result in memory being corrupted. */ /* ------------------------------------------------------------------------ */ nat_t * @@ -3406,6 +3406,7 @@ ipf_nat_insert(softc, softn, nat) u_int hv0, hv1; u_int sp, dp; ipnat_t *in; + int ret; /* * Try and return an error as early as possible, so calculate the hash @@ -3488,7 +3489,10 @@ ipf_nat_insert(softc, softn, nat) nat->nat_mtu[1] = GETIFMTU_4(nat->nat_ifps[1]); } - return ipf_nat_hashtab_add(softc, softn, nat); + ret = ipf_nat_hashtab_add(softc, softn, nat); + if (ret == -1) + MUTEX_DESTROY(&nat->nat_lock); + return ret; } From owner-svn-src-stable-11@freebsd.org Sat Aug 31 04:28:23 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7B62DE3798; Sat, 31 Aug 2019 04:28:23 +0000 (UTC) (envelope-from cy@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 46L3Hq2cfmz405f; Sat, 31 Aug 2019 04:28:23 +0000 (UTC) (envelope-from cy@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 35427B40D; Sat, 31 Aug 2019 04:28:23 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7V4SNqK074251; Sat, 31 Aug 2019 04:28:23 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7V4SNa6074250; Sat, 31 Aug 2019 04:28:23 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908310428.x7V4SNa6074250@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sat, 31 Aug 2019 04:28:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351636 - in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-11 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Commit-Revision: 351636 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Aug 2019 04:28:23 -0000 Author: cy Date: Sat Aug 31 04:28:22 2019 New Revision: 351636 URL: https://svnweb.freebsd.org/changeset/base/351636 Log: MFC r351563: Document ipf_nat_hashtab_add() return codes. Modified: stable/11/sys/contrib/ipfilter/netinet/ip_nat.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/sys/contrib/ipfilter/netinet/ip_nat.c Directory Properties: stable/12/ (props changed) Modified: stable/11/sys/contrib/ipfilter/netinet/ip_nat.c ============================================================================== --- stable/11/sys/contrib/ipfilter/netinet/ip_nat.c Sat Aug 31 04:26:59 2019 (r351635) +++ stable/11/sys/contrib/ipfilter/netinet/ip_nat.c Sat Aug 31 04:28:22 2019 (r351636) @@ -3498,6 +3498,7 @@ ipf_nat_insert(softc, softn, nat) /* ------------------------------------------------------------------------ */ /* Function: ipf_nat_hashtab_add */ +/* Returns: int - 0 == sucess, -1 == failure */ /* Parameters: softc(I) - pointer to soft context main structure */ /* softn(I) - pointer to NAT context structure */ /* nat(I) - pointer to NAT structure */ From owner-svn-src-stable-11@freebsd.org Sat Aug 31 08:52:58 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A4E04CB14D; Sat, 31 Aug 2019 08:52:58 +0000 (UTC) (envelope-from kib@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 46L9963lLGz4GSY; Sat, 31 Aug 2019 08:52:58 +0000 (UTC) (envelope-from kib@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 6238CE6D4; Sat, 31 Aug 2019 08:52:58 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7V8qwkO038064; Sat, 31 Aug 2019 08:52:58 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7V8qwts038063; Sat, 31 Aug 2019 08:52:58 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201908310852.x7V8qwts038063@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 31 Aug 2019 08:52:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351640 - stable/11/sys/vm X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/vm X-SVN-Commit-Revision: 351640 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Aug 2019 08:52:58 -0000 Author: kib Date: Sat Aug 31 08:52:57 2019 New Revision: 351640 URL: https://svnweb.freebsd.org/changeset/base/351640 Log: MFC r351453: Make stack grow use the same gap as stack create. Modified: stable/11/sys/vm/vm_map.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/vm_map.c ============================================================================== --- stable/11/sys/vm/vm_map.c Sat Aug 31 08:40:41 2019 (r351639) +++ stable/11/sys/vm/vm_map.c Sat Aug 31 08:52:57 2019 (r351640) @@ -3686,8 +3686,20 @@ vm_map_stack_locked(vm_map_t map, vm_offset_t addrbos, rv = vm_map_insert(map, NULL, 0, gap_bot, gap_top, VM_PROT_NONE, VM_PROT_NONE, MAP_CREATE_GUARD | (orient == MAP_STACK_GROWS_DOWN ? MAP_CREATE_STACK_GAP_DN : MAP_CREATE_STACK_GAP_UP)); - if (rv != KERN_SUCCESS) + if (rv == KERN_SUCCESS) { + /* + * Gap can never successfully handle a fault, so + * read-ahead logic is never used for it. Re-use + * next_read of the gap entry to store + * stack_guard_page for vm_map_growstack(). + */ + if (orient == MAP_STACK_GROWS_DOWN) + new_entry->prev->next_read = sgp; + else + new_entry->next->next_read = sgp; + } else { (void)vm_map_delete(map, bot, top); + } return (rv); } @@ -3728,7 +3740,6 @@ vm_map_growstack(vm_map_t map, vm_offset_t addr, vm_ma MPASS(!map->system_map); - guard = stack_guard_page * PAGE_SIZE; lmemlim = lim_cur(curthread, RLIMIT_MEMLOCK); stacklim = lim_cur(curthread, RLIMIT_STACK); vmemlim = lim_cur(curthread, RLIMIT_VMEM); @@ -3755,6 +3766,7 @@ retry: } else { return (KERN_FAILURE); } + guard = gap_entry->next_read; max_grow = gap_entry->end - gap_entry->start; if (guard > max_grow) return (KERN_NO_SPACE);