From owner-svn-src-stable-10@freebsd.org Mon Mar 12 16:04:11 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AE849F51686; Mon, 12 Mar 2018 16:04:11 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5CF1A82EA4; Mon, 12 Mar 2018 16:04:11 +0000 (UTC) (envelope-from brooks@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 533A25F60; Mon, 12 Mar 2018 16:04:11 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2CG4BPk063014; Mon, 12 Mar 2018 16:04:11 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2CG4Ac2063011; Mon, 12 Mar 2018 16:04:10 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201803121604.w2CG4Ac2063011@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Mon, 12 Mar 2018 16:04:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r330801 - stable/10/lib/libc/sys X-SVN-Group: stable-10 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: stable/10/lib/libc/sys X-SVN-Commit-Revision: 330801 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-10@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Mar 2018 16:04:11 -0000 Author: brooks Date: Mon Mar 12 16:04:10 2018 New Revision: 330801 URL: https://svnweb.freebsd.org/changeset/base/330801 Log: MFC r330409: Refer to SysV IPC permissions as numeric constants. POSIX defines no macros for these permissions. Also remove unneeded headers from synopsis. PR: 225905 Reviewed by: wblock Differential Revision: https://reviews.freebsd.org/D14461 Modified: stable/10/lib/libc/sys/msgget.2 stable/10/lib/libc/sys/semget.2 stable/10/lib/libc/sys/shmget.2 Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/sys/msgget.2 ============================================================================== --- stable/10/lib/libc/sys/msgget.2 Mon Mar 12 15:57:55 2018 (r330800) +++ stable/10/lib/libc/sys/msgget.2 Mon Mar 12 16:04:10 2018 (r330801) @@ -31,7 +31,7 @@ .\" $FreeBSD$ .\" .\"/ -.Dd July 9, 2009 +.Dd March 4, 2018 .Dt MSGGET 2 .Os .Sh NAME @@ -40,8 +40,6 @@ .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In sys/types.h -.In sys/ipc.h .In sys/msg.h .Ft int .Fn msgget "key_t key" "int msgflg" @@ -83,7 +81,22 @@ are set to the effective gid of the calling process. .It .Va msg_perm.mode is set to the lower 9 bits of -.Fa msgflg . +.Fa msgflg +which are set by ORing these constants: +.Bl -tag -width 0000 +.It Dv 0400 +Read access for user. +.It Dv 0200 +Write access for user. +.It Dv 0040 +Read access for group. +.It Dv 0020 +Write access for group. +.It Dv 0004 +Read access for other. +.It Dv 0002 +Write access for other. +.El .It .Va msg_cbytes , .Va msg_qnum , Modified: stable/10/lib/libc/sys/semget.2 ============================================================================== --- stable/10/lib/libc/sys/semget.2 Mon Mar 12 15:57:55 2018 (r330800) +++ stable/10/lib/libc/sys/semget.2 Mon Mar 12 16:04:10 2018 (r330801) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 7, 2016 +.Dd March 4, 2018 .Dt SEMGET 2 .Os .Sh NAME @@ -34,8 +34,6 @@ .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In sys/types.h -.In sys/ipc.h .In sys/sem.h .Ft int .Fn semget "key_t key" "int nsems" "int flag" @@ -77,23 +75,22 @@ may be used to generate a key from a pathname. .\" Likewise for this section, except SHM_* becomes SEM_*. .\" .Pp -The mode of a newly created IPC object is determined by -.Em OR Ns 'ing -the following constants into the +The mode of a newly created IPC object is determined by ORing these constants +into the .Fa flag argument: -.Bl -tag -width XSEM_WXX6XXX -.It Dv SEM_R +.Bl -tag -width 0000 +.It Dv 0400 Read access for user. -.It Dv SEM_A +.It Dv 0200 Alter access for user. -.It Dv ( SEM_R>>3 ) +.It Dv 0040 Read access for group. -.It Dv ( SEM_A>>3 ) +.It Dv 0020 Alter access for group. -.It Dv ( SEM_R>>6 ) +.It Dv 0004 Read access for other. -.It Dv ( SEM_A>>6 ) +.It Dv 0002 Alter access for other. .El .Pp Modified: stable/10/lib/libc/sys/shmget.2 ============================================================================== --- stable/10/lib/libc/sys/shmget.2 Mon Mar 12 15:57:55 2018 (r330800) +++ stable/10/lib/libc/sys/shmget.2 Mon Mar 12 16:04:10 2018 (r330801) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 17, 2010 +.Dd March 4, 2018 .Dt SHMGET 2 .Os .Sh NAME @@ -34,8 +34,6 @@ .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In sys/types.h -.In sys/ipc.h .In sys/shm.h .Ft int .Fn shmget "key_t key" "size_t size" "int flag" @@ -74,22 +72,21 @@ may be used to generate a key from a pathname. .El .Pp The mode of a newly created IPC object is determined by -.Em OR Ns 'ing -the following constants into the +which are set by ORing these constants into the .Fa flag argument: -.Bl -tag -width XSHM_WXX6XXX -.It Dv S_IRUSR +.Bl -tag -width 0000 +.It Dv 0400 Read access for owner. -.It Dv S_IWUSR +.It Dv 0200 Write access for owner. -.It Dv S_IRGRP +.It Dv 0040 Read access for group. -.It Dv S_IWGRP +.It Dv 0020 Write access for group. -.It Dv S_IROTH +.It Dv 0004 Read access for other. -.It Dv S_IWOTH +.It Dv 0002 Write access for other. .El .\" @@ -142,5 +139,4 @@ already exists. .Xr shmat 2 , .Xr shmctl 2 , .Xr shmdt 2 , -.Xr stat 2 , .Xr ftok 3 From owner-svn-src-stable-10@freebsd.org Mon Mar 12 17:37:39 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 551B2F2EFCE; Mon, 12 Mar 2018 17:37:39 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0A37387C21; Mon, 12 Mar 2018 17:37:39 +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 053FD6D2A; Mon, 12 Mar 2018 17:37:39 +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 w2CHbclB008204; Mon, 12 Mar 2018 17:37:38 GMT (envelope-from eugen@FreeBSD.org) Received: (from eugen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2CHbcWX008197; Mon, 12 Mar 2018 17:37:38 GMT (envelope-from eugen@FreeBSD.org) Message-Id: <201803121737.w2CHbcWX008197@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eugen set sender to eugen@FreeBSD.org using -f From: Eugene Grosbein Date: Mon, 12 Mar 2018 17:37:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r330805 - stable/10/usr.sbin/ppp X-SVN-Group: stable-10 X-SVN-Commit-Author: eugen X-SVN-Commit-Paths: stable/10/usr.sbin/ppp X-SVN-Commit-Revision: 330805 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-10@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Mar 2018 17:37:39 -0000 Author: eugen Date: Mon Mar 12 17:37:38 2018 New Revision: 330805 URL: https://svnweb.freebsd.org/changeset/base/330805 Log: MFC r329105: ppp(8): fix code producing debugging logs ppp(8): fix code producing debugging logs Fix several cases when long buffer is copied to shorter one using snprintf that results in contents truncation and clobbering unsaved errno value and creation of misleading logs. PR: 218517 Approved by: mav (mentor) Modified: stable/10/usr.sbin/ppp/defs.h stable/10/usr.sbin/ppp/iface.c stable/10/usr.sbin/ppp/ip.c stable/10/usr.sbin/ppp/ipv6cp.c stable/10/usr.sbin/ppp/ncpaddr.c stable/10/usr.sbin/ppp/route.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/ppp/defs.h ============================================================================== --- stable/10/usr.sbin/ppp/defs.h Mon Mar 12 17:36:37 2018 (r330804) +++ stable/10/usr.sbin/ppp/defs.h Mon Mar 12 17:37:38 2018 (r330805) @@ -117,6 +117,8 @@ #define ROUNDUP(x) ((x) ? (1 + (((x) - 1) | (sizeof(long) - 1))) : sizeof(long)) +#define NCP_ASCIIBUFFERSIZE 52 + #ifdef __NetBSD__ extern void randinit(void); #else Modified: stable/10/usr.sbin/ppp/iface.c ============================================================================== --- stable/10/usr.sbin/ppp/iface.c Mon Mar 12 17:36:37 2018 (r330804) +++ stable/10/usr.sbin/ppp/iface.c Mon Mar 12 17:37:38 2018 (r330805) @@ -209,7 +209,7 @@ iface_addr_Zap(const char *name, struct iface_addr *ad #endif struct sockaddr_in *me4, *msk4, *peer4; struct sockaddr_storage ssme, sspeer, ssmsk; - int res; + int res, saved_errno; ncprange_getsa(&addr->ifa, &ssme, &ssmsk); ncpaddr_getsa(&addr->peer, &sspeer); @@ -235,8 +235,9 @@ iface_addr_Zap(const char *name, struct iface_addr *ad memcpy(peer4, &sspeer, sizeof *peer4); res = ID0ioctl(s, SIOCDIFADDR, &ifra); + saved_errno = errno; if (log_IsKept(LogDEBUG)) { - char buf[100]; + char buf[NCP_ASCIIBUFFERSIZE]; snprintf(buf, sizeof buf, "%s", ncprange_ntoa(&addr->ifa)); log_Printf(LogWARN, "%s: DIFADDR %s -> %s returns %d\n", @@ -260,12 +261,13 @@ iface_addr_Zap(const char *name, struct iface_addr *ad ifra6.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME; res = ID0ioctl(s, SIOCDIFADDR_IN6, &ifra6); + saved_errno = errno; break; #endif } if (res == -1) { - char dst[40]; + char dst[NCP_ASCIIBUFFERSIZE]; const char *end = #ifndef NOINET6 ncprange_family(&addr->ifa) == AF_INET6 ? "_IN6" : @@ -274,11 +276,11 @@ iface_addr_Zap(const char *name, struct iface_addr *ad if (ncpaddr_family(&addr->peer) == AF_UNSPEC) log_Printf(LogWARN, "iface rm: ioctl(SIOCDIFADDR%s, %s): %s\n", - end, ncprange_ntoa(&addr->ifa), strerror(errno)); + end, ncprange_ntoa(&addr->ifa), strerror(saved_errno)); else { snprintf(dst, sizeof dst, "%s", ncpaddr_ntoa(&addr->peer)); log_Printf(LogWARN, "iface rm: ioctl(SIOCDIFADDR%s, %s -> %s): %s\n", - end, ncprange_ntoa(&addr->ifa), dst, strerror(errno)); + end, ncprange_ntoa(&addr->ifa), dst, strerror(saved_errno)); } } @@ -294,7 +296,7 @@ iface_addr_Add(const char *name, struct iface_addr *ad #endif struct sockaddr_in *me4, *msk4, *peer4; struct sockaddr_storage ssme, sspeer, ssmsk; - int res; + int res, saved_errno; ncprange_getsa(&addr->ifa, &ssme, &ssmsk); ncpaddr_getsa(&addr->peer, &sspeer); @@ -320,8 +322,9 @@ iface_addr_Add(const char *name, struct iface_addr *ad memcpy(peer4, &sspeer, sizeof *peer4); res = ID0ioctl(s, SIOCAIFADDR, &ifra); + saved_errno = errno; if (log_IsKept(LogDEBUG)) { - char buf[100]; + char buf[NCP_ASCIIBUFFERSIZE]; snprintf(buf, sizeof buf, "%s", ncprange_ntoa(&addr->ifa)); log_Printf(LogWARN, "%s: AIFADDR %s -> %s returns %d\n", @@ -345,12 +348,13 @@ iface_addr_Add(const char *name, struct iface_addr *ad ifra6.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME; res = ID0ioctl(s, SIOCAIFADDR_IN6, &ifra6); + saved_errno = errno; break; #endif } if (res == -1) { - char dst[40]; + char dst[NCP_ASCIIBUFFERSIZE]; const char *end = #ifndef NOINET6 ncprange_family(&addr->ifa) == AF_INET6 ? "_IN6" : @@ -359,11 +363,11 @@ iface_addr_Add(const char *name, struct iface_addr *ad if (ncpaddr_family(&addr->peer) == AF_UNSPEC) log_Printf(LogWARN, "iface add: ioctl(SIOCAIFADDR%s, %s): %s\n", - end, ncprange_ntoa(&addr->ifa), strerror(errno)); + end, ncprange_ntoa(&addr->ifa), strerror(saved_errno)); else { snprintf(dst, sizeof dst, "%s", ncpaddr_ntoa(&addr->peer)); log_Printf(LogWARN, "iface add: ioctl(SIOCAIFADDR%s, %s -> %s): %s\n", - end, ncprange_ntoa(&addr->ifa), dst, strerror(errno)); + end, ncprange_ntoa(&addr->ifa), dst, strerror(saved_errno)); } } Modified: stable/10/usr.sbin/ppp/ip.c ============================================================================== --- stable/10/usr.sbin/ppp/ip.c Mon Mar 12 17:36:37 2018 (r330804) +++ stable/10/usr.sbin/ppp/ip.c Mon Mar 12 17:37:38 2018 (r330805) @@ -224,7 +224,7 @@ FilterCheck(const unsigned char *packet, int match; /* true if condition matched */ int mindata; /* minimum data size or zero */ const struct filterent *fp = filter->rule; - char dbuff[100], dstip[16]; + char dbuff[100], dstip[NCP_ASCIIBUFFERSIZE]; struct ncpaddr srcaddr, dstaddr; const char *payload; /* IP payload */ int datalen; /* IP datagram length */ Modified: stable/10/usr.sbin/ppp/ipv6cp.c ============================================================================== --- stable/10/usr.sbin/ppp/ipv6cp.c Mon Mar 12 17:36:37 2018 (r330804) +++ stable/10/usr.sbin/ppp/ipv6cp.c Mon Mar 12 17:37:38 2018 (r330805) @@ -465,7 +465,7 @@ ipv6cp_LayerUp(struct fsm *fp) { /* We're now up */ struct ipv6cp *ipv6cp = fsm2ipv6cp(fp); - char tbuff[40]; + char tbuff[NCP_ASCIIBUFFERSIZE]; log_Printf(LogIPV6CP, "%s: LayerUp.\n", fp->link->name); if (!ipv6cp_InterfaceUp(ipv6cp)) @@ -522,7 +522,7 @@ ipv6cp_LayerDown(struct fsm *fp) /* About to come down */ struct ipv6cp *ipv6cp = fsm2ipv6cp(fp); static int recursing; - char addr[40]; + char addr[NCP_ASCIIBUFFERSIZE]; if (!recursing++) { snprintf(addr, sizeof addr, "%s", ncpaddr_ntoa(&ipv6cp->myaddr)); Modified: stable/10/usr.sbin/ppp/ncpaddr.c ============================================================================== --- stable/10/usr.sbin/ppp/ncpaddr.c Mon Mar 12 17:36:37 2018 (r330804) +++ stable/10/usr.sbin/ppp/ncpaddr.c Mon Mar 12 17:37:38 2018 (r330805) @@ -76,8 +76,6 @@ #define ncpaddr_ip6addr u.ip6addr #endif -#define NCP_ASCIIBUFFERSIZE 52 - static struct in_addr bits2mask4(int bits) { Modified: stable/10/usr.sbin/ppp/route.c ============================================================================== --- stable/10/usr.sbin/ppp/route.c Mon Mar 12 17:36:37 2018 (r330804) +++ stable/10/usr.sbin/ppp/route.c Mon Mar 12 17:37:38 2018 (r330805) @@ -435,7 +435,7 @@ route_IfDelete(struct bundle *bundle, int all) ) && (all || (rtm->rtm_flags & RTF_GATEWAY))) { if (log_IsKept(LogDEBUG)) { - char gwstr[41]; + char gwstr[NCP_ASCIIBUFFERSIZE]; struct ncpaddr gw; ncprange_setsa(&range, sa[RTAX_DST], sa[RTAX_NETMASK]); ncpaddr_setsa(&gw, sa[RTAX_GATEWAY]); @@ -840,7 +840,7 @@ failed: } if (log_IsKept(LogDEBUG)) { - char gwstr[40]; + char gwstr[NCP_ASCIIBUFFERSIZE]; if (gw) snprintf(gwstr, sizeof gwstr, "%s", ncpaddr_ntoa(gw)); From owner-svn-src-stable-10@freebsd.org Wed Mar 14 19:04:41 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 854FDF35D4A; Wed, 14 Mar 2018 19:04:41 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3711771617; Wed, 14 Mar 2018 19:04:41 +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 320C83DEA; Wed, 14 Mar 2018 19:04:41 +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 w2EJ4fdQ017954; Wed, 14 Mar 2018 19:04:41 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2EJ4eRM017948; Wed, 14 Mar 2018 19:04:40 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201803141904.w2EJ4eRM017948@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 14 Mar 2018 19:04:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r330938 - in stable/10/sys: dev/acpica dev/cardbus dev/pci powerpc/ofw sparc64/pci X-SVN-Group: stable-10 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable/10/sys: dev/acpica dev/cardbus dev/pci powerpc/ofw sparc64/pci X-SVN-Commit-Revision: 330938 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-10@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Mar 2018 19:04:41 -0000 Author: jhb Date: Wed Mar 14 19:04:40 2018 New Revision: 330938 URL: https://svnweb.freebsd.org/changeset/base/330938 Log: Convert pci_delete_child() to a bus_child_deleted() method. Instead of providing a wrapper around device_delete_child() that the PCI bus and child bus drivers must call explicitly, move the bulk of the logic from pci_delete_child() into a bus_child_deleted() method (pci_child_deleted()). This allows PCI devices to be safely deleted via device_delete_child(). - Add a bus_child_deleted method to the ACPI PCI bus which clears the device_t associated with the corresponding ACPI handle in addition to the normal PCI bus cleanup. - Change cardbus_detach_card to call device_delete_children() and move CardBus-specific delete logic into a new cardbus_child_deleted() method. - Use device_delete_child() instead of pci_delete_child() in the SRIOV code. - Add a bus_child_deleted method to the OpenFirmware PCI bus drivers which frees the OpenFirmware device info for each PCI device. To preserve KBI, a pci_delete_child() function is left in place that just calls device_delete_child(). PR: 226562 Requested by: dexuan Modified: stable/10/sys/dev/acpica/acpi_pci.c stable/10/sys/dev/cardbus/cardbus.c stable/10/sys/dev/pci/pci.c stable/10/sys/dev/pci/pci_private.h stable/10/sys/powerpc/ofw/ofw_pcibus.c stable/10/sys/sparc64/pci/ofw_pcibus.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/acpica/acpi_pci.c ============================================================================== --- stable/10/sys/dev/acpica/acpi_pci.c Wed Mar 14 18:27:06 2018 (r330937) +++ stable/10/sys/dev/acpica/acpi_pci.c Wed Mar 14 19:04:40 2018 (r330938) @@ -70,6 +70,7 @@ CTASSERT(ACPI_STATE_D2 == PCI_POWERSTATE_D2); CTASSERT(ACPI_STATE_D3 == PCI_POWERSTATE_D3); static int acpi_pci_attach(device_t dev); +static void acpi_pci_child_deleted(device_t dev, device_t child); static int acpi_pci_child_location_str_method(device_t cbdev, device_t child, char *buf, size_t buflen); static int acpi_pci_probe(device_t dev); @@ -92,6 +93,7 @@ static device_method_t acpi_pci_methods[] = { /* Bus interface */ DEVMETHOD(bus_read_ivar, acpi_pci_read_ivar), DEVMETHOD(bus_write_ivar, acpi_pci_write_ivar), + DEVMETHOD(bus_child_deleted, acpi_pci_child_deleted), DEVMETHOD(bus_child_location_str, acpi_pci_child_location_str_method), DEVMETHOD(bus_get_dma_tag, acpi_pci_get_dma_tag), DEVMETHOD(bus_get_domain, acpi_get_domain), @@ -143,6 +145,16 @@ acpi_pci_write_ivar(device_t dev, device_t child, int return (0); } return (pci_write_ivar(dev, child, which, value)); +} + +static void +acpi_pci_child_deleted(device_t dev, device_t child) +{ + struct acpi_pci_devinfo *dinfo = device_get_ivars(child); + + if (acpi_get_device(dinfo->ap_handle) == child) + AcpiDetachData(dinfo->ap_handle, acpi_fake_objhandler); + pci_child_deleted(dev, child); } static int Modified: stable/10/sys/dev/cardbus/cardbus.c ============================================================================== --- stable/10/sys/dev/cardbus/cardbus.c Wed Mar 14 18:27:06 2018 (r330937) +++ stable/10/sys/dev/cardbus/cardbus.c Wed Mar 14 19:04:40 2018 (r330938) @@ -226,31 +226,30 @@ cardbus_attach_card(device_t cbdev) return (ENOENT); } +static void +cardbus_child_deleted(device_t cbdev, device_t child) +{ + struct cardbus_devinfo *dinfo = device_get_ivars(child); + + if (dinfo->pci.cfg.dev != child) + device_printf(cbdev, "devinfo dev mismatch\n"); + cardbus_device_destroy(dinfo); + pci_child_deleted(cbdev, child); +} + static int cardbus_detach_card(device_t cbdev) { - int numdevs; - device_t *devlist; - int tmp; int err = 0; - if (device_get_children(cbdev, &devlist, &numdevs) != 0) - return (ENOENT); - if (numdevs == 0) { - free(devlist, M_TEMP); - return (ENOENT); - } + err = bus_generic_detach(cbdev); + if (err) + return (err); + err = device_delete_children(cbdev); + if (err) + return (err); - for (tmp = 0; tmp < numdevs; tmp++) { - struct cardbus_devinfo *dinfo = device_get_ivars(devlist[tmp]); - - if (dinfo->pci.cfg.dev != devlist[tmp]) - device_printf(cbdev, "devinfo dev mismatch\n"); - cardbus_device_destroy(dinfo); - pci_delete_child(cbdev, devlist[tmp]); - } POWER_DISABLE_SOCKET(device_get_parent(cbdev), cbdev); - free(devlist, M_TEMP); return (err); } @@ -335,6 +334,7 @@ static device_method_t cardbus_methods[] = { DEVMETHOD(device_resume, cardbus_resume), /* Bus interface */ + DEVMETHOD(bus_child_deleted, cardbus_child_deleted), DEVMETHOD(bus_get_dma_tag, bus_generic_get_dma_tag), DEVMETHOD(bus_read_ivar, cardbus_read_ivar), DEVMETHOD(bus_driver_added, cardbus_driver_added), Modified: stable/10/sys/dev/pci/pci.c ============================================================================== --- stable/10/sys/dev/pci/pci.c Wed Mar 14 18:27:06 2018 (r330937) +++ stable/10/sys/dev/pci/pci.c Wed Mar 14 19:04:40 2018 (r330938) @@ -154,6 +154,7 @@ static device_method_t pci_methods[] = { DEVMETHOD(bus_release_resource, pci_release_resource), DEVMETHOD(bus_activate_resource, pci_activate_resource), DEVMETHOD(bus_deactivate_resource, pci_deactivate_resource), + DEVMETHOD(bus_child_deleted, pci_child_deleted), DEVMETHOD(bus_child_detached, pci_child_detached), DEVMETHOD(bus_child_pnpinfo_str, pci_child_pnpinfo_str_method), DEVMETHOD(bus_child_location_str, pci_child_location_str_method), @@ -4883,7 +4884,7 @@ pci_deactivate_resource(device_t dev, device_t child, } void -pci_delete_child(device_t dev, device_t child) +pci_child_deleted(device_t dev, device_t child) { struct resource_list_entry *rle; struct resource_list *rl; @@ -4892,13 +4893,14 @@ pci_delete_child(device_t dev, device_t child) dinfo = device_get_ivars(child); rl = &dinfo->resources; - if (device_is_attached(child)) - device_detach(child); - /* Turn off access to resources we're about to free */ - pci_write_config(child, PCIR_COMMAND, pci_read_config(child, - PCIR_COMMAND, 2) & ~(PCIM_CMD_MEMEN | PCIM_CMD_PORTEN), 2); + if (bus_child_present(child) != 0) { + pci_write_config(child, PCIR_COMMAND, pci_read_config(child, + PCIR_COMMAND, 2) & ~(PCIM_CMD_MEMEN | PCIM_CMD_PORTEN), 2); + pci_disable_busmaster(child); + } + /* Free all allocated resources */ STAILQ_FOREACH(rle, rl, link) { if (rle->res) { @@ -4918,8 +4920,17 @@ pci_delete_child(device_t dev, device_t child) } resource_list_free(rl); - device_delete_child(dev, child); pci_freecfg(dinfo); +} + +/* KBI compatability shim. */ +extern void pci_delete_child(device_t dev, device_t child); + +void +pci_delete_child(device_t dev, device_t child) +{ + + device_delete_child (dev, child); } void Modified: stable/10/sys/dev/pci/pci_private.h ============================================================================== --- stable/10/sys/dev/pci/pci_private.h Wed Mar 14 18:27:06 2018 (r330937) +++ stable/10/sys/dev/pci/pci_private.h Wed Mar 14 19:04:40 2018 (r330938) @@ -54,7 +54,6 @@ void pci_add_child(device_t bus, struct pci_devinfo * void pci_add_resources(device_t bus, device_t dev, int force, uint32_t prefetchmask); int pci_attach_common(device_t dev); -void pci_delete_child(device_t dev, device_t child); void pci_driver_added(device_t dev, driver_t *driver); int pci_print_child(device_t dev, device_t child); void pci_probe_nomatch(device_t dev, device_t child); @@ -118,6 +117,7 @@ struct pci_devinfo *pci_read_device(device_t pcib, int size_t size); void pci_print_verbose(struct pci_devinfo *dinfo); int pci_freecfg(struct pci_devinfo *dinfo); +void pci_child_deleted(device_t dev, device_t child); void pci_child_detached(device_t dev, device_t child); int pci_child_location_str_method(device_t cbdev, device_t child, char *buf, size_t buflen); Modified: stable/10/sys/powerpc/ofw/ofw_pcibus.c ============================================================================== --- stable/10/sys/powerpc/ofw/ofw_pcibus.c Wed Mar 14 18:27:06 2018 (r330937) +++ stable/10/sys/powerpc/ofw/ofw_pcibus.c Wed Mar 14 19:04:40 2018 (r330938) @@ -61,6 +61,7 @@ static device_probe_t ofw_pcibus_probe; static device_attach_t ofw_pcibus_attach; static pci_assign_interrupt_t ofw_pcibus_assign_interrupt; static ofw_bus_get_devinfo_t ofw_pcibus_get_devinfo; +static bus_child_deleted_t ofw_pcibus_child_deleted; static int ofw_pcibus_child_pnpinfo_str_method(device_t cbdev, device_t child, char *buf, size_t buflen); @@ -73,6 +74,7 @@ static device_method_t ofw_pcibus_methods[] = { DEVMETHOD(device_attach, ofw_pcibus_attach), /* Bus interface */ + DEVMETHOD(bus_child_deleted, ofw_pcibus_child_deleted), DEVMETHOD(bus_child_pnpinfo_str, ofw_pcibus_child_pnpinfo_str_method), /* PCI interface */ @@ -265,6 +267,16 @@ ofw_pcibus_enum_bus(device_t dev, u_int domain, u_int pci_add_child(dev, (struct pci_devinfo *)dinfo); } } +} + +static void +ofw_pcibus_child_deleted(device_t dev, device_t child) +{ + struct ofw_pcibus_devinfo *dinfo; + + dinfo = device_get_ivars(dev); + ofw_bus_gen_destroy_devinfo(&dinfo->opd_obdinfo); + pci_child_deleted(dev, child); } static int Modified: stable/10/sys/sparc64/pci/ofw_pcibus.c ============================================================================== --- stable/10/sys/sparc64/pci/ofw_pcibus.c Wed Mar 14 18:27:06 2018 (r330937) +++ stable/10/sys/sparc64/pci/ofw_pcibus.c Wed Mar 14 19:04:40 2018 (r330938) @@ -65,6 +65,7 @@ static void ofw_pcibus_setup_device(device_t bridge, u u_int busno, u_int slot, u_int func); /* Methods */ +static bus_child_deleted_t ofw_pcibus_child_deleted; static bus_child_pnpinfo_str_t ofw_pcibus_pnpinfo_str; static device_attach_t ofw_pcibus_attach; static device_probe_t ofw_pcibus_probe; @@ -77,6 +78,7 @@ static device_method_t ofw_pcibus_methods[] = { DEVMETHOD(device_attach, ofw_pcibus_attach), /* Bus interface */ + DEVMETHOD(bus_child_deleted, ofw_pcibus_child_deleted), DEVMETHOD(bus_child_pnpinfo_str, ofw_pcibus_pnpinfo_str), /* PCI interface */ @@ -325,6 +327,16 @@ ofw_pcibus_get_devinfo(device_t bus, device_t dev) dinfo = device_get_ivars(dev); return (&dinfo->opd_obdinfo); +} + +static void +ofw_pcibus_child_deleted(device_t dev, device_t child) +{ + struct ofw_pcibus_devinfo *dinfo; + + dinfo = device_get_ivars(dev); + ofw_bus_gen_destroy_devinfo(&dinfo->opd_obdinfo); + pci_child_deleted(dev, child); } static int From owner-svn-src-stable-10@freebsd.org Wed Mar 14 23:59:53 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E144EF53998; Wed, 14 Mar 2018 23:59:52 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 93D767EA31; Wed, 14 Mar 2018 23:59:52 +0000 (UTC) (envelope-from marius@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 74A646A7C; Wed, 14 Mar 2018 23:59:52 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2ENxqZR066054; Wed, 14 Mar 2018 23:59:52 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2ENxqO0066053; Wed, 14 Mar 2018 23:59:52 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201803142359.w2ENxqO0066053@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Wed, 14 Mar 2018 23:59:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r330959 - stable/10/sys/x86/x86 X-SVN-Group: stable-10 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: stable/10/sys/x86/x86 X-SVN-Commit-Revision: 330959 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-10@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Mar 2018 23:59:53 -0000 Author: marius Date: Wed Mar 14 23:59:52 2018 New Revision: 330959 URL: https://svnweb.freebsd.org/changeset/base/330959 Log: MFC: 327314 With the advent of interrupt remapping, Intel has repurposed bit 11 (now: Interrupt_Index[15]) and assigned the previously reserved bits 55:48 (Interrupt_Index[14:0] goes into 63:49 while Destination Field used 63:56 and bit 48 now is Interrupt_Format) in the IO redirection tables (see the VT-d specification, "5.1.5.1 I/OxAPIC Programming"). Thus, when not using interrupt remapping, ensure that all previously reserved bits in the high part of the RTEs are zero instead of doing a read-modify-write for their Destination Field bits only. Otherwise, on machines based on Apollo Lake and its derivatives such as Denverton, typically some of the previously preserved bits remain set after boot when not employing interrupt remapping. The result is that INTx interrupts are not getting delivered. Note: With an AMD IOMMU, interrupt remapping apparently bypasses the IO APIC altogether. Submitted by: loos (modulo comment) Reviewed by: jhb (modulo comment) Modified: stable/10/sys/x86/x86/io_apic.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/x86/x86/io_apic.c ============================================================================== --- stable/10/sys/x86/x86/io_apic.c Wed Mar 14 23:59:50 2018 (r330958) +++ stable/10/sys/x86/x86/io_apic.c Wed Mar 14 23:59:52 2018 (r330959) @@ -252,7 +252,7 @@ static void ioapic_program_intpin(struct ioapic_intsrc *intpin) { struct ioapic *io = (struct ioapic *)intpin->io_intsrc.is_pic; - uint32_t low, high, value; + uint32_t low, high; /* * If a pin is completely invalid or if it is valid but hasn't @@ -270,7 +270,11 @@ ioapic_program_intpin(struct ioapic_intsrc *intpin) return; } - /* Set the destination. */ + /* + * Set the destination. Note that with Intel interrupt remapping, + * the previously reserved bits 55:48 now have a purpose so ensure + * these are zero. + */ low = IOART_DESTPHY; high = intpin->io_cpu << APIC_ID_SHIFT; @@ -308,10 +312,7 @@ ioapic_program_intpin(struct ioapic_intsrc *intpin) } /* Write the values to the APIC. */ - value = ioapic_read(io->io_addr, IOAPIC_REDTBL_HI(intpin->io_intpin)); - value &= ~IOART_DEST; - value |= high; - ioapic_write(io->io_addr, IOAPIC_REDTBL_HI(intpin->io_intpin), value); + ioapic_write(io->io_addr, IOAPIC_REDTBL_HI(intpin->io_intpin), high); intpin->io_lowreg = low; ioapic_write(io->io_addr, IOAPIC_REDTBL_LO(intpin->io_intpin), low); } From owner-svn-src-stable-10@freebsd.org Thu Mar 15 00:44:35 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3C67FF5614A; Thu, 15 Mar 2018 00:44:35 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E1B7280752; Thu, 15 Mar 2018 00:44:34 +0000 (UTC) (envelope-from emaste@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 DC7697213; Thu, 15 Mar 2018 00:44:34 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2F0iYLp091025; Thu, 15 Mar 2018 00:44:34 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2F0iYMG091024; Thu, 15 Mar 2018 00:44:34 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201803150044.w2F0iYMG091024@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 15 Mar 2018 00:44:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r330961 - stable/10/sys/dev/asmc X-SVN-Group: stable-10 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/10/sys/dev/asmc X-SVN-Commit-Revision: 330961 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-10@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Mar 2018 00:44:35 -0000 Author: emaste Date: Thu Mar 15 00:44:34 2018 New Revision: 330961 URL: https://svnweb.freebsd.org/changeset/base/330961 Log: MFC r330667: asmc: update temperature sensor name/description PR: 225911 Submitted by: Trev Modified: stable/10/sys/dev/asmc/asmcvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/asmc/asmcvar.h ============================================================================== --- stable/10/sys/dev/asmc/asmcvar.h Thu Mar 15 00:43:25 2018 (r330960) +++ stable/10/sys/dev/asmc/asmcvar.h Thu Mar 15 00:44:34 2018 (r330961) @@ -241,7 +241,7 @@ struct asmc_softc { "cpu0_proximity", "hdd_bay", \ "northbridge_die", \ "northbridge_proximity", \ - "wireless_module", } + "wireless_proximity", } #define ASMC_MM31_TEMPDESCS { "CPU0 Die Core Temperature", \ "CPU0 Heatsink Temperature", \ @@ -249,7 +249,7 @@ struct asmc_softc { "HDD Bay Temperature", \ "Northbridge Die Core Temperature", \ "Northbridge Proximity Temperature", \ - "Wireless Module Temperature", } + "Wireless Module Proximity Temperature", } #define ASMC_MP_TEMPS { "TA0P", "TCAG", "TCAH", "TCBG", "TCBH", \ "TC0C", "TC0D", "TC0P", "TC1C", "TC1D", \ From owner-svn-src-stable-10@freebsd.org Thu Mar 15 11:00:56 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6A085F419FC; Thu, 15 Mar 2018 11:00:56 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 17B5B7A92B; Thu, 15 Mar 2018 11:00:56 +0000 (UTC) (envelope-from avg@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 1278315395; Thu, 15 Mar 2018 11:00:56 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2FB0t9u006513; Thu, 15 Mar 2018 11:00:55 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2FB0tZr006507; Thu, 15 Mar 2018 11:00:55 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201803151100.w2FB0tZr006507@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 15 Mar 2018 11:00:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r330987 - in stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Group: stable-10 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Commit-Revision: 330987 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-10@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Mar 2018 11:00:56 -0000 Author: avg Date: Thu Mar 15 11:00:55 2018 New Revision: 330987 URL: https://svnweb.freebsd.org/changeset/base/330987 Log: MFC r322245,r329717: MFV r322242: 8373 TXG_WAIT in ZIL commit path MFC r322245: MFV r322242: 8373 TXG_WAIT in ZIL commit path MFC r329717: MFV r329715: 8997 ztest assertion failure in zil_lwb_write_issue Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_tx.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c Thu Mar 15 10:52:08 2018 (r330986) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c Thu Mar 15 11:00:55 2018 (r330987) @@ -1159,7 +1159,7 @@ dmu_tx_delay(dmu_tx_t *tx, uint64_t dirty) } static int -dmu_tx_try_assign(dmu_tx_t *tx, txg_how_t txg_how) +dmu_tx_try_assign(dmu_tx_t *tx, uint64_t txg_how) { dmu_tx_hold_t *txh; spa_t *spa = tx->tx_pool->dp_spa; @@ -1182,13 +1182,13 @@ dmu_tx_try_assign(dmu_tx_t *tx, txg_how_t txg_how) * of the failuremode setting. */ if (spa_get_failmode(spa) == ZIO_FAILURE_MODE_CONTINUE && - txg_how != TXG_WAIT) + !(txg_how & TXG_WAIT)) return (SET_ERROR(EIO)); return (SET_ERROR(ERESTART)); } - if (!tx->tx_waited && + if (!tx->tx_dirty_delayed && dsl_pool_need_dirty_delay(tx->tx_pool)) { tx->tx_wait_dirty = B_TRUE; return (SET_ERROR(ERESTART)); @@ -1308,41 +1308,44 @@ dmu_tx_unassign(dmu_tx_t *tx) } /* - * Assign tx to a transaction group. txg_how can be one of: + * Assign tx to a transaction group; txg_how is a bitmask: * - * (1) TXG_WAIT. If the current open txg is full, waits until there's - * a new one. This should be used when you're not holding locks. - * It will only fail if we're truly out of space (or over quota). + * If TXG_WAIT is set and the currently open txg is full, this function + * will wait until there's a new txg. This should be used when no locks + * are being held. With this bit set, this function will only fail if + * we're truly out of space (or over quota). * - * (2) TXG_NOWAIT. If we can't assign into the current open txg without - * blocking, returns immediately with ERESTART. This should be used - * whenever you're holding locks. On an ERESTART error, the caller - * should drop locks, do a dmu_tx_wait(tx), and try again. + * If TXG_WAIT is *not* set and we can't assign into the currently open + * txg without blocking, this function will return immediately with + * ERESTART. This should be used whenever locks are being held. On an + * ERESTART error, the caller should drop all locks, call dmu_tx_wait(), + * and try again. * - * (3) TXG_WAITED. Like TXG_NOWAIT, but indicates that dmu_tx_wait() - * has already been called on behalf of this operation (though - * most likely on a different tx). + * If TXG_NOTHROTTLE is set, this indicates that this tx should not be + * delayed due on the ZFS Write Throttle (see comments in dsl_pool.c for + * details on the throttle). This is used by the VFS operations, after + * they have already called dmu_tx_wait() (though most likely on a + * different tx). */ int -dmu_tx_assign(dmu_tx_t *tx, txg_how_t txg_how) +dmu_tx_assign(dmu_tx_t *tx, uint64_t txg_how) { int err; ASSERT(tx->tx_txg == 0); - ASSERT(txg_how == TXG_WAIT || txg_how == TXG_NOWAIT || - txg_how == TXG_WAITED); + ASSERT0(txg_how & ~(TXG_WAIT | TXG_NOTHROTTLE)); ASSERT(!dsl_pool_sync_context(tx->tx_pool)); /* If we might wait, we must not hold the config lock. */ - ASSERT(txg_how != TXG_WAIT || !dsl_pool_config_held(tx->tx_pool)); + IMPLY((txg_how & TXG_WAIT), !dsl_pool_config_held(tx->tx_pool)); - if (txg_how == TXG_WAITED) - tx->tx_waited = B_TRUE; + if ((txg_how & TXG_NOTHROTTLE)) + tx->tx_dirty_delayed = B_TRUE; while ((err = dmu_tx_try_assign(tx, txg_how)) != 0) { dmu_tx_unassign(tx); - if (err != ERESTART || txg_how != TXG_WAIT) + if (err != ERESTART || !(txg_how & TXG_WAIT)) return (err); dmu_tx_wait(tx); @@ -1379,12 +1382,12 @@ dmu_tx_wait(dmu_tx_t *tx) tx->tx_wait_dirty = B_FALSE; /* - * Note: setting tx_waited only has effect if the caller - * used TX_WAIT. Otherwise they are going to destroy - * this tx and try again. The common case, zfs_write(), - * uses TX_WAIT. + * Note: setting tx_dirty_delayed only has effect if the + * caller used TX_WAIT. Otherwise they are going to + * destroy this tx and try again. The common case, + * zfs_write(), uses TX_WAIT. */ - tx->tx_waited = B_TRUE; + tx->tx_dirty_delayed = B_TRUE; } else if (spa_suspended(spa) || tx->tx_lasttried_txg == 0) { /* * If the pool is suspended we need to wait until it Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h Thu Mar 15 10:52:08 2018 (r330986) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h Thu Mar 15 11:00:55 2018 (r330987) @@ -230,11 +230,14 @@ typedef enum dmu_object_type { DMU_OTN_ZAP_METADATA = DMU_OT(DMU_BSWAP_ZAP, B_TRUE), } dmu_object_type_t; -typedef enum txg_how { - TXG_WAIT = 1, - TXG_NOWAIT, - TXG_WAITED, -} txg_how_t; +/* + * These flags are intended to be used to specify the "txg_how" + * parameter when calling the dmu_tx_assign() function. See the comment + * above dmu_tx_assign() for more details on the meaning of these flags. + */ +#define TXG_NOWAIT (0ULL) +#define TXG_WAIT (1ULL<<0) +#define TXG_NOTHROTTLE (1ULL<<1) void byteswap_uint64_array(void *buf, size_t size); void byteswap_uint32_array(void *buf, size_t size); @@ -676,7 +679,7 @@ void dmu_tx_hold_spill(dmu_tx_t *tx, uint64_t object); void dmu_tx_hold_sa(dmu_tx_t *tx, struct sa_handle *hdl, boolean_t may_grow); void dmu_tx_hold_sa_create(dmu_tx_t *tx, int total_size); void dmu_tx_abort(dmu_tx_t *tx); -int dmu_tx_assign(dmu_tx_t *tx, enum txg_how txg_how); +int dmu_tx_assign(dmu_tx_t *tx, uint64_t txg_how); void dmu_tx_wait(dmu_tx_t *tx); void dmu_tx_commit(dmu_tx_t *tx); void dmu_tx_mark_netfree(dmu_tx_t *tx); Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_tx.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_tx.h Thu Mar 15 10:52:08 2018 (r330986) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_tx.h Thu Mar 15 11:00:55 2018 (r330987) @@ -66,15 +66,15 @@ struct dmu_tx { /* placeholder for syncing context, doesn't need specific holds */ boolean_t tx_anyobj; - /* has this transaction already been delayed? */ - boolean_t tx_waited; - /* time this transaction was created */ hrtime_t tx_start; /* need to wait for sufficient dirty space */ boolean_t tx_wait_dirty; + /* has this transaction already been delayed? */ + boolean_t tx_dirty_delayed; + int tx_err; #ifdef ZFS_DEBUG uint64_t tx_space_towrite; @@ -124,7 +124,7 @@ typedef struct dmu_tx_callback { * These routines are defined in dmu.h, and are called by the user. */ dmu_tx_t *dmu_tx_create(objset_t *dd); -int dmu_tx_assign(dmu_tx_t *tx, txg_how_t txg_how); +int dmu_tx_assign(dmu_tx_t *tx, uint64_t txg_how); void dmu_tx_commit(dmu_tx_t *tx); void dmu_tx_abort(dmu_tx_t *tx); uint64_t dmu_tx_get_txg(dmu_tx_t *tx); Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Thu Mar 15 10:52:08 2018 (r330986) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Thu Mar 15 11:00:55 2018 (r330987) @@ -125,7 +125,7 @@ * * If dmu_tx_assign() returns ERESTART and zfsvfs->z_assign is TXG_NOWAIT, * then drop all locks, call dmu_tx_wait(), and try again. On subsequent - * calls to dmu_tx_assign(), pass TXG_WAITED rather than TXG_NOWAIT, + * calls to dmu_tx_assign(), pass TXG_NOTHROTTLE in addition to TXG_NOWAIT, * to indicate that this operation has already called dmu_tx_wait(). * This will ensure that we don't retry forever, waiting a short bit * each time. @@ -150,7 +150,7 @@ * rw_enter(...); // grab any other locks you need * tx = dmu_tx_create(...); // get DMU tx * dmu_tx_hold_*(); // hold each object you might modify - * error = dmu_tx_assign(tx, waited ? TXG_WAITED : TXG_NOWAIT); + * error = dmu_tx_assign(tx, (waited ? TXG_NOTHROTTLE : 0) | TXG_NOWAIT); * if (error) { * rw_exit(...); // drop locks * zfs_dirent_unlock(dl); // unlock directory entry Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c Thu Mar 15 10:52:08 2018 (r330986) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c Thu Mar 15 11:00:55 2018 (r330987) @@ -994,7 +994,15 @@ zil_lwb_write_start(zilog_t *zilog, lwb_t *lwb, boolea * to clean up in the event of allocation failure or I/O failure. */ tx = dmu_tx_create(zilog->zl_os); - VERIFY(dmu_tx_assign(tx, TXG_WAIT) == 0); + + /* + * Since we are not going to create any new dirty data, and we + * can even help with clearing the existing dirty data, we + * should not be subject to the dirty data based delays. We + * use TXG_NOTHROTTLE to bypass the delay mechanism. + */ + VERIFY0(dmu_tx_assign(tx, TXG_WAIT | TXG_NOTHROTTLE)); + dsl_dataset_dirty(dmu_objset_ds(zilog->zl_os), tx); txg = dmu_tx_get_txg(tx); From owner-svn-src-stable-10@freebsd.org Thu Mar 15 11:04:31 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EDFACF43062; Thu, 15 Mar 2018 11:04:30 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9A86E7B02E; Thu, 15 Mar 2018 11:04:30 +0000 (UTC) (envelope-from avg@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 95830154EE; Thu, 15 Mar 2018 11:04:30 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2FB4Uwt010413; Thu, 15 Mar 2018 11:04:30 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2FB4Uww010412; Thu, 15 Mar 2018 11:04:30 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201803151104.w2FB4Uww010412@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 15 Mar 2018 11:04:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r330989 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-10 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 330989 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-10@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Mar 2018 11:04:31 -0000 Author: avg Date: Thu Mar 15 11:04:30 2018 New Revision: 330989 URL: https://svnweb.freebsd.org/changeset/base/330989 Log: MFC r330057: add ZFS_ENTER protection to .zfs/snapshot vnode operations that need it Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Thu Mar 15 11:03:39 2018 (r330988) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Thu Mar 15 11:04:30 2018 (r330989) @@ -1071,6 +1071,7 @@ zfsctl_snapdir_readdir(ap) return (error); } + ZFS_ENTER(zfsvfs); for (;;) { uint64_t cookie; uint64_t id; @@ -1087,6 +1088,7 @@ zfsctl_snapdir_readdir(ap) *eofp = 1; error = 0; } + ZFS_EXIT(zfsvfs); return (error); } @@ -1099,6 +1101,7 @@ zfsctl_snapdir_readdir(ap) if (error != 0) { if (error == ENAMETOOLONG) error = 0; + ZFS_EXIT(zfsvfs); return (SET_ERROR(error)); } uio->uio_offset = cookie + dots_offset; @@ -1122,6 +1125,7 @@ zfsctl_snapdir_getattr(ap) uint64_t snap_count; int err; + ZFS_ENTER(zfsvfs); zfsctl_common_getattr(vp, vap); vap->va_ctime = dmu_objset_snap_cmtime(zfsvfs->z_os); vap->va_mtime = vap->va_ctime; @@ -1129,12 +1133,15 @@ zfsctl_snapdir_getattr(ap) if (dsl_dataset_phys(ds)->ds_snapnames_zapobj != 0) { err = zap_count(dmu_objset_pool(ds->ds_objset)->dp_meta_objset, dsl_dataset_phys(ds)->ds_snapnames_zapobj, &snap_count); - if (err != 0) + if (err != 0) { + ZFS_EXIT(zfsvfs); return (err); + } vap->va_nlink += snap_count; } vap->va_size = vap->va_nlink; + ZFS_EXIT(zfsvfs); return (0); } From owner-svn-src-stable-10@freebsd.org Thu Mar 15 22:42:29 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 798DEF5A960; Thu, 15 Mar 2018 22:42:29 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2BB487D230; Thu, 15 Mar 2018 22:42:29 +0000 (UTC) (envelope-from marius@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 269851C13B; Thu, 15 Mar 2018 22:42:29 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2FMgTvm066852; Thu, 15 Mar 2018 22:42:29 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2FMgTfW066851; Thu, 15 Mar 2018 22:42:29 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201803152242.w2FMgTfW066851@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Thu, 15 Mar 2018 22:42:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r331031 - stable/10 X-SVN-Group: stable-10 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: stable/10 X-SVN-Commit-Revision: 331031 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-10@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Mar 2018 22:42:29 -0000 Author: marius Date: Thu Mar 15 22:42:28 2018 New Revision: 331031 URL: https://svnweb.freebsd.org/changeset/base/331031 Log: MFC: r287805 Unconditionally build CTF tools in the bootstrap-tools phase of the build. Stale CTF tools are a frequent source of DTrace issues, and they compile quickly enough that the increase in build time is negligible. Apart from what's described in the original commit message above, this change also fixes building GENERIC kernels, i. e. kernel configurations having "makeoptions WITH_CTF=1", when the host world has been built with WITHOUT_CDDL. Modified: stable/10/Makefile.inc1 Directory Properties: stable/10/ (props changed) Modified: stable/10/Makefile.inc1 ============================================================================== --- stable/10/Makefile.inc1 Thu Mar 15 21:42:49 2018 (r331030) +++ stable/10/Makefile.inc1 Thu Mar 15 22:42:28 2018 (r331031) @@ -1371,11 +1371,9 @@ ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/li ${_bt}-usr.bin/clang/tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport .endif -# dtrace tools are required for older bootstrap env and cross-build -.if ${MK_CDDL} != "no" && \ - ((${BOOTSTRAPPING} < 1000034 && \ - !(${BOOTSTRAPPING} >= 901505 && ${BOOTSTRAPPING} < 999999)) \ - || (${MACHINE} != ${TARGET} || ${MACHINE_ARCH} != ${TARGET_ARCH})) +# Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures +# resulting from missing bug fixes or ELF Toolchain updates. +.if ${MK_CDDL} != "no" _dtrace_tools= cddl/lib/libctf lib/libelf \ lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge From owner-svn-src-stable-10@freebsd.org Thu Mar 15 22:51:14 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1CCA2F5B2A3; Thu, 15 Mar 2018 22:51:14 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BFD5D7D755; Thu, 15 Mar 2018 22:51:13 +0000 (UTC) (envelope-from marius@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 BAD5C1C17A; Thu, 15 Mar 2018 22:51:13 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2FMpDaR068788; Thu, 15 Mar 2018 22:51:13 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2FMpDG5068787; Thu, 15 Mar 2018 22:51:13 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201803152251.w2FMpDG5068787@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Thu, 15 Mar 2018 22:51:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r331033 - stable/10/sys/dev/sdhci X-SVN-Group: stable-10 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: stable/10/sys/dev/sdhci X-SVN-Commit-Revision: 331033 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-10@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Mar 2018 22:51:14 -0000 Author: marius Date: Thu Mar 15 22:51:13 2018 New Revision: 331033 URL: https://svnweb.freebsd.org/changeset/base/331033 Log: MFC: r327315 Add quirks for Intel Denverton eMMC 5.0 controllers. Modified: stable/10/sys/dev/sdhci/sdhci_pci.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sdhci/sdhci_pci.c ============================================================================== --- stable/10/sys/dev/sdhci/sdhci_pci.c Thu Mar 15 22:51:10 2018 (r331032) +++ stable/10/sys/dev/sdhci/sdhci_pci.c Thu Mar 15 22:51:13 2018 (r331033) @@ -118,6 +118,12 @@ static const struct sdhci_device { SDHCI_QUIRK_MMC_DDR52 | SDHCI_QUIRK_CAPS_BIT63_FOR_MMC_HS400 | SDHCI_QUIRK_PRESET_VALUE_BROKEN }, + { 0x19db8086, 0xffff, "Intel Denverton eMMC 5.0 Controller", + SDHCI_QUIRK_INTEL_POWER_UP_RESET | + SDHCI_QUIRK_WAIT_WHILE_BUSY | + SDHCI_QUIRK_MMC_DDR52 | + SDHCI_QUIRK_CAPS_BIT63_FOR_MMC_HS400 | + SDHCI_QUIRK_PRESET_VALUE_BROKEN }, { 0x22948086, 0xffff, "Intel Braswell eMMC 4.5.1 Controller", SDHCI_QUIRK_DATA_TIMEOUT_1MHZ | SDHCI_QUIRK_INTEL_POWER_UP_RESET | From owner-svn-src-stable-10@freebsd.org Thu Mar 15 22:58:34 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AEAC4F5BA6D; Thu, 15 Mar 2018 22:58:34 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 62B9B7DCC7; Thu, 15 Mar 2018 22:58:34 +0000 (UTC) (envelope-from marius@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 5D9981C2CD; Thu, 15 Mar 2018 22:58:34 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2FMwYjq072041; Thu, 15 Mar 2018 22:58:34 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2FMwYP7072040; Thu, 15 Mar 2018 22:58:34 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201803152258.w2FMwYP7072040@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Thu, 15 Mar 2018 22:58:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r331035 - stable/10/sys/dev/sdhci X-SVN-Group: stable-10 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: stable/10/sys/dev/sdhci X-SVN-Commit-Revision: 331035 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-10@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Mar 2018 22:58:35 -0000 Author: marius Date: Thu Mar 15 22:58:34 2018 New Revision: 331035 URL: https://svnweb.freebsd.org/changeset/base/331035 Log: MFC: r327339, r327924 - There is no need to keep the tuning error and re-tuning interrupts enabled (though, no interrupt generation enabled for them) all the time as soon as (re-)tuning is supported; only enable them and let them generate interrupts when actually using (re-)tuning. - Also disable all interrupts except SDHCI_INT_DATA_AVAIL ones while executing tuning and not just their signaling. - Set the tuning error and re-tuning interrupt enable bits based on the SDHCI_TUNING_ENABLED rather than the SDHCI_TUNING_SUPPORTED flag, i. e. only when (re-)tuning is actually used. Currently, this change makes no net difference, though. Modified: stable/10/sys/dev/sdhci/sdhci.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sdhci/sdhci.c ============================================================================== --- stable/10/sys/dev/sdhci/sdhci.c Thu Mar 15 22:58:31 2018 (r331034) +++ stable/10/sys/dev/sdhci/sdhci.c Thu Mar 15 22:58:34 2018 (r331035) @@ -254,7 +254,7 @@ sdhci_tuning_intmask(struct sdhci_slot *slot) uint32_t intmask; intmask = 0; - if (slot->opt & SDHCI_TUNING_SUPPORTED) { + if (slot->opt & SDHCI_TUNING_ENABLED) { intmask |= SDHCI_INT_TUNEERR; if (slot->retune_mode == SDHCI_RETUNE_MODE_2 || slot->retune_mode == SDHCI_RETUNE_MODE_3) @@ -282,7 +282,7 @@ sdhci_init(struct sdhci_slot *slot) slot->intmask |= SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT; } - WR4(slot, SDHCI_INT_ENABLE, slot->intmask | sdhci_tuning_intmask(slot)); + WR4(slot, SDHCI_INT_ENABLE, slot->intmask); WR4(slot, SDHCI_SIGNAL_ENABLE, slot->intmask); } @@ -574,6 +574,7 @@ sdhci_card_task(void *arg, int pending __unused) d = slot->dev; slot->dev = NULL; slot->intmask &= ~sdhci_tuning_intmask(slot); + WR4(slot, SDHCI_INT_ENABLE, slot->intmask); WR4(slot, SDHCI_SIGNAL_ENABLE, slot->intmask); slot->opt &= ~SDHCI_TUNING_ENABLED; SDHCI_UNLOCK(slot); @@ -1250,6 +1251,7 @@ sdhci_generic_tune(device_t brdev __unused, device_t r if (err == 0) { slot->opt |= SDHCI_TUNING_ENABLED; slot->intmask |= sdhci_tuning_intmask(slot); + WR4(slot, SDHCI_INT_ENABLE, slot->intmask); WR4(slot, SDHCI_SIGNAL_ENABLE, slot->intmask); if (slot->retune_ticks) { callout_reset(&slot->retune_callout, slot->retune_ticks, @@ -1318,6 +1320,7 @@ sdhci_exec_tuning(struct sdhci_slot *slot, bool reset) */ intmask = slot->intmask; slot->intmask = SDHCI_INT_DATA_AVAIL; + WR4(slot, SDHCI_INT_ENABLE, SDHCI_INT_DATA_AVAIL); WR4(slot, SDHCI_SIGNAL_ENABLE, SDHCI_INT_DATA_AVAIL); hostctrl2 = RD2(slot, SDHCI_HOST_CONTROL2); @@ -1348,8 +1351,17 @@ sdhci_exec_tuning(struct sdhci_slot *slot, bool reset) DELAY(1000); } + /* + * Restore DMA usage and interrupts. + * Note that the interrupt aggregation code might have cleared + * SDHCI_INT_DMA_END and/or SDHCI_INT_RESPONSE in slot->intmask + * and SDHCI_SIGNAL_ENABLE respectively so ensure SDHCI_INT_ENABLE + * doesn't lose these. + */ slot->opt = opt; slot->intmask = intmask; + WR4(slot, SDHCI_INT_ENABLE, intmask | SDHCI_INT_DMA_END | + SDHCI_INT_RESPONSE); WR4(slot, SDHCI_SIGNAL_ENABLE, intmask); if ((hostctrl2 & (SDHCI_CTRL2_EXEC_TUNING | From owner-svn-src-stable-10@freebsd.org Thu Mar 15 23:01:08 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EBB64F5BDC4; Thu, 15 Mar 2018 23:01:07 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 027467E13F; Thu, 15 Mar 2018 23:01:04 +0000 (UTC) (envelope-from marius@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 BCF9B1C2F7; Thu, 15 Mar 2018 23:01:04 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2FN14vq073094; Thu, 15 Mar 2018 23:01:04 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2FN14Hs073093; Thu, 15 Mar 2018 23:01:04 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201803152301.w2FN14Hs073093@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Thu, 15 Mar 2018 23:01:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r331037 - stable/10/sys/dev/mmc X-SVN-Group: stable-10 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: stable/10/sys/dev/mmc X-SVN-Commit-Revision: 331037 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-10@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Mar 2018 23:01:08 -0000 Author: marius Date: Thu Mar 15 23:01:04 2018 New Revision: 331037 URL: https://svnweb.freebsd.org/changeset/base/331037 Log: MFC: r327355, r327926 - Don't allow userland to switch partitions; it's next to impossible to recover from that, especially when something goes wrong. - When userland changes EXT_CSD, update the kernel copy before using relevant EXT_CSD bits in mmcsd_switch_part(). Modified: stable/10/sys/dev/mmc/mmcsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/mmc/mmcsd.c ============================================================================== --- stable/10/sys/dev/mmc/mmcsd.c Thu Mar 15 23:01:00 2018 (r331036) +++ stable/10/sys/dev/mmc/mmcsd.c Thu Mar 15 23:01:04 2018 (r331037) @@ -914,6 +914,16 @@ mmcsd_ioctl_cmd(struct mmcsd_part *part, struct mmc_io default: break; } + /* + * No partition switching in userland; it's almost impossible + * to recover from that, especially if things go wrong. + */ + if (cmd.opcode == MMC_SWITCH_FUNC && dp != NULL && + (((uint8_t *)dp)[EXT_CSD_PART_CONFIG] & + EXT_CSD_PART_CONFIG_ACC_MASK) != part->type) { + err = EINVAL; + goto out; + } } dev = sc->dev; mmcbus = sc->mmcbus; @@ -934,7 +944,7 @@ mmcsd_ioctl_cmd(struct mmcsd_part *part, struct mmc_io if (part->type == EXT_CSD_PART_CONFIG_ACC_RPMB) { /* * If the request went to the RPMB partition, try to ensure - * that the command actually has completed ... + * that the command actually has completed. */ retries = MMCSD_CMD_RETRIES; do { @@ -946,13 +956,6 @@ mmcsd_ioctl_cmd(struct mmcsd_part *part, struct mmc_io break; DELAY(1000); } while (retries-- > 0); - -switch_back: - /* ... and always switch back to the default partition. */ - err = mmcsd_switch_part(mmcbus, dev, rca, - EXT_CSD_PART_CONFIG_ACC_DEFAULT); - if (err != MMC_ERR_NONE) - goto release; } /* * If EXT_CSD was changed, our copy is outdated now. Specifically, @@ -961,6 +964,17 @@ switch_back: */ if (cmd.opcode == MMC_SWITCH_FUNC) { err = mmc_send_ext_csd(mmcbus, dev, sc->ext_csd); + if (err != MMC_ERR_NONE) + goto release; + } +switch_back: + if (part->type == EXT_CSD_PART_CONFIG_ACC_RPMB) { + /* + * If the request went to the RPMB partition, always switch + * back to the default partition (see mmcsd_switch_part()). + */ + err = mmcsd_switch_part(mmcbus, dev, rca, + EXT_CSD_PART_CONFIG_ACC_DEFAULT); if (err != MMC_ERR_NONE) goto release; } From owner-svn-src-stable-10@freebsd.org Thu Mar 15 23:02:53 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1197BF5C163; Thu, 15 Mar 2018 23:02:53 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AB25C7E60F; Thu, 15 Mar 2018 23:02:52 +0000 (UTC) (envelope-from marius@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 A3AE21C466; Thu, 15 Mar 2018 23:02:52 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2FN2qDM076815; Thu, 15 Mar 2018 23:02:52 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2FN2qBB076814; Thu, 15 Mar 2018 23:02:52 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201803152302.w2FN2qBB076814@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Thu, 15 Mar 2018 23:02:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r331039 - stable/10/sys/dev/mmc X-SVN-Group: stable-10 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: stable/10/sys/dev/mmc X-SVN-Commit-Revision: 331039 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-10@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Mar 2018 23:02:53 -0000 Author: marius Date: Thu Mar 15 23:02:52 2018 New Revision: 331039 URL: https://svnweb.freebsd.org/changeset/base/331039 Log: MFC: r327929 Use the correct revision specifier (EXT_CSD revision rather than system specification version) for deciding whether the EXT_CSD register includes the EXT_CSD_GEN_CMD6_TIME field. Submitted by: Masanobu SAITOH Modified: stable/10/sys/dev/mmc/mmc.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/mmc/mmc.c ============================================================================== --- stable/10/sys/dev/mmc/mmc.c Thu Mar 15 23:02:49 2018 (r331038) +++ stable/10/sys/dev/mmc/mmc.c Thu Mar 15 23:02:52 2018 (r331039) @@ -1870,7 +1870,7 @@ mmc_discover_cards(struct mmc_softc *sc) * units of 10 ms), defaulting to 500 ms. */ ivar->cmd6_time = 500 * 1000; - if (ivar->csd.spec_vers >= 6) + if (ivar->raw_ext_csd[EXT_CSD_REV] >= 6) ivar->cmd6_time = 10 * ivar->raw_ext_csd[EXT_CSD_GEN_CMD6_TIME]; /* Handle HC erase sector size. */ From owner-svn-src-stable-10@freebsd.org Fri Mar 16 15:10:14 2018 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 38D76F55EC8; Fri, 16 Mar 2018 15:10:14 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DA50582C79; Fri, 16 Mar 2018 15:10:13 +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 D0CF325781; Fri, 16 Mar 2018 15:10:13 +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 w2GFADsW059599; Fri, 16 Mar 2018 15:10:13 GMT (envelope-from eugen@FreeBSD.org) Received: (from eugen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2GFADcC059596; Fri, 16 Mar 2018 15:10:13 GMT (envelope-from eugen@FreeBSD.org) Message-Id: <201803161510.w2GFADcC059596@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eugen set sender to eugen@FreeBSD.org using -f From: Eugene Grosbein Date: Fri, 16 Mar 2018 15:10:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r331059 - in stable/10: share/man/man4 sys/netgraph X-SVN-Group: stable-10 X-SVN-Commit-Author: eugen X-SVN-Commit-Paths: in stable/10: share/man/man4 sys/netgraph X-SVN-Commit-Revision: 331059 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-10@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Mar 2018 15:10:14 -0000 Author: eugen Date: Fri Mar 16 15:10:13 2018 New Revision: 331059 URL: https://svnweb.freebsd.org/changeset/base/331059 Log: MFC r329279: add support for user-supplied Host-Uniq tag to ng_pppoe(4). Submitted by: ale Approved by: mav (mentor) Relnotes: yes Differential Revision: https://reviews.freebsd.org/D9270 Modified: stable/10/share/man/man4/ng_pppoe.4 stable/10/sys/netgraph/ng_pppoe.c stable/10/sys/netgraph/ng_pppoe.h Directory Properties: stable/10/ (props changed) Modified: stable/10/share/man/man4/ng_pppoe.4 ============================================================================== --- stable/10/share/man/man4/ng_pppoe.4 Fri Mar 16 15:04:13 2018 (r331058) +++ stable/10/share/man/man4/ng_pppoe.4 Fri Mar 16 15:10:13 2018 (r331059) @@ -35,7 +35,7 @@ .\" $FreeBSD$ .\" $Whistle: ng_pppoe.8,v 1.1 1999/01/25 23:46:27 archie Exp $ .\" -.Dd September 15, 2015 +.Dd February 14, 2018 .Dt NG_PPPOE 4 .Os .Sh NAME @@ -104,12 +104,33 @@ the state machine as a client. It must be newly created and a service name can be given as an argument. It is legal to specify a zero-length service name, this is common on some DSL setups. -It is possible to request a connection to a specific -access concentrator by its name using the "AC-Name\\Service-Name" syntax. -A session request packet will be broadcasted on the Ethernet. +It is possible to request a connection to a specific access concentrator, +and/or set a specific Host-Uniq tag, required by some Internet providers, +using the +.Qq Li [AC-Name\\][Host-Uniq|]Service-Name +syntax. +To set a binary Host-Uniq, it must be encoded as a hexadecimal lowercase +string and prefixed with +.Qq Li 0x , +for example +.Qq Li 0x6d792d746167 +is equivalent to +.Qq Li my-tag . +A session request packet will be broadcast on the Ethernet. This command uses the .Dv ngpppoe_init_data structure shown below. +For example, this init data argument can be used to +connect to +.Qq Li my-isp +service with +.Qq Li my-host +uniq tag, accepting only +.Qq Li remote-ac +as access concentrator: +.Bd -literal -offset indent +"remote-ac\\my-host|my-isp" +.Ed .It Dv NGM_PPPOE_LISTEN Pq Ic pppoe_listen Tell a nominated newly created hook that its session should enter the state machine as a server listener. @@ -258,7 +279,41 @@ struct ngpppoe_maxp { uint16_t data; }; .Ed +.It Dv NGM_PPPOE_SEND_HURL Pq Ic send_hurl +Tell a nominated hook with an active session to send a PADM message with +a HURL tag. +The argument is the URL to be delivered to the client: +.Bd -literal -offset indent +ngctl msg fxp0:orphans send_hurl '{ hook="myHook" data="http://example.net/cpe" }' +.Ed +.It Dv NGM_PPPOE_SEND_MOTM Pq Ic send_motm +Tell a nominated hook with an active session to send a PADM message with +a MOTM tag. +The argument is the message to be delivered to the client: +.Bd -literal -offset indent +ngctl msg fxp0:orphans send_motm '{ hook="myHook" data="Welcome aboard" }' +.Ed .El +.Pp +The two commands above use the same ngpppoe_init_data structure described +above. +.Bl -tag -width 3n +.It Dv NGM_PPPOE_HURL +This command is sent to the node that started this session when a PADM +message with a HURL tag is received, and contains a URL that the host can +pass to a web browser for presentation to the user. +.It Dv NGM_PPPOE_MOTM +This command is sent to the node that started this session when a PADM +message with a MOTM tag is received, and contains a Message Of The +Minute that the host can display to the user. +.El +.Pp +The two commands above use a common data structure: +.Bd -literal -offset 4n +struct ngpppoe_padm { + char msg[PPPOE_PADM_VALUE_SIZE]; +}; +.Ed .Sh SHUTDOWN This node shuts down upon receipt of a .Dv NGM_SHUTDOWN Modified: stable/10/sys/netgraph/ng_pppoe.c ============================================================================== --- stable/10/sys/netgraph/ng_pppoe.c Fri Mar 16 15:04:13 2018 (r331058) +++ stable/10/sys/netgraph/ng_pppoe.c Fri Mar 16 15:10:13 2018 (r331059) @@ -175,6 +175,20 @@ static const struct ng_cmdlist ng_pppoe_cmds[] = { &ng_parse_uint16_type, NULL }, + { + NGM_PPPOE_COOKIE, + NGM_PPPOE_SEND_HURL, + "send_hurl", + &ngpppoe_init_data_state_type, + NULL + }, + { + NGM_PPPOE_COOKIE, + NGM_PPPOE_SEND_MOTM, + "send_motm", + &ngpppoe_init_data_state_type, + NULL + }, { 0 } }; @@ -226,9 +240,11 @@ struct sess_neg { const struct pppoe_tag *tags[NUMTAGS]; u_int service_len; u_int ac_name_len; + u_int host_uniq_len; struct datatag service; struct datatag ac_name; + struct datatag host_uniq; }; typedef struct sess_neg *negp; @@ -589,22 +605,47 @@ static hook_p pppoe_finduniq(node_p node, const struct pppoe_tag *tag) { hook_p hook = NULL; - union uniq uniq; + sessp sp; - bcopy(tag + 1, uniq.bytes, sizeof(void *)); /* Cycle through all known hooks. */ LIST_FOREACH(hook, &node->nd_hooks, hk_hooks) { /* Skip any nonsession hook. */ if (NG_HOOK_PRIVATE(hook) == NULL) continue; - if (uniq.pointer == NG_HOOK_PRIVATE(hook)) + sp = NG_HOOK_PRIVATE(hook); + /* Skip already connected sessions. */ + if (sp->neg == NULL) + continue; + if (sp->neg->host_uniq_len == ntohs(tag->tag_len) && + bcmp(sp->neg->host_uniq.data, (const char *)(tag + 1), + sp->neg->host_uniq_len) == 0) break; } - CTR3(KTR_NET, "%20s: matched %p for %p", __func__, hook, uniq.pointer); + CTR3(KTR_NET, "%20s: matched %p for %p", __func__, hook, sp); return (hook); } +static hook_p +pppoe_findcookie(node_p node, const struct pppoe_tag *tag) +{ + hook_p hook = NULL; + union uniq cookie; + + bcopy(tag + 1, cookie.bytes, sizeof(void *)); + /* Cycle through all known hooks. */ + LIST_FOREACH(hook, &node->nd_hooks, hk_hooks) { + /* Skip any nonsession hook. */ + if (NG_HOOK_PRIVATE(hook) == NULL) + continue; + if (cookie.pointer == NG_HOOK_PRIVATE(hook)) + break; + } + CTR3(KTR_NET, "%20s: matched %p for %p", __func__, hook, cookie.pointer); + + return (hook); +} + /************************************************************************** * Start of Netgraph entrypoints. * **************************************************************************/ @@ -744,17 +785,29 @@ ng_pppoe_rcvmsg(node_p node, item_p item, hook_p lasth case NGM_PPPOE_LISTEN: case NGM_PPPOE_OFFER: case NGM_PPPOE_SERVICE: + case NGM_PPPOE_SEND_HURL: + case NGM_PPPOE_SEND_MOTM: ourmsg = (struct ngpppoe_init_data *)msg->data; if (msg->header.arglen < sizeof(*ourmsg)) { log(LOG_ERR, "ng_pppoe[%x]: init data too " "small\n", node->nd_ID); LEAVE(EMSGSIZE); } - if (msg->header.arglen - sizeof(*ourmsg) > - PPPOE_SERVICE_NAME_SIZE) { - log(LOG_ERR, "ng_pppoe[%x]: service name " - "too big\n", node->nd_ID); - LEAVE(EMSGSIZE); + if (msg->header.cmd == NGM_PPPOE_SEND_HURL || + msg->header.cmd == NGM_PPPOE_SEND_MOTM) { + if (msg->header.arglen - sizeof(*ourmsg) > + PPPOE_PADM_VALUE_SIZE) { + log(LOG_ERR, "ng_pppoe[%x]: message " + "too big\n", node->nd_ID); + LEAVE(EMSGSIZE); + } + } else { + if (msg->header.arglen - sizeof(*ourmsg) > + PPPOE_SERVICE_NAME_SIZE) { + log(LOG_ERR, "ng_pppoe[%x]: service name " + "too big\n", node->nd_ID); + LEAVE(EMSGSIZE); + } } if (msg->header.arglen - sizeof(*ourmsg) < ourmsg->data_len) { @@ -794,6 +847,20 @@ ng_pppoe_rcvmsg(node_p node, item_p item, hook_p lasth if (msg->header.cmd == NGM_PPPOE_SERVICE) break; + /* + * PADM messages are set up on active sessions. + */ + if (msg->header.cmd == NGM_PPPOE_SEND_HURL || + msg->header.cmd == NGM_PPPOE_SEND_MOTM) { + if (sp->state != PPPOE_NEWCONNECTED && + sp->state != PPPOE_CONNECTED) { + log(LOG_NOTICE, "ng_pppoe[%x]: session is not " + "active\n", node->nd_ID); + LEAVE(EISCONN); + } + break; + } + if (sp->state != PPPOE_SNONE) { log(LOG_NOTICE, "ng_pppoe[%x]: Session already " "active\n", node->nd_ID); @@ -848,12 +915,15 @@ ng_pppoe_rcvmsg(node_p node, item_p item, hook_p lasth * Check the hook exists and is Uninitialised. * Send a PADI request, and start the timeout logic. * Store the originator of this message so we can send - * a success of fail message to them later. + * a success or fail message to them later. * Move the session to SINIT. * Set up the session to the correct state and * start it. */ - int i, acnlen = 0, acnsep = 0, srvlen; + int acnpos, acnlen = 0, acnsep = 0; + int hupos, hulen = 0, husep = 0; + int i, srvpos, srvlen; + acnpos = 0; for (i = 0; i < ourmsg->data_len; i++) { if (ourmsg->data[i] == '\\') { acnlen = i; @@ -861,15 +931,56 @@ ng_pppoe_rcvmsg(node_p node, item_p item, hook_p lasth break; } } - srvlen = ourmsg->data_len - acnlen - acnsep; + hupos = acnlen + acnsep; + for (i = hupos; i < ourmsg->data_len; i++) { + if (ourmsg->data[i] == '|') { + hulen = i - hupos; + husep = 1; + break; + } + } + srvpos = hupos + hulen + husep; + srvlen = ourmsg->data_len - srvpos; - bcopy(ourmsg->data, neg->ac_name.data, acnlen); + bcopy(ourmsg->data + acnpos, neg->ac_name.data, acnlen); neg->ac_name_len = acnlen; + neg->host_uniq.hdr.tag_type = PTT_HOST_UNIQ; + if (hulen == 0) { + /* Not provided, generate one */ + neg->host_uniq.hdr.tag_len = htons(sizeof(sp)); + bcopy(&sp, neg->host_uniq.data, sizeof(sp)); + neg->host_uniq_len = sizeof(sp); + } else if (hulen > 2 && ourmsg->data[hupos] == '0' && + ourmsg->data[hupos + 1] == 'x' && hulen % 2 == 0) { + /* Hex encoded */ + static const char hexdig[16] = "0123456789abcdef"; + int j; + + neg->host_uniq.hdr.tag_len = htons((uint16_t)(hulen / 2 - 1)); + for (i = 0; i < hulen - 2; i++) { + for (j = 0; + j < 16 && + ourmsg->data[hupos + 2 + i] != hexdig[j]; + j++); + if (j == 16) + LEAVE(EINVAL); + if (i % 2 == 0) + neg->host_uniq.data[i / 2] = j << 4; + else + neg->host_uniq.data[i / 2] |= j; + } + neg->host_uniq_len = hulen / 2 - 1; + } else { + /* Plain string */ + neg->host_uniq.hdr.tag_len = htons((uint16_t)hulen); + bcopy(ourmsg->data + hupos, neg->host_uniq.data, hulen); + neg->host_uniq_len = hulen; + } + neg->service.hdr.tag_type = PTT_SRV_NAME; neg->service.hdr.tag_len = htons((uint16_t)srvlen); - bcopy(ourmsg->data + acnlen + acnsep, - neg->service.data, srvlen); + bcopy(ourmsg->data + srvpos, neg->service.data, srvlen); neg->service_len = srvlen; pppoe_start(sp); break; @@ -879,7 +990,7 @@ ng_pppoe_rcvmsg(node_p node, item_p item, hook_p lasth * Check the hook exists and is Uninitialised. * Install the service matching string. * Store the originator of this message so we can send - * a success of fail message to them later. + * a success or fail message to them later. * Move the hook to 'LISTENING' */ neg->service.hdr.tag_type = PTT_SRV_NAME; @@ -1019,6 +1130,92 @@ ng_pppoe_rcvmsg(node_p node, item_p item, hook_p lasth privp->max_payload.hdr.tag_len = htons(sizeof(uint16_t)); privp->max_payload.data = htons(*((uint16_t *)msg->data)); break; + case NGM_PPPOE_SEND_HURL: + { + struct mbuf *m; + + /* Generate a packet of that type. */ + m = m_gethdr(M_NOWAIT, MT_DATA); + if (m == NULL) + log(LOG_NOTICE, "ng_pppoe[%x]: session out of " + "mbufs\n", node->nd_ID); + else { + struct pppoe_full_hdr *wh; + struct pppoe_tag *tag; + int error = 0; + + wh = mtod(m, struct pppoe_full_hdr *); + bcopy(&sp->pkt_hdr, wh, sizeof(*wh)); + + /* Revert the stored header to DISC/PADM mode. */ + wh->ph.code = PADM_CODE; + /* + * Configure ethertype depending on what + * was used during sessions stage. + */ + if (wh->eh.ether_type == + ETHERTYPE_PPPOE_3COM_SESS) + wh->eh.ether_type = ETHERTYPE_PPPOE_3COM_DISC; + else + wh->eh.ether_type = ETHERTYPE_PPPOE_DISC; + /* + * Add PADM message and adjust sizes. + */ + tag = (void *)(&wh->ph + 1); + tag->tag_type = PTT_HURL; + tag->tag_len = htons(ourmsg->data_len); + strncpy((char *)(tag + 1), ourmsg->data, ourmsg->data_len); + m->m_pkthdr.len = m->m_len = sizeof(*wh) + sizeof(*tag) + + ourmsg->data_len; + wh->ph.length = htons(sizeof(*tag) + ourmsg->data_len); + NG_SEND_DATA_ONLY(error, + privp->ethernet_hook, m); + } + break; + } + case NGM_PPPOE_SEND_MOTM: + { + struct mbuf *m; + + /* Generate a packet of that type. */ + m = m_gethdr(M_NOWAIT, MT_DATA); + if (m == NULL) + log(LOG_NOTICE, "ng_pppoe[%x]: session out of " + "mbufs\n", node->nd_ID); + else { + struct pppoe_full_hdr *wh; + struct pppoe_tag *tag; + int error = 0; + + wh = mtod(m, struct pppoe_full_hdr *); + bcopy(&sp->pkt_hdr, wh, sizeof(*wh)); + + /* Revert the stored header to DISC/PADM mode. */ + wh->ph.code = PADM_CODE; + /* + * Configure ethertype depending on what + * was used during sessions stage. + */ + if (wh->eh.ether_type == + ETHERTYPE_PPPOE_3COM_SESS) + wh->eh.ether_type = ETHERTYPE_PPPOE_3COM_DISC; + else + wh->eh.ether_type = ETHERTYPE_PPPOE_DISC; + /* + * Add PADM message and adjust sizes. + */ + tag = (void *)(&wh->ph + 1); + tag->tag_type = PTT_MOTM; + tag->tag_len = htons(ourmsg->data_len); + strncpy((char *)(tag + 1), ourmsg->data, ourmsg->data_len); + m->m_pkthdr.len = m->m_len = sizeof(*wh) + sizeof(*tag) + + ourmsg->data_len; + wh->ph.length = htons(sizeof(*tag) + ourmsg->data_len); + NG_SEND_DATA_ONLY(error, + privp->ethernet_hook, m); + } + break; + } default: LEAVE(EINVAL); } @@ -1061,10 +1258,6 @@ pppoe_start(sessp sp) node_p node = NG_HOOK_NODE(hook); priv_p privp = NG_NODE_PRIVATE(node); negp neg = sp->neg; - struct { - struct pppoe_tag hdr; - union uniq data; - } __packed uniqtag; struct mbuf *m0; int error; @@ -1080,11 +1273,8 @@ pppoe_start(sessp sp) memcpy((void *)&neg->pkt->pkt_header.eh, &privp->eh, sizeof(struct ether_header)); neg->pkt->pkt_header.ph.code = PADI_CODE; - uniqtag.hdr.tag_type = PTT_HOST_UNIQ; - uniqtag.hdr.tag_len = htons((u_int16_t)sizeof(uniqtag.data)); - uniqtag.data.pointer = sp; init_tags(sp); - insert_tag(sp, &uniqtag.hdr); + insert_tag(sp, &neg->host_uniq.hdr); insert_tag(sp, &neg->service.hdr); if (privp->max_payload.data != 0) insert_tag(sp, &privp->max_payload.hdr); @@ -1163,6 +1353,52 @@ send_maxp(sessp sp, const struct pppoe_tag *tag) return (error); } +static int +send_hurl(sessp sp, const struct pppoe_tag *tag) +{ + int error, tlen; + struct ng_mesg *msg; + struct ngpppoe_padm *padm; + + CTR2(KTR_NET, "%20s: called %d", __func__, sp->Session_ID); + + NG_MKMESSAGE(msg, NGM_PPPOE_COOKIE, NGM_PPPOE_HURL, + sizeof(struct ngpppoe_padm), M_NOWAIT); + if (msg == NULL) + return (ENOMEM); + + padm = (struct ngpppoe_padm *)msg->data; + tlen = min(PPPOE_PADM_VALUE_SIZE - 1, ntohs(tag->tag_len)); + strncpy(padm->msg, (const char *)(tag + 1), tlen); + padm->msg[tlen] = '\0'; + NG_SEND_MSG_ID(error, NG_HOOK_NODE(sp->hook), msg, sp->creator, 0); + + return (error); +} + +static int +send_motm(sessp sp, const struct pppoe_tag *tag) +{ + int error, tlen; + struct ng_mesg *msg; + struct ngpppoe_padm *padm; + + CTR2(KTR_NET, "%20s: called %d", __func__, sp->Session_ID); + + NG_MKMESSAGE(msg, NGM_PPPOE_COOKIE, NGM_PPPOE_MOTM, + sizeof(struct ngpppoe_padm), M_NOWAIT); + if (msg == NULL) + return (ENOMEM); + + padm = (struct ngpppoe_padm *)msg->data; + tlen = min(PPPOE_PADM_VALUE_SIZE - 1, ntohs(tag->tag_len)); + strncpy(padm->msg, (const char *)(tag + 1), tlen); + padm->msg[tlen] = '\0'; + NG_SEND_MSG_ID(error, NG_HOOK_NODE(sp->hook), msg, sp->creator, 0); + + return (error); +} + /* * Receive data from session hook and do something with it. */ @@ -1320,6 +1556,7 @@ ng_pppoe_rcvdata_ether(hook_p hook, item_p item) const priv_p privp = NG_NODE_PRIVATE(node); sessp sp; const struct pppoe_tag *utag = NULL, *tag = NULL; + const struct pppoe_tag sntag = { PTT_SRV_NAME, 0 }; const struct pppoe_full_hdr *wh; const struct pppoe_hdr *ph; negp neg = NULL; @@ -1409,11 +1646,8 @@ ng_pppoe_rcvdata_ether(hook_p hook, item_p item) * processing. */ tag = get_tag(ph, PTT_SRV_NAME); - if (tag == NULL) { - CTR1(KTR_NET, "%20s: PADI w/o Service-Name", - __func__); - LEAVE(ENETUNREACH); - } + if (tag == NULL) + tag = &sntag; /* * First, try to match Service-Name against our @@ -1438,8 +1672,7 @@ ng_pppoe_rcvdata_ether(hook_p hook, item_p item) * For now simply accept the first we receive. */ utag = get_tag(ph, PTT_HOST_UNIQ); - if ((utag == NULL) || - (ntohs(utag->tag_len) != sizeof(sp))) { + if (utag == NULL) { log(LOG_NOTICE, "ng_pppoe[%x]: no host " "unique field\n", node->nd_ID); LEAVE(ENETUNREACH); @@ -1529,7 +1762,7 @@ ng_pppoe_rcvdata_ether(hook_p hook, item_p item) LEAVE(ENETUNREACH); } - sendhook = pppoe_finduniq(node, utag); + sendhook = pppoe_findcookie(node, utag); if (sendhook == NULL) LEAVE(ENETUNREACH); @@ -1605,8 +1838,7 @@ ng_pppoe_rcvdata_ether(hook_p hook, item_p item) * set us into Session mode. */ utag = get_tag(ph, PTT_HOST_UNIQ); - if ((utag == NULL) || - (ntohs(utag->tag_len) != sizeof(sp))) { + if (utag == NULL) { LEAVE (ENETUNREACH); } sendhook = pppoe_finduniq(node, utag); @@ -1659,6 +1891,19 @@ ng_pppoe_rcvdata_ether(hook_p hook, item_p item) /* Disconnect that hook. */ ng_rmhook_self(sp->hook); break; + case PADM_CODE: + /* + * We are a client: + * find matching peer/session combination. + */ + sp = pppoe_findsession(privp, wh); + if (sp == NULL) + LEAVE (ENETUNREACH); + if ((tag = get_tag(ph, PTT_HURL))) + send_hurl(sp, tag); + if ((tag = get_tag(ph, PTT_MOTM))) + send_motm(sp, tag); + break; default: LEAVE(EPFNOSUPPORT); } @@ -1781,7 +2026,7 @@ ng_pppoe_disconnect(hook_p hook) struct mbuf *m; /* Generate a packet of that type. */ - MGETHDR(m, M_NOWAIT, MT_DATA); + m = m_gethdr(M_NOWAIT, MT_DATA); if (m == NULL) log(LOG_NOTICE, "ng_pppoe[%x]: session out of " "mbufs\n", node->nd_ID); @@ -1791,8 +2036,6 @@ ng_pppoe_disconnect(hook_p hook) int msglen = strlen(SIGNOFF); int error = 0; - m->m_pkthdr.rcvif = NULL; - m->m_pkthdr.len = m->m_len = sizeof(*wh); wh = mtod(m, struct pppoe_full_hdr *); bcopy(&sp->pkt_hdr, wh, sizeof(*wh)); @@ -1815,8 +2058,8 @@ ng_pppoe_disconnect(hook_p hook) tag->tag_type = PTT_GEN_ERR; tag->tag_len = htons((u_int16_t)msglen); strncpy((char *)(tag + 1), SIGNOFF, msglen); - m->m_pkthdr.len = (m->m_len += sizeof(*tag) + - msglen); + m->m_pkthdr.len = m->m_len = sizeof(*wh) + sizeof(*tag) + + msglen; wh->ph.length = htons(sizeof(*tag) + msglen); NG_SEND_DATA_ONLY(error, privp->ethernet_hook, m); @@ -1933,6 +2176,8 @@ scan_tags(sessp sp, const struct pppoe_hdr* ph) case PTT_SYS_ERR: case PTT_GEN_ERR: case PTT_MAX_PAYL: + case PTT_HURL: + case PTT_MOTM: break; } pt = (const struct pppoe_tag*)ptn; Modified: stable/10/sys/netgraph/ng_pppoe.h ============================================================================== --- stable/10/sys/netgraph/ng_pppoe.h Fri Mar 16 15:04:13 2018 (r331058) +++ stable/10/sys/netgraph/ng_pppoe.h Fri Mar 16 15:10:13 2018 (r331059) @@ -52,8 +52,10 @@ #define NGM_PPPOE_COOKIE 1089893072 #define NGM_PPPOE_SETMAXP_COOKIE 1441624322 +#define NGM_PPPOE_PADM_COOKIE 1488405822 #define PPPOE_SERVICE_NAME_SIZE 64 /* for now */ +#define PPPOE_PADM_VALUE_SIZE 128 /* for now */ /* Hook names */ #define NG_PPPOE_HOOK_ETHERNET "ethernet" @@ -84,7 +86,11 @@ enum cmd { NGM_PPPOE_SETMODE = 12, /* set to standard or compat modes */ NGM_PPPOE_GETMODE = 13, /* see current mode */ NGM_PPPOE_SETENADDR = 14, /* set Ethernet address */ - NGM_PPPOE_SETMAXP = 15 /* Set PPP-Max-Payload value */ + NGM_PPPOE_SETMAXP = 15, /* Set PPP-Max-Payload value */ + NGM_PPPOE_SEND_HURL = 16, /* Send PADM HURL message */ + NGM_PPPOE_HURL = 17, /* HURL for informational purposes */ + NGM_PPPOE_SEND_MOTM = 18, /* Send PADM MOTM message */ + NGM_PPPOE_MOTM = 19 /* MOTM for informational purposes */ }; /*********************** @@ -157,6 +163,13 @@ struct ngpppoe_maxp { uint16_t data; }; +/* + * This structure is used to send PADM messages from server to client. + */ +struct ngpppoe_padm { + char msg[PPPOE_PADM_VALUE_SIZE]; +}; + /******************************************************************** * Constants and definitions specific to pppoe ********************************************************************/ @@ -171,6 +184,7 @@ struct ngpppoe_maxp { #define PADR_CODE 0x19 #define PADS_CODE 0x65 #define PADT_CODE 0xa7 +#define PADM_CODE 0xd3 /* Tag identifiers */ #if BYTE_ORDER == BIG_ENDIAN @@ -181,6 +195,8 @@ struct ngpppoe_maxp { #define PTT_AC_COOKIE (0x0104) #define PTT_VENDOR (0x0105) #define PTT_RELAY_SID (0x0110) +#define PTT_HURL (0x0111) /* PPPoE Extensions (CARREL) */ +#define PTT_MOTM (0x0112) /* PPPoE Extensions (CARREL) */ #define PTT_MAX_PAYL (0x0120) /* PPP-Max-Payload (RFC4638) */ #define PTT_SRV_ERR (0x0201) #define PTT_SYS_ERR (0x0202) @@ -198,6 +214,8 @@ struct ngpppoe_maxp { #define PTT_AC_COOKIE (0x0401) #define PTT_VENDOR (0x0501) #define PTT_RELAY_SID (0x1001) +#define PTT_HURL (0x1101) /* PPPoE Extensions (CARREL) */ +#define PTT_MOTM (0x1201) /* PPPoE Extensions (CARREL) */ #define PTT_MAX_PAYL (0x2001) /* PPP-Max-Payload (RFC4638) */ #define PTT_SRV_ERR (0x0102) #define PTT_SYS_ERR (0x0202)